Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
diracspinor2d.h
Go to the documentation of this file.
1/**
2 * @file diracspinor2d.h
3 * @brief Declares the two-component Dirac spinor field container used by QPE.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/diracspinor2d.h. 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#pragma once
13
15
16#include <cstddef>
17
18namespace qpe {
19
20// Two-component 2D Dirac spinor. The components share exactly the same
21// spatial grid. For the relativistic branch of QPE this object, not the
22// scalar display proxy, is the authoritative wavefunction.
23/**
24 * @brief Two-component complex spinor field used by the QPE Dirac branch.
25 *
26 * The container stores both spinor components on the same Cartesian grid and provides the normalization and field-level operations required by the Dirac experiments.
27 */
29{
30public:
31 /**
32 * @brief Constructs a Dirac Spinor 2D instance.
33 */
34 DiracSpinor2D() = default;
35 /**
36 * @brief Constructs a Dirac Spinor 2D instance.
37 * @param width The width value used by the operation.
38 * @param height The height value used by the operation.
39 * @param dx The dx value used by the operation.
40 * @param dy The dy value used by the operation.
41 */
42 DiracSpinor2D(std::size_t width, std::size_t height, float dx = 1.0f, float dy = 1.0f);
43
44 /**
45 * @brief Resizes storage and updates the associated grid geometry.
46 * @param width The width value used by the operation.
47 * @param height The height value used by the operation.
48 * @param dx The dx value used by the operation.
49 * @param dy The dy value used by the operation.
50 */
51 void resize(std::size_t width, std::size_t height, float dx = 1.0f, float dy = 1.0f);
52 /**
53 * @brief Clears stored state and returns the component to its empty/default state.
54 */
55 void clear() noexcept;
56 /**
57 * @brief Assigns one value to all stored samples.
58 * @param upperValue The upper value value used by the operation.
59 * @param lowerValue The lower value value used by the operation.
60 */
61 void fill(const ComplexField2D::Value &upperValue,
62 const ComplexField2D::Value &lowerValue);
63
64 /**
65 * @brief Returns whether the object contains no data.
66 */
67 bool empty() const noexcept;
68 /**
69 * @brief Carries out matches grid.
70 * @param field Field data to read or modify.
71 */
72 bool matchesGrid(const ComplexField2D &field) const noexcept;
73
74 /**
75 * @brief Returns width.
76 * @param width The width value used by the operation.
77 */
78 std::size_t width() const noexcept { return upper_.width(); }
79 /**
80 * @brief Returns height.
81 * @param height The height value used by the operation.
82 */
83 std::size_t height() const noexcept { return upper_.height(); }
84 /**
85 * @brief Returns the X-axis grid spacing.
86 * @param dx The dx value used by the operation.
87 */
88 float dx() const noexcept { return upper_.dx(); }
89 /**
90 * @brief Returns the Y-axis grid spacing.
91 * @param dy The dy value used by the operation.
92 */
93 float dy() const noexcept { return upper_.dy(); }
94
95 /**
96 * @brief Carries out upper.
97 */
98 ComplexField2D &upper() noexcept { return upper_; }
99 /**
100 * @brief Carries out upper.
101 */
102 const ComplexField2D &upper() const noexcept { return upper_; }
103 /**
104 * @brief Carries out lower.
105 */
106 ComplexField2D &lower() noexcept { return lower_; }
107 /**
108 * @brief Carries out lower.
109 */
110 const ComplexField2D &lower() const noexcept { return lower_; }
111
112 /**
113 * @brief Returns norm2.
114 */
115 double norm2() const noexcept;
116 /**
117 * @brief Returns norm.
118 */
119 double norm() const noexcept;
120 /**
121 * @brief Returns normalize.
122 */
123 bool normalize() noexcept;
124 /**
125 * @brief Carries out upper population.
126 */
127 double upperPopulation() const noexcept;
128 /**
129 * @brief Carries out lower population.
130 */
131 double lowerPopulation() const noexcept;
132
133 // Renderer compatibility: writes a scalar field whose |psi|^2 equals the
134 // physical total spinor density |upper|^2+|lower|^2 point by point.
135 // Its phase is intentionally zero and must not be interpreted physically.
136 /**
137 * @brief Writes density proxy.
138 * @param out The out value used by the operation.
139 */
140 void writeDensityProxy(ComplexField2D &out) const;
141
142private:
145};
146
147} // namespace qpe
Owning Cartesian grid of complex scalar samples.
float dx() const noexcept
Returns the X grid spacing.
std::size_t height() const noexcept
Returns the number of samples along Y.
float dy() const noexcept
Returns the Y grid spacing.
std::size_t width() const noexcept
Returns the number of samples along X.
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.
ComplexField2D & lower() noexcept
Carries out lower.
std::size_t height() const noexcept
Returns height.
double norm2() const noexcept
Returns norm2.
ComplexField2D & upper() noexcept
Carries out upper.
const ComplexField2D & upper() const noexcept
Carries out upper.
ComplexField2D upper_
void fill(const ComplexField2D::Value &upperValue, const ComplexField2D::Value &lowerValue)
Assigns one value to all stored samples.
bool normalize() noexcept
Returns normalize.
float dx() const noexcept
Returns the X-axis grid spacing.
void clear() noexcept
Clears stored state and returns the component to its empty/default state.
const ComplexField2D & lower() const noexcept
Carries out lower.
void resize(std::size_t width, std::size_t height, float dx=1.0f, float dy=1.0f)
Resizes storage and updates the associated grid geometry.
double lowerPopulation() const noexcept
Carries out lower population.
float dy() const noexcept
Returns the Y-axis grid spacing.
double norm() const noexcept
Returns norm.
bool matchesGrid(const ComplexField2D &field) const noexcept
Carries out matches grid.
std::size_t width() const noexcept
Returns width.
bool empty() const noexcept
Returns whether the object contains no data.
DiracSpinor2D()=default
Constructs a Dirac Spinor 2D instance.
ComplexField2D lower_
Declares the complex scalar field container representing two-dimensional wave functions.