Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumkleinheightscan2d_tests.cpp
Go to the documentation of this file.
1/**
2 * @file quantumkleinheightscan2d_tests.cpp
3 * @brief Implements regression and invariant tests for quantumkleinheightscan2d tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/quantumkleinheightscan2d_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
14
15#include <cmath>
16
17namespace qpe { namespace tests {
18
19/**
20 * @brief Runs quantum klein height scan2 d tests.
21 * @param errorMessage The error message value used by the operation.
22 */
23bool runQuantumKleinHeightScan2DTests(std::string &errorMessage)
24{
26 c.enabled = true;
27 c.lightSpeed = 1.0;
28 c.restMass = 0.05;
29 c.centerX = -10.0;
30 c.centerY = 0.0;
31 c.sigma = 2.2;
32 c.momentumX = 1.5;
33 c.momentumY = 0.0;
34 c.barrierCenterX = 0.0;
35 c.barrierWidth = 3.0;
36 c.barrierHeight = 3.2;
37 c.detectorX = 6.0;
38 c.analysisEndTime = 18.0;
39
41 if (!zero.valid || std::fabs(zero.transmission - 1.0) > 1.0e-12 ||
42 std::fabs(zero.reflection) > 1.0e-12 ||
44 errorMessage = "Klein height scan zero-barrier reference failed";
45 return false;
46 }
47
50 const QuantumKleinHeightPoint2D subcritical = QuantumKleinHeightScan2D::evaluate(c, lower - 0.15, 1.0);
51 const QuantumKleinHeightPoint2D evanescent = QuantumKleinHeightScan2D::evaluate(c, 0.5 * (lower + upper), 1.0);
52 const QuantumKleinHeightPoint2D supercritical = QuantumKleinHeightScan2D::evaluate(c, 3.2, 1.0);
53 if (!subcritical.valid || !evanescent.valid || !supercritical.valid ||
57 errorMessage = "Klein height scan regime classification failed";
58 return false;
59 }
60
61 const QuantumKleinHeightScan2DResult scan = QuantumKleinHeightScan2D::scan(c, 0.0, 4.0, 241, 1.0);
62 if (!scan.valid || scan.points.size() != 241u ||
63 std::fabs(scan.incidentEnergy - QuantumKleinTunneling2D::incidentEnergy(c)) > 1.0e-12 ||
64 std::fabs(scan.lowerThreshold - lower) > 1.0e-12 ||
65 std::fabs(scan.upperThreshold - upper) > 1.0e-12) {
66 errorMessage = "Klein height scan result metadata failed";
67 return false;
68 }
69
70 int conservationCount = 0;
71 for (const QuantumKleinHeightPoint2D &point : scan.points) {
72 if (!point.valid) continue;
73 if (point.transmission < -1.0e-12 || point.transmission > 1.0 + 1.0e-12 ||
74 point.reflection < -1.0e-12 || point.reflection > 1.0 + 1.0e-12 ||
75 std::fabs(point.transmission + point.reflection - 1.0) > 2.0e-8) {
76 errorMessage = "Klein height scan probability conservation failed";
77 return false;
78 }
79 ++conservationCount;
80 }
81 if (conservationCount < 239) {
82 errorMessage = "Klein height scan has too many invalid points";
83 return false;
84 }
85
86 errorMessage.clear();
87 return true;
88}
89
90} } // namespace qpe::tests
static QuantumKleinHeightScan2DResult scan(const QuantumKleinTunneling2DConfig &baseConfig, double minimumBarrierHeight=0.0, double maximumBarrierHeight=4.0, int samples=241, double hbar=1.0) noexcept
Performs scan.
static QuantumKleinHeightPoint2D evaluate(const QuantumKleinTunneling2DConfig &baseConfig, double barrierHeight, double hbar=1.0) noexcept
Performs evaluate.
static double incidentEnergy(const QuantumKleinTunneling2DConfig &config) noexcept
Performs incident energy.
static double normalIncidenceUpperThreshold(const QuantumKleinTunneling2DConfig &config) noexcept
Returns normal incidence upper threshold.
static double normalIncidenceLowerThreshold(const QuantumKleinTunneling2DConfig &config) noexcept
Returns normal incidence lower threshold.
bool runQuantumKleinHeightScan2DTests(std::string &errorMessage)
Runs quantum klein height scan2 d tests.
Declares the quantumkleinheightscan2d physics/numerical component used by QPE experiments.
Declares regression and invariant tests for quantumkleinheightscan2d tests.
Data structure used by the Quantum Klein Height Point2D component.
QuantumKleinBarrierRegime2D regime
Data record containing Quantum Klein Height Scan2D Result.
std::vector< QuantumKleinHeightPoint2D > points
Configuration values for Quantum Klein Tunneling2D Config.