Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumrevivals2d.h
Go to the documentation of this file.
1/**
2 * @file quantumrevivals2d.h
3 * @brief Declares the quantumrevivals2d physics/numerical component used by QPE experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/quantumrevivals2d.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 <string>
19#include <vector>
20
21namespace qpe {
22
23/**
24 * @brief Data structure used by the Quantum Box Geometry2D component.
25 *
26 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
27 */
29{
30 bool valid = false;
31 double centerX = 0.0;
32 double centerY = 0.0;
33 double innerWidth = 0.0;
34 double innerHeight = 0.0;
35 double wallThicknessX = 0.0;
36 double wallThicknessY = 0.0;
37 double wallPotential = 0.0;
38};
39
40/**
41 * @brief Data structure used by the Quantum Revival Sample2D component.
42 *
43 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
44 */
46{
47 double time = 0.0;
48 double fidelity = 0.0;
49 std::vector<float> marginalX;
50};
51
52/**
53 * @brief Implements the Quantum Revivals2D component.
54 *
55 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
56 */
58{
59public:
60 // Identify a Step-30 style rectangular box made from four positive
61 // Rectangle walls: two vertical plus two horizontal.
62 /**
63 * @brief Returns identify box.
64 * @param scene The scene value used by the operation.
65 * @param geometry The geometry value used by the operation.
66 * @param reason The reason value used by the operation.
67 */
68 static bool identifyBox(const PotentialScene2D &scene,
69 QuantumBoxGeometry2D &geometry,
70 std::string *reason = nullptr) noexcept;
71
72 // Infinite-square-well reference recurrence time for one dimension:
73 // E_n = n^2*pi^2*hbar^2/(2*m*L^2), T_rev = 4*m*L^2/(pi*hbar).
74 // The finite barriers used by the real 2D solver can shift the measured
75 // recurrence slightly; the formula is therefore a tutor/reference layer.
76 /**
77 * @brief Performs revival time.
78 * @param boxLength The box length value used by the operation.
79 * @param mass The mass value used by the operation.
80 * @param hbar The hbar value used by the operation.
81 */
82 static double revivalTime(double boxLength,
83 double mass,
84 double hbar = 1.0) noexcept;
85
86 /**
87 * @brief Performs revival time x.
88 * @param geometry The geometry value used by the operation.
89 * @param mass The mass value used by the operation.
90 * @param hbar The hbar value used by the operation.
91 */
92 static double revivalTimeX(const QuantumBoxGeometry2D &geometry,
93 double mass,
94 double hbar = 1.0) noexcept;
95 /**
96 * @brief Performs revival time y.
97 * @param geometry The geometry value used by the operation.
98 * @param mass The mass value used by the operation.
99 * @param hbar The hbar value used by the operation.
100 */
101 static double revivalTimeY(const QuantumBoxGeometry2D &geometry,
102 double mass,
103 double hbar = 1.0) noexcept;
104
105 // Integral over y of |psi(x,y)|^2. The returned samples are densities in x
106 // and therefore sum to norm/dx rather than to one without the dx factor.
107 /**
108 * @brief Performs marginal probability x.
109 * @param field Field data to read or modify.
110 */
111 static std::vector<float> marginalProbabilityX(const ComplexField2D &field);
112
113 // |<reference|field>|^2, normalized by both field norms. This makes the
114 // diagnostic robust to small norm loss while never altering either field.
115 /**
116 * @brief Performs fidelity.
117 * @param reference The reference value used by the operation.
118 * @param field Field data to read or modify.
119 */
120 static double fidelity(const ComplexField2D &reference,
121 const ComplexField2D &field) noexcept;
122};
123
124// Small diagnostic history for the quantum-carpet plot. It keeps one initial
125// reference field plus 1D probability marginals, never a time history of full
126// 2D wavefunctions. It is analysis-only and cannot evolve psi.
127/**
128 * @brief Implements the Quantum Revival History2D component.
129 *
130 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
131 */
133{
134public:
135 /**
136 * @brief Constructs a Quantum Revival History 2D instance.
137 * @param maximumSamples The maximum samples value used by the operation.
138 */
139 explicit QuantumRevivalHistory2D(std::size_t maximumSamples = 1200u);
140
141 /**
142 * @brief Clears stored state and returns the component to its empty/default state.
143 */
144 void clear() noexcept;
145 /**
146 * @brief Carries out capture reference.
147 * @param field Field data to read or modify.
148 */
149 bool captureReference(const ComplexField2D &field);
150 /**
151 * @brief Returns whether reference.
152 * @param empty The empty value used by the operation.
153 */
154 bool hasReference() const noexcept { return !reference_.empty(); }
155
156 /**
157 * @brief Sets maximum samples.
158 * @param maximumSamples The maximum samples value used by the operation.
159 */
160 void setMaximumSamples(std::size_t maximumSamples);
161 /**
162 * @brief Carries out maximum samples.
163 */
164 std::size_t maximumSamples() const noexcept { return maximumSamples_; }
165
166 /**
167 * @brief Carries out append.
168 * @param time Simulation time in solver units.
169 * @param field Field data to read or modify.
170 */
171 bool append(double time, const ComplexField2D &field);
172
173 /**
174 * @brief Samples s.
175 */
176 const std::vector<QuantumRevivalSample2D> &samples() const noexcept
177 {
178 return samples_;
179 }
180
181 /**
182 * @brief Returns size.
183 * @param size The size value used by the operation.
184 */
185 std::size_t size() const noexcept { return samples_.size(); }
186 /**
187 * @brief Returns whether the object contains no data.
188 * @param empty The empty value used by the operation.
189 */
190 bool empty() const noexcept { return samples_.empty(); }
191 /**
192 * @brief Returns the X-axis grid spacing.
193 * @param dx The dx value used by the operation.
194 */
195 float dx() const noexcept { return reference_.dx(); }
196 /**
197 * @brief Carries out grid width.
198 * @param width The width value used by the operation.
199 */
200 std::size_t gridWidth() const noexcept { return reference_.width(); }
201
202private:
203 /**
204 * @brief Carries out trim to limit.
205 */
206 void trimToLimit();
207
208 std::size_t maximumSamples_ = 1200u;
210 std::vector<QuantumRevivalSample2D> samples_;
211};
212
213} // namespace qpe
Owning Cartesian grid of complex scalar samples.
bool empty() const noexcept
Returns whether the field contains no samples.
float dx() const noexcept
Returns the X grid spacing.
std::size_t width() const noexcept
Returns the number of samples along X.
Implements the Potential Scene2D component.
Implements the Quantum Revival History2D component.
bool empty() const noexcept
Returns whether the object contains no data.
void setMaximumSamples(std::size_t maximumSamples)
Sets maximum samples.
bool captureReference(const ComplexField2D &field)
Carries out capture reference.
std::size_t size() const noexcept
Returns size.
std::vector< QuantumRevivalSample2D > samples_
float dx() const noexcept
Returns the X-axis grid spacing.
const std::vector< QuantumRevivalSample2D > & samples() const noexcept
Samples s.
void clear() noexcept
Clears stored state and returns the component to its empty/default state.
bool append(double time, const ComplexField2D &field)
Carries out append.
std::size_t maximumSamples() const noexcept
Carries out maximum samples.
bool hasReference() const noexcept
Returns whether reference.
QuantumRevivalHistory2D(std::size_t maximumSamples=1200u)
Constructs a Quantum Revival History 2D instance.
std::size_t gridWidth() const noexcept
Carries out grid width.
void trimToLimit()
Carries out trim to limit.
Implements the Quantum Revivals2D component.
static std::vector< float > marginalProbabilityX(const ComplexField2D &field)
Performs marginal probability x.
static double revivalTimeY(const QuantumBoxGeometry2D &geometry, double mass, double hbar=1.0) noexcept
Performs revival time y.
static double revivalTimeX(const QuantumBoxGeometry2D &geometry, double mass, double hbar=1.0) noexcept
Performs revival time x.
static bool identifyBox(const PotentialScene2D &scene, QuantumBoxGeometry2D &geometry, std::string *reason=nullptr) noexcept
Returns identify box.
static double revivalTime(double boxLength, double mass, double hbar=1.0) noexcept
Performs revival time.
static double fidelity(const ComplexField2D &reference, const ComplexField2D &field) noexcept
Performs fidelity.
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 Box Geometry2D component.
Data structure used by the Quantum Revival Sample2D component.
std::vector< float > marginalX