1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// SPDX-License-Identifier: AGPL-3.0-or-later
//! Vector Mixing Operations for Self-Consistent Field Solvers
//!
//! **Physics-Agnostic Mixing Primitives**
//!
//! Generic vector mixing operations used in iterative solvers:
//! - Linear mixing: simple damped iteration
//! - Broyden mixing: quasi-Newton acceleration with history
//!
//! ## Applications
//!
//! - **Nuclear physics**: HFB density mixing (validated by hotSpring)
//! - **DFT**: Electron density mixing in Kohn-Sham iterations
//! - **Chemistry**: Coupled-cluster amplitude mixing
//! - **Electrostatics**: Poisson-Boltzmann SCF convergence
//! - **General**: Any fixed-point iteration F(x) = x
//!
//! ## Algorithm
//!
//! ### Linear Mixing
//! ```text
//! x_{n+1} = (1-α)·x_n + α·F(x_n)
//! ```
//! Safe but slow convergence. Use for warmup (first 3-5 iterations).
//!
//! ### Modified Broyden II
//! ```text
//! x_{n+1} = x_n + α·r_n - Σ_m γ_m·(Δx_m + α·Δr_m)
//! ```
//! Where `r_n` = `F(x_n)` - `x_n` is the residual.
//! Fast convergence (quadratic near solution) but requires history management.
//!
//! ## Usage
//!
//! ```rust,ignore
//! use barracuda::ops::mixing::{LinearMixer, BroydenMixer};
//!
//! // For warmup or simple problems
//! let linear = LinearMixer::new(device, vec_dim, 0.5)?;
//! let x_mixed = linear.mix(&x_old, &x_computed).await?;
//!
//! // For production SCF
//! let broyden = BroydenMixer::new(device, vec_dim, 8)?; // 8 history vectors
//! let x_mixed = broyden.update(&x, &residual).await?;
//! ```
//!
//! ## Deep Debt Compliance
//!
//! - Pure WGSL (f64 via `SHADER_F64`)
//! - Physics-agnostic (no domain-specific parameters)
//! - Validated by hotSpring nuclear EOS (169/169 acceptance checks)
pub use ;
/// Recommended mixing parameters for different problem types