Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumkleintunneling2d_tests.cpp
Go to the documentation of this file.
1/**
2 * @file quantumkleintunneling2d_tests.cpp
3 * @brief Implements regression and invariant tests for quantumkleintunneling2d tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/quantumkleintunneling2d_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
15
16#include <cmath>
17#include <iostream>
18#include <string>
19
20namespace qpe { namespace tests {
21
22/**
23 * @brief Runs quantum klein tunneling2 d tests.
24 * @param errorMessage The error message value used by the operation.
25 */
26bool runQuantumKleinTunneling2DTests(std::string &errorMessage)
27{
29 c.enabled = true;
30 DiracSpinor2D s(128, 128, 0.16f, 0.16f);
31 std::string why;
33 errorMessage = why; return false;
34 }
35 if (std::abs(s.norm2()-1.0) > 2.0e-5) {
36 errorMessage = "Klein incident state is not normalized"; return false;
37 }
38 QuantumKleinTunneling2DConfig masslessConfig = c;
39 masslessConfig.restMass = 0.0;
40 DiracSpinor2D masslessState(128, 128, 0.16f, 0.16f);
41 if (!QuantumKleinTunneling2D::prepareIncidentState(masslessState, masslessConfig, 1.0, &why) ||
42 !std::isfinite(masslessState.norm2()) || std::abs(masslessState.norm2()-1.0) > 2.0e-5) {
43 errorMessage = "exact massless Klein incident state is invalid"; return false;
44 }
45 PotentialField2D p(128,128,0.16f,0.16f);
46 if (!QuantumKleinTunneling2D::rasterizeBarrier(p,c,&why) || p.maximum() < 3.19f) {
47 errorMessage = "Klein barrier rasterization failed"; return false;
48 }
50 errorMessage = "default Klein preset is not in the Klein zone"; return false;
51 }
52 if (std::abs(QuantumKleinTunneling2D::incidentMomentumMagnitude(c) - 1.5) > 1.0e-12 ||
54 errorMessage = "Klein momentum/regime helper regression"; return false;
55 }
59 errorMessage = "Klein evanescent-regime classifier regression"; return false;
60 }
62 low.barrierHeight = 0.5;
64 errorMessage = "Klein positive-branch classifier regression"; return false;
65 }
67 if (!(a.leftProbability > 0.95) || std::abs(a.norm-1.0) > 2.0e-5) {
68 errorMessage = "Klein initial partition is invalid"; return false;
69 }
70 DiracSplitStep2DParams dp; dp.hbar=1.0f; dp.dt=0.02f; dp.lightSpeed=1.0f; dp.restMass=0.05f;
71 DiracSplitStepSolver2D solver(dp);
72 for (int i=0;i<20;++i) solver.step(s,p);
73 if (std::abs(s.norm2()-1.0) > 2.0e-4) {
74 errorMessage = "Dirac scalar-barrier step lost norm"; return false;
75 }
76 DiracSplitStep2DParams dp0=dp; dp0.restMass=0.0f;
77 DiracSplitStepSolver2D masslessSolver(dp0);
78 for (int i=0;i<20;++i) masslessSolver.step(masslessState,p);
79 if (!std::isfinite(masslessState.norm2()) || std::abs(masslessState.norm2()-1.0) > 2.0e-4) {
80 errorMessage = "massless Dirac scalar-barrier step lost norm"; return false;
81 }
82 std::cout << "QuantumKleinTunneling2D tests OK\n";
83 return true;
84}
85
86} } // namespace qpe::tests
Two-component complex spinor field used by the QPE Dirac branch.
double norm2() const noexcept
Returns norm2.
Two-component split-step solver for the effective 2D Dirac equation.
void step(DiracSpinor2D &spinor, const PotentialField2D &potential)
Advances one symmetric scalar-potential/free-Dirac split step.
Implements the Potential Field2D component.
Value maximum() const noexcept
Performs maximum.
static double incidentEnergy(const QuantumKleinTunneling2DConfig &config) noexcept
Performs incident energy.
static double incidentMomentumMagnitude(const QuantumKleinTunneling2DConfig &config) noexcept
Performs incident momentum magnitude.
static bool prepareIncidentState(DiracSpinor2D &spinor, const QuantumKleinTunneling2DConfig &config, double hbar=1.0, std::string *reason=nullptr) noexcept
Prepares incident state.
static QuantumKleinTunnelingSample2D measure(const DiracSpinor2D &spinor, const QuantumKleinTunneling2DConfig &config, double time) noexcept
Performs measure.
static QuantumKleinBarrierRegime2D classifyBarrierRegime(const QuantumKleinTunneling2DConfig &config) noexcept
Performs classify barrier regime.
static bool inKleinZone(const QuantumKleinTunneling2DConfig &config) noexcept
Performs in klein zone.
static bool rasterizeBarrier(PotentialField2D &potential, const QuantumKleinTunneling2DConfig &config, std::string *reason=nullptr) noexcept
Performs rasterize barrier.
Declares the two-component split-step Dirac propagator used by the relativistic and graphene-like QPE...
bool runQuantumKleinTunneling2DTests(std::string &errorMessage)
Runs quantum klein tunneling2 d tests.
Declares the potentialfield2d physics/numerical component used by QPE experiments.
Declares the quantumkleintunneling2d physics/numerical component used by QPE experiments.
Parameters of the two-component effective Dirac propagator.
float restMass
Rest/effective mass; exactly zero is supported.
float dt
Propagation step in simulation time units.
float hbar
Reduced Planck constant in simulation units.
float lightSpeed
Dirac characteristic velocity c_D.
Configuration values for Quantum Klein Tunneling2D Config.
Data structure used by the Quantum Klein Tunneling Sample2D component.