10 int N = (
Li+1) * (
Li+1);
11 VectorXd NR = VectorXd::Zero(2*N *
num_f);
12 for (
int j = 0; j <
num_f; ++j) {
14 for (
int i = 0; i < N; ++i) {
15 NR(tmp + i) =
field(i, j).real();
16 NR(tmp + i + N) =
field(i, j).imag();
23 int N = (
Li+1) * (
Li+1);
24 int num_col =
field.cols();
25 VectorXcd NR = VectorXcd::Zero(N * num_col);
26 for (
int j = 0; j < num_col; ++j) {
28 for (
int i = 0; i < N; ++i) {NR(tmp + i) =
field(i, j);}
40 if (lambda.size() == 1) {
41 fnm =
"lm"; fnm += std::to_string(lambda(0));
43 for(
int i = 0; i < lambda.size(); ++i) {
44 fnm +=
"lm"; fnm += std::to_string(i);
45 fnm +=
"-"; fnm += std::to_string(lambda(i));
49 fnm +=
"k"; fnm += std::to_string(k(0));
51 for (
int i = 0; i < k.size(); ++i) {
52 fnm +=
"k"; fnm += std::to_string(i);
53 fnm +=
"-"; fnm += std::to_string(k(i));
56 fnm +=
"L"; fnm += std::to_string(
Li);
57 fnm +=
"n"; fnm += std::to_string(
in);
59 std::ofstream fo_n; std::string fnm_n;
60 fnm_n =
"confs/nicolai_";
69 fnm_n += fnm; fnm_n +=
".dat";
72 fo_n <<
"# Superpotential Type" << endl;
74 fo_n <<
"AlgebraA" << endl;
76 fo_n <<
"AlgebraD" << endl;
78 fo_n <<
"AlgebraE" << endl;
80 fo_n <<
"Custom" << endl;
82 fo_n <<
"# Physical Box Size, Power, Coupling" << endl
83 <<
Li <<
", " << k.transpose() <<
", " << lambda.transpose() << endl
84 <<
"# Nicolai Configuration Number" << endl
86 <<
"# Number of Solutions and Dumped-Solutions" << endl
87 << signs.size() <<
", "
88 << dmp <<
" / " << (num_nrsol + dmp) << endl
89 <<
"# Signs of Determinants" << endl
90 << signs.transpose() << endl
91 <<
"# Max norm of residue" << endl
93 <<
"# Configuration of Gaussian random numbers" << endl
94 << std::setprecision(20) <<
field;
100 cout <<
"# class Nicolai" << endl
101 <<
"Li = " <<
Li << endl
102 <<
"in = " <<
in << endl
103 <<
"field = " << endl
111 if (err < sol_id_maxval) {
return true;}
118 int num_col =
field.cols();
119 VectorXcd p = VectorXcd::Zero(N);
120 for (
int i = 0; i < N; ++i) {
121 p(i) = 2 * M_PI / double(
Li)
122 * (
IM * double(L/2 - i/L) + double(L/2 - i%L));
124 VectorXcd NR = VectorXcd::Zero(N * num_col);
125 for (
int j = 0; j < num_col; ++j) {
127 for (
int i = 0; i < N; ++i) {NR(tmp + i) = p(i) *
field(i, j);}
133Potential Scalar::superpotential_typealgebraA ()
const {
136 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraA: number of field should be 1.";
138 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraA: size of VectorXi for powers should be 1.";
139 if (lambda.size() != 1)
140 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraA: size of VectorXd for couplings should be 1.";
142 Field f =
conv_pw(k(0)-2); f *= double(k(0)-1) * lambda(0);
145 }
catch (
const char *str) {
148Potential Scalar::superpotential_typealgebraD ()
const {
151 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraD: number of fields should be 2.";
153 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraD: size of VectorXi for powers should be 1.";
154 if (lambda.size() != 2)
155 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraD: size of VectorXd for couplings should be 2.";
157 Field Xk2 =
conv_pw(k(0)-2,0); Xk2 *= double(k(0)-1) * lambda(0);
164 }
catch (
const char *str) {
167Potential Scalar::superpotential_typealgebraE ()
const {
170 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraE (E_7): number of fields should be 2.";
171 if (lambda.size() != 2)
172 throw "ERROR<Scalar::superpotential> Case SuperPotentialType::AlgebraE (E_7): size of VectorXd for couplings should be 2.";
179 X1 *= 2.0 * lambda(0); Y2 *= lambda(1); XY *= 2.0 * lambda(1);
184 }
catch (
const char *str) {
192 return superpotential_typealgebraA();
195 return superpotential_typealgebraD();
198 return superpotential_typealgebraE();
201 return superpotential_typecustom();
206PotentialNR Scalar::superpotential_nr_typealgebraA ()
const {
209 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraA: number of field should be 1.";
211 throw "ERROR<Scalar::superpotentia_nrl> Case SuperPotentialType::AlgebraA: size of VectorXi for powers should be 1.";
212 if (lambda.size() != 1)
213 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraA: size of VectorXd for couplings should be 1.";
218 f1 *= double(k(0)-1);
219 MatrixXcd m2 = f2.
conf();
222 }
catch (
const char *str) {
225PotentialNR Scalar::superpotential_nr_typealgebraD ()
const {
228 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraD: number of fields should be 2.";
230 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraD: size of VectorXi for powers should be 1.";
231 if (lambda.size() != 2)
232 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraD: size of VectorXd for couplings should be 2.";
246 X1 *= lambda(1); Y1 *= lambda(1);
247 Xk2 *= double(k(0)-1) * lambda(0);
252 Y2 *= lambda(1) / 2.0; XY *= lambda(1); Xk1 *= lambda(0);
258 Y2 *= 2.0; XY *= 2.0; Xk1 *= double(k(0)-1);
264 }
catch (
const char *str) {
267PotentialNR Scalar::superpotential_nr_typealgebraE ()
const {
270 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraE (E_7): number of fields should be 2.";
271 if (lambda.size() != 2)
272 throw "ERROR<Scalar::superpotential_nr> Case SuperPotentialType::AlgebraE (E_7): size of VectorXd for couplings should be 2.";
289 MatrixXcd tmp = ( XYY.
conf() + 2.0 * YXY.
conf() ) / 3.0;
295 X1 *= 2.0 * lambda(0); Y2 *= lambda(1); XY *= 2.0 * lambda(1);
300 X2 *= lambda(0); Y3 *= lambda(1) / 3.0; XY2 *= lambda(1);
306 X2 *= 2.0; Y3 *= 3.0; XY2 *= 3.0;
312 }
catch (
const char *str) {
320 return superpotential_nr_typealgebraA();
323 return superpotential_nr_typealgebraD();
326 return superpotential_nr_typealgebraE();
329 return superpotential_nr_typecustom();
339 MatrixXd m = p_nr.
nr_mat();
340 VectorXd v_res = m.partialPivLu().solve(v);
341 *
this =
Scalar {*
this, v_res};
return *
this;
349 return (v + w.conjugate() - n) / n.norm();
353 const int sign,
const double err)
const {
355 if (lambda.size() == 1) {
356 fnm =
"lm"; fnm += std::to_string(lambda(0));
358 for(
int i = 0; i < lambda.size(); ++i) {
359 fnm +=
"lm"; fnm += std::to_string(i);
360 fnm +=
"-"; fnm += std::to_string(lambda(i));
364 fnm +=
"k"; fnm += std::to_string(k(0));
366 for (
int i = 0; i < k.size(); ++i) {
367 fnm +=
"k"; fnm += std::to_string(i);
368 fnm +=
"-"; fnm += std::to_string(k(i));
371 fnm +=
"L"; fnm += std::to_string(
Li);
372 fnm +=
"n"; fnm += std::to_string(in);
374 std::ofstream fo_p; std::string fnm_p;
375 fnm_p =
"confs/phi_";
385 fnm_p +=
"_"; fnm_p += std::to_string(i); fnm_p +=
".dat";
388 fo_p <<
"# Superpotential Type" << endl;
390 fo_p <<
"AlgebraA" << endl;
392 fo_p <<
"AlgebraD" << endl;
394 fo_p <<
"AlgebraE" << endl;
396 fo_p <<
"Custom" << endl;
398 fo_p <<
"# Physical Box Size, Power, Coupling" << endl
399 <<
Li <<
", " << k.transpose() <<
", " << lambda.transpose() << endl
400 <<
"# Nicolai Configuration Number" << endl
402 <<
"# Solution Configuration Number" << endl
403 << i <<
" / " << num_sol << endl
404 <<
"# Sign of Determinant" << endl << sign << endl
405 <<
"# Norm of residue" << endl << err << endl
406 <<
"# Configuration of a scalar field solution" << endl
407 << std::setprecision(20) <<
field;
412 cout <<
"# class Scalar" << endl
413 <<
"Li = " <<
Li << endl
414 <<
"k = " << k.transpose() << endl
415 <<
"lambda = " << lambda.transpose() << endl
416 <<
"field = " << endl
424 if (fs.size() == 0) {
425 fs.push_back(f); errs.push_back(err);
return *
this;
428 throw "ERROR<NicolaiSol::add_sol> Sizes of Scalars are not same.";
430 for(
int i = 0; i < fs.size(); ++i) {
431 if ( fs[i].is_identical(f) ) {
id =
false;
break;}
433 if (
id) {fs.push_back(f); errs.push_back(err);}
return *
this;
434 }
catch (
const char *str) {cerr << str << endl;
return *
this;}
437 for (
int i = 0; i < sol.fs.size(); ++i) {
438 add_sol(sol.fs[i], sol.errs[i]);
444 const int num_nrsol,
const int LOOP,
448 throw "ERROR<NicolaiSol::nr_method> Box size is not EVEN.";
450 for (
int i = 0; i < num_nrsol; ++i) {
452 double err;
double min_err;
453 for (
int j = 0; j < LOOP; ++j) {
456 if (j == 0 || err < min_err) min_err = err;
457 else if (err >= min_err * nr_interruption)
break;
463 }
catch (
const char *str) {cerr << str << endl;
return -1;}
467 const int LOOP,
const int TRIAL,
471 throw "ERROR<NicolaiSol::test_nr_method> Box size is not EVEN.";
473 for (
int j = 0; j < TRIAL; ++j) {
475 <<
"##########################################" << endl
476 << j+1 <<
"-th trial" << endl
477 <<
"##########################################" << endl
478 <<
"Physical Box Size : " <<
Li << endl
479 <<
"Power in SuperPotential: " << k.transpose() << endl
480 <<
"Coupling : " << lambda.transpose()
485 cout <<
"Initial Error of NR " << endl
486 << err << endl << endl;
488 clock_t start_nr = clock();
491 for (
int i = 0; i < LOOP; ++i) {
492 cout <<
"NR iteration " << std::setw(3) << i+1 <<
": ";
496 cout <<
"Error of NR "
497 << std::setprecision(15) << err
498 <<
" (" << tmp_id <<
")" << endl;
500 if (i == 0 || err < min_err) min_err = err;
501 else if (err >= min_err * nr_interruption)
break;
505 clock_t end_nr = clock();
506 cout << (double)(end_nr-start_nr) / CLOCKS_PER_SEC <<
"sec"
512 }
catch (
const char *str) {cerr << str << endl;
return;}
517 for (
int i = 0; i <
num_sol; ++i) {
518 fs[i].scl_output(
in,
num_sol, i, signs(i), errs[i]);
524 int fssize = fs.size();
526 throw "ERROR<NicolaiSol::show> No entries in this object.";
527 cout <<
"# class NicolaiSol with " << fssize <<
" Scalars" << endl;
528 for (
int i = 0; i < fssize; ++i) {
529 cout <<
"# entry: " << i << endl <<
"#"; fs[i].show();
532 }
catch (
const char *str) {cerr << str << endl;
return;}
Generate normal distributions; Compute convolutions.
MatrixXcd field
Superfields.
Field combine_with(const Field &f)
Combine with another Field object; Mutate field (Li and num_f are unchaged) except for the case that ...
int Li
Physical box size, N_0=N_1.
Field conv(const int n1, const int n2) const
Convolution field(:,n1)*field(:,n2)
Field conv_pw(const int pw, const int n=0) const
Convolution field(:,n)*field(:,n)*...*field(:,n)
int num_f
Number of superfields.
Nicolai map; Compute Vector for NR method.
int in
ID number for the Nicolai map.
VectorXcd nrerr_nvec() const
Compute Vector for NR error estimate (complex type)
VectorXd nr_nvec() const
Compute Vector for NR method (Real type)
void nic_output(const VectorXi k, const VectorXd lambda, const int num_nrsol, const VectorXi signs, const int dmp, const double max_err, const SuperPotentialType spt) const
Output to file.
void show() const
Output Li, in, field.
Execute the Newton–Raphson method; Combine solutions; Obtain sign det for each Scalar.
int num_sol() const
Number of solutions.
void phi_output(const int in, const VectorXi signs) const
Output to file.
NicolaiSol & add_sol(const Scalar &f, const double &err)
Add a new solution; Ignore identical one.
void test_nr_method(const VectorXi k, const VectorXd lambda, const int LOOP, const int TRIAL, const SuperPotentialType t=SuperPotentialType::AlgebraA)
Observe the numerical convergence of NR method for each system.
double nr_method(const VectorXi k, const VectorXd lambda, const int num_nrsol, const int LOOP, const SuperPotentialType t=SuperPotentialType::AlgebraA)
Newton–Raphson method.
void show() const
Output Scalars.
Compute Jacobian and its sign determinant.
Compute Matrix and Vector for NR method.
VectorXd nr_pvec() const
Compute Vector for NR method (Real type)
MatrixXd nr_mat() const
Compute Matrix for NR method (Real type)
VectorXcd nrerr_pvec() const
Compute Vector for NR error estimate (complex type)
An solution of Nicolai map; Update to a new solution with NR method; Compute some types of superpoten...
Scalar nr_loop(const Nicolai &nic)
An iteration of NR method; Compute LU decompositon; Overwrite own members.
void show() const
Output Li, k, lambda, field.
PotentialNR superpotential_nr() const
Compute superpotential (class PotentialNR)
VectorXcd nr_error_vec(const Nicolai &nic) const
Compute error of NR method for each momentum.
double nr_error(const Nicolai &nic) const
Compute error of NR method.
Potential superpotential() const
Compute superpotential (class Potential)
bool is_identical(const Scalar &f) const
Identify two solutions.
void scl_output(const int in, const int num_sol, const int i, const int sign, const double err) const
Output to file.
VectorXcd nrerr_svec() const
Compute Vector for NR error (complex type)
const std::complex< double > IM(0, 1.0)
Imaginary unit.
int SuperPotentialType_StdNumSol(const VectorXi k, const SuperPotentialType t)
Standard number of solutions for each SuperPotentialType.
Definition of the classes associated with Nicolai map.
SuperPotentialType
Types of superpotentials.
const double MAX_NRERR
Max error of NR iteration.
const int SuperPotentialTypeCustom_StdNumSol
Standard number of solutions for SuperPotentialType::Custom.