summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2025-04-02 22:24:48 -0300
committerJaron Kent-Dobias <jaron@kent-dobias.com>2025-04-02 22:24:48 -0300
commit3e4a32352e30c549a4f333f2a6900e04b136c29b (patch)
tree487bb9838ad4424a01805d82e2b175abc69908ed
parent24a796d66fafa36ac1777b961eae7a338c6873d3 (diff)
downloadcode-3e4a32352e30c549a4f333f2a6900e04b136c29b.tar.gz
code-3e4a32352e30c549a4f333f2a6900e04b136c29b.tar.bz2
code-3e4a32352e30c549a4f333f2a6900e04b136c29b.zip
Adjust damping with failures
-rw-r--r--fourier_integrator.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/fourier_integrator.cpp b/fourier_integrator.cpp
index 4ee9150..e2446fd 100644
--- a/fourier_integrator.cpp
+++ b/fourier_integrator.cpp
@@ -71,12 +71,13 @@ int main(int argc, char* argv[]) {
unsigned log2n = 8;
Real τₘₐₓ = 20 / M_PI;
- unsigned maxIterations = 100;
+ unsigned maxIterations = 1000;
Real ε = 1e-14;
+ Real γ = 0;
int opt;
- while ((opt = getopt(argc, argv, "p:2:T:t:y:d:I:")) != -1) {
+ while ((opt = getopt(argc, argv, "p:2:T:t:y:d:I:g:")) != -1) {
switch (opt) {
case 'p':
p = atoi(optarg);
@@ -99,6 +100,9 @@ int main(int argc, char* argv[]) {
case 'I':
maxIterations = (unsigned)atof(optarg);
break;
+ case 'g':
+ γ = atof(optarg);
+ break;
default:
exit(1);
}
@@ -132,8 +136,9 @@ int main(int argc, char* argv[]) {
Real y = 0;
while (y += Δy, y <= yₘₐₓ) {
+ Real ΔC = 1;;
unsigned it = 0;
- while (true) {
+ while (sqrt(ΔC / C.size()) > ε) {
it++;
std::vector<Real> RddfC(C.size());
for (unsigned i = 0; i < C.size(); i++) {
@@ -155,24 +160,28 @@ int main(int argc, char* argv[]) {
Rtnew[i] = (1.0 + pow(y, 2) * RddfCt[i] * Rt[i]) / (z + 1i * ω);
}
- Rt = Rtnew;
+ for (unsigned i = 0; i < Rt.size(); i++) {
+ Rt[i] += γ * (Rtnew[i] - Rt[i]);
+ }
for (unsigned i = 0; i < Rt.size(); i++) {
Real ω = i * Δω;
Ctnew[i] = (Γ₀ * std::conj(Rt[i]) / (1 + pow(τ₀ * ω, 2)) + pow(y, 2) * (RddfCt[i] * Ct[i] + dfCt[i] * std::conj(Rt[i]))) / (z + 1i * ω);
}
- Ct = Ctnew;
+ for (unsigned i = 0; i < Ct.size(); i++) {
+ Ct[i] += γ * (Ctnew[i] - Ct[i]);
+ }
std::vector<Real> Cnew = fft.inverse(Ctnew);
std::vector<Real> Rnew = fft.inverse(Rtnew);
- Real ΔC = 0;
+ ΔC = 0;
for (unsigned i = 0; i < Cnew.size(); i++) {
ΔC += pow(Cnew[i] - C[i], 2);
}
- z *= sqrt(Cnew[0]);
+ z *= Cnew[0];
Real energy = 0;
@@ -185,12 +194,9 @@ int main(int argc, char* argv[]) {
std::cerr << "y " << y << " iteration " << it << ": " << sqrt(ΔC / C.size()) << " " << pow(y, 2) / z << " " << energy << std::endl;
- if (sqrt(ΔC / C.size()) < ε) break;
if (it > maxIterations) {
- y -= Δy;
- Δy /= 2;
- y += Δy;
it = 0;
+ γ /= 2;
}
}
}