Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
u1gaugefield2d.h
Go to the documentation of this file.
1/**
2 * @file u1gaugefield2d.h
3 * @brief Declares the U(1) lattice gauge field used by magnetic-flux, Landau, and Hall-edge experiments.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/u1gaugefield2d.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
14#include <complex>
15#include <cstddef>
16#include <vector>
17
18namespace qpe {
19
20class ComplexField2D;
21
22// U(1) link field on the regular simulation lattice.
23// linkX(x,y) parallel-transports psi from (x+1,y) back to (x,y), and
24// linkY(x,y) does the same along +Y. Storing gauge links instead of A itself
25// makes the finite-difference kinetic operator exactly gauge covariant on the
26// sampled lattice and is reusable for Aharonov-Bohm, uniform B/Landau and
27// edge-state experiments.
28/**
29 * @brief Discrete U(1) gauge connection for gauge-covariant Schrodinger experiments.
30 *
31 * The field stores unit-modulus link variables rather than a sampled vector
32 * potential. `linkX(x,y)` parallel-transports a neighboring sample from
33 * `(x+1,y)` back to `(x,y)`; `linkY` does the analogous operation along Y.
34 * For charge `q`, a continuum connection corresponds schematically to
35 * \f[
36 * U_x = \exp[-i(q/\hbar)\int_x^{x+\Delta x} A_x\,dx].
37 * \f]
38 * This representation lets the finite-difference kinetic operator transform
39 * covariantly under a sampled U(1) gauge transformation.
40 */
42{
43public:
44 using Link = std::complex<float>;
45
46 /** @brief Constructs an empty gauge-link field. */
47 U1GaugeField2D() = default;
48 /**
49 * @brief Constructs an identity-link field on a Cartesian grid.
50 * @param width Number of lattice sites along X.
51 * @param height Number of lattice sites along Y.
52 * @param dx Lattice spacing along X.
53 * @param dy Lattice spacing along Y.
54 */
55 U1GaugeField2D(std::size_t width, std::size_t height,
56 float dx = 1.0f, float dy = 1.0f);
57
58 /**
59 * @brief Resizes the lattice and resets all links to the identity phase.
60 * @param width Number of lattice sites along X.
61 * @param height Number of lattice sites along Y.
62 * @param dx Lattice spacing along X.
63 * @param dy Lattice spacing along Y.
64 */
65 void resize(std::size_t width, std::size_t height,
66 float dx = 1.0f, float dy = 1.0f);
67 /** @brief Releases the link arrays and resets the geometry. */
68 void clear() noexcept;
69 /** @brief Sets every X/Y link to complex unity (zero gauge phase). */
70 void fillIdentity() noexcept;
71
72 /** @brief Returns whether the lattice contains no links. */
73 bool empty() const noexcept;
74 /** @brief Tests whether dimensions and spacing match a scalar field. @param field Scalar field whose grid is compared. */
75 bool matchesGrid(const ComplexField2D &field) const noexcept;
76
77 /** @brief Returns the number of lattice sites along X. */
78 std::size_t width() const noexcept { return width_; }
79 /** @brief Returns the number of lattice sites along Y. */
80 std::size_t height() const noexcept { return height_; }
81 /** @brief Returns the X lattice spacing. */
82 float dx() const noexcept { return dx_; }
83 /** @brief Returns the Y lattice spacing. */
84 float dy() const noexcept { return dy_; }
85
86 /** @brief Returns the +X parallel-transport link at a site. @param x X site index. @param y Y site index. */
87 Link linkX(std::size_t x, std::size_t y) const noexcept;
88 /** @brief Returns the +Y parallel-transport link at a site. @param x X site index. @param y Y site index. */
89 Link linkY(std::size_t x, std::size_t y) const noexcept;
90 /** @brief Assigns the +X link at a lattice site. @param x X site index. @param y Y site index. @param value Complex link phase. */
91 void setLinkX(std::size_t x, std::size_t y, Link value) noexcept;
92 /** @brief Assigns the +Y link at a lattice site. @param x X site index. @param y Y site index. @param value Complex link phase. */
93 void setLinkY(std::size_t x, std::size_t y, Link value) noexcept;
94
95private:
96 /**
97 * @brief Returns index.
98 * @param x X coordinate/value.
99 * @param y Y coordinate/value.
100 */
101 std::size_t index(std::size_t x, std::size_t y) const noexcept
102 { return y * width_ + x; }
103
104 std::size_t width_ = 0;
105 std::size_t height_ = 0;
106 float dx_ = 1.0f;
107 float dy_ = 1.0f;
108 std::vector<Link> xLinks_;
109 std::vector<Link> yLinks_;
110};
111
112} // namespace qpe
Owning Cartesian grid of complex scalar samples.
Discrete U(1) gauge connection for gauge-covariant Schrodinger experiments.
Link linkY(std::size_t x, std::size_t y) const noexcept
Returns the +Y parallel-transport link at a site.
void setLinkY(std::size_t x, std::size_t y, Link value) noexcept
Assigns the +Y link at a lattice site.
bool matchesGrid(const ComplexField2D &field) const noexcept
Tests whether dimensions and spacing match a scalar field.
void setLinkX(std::size_t x, std::size_t y, Link value) noexcept
Assigns the +X link at a lattice site.
std::size_t index(std::size_t x, std::size_t y) const noexcept
Returns index.
void resize(std::size_t width, std::size_t height, float dx=1.0f, float dy=1.0f)
Resizes the lattice and resets all links to the identity phase.
bool empty() const noexcept
Returns whether the lattice contains no links.
void clear() noexcept
Releases the link arrays and resets the geometry.
U1GaugeField2D()=default
Constructs an empty gauge-link field.
std::complex< float > Link
std::vector< Link > yLinks_
void fillIdentity() noexcept
Sets every X/Y link to complex unity (zero gauge phase).
float dx() const noexcept
Returns the X lattice spacing.
float dy() const noexcept
Returns the Y lattice spacing.
std::size_t height() const noexcept
Returns the number of lattice sites along Y.
Link linkX(std::size_t x, std::size_t y) const noexcept
Returns the +X parallel-transport link at a site.
std::vector< Link > xLinks_
std::size_t width() const noexcept
Returns the number of lattice sites along X.