diff options
Diffstat (limited to 'langevin.cpp')
-rw-r--r-- | langevin.cpp | 58 |
1 files changed, 8 insertions, 50 deletions
diff --git a/langevin.cpp b/langevin.cpp index 1181173..9aec7c8 100644 --- a/langevin.cpp +++ b/langevin.cpp @@ -18,6 +18,9 @@ #define PSPIN_P 3 const int p = PSPIN_P; // polynomial degree of Hamiltonian using Complex = std::complex<Real>; +using RealVector = Vector<Real>; +using RealMatrix = Matrix<Real>; +using RealTensor = Tensor<Real, p>; using ComplexVector = Vector<Complex>; using ComplexMatrix = Matrix<Complex>; using ComplexTensor = Tensor<Complex, p>; @@ -144,12 +147,12 @@ int main(int argc, char* argv[]) { std::normal_distribution<Real> Red(0, 1); - Vector<Real> zMin = randomMinimum(ReJ, Red, r, ε); + RealVector zMin = randomMinimum(ReJ, Red, r, ε); auto [Hr, dHr, ddHr] = hamGradHess(ReJ, zMin); Eigen::EigenSolver<Matrix<Real>> eigenS(ddHr - (dHr * zMin.transpose() + zMin.dot(dHr) * Matrix<Real>::Identity(zMin.size(), zMin.size()) + (ddHr * zMin) * zMin.transpose()) / (Real)zMin.size() + 2.0 * zMin * zMin.transpose()); std::cout << eigenS.eigenvalues().transpose() << std::endl; for (unsigned i = 0; i < N; i++) { - Vector<Real> zNew = normalize(zMin + 0.01 * eigenS.eigenvectors().col(i).real()); + RealVector zNew = normalize(zMin + 0.01 * eigenS.eigenvectors().col(i).real()); std::cout << getHamiltonian(ReJ, zNew) - Hr << " " << real(eigenS.eigenvectors().col(i).dot(zMin)) << std::endl; } std::cout << std::endl; @@ -157,17 +160,8 @@ int main(int argc, char* argv[]) { complex_normal_distribution<Real> d(0, 1, 0); - ComplexTensor J = generateCouplings<Complex, p>(N, complex_normal_distribution<Real>(0, σ, κ), r.engine()); - - std::function<Real(const ComplexTensor&, const ComplexVector&)> energyNormGrad = [] - (const ComplexTensor& J, const ComplexVector& z) { - Real W; - std::tie(W, std::ignore) = WdW(J, z); - return W; - }; - - ComplexVector zSaddle = randomSaddle(J, d, r, ε); - std::cerr << "Found saddle." << std::endl; + ComplexTensor J = ReJ.cast<Complex>(); + ComplexVector zSaddle = zMin.cast<Complex>(); ComplexVector zSaddleNext; bool foundSaddle = false; @@ -198,46 +192,10 @@ int main(int argc, char* argv[]) { } } std::cerr << smallestNorm << std::endl; + getchar(); J = exp(Complex(0, φ)) * J; - /* - if (stokesLineTest<Real>(J, zSaddle, zSaddleNext, 10, 4)) { - std::cerr << "Found a Stokes line" << std::endl; -// stokesLineTestNew<Real>(J, zSaddle, zSaddleNext, 10, 3); - } else { - std::cerr << "Didn't find a Stokes line" << std::endl; - } - */ - - /* - J(0,0,0) = Complex(2, 3); - J(1,1,1) = Complex(-2, 0.3); - J(0,1,1) = Complex(4, 0.2); - J(1,0,1) = Complex(4, 0.2); - J(1,1,0) = Complex(4, 0.2); - J(1,0,0) = Complex(0.7, 0.4); - J(0,1,0) = Complex(0.7, 0.4); - J(0,0,1) = Complex(0.7, 0.4); - - ComplexVector z0(2);; - z0 << Complex(0.8, 0.3), Complex(0.7, 0.2); - ComplexVector z1(2); - z1 << Complex(-0.5, 0.2), Complex(1.0, 1.0); - - Cord test(J, z0, z1, 2); - - test.gs[0](0) = Complex(0.2, 0.2); - test.gs[0](1) = Complex(0.4, 0.4); - test.gs[1](0) = Complex(0.1, 0.2); - test.gs[1](1) = Complex(0.3, 0.4); - - auto [dgs, ddgs] = test.gsGradHess(J, 0.7); - - std::cout << dgs << std::endl; - std::cout << ddgs << std::endl; - */ - Cord test(J, zSaddle, zSaddleNext, 5); test.relaxNewton(J, 25, 1, 1e4); |