diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-04-19 14:54:41 -0300 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-04-19 14:54:41 -0300 |
commit | ebd38828e38760954affea2c5c9073497c2926a7 (patch) | |
tree | fb9e11bb3681fd92a2039bd8f3f764fc63c40b51 /log-fourier_integrator.cpp | |
parent | 1cd4b73e11fed320b87900a1636d88cc42e7be5f (diff) | |
download | code-ebd38828e38760954affea2c5c9073497c2926a7.tar.gz code-ebd38828e38760954affea2c5c9073497c2926a7.tar.bz2 code-ebd38828e38760954affea2c5c9073497c2926a7.zip |
Playing with step size contral
Diffstat (limited to 'log-fourier_integrator.cpp')
-rw-r--r-- | log-fourier_integrator.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/log-fourier_integrator.cpp b/log-fourier_integrator.cpp index ffbce1d..eb72b49 100644 --- a/log-fourier_integrator.cpp +++ b/log-fourier_integrator.cpp @@ -85,6 +85,8 @@ int main(int argc, char* argv[]) { Real β = 0; while (β < βₘₐₓ) { Real ΔC = 100; + Real ΔC₀ = 100; + unsigned it = 0; while (ΔC > ε) { std::vector<Real> RddfC(N); for (unsigned n = 0; n < N; n++) { @@ -119,6 +121,20 @@ int main(int argc, char* argv[]) { μ *= Cₜ[0]; + if (ΔC < ΔC₀) { + ΔC₀ = ΔC; + it = 0; + γ = std::min(1.01 * γ, 1.0); + } else { + it++; + } + + if (it > 1000) { + std::cerr << "Decreased!" << std::endl; + γ = std::max(0.5 * γ, 1e-6); + it = 0; + } + // std::cerr << ΔC << std::endl; } @@ -138,7 +154,7 @@ int main(int argc, char* argv[]) { } E *= β; - std::cerr << β << " " << μ << " " << Ĉₜ[0].real() << " " << E << std::endl; + std::cerr << β << " " << μ << " " << Ĉₜ[0].real() << " " << E << " " << γ << std::endl; β += Δβ; } |