Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
u1gaugefield2d.cpp
Go to the documentation of this file.
1/**
2 * @file u1gaugefield2d.cpp
3 * @brief Implements the U(1) lattice gauge field and gauge-covariant link construction.
4 * @ingroup qpe_quantum
5 *
6 * Source: @c core/quantum/u1gaugefield2d.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 "u1gaugefield2d.h"
14
15namespace qpe {
16
17U1GaugeField2D::U1GaugeField2D(std::size_t width, std::size_t height,
18 float dx, float dy)
19{
21}
22
23void U1GaugeField2D::resize(std::size_t width, std::size_t height,
24 float dx, float dy)
25{
26 width_ = width;
28 dx_ = dx;
29 dy_ = dy;
30 xLinks_.assign(width_ * height_, Link(1.0f, 0.0f));
31 yLinks_.assign(width_ * height_, Link(1.0f, 0.0f));
32}
33
34void U1GaugeField2D::clear() noexcept
35{
36 width_ = height_ = 0;
37 xLinks_.clear();
38 yLinks_.clear();
39}
40
42{
43 const Link one(1.0f, 0.0f);
44 for (std::size_t i = 0; i < xLinks_.size(); ++i) xLinks_[i] = one;
45 for (std::size_t i = 0; i < yLinks_.size(); ++i) yLinks_[i] = one;
46}
47
48bool U1GaugeField2D::empty() const noexcept
49{
50 return width_ == 0 || height_ == 0 || xLinks_.empty() || yLinks_.empty();
51}
52
53bool U1GaugeField2D::matchesGrid(const ComplexField2D &field) const noexcept
54{
55 return !empty() && width_ == field.width() && height_ == field.height() &&
56 dx_ == field.dx() && dy_ == field.dy();
57}
58
59U1GaugeField2D::Link U1GaugeField2D::linkX(std::size_t x, std::size_t y) const noexcept
60{
61 return xLinks_[index(x, y)];
62}
63U1GaugeField2D::Link U1GaugeField2D::linkY(std::size_t x, std::size_t y) const noexcept
64{
65 return yLinks_[index(x, y)];
66}
67void U1GaugeField2D::setLinkX(std::size_t x, std::size_t y, Link value) noexcept
68{
69 xLinks_[index(x, y)] = value;
70}
71void U1GaugeField2D::setLinkY(std::size_t x, std::size_t y, Link value) noexcept
72{
73 yLinks_[index(x, y)] = value;
74}
75
76} // namespace qpe
Owning Cartesian grid of complex scalar samples.
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.
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.
Declares the complex scalar field container representing two-dimensional wave functions.
Declares the U(1) lattice gauge field used by magnetic-flux, Landau, and Hall-edge experiments.