From 94b6ed7d9c591ae2df0957a25e73bd2e5c69f6e1 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 4 Jan 2022 17:42:30 +0100 Subject: Added option for spiking the interaction tensor to study minima below the threshold. --- collectStokesData.hpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'collectStokesData.hpp') diff --git a/collectStokesData.hpp b/collectStokesData.hpp index 54062f5..ca52386 100644 --- a/collectStokesData.hpp +++ b/collectStokesData.hpp @@ -4,8 +4,32 @@ using Complex = std::complex; +template +Tensor makeSpikeHelper(const Vector& x) { + Eigen::array, 0> ei = {}; + Tensor xT = Eigen::TensorMap>(x.data(), {x.size()}); + + return xT.contract(makeSpikeHelper

(x), ei); +} + +template <> +Tensor makeSpikeHelper(const Vector& x) { + Tensor xT = Eigen::TensorMap>(x.data(), {x.size()}); + return xT; +} + +template +Tensor makeSpike(const Vector& x) { + return makeSpikeHelper

(x); +} + +template +int getFirstP() { + return p; +} + template -void collectStokesData(std::string tag, unsigned N, Generator& r, Real ε, Real δz₀, bool minimum, T... μs) { +void collectStokesData(std::string tag, unsigned N, Generator& r, Real ε, Real δz₀, bool minimum, bool spike, T... μs) { unsigned nIts = 5; unsigned nGs = 4; unsigned coDim = 16; @@ -24,6 +48,18 @@ void collectStokesData(std::string tag, unsigned N, Generator& r, Real ε, Real } Real Hx; + std::tie(Hx, std::ignore, std::ignore, std::ignore) = ReM.hamGradHess(xMin); + + if (spike) { + const unsigned p = getFirstP(); + Real εgs = sqrt((p - 1) * log(p - 1) / (p - 2)); + Real εth = sqrt((p - 1) * 2.0 / p); + + Real εTarget = std::uniform_real_distribution(εth, εgs)(r); + + std::get<0>(ReM.Js) -= factorial(p) * (εTarget * N + Hx) * makeSpike(xMin) / pow(N, p); + } + Vector dHx; Matrix ddHx; std::tie(Hx, dHx, ddHx, std::ignore) = ReM.hamGradHess(xMin); -- cgit v1.2.3-54-g00ecf