78 throw "ERROR<NicolaiConf> Box size is not EVEN.";
82 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraA: number of fields should be 1.";
84 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraA: number of powers should be 1.";
85 if (lp.lambda.size() != 1)
86 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraA: number of couplings should be 1.";
90 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraD: number of fields should be 2.";
92 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraD: number of powers should be 1.";
93 if (lp.lambda.size() != 2)
94 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraD: number of couplings should be 2.";
98 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraE: number of fields should be 2.";
99 if (lp.lambda.size() != 2)
100 throw "ERROR<NicolaiConf> SuperPotentialType::AlgebraE: number of couplings should be 2.";
104 throw "ERROR<NicolaiConf> Number of fields should be positive.";
105 if (lp.k.size() == 0)
106 throw "ERROR<NicolaiConf> No values in powers.";
107 if (lp.lambda.size() == 0)
108 throw "ERROR<NicolaiConf> No values in couplings";
111 cerr << endl <<
"Calc start ..." << endl;
113 #pragma omp parallel for
114 for (
int in = lp.num_initialnic; in < lp.num_initialnic + lp.num_nicolai; ++in) {
116 double dmp = nic.
nr_method(lp.k, lp.lambda, lp.num_nrsolutions, lp.num_loop, lp.spt);
119 VectorXi signs(num_sol);
120 for (
int i = 0; i < num_sol; ++i) {signs(i) = nic.
sign_det(i);}
122 cerr <<
"lm" << lp.lambda.transpose() <<
" k" << lp.k.transpose() <<
" L" << lp.Li <<
" n" << in
123 <<
" " <<
"num_sol: " << num_sol << endl;
125 for (
int i = 0; i < num_sol; ++i) {
126 if (signs(i) == -1) {
127 cerr <<
"lm" << lp.lambda.transpose() <<
" k" << lp.k.transpose() <<
" L" << lp.Li <<
" n" << in
128 <<
"_" << i <<
" " <<
"sign: -1" << endl;
132 nic.
nic_output(lp.k, lp.lambda, lp.num_nrsolutions, signs, dmp, nic.
max_err(), lp.spt);
135 cerr <<
"Calc end ..." << endl << endl;
137 }
catch (
const char *str) {cerr << str << endl;
return;}
151 cout <<
"Box size : " << Li << endl
152 <<
"Number of fields: " << num_f << endl
153 <<
"Number of loop : " << loop << endl << endl;
156 VectorXd times = VectorXd::Zero(loop);
157 for (
int i = 0; i < loop; ++i) {
160 clock_t start1 = clock();
162 clock_t end1 = clock();
163 double t1 = (end1 - start1);
165 clock_t start2 = clock();
167 clock_t end2 = clock();
168 double t2 = (end2 - start2);
170 if (t1 > t2) ++which_fast;
172 if (sign != sign2) {cout << i <<
": Noooooooo!!!!!!! ("
173 << sign <<
", " << sign2 <<
")" << endl;}
175 ++count; cout <<
" #" << i <<
": sign_modf is negative" << endl;
178 cout <<
" #" << i <<
": sign_naive is negative" << endl;
182 <<
"Positive, Negative :" << loop - count <<
", " << count << endl
184 <<
"Which is fast? modf:" << loop - which_fast
185 <<
", naive:" << which_fast << endl
187 <<
"Ratio of time (modf/naive): "
189 << times.mean() << endl
190 <<
" Minimum, Maximum: "
191 << times.minCoeff() <<
", " << times.maxCoeff() << endl;
199static int get_val(FILE* fp,
const char *str,
const char* fmt,
void* val){
201 if(1!=fscanf(fp,
"%s",c)) {
202 fprintf(stderr,
"Error reading input file at %s\n",str);
205 if(strcmp(str,c)!=0) {
206 fprintf(stderr,
"Error reading input file expected %s found %s\n",str,c);
209 if(1!=fscanf(fp,fmt,val)) {
210 fprintf(stderr,
"Error reading input file at %s\n",str);
211 fprintf(stderr,
"Cannot read value format %s\n",fmt);
220static int read_input(
char *input) {
224 fprintf(stderr,
"Cannot open input file %s\n",input);
228 get_val(fp,
"Li",
"%i",&(params.Li));
229 get_val(fp,
"num_f",
"%i",¶ms.num_f);
230 get_val(fp,
"potentialtype",
"%i",&spt);
239 get_val(fp,
"testmode",
"%i",¶ms.testmode);
240 get_val(fp,
"num_nrsolutions",
"%i",¶ms.num_nrsolutions);
241 get_val(fp,
"num_nicolai",
"%i",¶ms.num_nicolai);
242 get_val(fp,
"num_initialnic",
"%i",¶ms.num_initialnic);
243 get_val(fp,
"num_loop",
"%i",¶ms.num_loop);
244 get_val(fp,
"num_power",
"%i",¶ms.num_power);
245 params.k = VectorXi::Zero(params.num_power);
246 for (
int i = 0; i<params.num_power; ++i) {
247 get_val(fp,
"k",
"%i",¶ms.k(i));
249 get_val(fp,
"num_coupling",
"%i",¶ms.num_coupling);
250 params.lambda = VectorXd::Zero(params.num_coupling);
251 for (
int i = 0; i<params.num_coupling; ++i) {
252 get_val(fp,
"lambda",
"%lf",¶ms.lambda(i));
254 cerr <<
"Superpotential Type : ";
256 cerr <<
"Algebra A" << endl;
258 cerr <<
"Algebra D" << endl;
260 cerr <<
"Algebra E" << endl;
262 cerr <<
"Custom type" << endl;
263 cerr <<
"Physical Box Size : " << params.Li << endl
264 <<
"Power in SuperPotential: " << params.k.transpose() << endl
265 <<
"Coupling : " << params.lambda.transpose() << endl << endl
266 <<
"Configuration Number : " << params.num_initialnic <<
"~" << params.num_initialnic + params.num_nicolai << endl
267 <<
"Number of Loop : " << params.num_loop << endl;
275int main (
int argc,
char*argv[]) {
276 cout << endl <<
"main start ..." << endl;
277 clock_t start = clock();
285 fprintf(stderr,
"Number of arguments not correct\n");
286 fprintf(stderr,
"Usage: %s <infile> \n",argv[0]);
292 if (params.testmode==1) {
294 nic.
test_nr_method(params.k,params.lambda,params.num_loop,params.num_nrsolutions,params.spt);
299 clock_t end = clock();
300 cerr << (double)(end - start) / CLOCKS_PER_SEC <<
"sec" << endl;
301 cout <<
"main end ..." << endl;
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.
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.
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.
int sign_det(const int n) const
Sign determinant (Jacobian)
double max_err() const
Maximum error of NR method.
double nr_method(const VectorXi k, const VectorXd lambda, const int num_nrsol, const int LOOP, const SuperPotentialType t=SuperPotentialType::AlgebraA)
Newton–Raphson method.
Compute Jacobian and its sign determinant.
int sign_det(const int debug=0) const
Sign determinant with a fast algorithm (num_f < 4)
int sign_det4multifield(const int debug=0) const
Sign determinant for mutli-superfield.
const double SOL_ID_MAXVAL
Identification of scalar solutions.
int main(int argc, char *argv[])
Main function.
const double NR_INTERRUPTION
Interruption of NR iteration.
void NicolaiConf(const lg_params_t lp)
Solve a Landau–Ginzburg model by NR method; Parallel computing with openmp.
const double MAX_NRERR
Max error of NR iteration.
void Test_SignDet(const int Li, const int num_f, const int loop)
Test program: computation of sign_det() in Potential; Compare signs and times, which are computed by ...
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.