Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumberryphase2d.h
Go to the documentation of this file.
1/**
2 * @file quantumberryphase2d.h
3 * @brief Declares the quantumberryphase2d physics/numerical component used by QPE experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/quantumberryphase2d.h. This file is part of Quantum Phenomena Explorer (QPE),
7 * maintained by Officina Turini. See LICENSE_IT.txt / LICENSE.txt for the
8 * QPE freeware source-available terms and THIRD_PARTY_NOTICES.txt for
9 * third-party components.
10 */
11
12#pragma once
13
16
17#include <complex>
18#include <cstddef>
19#include <vector>
20
21namespace qpe {
22
23// Step 39: cyclic quadrupole deformation of an otherwise isotropic 2D
24// harmonic trap. The pair (q1,q2) winds around the exact first-excited-state
25// degeneracy at q1=q2=0:
26//
27// V_q = q1 (x^2-y^2) + 2 q2 x y
28// q1 = A cos(theta), q2 = A sin(theta)
29//
30// The principal axes of the trap rotate by theta/2. A complete 2*pi loop in
31// parameter space therefore rotates the physical anisotropy by pi, bringing V
32// back to itself. The lowest p-like excited eigenstate changes sign in the
33// adiabatic limit: Berry phase = pi modulo 2*pi.
34/**
35 * @brief Configuration values for Quantum Berry Loop2D Config.
36 *
37 * The structure groups parameters that are passed together so the associated numerical/analysis component can be configured reproducibly.
38 */
40{
41 bool enabled = false;
42 double anisotropy = 0.35;
43 double startTime = 0.0;
44 double duration = 240.0;
45 int winding = 1; // +1 counter-clockwise in (q1,q2), -1 clockwise.
46};
47
48/**
49 * @brief Data structure used by the Quantum Berry Trap2D component.
50 *
51 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
52 */
54{
55 bool valid = false;
56 double centerX = 0.0;
57 double centerY = 0.0;
58 double offset = 0.0;
59 double baseCurvature = 1.0;
60};
61
62/**
63 * @brief Data record containing Quantum Berry Loop2D State.
64 *
65 * The structure carries computed data without coupling the numerical component to the GUI or renderer.
66 */
68{
69 bool valid = false;
70 bool active = false;
71 bool finished = false;
72 double progress = 0.0; // 0..1
73 double parameterAngle = 0.0; // theta, radians
74 double principalAxisAngle = 0.0; // theta/2, radians
75 double q1 = 0.0;
76 double q2 = 0.0;
77};
78
79/**
80 * @brief Data structure used by the Quantum Berry Sample2D component.
81 *
82 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
83 */
85{
86 double time = 0.0;
87 double progress = 0.0;
88 double parameterAngle = 0.0;
89 double principalAxisAngle = 0.0;
90 double q1 = 0.0;
91 double q2 = 0.0;
92 double returnFidelity = 0.0;
93 double adjacentFidelity = 0.0;
94 double geometricPhase = 0.0; // wrapped to [-pi,+pi]
95 bool geometricPhaseValid = false;
96};
97
99
100/**
101 * @brief Implements the Quantum Berry Phase2D component.
102 *
103 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
104 */
106{
107public:
108 /**
109 * @brief Validates config.
110 * @param config Configuration to apply.
111 * @param trap The trap value used by the operation.
112 * @param reason The reason value used by the operation.
113 */
114 static bool validateConfig(const QuantumBerryLoop2DConfig &config,
115 const QuantumBerryTrap2D &trap,
116 const char **reason = nullptr) noexcept;
117
118 // For this guided experiment the base scene is intentionally minimal:
119 // exactly one enabled, isotropic Harmonic object and no other enabled
120 // terms. This keeps the degeneracy and analytic initial state explicit.
121 /**
122 * @brief Returns identify trap.
123 * @param scene The scene value used by the operation.
124 * @param trap The trap value used by the operation.
125 * @param reason The reason value used by the operation.
126 */
127 static bool identifyTrap(const PotentialScene2D &scene,
128 QuantumBerryTrap2D &trap,
129 const char **reason = nullptr) noexcept;
130
131 /**
132 * @brief Performs state.
133 * @param config Configuration to apply.
134 * @param time Simulation time in solver units.
135 */
137 double time) noexcept;
138
139 // Rebuild V(x,y,t) from the immutable base scene plus the quadrupole term.
140 // The Potential Scene itself is never mutated.
141 /**
142 * @brief Performs rasterize.
143 * @param baseScene The base scene value used by the operation.
144 * @param trap The trap value used by the operation.
145 * @param config Configuration to apply.
146 * @param time Simulation time in solver units.
147 * @param target The target value used by the operation.
148 */
149 static QuantumBerryLoop2DState rasterize(const PotentialScene2D &baseScene,
150 const QuantumBerryTrap2D &trap,
151 const QuantumBerryLoop2DConfig &config,
152 double time,
153 PotentialField2D &target);
154
155 // Prepare the lower member of the first excited doublet at theta=0. For
156 // positive anisotropy the Y oscillator is softer, hence psi ~ y times the
157 // anisotropic Gaussian ground envelope.
158 /**
159 * @brief Prepares first excited.
160 * @param field Field data to read or modify.
161 * @param trap The trap value used by the operation.
162 * @param config Configuration to apply.
163 * @param mass The mass value used by the operation.
164 * @param hbar The hbar value used by the operation.
165 */
166 static bool prepareFirstExcited(ComplexField2D &field,
167 const QuantumBerryTrap2D &trap,
168 const QuantumBerryLoop2DConfig &config,
169 double mass,
170 double hbar) noexcept;
171
172 /**
173 * @brief Returns normalized overlap.
174 * @param a The a value used by the operation.
175 * @param b The b value used by the operation.
176 */
177 static std::complex<double> normalizedOverlap(const ComplexField2D &a,
178 const ComplexField2D &b) noexcept;
179
180 /**
181 * @brief Performs wrap phase.
182 * @param radians The radians value used by the operation.
183 */
184 static double wrapPhase(double radians) noexcept;
185 /**
186 * @brief Performs expected berry phase.
187 * @param config Configuration to apply.
188 */
189 static double expectedBerryPhase(const QuantumBerryLoop2DConfig &config) noexcept;
190 /**
191 * @brief Performs doublet gap.
192 * @param trap The trap value used by the operation.
193 * @param config Configuration to apply.
194 * @param mass The mass value used by the operation.
195 * @param hbar The hbar value used by the operation.
196 */
197 static double doubletGap(const QuantumBerryTrap2D &trap,
198 const QuantumBerryLoop2DConfig &config,
199 double mass,
200 double hbar = 1.0) noexcept;
201 /**
202 * @brief Performs adiabatic ratio.
203 * @param trap The trap value used by the operation.
204 * @param config Configuration to apply.
205 * @param mass The mass value used by the operation.
206 * @param hbar The hbar value used by the operation.
207 */
208 static double adiabaticRatio(const QuantumBerryTrap2D &trap,
209 const QuantumBerryLoop2DConfig &config,
210 double mass,
211 double hbar = 1.0) noexcept;
212};
213
214/**
215 * @brief Implements the Quantum Berry History2D component.
216 *
217 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
218 */
220{
221public:
222 /**
223 * @brief Constructs a Quantum Berry History 2D instance.
224 * @param maximumSamples The maximum samples value used by the operation.
225 */
226 explicit QuantumBerryHistory2D(std::size_t maximumSamples = 1200u);
227
228 /**
229 * @brief Clears stored state and returns the component to its empty/default state.
230 */
231 void clear() noexcept;
232 /**
233 * @brief Returns configure.
234 * @param reference The reference value used by the operation.
235 * @param trap The trap value used by the operation.
236 * @param config Configuration to apply.
237 */
238 bool configure(const ComplexField2D &reference,
241 /**
242 * @brief Carries out append.
243 * @param time Simulation time in solver units.
244 * @param loopState The loop state value used by the operation.
245 * @param field Field data to read or modify.
246 */
247 bool append(double time,
248 const QuantumBerryLoop2DState &loopState,
249 const ComplexField2D &field);
250
251 /**
252 * @brief Returns configured.
253 */
254 bool configured() const noexcept { return configured_; }
255 /**
256 * @brief Returns whether the object contains no data.
257 * @param empty The empty value used by the operation.
258 */
259 bool empty() const noexcept { return samples_.empty(); }
260 /**
261 * @brief Carries out trap.
262 */
263 const QuantumBerryTrap2D &trap() const noexcept { return trap_; }
264 /**
265 * @brief Returns config.
266 */
267 const QuantumBerryLoop2DConfig &config() const noexcept { return config_; }
268 /**
269 * @brief Samples s.
270 */
271 const std::vector<QuantumBerrySample2D> &samples() const noexcept { return samples_; }
272
273private:
274 /**
275 * @brief Carries out trim to limit.
276 */
277 void trimToLimit();
278
279 std::size_t maximumSamples_ = 1200u;
280 bool configured_ = false;
285 std::complex<double> transportPhase_ = std::complex<double>(1.0, 0.0);
286 bool havePrevious_ = false;
287 std::vector<QuantumBerrySample2D> samples_;
288};
289
290} // namespace qpe
Owning Cartesian grid of complex scalar samples.
Implements the Potential Field2D component.
Implements the Potential Scene2D component.
Implements the Quantum Berry History2D component.
void clear() noexcept
Clears stored state and returns the component to its empty/default state.
const std::vector< QuantumBerrySample2D > & samples() const noexcept
Samples s.
bool configure(const ComplexField2D &reference, const QuantumBerryTrap2D &trap, const QuantumBerryLoop2DConfig &config)
Returns configure.
QuantumBerryHistory2D(std::size_t maximumSamples=1200u)
Constructs a Quantum Berry History 2D instance.
std::vector< QuantumBerrySample2D > samples_
std::complex< double > transportPhase_
bool append(double time, const QuantumBerryLoop2DState &loopState, const ComplexField2D &field)
Carries out append.
QuantumBerryLoop2DConfig config_
const QuantumBerryLoop2DConfig & config() const noexcept
Returns config.
void trimToLimit()
Carries out trim to limit.
const QuantumBerryTrap2D & trap() const noexcept
Carries out trap.
bool empty() const noexcept
Returns whether the object contains no data.
bool configured() const noexcept
Returns configured.
Implements the Quantum Berry Phase2D component.
static double doubletGap(const QuantumBerryTrap2D &trap, const QuantumBerryLoop2DConfig &config, double mass, double hbar=1.0) noexcept
Performs doublet gap.
static QuantumBerryLoop2DState state(const QuantumBerryLoop2DConfig &config, double time) noexcept
Performs state.
static double expectedBerryPhase(const QuantumBerryLoop2DConfig &config) noexcept
Performs expected berry phase.
static QuantumBerryLoop2DState rasterize(const PotentialScene2D &baseScene, const QuantumBerryTrap2D &trap, const QuantumBerryLoop2DConfig &config, double time, PotentialField2D &target)
Performs rasterize.
static bool validateConfig(const QuantumBerryLoop2DConfig &config, const QuantumBerryTrap2D &trap, const char **reason=nullptr) noexcept
Validates config.
static double adiabaticRatio(const QuantumBerryTrap2D &trap, const QuantumBerryLoop2DConfig &config, double mass, double hbar=1.0) noexcept
Performs adiabatic ratio.
static bool prepareFirstExcited(ComplexField2D &field, const QuantumBerryTrap2D &trap, const QuantumBerryLoop2DConfig &config, double mass, double hbar) noexcept
Prepares first excited.
static bool identifyTrap(const PotentialScene2D &scene, QuantumBerryTrap2D &trap, const char **reason=nullptr) noexcept
Returns identify trap.
static std::complex< double > normalizedOverlap(const ComplexField2D &a, const ComplexField2D &b) noexcept
Returns normalized overlap.
static double wrapPhase(double radians) noexcept
Performs wrap phase.
Declares the complex scalar field container representing two-dimensional wave functions.
Declares the potentialscene2d physics/numerical component used by QPE experiments.
Configuration values for Quantum Berry Loop2D Config.
Data record containing Quantum Berry Loop2D State.
Data structure used by the Quantum Berry Sample2D component.
Data structure used by the Quantum Berry Trap2D component.