Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
squarebarrier1d.cpp
Go to the documentation of this file.
1/**
2 * @file squarebarrier1d.cpp
3 * @brief Implements the squarebarrier1d physics/numerical component used by QPE experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/squarebarrier1d.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
12#include "squarebarrier1d.h"
13
14#include <algorithm>
15#include <cmath>
16#include <stdexcept>
17
18namespace qpe {
19namespace {
20
21/**
22 * @brief Performs finite positive.
23 * @param v The v value used by the operation.
24 */
25bool finitePositive(double v) noexcept
26{
27 return std::isfinite(v) && v > 0.0;
28}
29
30/**
31 * @brief Performs finite non negative.
32 * @param v The v value used by the operation.
33 */
34bool finiteNonNegative(double v) noexcept
35{
36 return std::isfinite(v) && v >= 0.0;
37}
38
39} // namespace
40
42 double barrierHeight,
43 double barrierWidth,
44 double mass,
45 double hbar)
46{
47 if (!finiteNonNegative(energy) ||
48 !finiteNonNegative(barrierHeight) ||
49 !finiteNonNegative(barrierWidth) ||
50 !finitePositive(mass) ||
51 !finitePositive(hbar)) {
52 throw std::invalid_argument("SquareBarrier1D: invalid parameters");
53 }
54
56 result.energy = energy;
57 result.barrierHeight = barrierHeight;
58 result.barrierWidth = barrierWidth;
59 result.tunnelingRegime = energy < barrierHeight;
60
61 // Degenerate cases: no barrier, zero thickness, or a non-zero-energy
62 // particle encountering V0=0 all transmit completely.
63 if (barrierHeight == 0.0 || barrierWidth == 0.0) {
64 result.transmission = 1.0;
65 result.reflection = 0.0;
66 return result;
67 }
68
69 // At exactly zero incident energy the stationary plane-wave flux tends to
70 // zero and the finite positive barrier is fully reflecting in this limit.
71 if (energy == 0.0) {
72 result.transmission = 0.0;
73 result.reflection = 1.0;
74 return result;
75 }
76
77 const double hbar2 = hbar * hbar;
78 double denominatorExtra = 0.0;
79
80 const double scale = std::max({1.0, std::abs(energy), std::abs(barrierHeight)});
81 const bool atTop = std::abs(energy - barrierHeight) <= 1.0e-12 * scale;
82
83 if (atTop) {
84 // Limit E -> V0 of either branch.
85 denominatorExtra = mass * barrierHeight * barrierWidth * barrierWidth /
86 (2.0 * hbar2);
87 } else if (energy < barrierHeight) {
88 const double delta = barrierHeight - energy;
89 const double kappa = std::sqrt(2.0 * mass * delta) / hbar;
90 const double s = std::sinh(kappa * barrierWidth);
91 denominatorExtra = barrierHeight * barrierHeight * s * s /
92 (4.0 * energy * delta);
93 } else {
94 const double delta = energy - barrierHeight;
95 const double q = std::sqrt(2.0 * mass * delta) / hbar;
96 const double s = std::sin(q * barrierWidth);
97 denominatorExtra = barrierHeight * barrierHeight * s * s /
98 (4.0 * energy * delta);
99 }
100
101 const double t = 1.0 / (1.0 + denominatorExtra);
102 result.transmission = std::max(0.0, std::min(1.0, t));
103 result.reflection = 1.0 - result.transmission;
104 return result;
105}
106
107} // namespace qpe
static SquareBarrier1DResult evaluate(double energy, double barrierHeight, double barrierWidth, double mass=1.0, double hbar=1.0)
Performs evaluate.
Declares the squarebarrier1d physics/numerical component used by QPE experiments.
Data record containing Square Barrier1D Result.