summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2025-05-18 18:29:28 -0300
committerJaron Kent-Dobias <jaron@kent-dobias.com>2025-05-18 18:29:28 -0300
commit2653586bab4f9519e18be93caea2dea7f891a8e6 (patch)
tree075bfe4ac5ababfb8a4bbb5ef7a9e7db9e40f9b1
parenta019e4827076b85b89a0a0f58da2bfae4927820c (diff)
downloadcode-2653586bab4f9519e18be93caea2dea7f891a8e6.tar.gz
code-2653586bab4f9519e18be93caea2dea7f891a8e6.tar.bz2
code-2653586bab4f9519e18be93caea2dea7f891a8e6.zip
Neutral refactoring, edited .gitignore
-rw-r--r--.gitignore1
-rw-r--r--log-fourier.cpp35
-rw-r--r--log-fourier.hpp8
-rw-r--r--log-fourier_integrator.cpp10
4 files changed, 28 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 35be3ad..377d382 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ get_energy
integrator
fftw.wisdom
log_get_energy
+log_get_energy_long
diff --git a/log-fourier.cpp b/log-fourier.cpp
index 1fa57c3..07429f1 100644
--- a/log-fourier.cpp
+++ b/log-fourier.cpp
@@ -135,14 +135,14 @@ std::string logFourierFile(std::string prefix, unsigned p, unsigned s, Real λ,
return prefix + "_" + std::to_string(p) + "_" + std::to_string(s) + "_" + std::to_string(λ) + "_" + std::to_string(τ₀) + "_" + std::to_string(β) + "_" + std::to_string(log2n) + "_" + std::to_string(Δτ) + "_" + std::to_string(shift) + ".dat";
}
-void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ct, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
+void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ĉ, const std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
unsigned N = std::pow(2, log2n);
std::ofstream outfile(logFourierFile("C", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
outfile.write((const char*)(C.data()), N * sizeof(Real));
outfile.close();
std::ofstream outfileCt(logFourierFile("Ct", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
- outfileCt.write((const char*)(Ct.data()), N * sizeof(Complex));
+ outfileCt.write((const char*)(Ĉ.data()), N * sizeof(Complex));
outfileCt.close();
std::ofstream outfileR(logFourierFile("R", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
@@ -150,11 +150,11 @@ void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, cons
outfileR.close();
std::ofstream outfileRt(logFourierFile("Rt", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
- outfileRt.write((const char*)(Rt.data()), N * sizeof(Complex));
+ outfileRt.write((const char*)(Ȓ.data()), N * sizeof(Complex));
outfileRt.close();
}
-bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Complex>& Ct, std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
+bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Complex>& Ĉ, std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
std::ifstream cfile(logFourierFile("C", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::binary);
std::ifstream rfile(logFourierFile("R", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::binary);
std::ifstream ctfile(logFourierFile("Ct", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::binary);
@@ -172,33 +172,34 @@ bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Comp
rfile.read((char*)(R.data()), N * sizeof(Real));
rfile.close();
- ctfile.read((char*)(Ct.data()), N * sizeof(Complex));
+ ctfile.read((char*)(Ĉ.data()), N * sizeof(Complex));
ctfile.close();
- rtfile.read((char*)(Rt.data()), N * sizeof(Complex));
+ rtfile.read((char*)(Ȓ.data()), N * sizeof(Complex));
rtfile.close();
return true;
}
-std::tuple<std::vector<Complex>, std::vector<Complex>> RddfCtdfCt(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ) {
- std::vector<Real> dfC(C.size());
- std::vector<Real> RddfC(C.size());
+std::tuple<std::vector<Complex>, std::vector<Complex>> ΣD(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, Real β, unsigned p, unsigned s, Real λ) {
+ std::vector<Real> D(C.size());
+ std::vector<Real> Σ(C.size());
+ Real β² = std::pow(β, 2);
for (unsigned n = 0; n < C.size(); n++) {
- RddfC[n] = R[n] * ddf(λ, p, s, C[n]);
- dfC[n] = df(λ, p, s, C[n]);
+ D[n] = β² * df(λ, p, s, C[n]);
+ Σ[n] = β² * R[n] * ddf(λ, p, s, C[n]);
}
- std::vector<Complex> RddfCt = fft.fourier(RddfC, false);
- std::vector<Complex> dfCt = fft.fourier(dfC, true);
+ std::vector<Complex> Σhat = fft.fourier(Σ, false);
+ std::vector<Complex> Dhat = fft.fourier(D, true);
- return {RddfCt, dfCt};
+ return {Σhat, Dhat};
}
-Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Complex>& Ct, const std::vector<Real>& R, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β) {
- auto [RddfCt, dfCt] = RddfCtdfCt(fft, C, R, p, s, λ);
+Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Complex>& Ĉ, const std::vector<Real>& R, const std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β) {
+ auto [Σhat, Dhat] = ΣD(fft, C, R, β, p, s, λ);
Real Γ₀ = 1.0;
- return ((2 * Γ₀ * std::conj(Rt[0]) + std::pow(β, 2) * (RddfCt[0] * Ct[0] + dfCt[0] * std::conj(Rt[0]))) / Ct[0]).real();
+ return (((2 * Γ₀ + Dhat[0]) * std::conj(Ȓ[0]) + Σhat[0] * Ĉ[0]) / Ĉ[0]).real();
}
Real energy(const LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real β) {
diff --git a/log-fourier.hpp b/log-fourier.hpp
index 29717cd..5651ddb 100644
--- a/log-fourier.hpp
+++ b/log-fourier.hpp
@@ -42,13 +42,13 @@ public:
std::string logFourierFile(std::string prefix, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real shift);
-void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ct, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real shift);
+void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ĉ, const std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real shift);
-bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Complex>& Ct, std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real shift);
+bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Complex>& Ĉ, std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real shift);
-std::tuple<std::vector<Complex>, std::vector<Complex>> RddfCtdfCt(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ);
+std::tuple<std::vector<Complex>, std::vector<Complex>> ΣD(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, Real β, unsigned p, unsigned s, Real λ);
-Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Complex>& Ct, const std::vector<Real>& R, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β);
+Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Complex>& Ĉ, const std::vector<Real>& Ȓ, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β);
Real energy(const LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real β);
diff --git a/log-fourier_integrator.cpp b/log-fourier_integrator.cpp
index 4490b71..f2a88c2 100644
--- a/log-fourier_integrator.cpp
+++ b/log-fourier_integrator.cpp
@@ -143,7 +143,7 @@ int main(int argc, char* argv[]) {
Real ΔCₜ = 100;
Real ΔCₜ₋₁ = 101;
while (ΔCₜ > ε) {
- auto [RddfCt, dfCt] = RddfCtdfCt(fft, Cₜ, Rₜ, p, s, λ);
+ auto [Σ, D] = ΣD(fft, Cₜ, Rₜ, β, p, s, λ);
std::vector<Complex> Ĉₜ₊₁(N);
std::vector<Complex> Ȓₜ₊₁(N);
@@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
while (std::abs(C₀ - 1) > ε) {
for (unsigned n = 0; n < N; n++) {
- Ĉₜ₊₁[n] = ((2 * Γ[n] * std::conj(Ȓₜ[n]) + std::pow(β, 2) * (RddfCt[n] * Ĉₜ[n] + dfCt[n] * std::conj(Ȓₜ[n]))) / (μₜ + II * fft.ν(n))).real();
+ Ĉₜ₊₁[n] = (((2 * Γ[n] + D[n]) * std::conj(Ȓₜ[n]) + Σ[n] * Ĉₜ[n]) / (μₜ + II * fft.ν(n))).real();
}
C₀ = C0(fft, Ĉₜ₊₁);
if (C₀ > 1) {
@@ -171,13 +171,13 @@ int main(int argc, char* argv[]) {
ΔCₜ = 0;
for (unsigned n = 0; n < N; n++) {
- ΔCₜ += std::norm((2 * Γ[n] * std::conj(Ȓₜ[n]) + std::pow(β, 2) * (RddfCt[n] * Ĉₜ[n] + dfCt[n] * std::conj(Ȓₜ[n]))) - Ĉₜ[n] * (μₜ + II * fft.ν(n)));
- ΔCₜ += std::norm(((Real)1.0 + std::pow(β, 2) * RddfCt[n] * Ȓₜ[n]) - Ȓₜ[n] * (μₜ + II * fft.ν(n)));
+ ΔCₜ += std::norm(((2 * Γ[n] + D[n]) * std::conj(Ȓₜ[n]) + Σ[n] * Ĉₜ[n]) - Ĉₜ[n] * (μₜ + II * fft.ν(n)));
+ ΔCₜ += std::norm(((Real)1.0 + Σ[n] * Ȓₜ[n]) - Ȓₜ[n] * (μₜ + II * fft.ν(n)));
}
ΔCₜ = sqrt(ΔCₜ) / (2*N);
for (unsigned n = 0; n < N; n++) {
- Ȓₜ₊₁[n] = ((Real)1.0 + std::pow(β, 2) * RddfCt[n] * Ȓₜ[n]) / (μₜ + II * fft.ν(n));
+ Ȓₜ₊₁[n] = ((Real)1.0 + Σ[n] * Ȓₜ[n]) / (μₜ + II * fft.ν(n));
}
std::vector<Real> Cₜ₊₁ = fft.inverse(Ĉₜ₊₁);