Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumloschmidt2d.h
Go to the documentation of this file.
1/**
2 * @file quantumloschmidt2d.h
3 * @brief Declares the quantumloschmidt2d physics/numerical component used by QPE experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/quantumloschmidt2d.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
15
16#include <cstddef>
17#include <vector>
18
19namespace qpe {
20
21// Step 40: one-shot time reversal for a scalar wavefunction evolving under a
22// real, time-independent Hamiltonian. At reversalTime the anti-unitary time
23// reversal operation reduces to complex conjugation, psi -> psi*. Optional
24// delta-p terms deliberately make the reversal imperfect by applying a small
25// additional momentum kick immediately after conjugation.
26/**
27 * @brief Configuration values for Quantum Loschmidt2D Config.
28 *
29 * The structure groups parameters that are passed together so the associated numerical/analysis component can be configured reproducibly.
30 */
32{
33 bool enabled = false;
34 double reversalTime = 4.0;
35 double momentumErrorX = 0.0;
36 double momentumErrorY = 0.0;
37};
38
39/**
40 * @brief Data structure used by the Quantum Loschmidt Sample2D component.
41 *
42 * The structure keeps related values explicit and testable across the QPE physics, analysis, or persistence layers.
43 */
45{
46 double time = 0.0;
47 double meanX = 0.0;
48 double meanY = 0.0;
49 double densityEcho = 0.0; // phase-insensitive Bhattacharyya fidelity
50 double stateEcho = 0.0; // |<psi0*|psi(t)>|^2, normalized
51 double norm = 0.0;
52 bool reversalApplied = false;
53};
54
55/**
56 * @brief Implements the Quantum Loschmidt Echo2D component.
57 *
58 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
59 */
61{
62public:
63 /**
64 * @brief Validates config.
65 * @param config Configuration to apply.
66 * @param reason The reason value used by the operation.
67 */
68 static bool validateConfig(const QuantumLoschmidt2DConfig &config,
69 const char **reason = nullptr) noexcept;
70
71 // Applies T psi = psi* followed by an optional deterministic momentum
72 // mismatch exp[i(delta_px x + delta_py y)/hbar]. The field is renormalized
73 // only defensively; the operation itself is norm-preserving.
74 /**
75 * @brief Applies time reversal.
76 * @param field Field data to read or modify.
77 * @param config Configuration to apply.
78 * @param hbar The hbar value used by the operation.
79 */
80 static bool applyTimeReversal(ComplexField2D &field,
81 const QuantumLoschmidt2DConfig &config,
82 double hbar) noexcept;
83
84 /**
85 * @brief Performs state echo fidelity.
86 * @param reference The reference value used by the operation.
87 * @param field Field data to read or modify.
88 */
89 static double stateEchoFidelity(const ComplexField2D &reference,
90 const ComplexField2D &field) noexcept;
91
92 /**
93 * @brief Performs density echo fidelity.
94 * @param reference The reference value used by the operation.
95 * @param field Field data to read or modify.
96 */
97 static double densityEchoFidelity(const ComplexField2D &reference,
98 const ComplexField2D &field) noexcept;
99
100 /**
101 * @brief Performs centroid.
102 * @param field Field data to read or modify.
103 * @param meanX The mean x value used by the operation.
104 * @param meanY The mean y value used by the operation.
105 */
106 static bool centroid(const ComplexField2D &field,
107 double &meanX,
108 double &meanY) noexcept;
109};
110
111/**
112 * @brief Implements the Quantum Loschmidt History2D component.
113 *
114 * The class provides one focused service within the QPE architecture and is documented here independently of the experiment-level Help.
115 */
117{
118public:
119 /**
120 * @brief Constructs a Quantum Loschmidt History 2D instance.
121 * @param maximumSamples The maximum samples value used by the operation.
122 */
123 explicit QuantumLoschmidtHistory2D(std::size_t maximumSamples = 1600u);
124
125 /**
126 * @brief Clears stored state and returns the component to its empty/default state.
127 */
128 void clear() noexcept;
129 /**
130 * @brief Returns configure.
131 * @param reference The reference value used by the operation.
132 * @param config Configuration to apply.
133 */
134 bool configure(const ComplexField2D &reference,
136 /**
137 * @brief Carries out append.
138 * @param time Simulation time in solver units.
139 * @param field Field data to read or modify.
140 * @param reversalApplied The reversal applied value used by the operation.
141 */
142 bool append(double time,
143 const ComplexField2D &field,
144 bool reversalApplied);
145
146 /**
147 * @brief Returns configured.
148 */
149 bool configured() const noexcept { return configured_; }
150 /**
151 * @brief Returns whether the object contains no data.
152 * @param empty The empty value used by the operation.
153 */
154 bool empty() const noexcept { return samples_.empty(); }
155 /**
156 * @brief Returns config.
157 */
158 const QuantumLoschmidt2DConfig &config() const noexcept { return config_; }
159 /**
160 * @brief Samples s.
161 */
162 const std::vector<QuantumLoschmidtSample2D> &samples() const noexcept { return samples_; }
163
164private:
165 /**
166 * @brief Carries out trim to limit.
167 */
168 void trimToLimit();
169
170 std::size_t maximumSamples_ = 1600u;
171 bool configured_ = false;
174 std::vector<QuantumLoschmidtSample2D> samples_;
175};
176
177} // namespace qpe
Owning Cartesian grid of complex scalar samples.
Implements the Quantum Loschmidt Echo2D component.
static double stateEchoFidelity(const ComplexField2D &reference, const ComplexField2D &field) noexcept
Performs state echo fidelity.
static bool validateConfig(const QuantumLoschmidt2DConfig &config, const char **reason=nullptr) noexcept
Validates config.
static bool centroid(const ComplexField2D &field, double &meanX, double &meanY) noexcept
Performs centroid.
static bool applyTimeReversal(ComplexField2D &field, const QuantumLoschmidt2DConfig &config, double hbar) noexcept
Applies time reversal.
static double densityEchoFidelity(const ComplexField2D &reference, const ComplexField2D &field) noexcept
Performs density echo fidelity.
Implements the Quantum Loschmidt History2D component.
const std::vector< QuantumLoschmidtSample2D > & samples() const noexcept
Samples s.
bool append(double time, const ComplexField2D &field, bool reversalApplied)
Carries out append.
bool configured() const noexcept
Returns configured.
std::vector< QuantumLoschmidtSample2D > samples_
bool configure(const ComplexField2D &reference, const QuantumLoschmidt2DConfig &config)
Returns configure.
QuantumLoschmidt2DConfig config_
bool empty() const noexcept
Returns whether the object contains no data.
QuantumLoschmidtHistory2D(std::size_t maximumSamples=1600u)
Constructs a Quantum Loschmidt History 2D instance.
const QuantumLoschmidt2DConfig & config() const noexcept
Returns config.
void trimToLimit()
Carries out trim to limit.
void clear() noexcept
Clears stored state and returns the component to its empty/default state.
Declares the complex scalar field container representing two-dimensional wave functions.
Configuration values for Quantum Loschmidt2D Config.
Data structure used by the Quantum Loschmidt Sample2D component.