Browse Source

Finish first clean of src files

master
J.-S. Caux 6 years ago
parent
commit
0559fa9301

+ 142
- 758
src/SCAN/Descendents.cc
File diff suppressed because it is too large
View File


+ 262
- 879
src/SCAN/General_Scan.cc
File diff suppressed because it is too large
View File


+ 17
- 100
src/SCAN/General_Scan_Parallel.cc View File

@@ -52,7 +52,8 @@ namespace ABACUS {
52 52
 
53 53
     Vect<Scan_Thread_Data> thr_data_par(nr_processors_at_newlevel);
54 54
     for (int rank = 0; rank < nr_processors_at_newlevel; ++rank)
55
-      thr_data_par[rank] = Scan_Thread_Data (THRDIRS_stringstream[rank].str(), false); // put refine == false here to avoid loading any deprecated data
55
+      thr_data_par[rank] = Scan_Thread_Data (THRDIRS_stringstream[rank].str(), false);
56
+    // put refine == false here to avoid loading any deprecated data
56 57
 
57 58
     // Transfer all the existing threads into the new ones:
58 59
     int rankindex = 0;
@@ -83,59 +84,12 @@ namespace ABACUS {
83 84
     return;
84 85
   }
85 86
 
86
-  /*
87
-  void Create_Empty_Files (string prefix, char whichDSF, int nr_processors_at_newlevel)
88
-  {
89
-    // This function creates, for convenience, a set of 'empty' files, so a full set of files is available at all paralevels.
90
-    for (int rank = 0; rank < nr_processors_at_newlevel; ++rank) {
91
-      stringstream RAW_stringstream;    string RAW_string;
92
-      stringstream INADM_stringstream;    string INADM_string;
93
-      stringstream CONV0_stringstream;    string CONV0_string;
94
-      stringstream LOG_stringstream;    string LOG_string;
95
-      //stringstream THR_stringstream;    string THR_string;
96
-      stringstream SRC_stringstream;    string SRC_string;
97
-      stringstream FSR_stringstream;    string FSR_string;
98
-      stringstream SUM_stringstream;    string SUM_string;
99
-
100
-      RAW_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".raw";
101
-      INADM_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".inadm";
102
-      CONV0_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".conv0";
103
-      LOG_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".log";
104
-      //THR_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".thr";
105
-      SRC_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".src";
106
-      FSR_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".fsr";
107
-      SUM_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".sum";
108
-
109
-      RAW_string = RAW_stringstream.str();    const char* RAW_Cstr = RAW_string.c_str();
110
-      INADM_string = INADM_stringstream.str();    const char* INADM_Cstr = INADM_string.c_str();
111
-      CONV0_string = CONV0_stringstream.str();    const char* CONV0_Cstr = CONV0_string.c_str();
112
-      LOG_string = LOG_stringstream.str();    const char* LOG_Cstr = LOG_string.c_str();
113
-      //THR_string = THR_stringstream.str();    const char* THR_Cstr = THR_string.c_str();
114
-      SRC_string = SRC_stringstream.str();    const char* SRC_Cstr = SRC_string.c_str();
115
-      FSR_string = FSR_stringstream.str();    const char* FSR_Cstr = FSR_string.c_str();
116
-      SUM_string = SUM_stringstream.str();    const char* SUM_Cstr = SUM_string.c_str();
117
-
118
-      // We open and close these files (except for SUM, which we fill with a zero-valued scan_info
119
-      fstream RAW_file; RAW_file.open(RAW_Cstr); RAW_file.close();
120
-      fstream INADM_file; INADM_file.open(INADM_Cstr); INADM_file.close();
121
-      fstream CONV0_file; CONV0_file.open(CONV0_Cstr); CONV0_file.close();
122
-      fstream LOG_file; LOG_file.open(LOG_Cstr); LOG_file.close();
123
-      Scan_Info emptyinfo; emptyinfo.Save(SRC_Cstr);
124
-      fstream FSR_file; FSR_file.open(FSR_Cstr); FSR_file.close();
125
-      fstream SUM_file; SUM_file.open(SUM_Cstr); SUM_file.close();
126
-
127
-    }
128
-  }
129
-  */
130 87
 
131 88
   void Merge_raw_Files (string prefix, char whichDSF, int nr_processors_at_newlevel)
132 89
   {
133 90
 
134 91
     // Open the original raw file:
135 92
     stringstream RAW_stringstream;    string RAW_string;
136
-    //RAW_stringstream << prefix;
137
-    //if (whichDSF == 'Z') RAW_stringstream << ".dat";
138
-    //else RAW_stringstream << ".raw";
139 93
     RAW_stringstream << prefix << ".raw";
140 94
     RAW_string = RAW_stringstream.str();    const char* RAW_Cstr = RAW_string.c_str();
141 95
 
@@ -153,23 +107,18 @@ namespace ABACUS {
153 107
       ifstream RAW_infile;
154 108
       RAW_infile.open(RAW_in_Cstr);
155 109
       if (RAW_infile.fail()) {
156
-	//cout << RAW_in_Cstr << endl;
157
-	//ABACUSerror ("Could not open file.");
158 110
 	continue; // if file isn't there, just continue...
159 111
       }
160 112
 
161 113
       DP omega;
162 114
       int iK;
163 115
       DP FF;
164
-      //int conv;
165 116
       DP dev;
166 117
       string label;
167 118
       int nr, nl;
168 119
       while (RAW_infile.peek() != EOF) {
169
-	//RAW_infile >> omega >> iK >> FF >> conv >> label;
170 120
 	RAW_infile >> omega >> iK >> FF >> dev >> label;
171 121
 	if (whichDSF == '1') RAW_infile >> nr >> nl;
172
-	//RAW_outfile << endl << omega << "\t" << iK << "\t" << FF << "\t" << conv << "\t" << label;
173 122
 	RAW_outfile << endl << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label;
174 123
 	if (whichDSF == '1') RAW_outfile << "\t" << nr << "\t" << nl;
175 124
       }
@@ -244,7 +193,6 @@ namespace ABACUS {
244 193
     SUM_string = SUM_stringstream.str();    const char* SUM_Cstr = SUM_string.c_str();
245 194
 
246 195
     // Load the original info:
247
-    //ScanStateList.Load_Info (SUM_Cstr);  // Not needed anymore: rank 0 has loaded the original info
248 196
     if (file_exists(SUM_Cstr)) ScanStateList.Load_Info (SUM_Cstr);  // Needed again!
249 197
 
250 198
     // Load all other info:
@@ -470,12 +418,9 @@ namespace ABACUS {
470 418
   //****************************************************************************//
471 419
   // Model-specific functions:
472 420
 
473
-  //void Prepare_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iK_UL, bool fixed_iK, int iKneeded,
474 421
   void Prepare_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iKmin, int iKmax, DP kBT,
475
-				   string defaultScanStatename,
476
-				   //int Max_Secs, bool refine, int rank,
477
-				   int paralevel, Vect<int> rank_lower_paralevels, Vect<int> nr_processors_lower_paralevels,
478
-				   int nr_processors_at_newlevel)
422
+				      string defaultScanStatename, int paralevel, Vect<int> rank_lower_paralevels,
423
+				      Vect<int> nr_processors_lower_paralevels, int nr_processors_at_newlevel)
479 424
   {
480 425
     // From an existing scan, this function splits the threads into
481 426
     // nr_processors_at_newlevel separate files, from which the parallel process
@@ -485,35 +430,21 @@ namespace ABACUS {
485 430
 
486 431
     // Define file name
487 432
     stringstream filenameprefix;
488
-    //Data_File_Name (filenameprefix, whichDSF, fixed_iK, iKneeded, GroundState, GroundState);
489 433
     Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, kBT, GroundState, GroundState, defaultScanStatename);
490 434
     for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
491 435
     string prefix = filenameprefix.str();
492 436
 
493 437
     Split_thr_Files (prefix, whichDSF, nr_processors_at_newlevel);
494 438
 
495
-    //Create_Empty_Files (prefix, whichDSF, nr_processors_at_newlevel);
496
-
497 439
     return;
498 440
   }
499 441
 
500
-  //void Wrapup_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iK_UL, bool fixed_iK, int iKneeded,
501 442
   void Wrapup_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iKmin, int iKmax, DP kBT,
502
-				  string defaultScanStatename,
503
-				  //int Max_Secs, bool refine, int rank,
504
-				  int paralevel, Vect<int> rank_lower_paralevels, Vect<int> nr_processors_lower_paralevels,
505
-				  int nr_processors_at_newlevel)
443
+				     string defaultScanStatename, int paralevel, Vect<int> rank_lower_paralevels,
444
+				     Vect<int> nr_processors_lower_paralevels, int nr_processors_at_newlevel)
506 445
   {
507
-    //DP epsilon = log(L)/L;
508
-
509
-    //LiebLin_Bethe_State GroundState (c_int, L, N);
510
-    //LiebLin_Bethe_State spstate = Canonical_Saddle_Point_State (c_int, L, N, kBT, epsilon);
511
-    //LiebLin_Bethe_State spstate = Canonical_Saddle_Point_State (c_int, L, N, kBT);
512
-
513 446
     // Read the saddle-point state from the sps file:
514 447
     stringstream SPS_stringstream;  string SPS_string;
515
-    //SPS_stringstream << "Tgt0_";
516
-    //Data_File_Name (SPS_stringstream, whichDSF, iKmin, iKmax, kBT, spstate, SeedScanState, "");
517 448
     Data_File_Name (SPS_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
518 449
     SPS_stringstream << ".sps";
519 450
     SPS_string = SPS_stringstream.str();    const char* SPS_Cstr = SPS_string.c_str();
@@ -546,14 +477,13 @@ namespace ABACUS {
546 477
     if (whichDSF == 'g') Nscan = N + 1;
547 478
 
548 479
     LiebLin_Bethe_State SeedScanState = spstate;
549
-    //if (whichDSF == 'o' || whichDSF == 'g') SeedScanState = Canonical_Saddle_Point_State (c_int, L, Nscan, kBT, epsilon);
550 480
     if (whichDSF == 'o' || whichDSF == 'g') SeedScanState = Canonical_Saddle_Point_State (c_int, L, Nscan, kBT);
551 481
 
552 482
     // Define file name
553 483
     stringstream filenameprefix;
554
-    //Data_File_Name (filenameprefix, whichDSF, fixed_iK, iKneeded, GroundState, GroundState);
555 484
     Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, kBT, spstate, SeedScanState, defaultScanStatename);
556
-    for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
485
+    for (int i = 0; i < paralevel - 1; ++i)
486
+      filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
557 487
     string prefix = filenameprefix.str();
558 488
 
559 489
 
@@ -570,19 +500,7 @@ namespace ABACUS {
570 500
     Merge_inadm_conv0_src_stat_log_Files (prefix, whichDSF, nr_processors_at_newlevel);
571 501
     // This also puts some digested info in log file.
572 502
 
573
-    // Evaluate f-sumrule:
574
-    /*
575
-    stringstream RAW_stringstream;    string RAW_string;
576
-    RAW_stringstream << prefix << ".raw";
577
-    RAW_string = RAW_stringstream.str();    const char* RAW_Cstr = RAW_string.c_str();
578
-
579
-    stringstream FSR_stringstream;    string FSR_string;
580
-    FSR_stringstream << prefix << ".fsr";
581
-    FSR_string = FSR_stringstream.str();    const char* FSR_Cstr = FSR_string.c_str();
582
-    */
583 503
     DP Chem_Pot = Chemical_Potential (spstate);
584
-    //if (!fixed_iK) if (whichDSF != 'q') Evaluate_F_Sumrule (whichDSF, GroundState, Chem_Pot, RAW_Cstr, FSR_Cstr);
585
-    //if (iKmin != iKmax) if (whichDSF != 'q') Evaluate_F_Sumrule (whichDSF, GroundState, Chem_Pot, iKmin, iKmax, RAW_Cstr, FSR_Cstr);
586 504
     if (iKmin != iKmax) if (whichDSF != 'q') Evaluate_F_Sumrule (prefix, whichDSF, spstate, Chem_Pot, iKmin, iKmax);
587 505
 
588 506
     // ... and we're done.
@@ -595,7 +513,6 @@ namespace ABACUS {
595 513
   // Heisenberg:
596 514
 
597 515
   void Prepare_Parallel_Scan_Heis (char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax,
598
-				   //int Max_Secs, bool refine, int rank,
599 516
 				   int paralevel, Vect<int> rank_lower_paralevels, Vect<int> nr_processors_lower_paralevels,
600 517
 				   int nr_processors_at_newlevel)
601 518
   {
@@ -611,8 +528,6 @@ namespace ABACUS {
611 528
 
612 529
     Heis_Base baseconfig_groundstate(BD1, Nrapidities_groundstate);
613 530
 
614
-    //Ix2_Offsets baseoffsets(baseconfig_groundstate, 0ULL);
615
-
616 531
     // Define file name
617 532
     stringstream filenameprefix;
618 533
 
@@ -639,7 +554,8 @@ namespace ABACUS {
639 554
 
640 555
     else ABACUSerror("Delta out of range in Prepare_Parallel_Scan_Heis");
641 556
 
642
-    for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
557
+    for (int i = 0; i < paralevel - 1; ++i)
558
+      filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
643 559
     string prefix = filenameprefix.str();
644 560
 
645 561
     Split_thr_Files (prefix, whichDSF, nr_processors_at_newlevel);
@@ -664,8 +580,6 @@ namespace ABACUS {
664 580
 
665 581
     Heis_Base baseconfig_groundstate(BD1, Nrapidities_groundstate);
666 582
 
667
-    //Ix2_Offsets baseoffsets(baseconfig_groundstate, 0ULL);
668
-
669 583
     // Define file name
670 584
     stringstream filenameprefix;
671 585
     string prefix;
@@ -681,7 +595,8 @@ namespace ABACUS {
681 595
       else ABACUSerror("Unknown whichDSF in Scan_Heis.");
682 596
 
683 597
       Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, 0.0, GroundState, SeedScanState, "");
684
-      for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
598
+      for (int i = 0; i < paralevel - 1; ++i)
599
+	filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
685 600
       prefix = filenameprefix.str();
686 601
 
687 602
       // Merge sum files
@@ -715,7 +630,8 @@ namespace ABACUS {
715 630
       else ABACUSerror("Unknown whichDSF in Scan_Heis.");
716 631
 
717 632
       Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, 0.0, GroundState, SeedScanState, "");
718
-      for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
633
+      for (int i = 0; i < paralevel - 1; ++i)
634
+	filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
719 635
       prefix = filenameprefix.str();
720 636
 
721 637
       // Merge sum files
@@ -748,7 +664,8 @@ namespace ABACUS {
748 664
       else ABACUSerror("Unknown whichDSF in Scan_Heis.");
749 665
 
750 666
       Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, 0.0, GroundState, SeedScanState, "");
751
-      for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
667
+      for (int i = 0; i < paralevel - 1; ++i)
668
+	filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
752 669
       prefix = filenameprefix.str();
753 670
 
754 671
       // Merge sum files
@@ -773,7 +690,7 @@ namespace ABACUS {
773 690
     else ABACUSerror("Delta out of range in Prepare_Parallel_Scan_Heis");
774 691
 
775 692
 
776
-     // ... and we're done.
693
+    // ... and we're done.
777 694
 
778 695
     return;
779 696
   }

+ 0
- 3
src/SCAN/Particle_Hole_Excitation_Cost.cc View File

@@ -24,10 +24,7 @@ namespace ABACUS {
24 24
     // Estimates the cost of adding a particle-hole excitation to an intermediate state
25 25
     DP ph_cost = 1.0;
26 26
 
27
-    //if (whichDSF == 'd') ph_cost = ABACUS::min(0.1, 1.0/sqrt(AveragingState.c_int));
28
-    //if (whichDSF == 'd') ph_cost = ABACUS::min(0.1, 1.0/AveragingState.c_int);
29 27
     if (whichDSF == 'd') ph_cost = ABACUS::min(0.01, 0.1/AveragingState.c_int);
30
-    //if (whichDSF == 'd') ph_cost = ABACUS::min(0.001, 0.01/AveragingState.c_int);
31 28
     else if (whichDSF == 'o') ph_cost = 0.01;
32 29
     else if (whichDSF == 'g') ph_cost = 0.01;
33 30
     else if (whichDSF == 'Z') ph_cost = 1.0;

+ 13
- 22
src/SCAN/Scan_Info.cc View File

@@ -20,13 +20,9 @@ using namespace ABACUS;
20 20
 namespace ABACUS {
21 21
 
22 22
   Scan_Info::Scan_Info() :
23
-    //sumrule_obtained(0.0), Nfull(0LL), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), CPU_ticks(0LL), CPU_ticks_TOT(0LL)  {}
24
-    //sumrule_obtained(0.0), Nfull(0.0), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), CPU_ticks(0LL), CPU_ticks_TOT(0LL)  {}
25 23
     sumrule_obtained(0.0), Nfull(0.0), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), TT(0.0)  {}
26 24
 
27
-  //Scan_Info::Scan_Info (DP sr, long long int Nf, long long int Ni, long long int Nd, long long int Ndc, long long int Ndc0, long long int t) :
28 25
   Scan_Info::Scan_Info (DP sr, DP Nf, long long int Ni, long long int Nd, long long int Ndc, long long int Ndc0, double t) :
29
-    //sumrule_obtained(sr), Nfull(Nf), Ninadm(Ni), Ndata(Nd), Ndata_conv(Ndc), Ndata_conv0(Ndc0), CPU_ticks(t), CPU_ticks_TOT(t) {}
30 26
     sumrule_obtained(sr), Nfull(Nf), Ninadm(Ni), Ndata(Nd), Ndata_conv(Ndc), Ndata_conv0(Ndc0), TT(t) {}
31 27
 
32 28
   void Scan_Info::Save (const char* outfile_Cstr)
@@ -36,19 +32,17 @@ namespace ABACUS {
36 32
     outfile.open(outfile_Cstr);
37 33
     if (outfile.fail()) ABACUSerror("Could not open outfile... ");
38 34
 
39
-    //outfile.setf(ios::fixed);
40
-    //outfile.setf(ios::showpoint);
41 35
     outfile.precision(16);
42 36
 
43 37
     int TT_hr = int(TT/3600);
44 38
     int TT_min = int((TT - 3600.0*TT_hr)/60);
45 39
 
46
-    outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull << setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
47
-      //<< "\t" << CPU_ticks/CLOCKS_PER_SEC << "\t" << CPU_ticks_TOT/CLOCKS_PER_SEC << endl;
48
-      //<< setw(16) << std::fixed << setprecision(3) << TT << endl;
49
-	    << "\t" << TT_hr << " h " << TT_min << " m " << std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
50
-    //outfile << "sumrule_obtained \t Nfull \t Ninadm \t Ndata \t Ndata_conv \t Ndata_conv0 \t T \t TT.";
51
-    outfile << setw(25) << "sumrule_obtained" << setw(25) << "Nfull" << setw(16) << "Ninadm" << setw(16) << "Ndata" << setw(16) << "Ndata_conv" << setw(16) << "Ndata_conv0" << setw(16) << "TT." << endl;
40
+    outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull
41
+	    << setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
42
+	    << "\t" << TT_hr << " h " << TT_min << " m "
43
+	    << std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
44
+    outfile << setw(25) << "sumrule_obtained" << setw(25) << "Nfull" << setw(16) << "Ninadm"
45
+	    << setw(16) << "Ndata" << setw(16) << "Ndata_conv" << setw(16) << "Ndata_conv0" << setw(16) << "TT." << endl;
52 46
     outfile.close();
53 47
 
54 48
     return;
@@ -67,13 +61,10 @@ namespace ABACUS {
67 61
     DP TT_sec;
68 62
     char a;
69 63
 
70
-    //infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0 >> CPU_ticks >> CPU_ticks_TOT;
71
-    //infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0 >> TT;
72
-    infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0 >> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
64
+    infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0
65
+	   >> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
73 66
 
74 67
     TT = 3600.0 * TT_hr + 60.0* TT_min + TT_sec;
75
-    //CPU_ticks_TOT *= CLOCKS_PER_SEC; // correct for factor in Save function
76
-    //CPU_ticks = 0;  // reset CPU ticks.
77 68
 
78 69
     infile.close();
79 70
 
@@ -84,12 +75,12 @@ namespace ABACUS {
84 75
   {
85 76
     s.ios::unsetf(ios::scientific);
86 77
     return s << " sr " << setprecision(14) << info.sumrule_obtained
87
-	     << "\tNfull " << std::fixed << setprecision(0) << info.Nfull << "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
78
+	     << "\tNfull " << std::fixed << setprecision(0) << info.Nfull
79
+	     << "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
88 80
 	     << "\t_conv " << info.Ndata_conv << " _conv0 " << info.Ndata_conv0
89
-      //<< " t " << info.CPU_ticks/CLOCKS_PER_SEC << "s"
90
-      //<< " TT " << info.CPU_ticks_TOT/CLOCKS_PER_SEC;
91
-      //<< "\tTT " << std::fixed << setprecision(3) << info.TT;
92
-	     << "\tTT " << int(info.TT/3600) << " h " << int((info.TT - 3600.0 * int(info.TT/3600))/60) << " m " << std::fixed << setprecision(3) << info.TT - 3600.0 * int(info.TT/3600) - 60.0 * int((info.TT - 3600.0 * int(info.TT/3600))/60) << " s";
81
+	     << "\tTT " << int(info.TT/3600) << " h " << int((info.TT - 3600.0 * int(info.TT/3600))/60)
82
+	     << " m " << std::fixed << setprecision(3)
83
+	     << info.TT - 3600.0 * int(info.TT/3600) - 60.0 * int((info.TT - 3600.0 * int(info.TT/3600))/60) << " s";
93 84
   }
94 85
 
95 86
 

+ 8
- 57
src/SCAN/Scan_Thread_Data.cc View File

@@ -57,15 +57,13 @@ namespace ABACUS {
57 57
     }
58 58
 
59 59
     filename = Vect<string> (nlists);
60
-    //file = Vect<fstream*> (nlists);
61
-    //file_is_open = Vect<bool> (nlists);
62 60
 
63 61
     for (int il = 0; il < nlists; ++il) {
64 62
       stringstream filename_strstream;
65 63
       filename_strstream << thrdir_name << "/" << il << ".thr";
66 64
       filename[il] = filename_strstream.str();
67
-      if (!refine) remove(filename[il].c_str()); // the file is deleted to make sure we don't interfere with a previous (failed) computation
68
-      //file_is_open[il] = false;
65
+      if (!refine) remove(filename[il].c_str());
66
+      // the file is deleted to make sure we don't interfere with a previous (failed) computation
69 67
     }
70 68
     if (!refine) {
71 69
       // remove the nthreads.dat file
@@ -79,11 +77,6 @@ namespace ABACUS {
79 77
 
80 78
   Scan_Thread_Data::~Scan_Thread_Data()
81 79
   {
82
-    //for (int il = 0; il < nlists; ++il)
83
-    //if (file_is_open[il]) {
84
-    //	(*file[il]).close();
85
-    //	delete file[il];
86
-    //}
87 80
   }
88 81
 
89 82
   bool Scan_Thread_Data::Increase_Memory_Size (int il, int nr_to_add)
@@ -118,21 +111,11 @@ namespace ABACUS {
118 111
 
119 112
   void Scan_Thread_Data::Include_Thread (int il, string label_ref, int type_ref)
120 113
   {
121
-    //cout << "Calling Include_Threads..." << endl;
122
-
123
-    if (il < 0 || il > nlists - 1) ABACUSerror("il out of range in Scan_Thread_Data::Include_Thread.");
124
-
125
-    //cout << "\t\tIncluding thread " << label_ref << "\t" << type_ref << " in list with il = " << il << endl;
114
+    if (il < 0 || il > nlists - 1)
115
+      ABACUSerror("il out of range in Scan_Thread_Data::Include_Thread.");
126 116
 
127 117
     if (il < lowest_il_with_nthreads_neq_0) lowest_il_with_nthreads_neq_0 = il;
128 118
 
129
-    // append to file
130
-    //if (!file_is_open[il]) {
131
-    //file[il] = new fstream(filename[il].c_str(), fstream::out);
132
-    //file_is_open[il] = true;
133
-    //}
134
-    //*file[il] << label_ref << "\t" << type_ref << endl;
135
-
136 119
     // Keep in memory for now:
137 120
     if (nthreads_in_memory[il] > dim[il] - 10) {
138 121
       (*this).Increase_Memory_Size (il, dim[il]);
@@ -158,23 +141,13 @@ namespace ABACUS {
158 141
       label[il] = Vect<string> (dim[il]);
159 142
       type[il] = Vect<int> (dim[il]);
160 143
     }
161
-
162
-    //cout << "\t\tDone including thread." << endl;
163
-    //char a;
164
-    //cin >> a;
165
-    //cout << "OK for Include_Threads..." << endl;
166
-
167 144
   }
168 145
 
169 146
 
170 147
   Vect<Scan_Thread> Scan_Thread_Data::Extract_Next_Scan_Threads ()
171 148
   {
172
-    //cout << "Calling Extract_Next_Scan_Threads..." << endl;
173
-
174 149
     // Returns a vector of threads which are next in line for scanning.
175 150
 
176
-    //cout << "Here 1" << endl;
177
-
178 151
     int il_used = lowest_il_with_nthreads_neq_0;
179 152
     Vect<Scan_Thread> next_in_line(nthreads_total[il_used]);
180 153
 
@@ -206,25 +179,6 @@ namespace ABACUS {
206 179
     type[il_used] = Vect<int> (dim[il_used]);
207 180
     remove(filename[il_used].c_str());
208 181
 
209
-    /* Moved to Include_Thread
210
-    // We save the higher-index in-memory threads to files if they are big enough:
211
-    for (int il = il_used + 1; il < nlists; ++il)
212
-      //if (nthreads_in_memory[il] > 0) {
213
-      if (nthreads_in_memory[il] > 1000) {
214
-	fstream outfile;
215
-	outfile.open(filename[il].c_str(), fstream::out | fstream::app);
216
-	for (int it = 0; it < nthreads_in_memory[il]; ++it)
217
-	  outfile << label[il][it] << "\t" << type[il][it] << endl;
218
-	outfile.close();
219
-	nthreads_on_disk[il] += nthreads_in_memory[il];
220
-
221
-	// We then reset these memory buffers
222
-	dim[il] = 100;
223
-	nthreads_in_memory[il] = 0;
224
-	label[il] = Vect<string> (dim[il]);
225
-	type[il] = Vect<int> (dim[il]);
226
-      }
227
-    */
228 182
     // Find the next non-empty list:
229 183
     do {
230 184
       lowest_il_with_nthreads_neq_0 += 1;
@@ -234,11 +188,6 @@ namespace ABACUS {
234 188
       }
235 189
     } while (nthreads_total[lowest_il_with_nthreads_neq_0] == 0);
236 190
 
237
-    //cout << "Set lowest_il_with_nthreads_neq_0 to " << lowest_il_with_nthreads_neq_0 << endl;
238
-    //cin >> a;
239
-
240
-    //cout << "OK for Extract_Next_Scan_Threads." << endl;
241
-
242 191
     return(next_in_line);
243 192
   }
244 193
 
@@ -258,7 +207,8 @@ namespace ABACUS {
258 207
 
259 208
   void Scan_Thread_Data::Flush_to_Disk (int il)
260 209
   {
261
-    if (il < 0 || il > nlists - 1) ABACUSerror("il out of range in Scan_Thread_Data::Flush_to_Disk.");
210
+    if (il < 0 || il > nlists - 1)
211
+      ABACUSerror("il out of range in Scan_Thread_Data::Flush_to_Disk.");
262 212
 
263 213
     if (nthreads_in_memory[il] > 0) {
264 214
       fstream outfile;
@@ -288,7 +238,8 @@ namespace ABACUS {
288 238
     string nthreads_outfile_str = nthreads_outfile_strstream.str();
289 239
 
290 240
     nthreads_outfile.open(nthreads_outfile_str.c_str());
291
-    if (nthreads_outfile.fail()) ABACUSerror("Could not open outfile in Scan_Thread_Data::Save... ");
241
+    if (nthreads_outfile.fail())
242
+      ABACUSerror("Could not open outfile in Scan_Thread_Data::Save... ");
292 243
 
293 244
     //cout << "Saving threads: nthreads_tot vector is" << endl;
294 245
     for (int il = 0; il < nlists; ++il) {

+ 263
- 355
src/TBA/Root_Density.cc View File

@@ -19,439 +19,347 @@ using namespace ABACUS;
19 19
 
20 20
 namespace ABACUS {
21 21
 
22
-/************************************/
23
-/*
24
-struct Root_Density {
25
-
26
-  int Npts;  // how many points are used to describe each function
27
-  DP lambdamax;  // what the largest rapidity is
28
-  Vect_DP lambda;  // rapidity vector
29
-  Vect_DP dlambda; // differential element
30
-  Vect_DP value;  // the root density itself
31
-  Vect_DP prev_value;  // results of previous iteration
32
-  DP diff;   // relative differences with previous iteration
33
-  bool value_infty_set;  // boolean, true if asymptotic value set
34
-  DP value_infty;  // asymptotic value, computed analytically
35
-
36
-  Root_Density ();
37
-  Root_Density (int Npts_ref, DP lambdamax_ref);
38
-
39
-  Root_Density& operator= (const Root_Density& RefDensity);
40
-
41
-  DP Return_Value (DP lambda_ref);  // evaluates the function for any argument using linear interpolation
42
-  DP Set_Asymptotics (DP value_infty_ref);  // sets value for lambda >= lambdamax
43
-
44
-  Root_Density Compress_and_Match_Densities (DP comp_factor);  // returns a Root_Density with fewer points
45
-};
46
-*/
47
-
48
-Root_Density::Root_Density ()
49
-  : Npts(1), lambdamax(0.0), lambda(Vect_DP(0.0, Npts)), dlambda(Vect_DP(0.0, Npts)), value(Vect_DP(0.0, Npts)),
50
-    prev_value(Vect_DP(0.0, Npts)), diff(1.0e+6), value_infty_set(false), value_infty(0.0)
51
-{
52
-}
53
-
54
-Root_Density::Root_Density (int Npts_ref, DP lambdamax_ref)
55
-  : Npts(Npts_ref), lambdamax(lambdamax_ref), lambda(Vect_DP(Npts)), dlambda(Vect_DP(0.0, Npts)), value(Vect_DP(0.0, Npts)),
56
-    prev_value(Vect_DP(0.0, Npts)), diff(1.0e+6), value_infty_set(false), value_infty(0.0)
57
-{
58
-  for (int i = 0; i < value.size(); ++i) {
59
-    lambda[i] = lambdamax * (-(Npts - 1.0) + 2*i)/Npts;
60
-    dlambda[i] = 2.0 * lambdamax/Npts;
22
+
23
+  Root_Density::Root_Density ()
24
+    : Npts(1), lambdamax(0.0), lambda(Vect_DP(0.0, Npts)), dlambda(Vect_DP(0.0, Npts)), value(Vect_DP(0.0, Npts)),
25
+      prev_value(Vect_DP(0.0, Npts)), diff(1.0e+6), value_infty_set(false), value_infty(0.0)
26
+  {
61 27
   }
62
-}
63
-
64
-Root_Density& Root_Density::operator= (const Root_Density& RefDensity)
65
-{
66
-  if (this != &RefDensity) {
67
-    Npts = RefDensity.Npts;
68
-    lambdamax = RefDensity.lambdamax;
69
-    lambda = RefDensity.lambda;
70
-    dlambda = RefDensity.dlambda;
71
-    value = RefDensity.value;
72
-    prev_value = RefDensity.prev_value;
73
-    diff = RefDensity.diff;
74
-    value_infty_set = RefDensity.value_infty_set;
75
-    value_infty = RefDensity.value_infty;
76 28
 
29
+  Root_Density::Root_Density (int Npts_ref, DP lambdamax_ref)
30
+    : Npts(Npts_ref), lambdamax(lambdamax_ref), lambda(Vect_DP(Npts)), dlambda(Vect_DP(0.0, Npts)), value(Vect_DP(0.0, Npts)),
31
+      prev_value(Vect_DP(0.0, Npts)), diff(1.0e+6), value_infty_set(false), value_infty(0.0)
32
+  {
33
+    for (int i = 0; i < value.size(); ++i) {
34
+      lambda[i] = lambdamax * (-(Npts - 1.0) + 2*i)/Npts;
35
+      dlambda[i] = 2.0 * lambdamax/Npts;
36
+    }
77 37
   }
78
-  return(*this);
79
-}
80
-
81
-DP Root_Density::Return_Value (DP lambda_ref)
82
-{
83
-  // This function returns a value for epsilon at any real lambda
84
-  // using simple linear interpolation.
85
-  // Degree 3 polynomical also programmed in, but commented out:  no improvement.
86
-
87
-  DP answer = 0.0;
88
-  if (fabs(lambda_ref) >= fabs(lambda[0])) {
89
-    if (value_infty_set) answer = value_infty;
90
-    else ABACUSerror("Need to set asymptotics of Root_Density !");
38
+
39
+  Root_Density& Root_Density::operator= (const Root_Density& RefDensity)
40
+  {
41
+    if (this != &RefDensity) {
42
+      Npts = RefDensity.Npts;
43
+      lambdamax = RefDensity.lambdamax;
44
+      lambda = RefDensity.lambda;
45
+      dlambda = RefDensity.dlambda;
46
+      value = RefDensity.value;
47
+      prev_value = RefDensity.prev_value;
48
+      diff = RefDensity.diff;
49
+      value_infty_set = RefDensity.value_infty_set;
50
+      value_infty = RefDensity.value_infty;
51
+
52
+    }
53
+    return(*this);
91 54
   }
92 55
 
93
-  else { // try to find the i such that lambda[i] <= lambda_ref < lambda[i+1]
56
+  DP Root_Density::Return_Value (DP lambda_ref)
57
+  {
58
+    // This function returns a value for epsilon at any real lambda
59
+    // using simple linear interpolation.
60
+    // Degree 3 polynomical also programmed in, but commented out:  no improvement.
61
+
62
+    DP answer = 0.0;
63
+    if (fabs(lambda_ref) >= fabs(lambda[0])) {
64
+      if (value_infty_set) answer = value_infty;
65
+      else ABACUSerror("Need to set asymptotics of Root_Density !");
66
+    }
94 67
 
95
-    int index = (Npts - 1)/2;
96
-    int indexstep = (Npts - 1)/4 + 1;
68
+    else { // try to find the i such that lambda[i] <= lambda_ref < lambda[i+1]
97 69
 
98
-    while (indexstep >= 1) {
70
+      int index = (Npts - 1)/2;
71
+      int indexstep = (Npts - 1)/4 + 1;
99 72
 
100
-      if ( // if is "lower": we go up
101
-	  lambda_ref >= lambda[index + 1]) {
102
-	index += indexstep;
103
-      }
73
+      while (indexstep >= 1) {
104 74
 
105
-      else if ( // if is "higher" or equal:  we go down
106
-	       lambda[index] > lambda_ref) {
107
-	index -= indexstep;
108
-      }
75
+	if ( // if is "lower": we go up
76
+	    lambda_ref >= lambda[index + 1]) {
77
+	  index += indexstep;
78
+	}
109 79
 
110
-      index = ABACUS::max(0, index);
111
-      index = ABACUS::min(Npts - 2, index);
80
+	else if ( // if is "higher" or equal:  we go down
81
+		 lambda[index] > lambda_ref) {
82
+	  index -= indexstep;
83
+	}
112 84
 
113
-      if (indexstep == 1) indexstep--;
114
-      else indexstep = (indexstep + 1)/2;
85
+	index = ABACUS::max(0, index);
86
+	index = ABACUS::min(Npts - 2, index);
115 87
 
116
-    } // while ...
88
+	if (indexstep == 1) indexstep--;
89
+	else indexstep = (indexstep + 1)/2;
117 90
 
118
-    if (index < 0 || index >= Npts || lambda[index] > lambda_ref || lambda[index + 1] < lambda_ref) {
119
-      cout << "Seeking index: " << index << "\t" << lambda[index] << "\t <=? " << lambda_ref << "\t<? " << lambda[index + 1] << endl;
120
-      ABACUSerror("Calculating index wrong in Root_Density::Evaluate.");
121
-    }
91
+      } // while ...
92
+
93
+      if (index < 0 || index >= Npts || lambda[index] > lambda_ref || lambda[index + 1] < lambda_ref) {
94
+	cout << "Seeking index: " << index << "\t" << lambda[index] << "\t <=? " << lambda_ref
95
+	     << "\t<? " << lambda[index + 1] << endl;
96
+	ABACUSerror("Calculating index wrong in Root_Density::Evaluate.");
97
+      }
122 98
 
123
-    //if (index < 1 || index > Npts - 3)
124
-    answer = ((value[index] * (lambda[index+1] - lambda_ref)
125
-	       + value[index + 1] * (lambda_ref - lambda[index]))/(lambda[index+1] - lambda[index]));
126
-    /*
127
-    else {
128
-      // Better:  if possible, fit to polynomial going through 4 closest points
129
-      Vect_DP xa (4);
130
-      Vect_DP ya (4);
131
-      DP dy;
132
-      xa[0] = lambda[index - 1];  xa[1] = lambda[index];  xa[2] = lambda[index + 1];  xa[3] = lambda[index + 2];
133
-      ya[0] = value[index - 1];  ya[1] = value[index];  ya[2] = value[index + 1];  ya[3] = value[index + 2];
134
-      polint (xa, ya, lambda_ref, answer, dy);  // sets answer to value at lambda_ref
99
+      answer = ((value[index] * (lambda[index+1] - lambda_ref)
100
+		 + value[index + 1] * (lambda_ref - lambda[index]))/(lambda[index+1] - lambda[index]));
135 101
     }
136
-    */
102
+
103
+    return(answer);
137 104
   }
138 105
 
139
-  return(answer);
140
-}
106
+  void Root_Density::Set_Asymptotics (DP value_infty_ref)
107
+  {
108
+    value_infty = value_infty_ref;
109
+    value_infty_set = true;
110
+  }
141 111
 
142
-void Root_Density::Set_Asymptotics (DP value_infty_ref)
143
-{
144
-  value_infty = value_infty_ref;
145
-  value_infty_set = true;
146
-}
112
+  Root_Density Root_Density::Compress_and_Match_Densities (DP comp_factor)
113
+  {
114
+    // Returns a 'compressed' version of the density, using 1/comp_factor as many points.
147 115
 
148
-Root_Density Root_Density::Compress_and_Match_Densities (DP comp_factor)
149
-{
150
-  // Returns a 'compressed' version of the density, using 1/comp_factor as many points.
116
+    int Npts_used = int(2.0 * lambdamax/(dlambda[0] * comp_factor));
151 117
 
152
-  // PROBLEM:  this implementation can lead to numerical instabilities.
118
+    Root_Density compressed_density(Npts_used, lambdamax);
153 119
 
154
-  //Root_Density compressed_density(Npts/comp_factor, lambdamax);
120
+    compressed_density.Set_Asymptotics (value_infty);
155 121
 
156
-  // Rather:  use this implementation:
157
-  int Npts_used = int(2.0 * lambdamax/(dlambda[0] * comp_factor));
122
+    for (int i = 0; i < compressed_density.Npts; ++i)
123
+      compressed_density.value[i] = (*this).Return_Value (compressed_density.lambda[i]);
158 124
 
159
-  Root_Density compressed_density(Npts_used, lambdamax);
125
+    return(compressed_density);
126
+  }
160 127
 
161
-  compressed_density.Set_Asymptotics (value_infty);
128
+  void Root_Density::Save (const char* outfile_Cstr)
129
+  {
130
+    ofstream outfile;
131
+    outfile.open(outfile_Cstr);
132
+    outfile.precision(16);
162 133
 
163
-  for (int i = 0; i < compressed_density.Npts; ++i)
164
-    compressed_density.value[i] = (*this).Return_Value (compressed_density.lambda[i]);
134
+    for (int i = 0; i < Npts; ++i) {
135
+      if (i > 0) outfile << endl;
136
+      outfile << setw(20) << lambda[i] << "\t" << setw(20) << value[i];
137
+    }
165 138
 
166
-  return(compressed_density);
167
-}
139
+    outfile.close();
140
+  }
168 141
 
169
-void Root_Density::Save (const char* outfile_Cstr)
170
-{
171
-  ofstream outfile;
172
-  outfile.open(outfile_Cstr);
173
-  outfile.precision(16);
174 142
 
175
-  for (int i = 0; i < Npts; ++i) {
176
-    if (i > 0) outfile << endl;
177
-    outfile << setw(20) << lambda[i] << "\t" << setw(20) << value[i];
143
+  Root_Density_Set::Root_Density_Set () : ntypes(1), epsilon(Vect<Root_Density> (ntypes)), Npts_total(0), diff(1.0e+6)
144
+  {
178 145
   }
179 146
 
180
-  outfile.close();
181
-}
182
-
183
-
184
-/************************************/
185
-/*
186
-struct Root_Density_Set {
187
-
188
-  int ntypes;
189
-  Vect<Root_Density> epsilon;
190
-  int Npts_total;  // sum of all Npts of epsilon's
191
-  DP diff;  // sum of diff's of the epsilon's
192
-
193
-  Root_Density_Set ();
194
-  Root_Density_Set (int ntypes_ref, int Npts_ref, DP lambdamax_ref);
195
-  Root_Density_Set (int ntypes_ref, Vect_INT Npts_ref, Vect_DP lambdamax_ref);
196
-
197
-  Root_Density_Set& operator= (const Root_Density_Set& RefSet);
198
-
199
-  void Insert_new_function (DP asymptotic_value);
200
-  void Extend_limits (Vect<bool> need_to_extend_limit);
201
-  void Insert_new_points (Vect<Vect<bool> > need_new_point_around);
202
-
203
-  DP Return_Value (int n_ref, DP lambda_ref);  // returns a value, no matter what.
204
-
205
-  Root_Density_Set Return_Compressed_and_Matched_Set (DP comp_factor);
206
-  void Match_Densities (Root_Density_Set& RefSet);
207
-
208
-  void Save (const char* outfile_Cstr);
209
-};
210
-*/
211
-Root_Density_Set::Root_Density_Set () : ntypes(1), epsilon(Vect<Root_Density> (ntypes)), Npts_total(0), diff(1.0e+6)
212
-{
213
-}
214
-
215
-Root_Density_Set::Root_Density_Set (int ntypes_ref, int Npts_ref, DP lambdamax_ref)
216
-  : ntypes(ntypes_ref), epsilon(Vect<Root_Density> (ntypes_ref)), Npts_total(ntypes_ref * Npts_ref), diff(1.0e+6)
217
-{
218
-  for (int n = 0; n < ntypes; ++n) epsilon[n] = Root_Density(Npts_ref, lambdamax_ref);
219
-}
220
-
221
-Root_Density_Set::Root_Density_Set (int ntypes_ref, Vect_INT Npts_ref, Vect_DP lambdamax_ref)
222
-  : ntypes(ntypes_ref), epsilon(Vect<Root_Density> (ntypes_ref)), Npts_total(Npts_ref.sum()), diff(1.0e+6)
223
-{
224
-  if (Npts_ref.size() != ntypes_ref || lambdamax_ref.size() != ntypes_ref) ABACUSerror("Wrong vector sizes in Root_Density_Set.");
225
-  for (int n = 0; n < ntypes; ++n) epsilon[n] = Root_Density(Npts_ref[n], lambdamax_ref[n]);
226
-}
227
-
228
-Root_Density_Set& Root_Density_Set::operator= (const Root_Density_Set& RefSet)
229
-{
230
-  if (this != &RefSet) {
231
-    ntypes = RefSet.ntypes;
232
-    epsilon = RefSet.epsilon;
233
-    Npts_total = RefSet.Npts_total;
234
-    diff = RefSet.diff;
147
+  Root_Density_Set::Root_Density_Set (int ntypes_ref, int Npts_ref, DP lambdamax_ref)
148
+    : ntypes(ntypes_ref), epsilon(Vect<Root_Density> (ntypes_ref)), Npts_total(ntypes_ref * Npts_ref), diff(1.0e+6)
149
+  {
150
+    for (int n = 0; n < ntypes; ++n) epsilon[n] = Root_Density(Npts_ref, lambdamax_ref);
235 151
   }
236
-  return(*this);
237
-}
238 152
 
239
-void Root_Density_Set::Insert_new_function (DP asymptotic_value)
240
-{
241
-  // This function extends a set by adding one epsilon_n function on top
153
+  Root_Density_Set::Root_Density_Set (int ntypes_ref, Vect_INT Npts_ref, Vect_DP lambdamax_ref)
154
+    : ntypes(ntypes_ref), epsilon(Vect<Root_Density> (ntypes_ref)), Npts_total(Npts_ref.sum()), diff(1.0e+6)
155
+  {
156
+    if (Npts_ref.size() != ntypes_ref || lambdamax_ref.size() != ntypes_ref)
157
+      ABACUSerror("Wrong vector sizes in Root_Density_Set.");
158
+    for (int n = 0; n < ntypes; ++n) epsilon[n] = Root_Density(Npts_ref[n], lambdamax_ref[n]);
159
+  }
242 160
 
243
-  Root_Density_Set Updated_Set (ntypes + 1, 10, 10.0);  // last two parameters are meaningless
244
-  for (int n = 0; n < ntypes; ++n) Updated_Set.epsilon[n] = epsilon[n];
161
+  Root_Density_Set& Root_Density_Set::operator= (const Root_Density_Set& RefSet)
162
+  {
163
+    if (this != &RefSet) {
164
+      ntypes = RefSet.ntypes;
165
+      epsilon = RefSet.epsilon;
166
+      Npts_total = RefSet.Npts_total;
167
+      diff = RefSet.diff;
168
+    }
169
+    return(*this);
170
+  }
245 171
 
246
-  //Updated_Set.epsilon[ntypes] = Root_Density (epsilon[ntypes - 1].Npts, epsilon[ntypes - 1].lambdamax);
247
-  Updated_Set.epsilon[ntypes] = Root_Density (50, epsilon[ntypes - 1].lambdamax);
248
-  Updated_Set.epsilon[ntypes].Set_Asymptotics (asymptotic_value);
172
+  void Root_Density_Set::Insert_new_function (DP asymptotic_value)
173
+  {
174
+    // This function extends a set by adding one epsilon_n function on top
249 175
 
250
-  for (int i = 0; i < Updated_Set.epsilon[ntypes].Npts; ++i)
251
-    Updated_Set.epsilon[ntypes].value[i] = Updated_Set.epsilon[ntypes].value_infty;
176
+    Root_Density_Set Updated_Set (ntypes + 1, 10, 10.0);  // last two parameters are meaningless
177
+    for (int n = 0; n < ntypes; ++n) Updated_Set.epsilon[n] = epsilon[n];
252 178
 
253
-  ntypes = Updated_Set.ntypes;
254
-  epsilon = Updated_Set.epsilon;
255
-  Npts_total+= Updated_Set.epsilon[ntypes - 1].Npts;
256
-}
179
+    Updated_Set.epsilon[ntypes] = Root_Density (50, epsilon[ntypes - 1].lambdamax);
180
+    Updated_Set.epsilon[ntypes].Set_Asymptotics (asymptotic_value);
257 181
 
258
-void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
259
-{
260
-  // Extend the limits of integration at each level, according to boolean
182
+    for (int i = 0; i < Updated_Set.epsilon[ntypes].Npts; ++i)
183
+      Updated_Set.epsilon[ntypes].value[i] = Updated_Set.epsilon[ntypes].value_infty;
261 184
 
262
-  // The function extends the limits by 10% on both sides, putting the
263
-  // extra values to value_infty.
185
+    ntypes = Updated_Set.ntypes;
186
+    epsilon = Updated_Set.epsilon;
187
+    Npts_total+= Updated_Set.epsilon[ntypes - 1].Npts;
188
+  }
264 189
 
265
-  if (need_to_extend_limit.size() != epsilon.size()) ABACUSerror("Wrong size need_to_extend_limit boolean in Extend_limits.");
190
+  void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
191
+  {
192
+    // Extend the limits of integration at each level, according to boolean
266 193
 
267
-  Vect_INT nr_new_points_needed(0, ntypes);
268
-  int total_nr_new_points_added = 0;
269
-  DP dlambda_used = 0.0;
270
-  for (int n = 0; n < ntypes; ++n) {
271
-    if (need_to_extend_limit[n]) {
194
+    // The function extends the limits by 10% on both sides, putting the
195
+    // extra values to value_infty.
272 196
 
273
-      Root_Density epsilon_n_before_update = epsilon[n];
197
+    if (need_to_extend_limit.size() != epsilon.size())
198
+      ABACUSerror("Wrong size need_to_extend_limit boolean in Extend_limits.");
274 199
 
275
-      // Determine the dlambda to be used:
276
-      dlambda_used = epsilon[n].dlambda[0];
200
+    Vect_INT nr_new_points_needed(0, ntypes);
201
+    int total_nr_new_points_added = 0;
202
+    DP dlambda_used = 0.0;
203
+    for (int n = 0; n < ntypes; ++n) {
204
+      if (need_to_extend_limit[n]) {
277 205
 
278
-      // How many new points do we add ?  Say 5\% on each side:
279
-      nr_new_points_needed[n] = ABACUS::max(1, epsilon[n].Npts/20);
206
+	Root_Density epsilon_n_before_update = epsilon[n];
280 207
 
281
-      epsilon[n] = Root_Density(epsilon_n_before_update.Npts + 2* nr_new_points_needed[n], epsilon_n_before_update.lambdamax + nr_new_points_needed[n] * dlambda_used);
282
-      epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
208
+	// Determine the dlambda to be used:
209
+	dlambda_used = epsilon[n].dlambda[0];
283 210
 
284
-      for (int i = 0; i < nr_new_points_needed[n]; ++i) {
285
-	epsilon[n].lambda[i] = epsilon_n_before_update.lambda[0] - (nr_new_points_needed[n] - i) * dlambda_used;
286
-	epsilon[n].dlambda[i] = dlambda_used;
287
-	epsilon[n].value[i] = epsilon_n_before_update.value_infty;
288
-      }
211
+	// How many new points do we add ?  Say 5\% on each side:
212
+	nr_new_points_needed[n] = ABACUS::max(1, epsilon[n].Npts/20);
289 213
 
290
-      for (int i = 0; i < epsilon_n_before_update.Npts; ++i) {
291
-	epsilon[n].lambda[i + nr_new_points_needed[n] ] = epsilon_n_before_update.lambda[i];
292
-	epsilon[n].dlambda[i + nr_new_points_needed[n] ] = epsilon_n_before_update.dlambda[i];
293
-	epsilon[n].value[i + nr_new_points_needed[n] ] = epsilon_n_before_update.value[i];
294
-      }
295
-
296
-      for (int i = 0; i < nr_new_points_needed[n]; ++i) {
297
-	epsilon[n].lambda[i + epsilon_n_before_update.Npts + nr_new_points_needed[n] ]
298
-	  = epsilon_n_before_update.lambda[epsilon_n_before_update.Npts - 1] + (i+1.0) * dlambda_used;
299
-	epsilon[n].dlambda[i + epsilon_n_before_update.Npts + nr_new_points_needed[n] ] = dlambda_used;
300
-	epsilon[n].value[i + epsilon_n_before_update.Npts + nr_new_points_needed[n] ] = epsilon_n_before_update.value_infty;
301
-      }
214
+	epsilon[n] = Root_Density(epsilon_n_before_update.Npts + 2* nr_new_points_needed[n],
215
+				  epsilon_n_before_update.lambdamax + nr_new_points_needed[n] * dlambda_used);
216
+	epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
302 217
 
303
-      total_nr_new_points_added += 2 * nr_new_points_needed[n];
218
+	for (int i = 0; i < nr_new_points_needed[n]; ++i) {
219
+	  epsilon[n].lambda[i] = epsilon_n_before_update.lambda[0] - (nr_new_points_needed[n] - i) * dlambda_used;
220
+	  epsilon[n].dlambda[i] = dlambda_used;
221
+	  epsilon[n].value[i] = epsilon_n_before_update.value_infty;
222
+	}
304 223
 
305
-      //cout << "Extending limits at level " << n << " with " << nr_new_points_needed[n] << " points on each side to " << epsilon[n].lambdamax << endl;
224
+	for (int i = 0; i < epsilon_n_before_update.Npts; ++i) {
225
+	  epsilon[n].lambda[i + nr_new_points_needed[n] ] = epsilon_n_before_update.lambda[i];
226
+	  epsilon[n].dlambda[i + nr_new_points_needed[n] ] = epsilon_n_before_update.dlambda[i];
227
+	  epsilon[n].value[i + nr_new_points_needed[n] ] = epsilon_n_before_update.value[i];
228
+	}
306 229
 
307
-    } // if (need
308
-  } // for n
230
+	for (int i = 0; i < nr_new_points_needed[n]; ++i) {
231
+	  epsilon[n].lambda[i + epsilon_n_before_update.Npts + nr_new_points_needed[n] ]
232
+	    = epsilon_n_before_update.lambda[epsilon_n_before_update.Npts - 1] + (i+1.0) * dlambda_used;
233
+	  epsilon[n].dlambda[i + epsilon_n_before_update.Npts + nr_new_points_needed[n] ] = dlambda_used;
234
+	  epsilon[n].value[i + epsilon_n_before_update.Npts + nr_new_points_needed[n] ] = epsilon_n_before_update.value_infty;
235
+	}
309 236
 
310
-  Npts_total += total_nr_new_points_added;
237
+	total_nr_new_points_added += 2 * nr_new_points_needed[n];
311 238
 
312
-  // Done !
239
+      } // if (need
240
+    } // for n
313 241
 
314
-  return;
242
+    Npts_total += total_nr_new_points_added;
315 243
 
316
-}
244
+    // Done !
317 245
 
318
-void Root_Density_Set::Insert_new_points (Vect<Vect<bool> > need_new_point_around)
319
-{
320
-  // need_new_point_around specifies whether a new point needs to be inserted around existing points.
246
+    return;
321 247
 
322
-  // Count the number of new points needed per type:
323
-  Vect_INT nr_new_points_needed(0, ntypes);
324
-  int total_nr_new_points_needed = 0;
325
-  for (int n = 0; n < ntypes; ++n) {
326
-    if (need_new_point_around[n].size() != epsilon[n].Npts) ABACUSerror("Wrong size need_new_point_around boolean in Insert_new_points.");
327
-    for (int i = 0; i < epsilon[n].Npts; ++i)
328
-      if (need_new_point_around[n][i]) nr_new_points_needed[n]++;
329
-    total_nr_new_points_needed += nr_new_points_needed[n];
330
-  }
331
-  /*
332
-  // Simplistic version:  always keep equidistant points
333
-  for (int n = 0; n < ntypes; ++n) {
334
-    Root_Density epsilon_n_before_update = epsilon[n];
335
-    epsilon[n] = Root_Density(epsilon_n_before_update.Npts + nr_new_points_needed[n], epsilon_n_before_update.lambdamax);
336
-    epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
337
-    for (int i = 0; i < epsilon[n].Npts; ++i)
338
-      epsilon[n].value[i] = epsilon_n_before_update.Return_Value(epsilon[n].lambda[i]);
339 248
   }
340
-  */
341
-
342
-  // Working version using non-equispaced points
343
-  // Now update all data via interpolation:
344
-  for (int n = 0; n < ntypes; ++n) {
345
-    Root_Density epsilon_n_before_update = epsilon[n];
346
-    epsilon[n] = Root_Density(epsilon_n_before_update.Npts + nr_new_points_needed[n], epsilon_n_before_update.lambdamax);
347
-    epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
348
-    //cout << "Check: " << epsilon[n].Npts << " " << epsilon_n_before_update.Npts << endl;
349
-    int nr_pts_added_n = 0;
350
-    for (int i = 0; i < epsilon_n_before_update.Npts; ++i) {
351
-      if (!need_new_point_around[n][i]) {
352
-	epsilon[n].lambda[i + nr_pts_added_n] = epsilon_n_before_update.lambda[i];
353
-	epsilon[n].dlambda[i + nr_pts_added_n] = epsilon_n_before_update.dlambda[i];
354
-	epsilon[n].value[i + nr_pts_added_n] = epsilon_n_before_update.value[i];
249
+
250
+  void Root_Density_Set::Insert_new_points (Vect<Vect<bool> > need_new_point_around)
251
+  {
252
+    // need_new_point_around specifies whether a new point needs to be inserted around existing points.
253
+
254
+    // Count the number of new points needed per type:
255
+    Vect_INT nr_new_points_needed(0, ntypes);
256
+    int total_nr_new_points_needed = 0;
257
+    for (int n = 0; n < ntypes; ++n) {
258
+      if (need_new_point_around[n].size() != epsilon[n].Npts)
259
+	ABACUSerror("Wrong size need_new_point_around boolean in Insert_new_points.");
260
+      for (int i = 0; i < epsilon[n].Npts; ++i)
261
+	if (need_new_point_around[n][i]) nr_new_points_needed[n]++;
262
+      total_nr_new_points_needed += nr_new_points_needed[n];
263
+    }
264
+
265
+    // Working version using non-equispaced points
266
+    // Now update all data via interpolation:
267
+    for (int n = 0; n < ntypes; ++n) {
268
+      Root_Density epsilon_n_before_update = epsilon[n];
269
+      epsilon[n] = Root_Density(epsilon_n_before_update.Npts + nr_new_points_needed[n], epsilon_n_before_update.lambdamax);
270
+      epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
271
+      int nr_pts_added_n = 0;
272
+      for (int i = 0; i < epsilon_n_before_update.Npts; ++i) {
273
+	if (!need_new_point_around[n][i]) {
274
+	  epsilon[n].lambda[i + nr_pts_added_n] = epsilon_n_before_update.lambda[i];
275
+	  epsilon[n].dlambda[i + nr_pts_added_n] = epsilon_n_before_update.dlambda[i];
276
+	  epsilon[n].value[i + nr_pts_added_n] = epsilon_n_before_update.value[i];
277
+	}
278
+	else if (need_new_point_around[n][i]) {
279
+	  epsilon[n].lambda[i + nr_pts_added_n] = epsilon_n_before_update.lambda[i] - 0.25 * epsilon_n_before_update.dlambda[i];
280
+	  epsilon[n].dlambda[i + nr_pts_added_n] = 0.5 * epsilon_n_before_update.dlambda[i];
281
+	  epsilon[n].value[i + nr_pts_added_n] = epsilon_n_before_update.Return_Value(epsilon[n].lambda[i + nr_pts_added_n]);
282
+	  nr_pts_added_n++;
283
+	  epsilon[n].lambda[i + nr_pts_added_n] = epsilon_n_before_update.lambda[i] + 0.25 * epsilon_n_before_update.dlambda[i];
284
+	  epsilon[n].dlambda[i + nr_pts_added_n] = 0.5 * epsilon_n_before_update.dlambda[i];
285
+	  epsilon[n].value[i + nr_pts_added_n] = epsilon_n_before_update.Return_Value(epsilon[n].lambda[i + nr_pts_added_n]);
286
+	}
355 287
       }
356
-      else if (need_new_point_around[n][i]) {
357
-	epsilon[n].lambda[i + nr_pts_added_n] = epsilon_n_before_update.lambda[i] - 0.25 * epsilon_n_before_update.dlambda[i];
358
-	epsilon[n].dlambda[i + nr_pts_added_n] = 0.5 * epsilon_n_before_update.dlambda[i];
359
-	epsilon[n].value[i + nr_pts_added_n] = epsilon_n_before_update.Return_Value(epsilon[n].lambda[i + nr_pts_added_n]);
360
-	nr_pts_added_n++;
361
-	epsilon[n].lambda[i + nr_pts_added_n] = epsilon_n_before_update.lambda[i] + 0.25 * epsilon_n_before_update.dlambda[i];
362
-	epsilon[n].dlambda[i + nr_pts_added_n] = 0.5 * epsilon_n_before_update.dlambda[i];
363
-	epsilon[n].value[i + nr_pts_added_n] = epsilon_n_before_update.Return_Value(epsilon[n].lambda[i + nr_pts_added_n]);
288
+      if (nr_pts_added_n != nr_new_points_needed[n]) {
289
+	cout << nr_pts_added_n << "\t" << nr_new_points_needed[n] << endl;
290
+	ABACUSerror("Wrong counting of new points in Insert_new_points.");
364 291
       }
365
-    }
366
-    if (nr_pts_added_n != nr_new_points_needed[n]) {
367
-      cout << nr_pts_added_n << "\t" << nr_new_points_needed[n] << endl;
368
-      ABACUSerror("Wrong counting of new points in Insert_new_points.");
369
-    }
370 292
 
371
-    // Check:
372
-    //for (int i = 0; i < epsilon[n].Npts - 1; ++i)
373
-    //if (fabs(epsilon[n].lambda[i] + 0.5 *(epsilon[n].dlambda[i] + epsilon[n].dlambda[i+1]) - epsilon[n].lambda[i+1]) > 1.0e-13)
374
-	//{
375
-    // cout << "Error at level " << n << "\ti " << i << "\t" << epsilon[n].lambda[i] << "\t" << epsilon[n].dlambda[i]
376
-    //       << "\t" << epsilon[n].lambda[i+1] << "\t" << epsilon[n].dlambda[i+1]
377
-    //       << "\t" << epsilon[n].lambda[i] + 0.5 *(epsilon[n].dlambda[i] + epsilon[n].dlambda[i+1]) - epsilon[n].lambda[i+1] << endl;
378
-    //  ABACUSerror("...");
379
-    //}
293
+    } // for n
380 294
 
381
-  } // for n
295
+    Npts_total += total_nr_new_points_needed;
382 296
 
297
+    // Done !
383 298
 
384
-  //cout << "need_new_pt_above " << need_new_point_above[0] << endl << endl;
385
-  //cout << "epsilon[0].lambda = " << epsilon[0].lambda << endl << endl;
386
-  //cout << "epsilon[0].dlambda = " << epsilon[0].dlambda << endl << endl;
387
-  //cout << "epsilon[0].value = " << epsilon[0].value << endl << endl;
299
+    return;
300
+  }
388 301
 
389
-  Npts_total += total_nr_new_points_needed;
302
+  DP Root_Density_Set::Return_Value (int n_ref, DP lambda_ref)
303
+  {
304
+    // Returns a value, no matter what !
390 305
 
391
-  // Done !
306
+    if (n_ref < ntypes) return(epsilon[n_ref].Return_Value(lambda_ref));
392 307
 
393
-  return;
394
-}
308
+    else // assume asymptotic form of epsilon, proportional to n
309
+      return(epsilon[ntypes - 1].Return_Value(lambda_ref) * n_ref/(ntypes - 1.0));
395 310
 
396
-DP Root_Density_Set::Return_Value (int n_ref, DP lambda_ref)
397
-{
398
-  // Returns a value, no matter what !
311
+  }
399 312
 
400
-  if (n_ref < ntypes) return(epsilon[n_ref].Return_Value(lambda_ref));
313
+  Root_Density_Set Root_Density_Set::Return_Compressed_and_Matched_Set (DP comp_factor)
314
+  {
315
+    // Returns a set with 1/comp_factor as many points at each level
401 316
 
402
-  else // assume asymptotic form of epsilon, proportional to n
403
-    return(epsilon[ntypes - 1].Return_Value(lambda_ref) * n_ref/(ntypes - 1.0));
317
+    if (comp_factor >= 2.0)
318
+      ABACUSerror("Compression factor too large in Return_Compressed_and_Matched_Set, numerical instability will occur.");
404 319
 
405
-}
320
+    Vect_INT nrpts_comp (ntypes);
321
+    Vect_DP lambdamax_comp (ntypes);
322
+    for (int n = 0; n < ntypes; ++n) {
323
+      nrpts_comp[n] = int(2.0 * epsilon[n].lambdamax/(epsilon[n].dlambda[0] * comp_factor));
324
+      lambdamax_comp[n] = epsilon[n].lambdamax;
325
+    }
406 326
 
407
-Root_Density_Set Root_Density_Set::Return_Compressed_and_Matched_Set (DP comp_factor)
408
-{  // Returns a set with 1/comp_factor as many points at each level
327
+    Root_Density_Set Compressed_and_Matched_Set (ntypes, nrpts_comp, lambdamax_comp);
409 328
 
410
-  if (comp_factor >= 2.0)
411
-    ABACUSerror("Compression factor too large in Return_Compressed_and_Matched_Set, numerical instability will occur.");
329
+    for (int n = 0; n < ntypes; ++n)
330
+      Compressed_and_Matched_Set.epsilon[n] = (*this).epsilon[n].Compress_and_Match_Densities (comp_factor);
412 331
 
413
-  Vect_INT nrpts_comp (ntypes);
414
-  Vect_DP lambdamax_comp (ntypes);
415
-  for (int n = 0; n < ntypes; ++n) {
416
-    nrpts_comp[n] = int(2.0 * epsilon[n].lambdamax/(epsilon[n].dlambda[0] * comp_factor));
417
-    lambdamax_comp[n] = epsilon[n].lambdamax;
332
+    return(Compressed_and_Matched_Set);
418 333
   }
419 334
 
420
-  Root_Density_Set Compressed_and_Matched_Set (ntypes, nrpts_comp, lambdamax_comp);
421
-
422
-  for (int n = 0; n < ntypes; ++n)
423
-    Compressed_and_Matched_Set.epsilon[n] = (*this).epsilon[n].Compress_and_Match_Densities (comp_factor);
424
-
425
-  return(Compressed_and_Matched_Set);
426
-}
335
+  void Root_Density_Set::Match_Densities (Root_Density_Set& RefSet)
336
+  {
337
+    // matched densities to those in RefSet
427 338
 
428
-void Root_Density_Set::Match_Densities (Root_Density_Set& RefSet)
429
-{ // matched densities to those in RefSet
430
-
431
-  for (int n = 0; n < ntypes; ++n)
432
-    for (int i = 0; i < epsilon[n].Npts; ++i)
433
-      epsilon[n].value[i] = RefSet.epsilon[n].Return_Value(epsilon[n].lambda[i]);
434
-}
435
-
436
-void Root_Density_Set::Save (const char* outfile_Cstr)
437
-{
438
-  ofstream outfile;
439
-  outfile.open(outfile_Cstr);
440
-  outfile.precision(16);
339
+    for (int n = 0; n < ntypes; ++n)
340
+      for (int i = 0; i < epsilon[n].Npts; ++i)
341
+	epsilon[n].value[i] = RefSet.epsilon[n].Return_Value(epsilon[n].lambda[i]);
342
+  }
441 343
 
442
-  // Determine what the maximal nr of pts is:
443
-  int Npts_n_max = 0;
444
-  for (int n = 0; n < ntypes; ++n) Npts_n_max = ABACUS::max(Npts_n_max, epsilon[n].Npts);
344
+  void Root_Density_Set::Save (const char* outfile_Cstr)
345
+  {
346
+    ofstream outfile;
347
+    outfile.open(outfile_Cstr);
348
+    outfile.precision(16);
349
+
350
+    // Determine what the maximal nr of pts is:
351
+    int Npts_n_max = 0;
352
+    for (int n = 0; n < ntypes; ++n) Npts_n_max = ABACUS::max(Npts_n_max, epsilon[n].Npts);
353
+
354
+    for (int i = 0; i < Npts_n_max; ++i) {
355
+      if (i > 0) outfile << endl;
356
+      for (int n = 0; n < ntypes; ++n) (i < epsilon[n].Npts) ?
357
+					 (outfile << epsilon[n].lambda[i] << "\t" << epsilon[n].value[i] << "\t")
358
+					 : (outfile << 0 << "\t" << 0 << "\t");
359
+    }
445 360
 
446
-  for (int i = 0; i < Npts_n_max; ++i) {
447
-    if (i > 0) outfile << endl;
448
-    for (int n = 0; n < ntypes; ++n) (i < epsilon[n].Npts) ?
449
-					       (outfile << epsilon[n].lambda[i] << "\t" << epsilon[n].value[i] << "\t")
450
-					       : (outfile << 0 << "\t" << 0 << "\t");
361
+    outfile.close();
451 362
   }
452 363
 
453
-  outfile.close();
454
-}
455
-
456 364
 
457 365
 } // namespace ABACUS

+ 849
- 1455
src/TBA/TBA_2CBG.cc
File diff suppressed because it is too large
View File


+ 37
- 128
src/TBA/TBA_LiebLin.cc View File

@@ -90,8 +90,6 @@ namespace ABACUS {
90 90
       rho_GS = LiebLin_rho_GS (c_int, k_F, lambdamax, Npts, req_prec);
91 91
       n_found = Density_GS (rho_GS);
92 92
 
93
-      //cout << "k_F " << k_F << "\tn_found " << n_found << endl;
94
-
95 93
     } while (fabs(dk_F) > req_prec && dk_F > 1.0/Npts
96 94
 	     && fabs(n - n_found) > req_prec && fabs(n - n_found) > 1.0/Npts);
97 95
 
@@ -189,23 +187,6 @@ namespace ABACUS {
189 187
 
190 188
 
191 189
   // Finite T functions:
192
-  /*
193
-  // from ABACUS_TBA.h
194
-
195
-  struct LiebLin_TBA_Solution {
196
-
197
-    DP c_int;
198
-    DP mu;
199
-    DP nbar;
200
-    DP kBT;
201
-    Root_Density epsilon;
202
-    Root_Density depsilon_dmu;
203
-    Root_Density rho;
204
-    Root_Density rhoh;
205
-
206
-    LiebLin_TBA_Solution (DP c_int_ref, DP mu_ref, DP kBT_ref, int Npts_ref, DP req_diff, int Max_Secs);
207
-  };
208
-  */
209 190
 
210 191
   LiebLin_TBA_Solution::LiebLin_TBA_Solution (DP c_int_ref, DP mu_ref, DP kBT_ref, DP req_diff, int Max_Secs)
211 192
     : c_int(c_int_ref), mu(mu_ref), kBT(kBT_ref)
@@ -218,20 +199,10 @@ namespace ABACUS {
218 199
     ebar = LiebLin_ebar_TBA (rho);
219 200
     sbar = LiebLin_sbar_TBA (rho, rhoh);
220 201
   }
221
-  /*
222
-  LiebLin_TBA_Solution::LiebLin_TBA_Solution (DP c_int_ref, DP mu_ref, DP kBT_ref, int Npts_ref, DP req_diff, int Max_Secs, const LiebLin_TBA_Solution& prev_sol)
223
-    : c_int(c_int_ref), mu(mu_ref), kBT(kBT_ref)
224
-  {
225
-    epsilon = LiebLin_epsilon_TBA (c_int, mu, kBT, Npts_ref, req_diff, Max_Secs, prev_sol.epsilon);
226
-    depsilon_dmu = LiebLin_depsilon_dmu_TBA (c_int, mu, kBT, Npts_ref, req_diff, Max_Secs, epsilon, prev_sol.depsilon_dmu);
227
-    rho = LiebLin_rho_TBA (kBT, epsilon, depsilon_dmu);
228
-    rhoh = LiebLin_rhoh_TBA (kBT, epsilon, depsilon_dmu);
229
-    nbar = LiebLin_nbar_TBA (rho);
230
-  }
231
-  */
232 202
 
233 203
 
234
-  LiebLin_TBA_Solution LiebLin_TBA_Solution_fixed_nbar_ebar (DP c_int, DP nbar_required, DP ebar_required, DP req_diff, int Max_Secs)
204
+  LiebLin_TBA_Solution LiebLin_TBA_Solution_fixed_nbar_ebar (DP c_int, DP nbar_required, DP ebar_required,
205
+							     DP req_diff, int Max_Secs)
235 206
   {
236 207
     // This function finds the TBA solution for a required nbar and ebar (mean energy).
237 208
     // We here try to triangulate the temperature; the chemical potential is triangulated
@@ -263,26 +234,7 @@ namespace ABACUS {
263 234
       lnkBT += dlnkBT;
264 235
       tbasol = LiebLin_TBA_Solution_fixed_nbar(c_int, nbar_required, exp(lnkBT), req_diff, Max_Secs);
265 236
       niter++;
266
-      //cout << setprecision(16) << "kBT: niter " << niter << "\tebar = " << tbasol.ebar << "\trequired = " << ebar_required << "\tlnkBT = " << lnkBT << "\tdlnkBT = " << dlnkBT << endl;
267 237
     }
268
-    // FIRST VERSION
269
-
270
-    /* SECOND VERSION
271
-    DP lnkBT = 1.0;
272
-    DP dlnkBT = 1.0;
273
-
274
-    DP mu = 2.0;
275
-    DP dmu = 1.0;
276
-
277
-    LiebLin_TBA_Solution tbasol = LiebLin_TBA_Solution(c_int, mu, kBT, req_diff, Max_Secs);
278
-    DP mu_prev = mu;
279
-    DP nbar_prev = tbasol.nbar;
280
-    DP lnkBT_prev = lnkBT;
281
-    DP ebar_prev = LiebLin_ebar_TBA (tbasol.rho);
282
-
283
-    DP dmu_prev, dnbardmu;
284
-    DP dlnkBT_prev, debardlnkBT;
285
-    */ // SECOND VERSION
286 238
 
287 239
     return(tbasol);
288 240
   }
@@ -292,48 +244,6 @@ namespace ABACUS {
292 244
   LiebLin_TBA_Solution LiebLin_TBA_Solution_fixed_nbar (DP c_int, DP nbar_required, DP kBT, DP req_diff, int Max_Secs)
293 245
   {
294 246
     // Find the required mu. Provide some initial guess.
295
-    /*
296
-    DP gamma_required = c_int/nbar_required;
297
-
298
-
299
-    // We define a matrix of mu's (calculated once and for all and filled in here)
300
-    // from which we can define an accurate first guess for mu, given gamma_required and kBT.
301
-
302
-    // The gamma's are by definition (1/16) * 2^{igamma},
303
-    // and the kBT are (1/16) * 2^{iT}.
304
-    int ndata = 16;
305
-    Vect<DP> gamma(ndata);
306
-    Vect<DP> Tred(ndata); // reduced temperature, kBT/
307
-    for (int i = 0; i < ndata; ++i) {
308
-      gamma[i] = 0.0625 * pow(2.0, i);
309
-      T[i] = 0.0625 * pow(2.0, i);
310
-    }
311
-    SQMat<DP> mudata(ndata);
312
-    // This data was computed separately, for unit filling, using 512 points, to accuracy 10^-4:
313
-
314
-    // Figure out which index igamma we should use:
315
-    // (1/16) * 2^{igamma_low} <~ gamma_required, so
316
-    int igamma_below = int(log(gamma_required * 16.0)/log(2.0));
317
-    // Similarly,
318
-    int iT_below = int(log(kBT * 16.0)/log(2.0));
319
-
320
-    igamma_below = ABACUS::max(igamma_below, 0);
321
-    igamma_below = ABACUS::min(igamma_below, ndata - 1);
322
-    iT_below = ABACUS::max(iT_below, 0);
323
-    iT_below = ABACUS::min(iT_below, ndata - 1);
324
-    // We use indices igamma_below, igamma_below + 1, iT_below, iT_below + 1 to guess mu:
325
-    // do a four-point extrapolation,
326
-    DP mu = ((gamma[igamma_below + 1] - gamma_required) * (T[iT_below + 1] - kBT) * mudata[igamma_below][iT_below]
327
-	     + (gamma_required - gamma[igamma_below]) * (T[iT_below + 1] - kBT) * mudata[igamma_below + 1][iT_below]
328
-	     + (gamma[igamma_below + 1] - gamma_required) * (kBT - T[iT_below]) * mudata[igamma_below][iT_below + 1]
329
-	     + (gamma_required - gamma[igamma_below]) * (kBT - T[iT_below]) * mudata[igamma_below + 1][iT_below + 1])
330
-      /((gamma[igamma_below + 1] - gamma[igamma_below]) * (T[iT_below + 1] - T[iT_below]));
331
-
332
-    // Translate to the required filling:
333
-
334
-
335
-    DP dnbardmu = ;
336
-    */
337 247
 
338 248
     DP mu = 2.0;
339 249
     DP dmu = 1.0;
@@ -360,7 +270,6 @@ namespace ABACUS {
360 270
       mu += dmu;
361 271
       tbasol = LiebLin_TBA_Solution(c_int, mu, kBT, req_diff, Max_Secs);
362 272
       niter++;
363
-      //cout << setprecision(16) << "\tmu: niter " << niter << "\tnbar = " << tbasol.nbar << "\trequired = " << nbar_required<< "\tmu = " << mu << "\tdmu = " << dmu << endl;
364 273
     }
365 274
 
366 275
     return(tbasol);
@@ -398,7 +307,7 @@ namespace ABACUS {
398 307
 
399 308
       tni[i] = measure_factor * epsilon.value[i];
400 309
       tni_ex[i] = measure_factor * (epsilon.value[i-1] *  (epsilon.lambda[i+1] - epsilon.lambda[i])
401
-				       + epsilon.value[i+1] * (epsilon.lambda[i] - epsilon.lambda[i-1]))
310
+				    + epsilon.value[i+1] * (epsilon.lambda[i] - epsilon.lambda[i-1]))
402 311
 	/(epsilon.lambda[i+1] - epsilon.lambda[i-1]);
403 312
 
404 313
       max_delta_tni_dlambda = ABACUS::max(max_delta_tni_dlambda, fabs(tni[i] - tni_ex[i]) * epsilon.dlambda[i]);
@@ -454,7 +363,9 @@ namespace ABACUS {
454 363
       int nr_pts_to_add_left = epsilon.Npts/10;
455 364
       int nr_pts_to_add_right = epsilon.Npts/10;
456 365
       Root_Density epsilon_before_update = epsilon;
457
-      epsilon = Root_Density(epsilon_before_update.Npts + nr_pts_to_add_left + nr_pts_to_add_right, epsilon_before_update.lambdamax + nr_pts_to_add_left * epsilon_before_update.dlambda[0] + nr_pts_to_add_right * epsilon_before_update.dlambda[epsilon_before_update.Npts - 1]);
366
+      epsilon = Root_Density(epsilon_before_update.Npts + nr_pts_to_add_left + nr_pts_to_add_right,
367
+			     epsilon_before_update.lambdamax + nr_pts_to_add_left * epsilon_before_update.dlambda[0]
368
+			     + nr_pts_to_add_right * epsilon_before_update.dlambda[epsilon_before_update.Npts - 1]);
458 369
 
459 370
       // Initialize points added on left
460 371
       for (int i = 0; i < nr_pts_to_add_left; ++i) {
@@ -470,9 +381,13 @@ namespace ABACUS {
470 381
       }
471 382
       // Initialize points added on right
472 383
       for (int i = 0; i < nr_pts_to_add_right; ++i) {
473
-	epsilon.lambda[nr_pts_to_add_left + epsilon_before_update.Npts + i] = epsilon_before_update.lambda[epsilon_before_update.Npts - 1] + (i+1) * epsilon_before_update.dlambda[epsilon_before_update.Npts - 1];
474
-	epsilon.dlambda[nr_pts_to_add_left + epsilon_before_update.Npts + i] = epsilon_before_update.dlambda[epsilon_before_update.Npts - 1];
475
-	epsilon.value[nr_pts_to_add_left + epsilon_before_update.Npts + i] = epsilon_before_update.value[epsilon_before_update.Npts - 1];
384
+	epsilon.lambda[nr_pts_to_add_left + epsilon_before_update.Npts + i] =
385
+	  epsilon_before_update.lambda[epsilon_before_update.Npts - 1]
386
+	  + (i+1) * epsilon_before_update.dlambda[epsilon_before_update.Npts - 1];
387
+	epsilon.dlambda[nr_pts_to_add_left + epsilon_before_update.Npts + i] =
388
+	  epsilon_before_update.dlambda[epsilon_before_update.Npts - 1];
389
+	epsilon.value[nr_pts_to_add_left + epsilon_before_update.Npts + i] =
390
+	  epsilon_before_update.value[epsilon_before_update.Npts - 1];
476 391
       }
477 392
     }
478 393
 
@@ -484,14 +399,16 @@ namespace ABACUS {
484 399
   {
485 400
 
486 401
     clock_t StartTime = clock();
487
-    int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100;  // give 30 seconds to wrap up, assume we time to 2% accuracy.
402
+    int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100;
403
+    // give 30 seconds to wrap up, assume we time to 2% accuracy.
488 404
 
489 405
     // Set basic precision needed:
490 406
     DP running_prec = 1.0;
491 407
 
492 408
     DP refine_fraction = 0.5; // value fraction of points to be refined
493 409
 
494
-    DP lambdamax_init = 10.0 * sqrt(ABACUS::max(1.0, kBT + mu));  // such that exp(-(lambdamax^2 - mu - Omega)/T) <~ machine_eps
410
+    DP lambdamax_init = 10.0 * sqrt(ABACUS::max(1.0, kBT + mu));
411
+    // such that exp(-(lambdamax^2 - mu - Omega)/T) <~ machine_eps
495 412
 
496 413
     int Npts = 50;
497 414
 
@@ -522,7 +439,6 @@ namespace ABACUS {
522 439
       // Refine... returns sum_delta_tni_dlambda, so running prec is estimated as...
523 440
       previous_running_prec = running_prec;
524 441
       running_prec = Refine_LiebLin_epsilon_TBA (epsilon, c_int, mu, kBT, refine_fraction);
525
-      //cout << "ncycles = " << ncycles << "\trunning_prec = " << running_prec << endl;
526 442
       running_prec = ABACUS::min(running_prec, previous_running_prec);
527 443
 
528 444
       // Now iterate to convergence for given discretization
@@ -537,11 +453,13 @@ namespace ABACUS {
537 453
 	Vect<DP> Tln1plusemineps(epsilon.Npts);
538 454
 	for (int i = 0; i < epsilon.Npts; ++i) {
539 455
 	  Tln1plusemineps[i] = epsilon.value[i] > 0.0 ?
540
-	    kBT * (epsilon.value[i] < 24.0 * kBT ? log(1.0 + exp(-epsilon.value[i]/kBT)) : exp(-epsilon.value[i]/kBT) * (1.0 - 0.5 * exp(-epsilon.value[i]/kBT)))
541
-	    //kBT * log(1.0 + exp(-epsilon.value[i]/kBT))
456
+	    kBT * (epsilon.value[i] < 24.0 * kBT
457
+		   ? log(1.0 + exp(-epsilon.value[i]/kBT))
458
+		   : exp(-epsilon.value[i]/kBT) * (1.0 - 0.5 * exp(-epsilon.value[i]/kBT)))
542 459
 	    :
543
-	    -epsilon.value[i] + kBT * (-epsilon.value[i] < 24.0 * kBT ? log (1.0 + exp(epsilon.value[i]/kBT)) : exp(epsilon.value[i]/kBT) * (1.0 - 0.5 * exp(epsilon.value[i]/kBT)));
544
-	  //-epsilon.value[i] + kBT * log (1.0 + exp(epsilon.value[i]/kBT));
460
+	    -epsilon.value[i] + kBT * (-epsilon.value[i] < 24.0 * kBT
461
+				       ? log (1.0 + exp(epsilon.value[i]/kBT))
462
+				       : exp(epsilon.value[i]/kBT) * (1.0 - 0.5 * exp(epsilon.value[i]/kBT)));
545 463
 	  // Keep previous rapidities:
546 464
 	  epsilon.prev_value[i] = epsilon.value[i];
547 465
 	}
@@ -551,7 +469,11 @@ namespace ABACUS {
551 469
 	for (int i = 0; i < epsilon.Npts; ++i) {
552 470
 	  a_2_Tln_conv[i] = 0.0;
553 471
 
554
-	  for (int j = 0; j < epsilon.Npts; ++j) a_2_Tln_conv[i] += oneoverpi * (atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] + 0.5 * epsilon.dlambda[j])) - atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] - 0.5 * epsilon.dlambda[j]))) * Tln1plusemineps[j];
472
+	  for (int j = 0; j < epsilon.Npts; ++j)
473
+	    a_2_Tln_conv[i] +=
474
+	      oneoverpi * (atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] + 0.5 * epsilon.dlambda[j]))
475
+			   - atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j]
476
+					      - 0.5 * epsilon.dlambda[j]))) * Tln1plusemineps[j];
555 477
 
556 478
 	} // a_2_Tln_conv is now calculated
557 479
 
@@ -563,9 +485,7 @@ namespace ABACUS {
563 485
 	  epsilon.value[i] -= a_2_Tln_conv[i];
564 486
 
565 487
 	  // Include some damping:
566
-	  //epsilon.value[i] = 0.1 * epsilon.prev_value[i] + 0.9 * epsilon.value[i];
567 488
 	  epsilon.value[i] = 0.1 * epsilon.prev_value[i] + 0.9 * epsilon.value[i];
568
-	  //* (1.0 + (epsilon.value[i] - epsilon.prev_value[i])/fabs(epsilon.value[i] + epsilon.prev_value[i]));
569 489
 	}
570 490
 
571 491
 	niter++;
@@ -582,15 +502,11 @@ namespace ABACUS {
582 502
 	StopTime = clock();
583 503
 	CPU_ticks += StopTime - StartTime;
584 504
 
585
-	//cout << "epsilon: niter = " << niter << "\tdiff = " << epsilon.diff << endl;
586
-	//cout << epsilon.lambda[0] << "\t" << epsilon.dlambda[0] << endl;
587
-	//cout << "a_2_Tln_conv[0] = " << a_2_Tln_conv[0] << "\tTln1plusemineps[0] = " << Tln1plusemineps[0] << endl;
588 505
       } while (niter < 5 || niter < niter_max && CPU_ticks < Max_CPU_ticks && epsilon.diff > 0.1*running_prec);
589 506
 
590 507
       ncycles++;
591 508
       niter_tot += niter;
592 509
 
593
-      //cout << "End of a cycle: niter = " << niter << "\tniter_tot = " << niter_tot << "\tepsilon.diff = " << epsilon.diff << "\tNpts = " << epsilon.Npts << "\tlambdamax = " << epsilon.lambda[0] << "\trunning_prec = " << running_prec << "\treq_diff = " << req_diff << endl;
594 510
     } // do cycles
595 511
     while (ncycles < 5 || running_prec > req_diff && CPU_ticks < Max_CPU_ticks);
596 512
 
@@ -603,7 +519,8 @@ namespace ABACUS {
603 519
   {
604 520
 
605 521
     clock_t StartTime = clock();
606
-    int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100;  // give 30 seconds to wrap up, assume we time to 2% accuracy.
522
+    int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100;
523
+    // give 30 seconds to wrap up, assume we time to 2% accuracy.
607 524
 
608 525
     Root_Density depsilon_dmu = epsilon;
609 526
 
@@ -644,7 +561,10 @@ namespace ABACUS {
644 561
 	a_2_depsover1plusepluseps_conv[i] = 0.0;
645 562
 
646 563
 	for (int j = 0; j < depsilon_dmu.Npts; ++j)
647
-	  a_2_depsover1plusepluseps_conv[i] += oneoverpi * (atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] + 0.5 * epsilon.dlambda[j])) - atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] - 0.5 * epsilon.dlambda[j]))) * depsover1plusepluseps[j];
564
+	  a_2_depsover1plusepluseps_conv[i] +=
565
+	    oneoverpi * (atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] + 0.5 * epsilon.dlambda[j]))
566
+			 - atan(oneoverc * (epsilon.lambda[i] - epsilon.lambda[j] - 0.5 * epsilon.dlambda[j])))
567
+	    * depsover1plusepluseps[j];
648 568
       }
649 569
 
650 570
       // Reconstruct the depsilon_dmu function:
@@ -668,7 +588,6 @@ namespace ABACUS {
668 588
       StopTime = clock();
669 589
       CPU_ticks += StopTime - StartTime;
670 590
 
671
-      //cout << "depsilon_dmu: niter = " << niter << "\tdiff = " << depsilon_dmu.diff << endl;
672 591
     } while (niter < 5 || niter < niter_max && CPU_ticks < Max_CPU_ticks && depsilon_dmu.diff > req_diff);
673 592
 
674 593
     return(depsilon_dmu);
@@ -717,7 +636,9 @@ namespace ABACUS {
717 636
   DP LiebLin_sbar_TBA (const Root_Density& rho, const Root_Density& rhoh)
718 637
   {
719 638
     DP sbar = 0.0;
720
-    for (int i = 0; i < rho.Npts; ++i) sbar += ((rho.value[i] + rhoh.value[i]) * log(rho.value[i] + rhoh.value[i]) - rho.value[i] * log(rho.value[i]+1.0e-30) - rhoh.value[i] * log(rhoh.value[i]+1.0e-30)) * rho.dlambda[i];
639
+    for (int i = 0; i < rho.Npts; ++i)
640
+      sbar += ((rho.value[i] + rhoh.value[i]) * log(rho.value[i] + rhoh.value[i])
641
+	       - rho.value[i] * log(rho.value[i]+1.0e-30) - rhoh.value[i] * log(rhoh.value[i]+1.0e-30)) * rho.dlambda[i];
721 642
 
722 643
     return(sbar);
723 644
   }
@@ -743,20 +664,12 @@ namespace ABACUS {
743 664
 	  lambda_found[Nfound++] = 0.25 * (rho.lambda[i-1] + 3.0 * rho.lambda[i]);
744 665
 	}
745 666
 	else {
746
-	  //lambda_found[Nfound] = rho.lambda[i];
747 667
 	  // Better: center the lambda_found between these points:
748
-	  //lambda_found[Nfound] = rho.lambda[i-1] + (rho.lambda[i] - rho.lambda[i-1]) * ((Nfound + 1.0) - integral_prev)/(integral - integral_prev);
749 668
 	  lambda_found[Nfound] = 0.5 * (rho.lambda[i-1] + rho.lambda[i]);
750 669
 	  Nfound++;
751 670
 	}
752 671
       }
753
-      //cout << "\ti = " << i << "\tintegral = " << integral << "\tNfound = " << Nfound << endl;
754 672
     }
755
-    //cout << "rho: " << rho.Npts << " points" << endl << rho.value << endl;
756
-    //cout << "sym: " << rho.value[0] << " " << rho.value[rho.value.size() - 1]
757
-    // << "\t" << rho.value[rho.value.size()/2] << " " << rho.value[rho.value.size()/2 + 1] << endl;
758
-    //cout << "Found " << Nfound << " particles." << endl;
759
-    //cout << "lambda_found = " << lambda_found << endl;
760 673
 
761 674
     Vect<DP> lambda(N);
762 675
     // Fill up the found rapidities:
@@ -770,11 +683,9 @@ namespace ABACUS {
770 683
     for (int i = 0; i < N; ++i) {
771 684
       DP sum = 0.0;
772 685
       for (int j = 0; j < N; ++j) sum += 2.0 * atan((lambda[i] - lambda[j])/c_int);
773
-      //Ix2[i] = 2.0* int((L * lambda[i] + sum)/twoPI) + (N % 2) - 1;
774 686
       // For N is even/odd, we want to round off to the nearest odd/even integer.
775 687
       Ix2[i] = 2.0 * floor((L* lambda[i] + sum)/twoPI + 0.5 * (N%2 ? 1 : 2)) + (N%2) - 1;
776 688
     }
777
-    //cout << "Found quantum numbers " << endl << Ix2 << endl;
778 689
 
779 690
     // Check that the quantum numbers are all distinct:
780 691
     bool allOK = false;
@@ -784,12 +695,10 @@ namespace ABACUS {
784 695
       allOK = true;
785 696
       for (int i = 0; i < N-1; ++i) if (Ix2[i] == Ix2[i+1]) allOK = false;
786 697
     }
787
-    //cout << "Found modified quantum numbers " << endl << Ix2 << endl;
788 698
 
789 699
     LiebLin_Bethe_State rhostate(c_int, L, N);
790 700
     rhostate.Ix2 = Ix2;
791 701
     rhostate.Compute_All(true);
792
-    //cout << "rapidities of state found: " << rhostate.lambdaoc << endl;
793 702
 
794 703
     return(rhostate);
795 704
   }

+ 2
- 212
src/TBA/TBA_XXZ.cc View File

@@ -80,7 +80,8 @@ namespace ABACUS {
80 80
       conv = 0.0;
81 81
       for (int j = 0; j < rhotot_GS.Npts; ++j)
82 82
 	conv += fabs(rhotot_GS.lambda[j]) > B ? 0.0 :
83
-	  XXZ_a2_kernel (sin2zeta, cos2zeta, rhotot_GS.lambda[i] - rhotot_GS.lambda[j]) * rhotot_GS.prev_value[j] * rhotot_GS.dlambda[j];
83
+	  XXZ_a2_kernel (sin2zeta, cos2zeta, rhotot_GS.lambda[i] - rhotot_GS.lambda[j])
84
+	  * rhotot_GS.prev_value[j] * rhotot_GS.dlambda[j];
84 85
       rhotot_GS.value[i] = XXZ_a1_kernel(sinzeta, coszeta, rhotot_GS.lambda[i]) - conv;
85 86
     }
86 87
 
@@ -109,11 +110,9 @@ namespace ABACUS {
109 110
     int niter = 0;
110 111
     do {
111 112
       Iterate_XXZ_rhotot_GS (zeta, B, rhotot_GS);
112
-      //cout << rhotot_GS.diff << endl;
113 113
       niter ++;
114 114
     } while (rhotot_GS.diff > req_prec);
115 115
 
116
-    //cout << "rhotot: niter = " << niter << endl;
117 116
     return(rhotot_GS);
118 117
   }
119 118
 
@@ -147,7 +146,6 @@ namespace ABACUS {
147 146
 	  XXZ_a2_kernel (sin2zeta, cos2zeta, eps_GS.lambda[i] - eps_GS.lambda[j])
148 147
 	  * eps_GS.prev_value[j] * eps_GS.dlambda[j];
149 148
       eps_GS.value[i] = Hz - PI * sinzeta * XXZ_a1_kernel(sinzeta, coszeta, eps_GS.lambda[i]) - conv;
150
-      //cout << i << "\t" << eps_GS.lambda[i] << "\t" << eps_GS.value[i] << "\t" << conv << endl;
151 149
     }
152 150
 
153 151
     // Calculate the sum of differences:
@@ -175,12 +173,9 @@ namespace ABACUS {
175 173
     int niter = 0;
176 174
     do {
177 175
       Iterate_XXZ_eps_GS (zeta, Hz, eps_GS);
178
-      //cout << eps_GS.diff << endl;
179 176
       niter++;
180
-      //cout << niter << "\t" << eps_GS.diff << endl;
181 177
     } while (eps_GS.diff > req_prec);
182 178
 
183
-  //cout << "eps: niter = " << niter << endl;
184 179
     return(eps_GS);
185 180
   }
186 181
 
@@ -232,11 +227,9 @@ namespace ABACUS {
232 227
     int niter = 0;
233 228
     do {
234 229
       Iterate_XXZ_depsdlambda_GS (zeta, B, depsdlambda_GS);
235
-      //cout << depsdlambda_GS.diff << endl;
236 230
       niter++;
237 231
     } while (depsdlambda_GS.diff > req_prec);
238 232
 
239
-    //cout << "depsdlambda: niter = " << niter << endl;
240 233
     return(depsdlambda_GS);
241 234
   }
242 235
 
@@ -289,12 +282,9 @@ namespace ABACUS {
289 282
     int niter = 0;
290 283
     do {
291 284
       Iterate_XXZ_b2BB_lambda_B (zeta, B, b2BB_lambda_B);
292
-      //cout << eps_GS.diff << endl;
293 285
       niter++;
294 286
     } while (b2BB_lambda_B.diff > req_prec);
295 287
 
296
-    //if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
297
-    //cout << "Kbackflow: niter = " << niter << endl;
298 288
     return(b2BB_lambda_B);
299 289
   }
300 290
 
@@ -347,12 +337,9 @@ namespace ABACUS {
347 337
     int niter = 0;
348 338
     do {
349 339
       Iterate_XXZ_b2BB_lambda_lambdap (zeta, B, lambdap, b2BB_lambda_lambdap);
350
-      //cout << eps_GS.diff << endl;
351 340
       niter++;
352 341
     } while (b2BB_lambda_lambdap.diff > req_prec);
353 342
 
354
-    //if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
355
-    //cout << "Kbackflow: niter = " << niter << endl;
356 343
     return(b2BB_lambda_lambdap);
357 344
   }
358 345
 
@@ -368,14 +355,12 @@ namespace ABACUS {
368 355
     DP sin2zeta = sin(2.0*zeta);
369 356
     DP cos2zeta = cos(2.0*zeta);
370 357
     for (int i = 0; i < Kbackflow_GS.Npts; ++i) {
371
-      //if (Kbackflow_GS.lambda[i] < -B || Kbackflow_GS.lambda[i] > lambda_p + lambda_h + B) Kbackflow_GS.value[i] = 0.0;
372 358
       if (false && fabs(Kbackflow_GS.lambda[i]) > B) Kbackflow_GS.value[i] = 0.0;
373 359
       else {
374 360
 	// First, calculate the convolution
375 361
 	conv = 0.0;
376 362
 	for (int j = 0; j < Kbackflow_GS.Npts; ++j)
377 363
 	  conv += fabs(Kbackflow_GS.lambda[j]) > B ? 0.0 :
378
-	    //(Kbackflow_GS.lambda[i] < -B || Kbackflow_GS.lambda[i] > lambda_p + lambda_h + B) ? 0.0 :
379 364
 	    XXZ_a2_kernel (sin2zeta, cos2zeta, Kbackflow_GS.lambda[i] - Kbackflow_GS.lambda[j])
380 365
 	    * Kbackflow_GS.prev_value[j] * Kbackflow_GS.dlambda[j];
381 366
 	Kbackflow_GS.value[i] = -XXZ_a2_kernel(sin2zeta, cos2zeta, Kbackflow_GS.lambda[i] - lambda_p)
@@ -407,12 +392,9 @@ namespace ABACUS {
407 392
     int niter = 0;
408 393
     do {
409 394
       Iterate_XXZ_Kbackflow_GS (zeta, B, lambda_p, lambda_h, Kbackflow_GS);
410
-      //cout << eps_GS.diff << endl;
411 395
       niter++;
412 396
     } while (Kbackflow_GS.diff > req_prec);
413 397
 
414
-    //if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
415
-    //cout << "Kbackflow: niter = " << niter << endl;
416 398
     return(Kbackflow_GS);
417 399
   }
418 400
 
@@ -465,12 +447,9 @@ namespace ABACUS {
465 447
     int niter = 0;
466 448
     do {
467 449
       Iterate_XXZ_Fbackflow_GS (zeta, B, lambda_p, lambda_h, Fbackflow_GS);
468
-      //cout << eps_GS.diff << endl;
469 450
       niter++;
470 451
     } while (Fbackflow_GS.diff > req_prec);
471 452
 
472
-    //if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
473
-    //cout << "Fbackflow: niter = " << niter << endl;
474 453
     return(Fbackflow_GS);
475 454
   }
476 455
 
@@ -519,199 +498,10 @@ namespace ABACUS {
519 498
 
520 499
     do {
521 500
       Iterate_XXZ_Z_GS (zeta, B, Z_GS);
522
-      //cout << depsdlambda_GS.diff << endl;
523 501
     } while (Z_GS.diff > req_prec);
524 502
 
525 503
     return(Z_GS);
526 504
   }
527 505
 
528
-  /*
529
-  void XXZ_Compare_Lattice_and_Continuum_Backflows_base_1010 (DP Delta, int N, int M, long long int id)
530
-  {
531
-    // Define the chain:  J, Delta, h, Nsites
532
-    Heis_Chain chain(1.0, Delta, 0.0, N);
533
-
534
-    // Define the base:  chain, Mdown
535
-    Heis_Base gbase(chain, M);
536
-
537
-    // Define the ground state
538
-    XXZ_Bethe_State gstate(chain, gbase);
539
-
540
-    // Compute everything about the ground state
541
-    gstate.Compute_All(true);
542
-
543
-    // Define the number of rapidities for an excited state
544
-    Vect_INT Nrapidities(0, chain.Nstrings);
545
-    Nrapidities[0] = M;
546
-
547
-    Vect_INT Nexcitations(0, 2* chain.Nstrings + 2);
548
-    Nexcitations[0] = 0;
549
-    Nexcitations[1] = 1;
550
-    Nexcitations[2] = 0;
551
-    Nexcitations[3] = 1;
552
-
553
-    // Define a base configuration for this set of rapidity numbers
554
-    Heis_Base ebase (chain, Nrapidities);
555
-
556
-    // Define the excited state
557
-    XXZ_Bethe_State estate(chain, ebase);
558
-
559
-    // Define an offset from a base and a number of holes
560
-    Ix2_Offsets offsets(ebase, Nexcitations);
561
-
562
-    // Set the offset to the desired id
563
-    offsets.Set_to_id (id);
564
-
565
-    // Set the offset data into the quantum numbers
566
-    estate.Set_Ix2_Offsets(offsets);
567
-
568
-    // Compute everything about this eigenstate
569
-    estate.Compute_All(true);
570
-
571
-    DP k_ext_N = estate.K - gstate.K;
572
-    DP omega_N = estate.E - gstate.E;
573
-    DP lambdap = estate.lambda[0][0];
574
-    DP lambdah = 0.0;
575
-    for (int alpha = 1; alpha < estate.base[0] - 1; ++alpha)
576
-      if (estate.Ix2[0][alpha + 1] > estate.Ix2[0][alpha] + 2) {
577
-	lambdah = 0.5 * (estate.lambda[0][alpha] + estate.lambda[0][alpha + 1]);
578
-      }
579
-
580
-
581
-    // Now solve the thermodynamic equations:
582
-    DP req_prec = 1.0e-12;
583
-    DP Hz_N = H_vs_M (Delta, N, M);
584
-    cout << "Hz_N = " << Hz_N << endl;
585
-    DP lambdamax = 4.0 * fabs(gstate.lambda[0][0]);
586
-    int Npts = 2000;
587
-    Root_Density eps_GS = XXZ_eps_GS (Delta, Hz_N, lambdamax, Npts, req_prec);
588
-
589
-    // We can read off the value of B from the obtained eps_GS function:
590
-    DP B_eps = 0.0;
591
-    int iB_eps = Npts/2;
592
-    for (int i = Npts/2; i < Npts - 1; ++i)
593
-      if (eps_GS.value[i] * eps_GS.value[i+1] < 0.0) {
594
-	B_eps = 0.5 * (eps_GS.lambda[i] + eps_GS.lambda[i+1]);
595
-	iB_eps = i;
596
-      }
597
-    if (B_eps == 0.0) {
598
-      cout << "Delta = " << Delta << "\tN = " << N << "\tM = " << M << "\tHz_N = " << Hz_N << "\tid = " << id << endl;
599
-      ABACUSerror("B not found.");
600
-    }
601
-    if (B_eps > 0.5 * lambdamax) {
602
-      cout << "Delta = " << Delta << "\tN = " << N << "\tM = " << M << "\tHz_N = " << Hz_N << "\tid = " << id << endl;
603
-      ABACUSerror("Use a higher value of lambdamax.");
604
-    }
605
-    //DP lambdamax = lambdamax_eps;
606
-    //DP lambdamax = 2.0 * fabs(gstate.lambda[0][0]); // window of definition of Kbackflow is covered
607
-    // Start by finding the appropriate B:
608
-    DP B = DP(M)/N; // initial guess;
609
-    DP B_old = B;
610
-    DP dB = 0.5 * B; // variation we allow;
611
-    DP m_TBA = 0.0;
612
-    //Vect<Root_Density> rhotot_GS_iter(10);// = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
613
-    Root_Density rhotot_GS = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
614
-    int iter = 0;
615
-    do {
616
-      B_old = B;
617
-      rhotot_GS = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
618
-      m_TBA = 0.0;
619
-      for (int i1 = 0; i1 < rhotot_GS.Npts; ++i1) if (fabs(rhotot_GS.lambda[i1]) < B) m_TBA += rhotot_GS.value[i1] * rhotot_GS.dlambda[i1];
620
-      if (m_TBA < DP(M)/N) B += dB;
621
-      else B -= dB;
622
-      cout << "B_old = " << B_old << "\tB = " << B << "\tdB = " << dB << "\tm = " << m_TBA << "\tM/N = " << DP(M)/N << endl;
623
-      dB *= 1.0/1.9;
624
-    } while (dB > 0.001 && iter < 9);
625
-
626
-    cout << "Check of consistency:  B_eps = " << B_eps << "\tB = " << B << "\tm_TBA = " << m_TBA << "\tM/N = " << DP(M)/N << endl;
627
-
628
-    //Root_Density rhotot_GS = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
629
-    Root_Density b2BB_lambda_B = XXZ_b2BB_lambda_B (Delta, B, lambdamax, Npts, req_prec);
630
-    Root_Density Kbackflow_GS = XXZ_Kbackflow_GS (Delta, B, lambdamax, lambdap, lambdah, Npts, req_prec);
631
-    Root_Density Fbackflow_GS = XXZ_Fbackflow_GS (Delta, B, lambdamax, lambdap, lambdah, Npts, req_prec);
632
-
633
-    // Calculate the momentum and energy of the TBA state:
634
-    // Momentum:
635
-    DP conv = 0.0;
636
-    DP zeta = acos(Delta);
637
-    for (int l = 0; l < rhotot_GS.Npts; ++l) {
638
-      conv += fabs(rhotot_GS.lambda[l]) > B ? 0.0 :
639
-	(XXZ_phi2_kernel(zeta, lambdap - rhotot_GS.lambda[l])
640
-	 - XXZ_phi2_kernel(zeta, lambdah - rhotot_GS.lambda[l]))
641
-	* rhotot_GS.value[l] * rhotot_GS.dlambda[l];
642
-    }
643
-    DP k_ext_TBA = -XXZ_phi1_kernel (zeta, lambdap) + XXZ_phi1_kernel (zeta, lambdah) + conv;
644
-    // Energy:
645
-    conv = 0.0;
646
-    DP sinzeta = sin(zeta);
647
-    DP coszeta = cos(zeta);
648
-    for (int l = 0; l < Kbackflow_GS.Npts; ++l)
649
-      conv += fabs(Kbackflow_GS.lambda[l]) > B ? 0.0 :
650
-	(Hz_N - PI * sinzeta * XXZ_a1_kernel(sinzeta, coszeta, Kbackflow_GS.lambda[l]))
651
-	* Kbackflow_GS.value[l] * Kbackflow_GS.dlambda[l];
652
-    DP omega_TBA = -PI * sin(zeta) * (XXZ_a1_kernel(sinzeta, coszeta, lambdap)
653
-				      - XXZ_a1_kernel(sinzeta, coszeta, lambdah)) + conv;
654
-
655
-    cout << "k_ext_N = " << k_ext_N << "\tk_ext_TBA = " << k_ext_TBA << "\tomega_N = " << omega_N << "\tomega_TBA = " << omega_TBA << endl;
656
-
657
-    // Get back to the finite lattice case:
658
-    // Define densities as 1/N \sum_j delta (lambda - lambda_j);  use Gaussian smoothing of functions.
659
-    DP gwidth = 2.0 * B * log(DP(N))/M; // mean rapidity spacing times some factor, for smoothing of Gaussians
660
-    DP gwidthsq = gwidth * gwidth;
661
-    Vect_DP rhoGS_N (0.0, Npts);
662
-    Vect_DP rhoexc_N (0.0, Npts);
663
-    Vect_DP Kflow_N (0.0, Npts);
664
-    for (int iout = 0; iout < Npts; ++iout) {
665
-      DP lambdaout = rhotot_GS.lambda[iout];
666
-      // We compute the densities at each point...
667
-      for (int alpha = 0; alpha < M; ++alpha)
668
-	rhoGS_N[iout] += exp(-(gstate.lambda[0][alpha] - lambdaout) * (gstate.lambda[0][alpha] - lambdaout)/gwidthsq);
669
-      rhoGS_N[iout] /= N * sqrt(PI) * gwidth;
670
-      for (int alpha = 1; alpha < estate.base[0]; ++alpha)
671
-	rhoexc_N[iout] += exp(-(estate.lambda[0][alpha] - lambdaout) * (estate.lambda[0][alpha] - lambdaout)/gwidthsq);
672
-      rhoexc_N[iout] /= N * sqrt(PI) * gwidth;
673
-
674
-      Kflow_N[iout] = N * (rhoexc_N[iout] - rhoGS_N[iout] + (1.0/N) * exp(-(lambdah - lambdaout) * (lambdah - lambdaout)/gwidthsq)/(sqrt(PI) * gwidth));
675
-    } // for iout
676
-
677
-    cout << "Here 1" << endl;
678
-    // Now produce a file with the density flow:
679
-    stringstream flo_stringstream;
680
-    flo_stringstream << "Flow_D_" << Delta << "_N_" << N << "_M_" << M << "_base_id_" << estate.base_id << "_type_id_" << estate.type_id
681
-		     << "_id_" << estate.id << ".flo";
682
-    string flo_string = flo_stringstream.str();
683
-    const char* flo_Cstr = flo_string.c_str();
684
-
685
-    ofstream outfile_flo;
686
-    outfile_flo.open(flo_Cstr);
687
-    outfile_flo.precision(16);
688
-
689
-    for (int iout = 0; iout < Npts; ++iout)
690
-      outfile_flo << rhotot_GS.lambda[iout] << "\t" << rhotot_GS.value[iout] << "\t" << rhoGS_N[iout] << "\t"
691
-		  << rhoexc_N[iout] << "\t" << Kbackflow_GS.value[iout] << "\t"
692
-		  << (fabs(Kbackflow_GS.lambda[iout]) > B ? 0.0 : Kbackflow_GS.value[iout]) - b2BB_lambda_B.value[iout] * Fbackflow_GS.value[iB_eps]
693
-	+ b2BB_lambda_B.value[b2BB_lambda_B.Npts - 1 - iout] * Fbackflow_GS.value[Fbackflow_GS.Npts - 1 - iB_eps] << "\t" << Kflow_N[iout] << endl;
694
-
695
-    outfile_flo.close();
696
-
697
-    // ... and a file with the remainder of the data:
698
-    stringstream dat_stringstream;
699
-    dat_stringstream << "Flow_D_" << Delta << "_N_" << N << "_M_" << M << "_base_id_" << estate.base_id << "_type_id_" << estate.type_id
700
-		     << "_id_" << estate.id << ".dat";
701
-    string dat_string = dat_stringstream.str();
702
-    const char* dat_Cstr = dat_string.c_str();
703
-
704
-    ofstream outfile_dat;
705
-    outfile_dat.open(dat_Cstr);
706
-    outfile_dat.precision(16);
707
-
708
-    outfile_dat << "lambdap\tlambdah\tk_ext_N\tk_ext_TBA\tomega_N\tomega_TBA"
709
-		<< lambdap << "\t" << lambdah << "\t" << k_ext_N << "\t" << k_ext_TBA << "\t" << omega_N << "\t" << omega_TBA << endl;
710
-
711
-    outfile_dat.close();
712
-
713
-    return;
714
-  }
715
-  */
716 506
 
717 507
 }  // namespace ABACUS

+ 21
- 37
src/UTILS/Data_File_Name.cc View File

@@ -28,7 +28,8 @@ namespace ABACUS {
28 28
 
29 29
   // Lieb-Liniger:
30 30
 
31
-  void Data_File_Name (stringstream& name, char whichDSF, DP c_int, DP L, int N, int iKmin, int iKmax, DP kBT, DP L2, string defaultScanStatename)
31
+  void Data_File_Name (stringstream& name, char whichDSF, DP c_int, DP L, int N, int iKmin, int iKmax,
32
+		       DP kBT, DP L2, string defaultScanStatename)
32 33
   {
33 34
     name << "LiebLin_";
34 35
     if (whichDSF == 'Z') name << "Z";
@@ -42,7 +43,6 @@ namespace ABACUS {
42 43
     else ABACUSerror("Option not implemented in Data_File_Name");
43 44
 
44 45
     name << "_c_" << c_int << "_L_" << L << "_N_" << N;
45
-    //if (fixed_iK) name << "_iK_" << iKneeded;
46 46
     if (defaultScanStatename == "") name << "_" << N << "_0_"; // simulates label of ground state
47 47
     else name << "_" << defaultScanStatename;
48 48
     if (iKmin == iKmax) name << "_iK_" << iKmin;
@@ -53,8 +53,8 @@ namespace ABACUS {
53 53
     return;
54 54
   }
55 55
 
56
-  //void Data_File_Name (stringstream& name, char whichDSF, bool fixed_iK, int iKneeded, LiebLin_Bethe_State& State, LiebLin_Bethe_State& RefScanState)
57
-  void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT, LiebLin_Bethe_State& State, LiebLin_Bethe_State& RefScanState, string defaultScanStatename)
56
+  void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT,
57
+		       LiebLin_Bethe_State& State, LiebLin_Bethe_State& RefScanState, string defaultScanStatename)
58 58
   {
59 59
     name << "LiebLin_";
60 60
     if (whichDSF == 'Z') name << "Z";
@@ -68,7 +68,6 @@ namespace ABACUS {
68 68
     else ABACUSerror("Option not implemented in Data_File_Name");
69 69
 
70 70
     name << "_c_" << State.c_int << "_L_" << State.L << "_N_" << State.N;
71
-    //if (fixed_iK) name << "_iK_" << iKneeded;
72 71
     if (defaultScanStatename == "") name << "_" << State.label;
73 72
     else name << "_" << defaultScanStatename;
74 73
     if (iKmin == iKmax) name << "_iK_" << iKmin;  else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
@@ -81,8 +80,8 @@ namespace ABACUS {
81 80
 
82 81
   // Heisenberg:
83 82
 
84
-  //void Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, bool fixed_iK, int iKneeded, int N2)
85
-  void Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax, DP kBT, int N2, string defaultScanStatename)
83
+  void Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax,
84
+		       DP kBT, int N2, string defaultScanStatename)
86 85
   {
87 86
     name << "HEIS_";
88 87
     if (whichDSF == 'Z') name << "Z";
@@ -104,21 +103,14 @@ namespace ABACUS {
104 103
     if (defaultScanStatename == "") name << "_" << M << "_0_"; // simulates label of ground state
105 104
     else name << "_" << defaultScanStatename;
106 105
 
107
-    //if (fixed_iK) {
108
-    //  name << "_iK_";
109
-    //  for (int i = 0; i < int(log10(DP(N/2))) - int(log10(DP(iKneeded))); ++i) name << "0";
110
-    //  name << iKneeded;
111
-    //}
112
-    // From ABACUS++G_8 onwards: for Heisenberg, always scan over all momentum integers
113
-    //if (iKmin == iKmax) name << "_iK_" << iKmin;  else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
114 106
     if (kBT > 0.0) name << "_kBT_" << kBT;
115 107
     if (whichDSF == 'q') name << "_N2_" << N2;
116 108
 
117 109
     return;
118 110
   }
119 111
 
120
-  //void Data_File_Name (stringstream& name, char whichDSF, bool fixed_iK, int iKneeded, Heis_Bethe_State& State, Heis_Bethe_State& RefScanState)
121
-  void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT, Heis_Bethe_State& State, Heis_Bethe_State& RefScanState, string defaultScanStatename)
112
+  void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT,
113
+		       Heis_Bethe_State& State, Heis_Bethe_State& RefScanState, string defaultScanStatename)
122 114
   {
123 115
     name << "HEIS_";
124 116
     if (whichDSF == 'Z') name << "Z";
@@ -139,15 +131,6 @@ namespace ABACUS {
139 131
     name << State.base.Mdown;
140 132
     if (defaultScanStatename == "") name << "_" << State.label;
141 133
     else name << "_" << defaultScanStatename;
142
-    /*
143
-    if (fixed_iK) {
144
-      name << "_iK_";
145
-      for (int i = 0; i < int(log10(DP(State.chain.Nsites/2))) - int(log10(DP(iKneeded))); ++i) name << "0";
146
-      name << iKneeded;
147
-    }
148
-    */
149
-    // From ABACUS++G_8 onwards: for Heisenberg, always scan over all momentum integers
150
-    //if (iKmin == iKmax) name << "_iK_" << iKmin;  else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
151 134
     if (kBT > 0.0) name << "_kBT_" << kBT;
152 135
     if (whichDSF == 'q') name << "_N2_" << RefScanState.chain.Nsites;
153 136
 
@@ -155,10 +138,11 @@ namespace ABACUS {
155 138
   }
156 139
 
157 140
 
158
-  // One-D spinless fermions:
141
+  // One-D spinless fermions: IN DEVELOPMENT
159 142
   /*
160
-  void ODSLF_Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax, DP kBT, int N2, string defaultScanStatename)
161
-  {
143
+    void ODSLF_Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax,
144
+    DP kBT, int N2, string defaultScanStatename)
145
+    {
162 146
     name << "ODSLF_";
163 147
     if (whichDSF == 'Z') name << "Z";
164 148
     else if (whichDSF == 'm') name << "cdag_c";
@@ -176,11 +160,11 @@ namespace ABACUS {
176 160
     if (whichDSF == 'q') name << "_N2_" << N2;
177 161
 
178 162
     return;
179
-  }
163
+    }
180 164
 
181
-  //void Data_File_Name (stringstream& name, char whichDSF, bool fixed_iK, int iKneeded, Heis_Bethe_State& State, Heis_Bethe_State& RefScanState)
182
-  void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT, ODSLF_Bethe_State& State, ODSLF_Bethe_State& RefScanState, string defaultScanStatename)
183
-  {
165
+    void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT,
166
+    ODSLF_Bethe_State& State, ODSLF_Bethe_State& RefScanState, string defaultScanStatename)
167
+    {
184 168
     name << "ODSLF_";
185 169
     if (whichDSF == 'Z') name << "Z";
186 170
     else if (whichDSF == 'm') name << "cdag_c";
@@ -195,16 +179,16 @@ namespace ABACUS {
195 179
     for (int i = 0; i < int(log10(DP(State.chain.Nsites/2))) - int(log10(DP(State.base.Mdown))); ++i) name << "0";
196 180
     name << State.base.Mdown;
197 181
     if (fixed_iK) {
198
-      name << "_iK_";
199
-      for (int i = 0; i < int(log10(DP(State.chain.Nsites/2))) - int(log10(DP(iKneeded))); ++i) name << "0";
200
-      name << iKneeded;
182
+    name << "_iK_";
183
+    for (int i = 0; i < int(log10(DP(State.chain.Nsites/2))) - int(log10(DP(iKneeded))); ++i) name << "0";
184
+    name << iKneeded;
201 185
     }
202 186
     if (iKmin == iKmax) name << "_iK_" << iKmin;  else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
203 187
     if (kBT > 0.0) name << "_kBT_" << kBT;
204 188
     if (whichDSF == 'q') name << "_N2_" << RefScanState.chain.Nsites;
205 189
 
206 190
     return;
207
-  }
208
-*/
191
+    }
192
+  */
209 193
 
210 194
 } // namespace ABACUS

+ 0
- 21
src/UTILS/Smoothen_RAW_into_SF.cc View File

@@ -49,7 +49,6 @@ namespace ABACUS {
49 49
     DP omega;
50 50
     int iK;
51 51
     DP FF;
52
-    //int conv;
53 52
     DP dev;
54 53
     string label;
55 54
 
@@ -69,16 +68,13 @@ namespace ABACUS {
69 68
     DP SFfactor = 1.0;
70 69
 
71 70
     while (RAW_infile.peek() != EOF) {
72
-      //RAW_infile >> omega >> iK >> FF >> conv >> label;
73 71
       RAW_infile >> omega >> iK >> FF >> dev >> label;
74 72
       if (iK >= iKmin && iK <= iKmax  && fabs(omega) > 1.0e-8) { // remove connected part of DSF
75
-	//SSF[iK - iKmin] += FF * FF;
76 73
 	for (int deltaiK = -DiK; deltaiK <= DiK; ++deltaiK)
77 74
 	  if (iK + deltaiK >= iKmin && iK + deltaiK <= iKmax)
78 75
 	    SSF[iK + deltaiK - iKmin] += Kweight[abs(deltaiK)] * FF * FF;
79 76
 	for (int iomega = 0; iomega < Nom; ++iomega)
80 77
 	  if (big_gwidth_used > (d_omega = fabs(omegaout[iomega] - omega))) {
81
-	    //DSF[iomega][iK - iKmin] += FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
82 78
 	    SFfactor = FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
83 79
 	    ASF[iomega] += SFfactor;
84 80
 	    if (fabs(omega) > 1.0e-12) // exclude the delta function contribution coming from diagonal term, if present
@@ -107,7 +103,6 @@ namespace ABACUS {
107 103
 
108 104
     stringstream DSF_stringstream;    string DSF_string;
109 105
     DSF_stringstream << prefix;
110
-    //if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
111 106
     if (DiK > 0) DSF_stringstream << "_DiK_" << DiK;
112 107
     DSF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".dsf";
113 108
     DSF_string = DSF_stringstream.str();    const char* DSF_Cstr = DSF_string.c_str();
@@ -125,7 +120,6 @@ namespace ABACUS {
125 120
 
126 121
     stringstream SSF_stringstream;    string SSF_string;
127 122
     SSF_stringstream << prefix;
128
-    //if (iKmin != iKmax) SSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
129 123
     if (DiK > 0) SSF_stringstream << "_DiK_" << DiK;
130 124
     SSF_stringstream << ".ssf";
131 125
     SSF_string = SSF_stringstream.str();    const char* SSF_Cstr = SSF_string.c_str();
@@ -143,7 +137,6 @@ namespace ABACUS {
143 137
 
144 138
     stringstream ASF_stringstream;    string ASF_string;
145 139
     ASF_stringstream << prefix;
146
-    //if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
147 140
     ASF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".asf";
148 141
     ASF_string = ASF_stringstream.str();    const char* ASF_Cstr = ASF_string.c_str();
149 142
 
@@ -192,7 +185,6 @@ namespace ABACUS {
192 185
     DP omega;
193 186
     int iK;
194 187
     DP FF;
195
-    //int conv;
196 188
     DP dev;
197 189
     string label;
198 190
 
@@ -214,10 +206,6 @@ namespace ABACUS {
214 206
     for (int ns = 0; ns < weight.size(); ++ns) {
215 207
 
216 208
       // Open the original raw file:
217
-      //stringstream RAW_stringstream;    string RAW_string;
218
-      //RAW_stringstream << prefix << ".raw";
219
-      //RAW_string = RAW_stringstream.str();
220
-      //const char* RAW_Cstr = RAW_string.c_str();
221 209
       const char* RAW_Cstr = rawfilename[ns].c_str();
222 210
 
223 211
       ifstream RAW_infile;
@@ -228,13 +216,11 @@ namespace ABACUS {
228 216
       }
229 217
 
230 218
       while (RAW_infile.peek() != EOF) {
231
-	//RAW_infile >> omega >> iK >> FF >> conv >> label;
232 219
 	RAW_infile >> omega >> iK >> FF >> dev >> label;
233 220
 	if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF)
234 221
 	  SSF[iK - iKmin] += weight[ns] * FF * FF;
235 222
 	  for (int iomega = 0; iomega < Nom; ++iomega)
236 223
 	    if (big_gwidth_used > (d_omega = fabs(omegaout[iomega] - omega))) {
237
-	      //DSF[iomega][iK - iKmin] += FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
238 224
 	      SFfactor = weight[ns] * FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
239 225
 	      ASF[iomega] += SFfactor;
240 226
 	      if (fabs(omega) > 1.0e-12) // exclude the delta function contribution coming from diagonal term, if present
@@ -264,7 +250,6 @@ namespace ABACUS {
264 250
 
265 251
     stringstream DSF_stringstream;    string DSF_string;
266 252
     DSF_stringstream << prefix;
267
-    //if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
268 253
     DSF_stringstream << "_ns_" << weight.size();
269 254
     if (DiK > 0) DSF_stringstream << "_DiK_" << DiK;
270 255
     DSF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".dsf";
@@ -283,7 +268,6 @@ namespace ABACUS {
283 268
 
284 269
     stringstream SSF_stringstream;    string SSF_string;
285 270
     SSF_stringstream << prefix;
286
-    //if (iKmin != iKmax) SSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
287 271
     SSF_stringstream << "_ns_" << weight.size();
288 272
     SSF_stringstream << ".ssf";
289 273
     SSF_string = SSF_stringstream.str();    const char* SSF_Cstr = SSF_string.c_str();
@@ -301,7 +285,6 @@ namespace ABACUS {
301 285
 
302 286
     stringstream ASF_stringstream;    string ASF_string;
303 287
     ASF_stringstream << prefix;
304
-    //if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
305 288
     ASF_stringstream << "_ns_" << weight.size();
306 289
     ASF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".asf";
307 290
     ASF_string = ASF_stringstream.str();    const char* ASF_Cstr = ASF_string.c_str();
@@ -317,7 +300,6 @@ namespace ABACUS {
317 300
     ASF_outfile.close();
318 301
 
319 302
 
320
-
321 303
     // Check sums:
322 304
     DP sumdsf = 0.0;
323 305
     DP sumssf = 0.0;
@@ -361,7 +343,6 @@ namespace ABACUS {
361 343
     DP omega;
362 344
     int iK;
363 345
     DP FF;
364
-    //int conv;
365 346
     DP dev;
366 347
     string label;
367 348
 
@@ -373,7 +354,6 @@ namespace ABACUS {
373 354
     DP oneovertwowidthsq = 1.0/(2.0 * gwidth * gwidth);
374 355
 
375 356
     while (RAW_infile.peek() != EOF) {
376
-      //RAW_infile >> omega >> iK >> FF >> conv >> label;
377 357
       RAW_infile >> omega >> iK >> FF >> dev >> label;
378 358
       if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF)
379 359
 	for (int iomega = 0; iomega < Nom; ++iomega)
@@ -390,7 +370,6 @@ namespace ABACUS {
390 370
       ASF[iomega] *= normalization_used;
391 371
 
392 372
     // Output to .asf file
393
-
394 373
     stringstream ASF_stringstream;    string ASF_string;
395 374
     ASF_stringstream << prefix;
396 375
     //if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;

+ 5
- 17
src/UTILS/Smoothen_RAW_into_SF_LiebLin_Scaled.cc View File

@@ -21,7 +21,7 @@ using namespace ABACUS;
21 21
 namespace ABACUS {
22 22
 
23 23
   DP Smoothen_RAW_into_SF_LiebLin_Scaled (string prefix, DP L, int N, int iKmin, int iKmax, int DiK,
24
-				       DP ommin, DP ommax, int Nom, DP width, DP normalization)
24
+					  DP ommin, DP ommax, int Nom, DP width, DP normalization)
25 25
   {
26 26
     // DiK is the (half-)window in iK which is averaged over. A single iK means DiK == 0.
27 27
 
@@ -51,7 +51,6 @@ namespace ABACUS {
51 51
     DP omega;
52 52
     int iK;
53 53
     DP FF;
54
-    //int conv;
55 54
     DP dev;
56 55
     string label;
57 56
 
@@ -76,9 +75,10 @@ namespace ABACUS {
76 75
     // For iK > N, there are N states.
77 76
 
78 77
     for (iK = iKmin; iK <= iKmax; ++iK)
79
-      //gwidth[iK - iKmin] = width * 2.0 * ABACUS::min( pow(twoPI * ABACUS::max(abs(iK),1)/L, 2.0), pow(twoPI * N/L, 2.0))/ABACUS::min(N, ABACUS::max(abs(iK), 1));
80
-    // Make sure the width does not become lower than the omegaout raster:
81
-      gwidth[iK - iKmin] = ABACUS::max(2.0 * (ommax - ommin)/Nom, width * 2.0 * ABACUS::min( pow(twoPI * ABACUS::max(abs(iK),1)/L, 2.0), pow(twoPI * N/L, 2.0))/ABACUS::min(N, ABACUS::max(abs(iK), 1)));
78
+      // Make sure the width does not become lower than the omegaout raster:
79
+      gwidth[iK - iKmin] = ABACUS::max(2.0 * (ommax - ommin)/Nom, width * 2.0
80
+				       * ABACUS::min( pow(twoPI * ABACUS::max(abs(iK),1)/L, 2.0),
81
+						      pow(twoPI * N/L, 2.0))/ABACUS::min(N, ABACUS::max(abs(iK), 1)));
82 82
 
83 83
 
84 84
     Vect_DP big_gwidth_used (iKmax - iKmin + 1);
@@ -95,14 +95,12 @@ namespace ABACUS {
95 95
 
96 96
     DP FFsq = 0.0;
97 97
     while (RAW_infile.peek() != EOF) {
98
-      //RAW_infile >> omega >> iK >> FF >> conv >> label;
99 98
       RAW_infile >> omega >> iK >> FF >> dev >> label;
100 99
       if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF
101 100
 	FFsq = FF * FF;
102 101
 	SSF[iK - iKmin] += FFsq;
103 102
 	for (int iomega = 0; iomega < Nom; ++iomega)
104 103
 	  if (big_gwidth_used[iK - iKmin] > (d_omega = fabs(omegaout[iomega] - omega)))
105
-	    //DSF[iomega][iK - iKmin] += FF * FF * normalization_used[iK - iKmin] * exp(-d_omega*d_omega * oneovertwowidthsq[iK - iKmin]);
106 104
 	    for (int deltaiK = -DiK; deltaiK <= DiK; ++deltaiK)
107 105
 	      if (iK + deltaiK >= iKmin && iK + deltaiK <= iKmax)
108 106
 		DSFS[iomega][iK + deltaiK - iKmin] += Kweight[abs(deltaiK)] * FFsq * normalization_used[iK + deltaiK - iKmin]
@@ -112,19 +110,13 @@ namespace ABACUS {
112 110
     RAW_infile.close();
113 111
 
114 112
     // Reset proper normalization:
115
-    //DP normalization_used = normalization * 1.0/(sqrt(twoPI) * gwidth); // Gaussian factor
116 113
     for (int iK = 0; iK < iKmax - iKmin + 1; ++iK) {
117 114
       SSF[iK] *= normalization/twoPI;
118
-    //FSR[iK] *= normalization_used;
119
-    //for (int iomega = 0; iomega < Nom; ++iomega)
120
-    //DSF[iomega][iK] *= normalization_used;
121 115
     }
122 116
 
123 117
     // Output to .dsfs and .ssf files
124
-
125 118
     stringstream DSFS_stringstream;    string DSFS_string;
126 119
     DSFS_stringstream << prefix;
127
-    //if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
128 120
     if (DiK > 0) DSFS_stringstream << "_DiK_" << DiK;
129 121
     DSFS_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << width << ".dsfs";
130 122
     DSFS_string = DSFS_stringstream.str();    const char* DSFS_Cstr = DSFS_string.c_str();
@@ -143,7 +135,6 @@ namespace ABACUS {
143 135
 
144 136
     stringstream SSF_stringstream;    string SSF_string;
145 137
     SSF_stringstream << prefix;
146
-    //if (iKmin != iKmax) SSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
147 138
     SSF_stringstream << ".ssf";
148 139
     SSF_string = SSF_stringstream.str();    const char* SSF_Cstr = SSF_string.c_str();
149 140
 
@@ -159,13 +150,10 @@ namespace ABACUS {
159 150
 
160 151
     // Check sums:
161 152
     DP sumdsf = 0.0;
162
-    //DP sumssf = 0.0;
163 153
     for (int iK = 0; iK < iKmax - iKmin + 1; ++iK) {
164
-      //sumssf += FSR[iK];
165 154
       for (int iomega = 0; iomega < Nom; ++iomega)
166 155
 	sumdsf += DSFS[iomega][iK];
167 156
     }
168
-    //sumssf /= (iKmax - iKmin + 1);
169 157
     sumdsf /= (iKmax - iKmin + 1) * Nom;
170 158
 
171 159
     return(sumdsf);

+ 75
- 82
src/UTILS/Sort_RAW_File.cc View File

@@ -26,106 +26,99 @@ namespace ABACUS {
26 26
 
27 27
 
28 28
   void Sort_RAW_File (const char ff_file[], char optionchar, char whichDSF)
29
-    {
30
-      // Sorts FF in decreasing order for 'f' option, or energies in increasing order for option 'e', and writes .dat_srt file
29
+  {
30
+    // Sorts FF in decreasing order for 'f' option, or energies in increasing order for option 'e', and writes .dat_srt file
31
+
32
+    if (!(optionchar == 'e' || optionchar == 'f')) ABACUSerror("Wrong option in Sort_FF");
33
+
34
+    // Check size of threads file:
35
+    struct stat statbuf;
31 36
 
32
-      if (!(optionchar == 'e' || optionchar == 'f')) ABACUSerror("Wrong option in Sort_FF");
37
+    stat (ff_file, &statbuf);
38
+    int filesize = statbuf.st_size;
33 39
 
34
-      // Check size of threads file:
35
-      struct stat statbuf;
40
+    // Determine the number of entries approximately
41
+    int entry_size = 2* sizeof(float) + 2*sizeof(int);
36 42
 
37
-      stat (ff_file, &statbuf);
38
-      int filesize = statbuf.st_size;
43
+    //const int MAXDATA = 50000000;
44
+    const int MAXDATA = filesize/entry_size + 10;
39 45
 
40
-      // Determine the number of entries approximately
41
-      int entry_size = 2* sizeof(float) + 2*sizeof(int);
46
+    DP* omega = new DP[MAXDATA];
47
+    int* iK = new int[MAXDATA];
48
+    DP* ff = new DP[MAXDATA];
49
+    DP* ff_im = new DP[MAXDATA];
50
+    DP* dev = new DP[MAXDATA];
51
+    string* label = new string[MAXDATA];
42 52
 
43
-      //const int MAXDATA = 50000000;
44
-      const int MAXDATA = filesize/entry_size + 10;
53
+    ifstream infile;
54
+    infile.open(ff_file);
45 55
 
46
-      DP* omega = new DP[MAXDATA];
47
-      int* iK = new int[MAXDATA];
48
-      DP* ff = new DP[MAXDATA];
49
-      DP* ff_im = new DP[MAXDATA];
50
-      //int* conv = new int[MAXDATA];
51
-      DP* dev = new DP[MAXDATA];
52
-      string* label = new string[MAXDATA];
56
+    if (infile.fail()) ABACUSerror("The input file was not opened successfully in Sort_RAW_File. ");
53 57
 
54
-      ifstream infile;
55
-      infile.open(ff_file);
58
+    stringstream outfilename;
59
+    string outfilename_string;
60
+    outfilename << ff_file << "_srt_" << optionchar;
61
+    outfilename_string = outfilename.str();
62
+    const char* outfilename_c_str = outfilename_string.c_str();
56 63
 
57
-      if (infile.fail()) ABACUSerror("The input file was not opened successfully in Sort_RAW_File. ");
64
+    ofstream outfile;
65
+    outfile.open(outfilename_c_str);
66
+    outfile.precision(16);
58 67
 
59
-      stringstream outfilename;
60
-      string outfilename_string;
61
-      outfilename << ff_file << "_srt_" << optionchar;
62
-      outfilename_string = outfilename.str();
63
-      const char* outfilename_c_str = outfilename_string.c_str();
68
+    int Ndata = 0;
69
+    while (((infile.peek()) != EOF) && (Ndata < MAXDATA)) {
70
+
71
+      infile >> omega[Ndata];
72
+      infile >> iK[Ndata];
73
+      if (whichDSF != 'Z') infile >> ff[Ndata];
74
+      if (whichDSF == 'q') infile >> ff_im[Ndata];  // imaginary part of overlap, quench case
75
+      infile >> dev[Ndata];
76
+      infile >> label[Ndata];
77
+
78
+      Ndata++;
79
+    }
80
+    infile.close();
64 81
 
65
-      ofstream outfile;
66
-      outfile.open(outfilename_c_str);
67
-      outfile.precision(16);
82
+    int* index = new int[Ndata];
83
+    DP* ffsq = new DP[Ndata];
68 84
 
69
-      int Ndata = 0;
70
-      while (((infile.peek()) != EOF) && (Ndata < MAXDATA)) {
85
+    for (int i = 0; i < Ndata; ++i) index[i] = i;
86
+    for (int i = 0; i < Ndata; ++i) ffsq[i] = ff[i] * ff[i];
71 87
 
72
-      	infile >> omega[Ndata];
73
-	infile >> iK[Ndata];
74
-	if (whichDSF != 'Z') infile >> ff[Ndata];
75
-	if (whichDSF == 'q') infile >> ff_im[Ndata];  // imaginary part of overlap, quench case
76
-	//infile >> conv[Ndata];
77
-	infile >> dev[Ndata];
78
-	infile >> label[Ndata];
88
+    if (optionchar == 'f') QuickSort(ffsq, index, 0, Ndata - 1);
89
+    else if (optionchar == 'e') QuickSort(omega, index, 0, Ndata - 1);
79 90
 
80
-	Ndata++;
91
+    for (int i = 0; i < Ndata; i++) {
92
+
93
+      if (i > 0) outfile << endl;
94
+      if (optionchar == 'f') {
95
+
96
+	outfile << omega[index[Ndata - 1 - i] ] << "\t" << iK[index[Ndata - 1 - i] ];
97
+	if (whichDSF != 'Z') outfile << "\t" << ff[index[Ndata - 1 - i] ];
98
+	if (whichDSF == 'q') outfile << "\t" << ff_im[index[Ndata - 1 - i] ];
99
+	outfile << "\t" << dev[index[Ndata - 1 - i] ] << "\t" << label[index[Ndata - 1 - i] ];
81 100
       }
82
-      infile.close();
83
-
84
-      int* index = new int[Ndata];
85
-      DP* ffsq = new DP[Ndata];
86
-
87
-      for (int i = 0; i < Ndata; ++i) index[i] = i;
88
-      for (int i = 0; i < Ndata; ++i) ffsq[i] = ff[i] * ff[i];
89
-
90
-      if (optionchar == 'f') QuickSort(ffsq, index, 0, Ndata - 1);
91
-      else if (optionchar == 'e') QuickSort(omega, index, 0, Ndata - 1);
92
-
93
-      for (int i = 0; i < Ndata; i++) {
94
-
95
-	if (i > 0) outfile << endl;
96
-	if (optionchar == 'f') {
97
-
98
-	  outfile << omega[index[Ndata - 1 - i] ] << "\t" << iK[index[Ndata - 1 - i] ];
99
-	  if (whichDSF != 'Z') outfile << "\t" << ff[index[Ndata - 1 - i] ];
100
-	  if (whichDSF == 'q') outfile << "\t" << ff_im[index[Ndata - 1 - i] ];
101
-	  outfile << "\t" //<< conv[index[Ndata - 1 - i] ] << "\t"
102
-		  << dev[index[Ndata - 1 - i] ] << "\t"
103
-		  << label[index[Ndata - 1 - i] ];
104
-	}
105
-	else if (optionchar == 'e') {
106
-	  outfile << omega[i] << "\t" << iK[index[i] ];
107
-	  if (whichDSF != 'Z') outfile << "\t" << ff[index[i] ];
108
-	  if (whichDSF == 'q') outfile << "\t" << ff_im[index[i] ];
109
-	  outfile << "\t" //<< conv[index[i] ] << "\t"
110
-		  << dev[index[i] ] << "\t"
111
-		  << label[index[i] ];
112
-	}
101
+      else if (optionchar == 'e') {
102
+	outfile << omega[i] << "\t" << iK[index[i] ];
103
+	if (whichDSF != 'Z') outfile << "\t" << ff[index[i] ];
104
+	if (whichDSF == 'q') outfile << "\t" << ff_im[index[i] ];
105
+	outfile << "\t" << dev[index[i] ] << "\t" << label[index[i] ];
113 106
       }
107
+    }
114 108
 
115
-      outfile.close();
109
+    outfile.close();
116 110
 
117
-      delete[] omega;
118
-      delete[] iK;
119
-      delete[] ff;
120
-      delete[] ff_im;
121
-      //delete[] conv;
122
-      delete[] dev;
123
-      delete[] label;
111
+    delete[] omega;
112
+    delete[] iK;
113
+    delete[] ff;
114
+    delete[] ff_im;
115
+    delete[] dev;
116
+    delete[] label;
124 117
 
125
-      delete[] index;
126
-      delete[] ffsq;
118
+    delete[] index;
119
+    delete[] ffsq;
127 120
 
128
-      return;
129
-    }
121
+    return;
122
+  }
130 123
 
131 124
 } // namespace ABACUS

+ 36
- 144
src/UTILS/State_Label.cc View File

@@ -50,9 +50,7 @@ namespace ABACUS {
50 50
   {
51 51
     string::size_type i1 = label.find(LABELSEP);
52 52
 
53
-    //cout << "Extracting Base_Label from label " << label << endl;
54 53
     string baselabel = label.substr(0, i1);
55
-    //cout << "Extracted Base_Label " << baselabel << endl;
56 54
 
57 55
     return(baselabel);
58 56
   }
@@ -76,7 +74,6 @@ namespace ABACUS {
76 74
     int remainder = int_to_convert;
77 75
     stringstream result_strstrm;
78 76
     do {
79
-      //cout << "remainder = " << remainder << "\tnext index = " << remainder - ABACUScodingsize * (remainder/ABACUScodingsize) << endl;
80 77
       result_strstrm << ABACUScoding[remainder - ABACUScodingsize * (remainder/ABACUScodingsize)];
81 78
       remainder /= ABACUScodingsize;
82 79
     } while (remainder > 0);
@@ -120,22 +117,13 @@ namespace ABACUS {
120 117
     string nexclabel = label.substr(i1+1, i2-i1-1);
121 118
     string Ix2exclabel = label.substr(i2+1);
122 119
 
123
-    //cout << "label: " << label << endl;
124
-    //cout << "baselabel: " << baselabel << endl;
125
-    //cout << "nexclabel: " << nexclabel << endl;
126
-    //cout << "Ix2exclabel: " << Ix2exclabel << endl;
127
-
128 120
     // Read off the base label: count the number of TYPESEP in baselabel
129 121
     int nbar = 0;
130 122
     for (unsigned int i = 0; i < baselabel.length(); ++i) if (baselabel[i] == TYPESEP) nbar++;
131 123
 
132
-    //cout << "nbar = " << nbar << endl;
133
-
134 124
     // There are now nbar + 1 base label data:
135 125
     int ntypes = nbar + 1;
136 126
 
137
-    //cout << "ntypes = " << ntypes << endl;
138
-
139 127
     Vect<int> type(ntypes); // integer type labels of the types present
140 128
     type[0] = 0; // always the case by convention
141 129
     Vect<int> M(ntypes); // how many particles of each type
@@ -183,8 +171,6 @@ namespace ABACUS {
183 171
 
184 172
     } // else if ntypes > 1
185 173
 
186
-    //cout << "ntypes = " << ntypes << "\tM = " << M << endl;
187
-
188 174
     // baselabel is now completely read
189 175
 
190 176
     // Define some dud nex, Ix2old, Ix2exc:
@@ -213,22 +199,14 @@ namespace ABACUS {
213 199
     string nexclabel = label.substr(i1+1, i2-i1-1);
214 200
     string Ix2exclabel = label.substr(i2+1);
215 201
 
216
-    //cout << "label: " << label << endl;
217
-    //cout << "baselabel: " << baselabel << endl;
218
-    //cout << "nexclabel: " << nexclabel << endl;
219
-    //cout << "Ix2exclabel: " << Ix2exclabel << endl;
220 202
 
221 203
     // Read off the base label: count the number of TYPESEP in baselabel
222 204
     int nbar = 0;
223 205
     for (unsigned int i = 0; i < baselabel.length(); ++i) if (baselabel[i] == TYPESEP) nbar++;
224 206
 
225
-    //cout << "nbar = " << nbar << endl;
226
-
227 207
     // There are now nbar + 1 base label data:
228 208
     int ntypes = nbar + 1;
229 209
 
230
-    //cout << "ntypes = " << ntypes << endl;
231
-
232 210
     Vect<int> type(ntypes); // integer type labels of the types present
233 211
     type[0] = 0; // always the case by convention
234 212
     Vect<int> M(ntypes); // how many particles of each type
@@ -317,10 +295,6 @@ namespace ABACUS {
317 295
 
318 296
     // nexc is now completely read
319 297
 
320
-    //cout << "typefound: " << type << endl;
321
-    //cout << "Mfound: " << M << endl;
322
-    //cout << "nexcfound: " << nexc << endl;
323
-
324 298
 
325 299
     // Now read off the (compressed) jexc and Ix2exc vectors of vectors:
326 300
     Vect<Vect<int> > Ix2old(ntypes); // which Ix2 will be excited
@@ -340,22 +314,17 @@ namespace ABACUS {
340 314
       }
341 315
       for (int iexc = 0; iexc < nexc[itype]; ++iexc) {
342 316
 	//string::size_type i1 = Ix2exclabelremaining.find(INEXCSEP);
343
-	string::size_type i2 = (iexc < nexc[itype] - 1 ? Ix2exclabelremaining.find(EXCSEP) : Ix2exclabelremaining.find(TYPESEP)); // careful here!
344
-	//cout << "\t" << itype << "\t" << iexc << "\t" << Ix2exclabelremaining << "\t" << i1 << "\t" << i2 << endl;
345
-	//string Ix2oldread = Ix2exclabelremaining.substr(0,i1);
346
-	//string Ix2excread = Ix2exclabelremaining.substr(i1+1,i2-i1-1);
317
+	string::size_type i2 = (iexc < nexc[itype] - 1 ? Ix2exclabelremaining.find(EXCSEP)
318
+				: Ix2exclabelremaining.find(TYPESEP)); // careful here!
347 319
 	string Ix2excIDread = Ix2exclabelremaining.substr(0,i2);
348 320
 	int Ix2excID = Convert_STR_to_POSINT(Ix2excIDread);
349
-	Ix2old[itype][iexc] = OriginIx2[type[itype] ][Ix2excID - M[itype] * (Ix2excID/M[itype])]; // index is remainder w/r to nr of strings of this type
321
+	Ix2old[itype][iexc] = OriginIx2[type[itype] ][Ix2excID - M[itype] * (Ix2excID/M[itype])];
322
+	// index is remainder w/r to nr of strings of this type
350 323
 	// Convention: if remainder is even, moving left. If odd, moving right.
351 324
 	// 0 means move one unit left, 1 means move one unit right, etc.
352
-	//Ix2exc[itype][iexc] = Ix2old[itype][iexc] + (Ix2excID/M[itype] % 2 ? 2 : -2) * (Ix2excID/(2 * M[itype]) + 0);
353
-	Ix2exc[itype][iexc] = Ix2old[itype][iexc] + (Ix2excID/M[itype] % 2 ? 2 : -2) * (Ix2excID/(2 * M[itype]) + 1); // ABACUS++T_8 onwards
325
+	Ix2exc[itype][iexc] = Ix2old[itype][iexc] + (Ix2excID/M[itype] % 2 ? 2 : -2)
326
+	  * (Ix2excID/(2 * M[itype]) + 1); // ABACUS++T_8 onwards
354 327
 
355
-	//istringstream Ix2oldreadbuffer (Ix2oldread);
356
-	//Ix2oldreadbuffer >> Ix2old[itype][iexc];
357
-	//istringstream Ix2excreadbuffer (Ix2excread);
358
-	//Ix2excreadbuffer >> Ix2exc[itype][iexc];
359 328
 	// Remove everything up to index i2 in Ix2exclabelremaining
360 329
 	Ix2exclabelremaining = Ix2exclabelremaining.substr(i2+1);
361 330
       }
@@ -363,47 +332,27 @@ namespace ABACUS {
363 332
 
364 333
     // Now read off the Ix2old, Ix2exc of the last type: this is always done
365 334
     for (int iexc = 0; iexc < nexc[ntypes - 1] - 1; ++iexc) {
366
-      //string::size_type i1 = Ix2exclabelremaining.find(INEXCSEP);
367 335
       string::size_type i2 = Ix2exclabelremaining.find(EXCSEP);
368
-      //string Ix2oldread = Ix2exclabelremaining.substr(0,i1);
369
-      //string Ix2excread = Ix2exclabelremaining.substr(i1+1,i2-i1-1);
370 336
       string Ix2excIDread = Ix2exclabelremaining.substr(0,i2);
371 337
       int Ix2excID = Convert_STR_to_POSINT(Ix2excIDread);
372
-      Ix2old[ntypes - 1][iexc] = OriginIx2[type[ntypes - 1] ][Ix2excID - M[ntypes - 1] * (Ix2excID/M[ntypes - 1])]; // index is remainder w/r to nr of strings of this type
338
+      Ix2old[ntypes - 1][iexc] = OriginIx2[type[ntypes - 1] ][Ix2excID - M[ntypes - 1] * (Ix2excID/M[ntypes - 1])];
339
+      // index is remainder w/r to nr of strings of this type
373 340
       // Convention: if remainder is even, moving left. If odd, moving right.
374
-      //Ix2exc[ntypes - 1][iexc] = Ix2old[ntypes - 1][iexc] + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2) * (Ix2excID/(2 * M[ntypes - 1]) + 0);
375
-      Ix2exc[ntypes - 1][iexc] = Ix2old[ntypes - 1][iexc] + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2) * (Ix2excID/(2 * M[ntypes - 1]) + 1); // ABACUS++T_8 onwards
341
+      Ix2exc[ntypes - 1][iexc] = Ix2old[ntypes - 1][iexc] + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2)
342
+	* (Ix2excID/(2 * M[ntypes - 1]) + 1); // ABACUS++T_8 onwards
376 343
 
377
-      //istringstream Ix2oldreadbuffer (Ix2oldread);
378
-      //Ix2oldreadbuffer >> Ix2old[ntypes - 1][iexc];
379
-      //istringstream Ix2excreadbuffer (Ix2excread);
380
-      //Ix2excreadbuffer >> Ix2exc[ntypes - 1][iexc];
381 344
       // Remove everything up to index i2 in Ix2exclabelremaining
382 345
       Ix2exclabelremaining = Ix2exclabelremaining.substr(i2+1);
383 346
     }
384 347
 
385 348
     // Now read off the last pair:
386 349
     int Ix2excID = Convert_STR_to_POSINT(Ix2exclabelremaining);
387
-    Ix2old[ntypes - 1][ABACUS::max(nexc[ntypes - 1] - 1,0)] = OriginIx2[type[ntypes - 1] ][Ix2excID - M[ntypes - 1] * (Ix2excID/M[ntypes - 1])]; // index is remainder w/r to nr of strings of this type
350
+    Ix2old[ntypes - 1][ABACUS::max(nexc[ntypes - 1] - 1,0)] =
351
+      OriginIx2[type[ntypes - 1] ][Ix2excID - M[ntypes - 1] * (Ix2excID/M[ntypes - 1])];
352
+    // index is remainder w/r to nr of strings of this type
388 353
     // Convention: if remainder is even, moving left. If odd, moving right.
389
-    //Ix2exc[ntypes - 1][ABACUS::max(nexc[ntypes - 1] - 1,0)] = Ix2old[ntypes - 1][nexc[ntypes - 1] - 1] + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2) * (Ix2excID/(2 * M[ntypes - 1]) + 0);
390
-    Ix2exc[ntypes - 1][ABACUS::max(nexc[ntypes - 1] - 1,0)] = Ix2old[ntypes - 1][nexc[ntypes - 1] - 1] + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2) * (Ix2excID/(2 * M[ntypes - 1]) + 1); // ABACUS++T_8 onwards
391
-
392
-    //string::size_type ilast = Ix2exclabelremaining.find(INEXCSEP);
393
-    //string Ix2oldread = Ix2exclabelremaining.substr(0,ilast);
394
-    //string Ix2excread = Ix2exclabelremaining.substr(ilast+1);
395
-    //istringstream Ix2oldreadbuffer (Ix2oldread);
396
-    //Ix2oldreadbuffer >> Ix2old[ntypes - 1][nexc[ntypes - 1] - 1];
397
-    //istringstream Ix2excreadbuffer (Ix2excread);
398
-    //Ix2excreadbuffer >> Ix2exc[ntypes - 1][nexc[ntypes - 1] - 1];
399
-
400
-    //cout << "nexc = " << endl;
401
-    //cout << nexc << endl;
402
-    //cout << "Ix2old and Ix2exc: " << endl;
403
-    //for (int itype = 0; itype < ntypes; ++itype) {
404
-    //cout << "Ix2old["<< itype << "]: " << Ix2old[itype] << endl;
405
-    //cout << "Ix2exc["<< itype << "]: " << Ix2exc[itype] << endl;
406
-    //}
354
+    Ix2exc[ntypes - 1][ABACUS::max(nexc[ntypes - 1] - 1,0)] = Ix2old[ntypes - 1][nexc[ntypes - 1] - 1]
355
+      + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2) * (Ix2excID/(2 * M[ntypes - 1]) + 1); // ABACUS++T_8 onwards
407 356
 
408 357
     State_Label_Data labeldata (type, M, nexc, Ix2old, Ix2exc);
409 358
 
@@ -421,43 +370,28 @@ namespace ABACUS {
421 370
   {
422 371
     // This function produces a compressed label.
423 372
 
424
-    //cout << "Label A" << endl;
425
-
426
-    //cout << "\t" << data.M.size() << endl;
427
-    //cout << "\t" << data.M[0] << endl;
428
-
429 373
     string label;
430 374
 
431 375
     // Write the base:
432 376
     // First, particles of type 0:
433
-    //cout << "Label A2" << endl;
434 377
     stringstream M0out;
435
-    //cout << "Label A3" << endl;
436
-    //cout << "\t" << data.M[0] << endl;
437 378
     M0out << data.M[0];
438
-    //cout << "Label A4" << endl;
439 379
     label += M0out.str();
440
-    //cout << "Label A5" << endl;
441 380
 
442 381
     for (int itype = 1; itype < data.M.size(); ++itype) {
443
-      //cout << "\ta" << itype << "\t" << data.M.size() << endl;
444 382
       if (data.M[itype] > 0) {
445 383
 	label += TYPESEP;
446 384
 	stringstream typeout;
447 385
 	typeout << data.type[itype];
448 386
 	label += typeout.str();
449 387
 	label += EXCSEP;
450
-	//cout << "\tc" << endl;
451 388
 	stringstream Mout;
452 389
 	Mout << data.M[itype];
453 390
 	label += Mout.str();
454
-	//cout << "\td" << endl;
455 391
       }
456 392
     }
457 393
     label += LABELSEP;
458 394
 
459
-    //cout << "Label B" << endl;
460
-
461 395
     // Now the nexc:
462 396
     stringstream nexc0out;
463 397
     nexc0out << data.nexc[0];
@@ -470,8 +404,6 @@ namespace ABACUS {
470 404
     }
471 405
     label += LABELSEP;
472 406
 
473
-    //cout << "Label C" << endl;
474
-
475 407
     // Now the displacements:
476 408
     // The conventions are as follows.
477 409
     // For each excitation, an integer number ID is given according to the following rules:
@@ -489,15 +421,15 @@ namespace ABACUS {
489 421
 	int holeindex = -1;
490 422
 	do {
491 423
 	  holeindex++;
492
-	} while (OriginIx2[data.type[itype] ][holeindex] != data.Ix2old[itype][iexc] && holeindex < OriginIx2[data.type[itype] ].size() - 1);
493
-	if (holeindex == OriginIx2[data.type[itype] ].size()) ABACUSerror("Going out of bounds in Compress_Label.");
424
+	} while (OriginIx2[data.type[itype] ][holeindex] != data.Ix2old[itype][iexc]
425
+		 && holeindex < OriginIx2[data.type[itype] ].size() - 1);
426
+	if (holeindex == OriginIx2[data.type[itype] ].size())
427
+	  ABACUSerror("Going out of bounds in Compress_Label.");
494 428
 	excID = excID * data.M[itype] + holeindex;
495 429
 	label += Convert_POSINT_to_STR(excID);
496 430
       } // for iexc
497 431
     } // for itype
498 432
 
499
-    //cout << "Label D" << endl;
500
-
501 433
     return(label);
502 434
   }
503 435
 
@@ -512,13 +444,17 @@ namespace ABACUS {
512 444
   {
513 445
     // This function does not assume any ordering of the Ix2.
514 446
 
515
-    if (ScanIx2.size() != OriginIx2.size()) ABACUSerror("ScanIx2.size() != OriginIx2.size() in Find_Label.");
516
-    for (int i = 0; i < ScanIx2.size(); ++i) if (ScanIx2[i].size() != OriginIx2[i].size()) ABACUSerror("ScanIx2[i].size() != OriginIx2[i].size() in Find_Label.");
447
+    if (ScanIx2.size() != OriginIx2.size())
448
+      ABACUSerror("ScanIx2.size() != OriginIx2.size() in Find_Label.");
449
+    for (int i = 0; i < ScanIx2.size(); ++i)
450
+      if (ScanIx2[i].size() != OriginIx2[i].size())
451
+	ABACUSerror("ScanIx2[i].size() != OriginIx2[i].size() in Find_Label.");
517 452
 
518 453
     // Set the state ulabel:
519 454
     // Count the number of types present:
520 455
     int ntypespresent = 0;
521
-    for (int is = 0; is < ScanIx2.size(); ++is) if (is == 0 || ScanIx2[is].size() > 0) ntypespresent++; // type 0 is by default always present
456
+    for (int is = 0; is < ScanIx2.size(); ++is)
457
+      if (is == 0 || ScanIx2[is].size() > 0) ntypespresent++; // type 0 is by default always present
522 458
 
523 459
     Vect<int> type_ref(ntypespresent);
524 460
     Vect<int> M_ref(ntypespresent);
@@ -541,10 +477,15 @@ namespace ABACUS {
541 477
     for (int it = 0; it < ntypespresent; ++it) Ix2exc_ref[it] = Vect<int>(ABACUS::max(nexc_ref[it],1));
542 478
     for (int it = 0; it < ntypespresent; ++it) {
543 479
       int nexccheck = 0;
544
-      for (int i = 0; i < M_ref[it]; ++i) if (!OriginIx2[type_ref[it] ].includes(ScanIx2[type_ref[it] ][i])) Ix2exc_ref[it][nexccheck++] = ScanIx2[type_ref[it] ][i];
545
-      if (nexccheck != nexc_ref[it]) ABACUSerror("Counting excitations wrong (1) in Return_State_Label");
480
+      for (int i = 0; i < M_ref[it]; ++i)
481
+	if (!OriginIx2[type_ref[it] ].includes(ScanIx2[type_ref[it] ][i]))
482
+	  Ix2exc_ref[it][nexccheck++] = ScanIx2[type_ref[it] ][i];
483
+      if (nexccheck != nexc_ref[it])
484
+	ABACUSerror("Counting excitations wrong (1) in Return_State_Label");
546 485
       nexccheck = 0;
547
-      for (int i = 0; i < M_ref[it]; ++i) if (!ScanIx2[type_ref[it] ].includes(OriginIx2[type_ref[it] ][i])) Ix2old_ref[it][nexccheck++] = OriginIx2[type_ref[it] ][i];
486
+      for (int i = 0; i < M_ref[it]; ++i)
487
+	if (!ScanIx2[type_ref[it] ].includes(OriginIx2[type_ref[it] ][i]))
488
+	  Ix2old_ref[it][nexccheck++] = OriginIx2[type_ref[it] ][i];
548 489
       if (nexccheck != nexc_ref[it]) {
549 490
 	cout << OriginIx2 << endl;
550 491
 	cout << ScanIx2 << endl;
@@ -572,19 +513,16 @@ namespace ABACUS {
572 513
   }
573 514
 
574 515
 
575
-  //bool Set_to_Label (string label_ref, Vect<Vect<int> >& Ix2, const Vect<Vect<int> >& OriginIx2)
516
+
576 517
   Vect<Vect<int> > Return_Ix2_from_Label (string label_ref, const Vect<Vect<int> >& OriginIx2)
577 518
   {
578 519
     // ASSUMPTIONS:
579 520
     // OriginIx2 is ordered.
580 521
 
581
-    //Ix2 = OriginIx2; // this will fail if the sizes are incompatible
582 522
     Vect<Vect<int> > Ix2 = OriginIx2; // this will fail if the sizes are incompatible
583 523
 
584 524
     State_Label_Data labeldata = Read_State_Label (label_ref, OriginIx2);
585 525
 
586
-    //cout << "Read label OK" << endl;
587
-
588 526
     // Now set the excitations:
589 527
     for (int it = 0; it < labeldata.type.size(); ++it)
590 528
       for (int iexc = 0; iexc < labeldata.nexc[it]; ++iexc)
@@ -596,12 +534,9 @@ namespace ABACUS {
596 534
     // Now reorder the Ix2 to follow convention:
597 535
     for (int il = 0; il < Ix2.size(); ++il) Ix2[il].QuickSort();
598 536
 
599
-    //cout << "Ix2 found = " << Ix2 << endl;
600
-
601 537
     return(Ix2);
602
-    //return(true);
603 538
   }
604
-  // Specialization to Lieb-Liniger:
539
+
605 540
   Vect<int> Return_Ix2_from_Label (string label_ref, const Vect<int>& OriginIx2)
606 541
   {
607 542
     Vect<Vect<int> > OriginIx2here(1);
@@ -611,47 +546,4 @@ namespace ABACUS {
611 546
   }
612 547
 
613 548
 
614
-  /* DEPRECATED ++G_5
615
-  // Conversion from one to the other:
616
-  string Compress_Ulabel (string ulabel_ref, const Vect<Vect<int> >& OriginIx2)
617
-  {
618
-    // From a normal label, return a compressed one.
619
-    State_Label_Data data = Read_State_Ulabel (ulabel_ref);
620
-
621
-    return(Return_State_Label(data, OriginIx2));
622
-  }
623
-
624
-  string Compress_Ulabel (string ulabel_ref, const Vect<int>& OriginIx2)
625
-  // if there is only one type
626
-  {
627
-    // From a normal label, return a compressed one.
628
-    Vect<Vect<int> > OriginIx2here(1);
629
-    OriginIx2here[0] = OriginIx2;
630
-
631
-    State_Label_Data data = Read_State_Ulabel (ulabel_ref);
632
-
633
-    return(Return_State_Label(data, OriginIx2here));
634
-  }
635
-
636
-  string Uncompress_Label (string label_ref, const Vect<Vect<int> >& OriginIx2)
637
-  {
638
-    // From a compressed label, return a normal one.
639
-    State_Label_Data data = Read_State_Label (label_ref, OriginIx2);
640
-
641
-    return(Return_State_Ulabel(data));
642
-  }
643
-
644
-  string Uncompress_Label (string label_ref, const Vect<int>& OriginIx2)
645
-  // if there is only one type
646
-  {
647
-    // From a compressed label, return a normal one.
648
-    Vect<Vect<int> > OriginIx2here(1);
649
-    OriginIx2here[0] = OriginIx2;
650
-
651
-    State_Label_Data data = Read_State_Label (label_ref, OriginIx2here);
652
-
653
-    return(Return_State_Ulabel(data));
654
-  }
655
-  */
656
-
657 549
 } // namespace ABACUS

+ 0
- 103
src/XXX_VOA/SF_4p_client.cc View File

@@ -41,9 +41,6 @@ namespace ABACUS {
41 41
     MPI_Comm_rank (comm, &rank);
42 42
 
43 43
     MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
44
-    //cout << "Client of rank " << rank << ":  received request ";
45
-    //for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
46
-    //cout << "with tag " << status.MPI_TAG << endl;
47 44
 
48 45
 
49 46
     while (status.MPI_TAG) {
@@ -59,112 +56,12 @@ namespace ABACUS {
59 56
       client_result[7] = SF_4p_opt (client_request[2], client_request[3], client_request[4],
60 57
 				    int(client_request[5]), int(client_request[6]), Itable);
61 58
       MPI_Send (client_result, client_result_size, MPI_DOUBLE, server, status.MPI_TAG, comm);
62
-      //cout << "Client of rank " << rank << " sending complete" << endl;
63 59
 
64 60
       // Wait for subsequent request from server
65 61
       MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
66
-      //cout << "Client of rank " << rank << ":  received request ";
67
-      //for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
68
-      //cout << "with tag " << status.MPI_TAG << endl;
69
-
70
-    }
71
-
72
-    return;
73
-  }
74
-  /*
75
-  void SF_4p_kwKW_alpha_client (MPI_Comm comm, DP req_prec, int max_rec, I_table Itable)
76
-  {
77
-    int server = 0;
78
-    int rank;
79
-
80
-    MPI_Status status;
81
-
82
-    int client_request_size = 2;
83
-    DP client_request[client_request_size]; // this is k, alpha
84
-    int client_result_size = 3;
85
-    DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha
86
-
87
-    MPI_Comm_rank (comm, &rank);
88
-
89
-    MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
90
-    //cout << "Client of rank " << rank << ":  received request ";
91
-    //for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
92
-    //cout << "with tag " << status.MPI_TAG << endl;
93
-
94
-    Vect_DP args_to_SF_4p_kwKW_alpha(4);
95
-    args_to_SF_4p_kwKW_alpha[2] = req_prec;
96
-    args_to_SF_4p_kwKW_alpha[3] = DP(max_rec);
97
-
98
-    while (status.MPI_TAG) {
99
-
100
-      args_to_SF_4p_kwKW_alpha[0] = client_request[0];
101
-      args_to_SF_4p_kwKW_alpha[1] = client_request[1];
102
-
103
-      // Result:  SF_4p (k, omega)
104
-      client_result[0] = client_request[0];
105
-      client_result[1] = client_request[1];
106
-      client_result[2] = SF_4p_kwKW_alpha (args_to_SF_4p_kwKW_alpha, Itable);
107
-
108
-      MPI_Send (client_result, client_result_size, MPI_DOUBLE, server, status.MPI_TAG, comm);
109
-      //cout << "Client of rank " << rank << " sending complete" << endl;
110
-
111
-      // Wait for subsequent request from server
112
-      MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
113
-      //cout << "Client of rank " << rank << ":  received request ";
114
-      //for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
115
-      //cout << "with tag " << status.MPI_TAG << endl;
116
-
117 62
     }
118 63
 
119 64
     return;
120 65
   }
121 66
 
122
-  void SF_4p_kwKW_alpha_opt_client (MPI_Comm comm, DP req_prec, int Npts_K, int Npts_W, I_table Itable)
123
-  {
124
-    int server = 0;
125
-    int rank;
126
-
127
-    MPI_Status status;
128
-
129
-    int client_request_size = 2;
130
-    DP client_request[client_request_size]; // this is k, alpha
131
-    int client_result_size = 3;
132
-    DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha_opt
133
-
134
-    MPI_Comm_rank (comm, &rank);
135
-
136
-    MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
137
-    //cout << "Client of rank " << rank << ":  received request ";
138
-    //for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
139
-    //cout << "with tag " << status.MPI_TAG << endl;
140
-
141
-    Vect_DP args_to_SF_4p_kwKW_alpha_opt(5);
142
-    args_to_SF_4p_kwKW_alpha_opt[2] = req_prec;
143
-    args_to_SF_4p_kwKW_alpha_opt[3] = DP(Npts_K);
144
-    args_to_SF_4p_kwKW_alpha_opt[4] = DP(Npts_W);
145
-
146
-    while (status.MPI_TAG) {
147
-
148
-      args_to_SF_4p_kwKW_alpha_opt[0] = client_request[0];
149
-      args_to_SF_4p_kwKW_alpha_opt[1] = client_request[1];
150
-
151
-      // Result:  SF_4p (k, omega)
152
-      client_result[0] = client_request[0];
153
-      client_result[1] = client_request[1];
154
-      client_result[2] = SF_4p_kwKW_alpha_opt (args_to_SF_4p_kwKW_alpha_opt, Itable);
155
-
156
-      MPI_Send (client_result, client_result_size, MPI_DOUBLE, server, status.MPI_TAG, comm);
157
-      //cout << "Client of rank " << rank << " sending complete" << endl;
158
-
159
-      // Wait for subsequent request from server
160
-      MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
161
-      //cout << "Client of rank " << rank << ":  received request ";
162
-      //for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
163
-      //cout << "with tag " << status.MPI_TAG << endl;
164
-
165
-    }
166
-
167
-    return;
168
-  }
169
-  */
170 67
 } // namespace ABACUS

+ 1
- 397
src/XXX_VOA/SF_4p_server.cc View File

@@ -57,7 +57,6 @@ namespace ABACUS {
57 57
 	for (int ik = 0; ik < dim_k; ++ik) {
58 58
 	  SF_outfile >> SF_4p[dim_k * iomega + ik];
59 59
 	  if (SF_4p[dim_k * iomega + ik] == 0.0) total_nr_req++;
60
-	  //cout << ik << "\t" << iomega << "\t" << SF_4p[dim_k * iomega + ik] << "\t" << (SF_4p[dim_k * iomega + ik] == 0.0) << "\t" << total_nr_req << endl;
61 60
 
62 61
 	  // We only load the LHS of the BZ, so we load N/2 empty values...
63 62
 	}
@@ -87,11 +86,6 @@ namespace ABACUS {
87 86
       cout << total_nr_req << "\t" << index << endl;
88 87
       ABACUSerror("Not counting total_nr_req correctly in SF_4p_opt_server");
89 88
     }
90
-    //ofstream SFsrc_outfile;
91
-    //SFsrc_outfile.open(SFsrc_Cstr);
92
-
93
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
94
-    //DP omegamax_used = 0.5 * wmax_4p (k);
95 89
 
96 90
     int nr_machines;
97 91
     MPI_Comm_size (comm, &nr_machines);
@@ -129,22 +123,16 @@ namespace ABACUS {
129 123
       client_request[6] = DP(Npts_W);
130 124
 
131 125
       MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
132
-      //cout << "Server:  sent request ";
133
-      //for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
134
-      //cout << "with tag " << scanning << " to client " << i << endl;
135 126
       nr_sent_out++;
136
-      //cout << "nr_sent_out = " << nr_sent_out << endl;
137 127
     }
138 128
 
139 129
     DP Actual_Time_MPI = MPI_Wtime();
140 130
 
141
-    //while (nr_returned < total_nr_req) {
142 131
     while (nr_returned < nr_sent_out) {
143 132
 
144
-      //cout << "Server:  waiting for answers... " << endl;
145 133
       MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
146 134
       nr_returned++;
147
-      //cout << "Server:  received answer from client " << status.MPI_SOURCE << endl;
135
+
148 136
       // unbuffer result
149 137
       SF_4p[dim_k * int(client_result[1]) + int(client_result[0])] = client_result[7];
150 138
 
@@ -158,15 +146,10 @@ namespace ABACUS {
158 146
 	client_request[3] = (needed_iomega[nr_sent_out] + 0.5) * omegamax/Nomega;
159 147
 	MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
160 148
 	nr_sent_out++;
161
-	//cout << "nr_sent_out = " << nr_sent_out << endl;
162 149
       }
163 150
 
164 151
     } // while (nr_returned < total_nr_req)
165 152
 
166
-    cout << endl << "Computed " << nr_returned << " points ouf of " << total_nr_req << " required. " << endl;
167
-
168
-    cout << endl << "Server saving file..." << endl;
169
-
170 153
     // Output all data:  double up to full [0, 2pi] interval in k with symmetry
171 154
     SF_outfile.seekp(0);
172 155
     for (int iomega = 0; iomega < Nomega; ++iomega) {
@@ -187,384 +170,5 @@ namespace ABACUS {
187 170
     return;
188 171
   }
189 172
 
190
-  /****************************************************
191
-
192
-  // TO COMPLETE FOR 5.5 (commented out in 5.7)
193
-
194
-  *********************************************************/
195
-  /*
196
-  void SF_4p_opt_server (MPI_Comm comm, DP k_needed, DP omegamax, int Nomega, DP req_prec, int Npts_K, int Npts_W, I_table Itable,
197
-			 int Max_Secs, bool refine)
198
-  {
199
-    double Start_Time_MPI = MPI_Wtime();
200
-
201
-    Heis_Write_w_File (Nomega, omegamax);
202
-
203
-    stringstream SF_stringstream;
204
-    string SF_string;
205
-    SF_stringstream << "SF_4p_k_" << k_needed << "_No_" << Nomega << "_omax_" << omegamax
206
-		    << "_prec_" << req_prec << "_Npts_K_" << Npts_K << "_Npts_W_" << Npts_W << ".dat";
207
-    SF_string = SF_stringstream.str();
208
-    const char* SF_Cstr = SF_string.c_str();
209
-
210
-    fstream SF_outfile;
211
-    if (!refine) SF_outfile.open(SF_Cstr, fstream::out | fstream::trunc);
212
-    else SF_outfile.open(SF_Cstr, fstream::in | fstream::out);
213
-    if (SF_outfile.fail()) ABACUSerror("Could not open SF_outfile... ");
214
-
215
-    SF_outfile.precision(12);
216
-
217
-    int dim_k = 1;
218
-
219
-    DP* SF_4p = new DP[dim_k * Nomega];
220
-
221
-    // Initialize to zero to be sure:
222
-    for (int i = 0; i < Nomega * dim_k; ++i) SF_4p[i] = 0.0;
223
-
224
-    // If refining, load SF from existing file
225
-
226
-    int total_nr_req = 0;
227
-    DP buff;
228
-    if (refine) {
229
-      for (int iomega = 0; iomega < Nomega; ++iomega) {
230
-	for (int ik = 0; ik < dim_k; ++ik) {
231
-	  SF_outfile >> SF_4p[dim_k * iomega + ik];
232
-	  if (SF_4p[dim_k * iomega + ik] == 0.0) total_nr_req++;
233
-	  //cout << ik << "\t" << iomega << "\t" << SF_4p[dim_k * iomega + ik] << "\t" << (SF_4p[dim_k * iomega + ik] == 0.0) << "\t" << total_nr_req << endl;
234
-
235
-	  // We only load the LHS of the BZ, so we load N/2 empty values...
236
-	}
237
-	for (int ibuff = 0; ibuff < N/2; ++ibuff) SF_outfile >> buff;
238
-      }
239
-    }
240
-    else if (!refine) total_nr_req = dim_k * Nomega;
241
-
242
-    // List iomega and ik which need to be computed:
243
-
244
-    int* needed_ik = new int[total_nr_req];
245
-    int* needed_iomega = new int[total_nr_req];
246
-
247
-    int index = 0;
248
-    for (int iomega = 0; iomega < Nomega; ++iomega)
249
-      for (int ik = 0; ik < dim_k; ++ik) {
250
-	if (SF_4p[dim_k * iomega + ik] == 0) {
251
-	  needed_ik[index] = ik;
252
-	  needed_iomega[index] = iomega;
253
-	  index++;
254
-	}
255
-      }
256
-
257
-    cout << total_nr_req << " points required." << endl;
258
-
259
-    if (index != total_nr_req) {
260
-      cout << total_nr_req << "\t" << index << endl;
261
-      ABACUSerror("Not counting total_nr_req correctly in SF_4p_opt_server");
262
-    }
263
-    //ofstream SFsrc_outfile;
264
-    //SFsrc_outfile.open(SFsrc_Cstr);
265
-
266
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
267
-    //DP omegamax_used = 0.5 * wmax_4p (k);
268
-
269
-    int nr_machines;
270
-    MPI_Comm_size (comm, &nr_machines);
271
-    int nr_clients = nr_machines - 1;  // one for the server
272
-
273
-    int client_request_size = 7;
274
-    DP client_request[client_request_size];
275
-    // this is:
276
-    // ik
277
-    // iomega
278
-    // k
279
-    // omega
280
-    // req_prec
281
-    // Npts_K
282
-    // Npts_W
283
-    int client_result_size = 8;
284
-    DP client_result[client_result_size]; // same, plus SF_4p
285
-
286
-    MPI_Status status;
287
-
288
-    int scanning = 1;
289
-
290
-    int nr_sent_out = 0;
291
-    int nr_returned = 0;
292
-
293
-    for (int i = 1; i <= nr_clients && i <= total_nr_req; ++i) {
294
-
295
-      // Send request to client i, in the form of the req_id_array vector
296
-      client_request[0] = DP(needed_ik[nr_sent_out]);
297
-      client_request[1] = DP(needed_iomega[nr_sent_out]);
298
-      client_request[2] = k_needed;//(twoPI * needed_ik[nr_sent_out])/N;
299
-      client_request[3] = (needed_iomega[nr_sent_out] + 0.5) * omegamax/Nomega;
300
-      client_request[4] = req_prec;
301
-      client_request[5] = DP(Npts_K);
302
-      client_request[6] = DP(Npts_W);
303
-
304
-      MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
305
-      //cout << "Server:  sent request ";
306
-      //for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
307
-      //cout << "with tag " << scanning << " to client " << i << endl;
308
-      nr_sent_out++;
309
-      //cout << "nr_sent_out = " << nr_sent_out << endl;
310
-    }
311
-
312
-    DP Actual_Time_MPI = MPI_Wtime();
313
-
314
-    //while (nr_returned < total_nr_req) {
315
-    while (nr_returned < nr_sent_out) {
316
-
317
-      //cout << "Server:  waiting for answers... " << endl;
318
-      MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
319
-      nr_returned++;
320
-      //cout << "Server:  received answer from client " << status.MPI_SOURCE << endl;
321
-      // unbuffer result
322
-      SF_4p[int(client_result[1])] = client_result[7];
323
-
324
-      Actual_Time_MPI = MPI_Wtime();
325
-
326
-      // Send out new request if needed and time available
327
-      if (nr_sent_out < total_nr_req && Actual_Time_MPI - Start_Time_MPI < Max_Secs) {
328
-	client_request[0] = needed_ik[nr_sent_out];
329
-	client_request[1] = needed_iomega[nr_sent_out];
330
-	client_request[2] = k_needed;//(twoPI * needed_ik[nr_sent_out])/N;
331
-	client_request[3] = (needed_iomega[nr_sent_out] + 0.5) * omegamax/Nomega;
332
-	MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
333
-	nr_sent_out++;
334
-	//cout << "nr_sent_out = " << nr_sent_out << endl;
335
-      }
336
-
337
-    } // while (nr_returned < total_nr_req)
338
-
339
-    cout << endl << "Computed " << nr_returned << " points ouf of " << total_nr_req << " required. " << endl;
340
-
341
-    cout << endl << "Server saving file..." << endl;
342
-
343
-    // Output all data:
344
-    SF_outfile.seekp(0);
345
-    for (int iomega = 0; iomega < Nomega; ++iomega) {
346
-      SF_outfile << omega[iomega] << "\t" << SF_4p[iomega] << endl;
347
-    }
348
-
349
-    SF_outfile.close();
350
-
351
-    cout << endl << "Done !" << endl;
352
-
353
-    // Send term signal to clients
354
-    int scanning_completed = 0;
355
-    for (int i = 1; i <= nr_clients; ++i)
356
-      MPI_Send (client_request, client_request_size, MPI_DOUBLE, i, scanning_completed, comm);
357
-
358
-    return;
359
-  }
360
-  */
361
-  /*
362
-  // Function producing a fixed k scan, with data file
363
-  void SF_4p_rec_par (MPI_Comm comm, DP k, DP req_prec, int max_rec_w, int max_rec, I_table Itable)
364
-  {
365
-    int Npts_w = int(pow(3.0, max_rec_w + 2));
366
-
367
-    stringstream SFraw_stringstream;
368
-    string SFraw_string;
369
-    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".raw";
370
-    SFraw_string = SFraw_stringstream.str();
371
-    const char* SFraw_Cstr = SFraw_string.c_str();
372
-
373
-    stringstream SF_stringstream;
374
-    string SF_string;
375
-    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".dat";
376
-    SF_string = SF_stringstream.str();
377
-    const char* SF_Cstr = SF_string.c_str();
378
-
379
-    stringstream SFsrc_stringstream;
380
-    string SFsrc_string;
381
-    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".src";
382
-    SFsrc_string = SFsrc_stringstream.str();
383
-    const char* SFsrc_Cstr = SFsrc_string.c_str();
384
-
385
-    ofstream SFraw_outfile;
386
-    SFraw_outfile.open(SFraw_Cstr);
387
-    //ofstream SFsrc_outfile;
388
-    //SFsrc_outfile.open(SFsrc_Cstr);
389
-
390
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
391
-    //DP omegamax_used = 0.5 * wmax_4p (k);
392
-
393
-    int nr_machines;
394
-    MPI_Comm_size (comm, &nr_machines);
395
-    int nr_clients = nr_machines - 1;  // one for the server
396
-
397
-    int client_request_size = 2;
398
-    DP client_request[client_request_size]; // this is k, alpha
399
-    int client_result_size = 3;
400
-    DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha
401
-
402
-    MPI_Status status;
403
-
404
-    int scanning = 1;
405
-
406
-    int total_nr_req = Npts_w;
407
-    int nr_sent_out = 0;
408
-    int nr_returned = 0;
409
-
410
-    Vect_DP alpha_req(Npts_w);
411
-    for (int iw = 0; iw < Npts_w; ++iw) alpha_req[iw] = 0.5 * PI * (iw + 0.5)/Npts_w;
412
-
413
-    //cout << "alpha_req = " << alpha_req << endl;
414
-
415
-    for (int i = 1; i <= nr_clients && i <= total_nr_req; ++i) {
416
-
417
-      // Send request to client i, in the form of the req_id_array vector
418
-      client_request[0] = k;
419
-      client_request[1] = alpha_req[nr_sent_out];
420
-
421
-      MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
422
-      //cout << "Server:  sent request ";
423
-      //for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
424
-      //cout << "with tag " << scanning << " to client " << i << endl;
425
-      nr_sent_out++;
426
-      //cout << "nr_sent_out = " << nr_sent_out << endl;
427
-    }
428
-
429
-    while (nr_returned < total_nr_req) {
430
-
431
-      //cout << "Server:  waiting for answers... " << endl;
432
-      MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
433
-      nr_returned++;
434
-      //cout << "Server:  received answer from client " << status.MPI_SOURCE << endl;
435
-
436
-      // unbuffer result
437
-      SFraw_outfile << client_result[1] << "\t" << client_result[2] << endl;
438
-
439
-      // Send out new request if needed
440
-      if (nr_sent_out < total_nr_req) {
441
-	client_request[1] = alpha_req[nr_sent_out];
442
-	MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
443
-	nr_sent_out++;
444
-	//cout << "nr_sent_out = " << nr_sent_out << endl;
445
-      }
446
-
447
-    } // while (nr_returned < total_nr_req)
448
-
449
-    // Send term signal to clients
450
-    int scanning_completed = 0;
451
-    for (int i = 1; i <= nr_clients; ++i)
452
-      MPI_Send (client_request, client_request_size, MPI_DOUBLE, i, scanning_completed, comm);
453
-
454
-    SFraw_outfile.close();
455
-
456
-    //SFsrc_outfile << answer << endl;
457
-    //SFsrc_outfile.close();
458
-
459
-    // Translate raw data into SF_4p (k,omega) data
460
-
461
-    //Translate_raw_4p_data (k, max_rec_w, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
462
-    Translate_raw_4p_data (k, int(pow(3.0, max_rec_w + 2)), SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
463
-
464
-    return;
465
-  }
466
-
467
-  void SF_4p_opt_par (MPI_Comm comm, DP k, DP req_prec, int Npts_w, int Npts_K, int Npts_W, I_table Itable)
468
-  {
469
-    stringstream SFraw_stringstream;
470
-    string SFraw_string;
471
-    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".raw";
472
-    SFraw_string = SFraw_stringstream.str();
473
-    const char* SFraw_Cstr = SFraw_string.c_str();
474
-
475
-    stringstream SF_stringstream;
476
-    string SF_string;
477
-    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".dat";
478
-    SF_string = SF_stringstream.str();
479
-    const char* SF_Cstr = SF_string.c_str();
480
-
481
-    stringstream SFsrc_stringstream;
482
-    string SFsrc_string;
483
-    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".src";
484
-    SFsrc_string = SFsrc_stringstream.str();
485
-    const char* SFsrc_Cstr = SFsrc_string.c_str();
486
-
487
-    ofstream SFraw_outfile;
488
-    SFraw_outfile.open(SFraw_Cstr);
489
-    //ofstream SFsrc_outfile;
490
-    //SFsrc_outfile.open(SFsrc_Cstr);
491
-
492
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
493
-    //DP omegamax_used = 0.5 * wmax_4p (k);
494
-
495
-    int nr_machines;
496
-    MPI_Comm_size (comm, &nr_machines);
497
-    int nr_clients = nr_machines - 1;  // one for the server
498
-
499
-    int client_request_size = 2;
500
-    DP client_request[client_request_size]; // this is k, alpha
501
-    int client_result_size = 3;
502
-    DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha_opt
503
-
504
-    MPI_Status status;
505
-
506
-    int scanning = 1;
507
-
508
-    int total_nr_req = Npts_w;
509
-    int nr_sent_out = 0;
510
-    int nr_returned = 0;
511
-
512
-    Vect_DP alpha_req(Npts_w);
513
-    for (int iw = 0; iw < Npts_w; ++iw) alpha_req[iw] = 0.5 * PI * (iw + 0.5)/Npts_w;
514
-
515
-    //cout << "alpha_req = " << alpha_req << endl;
516
-
517
-    for (int i = 1; i <= nr_clients && i <= total_nr_req; ++i) {
518
-
519
-      // Send request to client i, in the form of the req_id_array vector
520
-      client_request[0] = k;
521
-      client_request[1] = alpha_req[nr_sent_out];
522
-
523
-      MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
524
-      //cout << "Server:  sent request ";
525
-      //for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
526
-      //cout << "with tag " << scanning << " to client " << i << endl;
527
-      nr_sent_out++;
528
-      //cout << "nr_sent_out = " << nr_sent_out << endl;
529
-    }
530
-
531
-    while (nr_returned < total_nr_req) {
532
-
533
-      //cout << "Server:  waiting for answers... " << endl;
534
-      MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
535
-      nr_returned++;
536
-      //cout << "Server:  received answer from client " << status.MPI_SOURCE << endl;
537
-
538
-      // unbuffer result
539
-      SFraw_outfile << client_result[1] << "\t" << client_result[2] << endl;
540
-
541
-      // Send out new request if needed
542
-      if (nr_sent_out < total_nr_req) {
543
-	client_request[1] = alpha_req[nr_sent_out];
544
-	MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
545
-	nr_sent_out++;
546
-	//cout << "nr_sent_out = " << nr_sent_out << endl;
547
-      }
548
-
549
-    } // while (nr_returned < total_nr_req)
550
-
551
-    // Send term signal to clients
552
-    int scanning_completed = 0;
553
-    for (int i = 1; i <= nr_clients; ++i)
554
-      MPI_Send (client_request, client_request_size, MPI_DOUBLE, i, scanning_completed, comm);
555
-
556
-    SFraw_outfile.close();
557
-
558
-    //SFsrc_outfile << answer << endl;
559
-    //SFsrc_outfile.close();
560
-
561
-    // Translate raw data into SF_4p (k,omega) data
562
-
563
-    //Translate_raw_4p_data (k, max_rec_w, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
564
-    Translate_raw_4p_data (k, Npts_w, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
565
-
566
-    return;
567
-  }
568
-  */
569 173
 
570 174
 } // namespace ABACUS

+ 97
- 234
src/XXX_VOA/XXX_VOA.cc View File

@@ -26,7 +26,7 @@ namespace ABACUS {
26 26
 
27 27
     DP rho_used = fabs(rho);
28 28
 
29
-    if (rho_used > 10000.0) return(-PI * rho_used - 2.0 * Euler_Mascheroni);  // CHECK THIS
29
+    if (rho_used > 10000.0) return(-PI * rho_used - 2.0 * Euler_Mascheroni);
30 30
 
31 31
     Vect_DP args(2);
32 32
     args[0] = 0.0;
@@ -37,12 +37,6 @@ namespace ABACUS {
37 37
       - 2.0 * Integrate_rec (Integrand_12, args, 0, t1, tinf, req_prec, 12)
38 38
       - Integrate_rec (Integrand_2, args, 0, 0.0, tinf, req_prec, 12);
39 39
 
40
-    /*
41
-    DP answer = -2.0 * Euler_Mascheroni - 2.0 * log(4.0 * rho_used * t1)
42
-      + 2.0 * (Integrate_optimal (Integrand_11, args, 0, 0.0, t1, req_prec, 1.0e-30, 10000)).integ_est
43
-      - 2.0 * (Integrate_optimal (Integrand_12, args, 0, t1, tinf, req_prec, 1.0e-30, 10000)).integ_est
44
-      - (Integrate_optimal (Integrand_2, args, 0, 0.0, tinf, req_prec, 1.0e-30, 10000)).integ_est;
45
-    */
46 40
     return(answer);
47 41
   }
48 42
 
@@ -53,14 +47,17 @@ namespace ABACUS {
53 47
   {
54 48
     // Careful !  This is S(k, omega) = S (k, w) |dw/domega| = 2 S(k, w)
55 49
 
56
-    DP w = 2.0 * omega;  // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
50
+    DP w = 2.0 * omega;
51
+    // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
57 52
 
58 53
     DP wu = twoPI * sin(0.5 * k);
59 54
     DP wl = PI * fabs(sin(k));
60 55
 
61 56
     // Factor of 2:  return S(k, omega), not S(k, w)
62
-    // 0.25 factor:  1/4 * 2 * 1/2, where 1/4 comes from Bougourzi, 2 is the Jacobian |dw/domega| and 1/2 is S^{zz} = 1/2 * S^{+-}
63
-    return(w < wu && w > wl ? 2.0 * 0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI))/sqrt(wu * wu - w * w) : 0.0);
57
+    // 0.25 factor:  1/4 * 2 * 1/2, where 1/4 comes from Bougourzi, 2 is the Jacobian |dw/domega|
58
+    // and 1/2 is S^{zz} = 1/2 * S^{+-}
59
+    return(w < wu && w > wl ? 2.0 * 0.5
60
+	   * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI))/sqrt(wu * wu - w * w) : 0.0);
64 61
 
65 62
   }
66 63
 
@@ -75,7 +72,8 @@ namespace ABACUS {
75 72
 
76 73
     // 0.5 factor:  1 from Bougourzi, and 1/2 is S^{zz} = 1/2 * S^{+-}
77 74
     return(args[1] < wu && args[1] > wl ?
78
-	   0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(args[1] * args[1] - wl * wl)))/PI))/sqrt(wu * wu - args[1] * args[1]) : 0.0);
75
+	   0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(args[1] * args[1] - wl * wl)))
76
+					 /PI))/sqrt(wu * wu - args[1] * args[1]) : 0.0);
79 77
   }
80 78
 
81 79
   DP SF_2p_alt (Vect_DP args, I_table Itable)
@@ -87,8 +85,7 @@ namespace ABACUS {
87 85
     DP wu = twoPI * sin(0.5 * args[0]);
88 86
     DP wl = PI * fabs(sin(args[0]));
89 87
 
90
-    //DP w = wu * cos(args[1]);
91
-    //DP factor = 1.0;
88
+
92 89
     DP w = wl * cosh(args[1]);
93 90
 
94 91
     if (w >= wu || w <= wl) return(0.0);
@@ -109,8 +106,6 @@ namespace ABACUS {
109 106
     DP wu = twoPI * sin(0.5 * args[0]);
110 107
     DP wl = PI * fabs(sin(args[0]));
111 108
 
112
-    //DP w = wu * cos(args[1]);
113
-    //DP factor = 1.0;
114 109
     DP w = wl * cosh(args[1]);
115 110
     DP factor = sqrt((w * w - wl * wl)/(wu * wu - w * w));
116 111
 
@@ -153,7 +148,6 @@ namespace ABACUS {
153 148
     args_to_SF_2p[1] = 0.0; // this will be w
154 149
     args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
155 150
 
156
-    //return(Integrate_rec_using_table (SF_2p_alt, args_to_SF_2p, 1, Itable, 0.0, acos(wl/wu), req_prec, max_rec)/twoPI);
157 151
     return(Integrate_rec_using_table (SF_2p_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(wu/wl), req_prec, max_rec)/twoPI);
158 152
   }
159 153
 
@@ -168,7 +162,8 @@ namespace ABACUS {
168 162
     args_to_SF_2p_intw[2] = DP(max_rec);
169 163
 
170 164
     // Factor 2:  int[0, 2PI] = 2 int[0, PI]
171
-    return(4.0 * 2.0 * Integrate_rec_using_table (SF_2p_intw, args_to_SF_2p_intw, 0, Itable, 0.0, PI, req_prec, max_rec)/twoPI);
165
+    return(4.0 * 2.0 * Integrate_rec_using_table (SF_2p_intw, args_to_SF_2p_intw, 0, Itable,
166
+						  0.0, PI, req_prec, max_rec)/twoPI);
172 167
     // 4 : because full integral gives 1/4, return value here is sr fraction obtained.
173 168
   }
174 169
 
@@ -183,7 +178,8 @@ namespace ABACUS {
183 178
     args_to_SF_2p_intw[2] = DP(max_rec);
184 179
 
185 180
     // Factor 2:  int[0, 2PI] = 2 int[0, PI]
186
-    return(4.0 * 2.0 * Integrate_rec_using_table (SF_2p_intw_alt, args_to_SF_2p_intw, 0, Itable, 0.0, PI, req_prec, max_rec)/twoPI);
181
+    return(4.0 * 2.0 * Integrate_rec_using_table (SF_2p_intw_alt, args_to_SF_2p_intw, 0, Itable,
182
+						  0.0, PI, req_prec, max_rec)/twoPI);
187 183
     // 4 : because full integral gives 1/4, return value here is sr fraction obtained.
188 184
   }
189 185
 
@@ -210,7 +206,8 @@ namespace ABACUS {
210 206
     args_to_SF_2p[1] = 0.0; // this will be w
211 207
     args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
212 208
 
213
-    return((Integrate_rec_using_table (SF_2p_w, args_to_SF_2p, 1, Itable, wl, wu, req_prec, max_rec)/twoPI)/Fixed_k_sumrule_w(k));
209
+    return((Integrate_rec_using_table (SF_2p_w, args_to_SF_2p, 1,
210
+				       Itable, wl, wu, req_prec, max_rec)/twoPI)/Fixed_k_sumrule_w(k));
214 211
   }
215 212
 
216 213
   DP SF_2p_check_fixed_k_sumrule_alt (DP k, DP req_prec, int max_rec, I_table Itable)
@@ -225,7 +222,8 @@ namespace ABACUS {
225 222
     args_to_SF_2p[1] = 0.0; // this will be alpha
226 223
     args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
227 224
 
228
-    return((Integrate_rec_using_table (SF_2p_w_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(wu/wl), req_prec, max_rec)/twoPI)/Fixed_k_sumrule_w(k));
225
+    return((Integrate_rec_using_table (SF_2p_w_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(wu/wl),
226
+				       req_prec, max_rec)/twoPI)/Fixed_k_sumrule_w(k));
229 227
   }
230 228
 
231 229
   DP SF_2p_check_fixed_k_sumrule_opt (DP k, DP req_prec, int Npts, I_table Itable)
@@ -240,7 +238,8 @@ namespace ABACUS {
240 238
     args_to_SF_2p[1] = 0.0; // this will be alpha
241 239
     args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
242 240
 
243
-    return(((Integrate_optimal_using_table (SF_2p_w_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(wu/wl), req_prec, 1.0e-32, Npts)).integ_est/twoPI)/Fixed_k_sumrule_w(k));
241
+    return(((Integrate_optimal_using_table (SF_2p_w_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(wu/wl),
242
+					    req_prec, 1.0e-32, Npts)).integ_est/twoPI)/Fixed_k_sumrule_w(k));
244 243
   }
245 244
 
246 245
 
@@ -253,9 +252,6 @@ namespace ABACUS {
253 252
     complex<DP> g[4];
254 253
     for (int l = 0; l < 4; ++l) g[l] = 0.0;
255 254
 
256
-    //DP prefactor = 256.0 * pow(PI, 14.0);
257
-    //DP prefactor = 1.0; // All factors taken into account later
258
-
259 255
     complex<DP> Plm[4];
260 256
     complex<DP> Pm[4];
261 257
 
@@ -280,27 +276,7 @@ namespace ABACUS {
280 276
     }
281 277
 
282 278
     // Do m = 0 terms:
283
-    /*
284
-    Pm[0] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj1[0]) - ln_Gamma(1.0 + irhoj1[0])
285
-				 + ln_Gamma(-0.5 + irhoj2[0]) - ln_Gamma(1.0 + irhoj2[0])
286
-				 + ln_Gamma(-0.5 + irhoj3[0]) - ln_Gamma(1.0 + irhoj3[0]));
287
-    Pm[1] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj0[1]) - ln_Gamma(1.0 + irhoj0[1])
288
-				 + ln_Gamma(-0.5 + irhoj2[1]) - ln_Gamma(1.0 + irhoj2[1])
289
-				 + ln_Gamma(-0.5 + irhoj3[1]) - ln_Gamma(1.0 + irhoj3[1]));
290
-    Pm[2] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj0[2]) - ln_Gamma(1.0 + irhoj0[2])
291
-				 + ln_Gamma(-0.5 + irhoj1[2]) - ln_Gamma(1.0 + irhoj1[2])
292
-				 + ln_Gamma(-0.5 + irhoj3[2]) - ln_Gamma(1.0 + irhoj3[2]));
293
-    Pm[3] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj0[3]) - ln_Gamma(1.0 + irhoj0[3])
294
-				 + ln_Gamma(-0.5 + irhoj1[3]) - ln_Gamma(1.0 + irhoj1[3])
295
-				 + ln_Gamma(-0.5 + irhoj2[3]) - ln_Gamma(1.0 + irhoj2[3]));
296
-    */
297 279
     for (int j = 0; j < 4; ++j) {
298
-      /*
299
-      Pm[j] *= exp(ln_Gamma(-0.5 + irhoj0[j]) - ln_Gamma(1.0 + irhoj0[j])
300
-		   + ln_Gamma(-0.5 + irhoj1[j]) - ln_Gamma(1.0 + irhoj1[j])
301
-		   + ln_Gamma(-0.5 + irhoj2[j]) - ln_Gamma(1.0 + irhoj2[j])
302
-		   + ln_Gamma(-0.5 + irhoj3[j]) - ln_Gamma(1.0 + irhoj3[j]));
303
-      */
304 280
       // Calling only Gamma (z) for Re(z) >= 0.5, in view of Lanczos method:
305 281
       Pm[j] *= exp(ln_Gamma(0.5 + irhoj0[j]) - ln_Gamma(1.0 + irhoj0[j])
306 282
 		   + ln_Gamma(0.5 + irhoj1[j]) - ln_Gamma(1.0 + irhoj1[j])
@@ -315,23 +291,12 @@ namespace ABACUS {
315 291
 
316 292
 	if (j <= l) g[l] += Plm[j] * Pm[j]; // otherwise no m = 0 term
317 293
 
318
-	//cout << "j = " << j << "\tl = " << l << "\tPlm[j] = " << Plm[j] << "\tPm[j] = " << Pm[j] << "\tprod = " << Plm[j] * Pm[j] << endl;
319 294
       }
320 295
     }
321 296
 
322
-    /*
323
-    for (int j = 0; j < 4; ++j) {
324
-      if (j == 0) g[0] += irhoj1[j] * irhoj2[j] * irhoj3[j] * Pm[j];
325
-      if (j <= 1) g[1] += (-0.5 + irhoj0[j]) * irhoj2[j] * irhoj3[j] * Pm[j];
326
-      if (j <= 2) g[2] += (-0.5 + irhoj0[j]) * (-0.5 + irhoj1[j]) * irhoj3[j] * Pm[j];
327
-      g[3] += (-0.5 + irhoj0[j]) * (-0.5 + irhoj1[j]) * (-0.5 + irhoj2[j]) * Pm[j];
328
-    }
329
-    */
330
-
331 297
     DP sum_norm_gl = norm(g[0]) + norm(g[1]) + norm(g[2]) + norm(g[3]);
332 298
     DP old_sum_norm_gl = sum_norm_gl;
333 299
 
334
-    //cout << "|g1|^2 = " << prefactor * norm(g[0]) << "\t2 " << prefactor * norm(g[1]) << "\t3 " << prefactor * norm(g[2]) << "\t4 " << prefactor * norm(g[3]) << endl;
335 300
 
336 301
     // Do m = 1, 2, ... terms:
337 302
 
@@ -353,68 +318,17 @@ namespace ABACUS {
353 318
 	  Pm[j] *= (m - 1.5 + irhoj0[j]) * (m - 1.5 + irhoj1[j]) * (m - 1.5 + irhoj2[j]) * (m - 1.5 + irhoj3[j])
354 319
 	    / ((DP(m) + irhoj0[j]) * (DP(m) + irhoj1[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]));
355 320
 
356
-	    //for (int l = 0; l < 4; ++l) {
357
-
358
-	    //Plm[j] = 1.0;
359
-	    //for (int i = 0; i < 4; ++i) if (i != l) Plm[j] *= m - (l > i ? 0.5 : 0.0) + II * (rho[j] - rho[i]);
360
-
361
-	    //g[l] += Plm[j] * Pm[j];
362
-	  //}
363
-
364 321
 	  // FASTER:  unwrap l, i loops
365 322
 	  // l = 0:
366
-	  //Plm[j] = (DP(m) + II * (rho[j] - rho[1])) * (DP(m) + II * (rho[j] - rho[2])) * (DP(m) + II * (rho[j] - rho[3]));
367
-	  //Plm[j] = (DP(m) + irhoj1[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]);
368
-	  //g[0] += Plm[j] * Pm[j];
369 323
 	  g[0] += (DP(m) + irhoj1[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]) * Pm[j];
370 324
 	  // l = 1;
371
-	  //Plm[j] = (m - 0.5 + II * (rho[j] - rho[0])) * (DP(m) + II * (rho[j] - rho[2])) * (DP(m) + II * (rho[j] - rho[3]));
372
-	  //Plm[j] = (m - 0.5 + irhoj0[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]);
373
-	  //g[1] += Plm[j] * Pm[j];
374 325
 	  g[1] += (m - 0.5 + irhoj0[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]) * Pm[j];
375 326
 	  // l = 2;
376
-	  //Plm[j] = (m - 0.5 + II * (rho[j] - rho[0])) * (m - 0.5 + II * (rho[j] - rho[1])) * (DP(m) + II * (rho[j] - rho[3]));
377
-	  //Plm[j] = (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (DP(m) + irhoj3[j]);
378
-	  //g[2] += Plm[j] * Pm[j];
379 327
 	  g[2] += (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (DP(m) + irhoj3[j]) * Pm[j];
380 328
 	  // l = 3;
381
-	  //Plm[j] = (m - 0.5 + II * (rho[j] - rho[0])) * (m - 0.5 + II * (rho[j] - rho[1])) * (m - 0.5 + II * (rho[j] - rho[2]));
382
-	  //Plm[j] = (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (m - 0.5 + irhoj2[j]);
383
-	  //g[3] += Plm[j] * Pm[j];
384 329
 	  g[3] += (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (m - 0.5 + irhoj2[j]) * Pm[j];
385 330
 	}
386 331
 
387
-	/*
388
-	// Also unwrap j loop:
389
-	Pm[0] *= (m - 1.5 + irhoj0[0]) * (m - 1.5 + irhoj1[0]) * (m - 1.5 + irhoj2[0]) * (m - 1.5 + irhoj3[0])
390
-	  / ((DP(m) + irhoj0[0]) * (DP(m) + irhoj1[0]) * (DP(m) + irhoj2[0]) * (DP(m) + irhoj3[0]));
391
-	Pm[1] *= (m - 1.5 + irhoj0[1]) * (m - 1.5 + irhoj1[1]) * (m - 1.5 + irhoj2[1]) * (m - 1.5 + irhoj3[1])
392
-	  / ((DP(m) + irhoj0[1]) * (DP(m) + irhoj1[1]) * (DP(m) + irhoj2[1]) * (DP(m) + irhoj3[1]));
393
-	Pm[2] *= (m - 1.5 + irhoj0[2]) * (m - 1.5 + irhoj1[2]) * (m - 1.5 + irhoj2[2]) * (m - 1.5 + irhoj3[2])
394
-	  / ((DP(m) + irhoj0[2]) * (DP(m) + irhoj1[2]) * (DP(m) + irhoj2[2]) * (DP(m) + irhoj3[2]));
395
-	Pm[3] *= (m - 1.5 + irhoj0[3]) * (m - 1.5 + irhoj1[3]) * (m - 1.5 + irhoj2[3]) * (m - 1.5 + irhoj3[3])
396
-	  / ((DP(m) + irhoj0[3]) * (DP(m) + irhoj1[3]) * (DP(m) + irhoj2[3]) * (DP(m) + irhoj3[3]));
397
-
398
-	g[0] += ((DP(m) + irhoj1[0]) * (DP(m) + irhoj2[0]) * (DP(m) + irhoj3[0])) * Pm[0]
399
-	  + ((DP(m)) * (DP(m) + irhoj2[1]) * (DP(m) + irhoj3[1])) * Pm[1]
400
-	  + ((DP(m) + irhoj1[2]) * (DP(m)) * (DP(m) + irhoj3[0])) * Pm[2]
401
-	  + ((DP(m) + irhoj1[3]) * (DP(m) + irhoj2[3]) * (DP(m))) * Pm[3];
402
-
403
-	g[1] += ((m - 0.5) * (DP(m) + irhoj2[0]) * (DP(m) + irhoj3[0])) * Pm[0]
404
-	  + ((m - 0.5 + irhoj0[1]) * (DP(m) + irhoj2[1]) * (DP(m) + irhoj3[1])) * Pm[1]
405
-	  + ((m - 0.5 + irhoj0[2]) * (DP(m)) * (DP(m) + irhoj3[2])) * Pm[2]
406
-	  + ((m - 0.5 + irhoj0[3]) * (DP(m) + irhoj2[3]) * (DP(m))) * Pm[3];
407
-
408
-	g[2] += ((m - 0.5) * (m - 0.5 + irhoj1[0]) * (DP(m) + irhoj3[0])) * Pm[0]
409
-	  + ((m - 0.5 + irhoj0[1]) * (m - 0.5) * (DP(m) + irhoj3[1])) * Pm[1]
410
-	  + ((m - 0.5 + irhoj0[2]) * (m - 0.5 + irhoj1[2]) * (DP(m) + irhoj3[2])) * Pm[2]
411
-	  + ((m - 0.5 + irhoj0[3]) * (m - 0.5 + irhoj1[3]) * (DP(m))) * Pm[3];
412
-
413
-	g[3] += ((m - 0.5) * (m - 0.5 + irhoj1[0]) * (m - 0.5 + irhoj2[0])) * Pm[0]
414
-	  + ((m - 0.5 + irhoj0[1]) * (m - 0.5) * (m - 0.5 + irhoj2[1])) * Pm[1]
415
-	  + ((m - 0.5 + irhoj0[2]) * (m - 0.5 + irhoj1[2]) * (m - 0.5)) * Pm[2]
416
-	  + ((m - 0.5 + irhoj0[3]) * (m - 0.5 + irhoj1[3]) * (m - 0.5 + irhoj2[3])) * Pm[3];
417
-	*/
418 332
 	m++;
419 333
 
420 334
       } while (m < m_to_reach);
@@ -423,11 +337,6 @@ namespace ABACUS {
423 337
 
424 338
     } while (m < 10 || sum_norm_gl/old_sum_norm_gl - 1.0 > req_prec && m < 100000);
425 339
 
426
-    //cout << "g converged using " << m << " terms." << endl;
427
-
428
-    //cout << "|g1|^2 = " << prefactor * norm(g[0]) << "\t2 " << prefactor * norm(g[1]) << "\t3 " << prefactor * norm(g[2]) << "\t4 " << prefactor * norm(g[3]) << endl;
429
-
430
-    //return(prefactor * (norm(g[0]) + norm(g[1]) + norm(g[2]) + norm(g[3])));
431 340
     return(norm(g[0]) + norm(g[1]) + norm(g[2]) + norm(g[3]));
432 341
 
433 342
   }
@@ -436,13 +345,8 @@ namespace ABACUS {
436 345
   {
437 346
     Vect_DP args(2);
438 347
 
439
-    DP answer = exp(-8.0 * real(ln_Gamma (0.25)) - 9.0 * log(2.0) + 8.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 50.0, req_prec, 16))/3.0;
440
-    //DP answer = exp(-8.0 * real(ln_Gamma (0.25)) - 21.0 * log(2.0) - 14.0 * log(PI) + 8.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 100.0, req_prec, 16))/3.0;
441
-
442
-    //cout << "|A|^2 = " << exp(-2.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 100.0, req_prec))
443
-    //   << "\t Gamma (1/4) = " << exp ((ln_Gamma(0.25))) << endl;
444
-    //cout << "NPB: " << exp(-8.0 * real(ln_Gamma (0.25)) - 9.0 * log(2.0) + 8.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 50.0, req_prec))/3.0 << endl;
445
-    //cout << "c-m: " << exp(-8.0 * real(ln_Gamma (0.25)) - 21.0 * log(2.0) - 14.0 * log(PI) + 8.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 50.0, req_prec))/3.0 << endl;
348
+    DP answer = exp(-8.0 * real(ln_Gamma (0.25)) - 9.0 * log(2.0)
349
+		    + 8.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 50.0, req_prec, 16))/3.0;
446 350
 
447 351
     return(answer);
448 352
   }
@@ -459,18 +363,11 @@ namespace ABACUS {
459 363
 
460 364
     sum_I_integrals = 0.0;
461 365
     for (int i1 = 0; i1 < 3; ++i1) for (int i2 = i1+1; i2 < 4; ++i2) {
462
-      //cout << "rho_ij = " << rho[i1] - rho[i2] << "\tI(rho_ij) = " << Itable.Return_val (rho[i1] - rho[i2]) << "\t" << I_integral (rho[i1] - rho[i2], req_prec) << endl;
463
-      //sum_I_integrals += I_integral(rho[i1] - rho[i2], req_prec);
464
-      sum_I_integrals += Itable.Return_val (rho[i1] - rho[i2]);
465
-    }
466
-    //cout << "sum_I_integrals = " << sum_I_integrals << "\texp(-sum) = " << exp(-sum_I_integrals) << endl;
366
+	sum_I_integrals += Itable.Return_val (rho[i1] - rho[i2]);
367
+      }
467 368
 
468
-    //sum_norm_g = 0.0;
469
-    //for (int i = 0; i < 4; ++i) sum_norm_g += norm(g(i, rho));
470 369
     sum_norm_g = Sum_norm_gl (rho, req_prec);
471 370
 
472
-    //cout << "sum_norm_g = " << sum_norm_g << "\t sqrt() = " << sqrt(Wu * Wu - W * W) << endl;
473
-
474 371
     return(exp(-sum_I_integrals) * sum_norm_g/sqrt(Wu * Wu - W * W));
475 372
   }
476 373
 
@@ -483,9 +380,9 @@ namespace ABACUS {
483 380
 
484 381
     sum_I_integrals = 0.0;
485 382
     for (int i1 = 0; i1 < 3; ++i1) for (int i2 = i1+1; i2 < 4; ++i2) {
486
-      if (fabs(rho[i1] - rho[i2]) < 1.0e-10 || fabs(rho[i1] - rho[i2]) >= 1000.0) return(0.0); // safety here
487
-      sum_I_integrals += Itable.Return_val (rho[i1] - rho[i2]);
488
-    }
383
+	if (fabs(rho[i1] - rho[i2]) < 1.0e-10 || fabs(rho[i1] - rho[i2]) >= 1000.0) return(0.0); // safety here
384
+	sum_I_integrals += Itable.Return_val (rho[i1] - rho[i2]);
385
+      }
489 386
 
490 387
     sum_norm_g = Sum_norm_gl (rho, req_prec);
491 388
 
@@ -498,7 +395,8 @@ namespace ABACUS {
498 395
 
499 396
     DP argacos1, argacos2;
500 397
 
501
-    if (fabs(argacos1 = W/(twoPI * sin(0.5*K))) > 1.0 || fabs(argacos2 = (w - W)/(twoPI * sin (0.5 * fabs(k - K)))) > 1.0) return(false);
398
+    if (fabs(argacos1 = W/(twoPI * sin(0.5*K))) > 1.0
399
+	|| fabs(argacos2 = (w - W)/(twoPI * sin (0.5 * fabs(k - K)))) > 1.0) return(false);
502 400
 
503 401
     DP acos1 = acos(argacos1);
504 402
     DP acos2 = acos(argacos2);
@@ -516,7 +414,7 @@ namespace ABACUS {
516 414
       p[3] = 0.5 * (K-k) - PI - acos2;
517 415
     }
518 416
 
519
-    for (int i = 0; i < 4; ++i) if (p[i] < -PI || p[i] > 0.0) return(false); // { cout << k << "\t" << w << "\t" << K << "\t" << W << "\t" << p; ABACUSerror("p out of bounds"); }
417
+    for (int i = 0; i < 4; ++i) if (p[i] < -PI || p[i] > 0.0) return(false);
520 418
 
521 419
     return(true);
522 420
   }
@@ -527,11 +425,9 @@ namespace ABACUS {
527 425
 
528 426
     if (!Set_p_given_kwKW (args_to_G[0], args_to_G[1], args_to_G[2], args_to_G[3], p)) return(0.0);
529 427
 
530
-    DP answer = Jacobian_p3p4_KW (args_to_G[0], args_to_G[1], args_to_G[2], args_to_G[3]) * SF_contrib (p, args_to_G[4], Itable);
428
+    DP answer = Jacobian_p3p4_KW (args_to_G[0], args_to_G[1], args_to_G[2], args_to_G[3])
429
+      * SF_contrib (p, args_to_G[4], Itable);
531 430
 
532
-    //  cout << "kwKW = " << args_to_G[0] << " " << args_to_G[1] << " " << args_to_G[2] << " " << args_to_G[3] << "\tp = " << p << "Jac = " << Jacobian_p3p4_KW (args_to_G[0], args_to_G[1], args_to_G[2], args_to_G[3]) << "\tG = " << answer << endl;
533
-
534
-    //return(Jacobian_p3p4_KW (args_to_G[0], args_to_G[1], args_to_G[2], args_to_G[3]) * SF_contrib (p, 0.01 * args_to_G[4], Itable));
535 431
     return(answer);
536 432
   }
537 433
 
@@ -583,12 +479,11 @@ namespace ABACUS {
583 479
 
584 480
     if (!Set_p_given_kwKW (args_to_G[0], args_to_G[1], args_to_G[2], W, p)) return(0.0);
585 481
 
586
-    DP answer = J_fn (p, args_to_G[4], Itable) * sqrt(W * (2.0 * args_to_G[6] - W)
587
-						      /((args_to_G[8] - W * W) * (args_to_G[9] - pow(args_to_G[1] - W, 2.0))));
482
+    DP answer = J_fn (p, args_to_G[4], Itable)
483
+      * sqrt(W * (2.0 * args_to_G[6] - W)/((args_to_G[8] - W * W) * (args_to_G[9] - pow(args_to_G[1] - W, 2.0))));
588 484
 
589 485
     if (is_nan(answer)) {
590 486
       cerr << setprecision(10) << "args_to_G1_fn_mid = " << args_to_G << "G1 = " << answer << "\tPut to zero..." << endl;
591
-      //ABACUSerror("non !");
592 487
       answer = 0.0;
593 488
     }
594 489
     return(answer);
@@ -609,13 +504,12 @@ namespace ABACUS {
609 504
     if (!Set_p_given_kwKW (args_to_G[0], args_to_G[1], args_to_G[2], W, p)) return(0.0);
610 505
 
611 506
     DP answer = J_fn (p, args_to_G[4], Itable)
612
-      //* sqrt((args_to_G[7] * args_to_G[7] - W * W)/((args_to_G[8] - W * W) * (args_to_G[9] - pow(args_to_G[1] - W, 2.0))));
613 507
       * args_to_G[7] * sin(args_to_G[3]) /sqrt((args_to_G[8] - W * W) * (args_to_G[9] - pow(args_to_G[1] - W, 2.0)));
614 508
 
615 509
     if (is_nan(answer)) {
616 510
       cerr << setprecision(10) << "args_to_G2_fn_mid = " << args_to_G << "G2 = " << answer << endl;
617
-      cerr << W << "\t" << (args_to_G[7] * args_to_G[7] - W * W) << "\t" << (args_to_G[8] - W * W) << "\t" << (args_to_G[9] - pow(args_to_G[1] - W, 2.0)) << endl;
618
-      //ABACUSerror("non !");
511
+      cerr << W << "\t" << (args_to_G[7] * args_to_G[7] - W * W) << "\t" << (args_to_G[8] - W * W)
512
+	   << "\t" << (args_to_G[9] - pow(args_to_G[1] - W, 2.0)) << endl;
619 513
       answer = 0.0;
620 514
     }
621 515
     return(answer);
@@ -634,7 +528,8 @@ namespace ABACUS {
634 528
     DP Wu1 = args_to_G[6];
635 529
     DP Wu2 = args_to_G[7];
636 530
 
637
-    return(J_fn (p, args_to_G[8], Itable) * sqrt((W * W - Wmin * Wmin)/((Wu1 * Wu1 - W * W) * (Wu2 * Wu2 - (args_to_G[1] - W) * (args_to_G[1] - W)))));
531
+    return(J_fn (p, args_to_G[8], Itable)
532
+	   * sqrt((W * W - Wmin * Wmin)/((Wu1 * Wu1 - W * W) * (Wu2 * Wu2 - (args_to_G[1] - W) * (args_to_G[1] - W)))));
638 533
   }
639 534
 
640 535
   DP H_fn (Vect_DP args_to_H, I_table Itable)
@@ -657,8 +552,8 @@ namespace ABACUS {
657 552
     DP Wmin_used = Wmin (k, w, K);
658 553
     DP Wmax_used = Wmax (k, w, K);
659 554
 
660
-    return(Wmax_used > Wmin_used ? Integrate_rec_using_table (G_fn, args_to_G, 3, Itable, Wmin_used, Wmax_used, req_prec, max_rec) : 0.0);
661
-    //return(Riemann_Integrate_rec_using_table (G_fn, args_to_G, 3, Itable, 0.0, 10.0, 500));
555
+    return(Wmax_used > Wmin_used ?
556
+	   Integrate_rec_using_table (G_fn, args_to_G, 3, Itable, Wmin_used, Wmax_used, req_prec, max_rec) : 0.0);
662 557
   }
663 558
 
664 559
   DP H2_fn (Vect_DP args_to_H, I_table Itable)
@@ -741,8 +636,10 @@ namespace ABACUS {
741 636
     DP alpha_L2 = 0.0;
742 637
     DP alpha_U2 = acos(Wmid/Wmax_used);
743 638
 
744
-    answer += Integrate_rec_using_table (G1_fn_mid, args_to_G, 3, Itable, alpha_L1, alpha_U1, args_to_H[3], int(args_to_H[4]));
745
-    answer += Integrate_rec_using_table (G2_fn_mid, args_to_G, 3, Itable, alpha_L2, alpha_U2, args_to_H[3], int(args_to_H[4]));
639
+    answer += Integrate_rec_using_table (G1_fn_mid, args_to_G, 3, Itable, alpha_L1,
640
+					 alpha_U1, args_to_H[3], int(args_to_H[4]));
641
+    answer += Integrate_rec_using_table (G2_fn_mid, args_to_G, 3, Itable, alpha_L2,
642
+					 alpha_U2, args_to_H[3], int(args_to_H[4]));
746 643
 
747 644
     return(answer);
748 645
   }
@@ -790,8 +687,10 @@ namespace ABACUS {
790 687
     DP alpha_L2 = 0.0;
791 688
     DP alpha_U2 = acos(Wmid/Wmax_used);
792 689
 
793
-    answer += (Integrate_optimal_using_table (G1_fn_mid, args_to_G, 3, Itable, alpha_L1, alpha_U1, args_to_H[3], 1.0e-32, int(args_to_H[4]))).integ_est;
794
-    answer += (Integrate_optimal_using_table (G2_fn_mid, args_to_G, 3, Itable, alpha_L2, alpha_U2, args_to_H[3], 1.0e-32, int(args_to_H[4]))).integ_est;
690
+    answer += (Integrate_optimal_using_table (G1_fn_mid, args_to_G, 3, Itable, alpha_L1, alpha_U1,
691
+					      args_to_H[3], 1.0e-32, int(args_to_H[4]))).integ_est;
692
+    answer += (Integrate_optimal_using_table (G2_fn_mid, args_to_G, 3, Itable, alpha_L2, alpha_U2,
693
+					      args_to_H[3], 1.0e-32, int(args_to_H[4]))).integ_est;
795 694
 
796 695
     return(answer);
797 696
   }
@@ -823,10 +722,9 @@ namespace ABACUS {
823 722
     args_to_G[9] = DP(max_rec);
824 723
 
825 724
     return(Integrate_rec_using_table (G_fn_alt, args_to_G, 3, Itable, 0.0, acosh(Wmax_used/Wmin_used), req_prec, max_rec));
826
-    //return(Riemann_Integrate_rec_using_table (G_fn, args_to_G, 3, Itable, 0.0, 10.0, 500));
827 725
   }
828 726
 
829
-  //DP SF_4p_kwKW (DP k, DP omega, DP req_prec, int max_rec, I_table Itable)
727
+
830 728
   DP SF_4p_kwKW (Vect_DP args, I_table Itable)
831 729
   {
832 730
     // Translate:
@@ -842,21 +740,20 @@ namespace ABACUS {
842 740
     Vect_DP args_to_H(5);
843 741
     args_to_H[0] = k;  // shift of PI in Bougourzi:  because they do FM case.
844 742
     // We want AFM, so SF_4p (k, omega) is correctly obtained directly from the RHS of their formula.
845
-    DP w = 2.0 * omega;  // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
743
+    DP w = 2.0 * omega;
744
+    // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
846 745
     args_to_H[1] = w;
847 746
     args_to_H[2] = 0.0;  // this is K
848 747
     args_to_H[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
849 748
     args_to_H[4] = DP(max_rec);
850 749
 
851 750
     if (w > wmax_4p(k) || w < wmin_4p(k)) {
852
-      //cout << "w out of bounds in SF_4p: " << "wmin = " << PI * sin(k) << " wmax = " <<  4.0 * PI * sin(0.25 * k) << " w = " << w << endl;
853 751
       return(0.0);
854 752
     }
855 753
 
856 754
     DP prefactor = 2.0 * 0.5 * 4.0 * Compute_C4 (req_prec);  // 4 comes from using p1 > p2 & p3 > p4 instead of whole interval.
857 755
     // 2 from Jacobian |dw/domega|
858 756
     // 0.5 from S^{zz} = S^{pm}/2
859
-    //DP prefactor = 4.0;
860 757
 
861 758
     // Define the K integral domain
862 759
     Domain<DP> Kdomain;
@@ -897,26 +794,17 @@ namespace ABACUS {
897 794
       Kdomain.Exclude (K3em, K3ep);
898 795
     }
899 796
 
900
-    //cout << "Kdomain: " << endl << Kdomain << endl;
901
-
902 797
     // Use (K,W) -> (k-K, w-W) symmetry to restrict to K in [k/2, k/2+PI]
903 798
     Kdomain.Exclude (0.0, 0.5 * k);
904 799
     Kdomain.Exclude (0.5 * k + PI, twoPI);
905
-    //Kdomain.Exclude (0.5 * k, 0.5 * k + PI);
906 800
     prefactor *= 2.0;
907 801
 
908
-    //cout << "Kdomain restricted: " << endl << Kdomain << endl;
909
-
910 802
     DP answer = 0.0;
911 803
 
912 804
     for (int idom = 0; idom < Kdomain.Ndomains(); ++idom)
913
-      //answer += Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
914
-      //answer += Integrate_rec_using_table (H2_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
915
-      //answer += Integrate_rec_using_table (H_fn_alt, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
916
-      answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
805
+      answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom),
806
+					   req_prec, max_rec);
917 807
 
918
-    //return(prefactor * Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, req_prec, max_rec));
919
-    //return(prefactor * Riemann_Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, 500));
920 808
     return (prefactor * answer);
921 809
   }
922 810
 
@@ -938,21 +826,21 @@ namespace ABACUS {
938 826
     Vect_DP args_to_H(5);
939 827
     args_to_H[0] = k;  // shift of PI in Bougourzi:  because they do FM case.
940 828
     // We want AFM, so SF_4p (k, omega) is correctly obtained directly from the RHS of their formula.
941
-    DP w = 2.0 * omega;  // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
829
+    DP w = 2.0 * omega;
830
+    // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
942 831
     args_to_H[1] = w;
943 832
     args_to_H[2] = 0.0;  // this is K
944 833
     args_to_H[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
945 834
     args_to_H[4] = DP(Npts_W);
946 835
 
947 836
     if (w > wmax_4p(k) || w < wmin_4p(k)) {
948
-      //cout << "w out of bounds in SF_4p: " << "wmin = " << PI * sin(k) << " wmax = " <<  4.0 * PI * sin(0.25 * k) << " w = " << w << endl;
949 837
       return(0.0);
950 838
     }
951 839
 
952
-    DP prefactor = 2.0 * 0.5 * 4.0 * Compute_C4 (req_prec);  // 4 comes from using p1 > p2 & p3 > p4 instead of whole interval.
840
+    DP prefactor = 2.0 * 0.5 * 4.0 * Compute_C4 (req_prec);
841
+    // 4 comes from using p1 > p2 & p3 > p4 instead of whole interval.
953 842
     // 2 from Jacobian |dw/domega|
954 843
     // 0.5 from S^{zz} = S^{pm}/2
955
-    //DP prefactor = 4.0;
956 844
 
957 845
     // Define the K integral domain
958 846
     Domain<DP> Kdomain;
@@ -993,28 +881,17 @@ namespace ABACUS {
993 881
       Kdomain.Exclude (K3em, K3ep);
994 882
     }
995 883
 
996
-    //cout << "Kdomain: " << endl << Kdomain << endl;
997
-
998 884
     // Use (K,W) -> (k-K, w-W) symmetry to restrict to K in [k, k+PI]
999 885
     Kdomain.Exclude (0.0, 0.5 * k);
1000 886
     Kdomain.Exclude (0.5 * k + PI, twoPI);
1001
-    //Kdomain.Exclude (0.5 * k, 0.5 * k + PI);
1002 887
     prefactor *= 2.0;
1003 888
 
1004
-    //cout << "Kdomain restricted: " << endl << Kdomain << endl;
1005
-
1006 889
     DP answer = 0.0;
1007 890
 
1008 891
     for (int idom = 0; idom < Kdomain.Ndomains(); ++idom)
1009
-      //answer += Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
1010
-      //answer += Integrate_rec_using_table (H2_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
1011
-      //answer += Integrate_rec_using_table (H_fn_alt, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
1012
-      //answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
1013
-      //answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, 1);
1014
-      answer += (Integrate_optimal_using_table (H_fn_mid_opt, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, 1.0e-32, Npts_K)).integ_est;
1015
-
1016
-    //return(prefactor * Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, req_prec, max_rec));
1017
-    //return(prefactor * Riemann_Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, 500));
892
+      answer += (Integrate_optimal_using_table (H_fn_mid_opt, args_to_H, 2, Itable, Kdomain.xmin(idom),
893
+						Kdomain.xmax(idom), req_prec, 1.0e-32, Npts_K)).integ_est;
894
+
1018 895
     return (prefactor * answer);
1019 896
   }
1020 897
 
@@ -1070,11 +947,9 @@ namespace ABACUS {
1070 947
 
1071 948
     Vect_DP args_to_SF_4p_kwKW = args;
1072 949
     DP omegamin = 0.5 * wmin_4p (args[0]);
1073
-    //DP omegamax = 0.5 * wmax_4p (args[0]);
1074 950
 
1075 951
     args_to_SF_4p_kwKW[1] = omegamin * cosh(args[1]);
1076 952
 
1077
-    //return((omegamax - omegamin) * sin(args[1]) * SF_4p_kwKW_opt (args_to_SF_4p_kwKW, Itable));
1078 953
     return(omegamin * sinh(args[1]) * SF_4p_kwKW_opt (args_to_SF_4p_kwKW, Itable));
1079 954
   }
1080 955
 
@@ -1117,7 +992,8 @@ namespace ABACUS {
1117 992
 
1118 993
   /******************************************************************************************/
1119 994
 
1120
-  void Translate_raw_4p_data (DP k, int dim_w, const char* SFraw_Cstr, const char* SF_Cstr, const char* SFsrc_Cstr, I_table Itable)
995
+  void Translate_raw_4p_data (DP k, int dim_w, const char* SFraw_Cstr, const char* SF_Cstr,
996
+			      const char* SFsrc_Cstr, I_table Itable)
1121 997
   {
1122 998
     DP omegamin = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
1123 999
     DP omegamax = 0.5 * wmax_4p (k);
@@ -1127,7 +1003,6 @@ namespace ABACUS {
1127 1003
     DP alpha_in_old = -1.0;
1128 1004
     DP SF_in_old = -1.0;
1129 1005
 
1130
-    //int dim_w = int(pow(3.0, max_rec_w + 2));
1131 1006
     DP* alpha = new DP[dim_w];
1132 1007
     DP* omega = new DP[dim_w];
1133 1008
     DP* SF_4p_dat = new DP[dim_w];
@@ -1167,8 +1042,6 @@ namespace ABACUS {
1167 1042
 
1168 1043
     QuickSort (omega, index, 0, dim_w - 1);
1169 1044
 
1170
-    //for (int j = 0; j < dim_w; ++j) cout << j << "\t" << omega[j] << "\t" << index[j] << endl;
1171
-
1172 1045
     DP fixed_k_sr_2p = 0.0;
1173 1046
     DP fixed_k_sr_4p = 0.0;
1174 1047
     DP full_sr_2p = 0.0;
@@ -1199,9 +1072,12 @@ namespace ABACUS {
1199 1072
       full_sr_2p += Jac_dalpha * SF_2p_dat[index[i] ];
1200 1073
     }
1201 1074
 
1202
-    Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[dim_w - 2] ]) * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
1203
-    fixed_k_sr_4p += Jac_dalpha * (omega[dim_w - 2] * SF_4p_dat[index[dim_w - 2] ] + omega[dim_w - 1] * SF_4p_dat[index[dim_w - 1] ]);
1204
-    fixed_k_sr_2p += Jac_dalpha * (omega[dim_w - 2] * SF_2p_dat[index[dim_w - 2] ] + omega[dim_w - 1] * SF_2p_dat[index[dim_w - 1] ]);
1075
+    Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[dim_w - 2] ])
1076
+      * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
1077
+    fixed_k_sr_4p += Jac_dalpha * (omega[dim_w - 2] * SF_4p_dat[index[dim_w - 2] ]
1078
+				   + omega[dim_w - 1] * SF_4p_dat[index[dim_w - 1] ]);
1079
+    fixed_k_sr_2p += Jac_dalpha * (omega[dim_w - 2] * SF_2p_dat[index[dim_w - 2] ]
1080
+				   + omega[dim_w - 1] * SF_2p_dat[index[dim_w - 1] ]);
1205 1081
     full_sr_4p += Jac_dalpha * (SF_4p_dat[index[dim_w - 2] ] + SF_4p_dat[index[dim_w - 1] ]);
1206 1082
     full_sr_2p += Jac_dalpha * (SF_2p_dat[index[dim_w - 2] ] + SF_2p_dat[index[dim_w - 1] ]);
1207 1083
 
@@ -1234,19 +1110,18 @@ namespace ABACUS {
1234 1110
     return;
1235 1111
   }
1236 1112
 
1237
-  void Translate_raw_4p_data_cosh (DP k, int dim_w, const char* SFraw_Cstr, const char* SF_Cstr, const char* SFsrc_Cstr, I_table Itable)
1113
+  void Translate_raw_4p_data_cosh (DP k, int dim_w, const char* SFraw_Cstr, const char* SF_Cstr,
1114
+				   const char* SFsrc_Cstr, I_table Itable)
1238 1115
   {
1239 1116
     // Here, omega = omegamin * cosh(alpha)
1240 1117
 
1241 1118
     DP omegamin = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
1242
-    //DP omegamax = 0.5 * wmax_4p (k);
1243 1119
 
1244 1120
     DP alpha_in;
1245 1121
     DP SF_in;
1246 1122
     DP alpha_in_old = -1.0;
1247 1123
     DP SF_in_old = -1.0;
1248 1124
 
1249
-    //int dim_w = int(pow(3.0, max_rec_w + 2));
1250 1125
     DP* alpha = new DP[dim_w];
1251 1126
     DP* omega = new DP[dim_w];
1252 1127
     DP* SF_4p_dat = new DP[dim_w];
@@ -1267,11 +1142,9 @@ namespace ABACUS {
1267 1142
       SFraw >> alpha_in >> SF_in;
1268 1143
 
1269 1144
       alpha[i] = alpha_in;
1270
-      //omega[i] = omegamin + (omegamax - omegamin) * (1.0 - cos(alpha_in));
1271 1145
       omega[i] = omegamin * cosh(alpha_in);
1272 1146
 
1273 1147
       // CAREFUL !!!  SF_in is S (k, w), and we want S (k, omega) = 2 S(k, w)
1274
-      //SF_4p_dat[i] = 2.0 * SF_in/((omegamax - omegamin) * sin(alpha_in));
1275 1148
       SF_4p_dat[i] = 2.0 * SF_in/(omegamin * sinh(alpha_in));
1276 1149
 
1277 1150
       SF_2p_dat[i] = SF_2p (k, omega[i], Itable);  // This already is S(k, omega)
@@ -1288,13 +1161,10 @@ namespace ABACUS {
1288 1161
 
1289 1162
     QuickSort (omega, index, 0, dim_w - 1);
1290 1163
 
1291
-    //for (int j = 0; j < dim_w; ++j) cout << j << "\t" << omega[j] << "\t" << index[j] << endl;
1292
-
1293 1164
     DP fixed_k_sr_2p = 0.0;
1294 1165
     DP fixed_k_sr_4p = 0.0;
1295 1166
     DP full_sr_2p = 0.0;
1296 1167
     DP full_sr_4p = 0.0;
1297
-    //DP Jac_dalpha = 0.0;  // This is domega = (omegamax - omegamin) sin alpha dalpha
1298 1168
     DP Jac_dalpha = 0.0;  // This is domega = omegamin sinh alpha dalpha
1299 1169
 
1300 1170
     ofstream SF;
@@ -1307,7 +1177,6 @@ namespace ABACUS {
1307 1177
     SF.close();
1308 1178
 
1309 1179
     // Compute first moment sum rule
1310
-    //Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[1] ]) * 0.5 * (alpha[index[2] ] - alpha[index[0] ]);
1311 1180
     Jac_dalpha = omegamin * sinh(alpha[index[1] ]) * 0.5 * (alpha[index[2] ] - alpha[index[0] ]);
1312 1181
     fixed_k_sr_4p += Jac_dalpha * (omega[0] * SF_4p_dat[index[0] ] + omega[1] * SF_4p_dat[index[1] ]);
1313 1182
     fixed_k_sr_2p += Jac_dalpha * (omega[0] * SF_2p_dat[index[0] ] + omega[1] * SF_2p_dat[index[1] ]);
@@ -1315,7 +1184,6 @@ namespace ABACUS {
1315 1184
     full_sr_2p += Jac_dalpha * (SF_2p_dat[index[0] ] + SF_2p_dat[index[1] ]);
1316 1185
 
1317 1186
     for (int i = 2; i < dim_w - 2; ++i) {
1318
-      //Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[i] ]) * 0.5 * (alpha[index[i + 1] ] - alpha[index[i - 1] ]);
1319 1187
       Jac_dalpha = omegamin * sinh(alpha[index[i] ]) * 0.5 * (alpha[index[i + 1] ] - alpha[index[i - 1] ]);
1320 1188
       fixed_k_sr_4p += Jac_dalpha * omega[i] * SF_4p_dat[index[i] ];
1321 1189
       fixed_k_sr_2p += Jac_dalpha * omega[i] * SF_2p_dat[index[i] ];
@@ -1323,10 +1191,11 @@ namespace ABACUS {
1323 1191
       full_sr_2p += Jac_dalpha * SF_2p_dat[index[i] ];
1324 1192
     }
1325 1193
 
1326
-    //Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[dim_w - 2] ]) * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
1327 1194
     Jac_dalpha = omegamin * sinh(alpha[index[dim_w - 2] ]) * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
1328
-    fixed_k_sr_4p += Jac_dalpha * (omega[dim_w - 2] * SF_4p_dat[index[dim_w - 2] ] + omega[dim_w - 1] * SF_4p_dat[index[dim_w - 1] ]);
1329
-    fixed_k_sr_2p += Jac_dalpha * (omega[dim_w - 2] * SF_2p_dat[index[dim_w - 2] ] + omega[dim_w - 1] * SF_2p_dat[index[dim_w - 1] ]);
1195
+    fixed_k_sr_4p += Jac_dalpha * (omega[dim_w - 2] * SF_4p_dat[index[dim_w - 2] ]
1196
+				   + omega[dim_w - 1] * SF_4p_dat[index[dim_w - 1] ]);
1197
+    fixed_k_sr_2p += Jac_dalpha * (omega[dim_w - 2] * SF_2p_dat[index[dim_w - 2] ]
1198
+				   + omega[dim_w - 1] * SF_2p_dat[index[dim_w - 1] ]);
1330 1199
     full_sr_4p += Jac_dalpha * (SF_4p_dat[index[dim_w - 2] ] + SF_4p_dat[index[dim_w - 1] ]);
1331 1200
     full_sr_2p += Jac_dalpha * (SF_2p_dat[index[dim_w - 2] ] + SF_2p_dat[index[dim_w - 1] ]);
1332 1201
 
@@ -1365,19 +1234,22 @@ namespace ABACUS {
1365 1234
   {
1366 1235
     stringstream SFraw_stringstream;
1367 1236
     string SFraw_string;
1368
-    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".raw";
1237
+    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w
1238
+		       << "_max_rec_" << max_rec << ".raw";
1369 1239
     SFraw_string = SFraw_stringstream.str();
1370 1240
     const char* SFraw_Cstr = SFraw_string.c_str();
1371 1241
 
1372 1242
     stringstream SF_stringstream;
1373 1243
     string SF_string;
1374
-    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".dat";
1244
+    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w
1245
+		    << "_max_rec_" << max_rec << ".dat";
1375 1246
     SF_string = SF_stringstream.str();
1376 1247
     const char* SF_Cstr = SF_string.c_str();
1377 1248
 
1378 1249
     stringstream SFsrc_stringstream;
1379 1250
     string SFsrc_string;
1380
-    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".src";
1251
+    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w
1252
+		       << "_max_rec_" << max_rec << ".src";
1381 1253
     SFsrc_string = SFsrc_stringstream.str();
1382 1254
     const char* SFsrc_Cstr = SFsrc_string.c_str();
1383 1255
 
@@ -1386,16 +1258,13 @@ namespace ABACUS {
1386 1258
     ofstream SFsrc_outfile;
1387 1259
     SFsrc_outfile.open(SFsrc_Cstr, ofstream::app);
1388 1260
 
1389
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
1390
-    //DP omegamax_used = 0.5 * wmax_4p (k);
1391
-
1392 1261
     Vect_DP args_to_SF(4);
1393 1262
     args_to_SF[0] = k;
1394 1263
     args_to_SF[1] = 0.0;  // integration variable
1395 1264
     args_to_SF[2] = req_prec;
1396 1265
     args_to_SF[3] = DP(max_rec);
1397 1266
 
1398
-    //DP answer = Integrate_rec_using_table (SF_4p_kwKW, args_to_SF, 1, Itable, omegamin_used, omegamax_used, req_prec, max_rec, SF_outfile);
1267
+
1399 1268
     // Version using omega = omegamin + (omegamax - omegamin) * (1-cos(alpha))
1400 1269
     DP answer = Integrate_rec_using_table (SF_4p_kwKW_alpha, args_to_SF, 1, Itable, 0.0, 0.5*PI, req_prec, max_rec_w, SFraw_outfile)/twoPI;
1401 1270
 
@@ -1405,7 +1274,6 @@ namespace ABACUS {
1405 1274
     SFsrc_outfile.close();
1406 1275
 
1407 1276
     // Translate raw data into SF_4p (k,omega) data
1408
-
1409 1277
     Translate_raw_4p_data (k, int(pow(3.0, max_rec_w + 2)), SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
1410 1278
 
1411 1279
     return(answer);
@@ -1415,22 +1283,22 @@ namespace ABACUS {
1415 1283
   {
1416 1284
     stringstream SFraw_stringstream;
1417 1285
     string SFraw_string;
1418
-    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".raw";
1419
-    //SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.raw";
1286
+    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_"
1287
+		       << Npts_K << "_" << Npts_W << ".raw";
1420 1288
     SFraw_string = SFraw_stringstream.str();
1421 1289
     const char* SFraw_Cstr = SFraw_string.c_str();
1422 1290
 
1423 1291
     stringstream SF_stringstream;
1424 1292
     string SF_string;
1425
-    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".dat";
1426
-    //SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.dat";
1293
+    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_"
1294
+		    << Npts_K << "_" << Npts_W << ".dat";
1427 1295
     SF_string = SF_stringstream.str();
1428 1296
     const char* SF_Cstr = SF_string.c_str();
1429 1297
 
1430 1298
     stringstream SFsrc_stringstream;
1431 1299
     string SFsrc_string;
1432
-    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".src";
1433
-    //SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.src";
1300
+    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_"
1301
+		       << Npts_K << "_" << Npts_W << ".src";
1434 1302
     SFsrc_string = SFsrc_stringstream.str();
1435 1303
     const char* SFsrc_Cstr = SFsrc_string.c_str();
1436 1304
 
@@ -1439,9 +1307,6 @@ namespace ABACUS {
1439 1307
     ofstream SFsrc_outfile;
1440 1308
     SFsrc_outfile.open(SFsrc_Cstr);
1441 1309
 
1442
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
1443
-    //DP omegamax_used = 0.5 * wmax_4p (k);
1444
-
1445 1310
     Vect_DP args_to_SF(5);
1446 1311
     args_to_SF[0] = k;
1447 1312
     args_to_SF[1] = 0.0;  // integration variable
@@ -1450,9 +1315,11 @@ namespace ABACUS {
1450 1315
     args_to_SF[4] = DP(Npts_W);
1451 1316
 
1452 1317
     // Version using omega = omegamin + (omegamax - omegamin) * (1-cos(alpha))
1453
-    Integral_result answer = Integrate_optimal_using_table (SF_4p_kwKW_alpha_opt, args_to_SF, 1, Itable, 0.0, 0.5*PI, req_prec, 1.0e-32, Npts_w, SFraw_outfile);
1318
+    Integral_result answer = Integrate_optimal_using_table (SF_4p_kwKW_alpha_opt, args_to_SF, 1,
1319
+							    Itable, 0.0, 0.5*PI, req_prec, 1.0e-32, Npts_w, SFraw_outfile);
1454 1320
     // Version using omega = omegamin * cosh(alpha)
1455
-    //Integral_result answer = Integrate_optimal_using_table (SF_4p_kwKW_cosh_alpha_opt, args_to_SF, 1, Itable, 0.0, acosh(wmax_4p(k)/wmin_4p(k)), req_prec, 1.0e-32, Npts_w, SFraw_outfile);
1321
+    //Integral_result answer = Integrate_optimal_using_table (SF_4p_kwKW_cosh_alpha_opt, args_to_SF, 1, Itable, 0.0,
1322
+    //acosh(wmax_4p(k)/wmin_4p(k)), req_prec, 1.0e-32, Npts_w, SFraw_outfile);
1456 1323
     answer.integ_est /= twoPI;
1457 1324
     answer.abs_prec /= twoPI;
1458 1325
 
@@ -1462,9 +1329,7 @@ namespace ABACUS {
1462 1329
     SFsrc_outfile.close();
1463 1330
 
1464 1331
     // Translate raw data into SF_4p (k,omega) data
1465
-
1466 1332
     Translate_raw_4p_data (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
1467
-    //Translate_raw_4p_data_cosh (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
1468 1333
 
1469 1334
     return(answer);
1470 1335
   }
@@ -1578,7 +1443,8 @@ namespace ABACUS {
1578 1443
 
1579 1444
     stringstream SF_stringstream;
1580 1445
     string SF_string;
1581
-    SF_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec << "_max_rec_" << max_rec << ".dat";
1446
+    SF_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec
1447
+		    << "_max_rec_" << max_rec << ".dat";
1582 1448
     SF_string = SF_stringstream.str();
1583 1449
     const char* SF_Cstr = SF_string.c_str();
1584 1450
 
@@ -1623,7 +1489,7 @@ namespace ABACUS {
1623 1489
     stringstream SRC_stringstream;
1624 1490
     string SRC_string;
1625 1491
     SRC_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec
1626
-		    << "_max_rec_" << max_rec << ".src";
1492
+		     << "_max_rec_" << max_rec << ".src";
1627 1493
     SRC_string = SRC_stringstream.str();
1628 1494
     const char* SRC_Cstr = SRC_string.c_str();
1629 1495
 
@@ -1638,7 +1504,7 @@ namespace ABACUS {
1638 1504
     stringstream SR1_stringstream;
1639 1505
     string SR1_string;
1640 1506
     SR1_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec
1641
-		    << "_max_rec_" << max_rec << ".sr1";
1507
+		     << "_max_rec_" << max_rec << ".sr1";
1642 1508
     SR1_string = SR1_stringstream.str();
1643 1509
     const char* SR1_Cstr = SR1_string.c_str();
1644 1510
 
@@ -1714,7 +1580,7 @@ namespace ABACUS {
1714 1580
     stringstream SRC_stringstream;
1715 1581
     string SRC_string;
1716 1582
     SRC_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec
1717
-		    << "_Npts_K_" << Npts_K << "_Npts_W_" << Npts_W << ".src";
1583
+		     << "_Npts_K_" << Npts_K << "_Npts_W_" << Npts_W << ".src";
1718 1584
     SRC_string = SRC_stringstream.str();
1719 1585
     const char* SRC_Cstr = SRC_string.c_str();
1720 1586
 
@@ -1729,7 +1595,7 @@ namespace ABACUS {
1729 1595
     stringstream SR1_stringstream;
1730 1596
     string SR1_string;
1731 1597
     SR1_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec
1732
-		    << "_Npts_K_" << Npts_K << "_Npts_W_" << Npts_W << ".sr1";
1598
+		     << "_Npts_K_" << Npts_K << "_Npts_W_" << Npts_W << ".sr1";
1733 1599
     SR1_string = SR1_stringstream.str();
1734 1600
     const char* SR1_Cstr = SR1_string.c_str();
1735 1601
 
@@ -1748,7 +1614,4 @@ namespace ABACUS {
1748 1614
   }
1749 1615
 
1750 1616
 
1751
-
1752
-
1753
-
1754 1617
 } // namespace ABACUS

+ 6
- 9
src/XXX_VOA/XXX_VOA_par.cc View File

@@ -26,22 +26,22 @@ namespace ABACUS {
26 26
   {
27 27
     stringstream SFraw_stringstream;
28 28
     string SFraw_string;
29
-    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".raw";
30
-    //SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.raw";
29
+    SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K
30
+		       << "_" << Npts_W << ".raw";
31 31
     SFraw_string = SFraw_stringstream.str();
32 32
     const char* SFraw_Cstr = SFraw_string.c_str();
33 33
 
34 34
     stringstream SF_stringstream;
35 35
     string SF_string;
36
-    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".dat";
37
-    //SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.dat";
36
+    SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K
37
+		    << "_" << Npts_W << ".dat";
38 38
     SF_string = SF_stringstream.str();
39 39
     const char* SF_Cstr = SF_string.c_str();
40 40
 
41 41
     stringstream SFsrc_stringstream;
42 42
     string SFsrc_string;
43
-    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".src";
44
-    //SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.src";
43
+    SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K
44
+		       << "_" << Npts_W << ".src";
45 45
     SFsrc_string = SFsrc_stringstream.str();
46 46
     const char* SFsrc_Cstr = SFsrc_string.c_str();
47 47
 
@@ -50,8 +50,6 @@ namespace ABACUS {
50 50
     ofstream SFsrc_outfile;
51 51
     SFsrc_outfile.open(SFsrc_Cstr);
52 52
 
53
-    //DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
54
-    //DP omegamax_used = 0.5 * wmax_4p (k);
55 53
 
56 54
     Vect_DP args_to_SF(5);
57 55
     args_to_SF[0] = k;
@@ -73,7 +71,6 @@ namespace ABACUS {
73 71
     SFsrc_outfile.close();
74 72
 
75 73
     // Translate raw data into SF_4p (k,omega) data
76
-
77 74
     Translate_raw_4p_data (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
78 75
     //Translate_raw_4p_data_cosh (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
79 76
 

+ 0
- 2
src/XXX_VOA/XXX_h0_v2.cc View File

@@ -198,8 +198,6 @@ namespace ABACUS {
198 198
 	      omega = -0.5 * PI * (sinp0 + sinp1 + sinp2 + sin(p[3]));
199 199
 	      iomega = int(omega * Npts_o/omegamax);
200 200
 
201
-	      //cout << ik << "\t" << iomega << endl;
202
-
203 201
 	      J_fn_cont = J_fn (p, req_prec, Itable);
204 202
 	      sum_J_fn += (ik == Npts_p ? 1.0 : 2.0) * J_fn_cont;
205 203
 

+ 48
- 120
src/XXZ_VOA/XXZ_VOA.cc View File

@@ -67,7 +67,6 @@ namespace ABACUS {
67 67
 
68 68
     return(answer);
69 69
 
70
-    //return(sinh(args[0]*(1.0 + args[2])) * sinh(args[0]) * cos(4.0 * args[0] * args[1])/(args[0] * sinh(args[0] * args[2]) * pow(cosh(args[0]), 2.0)));
71 70
   }
72 71
 
73 72
   DP I_xi_11_integral (DP xi, DP rho, DP req_prec, int max_nr_pts, DP t1bar)
@@ -106,8 +105,8 @@ namespace ABACUS {
106 105
   }
107 106
 
108 107
   /*
109
-  inline DP Integrand_xi_2 (Vect_DP args)
110
-  {
108
+    inline DP Integrand_xi_2 (Vect_DP args)
109
+    {
111 110
     // This version is used for rho <= 1
112 111
 
113 112
     // args[0] corresponds to t, args[1] to rho, args[2] to xi
@@ -116,30 +115,34 @@ namespace ABACUS {
116 115
 
117 116
     if (args[0] * args[2] <= 1.0) {
118 117
 
119
-      if (args[0] <= 1.0) {
120
-	answer = sinh(args[0] * (args[2] + 1.0)) * pow(sin(2.0 * args[0] * args[1]), 2.0)
121
-	  /(args[0] * sinh(args[2] * args[0]) * sinh(args[0]) * pow(cosh(args[0]), 2.0));
122
-      }
118
+    if (args[0] <= 1.0) {
119
+    answer = sinh(args[0] * (args[2] + 1.0)) * pow(sin(2.0 * args[0] * args[1]), 2.0)
120
+    /(args[0] * sinh(args[2] * args[0]) * sinh(args[0]) * pow(cosh(args[0]), 2.0));
121
+    }
123 122
 
124
-      else if (args[0] >= 1.0) {
125
-	DP expm2t = exp(-2.0 * args[0]);
126
-	DP expm2txi = exp(-2.0*args[0]*args[2]);
127
-	//answer = 8.0 * expm2t * pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
128
-	answer = 8.0 * (1.0 - expm2t*expm2txi) * expm2t *
129
-	  pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
130
-      }
123
+    else if (args[0] >= 1.0) {
124
+    DP expm2t = exp(-2.0 * args[0]);
125
+    DP expm2txi = exp(-2.0*args[0]*args[2]);
126
+    //answer = 8.0 * expm2t * pow(sin(2.0 * args[0] * args[1]), 2.0)
127
+    /(args[0] * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
128
+    answer = 8.0 * (1.0 - expm2t*expm2txi) * expm2t *
129
+    pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t)
130
+    * (1.0 + expm2t) * (1.0 + expm2t));
131
+    }
131 132
 
132 133
     DP expm2t = exp(-2.0 * args[0]);
133 134
     DP expm2txi = exp(-2.0*args[0]*args[2]);
134
-    //answer = 8.0 * expm2t * pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
135
+    //answer = 8.0 * expm2t * pow(sin(2.0 * args[0] * args[1]), 2.0)
136
+    /(args[0] * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
135 137
     answer = 8.0 * (1.0 - expm2t*expm2txi) * expm2t *
136
-      pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
138
+    pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t)
139
+    * (1.0 + expm2t) * (1.0 + expm2t));
137 140
 
138 141
     return(answer);
139 142
 
140
-      ... NOT USED
143
+    ... NOT USED
141 144
 
142
-  }
145
+    }
143 146
   */
144 147
 
145 148
   inline DP Integrand_xi_22 (Vect_DP args)
@@ -153,7 +156,8 @@ namespace ABACUS {
153 156
     else if (args[0] >= 1.0) {
154 157
       DP expm2t = exp(-2.0 * args[0]);
155 158
       DP expm2txi = exp(-2.0*args[0]*args[2]);
156
-      answer = 4.0 * expm2t * (1.0 + expm2txi) * pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 + expm2t) * (1.0 + expm2t));
159
+      answer = 4.0 * expm2t * (1.0 + expm2txi) * pow(sin(2.0 * args[0] * args[1]), 2.0)
160
+	/(args[0] * (1.0 - expm2txi) * (1.0 + expm2t) * (1.0 + expm2t));
157 161
     }
158 162
     return(answer);
159 163
   }
@@ -170,9 +174,6 @@ namespace ABACUS {
170 174
 
171 175
     DP answer = 0.0;
172 176
 
173
-    //if (rho_used <= 1.0) answer = (Integrate_optimal (Integrand_xi_2, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts)).integ_est;
174
-
175
-    //else
176 177
     answer = PI * rho + log(0.5 * (1.0 + exp(-2.0 * PI * rho_used))) // This is I^{(21)}
177 178
       + (Integrate_optimal (Integrand_xi_22, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts)).integ_est;
178 179
 
@@ -201,22 +202,20 @@ namespace ABACUS {
201 202
   {
202 203
     // Careful !  This is S(k, omega) = S (k, w) |dw/domega| = 2 S(k, w)
203 204
 
204
-    DP w = 2.0 * omega;  // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
205
+    DP w = 2.0 * omega;
206
+    // Rescale energies by factor 2 because of definitions of H_XXX (omega:  S.S;  w: 0.5 * sigma.sigma = 2 S.S)
205 207
 
206 208
     DP vF = Fermi_velocity_XXZ_h0 (Delta); // in units of omega
207 209
 
208
-    //DP wu = twoPI * sin(0.5 * k);
209 210
     DP wu = 4.0 * vF * sin(0.5 * k);
210
-    //DP wl = PI * fabs(sin(k));
211 211
     DP wl = 2.0 * vF * fabs(sin(k));
212 212
 
213 213
     DP rho = acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI;
214 214
     DP xi = PI/acos(Delta) - 1.0;
215 215
     // Factor of 2:  return S(k, omega), not S(k, w)
216
-    // 0.25 factor:  1/4 * 2 * 1/2, where 1/4 comes from Bougourzi, 2 is the Jacobian |dw/domega| and 1/2 is S^{zz} = 1/2 * S^{+-}
217
-    //return(w < wu && w > wl ? 2.0 * 0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI))/sqrt(wu * wu - w * w) : 0.0);
216
+    // 0.25 factor:  1/4 * 2 * 1/2, where 1/4 comes from Bougourzi, 2 is the Jacobian |dw/domega|
217
+    // and 1/2 is S^{zz} = 1/2 * S^{+-}
218 218
     DP expmtwoPIrhooverxi = exp(-twoPI * rho/xi);
219
-    //return(w < wu && w > wl ? 2.0 * exp(-Itable.Return_val (rho))/(sqrt(wu * wu - w * w) * (cosh(twoPI * rho/xi) + cos(PI/xi))) : 0.0);
220 219
     return(w < wu && w > wl ? 2.0 * pow(1.0 + 1.0/xi, 2.0) * exp(-Itable.Return_val (rho))
221 220
 	   * expmtwoPIrhooverxi/(sqrt(wu * wu - w * w)
222 221
 				 * (0.5 * (1.0 + expmtwoPIrhooverxi * expmtwoPIrhooverxi) + expmtwoPIrhooverxi * cos(PI/xi)))
@@ -236,30 +235,6 @@ namespace ABACUS {
236 235
 
237 236
     return(Szz_XXZ_h0_2spinons (Delta, args[0], args[1], Itable));
238 237
 
239
-    /*
240
-
241
-    // This uses args[0] = k, args[1] = w, args[2] = xi
242
-
243
-    DP Delta = cos(PI/(args[2] + 1.0));
244
-
245
-    DP vF = Fermi_velocity_XXZ_h0 (Delta); // in units of omega
246
-
247
-    //DP wu = twoPI * sin(0.5 * k);
248
-    DP wu = 4.0 * vF * sin(0.5 * args[0]);
249
-    //DP wl = PI * fabs(sin(k));
250
-    DP wl = 2.0 * vF * fabs(sin(args[0]));
251
-
252
-    DP rho = acosh(sqrt((wu * wu - wl * wl)/(args[1] * args[1] - wl * wl)))/PI;
253
-    DP expmtwoPIrhooverxi = exp(-twoPI * rho/args[2]);
254
-
255
-    // 0.5 factor:  1 from Bougourzi, and 1/2 is S^{zz} = 1/2 * S^{+-}
256
-    return(args[1] < wu && args[1] > wl ?
257
-	   //0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(args[1] * args[1] - wl * wl)))/PI))/sqrt(wu * wu - args[1] * args[1]) : 0.0);
258
-	   pow(1.0 + 1.0/args[2], 2.0) * exp(-Itable.Return_val (rho)) * expmtwoPIrhooverxi
259
-	   /(sqrt(wu * wu - args[1] * args[1])
260
-	     * (0.5 * (1.0 + expmtwoPIrhooverxi * expmtwoPIrhooverxi) + expmtwoPIrhooverxi * cos(PI/args[2]))) : 0.0);
261
-
262
-    */
263 238
   }
264 239
 
265 240
   DP Szz_XXZ_h0_2spinons_alt (Vect_DP args, Integral_table Itable)
@@ -283,30 +258,6 @@ namespace ABACUS {
283 258
     DP Jacobian = sqrt(omega * omega - omegalow * omegalow);
284 259
 
285 260
     return(Jacobian * Szz_XXZ_h0_2spinons (Delta, args[0], omega, Itable));
286
-
287
-    /*
288
-    //DP wu = twoPI * sin(0.5 * k);
289
-    DP wu = 4.0 * vF * sin(0.5 * args[0]);
290
-    //DP wl = PI * fabs(sin(k));
291
-    DP wl = 2.0 * vF * fabs(sin(args[0]));
292
-
293
-    //DP w = wu * cos(args[1]);
294
-    //DP factor = 1.0;
295
-    DP w = wl * cosh(args[1]);
296
-
297
-    if (w >= wu || w <= wl) return(0.0);
298
-
299
-    DP factor = sqrt((w * w - wl * wl)/(wu * wu - w * w));
300
-
301
-    DP rho = acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI;
302
-    DP expmtwoPIrhooverxi = exp(-twoPI * rho/args[2]);
303
-
304
-    // 0.5 factor:  1 from Bougourzi, and 1/2 is S^{zz} = 1/2 * S^{+-}
305
-    //return(factor * 0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI)));
306
-    return(pow(1.0 + 1.0/args[2], 2.0) * factor
307
-	   * exp(-Itable.Return_val (rho)) * expmtwoPIrhooverxi/(0.5 * (1.0 + expmtwoPIrhooverxi * expmtwoPIrhooverxi) + expmtwoPIrhooverxi * cos(PI/args[2])));
308
-	   */
309
-
310 261
   }
311 262
 
312 263
   DP Szz_XXZ_h0_2spinons_omega (Vect_DP args, Integral_table Itable)
@@ -450,7 +401,8 @@ namespace ABACUS {
450 401
     args[0] = 0.0;
451 402
     args[1] = xi;
452 403
 
453
-    return(-0.25 * sqrt(1.0 - Delta * Delta) * (2.0/acos(Delta)) * 2.0 * (Integrate_optimal (Integrand_GSE_XXZ_h0, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts).integ_est));
404
+    return(-0.25 * sqrt(1.0 - Delta * Delta) * (2.0/acos(Delta)) * 2.0
405
+	   * (Integrate_optimal (Integrand_GSE_XXZ_h0, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts).integ_est));
454 406
   }
455 407
 
456 408
   DP Integrand_2_fSR_XXZ_h0 (Vect_DP args)
@@ -474,8 +426,10 @@ namespace ABACUS {
474 426
     args[0] = 0.0;
475 427
     args[1] = xi;
476 428
 
477
-    DP Xavg = -(0.25/(acos(Delta) * sqrt(1.0 - Delta * Delta))) * 2.0 * (Integrate_optimal (Integrand_GSE_XXZ_h0, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts).integ_est)
478
-      + 0.25 * (Delta/pow(acos(Delta), 2.0)) * 2.0 * (Integrate_optimal (Integrand_2_fSR_XXZ_h0, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts).integ_est);
429
+    DP Xavg = -(0.25/(acos(Delta) * sqrt(1.0 - Delta * Delta))) * 2.0
430
+      * (Integrate_optimal (Integrand_GSE_XXZ_h0, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts).integ_est)
431
+      + 0.25 * (Delta/pow(acos(Delta), 2.0)) * 2.0
432
+      * (Integrate_optimal (Integrand_2_fSR_XXZ_h0, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts).integ_est);
479 433
 
480 434
     return (-2.0 * (1.0 - cos(k)) * Xavg);
481 435
   }
@@ -495,7 +449,9 @@ namespace ABACUS {
495 449
     args_to_SF_2p[2] = PI/acos(Delta) - 1.0;
496 450
     args_to_SF_2p[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
497 451
 
498
-    return(((Integrate_optimal_using_table (Szz_XXZ_h0_2spinons_omega, args_to_SF_2p, 1, Itable, omegalow, omegaup, req_prec, req_prec, max_nr_pts)).integ_est/twoPI)/Fixed_k_sumrule_omega_Szz_XXZ_h0(Delta, k, req_prec, max_nr_pts));
452
+    return(((Integrate_optimal_using_table (Szz_XXZ_h0_2spinons_omega, args_to_SF_2p, 1, Itable,
453
+					    omegalow, omegaup, req_prec, req_prec, max_nr_pts)).integ_est/twoPI)
454
+	   /Fixed_k_sumrule_omega_Szz_XXZ_h0(Delta, k, req_prec, max_nr_pts));
499 455
   }
500 456
 
501 457
   DP Szz_XXZ_h0_2spinons_check_fixed_k_Szz_sumrule_alt (DP Delta, DP k, DP req_prec, int max_nr_pts, Integral_table Itable)
@@ -513,7 +469,9 @@ namespace ABACUS {
513 469
     args_to_SF_2p[2] = PI/acos(Delta) - 1.0;
514 470
     args_to_SF_2p[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
515 471
 
516
-    return(((Integrate_optimal_using_table (Szz_XXZ_h0_2spinons_omega_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(omegaup/omegalow), req_prec, req_prec, max_nr_pts)).integ_est/twoPI)/Fixed_k_sumrule_omega_Szz_XXZ_h0(Delta, k, req_prec, max_nr_pts));
472
+    return(((Integrate_optimal_using_table (Szz_XXZ_h0_2spinons_omega_alt, args_to_SF_2p, 1, Itable,
473
+					    0.0, acosh(omegaup/omegalow), req_prec, req_prec, max_nr_pts)).integ_est/twoPI)
474
+	   /Fixed_k_sumrule_omega_Szz_XXZ_h0(Delta, k, req_prec, max_nr_pts));
517 475
   }
518 476
 
519 477
 
@@ -527,7 +485,8 @@ namespace ABACUS {
527 485
 
528 486
     stringstream SF_stringstream;
529 487
     string SF_string;
530
-    SF_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega << "_ommax_" << omegamax << ".dat";
488
+    SF_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega
489
+		    << "_ommax_" << omegamax << ".dat";
531 490
     SF_string = SF_stringstream.str();
532 491
     const char* SF_Cstr = SF_string.c_str();
533 492
 
@@ -571,7 +530,8 @@ namespace ABACUS {
571 530
 
572 531
     stringstream SRC_stringstream;
573 532
     string SRC_string;
574
-    SRC_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega << "_ommax_" << omegamax << ".src";
533
+    SRC_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega
534
+		     << "_ommax_" << omegamax << ".src";
575 535
     SRC_string = SRC_stringstream.str();
576 536
     const char* SRC_Cstr = SRC_string.c_str();
577 537
 
@@ -585,7 +545,8 @@ namespace ABACUS {
585 545
 
586 546
     stringstream SR1_stringstream;
587 547
     string SR1_string;
588
-    SR1_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega << "_ommax_" << omegamax << ".sr1";
548
+    SR1_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega
549
+		     << "_ommax_" << omegamax << ".sr1";
589 550
     SR1_string = SR1_stringstream.str();
590 551
     const char* SR1_Cstr = SR1_string.c_str();
591 552
 
@@ -606,9 +567,7 @@ namespace ABACUS {
606 567
 
607 568
     for (int iK = 1; iK < dim_K; ++iK)
608 569
       SR1_outfile << iK << "\t" << K[iK] << "\t" << sr1[iK] * omegamax/(twoPI * Nomega)
609
-	//<< "\t" << -((1.0 - cos(K[iK])) * 2.0 * (0.25 - log(2.0))/3.0) << "\t"
610 570
 		  << "\t" << (1.0 - cos(K[iK])) * sr1factor << "\t"
611
-	//<< -sr1[iK] * omegamax/(twoPI * Nomega)/((1.0 - cos(K[iK])) * 2.0 * (0.25 - log(2.0))/3.0) << endl;
612 571
 		  << sr1[iK] * omegamax/(twoPI * Nomega)/((1.0 - cos(K[iK])) * sr1factor) << endl;
613 572
 
614 573
     SR1_outfile.close();
@@ -636,7 +595,9 @@ namespace ABACUS {
636 595
     DP omegaup = 2.0 * vF * sin(0.5 * K);
637 596
     DP omegalow = vF * fabs(sin(K));
638 597
 
639
-    for (int iw = 0; iw < Nomega; ++iw) omega[iw] = 0.99 * omegalow + (1.01 * omegaup - 0.99 * omegalow) * (iw + 0.5)/Nomega; // factor of 1.01: just to have zeroes on either side of continuum.
598
+    for (int iw = 0; iw < Nomega; ++iw)
599
+      omega[iw] = 0.99 * omegalow + (1.01 * omegaup - 0.99 * omegalow) * (iw + 0.5)/Nomega;
600
+    // factor of 1.01: just to have zeroes on either side of continuum.
640 601
 
641 602
     DP* SF_XXZ_2p_dat = new DP[Nomega];
642 603
 
@@ -658,41 +619,8 @@ namespace ABACUS {
658 619
 
659 620
     SF_outfile.close();
660 621
 
661
-    // Do sum rule files:
662
-    /*
663
-      NOT ACCURATE SINCE WE'RE PLOTTING SOMEWHAT OUTSIDE OF CONTINUUM AS WELL (to get nice figures)
664
-    stringstream SR1_stringstream;
665
-    string SR1_string;
666
-    SR1_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_Kover2PI_" << Kover2PI
667
-		     << "_Nom_" << Nomega << ".sr1";
668
-    SR1_string = SR1_stringstream.str();
669
-    const char* SR1_Cstr = SR1_string.c_str();
670
-
671
-    ofstream SR1_outfile;
672
-    SR1_outfile.open(SR1_Cstr);
673
-    SR1_outfile.precision(14);
674
-
675
-    // Figure out the f-sumrule factor:
676
-    int Nfsr = 600;
677
-    int Mfsr = 300;
678
-    DP Xavg = 0.0;
679
-    if (Delta > 0.0) Xavg = X_avg ('x', Delta, Nfsr, Mfsr);
680
-    else Xavg = 0.0;
681
-
682
-    DP sr1factor = 1.0;
683
-    if (Delta > 0.0) sr1factor = -2.0 * Xavg/Nfsr;
684
-    else sr1factor = 1.0;
685
-
686
-    SR1_outfile << Kover2PI << "\t" << sr1 * (omegaup - omegalow)/(twoPI * Nomega)
687
-		<< "\t" << (1.0 - cos(K)) * sr1factor << "\t"
688
-		<< sr1 * (omegaup - omegalow)/(twoPI * Nomega)/((1.0 - cos(K)) * sr1factor) << endl;
689
-
690
-    SR1_outfile.close();
691
-    */
692
-
693 622
     return;
694 623
   }
695 624
 
696 625
 
697
-
698 626
 } // namespace ABACUS

+ 50
- 107
src/YOUNG/Young_Tableau.cc View File

@@ -20,7 +20,8 @@ using namespace std;
20 20
 namespace ABACUS {
21 21
 
22 22
   Young_Tableau::Young_Tableau () : Nrows(0), Ncols(0), Row_L(0), Col_L(0), id(0LL), maxid(0LL),
23
-				    map(new long long int [1]), map_computed(false), idnr_reached(0LL), nboxes_reached(-1),
23
+				    map(new long long int [1]), map_computed(false),
24
+				    idnr_reached(0LL), nboxes_reached(-1),
24 25
 				    dimchoose(0), choose_table(0LL)
25 26
   {}
26 27
 
@@ -47,32 +48,11 @@ namespace ABACUS {
47 48
       }
48 49
 
49 50
     // Fill map with zeros:
50
-    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
51
+    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
52
+      map[i] = 0LL;
51 53
 
52 54
   }
53
-  /*  SEGFAULTS
54
-  Young_Tableau::Young_Tableau (int Nr, int Nc, long long int idnr)
55
-    : Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(idnr),
56
-      maxid(choose_lli(Nr + Nc, Nc) - 1LL),
57
-      map(new long long int [YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
58
-      map_computed(false), idnr_reached(0LL), nboxes_reached(-1),
59
-      dimchoose (ABACUS::min(Nr, Nc) + 1),
60
-      choose_table(new long long int[(Nr + Nc + 1) * dimchoose])
61
-  {
62
-    // Constructs Young tableau of given idnr, if consistent with Nr, Nc.
63
-
64
-    // Construct the choose_table
65
-    for (int cti = 0; cti < Nr + Nc + 1; ++cti)
66
-      for (int ctj = 0; ctj < dimchoose; ++ctj) {
67
-	if (cti >= ctj) choose_table[dimchoose * cti + ctj] = choose_lli(cti, ctj);
68
-	else choose_table[dimchoose * cti + ctj] = 0LL;
69
-      }
70
-
71
-    for (int i = 0; i < YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1; ++i) map[i] = 0LL;
72 55
 
73
-    (*this).Set_to_id(idnr);
74
-  }
75
-  */
76 56
   Young_Tableau::Young_Tableau (const Young_Tableau& RefTableau)  // copy constructor
77 57
     : Nrows(RefTableau.Nrows), Ncols(RefTableau.Ncols), Row_L(new int[RefTableau.Nrows]), Col_L(new int[RefTableau.Ncols]),
78 58
       id(RefTableau.id), maxid(RefTableau.maxid),
@@ -93,47 +73,11 @@ namespace ABACUS {
93 73
       }
94 74
 
95 75
     // The map:
96
-    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = RefTableau.map[i];
76
+    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
77
+      map[i] = RefTableau.map[i];
97 78
 
98 79
   }
99
-  /*
100
-  Young_Tableau::Young_Tableau (int Nr, int Nc, long long int* ref_choose_table, int dimref)
101
-    : Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
102
-      maxid(choose_lli(Nr + Nc, Nc) - 1LL),
103
-      //choose_table(new long long int[(Nr + Nc + 1) * (Nr + Nc + 1)]),
104
-      choose_table(new long long int[(Nr + Nc + 1) * (ABACUS::min(Nr, Nc) + 1)]),
105
-      //map(new long long int[ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT)]),
106
-      map(new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
107
-      map_computed(false), idnr_reached(0LL), nboxes_reached(-1)
108
-
109
-  {
110
-    // Constructs empty tableau of appropriate size
111
-
112
-    for (int i = 0; i < Nrows; ++i) Row_L[i] = 0;
113
-    for (int i = 0; i < Ncols; ++i) Col_L[i] = 0;
114 80
 
115
-    // Construct the choose_table
116
-
117
-    // Copy entries from reference table
118
-    for (int cti = 0; cti < ABACUS::min(Nr + Nc + 1, dimref); ++cti)
119
-      for (int ctj = 0; ctj < ABACUS::min(Nr + Nc + 1, dimref); ++ctj)
120
-	  choose_table[(Nr + Nc + 1) * cti + ctj] = cti >= ctj ? ref_choose_table[dimref * cti + ctj] : 0LL;
121
-
122
-    // add missing parts if there are any
123
-    if (dimref < Nr + Nc + 1) {
124
-      for (int cti = 0; cti < Nr + Nc + 1; ++cti)
125
-	for (int ctj = dimref; ctj < Nr + Nc + 1; ++ctj)
126
-	  choose_table[(Nr + Nc + 1) * cti + ctj] = 0LL;
127
-      for (int cti = dimref; cti < Nr + Nc + 1; ++cti)
128
-	for (int ctj = 0; ctj < Nr + Nc + 1; ++ctj)
129
-	  choose_table[(Nr + Nc + 1) * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
130
-    }
131
-
132
-    // The map:
133
-    //for (int i = 0; i < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT); ++i) map[i] = 0LL;
134
-    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
135
-  }
136
-  */
137 81
   Young_Tableau::Young_Tableau (int Nr, int Nc, const Young_Tableau& RefTableau)
138 82
     : Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
139 83
       maxid(choose_lli(Nr + Nc, Nc) - 1LL),
@@ -163,7 +107,8 @@ namespace ABACUS {
163 107
 	  choose_table[dimchoose * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
164 108
 
165 109
     // The map:
166
-    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
110
+    for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
111
+      map[i] = 0LL;
167 112
   }
168 113
 
169 114
   Young_Tableau& Young_Tableau::operator= (const Young_Tableau& RefTableau)
@@ -190,7 +135,9 @@ namespace ABACUS {
190 135
 
191 136
       if (map != 0LL) delete[] map;
192 137
       map = new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1];
193
-      for (long long int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = RefTableau.map[i];
138
+      for (long long int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2
139
+				     ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
140
+	map[i] = RefTableau.map[i];
194 141
       map_computed = RefTableau.map_computed;
195 142
       idnr_reached = RefTableau.idnr_reached;
196 143
       nboxes_reached = RefTableau.nboxes_reached;
@@ -263,7 +210,8 @@ namespace ABACUS {
263 210
     }
264 211
 
265 212
     else if (nboxes_to_dist > Ncols * (Nrows - level)) {
266
-      cout << Nrows << "\t" << Ncols << "\t" << level << "\t" << nboxes_to_dist << "\t" << idnr_reached << "\t" << nboxes_reached << endl;
213
+      cout << Nrows << "\t" << Ncols << "\t" << level << "\t" << nboxes_to_dist << "\t"
214
+	   << idnr_reached << "\t" << nboxes_reached << endl;
267 215
       ABACUSerror("nboxes_to_dist too high");
268 216
     }
269 217
     else if (nboxes_to_dist == 0) {
@@ -309,10 +257,11 @@ namespace ABACUS {
309 257
 					    + ABACUS::min(highest_occupied_row, Ncols_Desc - j)];
310 258
 
311 259
 	Vect_INT Desc_Desc_Row_L(highest_occupied_row);
312
-	for (int i = 0; i < highest_occupied_row; ++i) Desc_Desc_Row_L[i] = Desc_Row_L[i] - Desc_Row_L[highest_occupied_row];
260
+	for (int i = 0; i < highest_occupied_row; ++i)
261
+	  Desc_Desc_Row_L[i] = Desc_Row_L[i] - Desc_Row_L[highest_occupied_row];
313 262
 
314
-	answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row, Ncols_Desc - Desc_Row_L[highest_occupied_row],
315
-					 RefTableau);
263
+	answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row,
264
+					 Ncols_Desc - Desc_Row_L[highest_occupied_row], RefTableau);
316 265
 
317 266
       }
318 267
     }
@@ -338,7 +287,7 @@ namespace ABACUS {
338 287
 	else {
339 288
 
340 289
 	  for (int j = 0; j < ndiag; ++j) answer += RefTableau.choose_table[RefTableau.dimchoose * Nrows_Desc + j]
341
-	    * RefTableau.choose_table[RefTableau.dimchoose * Ncols_Desc + j];
290
+					    * RefTableau.choose_table[RefTableau.dimchoose * Ncols_Desc + j];
342 291
 
343 292
 	  Vect_INT Desc1_Row_L(ndiag);
344 293
 	  for (int i = 0; i < ndiag; ++i) Desc1_Row_L[i] = Desc_Row_L[i] - ndiag;
@@ -381,8 +330,9 @@ namespace ABACUS {
381 330
 	int highest_occupied_row = Nrows - 1;
382 331
 	while (Row_L[highest_occupied_row] == 0) highest_occupied_row--;  // index of highest occupied row;
383 332
 
384
-	for (int j = 0; j < Row_L[highest_occupied_row]; ++j) idnr += choose_table[dimchoose * (highest_occupied_row + Ncols - j)
385
-										   + ABACUS::min(highest_occupied_row, Ncols - j)];
333
+	for (int j = 0; j < Row_L[highest_occupied_row]; ++j)
334
+	  idnr += choose_table[dimchoose * (highest_occupied_row + Ncols - j)
335
+			       + ABACUS::min(highest_occupied_row, Ncols - j)];
386 336
 
387 337
 	Vect_INT Desc_Row_L(highest_occupied_row);
388 338
 
@@ -432,7 +382,8 @@ namespace ABACUS {
432 382
 
433 383
       Compute_id (0);  // sets the id according to rule 0
434 384
       Compute_Map (idnr);  // make sure the state map is computed
435
-      while (map[idnr] != id && idnr < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT)) idnr++;  // match with inverse map to get the idnr according to rule 2
385
+      while (map[idnr] != id && idnr < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT))
386
+	idnr++;  // match with inverse map to get the idnr according to rule 2
436 387
     }
437 388
 
438 389
     else ABACUSerror("Wrong option for Tableau ids");
@@ -448,13 +399,15 @@ namespace ABACUS {
448 399
     return(*this);
449 400
   }
450 401
 
451
-  Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option) // sets the tableau to the one corresponding to idnr
402
+  Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option)
403
+  // sets the tableau to the one corresponding to idnr
452 404
   {
453 405
 
454 406
     if (option == 0) {
455 407
 
456 408
       if ((idnr < 0) || ((maxid < idnr) && (Nrows*Ncols != 0))) {
457
-	cout << "Nrows = " << Nrows << "\tNcols = " << Ncols << "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
409
+	cout << "Nrows = " << Nrows << "\tNcols = " << Ncols
410
+	     << "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
458 411
 	ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
459 412
       }
460 413
       id = idnr;
@@ -489,7 +442,8 @@ namespace ABACUS {
489 442
 
490 443
     else if (option == 1) {
491 444
 
492
-      if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0))) ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
445
+      if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0)))
446
+	ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
493 447
 
494 448
       if (Nrows*Ncols == 0 && idnr != 0LL) ABACUSerror("Trying nonzero id on empty Tableau.");
495 449
 
@@ -508,7 +462,8 @@ namespace ABACUS {
508 462
 	  sum += choose_table[dimchoose * Nrows + ndiag] * choose_table[dimchoose * Ncols + ndiag];
509 463
 	}
510 464
 
511
-	long long int residual_id = idnr - 1 - sum + choose_table[dimchoose * Nrows + ndiag] * choose_table[dimchoose * Ncols + ndiag];
465
+	long long int residual_id = idnr - 1 - sum + choose_table[dimchoose * Nrows + ndiag]
466
+	  * choose_table[dimchoose * Ncols + ndiag];
512 467
 
513 468
 	if (ndiag == 0 && idnr != 0LL) ABACUSerror("Zero ndiag for nonzero idnr in Tableau.");
514 469
 
@@ -561,9 +516,12 @@ namespace ABACUS {
561 516
 
562 517
   Young_Tableau& Young_Tableau::Set_Row_L (Vect_INT& Row_Lengths)  // set row lengths to elements of given vector
563 518
   {
564
-    if (Row_Lengths.size() != Nrows) ABACUSerror("Vector of incompatible dimension used to initialize Young Tableau.");
519
+    if (Row_Lengths.size() != Nrows)
520
+      ABACUSerror("Vector of incompatible dimension used to initialize Young Tableau.");
565 521
 
566
-    for (int i = 0; i < Row_Lengths.size() - 1; ++i) if (Row_Lengths[i] < Row_Lengths[i+1]) ABACUSerror("Vector is not a proper Young tableau.");
522
+    for (int i = 0; i < Row_Lengths.size() - 1; ++i)
523
+      if (Row_Lengths[i] < Row_Lengths[i+1])
524
+	ABACUSerror("Vector is not a proper Young tableau.");
567 525
 
568 526
     for (int i = 0; i < Nrows; ++i) Row_L[i] = Row_Lengths[i];
569 527
     (*this).Set_Col_L_given_Row_L();
@@ -663,8 +621,6 @@ namespace ABACUS {
663 621
   {
664 622
     // adds a box to the lowest nonzero length Row, recomputes id, returns true if tableau has changed
665 623
 
666
-    //cout << "Check before: "; (*this).Print();
667
-
668 624
     if (id == 0LL || Nrows == 0 || Ncols == 0) return(false);  // Tableau is empty
669 625
 
670 626
     // otherwise find the lowest nonzero row:
@@ -674,13 +630,12 @@ namespace ABACUS {
674 630
     if (iln0r < 0) ABACUSerror("id wrongly set in Young_Tableau (Raise_Lowest_Nonzero_Row).");
675 631
     // This should not happen, since if iln0r == -1, id should be 0.
676 632
 
677
-    else if (iln0r == 0 && Row_L[0] < Ncols || iln0r > 0 && Row_L[iln0r - 1] > Row_L[iln0r]) {  // there is space for at least one more box !
633
+    else if (iln0r == 0 && Row_L[0] < Ncols || iln0r > 0 && Row_L[iln0r - 1] > Row_L[iln0r]) {
634
+      // there is space for at least one more box !
678 635
       Row_L[iln0r] += 1;
679 636
       Set_Col_L_given_Row_L();
680 637
       Compute_id();
681 638
 
682
-      //cout << "Check after: iln0r = " << iln0r; (*this).Print();
683
-
684 639
       return(true);
685 640
     }
686 641
 
@@ -693,28 +648,20 @@ namespace ABACUS {
693 648
 
694 649
     // Important:  allow raising first row if tableau is empty.
695 650
 
696
-    //cout << "Check before: "; (*this).Print();
697
-
698 651
     if (Ncols == 0 || Nrows == 0) return(false); // no space !
699 652
 
700 653
     // Find index of lowest nonzero row:  can be -1 if Tableau is empty
701 654
     int iln0r = Nrows - 1;
702 655
     while (Row_L[iln0r] == 0 && iln0r >= 0) iln0r--;
703 656
 
704
-    //cout << "iln0r = " << iln0r << "\t" << Row_L[iln0r] << "\t" << Row_L[iln0r + 1] << endl;
705
-
706
-    //if (iln0r == Nrows - 1) return(false); // no row under that one;  allow raising of row 0
707
-
708 657
     if (iln0r == -1 && Row_L[0] < Ncols || iln0r >= 0 && iln0r < Nrows - 1 && Row_L[iln0r] > Row_L[iln0r + 1]) {
709
-	// there is space for at least one more box !
710
-	Row_L[iln0r + 1] += 1;
711
-	Set_Col_L_given_Row_L();
712
-	Compute_id();
713
-
714
-	//cout << "Check after: iln0r = " << iln0r; (*this).Print();
658
+      // there is space for at least one more box !
659
+      Row_L[iln0r + 1] += 1;
660
+      Set_Col_L_given_Row_L();
661
+      Compute_id();
715 662
 
716
-	return(true);
717
-      }
663
+      return(true);
664
+    }
718 665
 
719 666
     return(false);
720 667
   }
@@ -836,8 +783,6 @@ namespace ABACUS {
836 783
     // descendents considered here are thus those for which the raised
837 784
     // box is the highest still occupied box of the originally boosted state.
838 785
 
839
-    //cout << "Tableau in Desc_Boosted: " << (*this) << endl;
840
-
841 786
     int ndesc = 0;
842 787
 
843 788
     // Is tableau non-empty ?
@@ -860,19 +805,17 @@ namespace ABACUS {
860 805
     if (!fixed_Nboxes) {
861 806
       // The convention here is that we *remove* the highest yet unraised box only
862 807
 
863
-      //cout << "Removing box from " << (*this) << " with id " << (*this).id << endl;
864 808
       Young_Tableau descendent_attempt = (*this);
865 809
       if (descendent_attempt.Lower_Row(level_from)) ndesc = 1;
866
-      //cout << "Obtained: " << descendent_attempt << " with id " << descendent_attempt.id << endl;
867 810
 
868 811
       //if (ndesc > 0) {
869 812
       if (ndesc == 1) {
870 813
 	Vect<Young_Tableau> Tableau_desc(ndesc);
871
-	//if (ndesc == 1) Tableau_desc[0] = descendent_attempt;
872 814
 	Tableau_desc[0] = descendent_attempt;
873 815
 	return(Tableau_desc);
874 816
       }
875
-      else if (ndesc != 0) ABACUSerror("There should be either 0 or 1 descendents in Descended_Boosted_State with fixed_iK == true.");
817
+      else if (ndesc != 0)
818
+	ABACUSerror("There should be either 0 or 1 descendents in Descended_Boosted_State with fixed_iK == true.");
876 819
 
877 820
     } // if (!fixed_Nboxes)
878 821
 
@@ -886,10 +829,12 @@ namespace ABACUS {
886 829
       Young_Tableau Tableau_ref = (*this);
887 830
       Young_Tableau Tableau_check1 = (*this);
888 831
       bool check1 = (Tableau_check1.Lower_Row(level_from) && Tableau_check1.Raise_Lowest_Nonzero_Row());
889
-      if (check1 && Tableau_check1.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1) ndesc++;  // to make sure we don't Raise the one we've just removed
832
+      if (check1 && Tableau_check1.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1)
833
+	ndesc++;  // to make sure we don't Raise the one we've just removed
890 834
       Young_Tableau Tableau_check2 = (*this);
891 835
       bool check2 = (Tableau_check2.Lower_Row(level_from) && Tableau_check2.Raise_Next_to_Lowest_Nonzero_Row());
892
-      if (check2 && Tableau_check2.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1) ndesc++;   // to make sure we don't Raise the one we've just removed
836
+      if (check2 && Tableau_check2.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1)
837
+	ndesc++;   // to make sure we don't Raise the one we've just removed
893 838
 
894 839
       if (ndesc > 0) {
895 840
 	Vect<Young_Tableau> Tableau_desc(ndesc);
@@ -908,8 +853,6 @@ namespace ABACUS {
908 853
     // tries to add Nboxes to Tableau, returns number of boxes added.
909 854
     if (Ncols == 0 || Nrows == 0) return(0); // can't do anything !
910 855
 
911
-    //cout << "Requesting Nboxes " << Nboxes << " in tableau." << endl;
912
-
913 856
     int Nboxes_added = 0;
914 857
     int previous_Row_L = 0;
915 858
     for (int working_level = 0; working_level < Nrows; ++working_level) {

Loading…
Cancel
Save