Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumaharonovbohm2d_tests.cpp
Go to the documentation of this file.
1/**
2 * @file quantumaharonovbohm2d_tests.cpp
3 * @brief Implements regression and invariant tests for quantumaharonovbohm2d tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/quantumaharonovbohm2d_tests.cpp. 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
13
20
21#include <cmath>
22#include <complex>
23
24namespace qpe { namespace tests {
25
26/**
27 * @brief Runs quantum aharonov bohm2 d tests.
28 * @param error Output diagnostic text on failure.
29 */
30bool runQuantumAharonovBohm2DTests(std::string &error)
31{
32 const double pi = 3.14159265358979323846;
33 ComplexField2D field(64u, 64u, 0.20f, 0.20f);
35 packet.centerX = -3.0f;
36 packet.centerY = 0.0f;
37 packet.sigma = 1.2f;
38 packet.momentumX = 2.0f;
39 packet.momentumY = 0.0f;
40 packet.hbar = 1.0f;
41 GaussianPacket2D::initialize(field, packet);
42
44 config.enabled = true;
45 config.solenoidRadius = 0.8;
46 config.barrierHeight = 100.0;
47 config.detectorX = 2.5;
48 config.analysisEndTime = 2.0;
49 config.fluxQuanta = 0.0;
50
51 PotentialField2D potential;
52 U1GaugeField2D gauge;
53 if (!QuantumAharonovBohm2D::buildFields(field, config, potential, gauge, &error)) {
54 return false;
55 }
56 if (!potential.matchesGrid(field) || !gauge.matchesGrid(field) ||
57 potential.maximum() < 99.0f) {
58 error = "Aharonov-Bohm scalar/gauge field build failed";
59 return false;
60 }
61 for (std::size_t y = 0; y < gauge.height(); y += 7u) {
62 for (std::size_t x = 0; x < gauge.width(); x += 7u) {
63 if (std::abs(gauge.linkX(x, y) - U1GaugeField2D::Link(1.0f, 0.0f)) > 1.0e-6f ||
64 std::abs(gauge.linkY(x, y) - U1GaugeField2D::Link(1.0f, 0.0f)) > 1.0e-6f) {
65 error = "zero-flux U(1) links are not identity";
66 return false;
67 }
68 }
69 }
70
71 config.fluxQuanta = 0.5;
72 if (std::fabs(QuantumAharonovBohm2D::topologicalPhaseRadians(config) - pi) > 1.0e-12) {
73 error = "half-flux Aharonov-Bohm phase is not pi";
74 return false;
75 }
76 if (!QuantumAharonovBohm2D::buildFields(field, config, potential, gauge, &error)) return false;
78 if (std::fabs(field.norm2() - 1.0) > 2.0e-5) {
79 error = "incident gauge phase changed wavefunction norm";
80 return false;
81 }
82
85 params.mass = 1.0f;
86 params.hbar = 1.0f;
87 params.dt = 0.01f;
88 solver.setParameters(params);
89 solver.prepare(field);
90 solver.preparePotential(potential);
91 for (int i = 0; i < 20; ++i) solver.stepGaugeCovariant(field, potential, gauge);
92 if (std::fabs(field.norm2() - 1.0) > 2.0e-3) {
93 error = "gauge-covariant Cayley propagation did not preserve norm";
94 return false;
95 }
96
98 if (!history.configure(field, config)) {
99 error = "Aharonov-Bohm history configuration failed";
100 return false;
101 }
102 history.append(solver.time(), field);
103 if (history.empty() || history.samples().back().detectorProfileY.size() != field.height()) {
104 error = "Aharonov-Bohm detector history append failed";
105 return false;
106 }
107
108 error.clear();
109 return true;
110}
111
112} }
Owning Cartesian grid of complex scalar samples.
double norm2() const noexcept
Returns the discrete integral of |psi|^2 including dx*dy.
std::size_t height() const noexcept
Returns the number of samples along Y.
static void initialize(ComplexField2D &field, const GaussianPacket2DParams &params)
Initializes ialize.
Implements the Potential Field2D component.
bool matchesGrid(const ComplexField2D &field) const noexcept
Performs matches grid.
Value maximum() const noexcept
Performs maximum.
static double topologicalPhaseRadians(const QuantumAharonovBohm2DConfig &config) noexcept
Performs topological phase radians.
static void applyIncidentGaugePhase(ComplexField2D &field, const QuantumAharonovBohm2DConfig &config)
Applies incident gauge phase.
static bool buildFields(const ComplexField2D &reference, const QuantumAharonovBohm2DConfig &config, PotentialField2D &potential, U1GaugeField2D &gauge, std::string *reason=nullptr)
Builds fields.
Implements the Quantum Aharonov Bohm History2D component.
bool empty() const noexcept
Returns whether the object contains no data.
const std::vector< QuantumAharonovBohmSample2D > & samples() const noexcept
Samples s.
bool configure(const ComplexField2D &field, const QuantumAharonovBohm2DConfig &config)
Returns configure.
void append(double time, const ComplexField2D &field)
Carries out append.
Symmetric split-step Fourier solver for the scalar 2D Schrodinger equation.
double time() const noexcept
Returns accumulated simulation time in solver units.
void setParameters(const SplitStepFourier2DParams &params)
Replaces physical/time-step parameters and invalidates prepared caches.
void preparePotential(const PotentialField2D &potential)
Precomputes the scalar-potential half-step phase cache.
void prepare(const ComplexField2D &field)
Precomputes spectral kinetic phase factors for a specific grid.
void stepGaugeCovariant(ComplexField2D &field, const PotentialField2D &potential, const U1GaugeField2D &gauge)
Advances one gauge-covariant Schrodinger step using U(1) links.
Discrete U(1) gauge connection for gauge-covariant Schrodinger experiments.
Link linkY(std::size_t x, std::size_t y) const noexcept
Returns the +Y parallel-transport link at a site.
bool matchesGrid(const ComplexField2D &field) const noexcept
Tests whether dimensions and spacing match a scalar field.
std::complex< float > Link
std::size_t height() const noexcept
Returns the number of lattice sites along Y.
Link linkX(std::size_t x, std::size_t y) const noexcept
Returns the +X parallel-transport link at a site.
std::size_t width() const noexcept
Returns the number of lattice sites along X.
Declares the complex scalar field container representing two-dimensional wave functions.
Declares the gaussianpacket2d physics/numerical component used by QPE experiments.
bool runQuantumAharonovBohm2DTests(std::string &error)
Runs quantum aharonov bohm2 d tests.
Declares the potentialfield2d physics/numerical component used by QPE experiments.
Declares the quantumaharonovbohm2d physics/numerical component used by QPE experiments.
Declares regression and invariant tests for quantumaharonovbohm2d tests.
Declares the two-dimensional split-step Fourier propagator for the scalar Schrodinger branch.
Configuration values for Gaussian Packet2D Params.
Configuration values for Quantum Aharonov Bohm2D Config.
Physical/numerical parameters for scalar split-step propagation.
float hbar
Reduced Planck constant in simulation units.
float dt
Propagation step in simulation time units.
float mass
Particle/effective mass in simulation units.
Declares the U(1) lattice gauge field used by magnetic-flux, Landau, and Hall-edge experiments.