29 const float half = 3.2f;
30 const float thickness = 1.28f;
31 const float centre = half + 0.5f * thickness;
32 const float span = 2.0f * (half + thickness);
33 for (
int sign = -1; sign <= 1; sign += 2) {
36 vertical.
value = 120.0f;
37 vertical.
centerX = sign * centre;
39 vertical.
width = thickness;
45 horizontal.
value = 120.0f;
47 horizontal.
centerY = sign * centre;
48 horizontal.
width = span;
49 horizontal.
height = thickness;
50 scene.
add(horizontal);
61bool close(
double a,
double b,
double tolerance)
63 return std::fabs(a - b) <= tolerance;
78 errorMessage =
"failed to identify valid revival box";
81 if (!close(geometry.
innerWidth, 6.4, 1.0e-5) ||
84 errorMessage =
"revival box geometry is incorrect";
88 const double expected = 4.0 * 6.4 * 6.4 / 3.14159265358979323846;
91 errorMessage =
"hard-wall revival time is incorrect";
105 errorMessage =
"self fidelity is not one";
110 if (marginal.size() != field.
width()) {
111 errorMessage =
"wrong marginal size";
114 double marginalNorm = 0.0;
115 for (
float value : marginal) marginalNorm += value * field.
dx();
116 if (!close(marginalNorm, field.
norm2(), 2.0e-6)) {
117 errorMessage =
"x marginal does not integrate to field norm";
123 errorMessage =
"failed to capture/append revival history";
126 if (history.
size() != 1u || !close(history.
samples()[0].fidelity, 1.0, 1.0e-12)) {
127 errorMessage =
"initial revival history sample is inconsistent";
139 errorMessage =
"invalid mixed scene accepted as revival box";
Owning Cartesian grid of complex scalar samples.
double norm2() const noexcept
Returns the discrete integral of |psi|^2 including dx*dy.
float dx() const noexcept
Returns the X grid spacing.
std::size_t width() const noexcept
Returns the number of samples along X.
static void initialize(ComplexField2D &field, const GaussianPacket2DParams ¶ms)
Initializes ialize.
Implements the Potential Scene2D component.
std::uint64_t add(PotentialObject2D object)
Performs add.
Implements the Quantum Revival History2D component.
bool captureReference(const ComplexField2D &field)
Carries out capture reference.
std::size_t size() const noexcept
Returns size.
const std::vector< QuantumRevivalSample2D > & samples() const noexcept
Samples s.
bool append(double time, const ComplexField2D &field)
Carries out append.
static std::vector< float > marginalProbabilityX(const ComplexField2D &field)
Performs marginal probability x.
static double revivalTimeY(const QuantumBoxGeometry2D &geometry, double mass, double hbar=1.0) noexcept
Performs revival time y.
static double revivalTimeX(const QuantumBoxGeometry2D &geometry, double mass, double hbar=1.0) noexcept
Performs revival time x.
static bool identifyBox(const PotentialScene2D &scene, QuantumBoxGeometry2D &geometry, std::string *reason=nullptr) noexcept
Returns identify box.
static double fidelity(const ComplexField2D &reference, const ComplexField2D &field) noexcept
Performs fidelity.
Declares the gaussianpacket2d physics/numerical component used by QPE experiments.
PotentialScene2D makeBox()
Creates box.
bool runQuantumRevivals2DTests(std::string &errorMessage)
Runs quantum revivals2 d tests.
Declares the quantumrevivals2d physics/numerical component used by QPE experiments.
Declares regression and invariant tests for quantumrevivals2d tests.
Configuration values for Gaussian Packet2D Params.
Data structure used by the Potential Object2D component.
PotentialObjectType2D type
Data structure used by the Quantum Box Geometry2D component.