LandauGinzburg
Loading...
Searching...
No Matches
field_class.hpp
Go to the documentation of this file.
1
7#ifndef FIELD_CLASS_INCLUDED
8#define FIELD_CLASS_INCLUDED
9
10#include <iostream>
11#include <math.h>
12#include <random>
13#include "Eigen/LU"
14
15using namespace Eigen;
16using std::cout;
17using std::endl;
18using std::cerr;
19
21const std::complex<double> IM(0, 1.0);
22
23
28enum class Distribution {
29 Zero_conf ,
31 Gauss_L ,
34};
35
36
37
48class Field {
49protected:
51 int Li;
53 int num_f;
58 MatrixXcd field;
59
66 void setgauss(const int num_col,
67 const double mean = 0.0, const double dev = 1.0);
74 void setgaussl(const int num_col,
75 const double mean = 0.0);
82 void setgaussmt(const int num_col,
83 const double mean = 0.0, const double dev = 1.0);
90 void setgaussmtl(const int num_col,
91 const double mean = 0.0);
97 void setconf(const int num_col, const Distribution n,
98 const double mean = 0.0, const double dev = 1.0);
103 void setconf(const VectorXcd &v, const int num_field = 1);
108 void setconf(const VectorXd &v, const int num_field);
113 void setconf(const MatrixXcd &m);
119 void setconf(const MatrixXcd &m, const int num_field);
120
126 MatrixXcd vector2matrix(const int n) const;
132 MatrixXcd field2matrix(const int n) const;
138 MatrixXcd dfield2matrix(const int n) const;
139
140public:
143 explicit Field() {};
150 explicit Field(const int n1, const int n2) {Li = n1; num_f = n2;};
161 Field(const int n1, const int n2, const Distribution n3,
162 const double mean = 0.0, const double dev = 1.0) {
163 Li = n1; num_f = n2; setconf(num_f, n3, mean, dev);
164 };
178 Field(const int n1, const int n2, const int n3, const Distribution n4,
179 const double mean = 0.0, const double dev = 1.0) {
180 Li = n1; num_f = n2; setconf(n3, n4, mean, dev);
181 };
187 Field(const VectorXcd &v, const int num_field = 1) {setconf(v, num_field);};
194 Field(const VectorXd &v, const int num_field) {setconf(v, num_field);};
200 Field(const MatrixXcd &m) {setconf(m);};
208 Field(const MatrixXcd &m, const int num_field) {setconf(m, num_field);};
211 virtual ~Field() {};
212
215 static Field Zero(const int n1, const int n2) {
216 return Field {n1, n2, Distribution::Zero_conf}; };
219 static Field Zero(const int n1, const int n2, const int n3) {
220 return Field {n1, n2, n3, Distribution::Zero_conf}; };
223 static Field Gauss(const int n1, const int n2,
224 const double mean = 0.0, const double dev = 1.0) {
225 return Field {n1, n2, Distribution::Gauss_unit, mean, dev}; };
228 static Field Gauss(const int n1, const int n2, const int n3,
229 const double mean = 0.0, const double dev = 1.0) {
230 return Field {n1, n2, n3, Distribution::Gauss_unit, mean, dev}; };
233 static Field GaussL(const int n1, const int n2,
234 const double mean = 0.0) {
235 return Field {n1, n2, Distribution::Gauss_L, mean}; };
238 static Field GaussL(const int n1, const int n2, const int n3,
239 const double mean = 0.0) {
240 return Field {n1, n2, n3, Distribution::Gauss_L, mean}; };
243 static Field GaussMT(const int n1, const int n2,
244 const double mean = 0.0, const double dev = 1.0) {
245 return Field {n1, n2, Distribution::Gauss_MT_unit, mean, dev}; };
248 static Field GaussMT(const int n1, const int n2, const int n3,
249 const double mean = 0.0, const double dev = 1.0) {
250 return Field {n1, n2, n3, Distribution::Gauss_MT_unit, mean, dev}; };
253 static Field GaussMTL(const int n1, const int n2,
254 const double mean = 0.0) {
255 return Field {n1, n2, Distribution::Gauss_MT_L, mean}; };
258 static Field GaussMTL(const int n1, const int n2, const int n3,
259 const double mean = 0.0) {
260 return Field {n1, n2, n3, Distribution::Gauss_MT_L, mean}; };
263 static Field Vector(const VectorXcd &v, const int num_field = 1) {
264 return Field {v, num_field}; };
267 static Field Matrix(const MatrixXcd &m) {return Field {m};};
270 static Field Matrix(const MatrixXcd &m, const int num_field) {
271 return Field {m, num_field}; };
272
277 MatrixXcd conf() const {return field;};
282 VectorXcd conf(const int n) const {return field.col(n);};
287 VectorXd conf_real(const int n) const {return field.col(n).real();};
292 VectorXd conf_imag(const int n) const {return field.col(n).imag();};
293
298 virtual bool operator==(const Field &f) {return (Li==f.Li) && (num_f==f.num_f);};
303 virtual bool operator!=(const Field &f) {return !(*this==f);};
304
309 virtual Field &operator*=(const double n) { field *= n; return *this; };
314 virtual Field &operator/=(const double n) { field *= 1.0/n; return *this;};
315
322 Field conv(const int n1, const int n2) const;
328 Field conjconv(const int n) const;
335 Field conv_pw(const int pw, const int n = 0) const;
336
343 Field combine_with(const Field &f);
344
349 virtual void show() const;
350};
351
352
353#endif
Generate normal distributions; Compute convolutions.
Field conjconv(const int n) const
Convolution field(:,n)*conf(field(:,n))
static Field GaussMT(const int n1, const int n2, const int n3, const double mean=0.0, const double dev=1.0)
MatrixXcd field
Superfields.
Field(const MatrixXcd &m, const int num_field)
Set Li and field from MatrixXcd, but num_f=num_field
VectorXd conf_real(const int n) const
void setgaussl(const int num_col, const double mean=0.0)
MatrixXcd conf() const
static Field GaussMTL(const int n1, const int n2, const double mean=0.0)
static Field Vector(const VectorXcd &v, const int num_field=1)
static Field GaussL(const int n1, const int n2, const int n3, const double mean=0.0)
Field(const VectorXcd &v, const int num_field=1)
Set Li, num_f, and field from VectorXcd.
VectorXcd conf(const int n) const
MatrixXcd field2matrix(const int n) const
Field()
Constructor of Field.
virtual ~Field()
Destructor of Field.
virtual bool operator==(const Field &f)
Is identical (Li, num_f) ?
static Field GaussL(const int n1, const int n2, const double mean=0.0)
static Field Matrix(const MatrixXcd &m, const int num_field)
void setgauss(const int num_col, const double mean=0.0, const double dev=1.0)
void setgaussmtl(const int num_col, const double mean=0.0)
static Field GaussMT(const int n1, const int n2, const double mean=0.0, const double dev=1.0)
Field combine_with(const Field &f)
Combine with another Field object; Mutate field (Li and num_f are unchaged) except for the case that ...
void setconf(const int num_col, const Distribution n, const double mean=0.0, const double dev=1.0)
int Li
Physical box size, N_0=N_1.
VectorXd conf_imag(const int n) const
MatrixXcd dfield2matrix(const int n) const
Field conv(const int n1, const int n2) const
Convolution field(:,n1)*field(:,n2)
Field(const MatrixXcd &m)
Set Li, num_f, and field from MatrixXcd.
Field conv_pw(const int pw, const int n=0) const
Convolution field(:,n)*field(:,n)*...*field(:,n)
int num_f
Number of superfields.
Field(const int n1, const int n2, const int n3, const Distribution n4, const double mean=0.0, const double dev=1.0)
Set Li, num_f, and field; n3 is.
virtual Field & operator/=(const double n)
Devide by a real number n.
static Field Zero(const int n1, const int n2, const int n3)
Field(const int n1, const int n2)
Set Li=n1 and num_f=n2.
virtual void show() const
Output Li, field.
void setgaussmt(const int num_col, const double mean=0.0, const double dev=1.0)
Field(const int n1, const int n2, const Distribution n3, const double mean=0.0, const double dev=1.0)
Set Li, num_f, and field.
virtual bool operator!=(const Field &f)
Not identical (Li, num_f) ?
virtual Field & operator*=(const double n)
Multiply by a real number n.
static Field Gauss(const int n1, const int n2, const double mean=0.0, const double dev=1.0)
static Field GaussMTL(const int n1, const int n2, const int n3, const double mean=0.0)
static Field Matrix(const MatrixXcd &m)
static Field Gauss(const int n1, const int n2, const int n3, const double mean=0.0, const double dev=1.0)
static Field Zero(const int n1, const int n2)
MatrixXcd vector2matrix(const int n) const
Field(const VectorXd &v, const int num_field)
Set Li and field from VectorXd; num_f!=field.cols()
const std::complex< double > IM(0, 1.0)
Imaginary unit.
Distribution
Types of normal distributions.