Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumscar2d.h
Go to the documentation of this file.
1/**
2 * @file quantumscar2d.h
3 * @brief Declares the quantumscar2d physics/numerical component used by QPE experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/quantumscar2d.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 <cstddef>
18#include <complex>
19#include <string>
20#include <vector>
21
22namespace qpe {
23
24/**
25 * @brief Data structure used by the Quantum Scar Geometry2D component.
26 *
27 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
28 */
30{
31 bool valid = false;
32 double centerX = 0.0;
33 double centerY = 0.0;
34 double straightLength = 0.0;
35 double radius = 0.0;
36 double wallPotential = 0.0;
37};
38
39/**
40 * @brief Data structure used by the Quantum Scar Config2D component.
41 *
42 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
43 */
45{
46 bool enabled = false;
47 // Half-width of the band used to quantify concentration around the
48 // horizontal axial periodic orbit of the stadium.
49 double orbitBandHalfWidth = 0.75;
50
51 // Central energy used by the finite-time spectral projection
52 // Phi_E ~ integral psi(t) exp(+i E t / hbar) dt. A non-positive value asks
53 // the caller to supply an energy inferred from the prepared packet.
54 double referenceEnergy = 0.0;
55};
56
57/**
58 * @brief Data structure used by the Quantum Scar Sample2D component.
59 *
60 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
61 */
63{
64 double time = 0.0;
65 double fidelity = 0.0;
68};
69
70/**
71 * @brief Implements the Quantum Scars2D component.
72 *
73 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
74 */
76{
77public:
78 /**
79 * @brief Validates config.
80 * @param config Configuration to apply.
81 * @param reason The reason value used by the operation.
82 */
83 static bool validateConfig(const QuantumScarConfig2D &config,
84 std::string *reason = nullptr) noexcept;
85
86 /**
87 * @brief Returns identify.
88 * @param scene The scene value used by the operation.
89 * @param geometry The geometry value used by the operation.
90 * @param reason The reason value used by the operation.
91 */
92 static bool identify(const PotentialScene2D &scene,
93 QuantumScarGeometry2D &geometry,
94 std::string *reason = nullptr) noexcept;
95
96 /**
97 * @brief Performs inside.
98 * @param geometry The geometry value used by the operation.
99 * @param x X coordinate/value.
100 * @param y Y coordinate/value.
101 */
102 static bool inside(const QuantumScarGeometry2D &geometry,
103 double x,
104 double y) noexcept;
105
106 /**
107 * @brief Performs accessible area.
108 * @param geometry The geometry value used by the operation.
109 */
110 static double accessibleArea(const QuantumScarGeometry2D &geometry) noexcept;
111 /**
112 * @brief Performs orbit band area.
113 * @param geometry The geometry value used by the operation.
114 * @param halfWidth The half width value used by the operation.
115 */
116 static double orbitBandArea(const QuantumScarGeometry2D &geometry,
117 double halfWidth) noexcept;
118 /**
119 * @brief Performs axial orbit round trip length.
120 * @param geometry The geometry value used by the operation.
121 */
122 static double axialOrbitRoundTripLength(const QuantumScarGeometry2D &geometry) noexcept;
123 /**
124 * @brief Performs axial orbit period.
125 * @param geometry The geometry value used by the operation.
126 * @param speed The speed value used by the operation.
127 */
128 static double axialOrbitPeriod(const QuantumScarGeometry2D &geometry,
129 double speed) noexcept;
130
131 /**
132 * @brief Performs fidelity.
133 * @param reference The reference value used by the operation.
134 * @param field Field data to read or modify.
135 */
136 static double fidelity(const ComplexField2D &reference,
137 const ComplexField2D &field) noexcept;
138
139 /**
140 * @brief Performs orbit enhancement.
141 * @param field Field data to read or modify.
142 * @param geometry The geometry value used by the operation.
143 * @param halfWidth The half width value used by the operation.
144 */
145 static double orbitEnhancement(const ComplexField2D &field,
146 const QuantumScarGeometry2D &geometry,
147 double halfWidth) noexcept;
148};
149
150// Analysis-only accumulator. The authoritative evolution remains the full 2D
151// psi owned by MainWindow/SplitStepFourierSolver2D. This class only records
152// diagnostics and a finite-time spectral projection of the already-computed
153// psi sequence; it never feeds anything back into the Hamiltonian.
154/**
155 * @brief Implements the Quantum Scar History2D component.
156 *
157 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
158 */
160{
161public:
162 /**
163 * @brief Constructs a Quantum Scar History 2D instance.
164 * @param maximumSamples The maximum samples value used by the operation.
165 */
166 explicit QuantumScarHistory2D(std::size_t maximumSamples = 1600u);
167
168 /**
169 * @brief Clears stored state and returns the component to its empty/default state.
170 */
171 void clear() noexcept;
172 /**
173 * @brief Returns configure.
174 * @param reference The reference value used by the operation.
175 * @param geometry The geometry value used by the operation.
176 * @param config Configuration to apply.
177 * @param referenceEnergy The reference energy value used by the operation.
178 * @param hbar The hbar value used by the operation.
179 */
180 bool configure(const ComplexField2D &reference,
183 double referenceEnergy,
184 double hbar = 1.0);
185
186 /**
187 * @brief Returns configured.
188 */
189 bool configured() const noexcept { return configured_; }
190 /**
191 * @brief Sets maximum samples.
192 * @param maximumSamples The maximum samples value used by the operation.
193 */
194 void setMaximumSamples(std::size_t maximumSamples);
195 /**
196 * @brief Carries out maximum samples.
197 */
198 std::size_t maximumSamples() const noexcept { return maximumSamples_; }
199
200 /**
201 * @brief Carries out append.
202 * @param time Simulation time in solver units.
203 * @param field Field data to read or modify.
204 */
205 bool append(double time, const ComplexField2D &field);
206
207 /**
208 * @brief Samples s.
209 */
210 const std::vector<QuantumScarSample2D> &samples() const noexcept { return samples_; }
211 /**
212 * @brief Carries out mean probability density.
213 */
214 const std::vector<float> &meanProbabilityDensity() const noexcept { return meanDensity_; }
215 /**
216 * @brief Carries out filtered probability density.
217 */
218 const std::vector<float> &filteredProbabilityDensity() const noexcept { return filteredDensity_; }
219
220 /**
221 * @brief Carries out geometry.
222 */
223 const QuantumScarGeometry2D &geometry() const noexcept { return geometry_; }
224 /**
225 * @brief Returns config.
226 */
227 const QuantumScarConfig2D &config() const noexcept { return config_; }
228 /**
229 * @brief Carries out reference energy.
230 */
231 double referenceEnergy() const noexcept { return referenceEnergy_; }
232 /**
233 * @brief Carries out hbar.
234 */
235 double hbar() const noexcept { return hbar_; }
236
237 /**
238 * @brief Carries out grid width.
239 * @param width The width value used by the operation.
240 */
241 std::size_t gridWidth() const noexcept { return reference_.width(); }
242 /**
243 * @brief Carries out grid height.
244 * @param height The height value used by the operation.
245 */
246 std::size_t gridHeight() const noexcept { return reference_.height(); }
247 /**
248 * @brief Returns the X-axis grid spacing.
249 * @param dx The dx value used by the operation.
250 */
251 float dx() const noexcept { return reference_.dx(); }
252 /**
253 * @brief Returns the Y-axis grid spacing.
254 * @param dy The dy value used by the operation.
255 */
256 float dy() const noexcept { return reference_.dy(); }
257 /**
258 * @brief Carries out accumulated frames.
259 */
260 std::size_t accumulatedFrames() const noexcept { return accumulatedFrames_; }
261 /**
262 * @brief Returns whether the object contains no data.
263 * @param empty The empty value used by the operation.
264 */
265 bool empty() const noexcept { return samples_.empty(); }
266
267private:
268 /**
269 * @brief Carries out trim to limit.
270 */
271 void trimToLimit();
272 /**
273 * @brief Carries out filtered enhancement.
274 */
275 double filteredEnhancement() const noexcept;
276
277 std::size_t maximumSamples_ = 1600u;
278 bool configured_ = false;
282 double referenceEnergy_ = 0.0;
283 double hbar_ = 1.0;
285 std::vector<double> meanDensitySum_;
286 std::vector<std::complex<double>> spectralAccumulator_;
287 std::vector<float> meanDensity_;
288 std::vector<float> filteredDensity_;
289 std::size_t accumulatedFrames_ = 0u;
291 double totalTimeWeight_ = 0.0;
293};
294
295} // namespace qpe
Owning Cartesian grid of complex scalar samples.
float dx() const noexcept
Returns the X grid spacing.
std::size_t height() const noexcept
Returns the number of samples along Y.
float dy() const noexcept
Returns the Y grid spacing.
std::size_t width() const noexcept
Returns the number of samples along X.
Implements the Potential Scene2D component.
Implements the Quantum Scar History2D component.
std::vector< std::complex< double > > spectralAccumulator_
bool append(double time, const ComplexField2D &field)
Carries out append.
std::size_t gridWidth() const noexcept
Carries out grid width.
double filteredEnhancement() const noexcept
Carries out filtered enhancement.
std::vector< float > meanDensity_
std::size_t accumulatedFrames() const noexcept
Carries out accumulated frames.
const std::vector< QuantumScarSample2D > & samples() const noexcept
Samples s.
double referenceEnergy() const noexcept
Carries out reference energy.
std::vector< float > filteredDensity_
std::size_t gridHeight() const noexcept
Carries out grid height.
const std::vector< float > & filteredProbabilityDensity() const noexcept
Carries out filtered probability density.
QuantumScarConfig2D config_
std::vector< double > meanDensitySum_
float dx() const noexcept
Returns the X-axis grid spacing.
float dy() const noexcept
Returns the Y-axis grid spacing.
std::vector< QuantumScarSample2D > samples_
const std::vector< float > & meanProbabilityDensity() const noexcept
Carries out mean probability density.
std::size_t maximumSamples() const noexcept
Carries out maximum samples.
QuantumScarGeometry2D geometry_
const QuantumScarGeometry2D & geometry() const noexcept
Carries out geometry.
void clear() noexcept
Clears stored state and returns the component to its empty/default state.
bool configured() const noexcept
Returns configured.
const QuantumScarConfig2D & config() const noexcept
Returns config.
void setMaximumSamples(std::size_t maximumSamples)
Sets maximum samples.
double hbar() const noexcept
Carries out hbar.
bool configure(const ComplexField2D &reference, const QuantumScarGeometry2D &geometry, const QuantumScarConfig2D &config, double referenceEnergy, double hbar=1.0)
Returns configure.
QuantumScarHistory2D(std::size_t maximumSamples=1600u)
Constructs a Quantum Scar History 2D instance.
bool empty() const noexcept
Returns whether the object contains no data.
void trimToLimit()
Carries out trim to limit.
Implements the Quantum Scars2D component.
static double orbitEnhancement(const ComplexField2D &field, const QuantumScarGeometry2D &geometry, double halfWidth) noexcept
Performs orbit enhancement.
static double axialOrbitPeriod(const QuantumScarGeometry2D &geometry, double speed) noexcept
Performs axial orbit period.
static double orbitBandArea(const QuantumScarGeometry2D &geometry, double halfWidth) noexcept
Performs orbit band area.
static double accessibleArea(const QuantumScarGeometry2D &geometry) noexcept
Performs accessible area.
static double fidelity(const ComplexField2D &reference, const ComplexField2D &field) noexcept
Performs fidelity.
static double axialOrbitRoundTripLength(const QuantumScarGeometry2D &geometry) noexcept
Performs axial orbit round trip length.
static bool inside(const QuantumScarGeometry2D &geometry, double x, double y) noexcept
Performs inside.
static bool identify(const PotentialScene2D &scene, QuantumScarGeometry2D &geometry, std::string *reason=nullptr) noexcept
Returns identify.
static bool validateConfig(const QuantumScarConfig2D &config, std::string *reason=nullptr) noexcept
Validates config.
Declares the complex scalar field container representing two-dimensional wave functions.
Declares the potentialscene2d physics/numerical component used by QPE experiments.
Data structure used by the Quantum Scar Config2D component.
Data structure used by the Quantum Scar Geometry2D component.
Data structure used by the Quantum Scar Sample2D component.