Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
diracspinor2d_tests.cpp
Go to the documentation of this file.
1/**
2 * @file diracspinor2d_tests.cpp
3 * @brief Implements regression and invariant tests for diracspinor2d tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/diracspinor2d_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
12#include "diracspinor2d_tests.h"
14#include <cmath>
15namespace qpe { namespace tests {
16/**
17 * @brief Runs dirac spinor2 d tests.
18 * @param error Output diagnostic text on failure.
19 */
20bool runDiracSpinor2DTests(std::string &error)
21{
22 error.clear();
23 DiracSpinor2D s(16u, 8u, 0.25f, 0.5f);
24 s.fill(ComplexField2D::Value(1.0f,0.0f), ComplexField2D::Value(0.5f,0.0f));
25 if (!s.normalize() || std::abs(s.norm2()-1.0)>2.0e-6) { error="Dirac spinor normalization failed"; return false; }
26 ComplexField2D proxy;
27 s.writeDensityProxy(proxy);
28 if (!s.matchesGrid(proxy) || std::abs(proxy.norm2()-1.0)>2.0e-6) { error="Dirac density proxy does not preserve density"; return false; }
29 if (std::abs(s.upperPopulation()+s.lowerPopulation()-1.0)>2.0e-6) { error="Dirac component populations do not sum to one"; return false; }
30 return true;
31}
32} }
Owning Cartesian grid of complex scalar samples.
double norm2() const noexcept
Returns the discrete integral of |psi|^2 including dx*dy.
std::complex< float > Value
Two-component complex spinor field used by the QPE Dirac branch.
double upperPopulation() const noexcept
Carries out upper population.
void writeDensityProxy(ComplexField2D &out) const
Writes density proxy.
double norm2() const noexcept
Returns norm2.
void fill(const ComplexField2D::Value &upperValue, const ComplexField2D::Value &lowerValue)
Assigns one value to all stored samples.
bool normalize() noexcept
Returns normalize.
double lowerPopulation() const noexcept
Carries out lower population.
bool matchesGrid(const ComplexField2D &field) const noexcept
Carries out matches grid.
Declares the two-component Dirac spinor field container used by QPE.
Declares regression and invariant tests for diracspinor2d tests.
bool runDiracSpinor2DTests(std::string &error)
Runs dirac spinor2 d tests.