22namespace qpe {
namespace tests {
31bool near(
double a,
double b,
double tolerance)
33 return std::abs(a - b) <= tolerance;
58 if (!near(initial.
norm2, 1.0, 2.0e-5) ||
63 std::ostringstream ss;
64 ss <<
"initial spatial observables mismatch: norm=" << initial.
norm2
65 <<
" meanX=" << initial.
meanX <<
" meanY=" << initial.
meanY
66 <<
" sigmaX=" << initial.
sigmaX <<
" sigmaY=" << initial.
sigmaY;
72 solverParams.
mass = 1.0f;
73 solverParams.
hbar = 1.0f;
74 solverParams.
dt = 0.02f;
78 for (
int i = 0; i < steps; ++i) {
83 const double t = solver.
time();
84 const double expectedMeanX =
static_cast<double>(packet.
centerX) +
85 static_cast<double>(packet.
momentumX) / solverParams.
mass * t;
86 const double sigma0 = packet.
sigma;
87 const double spreadingTerm = solverParams.
hbar * t /
88 (2.0 * solverParams.
mass * sigma0 * sigma0);
89 const double expectedSigma = sigma0 * std::sqrt(1.0 + spreadingTerm * spreadingTerm);
91 if (!near(evolved.
norm2, 1.0, 1.0e-4) ||
92 !near(evolved.
meanX, expectedMeanX, 1.5e-2) ||
94 !near(evolved.
sigmaX, expectedSigma, 1.5e-2) ||
95 !near(evolved.
sigmaY, expectedSigma, 1.5e-2)) {
96 std::ostringstream ss;
97 ss <<
"free propagation mismatch: norm=" << evolved.
norm2
98 <<
" meanX=" << evolved.
meanX <<
" expectedX=" << expectedMeanX
99 <<
" sigmaX=" << evolved.
sigmaX <<
" expectedSigma=" << expectedSigma;
Owning Cartesian grid of complex scalar samples.
static void initialize(ComplexField2D &field, const GaussianPacket2DParams ¶ms)
Initializes ialize.
Symmetric split-step Fourier solver for the scalar 2D Schrodinger equation.
double time() const noexcept
Returns accumulated simulation time in solver units.
void stepFree(ComplexField2D &field)
Advances a free (V=0) scalar field by one cached kinetic step.
static SpatialObservables2D spatial(const ComplexField2D &field) noexcept
Performs spatial.
Declares the complex scalar field container representing two-dimensional wave functions.
Declares the gaussianpacket2d physics/numerical component used by QPE experiments.
bool runWavePacketObservables2DTests(std::string &error)
Runs wave packet observables2 d tests.
Declares the two-dimensional split-step Fourier propagator for the scalar Schrodinger branch.
Configuration values for Gaussian Packet2D Params.
Data structure used by the Spatial Observables2D component.
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 wavepacketobservables2d physics/numerical component used by QPE experiments.
Declares regression and invariant tests for wavepacketobservables2d tests.