Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantummoshinsky2d.h
Go to the documentation of this file.
1/**
2 * @file quantummoshinsky2d.h
3 * @brief Declares the quantummoshinsky2d physics/numerical component used by QPE experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/quantummoshinsky2d.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 <cstdint>
19#include <string>
20#include <vector>
21
22namespace qpe {
23
24// Step 41: Moshinsky shutter / diffraction in time.
25// A truncated matter wave occupies x < shutterX at t=0. The shutter potential
26// is removed suddenly, and the released edge develops Fresnel-like oscillations
27// in time at a fixed downstream detector.
28/**
29 * @brief Configuration values for Quantum Moshinsky Initial State2D Config.
30 *
31 * The structure groups parameters that are passed together so the associated numerical/analysis component can be configured reproducibly.
32 */
34{
35 bool enabled = false;
36 double shutterX = 0.0;
37 double envelopeCenterX = -8.0;
38 double envelopeSigmaX = 8.0;
39 double centerY = 0.0;
40 double transverseSigmaY = 3.2;
41 double momentumX = 3.0;
42 double edgeWidth = 0.18;
43};
44
45/**
46 * @brief Configuration values for Quantum Moshinsky2D Config.
47 *
48 * The structure groups parameters that are passed together so the associated numerical/analysis component can be configured reproducibly.
49 */
51{
52 bool enabled = false;
53 std::uint64_t shutterObjectId = 0;
54 double openTime = 0.0;
55 double detectorX = 4.0;
56 double analysisEndTime = 6.0;
57};
58
59/**
60 * @brief Data structure used by the Quantum Moshinsky Geometry2D component.
61 *
62 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
63 */
65{
66 bool valid = false;
67 std::uint64_t shutterObjectId = 0;
68 double shutterX = 0.0;
69 double shutterCenterY = 0.0;
70 double shutterLength = 0.0;
71 double shutterThickness = 0.0;
72 double closedHeight = 0.0;
73};
74
75/**
76 * @brief Data structure used by the Quantum Moshinsky Potential State2D component.
77 *
78 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
79 */
81{
82 bool valid = false;
83 bool opened = false;
84 double shutterHeight = 0.0;
85};
86
87/**
88 * @brief Data structure used by the Quantum Moshinsky Sample2D component.
89 *
90 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
91 */
93{
94 double time = 0.0;
95 bool shutterOpened = false;
96 double detectorSignal = 0.0; // x-marginal density at detectorX
97 double frontProbability = 0.0; // integral over x > shutterX
98 double meanX = 0.0;
99 std::vector<float> marginalX; // integral dy |psi(x,y)|^2
100};
101
102class PotentialField2D;
103
104/**
105 * @brief Implements the Quantum Moshinsky2D component.
106 *
107 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
108 */
110{
111public:
112 /**
113 * @brief Validates initial state.
114 * @param config Configuration to apply.
115 * @param reason The reason value used by the operation.
116 */
118 const char **reason = nullptr) noexcept;
119
120 /**
121 * @brief Initializes ialize.
122 * @param field Field data to read or modify.
123 * @param config Configuration to apply.
124 * @param hbar The hbar value used by the operation.
125 * @param reason The reason value used by the operation.
126 */
127 static bool initialize(ComplexField2D &field,
129 double hbar,
130 std::string *reason = nullptr);
131
132 /**
133 * @brief Returns identify shutter.
134 * @param scene The scene value used by the operation.
135 * @param shutterObjectId Stable identifier of the requested object.
136 * @param geometry The geometry value used by the operation.
137 * @param reason The reason value used by the operation.
138 */
139 static bool identifyShutter(const PotentialScene2D &scene,
140 std::uint64_t shutterObjectId,
142 const char **reason = nullptr) noexcept;
143
144 /**
145 * @brief Validates config.
146 * @param scene The scene value used by the operation.
147 * @param config Configuration to apply.
148 * @param geometry The geometry value used by the operation.
149 * @param reason The reason value used by the operation.
150 */
151 static bool validateConfig(const PotentialScene2D &scene,
152 const QuantumMoshinsky2DConfig &config,
153 QuantumMoshinskyGeometry2D *geometry = nullptr,
154 const char **reason = nullptr) noexcept;
155
156 // Rasterizes a temporary scene. At the exact reset instant t=openTime the
157 // shutter is still drawn closed; the first positive midpoint sample opens
158 // it. This makes the physical operation visible without evolving against a
159 // closed shutter for a finite pre-release interval.
160 /**
161 * @brief Performs rasterize.
162 * @param scene The scene value used by the operation.
163 * @param config Configuration to apply.
164 * @param time Simulation time in solver units.
165 * @param target The target value used by the operation.
166 */
168 const PotentialScene2D &scene,
169 const QuantumMoshinsky2DConfig &config,
170 double time,
171 PotentialField2D &target) noexcept;
172
173 /**
174 * @brief Performs marginal x.
175 * @param field Field data to read or modify.
176 * @param out The out value used by the operation.
177 */
178 static bool marginalX(const ComplexField2D &field,
179 std::vector<float> &out) noexcept;
180
181 /**
182 * @brief Performs detector signal.
183 * @param field Field data to read or modify.
184 * @param marginal The marginal value used by the operation.
185 * @param detectorX The detector x value used by the operation.
186 */
187 static double detectorSignal(const ComplexField2D &field,
188 const std::vector<float> &marginal,
189 double detectorX) noexcept;
190
191 /**
192 * @brief Performs front probability.
193 * @param field Field data to read or modify.
194 * @param marginal The marginal value used by the operation.
195 * @param shutterX The shutter x value used by the operation.
196 */
197 static double frontProbability(const ComplexField2D &field,
198 const std::vector<float> &marginal,
199 double shutterX) noexcept;
200
201 /**
202 * @brief Performs mean x.
203 * @param field Field data to read or modify.
204 * @param marginal The marginal value used by the operation.
205 */
206 static double meanX(const ComplexField2D &field,
207 const std::vector<float> &marginal) noexcept;
208};
209
210/**
211 * @brief Implements the Quantum Moshinsky History2D component.
212 *
213 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
214 */
216{
217public:
218 /**
219 * @brief Constructs a Quantum Moshinsky History 2D instance.
220 * @param maximumSamples The maximum samples value used by the operation.
221 */
222 explicit QuantumMoshinskyHistory2D(std::size_t maximumSamples = 520u);
223
224 /**
225 * @brief Clears stored state and returns the component to its empty/default state.
226 */
227 void clear() noexcept;
228 /**
229 * @brief Returns configure.
230 * @param config Configuration to apply.
231 * @param geometry The geometry value used by the operation.
232 * @param field Field data to read or modify.
233 */
236 const ComplexField2D &field);
237 /**
238 * @brief Carries out append.
239 * @param time Simulation time in solver units.
240 * @param shutterOpened The shutter opened value used by the operation.
241 * @param field Field data to read or modify.
242 */
243 bool append(double time,
244 bool shutterOpened,
245 const ComplexField2D &field);
246
247 /**
248 * @brief Returns configured.
249 */
250 bool configured() const noexcept { return configured_; }
251 /**
252 * @brief Returns whether the object contains no data.
253 * @param empty The empty value used by the operation.
254 */
255 bool empty() const noexcept { return samples_.empty(); }
256 /**
257 * @brief Returns config.
258 */
259 const QuantumMoshinsky2DConfig &config() const noexcept { return config_; }
260 /**
261 * @brief Carries out geometry.
262 */
263 const QuantumMoshinskyGeometry2D &geometry() const noexcept { return geometry_; }
264 /**
265 * @brief Samples s.
266 */
267 const std::vector<QuantumMoshinskySample2D> &samples() const noexcept { return samples_; }
268 /**
269 * @brief Carries out grid width.
270 */
271 std::size_t gridWidth() const noexcept { return width_; }
272 /**
273 * @brief Carries out grid dx.
274 */
275 float gridDx() const noexcept { return dx_; }
276 /**
277 * @brief Carries out x coordinate.
278 * @param x X coordinate/value.
279 */
280 double xCoordinate(std::size_t x) const noexcept;
281
282private:
283 /**
284 * @brief Carries out trim to limit.
285 */
286 void trimToLimit();
287
288 std::size_t maximumSamples_ = 520u;
289 bool configured_ = false;
290 std::size_t width_ = 0u;
291 std::size_t height_ = 0u;
292 float dx_ = 1.0f;
293 float dy_ = 1.0f;
296 std::vector<QuantumMoshinskySample2D> samples_;
297};
298
299} // namespace qpe
Owning Cartesian grid of complex scalar samples.
Implements the Potential Field2D component.
Implements the Potential Scene2D component.
Implements the Quantum Moshinsky2D component.
static bool validateInitialState(const QuantumMoshinskyInitialState2DConfig &config, const char **reason=nullptr) noexcept
Validates initial state.
static bool marginalX(const ComplexField2D &field, std::vector< float > &out) noexcept
Performs marginal x.
static double frontProbability(const ComplexField2D &field, const std::vector< float > &marginal, double shutterX) noexcept
Performs front probability.
static double meanX(const ComplexField2D &field, const std::vector< float > &marginal) noexcept
Performs mean x.
static bool identifyShutter(const PotentialScene2D &scene, std::uint64_t shutterObjectId, QuantumMoshinskyGeometry2D &geometry, const char **reason=nullptr) noexcept
Returns identify shutter.
static bool validateConfig(const PotentialScene2D &scene, const QuantumMoshinsky2DConfig &config, QuantumMoshinskyGeometry2D *geometry=nullptr, const char **reason=nullptr) noexcept
Validates config.
static double detectorSignal(const ComplexField2D &field, const std::vector< float > &marginal, double detectorX) noexcept
Performs detector signal.
static bool initialize(ComplexField2D &field, const QuantumMoshinskyInitialState2DConfig &config, double hbar, std::string *reason=nullptr)
Initializes ialize.
static QuantumMoshinskyPotentialState2D rasterize(const PotentialScene2D &scene, const QuantumMoshinsky2DConfig &config, double time, PotentialField2D &target) noexcept
Performs rasterize.
Implements the Quantum Moshinsky History2D component.
const QuantumMoshinsky2DConfig & config() const noexcept
Returns config.
bool append(double time, bool shutterOpened, const ComplexField2D &field)
Carries out append.
void clear() noexcept
Clears stored state and returns the component to its empty/default state.
void trimToLimit()
Carries out trim to limit.
double xCoordinate(std::size_t x) const noexcept
Carries out x coordinate.
const std::vector< QuantumMoshinskySample2D > & samples() const noexcept
Samples s.
bool configure(const QuantumMoshinsky2DConfig &config, const QuantumMoshinskyGeometry2D &geometry, const ComplexField2D &field)
Returns configure.
QuantumMoshinskyHistory2D(std::size_t maximumSamples=520u)
Constructs a Quantum Moshinsky History 2D instance.
QuantumMoshinsky2DConfig config_
std::vector< QuantumMoshinskySample2D > samples_
bool configured() const noexcept
Returns configured.
std::size_t gridWidth() const noexcept
Carries out grid width.
float gridDx() const noexcept
Carries out grid dx.
const QuantumMoshinskyGeometry2D & geometry() const noexcept
Carries out geometry.
QuantumMoshinskyGeometry2D geometry_
bool empty() const noexcept
Returns whether the object contains no data.
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 Moshinsky2D Config.
Data structure used by the Quantum Moshinsky Geometry2D component.
Configuration values for Quantum Moshinsky Initial State2D Config.
Data structure used by the Quantum Moshinsky Potential State2D component.
Data structure used by the Quantum Moshinsky Sample2D component.