Finish first clean of src files
This commit is contained in:
parent
e7dd24d337
commit
0559fa9301
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -52,7 +52,8 @@ namespace ABACUS {
|
|||
|
||||
Vect<Scan_Thread_Data> thr_data_par(nr_processors_at_newlevel);
|
||||
for (int rank = 0; rank < nr_processors_at_newlevel; ++rank)
|
||||
thr_data_par[rank] = Scan_Thread_Data (THRDIRS_stringstream[rank].str(), false); // put refine == false here to avoid loading any deprecated data
|
||||
thr_data_par[rank] = Scan_Thread_Data (THRDIRS_stringstream[rank].str(), false);
|
||||
// put refine == false here to avoid loading any deprecated data
|
||||
|
||||
// Transfer all the existing threads into the new ones:
|
||||
int rankindex = 0;
|
||||
|
@ -83,59 +84,12 @@ namespace ABACUS {
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
void Create_Empty_Files (string prefix, char whichDSF, int nr_processors_at_newlevel)
|
||||
{
|
||||
// This function creates, for convenience, a set of 'empty' files, so a full set of files is available at all paralevels.
|
||||
for (int rank = 0; rank < nr_processors_at_newlevel; ++rank) {
|
||||
stringstream RAW_stringstream; string RAW_string;
|
||||
stringstream INADM_stringstream; string INADM_string;
|
||||
stringstream CONV0_stringstream; string CONV0_string;
|
||||
stringstream LOG_stringstream; string LOG_string;
|
||||
//stringstream THR_stringstream; string THR_string;
|
||||
stringstream SRC_stringstream; string SRC_string;
|
||||
stringstream FSR_stringstream; string FSR_string;
|
||||
stringstream SUM_stringstream; string SUM_string;
|
||||
|
||||
RAW_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".raw";
|
||||
INADM_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".inadm";
|
||||
CONV0_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".conv0";
|
||||
LOG_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".log";
|
||||
//THR_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".thr";
|
||||
SRC_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".src";
|
||||
FSR_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".fsr";
|
||||
SUM_stringstream << prefix << "_" << rank << "_" << nr_processors_at_newlevel << ".sum";
|
||||
|
||||
RAW_string = RAW_stringstream.str(); const char* RAW_Cstr = RAW_string.c_str();
|
||||
INADM_string = INADM_stringstream.str(); const char* INADM_Cstr = INADM_string.c_str();
|
||||
CONV0_string = CONV0_stringstream.str(); const char* CONV0_Cstr = CONV0_string.c_str();
|
||||
LOG_string = LOG_stringstream.str(); const char* LOG_Cstr = LOG_string.c_str();
|
||||
//THR_string = THR_stringstream.str(); const char* THR_Cstr = THR_string.c_str();
|
||||
SRC_string = SRC_stringstream.str(); const char* SRC_Cstr = SRC_string.c_str();
|
||||
FSR_string = FSR_stringstream.str(); const char* FSR_Cstr = FSR_string.c_str();
|
||||
SUM_string = SUM_stringstream.str(); const char* SUM_Cstr = SUM_string.c_str();
|
||||
|
||||
// We open and close these files (except for SUM, which we fill with a zero-valued scan_info
|
||||
fstream RAW_file; RAW_file.open(RAW_Cstr); RAW_file.close();
|
||||
fstream INADM_file; INADM_file.open(INADM_Cstr); INADM_file.close();
|
||||
fstream CONV0_file; CONV0_file.open(CONV0_Cstr); CONV0_file.close();
|
||||
fstream LOG_file; LOG_file.open(LOG_Cstr); LOG_file.close();
|
||||
Scan_Info emptyinfo; emptyinfo.Save(SRC_Cstr);
|
||||
fstream FSR_file; FSR_file.open(FSR_Cstr); FSR_file.close();
|
||||
fstream SUM_file; SUM_file.open(SUM_Cstr); SUM_file.close();
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void Merge_raw_Files (string prefix, char whichDSF, int nr_processors_at_newlevel)
|
||||
{
|
||||
|
||||
// Open the original raw file:
|
||||
stringstream RAW_stringstream; string RAW_string;
|
||||
//RAW_stringstream << prefix;
|
||||
//if (whichDSF == 'Z') RAW_stringstream << ".dat";
|
||||
//else RAW_stringstream << ".raw";
|
||||
RAW_stringstream << prefix << ".raw";
|
||||
RAW_string = RAW_stringstream.str(); const char* RAW_Cstr = RAW_string.c_str();
|
||||
|
||||
|
@ -153,23 +107,18 @@ namespace ABACUS {
|
|||
ifstream RAW_infile;
|
||||
RAW_infile.open(RAW_in_Cstr);
|
||||
if (RAW_infile.fail()) {
|
||||
//cout << RAW_in_Cstr << endl;
|
||||
//ABACUSerror ("Could not open file.");
|
||||
continue; // if file isn't there, just continue...
|
||||
}
|
||||
|
||||
DP omega;
|
||||
int iK;
|
||||
DP FF;
|
||||
//int conv;
|
||||
DP dev;
|
||||
string label;
|
||||
int nr, nl;
|
||||
while (RAW_infile.peek() != EOF) {
|
||||
//RAW_infile >> omega >> iK >> FF >> conv >> label;
|
||||
RAW_infile >> omega >> iK >> FF >> dev >> label;
|
||||
if (whichDSF == '1') RAW_infile >> nr >> nl;
|
||||
//RAW_outfile << endl << omega << "\t" << iK << "\t" << FF << "\t" << conv << "\t" << label;
|
||||
RAW_outfile << endl << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label;
|
||||
if (whichDSF == '1') RAW_outfile << "\t" << nr << "\t" << nl;
|
||||
}
|
||||
|
@ -244,7 +193,6 @@ namespace ABACUS {
|
|||
SUM_string = SUM_stringstream.str(); const char* SUM_Cstr = SUM_string.c_str();
|
||||
|
||||
// Load the original info:
|
||||
//ScanStateList.Load_Info (SUM_Cstr); // Not needed anymore: rank 0 has loaded the original info
|
||||
if (file_exists(SUM_Cstr)) ScanStateList.Load_Info (SUM_Cstr); // Needed again!
|
||||
|
||||
// Load all other info:
|
||||
|
@ -470,12 +418,9 @@ namespace ABACUS {
|
|||
//****************************************************************************//
|
||||
// Model-specific functions:
|
||||
|
||||
//void Prepare_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iK_UL, bool fixed_iK, int iKneeded,
|
||||
void Prepare_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iKmin, int iKmax, DP kBT,
|
||||
string defaultScanStatename,
|
||||
//int Max_Secs, bool refine, int rank,
|
||||
int paralevel, Vect<int> rank_lower_paralevels, Vect<int> nr_processors_lower_paralevels,
|
||||
int nr_processors_at_newlevel)
|
||||
string defaultScanStatename, int paralevel, Vect<int> rank_lower_paralevels,
|
||||
Vect<int> nr_processors_lower_paralevels, int nr_processors_at_newlevel)
|
||||
{
|
||||
// From an existing scan, this function splits the threads into
|
||||
// nr_processors_at_newlevel separate files, from which the parallel process
|
||||
|
@ -485,35 +430,21 @@ namespace ABACUS {
|
|||
|
||||
// Define file name
|
||||
stringstream filenameprefix;
|
||||
//Data_File_Name (filenameprefix, whichDSF, fixed_iK, iKneeded, GroundState, GroundState);
|
||||
Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, kBT, GroundState, GroundState, defaultScanStatename);
|
||||
for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
string prefix = filenameprefix.str();
|
||||
|
||||
Split_thr_Files (prefix, whichDSF, nr_processors_at_newlevel);
|
||||
|
||||
//Create_Empty_Files (prefix, whichDSF, nr_processors_at_newlevel);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//void Wrapup_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iK_UL, bool fixed_iK, int iKneeded,
|
||||
void Wrapup_Parallel_Scan_LiebLin (char whichDSF, DP c_int, DP L, int N, int iKmin, int iKmax, DP kBT,
|
||||
string defaultScanStatename,
|
||||
//int Max_Secs, bool refine, int rank,
|
||||
int paralevel, Vect<int> rank_lower_paralevels, Vect<int> nr_processors_lower_paralevels,
|
||||
int nr_processors_at_newlevel)
|
||||
string defaultScanStatename, int paralevel, Vect<int> rank_lower_paralevels,
|
||||
Vect<int> nr_processors_lower_paralevels, int nr_processors_at_newlevel)
|
||||
{
|
||||
//DP epsilon = log(L)/L;
|
||||
|
||||
//LiebLin_Bethe_State GroundState (c_int, L, N);
|
||||
//LiebLin_Bethe_State spstate = Canonical_Saddle_Point_State (c_int, L, N, kBT, epsilon);
|
||||
//LiebLin_Bethe_State spstate = Canonical_Saddle_Point_State (c_int, L, N, kBT);
|
||||
|
||||
// Read the saddle-point state from the sps file:
|
||||
stringstream SPS_stringstream; string SPS_string;
|
||||
//SPS_stringstream << "Tgt0_";
|
||||
//Data_File_Name (SPS_stringstream, whichDSF, iKmin, iKmax, kBT, spstate, SeedScanState, "");
|
||||
Data_File_Name (SPS_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
|
||||
SPS_stringstream << ".sps";
|
||||
SPS_string = SPS_stringstream.str(); const char* SPS_Cstr = SPS_string.c_str();
|
||||
|
@ -546,14 +477,13 @@ namespace ABACUS {
|
|||
if (whichDSF == 'g') Nscan = N + 1;
|
||||
|
||||
LiebLin_Bethe_State SeedScanState = spstate;
|
||||
//if (whichDSF == 'o' || whichDSF == 'g') SeedScanState = Canonical_Saddle_Point_State (c_int, L, Nscan, kBT, epsilon);
|
||||
if (whichDSF == 'o' || whichDSF == 'g') SeedScanState = Canonical_Saddle_Point_State (c_int, L, Nscan, kBT);
|
||||
|
||||
// Define file name
|
||||
stringstream filenameprefix;
|
||||
//Data_File_Name (filenameprefix, whichDSF, fixed_iK, iKneeded, GroundState, GroundState);
|
||||
Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, kBT, spstate, SeedScanState, defaultScanStatename);
|
||||
for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
for (int i = 0; i < paralevel - 1; ++i)
|
||||
filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
string prefix = filenameprefix.str();
|
||||
|
||||
|
||||
|
@ -570,19 +500,7 @@ namespace ABACUS {
|
|||
Merge_inadm_conv0_src_stat_log_Files (prefix, whichDSF, nr_processors_at_newlevel);
|
||||
// This also puts some digested info in log file.
|
||||
|
||||
// Evaluate f-sumrule:
|
||||
/*
|
||||
stringstream RAW_stringstream; string RAW_string;
|
||||
RAW_stringstream << prefix << ".raw";
|
||||
RAW_string = RAW_stringstream.str(); const char* RAW_Cstr = RAW_string.c_str();
|
||||
|
||||
stringstream FSR_stringstream; string FSR_string;
|
||||
FSR_stringstream << prefix << ".fsr";
|
||||
FSR_string = FSR_stringstream.str(); const char* FSR_Cstr = FSR_string.c_str();
|
||||
*/
|
||||
DP Chem_Pot = Chemical_Potential (spstate);
|
||||
//if (!fixed_iK) if (whichDSF != 'q') Evaluate_F_Sumrule (whichDSF, GroundState, Chem_Pot, RAW_Cstr, FSR_Cstr);
|
||||
//if (iKmin != iKmax) if (whichDSF != 'q') Evaluate_F_Sumrule (whichDSF, GroundState, Chem_Pot, iKmin, iKmax, RAW_Cstr, FSR_Cstr);
|
||||
if (iKmin != iKmax) if (whichDSF != 'q') Evaluate_F_Sumrule (prefix, whichDSF, spstate, Chem_Pot, iKmin, iKmax);
|
||||
|
||||
// ... and we're done.
|
||||
|
@ -595,7 +513,6 @@ namespace ABACUS {
|
|||
// Heisenberg:
|
||||
|
||||
void Prepare_Parallel_Scan_Heis (char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax,
|
||||
//int Max_Secs, bool refine, int rank,
|
||||
int paralevel, Vect<int> rank_lower_paralevels, Vect<int> nr_processors_lower_paralevels,
|
||||
int nr_processors_at_newlevel)
|
||||
{
|
||||
|
@ -611,8 +528,6 @@ namespace ABACUS {
|
|||
|
||||
Heis_Base baseconfig_groundstate(BD1, Nrapidities_groundstate);
|
||||
|
||||
//Ix2_Offsets baseoffsets(baseconfig_groundstate, 0ULL);
|
||||
|
||||
// Define file name
|
||||
stringstream filenameprefix;
|
||||
|
||||
|
@ -639,7 +554,8 @@ namespace ABACUS {
|
|||
|
||||
else ABACUSerror("Delta out of range in Prepare_Parallel_Scan_Heis");
|
||||
|
||||
for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
for (int i = 0; i < paralevel - 1; ++i)
|
||||
filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
string prefix = filenameprefix.str();
|
||||
|
||||
Split_thr_Files (prefix, whichDSF, nr_processors_at_newlevel);
|
||||
|
@ -664,8 +580,6 @@ namespace ABACUS {
|
|||
|
||||
Heis_Base baseconfig_groundstate(BD1, Nrapidities_groundstate);
|
||||
|
||||
//Ix2_Offsets baseoffsets(baseconfig_groundstate, 0ULL);
|
||||
|
||||
// Define file name
|
||||
stringstream filenameprefix;
|
||||
string prefix;
|
||||
|
@ -681,7 +595,8 @@ namespace ABACUS {
|
|||
else ABACUSerror("Unknown whichDSF in Scan_Heis.");
|
||||
|
||||
Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, 0.0, GroundState, SeedScanState, "");
|
||||
for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
for (int i = 0; i < paralevel - 1; ++i)
|
||||
filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
prefix = filenameprefix.str();
|
||||
|
||||
// Merge sum files
|
||||
|
@ -715,7 +630,8 @@ namespace ABACUS {
|
|||
else ABACUSerror("Unknown whichDSF in Scan_Heis.");
|
||||
|
||||
Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, 0.0, GroundState, SeedScanState, "");
|
||||
for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
for (int i = 0; i < paralevel - 1; ++i)
|
||||
filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
prefix = filenameprefix.str();
|
||||
|
||||
// Merge sum files
|
||||
|
@ -748,7 +664,8 @@ namespace ABACUS {
|
|||
else ABACUSerror("Unknown whichDSF in Scan_Heis.");
|
||||
|
||||
Data_File_Name (filenameprefix, whichDSF, iKmin, iKmax, 0.0, GroundState, SeedScanState, "");
|
||||
for (int i = 0; i < paralevel - 1; ++i) filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
for (int i = 0; i < paralevel - 1; ++i)
|
||||
filenameprefix << "_" << rank_lower_paralevels[i] << "_" << nr_processors_lower_paralevels[i];
|
||||
prefix = filenameprefix.str();
|
||||
|
||||
// Merge sum files
|
||||
|
|
|
@ -24,10 +24,7 @@ namespace ABACUS {
|
|||
// Estimates the cost of adding a particle-hole excitation to an intermediate state
|
||||
DP ph_cost = 1.0;
|
||||
|
||||
//if (whichDSF == 'd') ph_cost = ABACUS::min(0.1, 1.0/sqrt(AveragingState.c_int));
|
||||
//if (whichDSF == 'd') ph_cost = ABACUS::min(0.1, 1.0/AveragingState.c_int);
|
||||
if (whichDSF == 'd') ph_cost = ABACUS::min(0.01, 0.1/AveragingState.c_int);
|
||||
//if (whichDSF == 'd') ph_cost = ABACUS::min(0.001, 0.01/AveragingState.c_int);
|
||||
else if (whichDSF == 'o') ph_cost = 0.01;
|
||||
else if (whichDSF == 'g') ph_cost = 0.01;
|
||||
else if (whichDSF == 'Z') ph_cost = 1.0;
|
||||
|
|
|
@ -20,13 +20,9 @@ using namespace ABACUS;
|
|||
namespace ABACUS {
|
||||
|
||||
Scan_Info::Scan_Info() :
|
||||
//sumrule_obtained(0.0), Nfull(0LL), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), CPU_ticks(0LL), CPU_ticks_TOT(0LL) {}
|
||||
//sumrule_obtained(0.0), Nfull(0.0), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), CPU_ticks(0LL), CPU_ticks_TOT(0LL) {}
|
||||
sumrule_obtained(0.0), Nfull(0.0), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), TT(0.0) {}
|
||||
|
||||
//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) :
|
||||
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) :
|
||||
//sumrule_obtained(sr), Nfull(Nf), Ninadm(Ni), Ndata(Nd), Ndata_conv(Ndc), Ndata_conv0(Ndc0), CPU_ticks(t), CPU_ticks_TOT(t) {}
|
||||
sumrule_obtained(sr), Nfull(Nf), Ninadm(Ni), Ndata(Nd), Ndata_conv(Ndc), Ndata_conv0(Ndc0), TT(t) {}
|
||||
|
||||
void Scan_Info::Save (const char* outfile_Cstr)
|
||||
|
@ -36,19 +32,17 @@ namespace ABACUS {
|
|||
outfile.open(outfile_Cstr);
|
||||
if (outfile.fail()) ABACUSerror("Could not open outfile... ");
|
||||
|
||||
//outfile.setf(ios::fixed);
|
||||
//outfile.setf(ios::showpoint);
|
||||
outfile.precision(16);
|
||||
|
||||
int TT_hr = int(TT/3600);
|
||||
int TT_min = int((TT - 3600.0*TT_hr)/60);
|
||||
|
||||
outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull << setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
|
||||
//<< "\t" << CPU_ticks/CLOCKS_PER_SEC << "\t" << CPU_ticks_TOT/CLOCKS_PER_SEC << endl;
|
||||
//<< setw(16) << std::fixed << setprecision(3) << TT << endl;
|
||||
<< "\t" << TT_hr << " h " << TT_min << " m " << std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
|
||||
//outfile << "sumrule_obtained \t Nfull \t Ninadm \t Ndata \t Ndata_conv \t Ndata_conv0 \t T \t TT.";
|
||||
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;
|
||||
outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull
|
||||
<< setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
|
||||
<< "\t" << TT_hr << " h " << TT_min << " m "
|
||||
<< std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
|
||||
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;
|
||||
outfile.close();
|
||||
|
||||
return;
|
||||
|
@ -67,13 +61,10 @@ namespace ABACUS {
|
|||
DP TT_sec;
|
||||
char a;
|
||||
|
||||
//infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0 >> CPU_ticks >> CPU_ticks_TOT;
|
||||
//infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0 >> TT;
|
||||
infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0 >> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
|
||||
infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0
|
||||
>> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
|
||||
|
||||
TT = 3600.0 * TT_hr + 60.0* TT_min + TT_sec;
|
||||
//CPU_ticks_TOT *= CLOCKS_PER_SEC; // correct for factor in Save function
|
||||
//CPU_ticks = 0; // reset CPU ticks.
|
||||
|
||||
infile.close();
|
||||
|
||||
|
@ -84,12 +75,12 @@ namespace ABACUS {
|
|||
{
|
||||
s.ios::unsetf(ios::scientific);
|
||||
return s << " sr " << setprecision(14) << info.sumrule_obtained
|
||||
<< "\tNfull " << std::fixed << setprecision(0) << info.Nfull << "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
|
||||
<< "\tNfull " << std::fixed << setprecision(0) << info.Nfull
|
||||
<< "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
|
||||
<< "\t_conv " << info.Ndata_conv << " _conv0 " << info.Ndata_conv0
|
||||
//<< " t " << info.CPU_ticks/CLOCKS_PER_SEC << "s"
|
||||
//<< " TT " << info.CPU_ticks_TOT/CLOCKS_PER_SEC;
|
||||
//<< "\tTT " << std::fixed << setprecision(3) << info.TT;
|
||||
<< "\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";
|
||||
<< "\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";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,15 +57,13 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
filename = Vect<string> (nlists);
|
||||
//file = Vect<fstream*> (nlists);
|
||||
//file_is_open = Vect<bool> (nlists);
|
||||
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
stringstream filename_strstream;
|
||||
filename_strstream << thrdir_name << "/" << il << ".thr";
|
||||
filename[il] = filename_strstream.str();
|
||||
if (!refine) remove(filename[il].c_str()); // the file is deleted to make sure we don't interfere with a previous (failed) computation
|
||||
//file_is_open[il] = false;
|
||||
if (!refine) remove(filename[il].c_str());
|
||||
// the file is deleted to make sure we don't interfere with a previous (failed) computation
|
||||
}
|
||||
if (!refine) {
|
||||
// remove the nthreads.dat file
|
||||
|
@ -79,11 +77,6 @@ namespace ABACUS {
|
|||
|
||||
Scan_Thread_Data::~Scan_Thread_Data()
|
||||
{
|
||||
//for (int il = 0; il < nlists; ++il)
|
||||
//if (file_is_open[il]) {
|
||||
// (*file[il]).close();
|
||||
// delete file[il];
|
||||
//}
|
||||
}
|
||||
|
||||
bool Scan_Thread_Data::Increase_Memory_Size (int il, int nr_to_add)
|
||||
|
@ -118,21 +111,11 @@ namespace ABACUS {
|
|||
|
||||
void Scan_Thread_Data::Include_Thread (int il, string label_ref, int type_ref)
|
||||
{
|
||||
//cout << "Calling Include_Threads..." << endl;
|
||||
|
||||
if (il < 0 || il > nlists - 1) ABACUSerror("il out of range in Scan_Thread_Data::Include_Thread.");
|
||||
|
||||
//cout << "\t\tIncluding thread " << label_ref << "\t" << type_ref << " in list with il = " << il << endl;
|
||||
if (il < 0 || il > nlists - 1)
|
||||
ABACUSerror("il out of range in Scan_Thread_Data::Include_Thread.");
|
||||
|
||||
if (il < lowest_il_with_nthreads_neq_0) lowest_il_with_nthreads_neq_0 = il;
|
||||
|
||||
// append to file
|
||||
//if (!file_is_open[il]) {
|
||||
//file[il] = new fstream(filename[il].c_str(), fstream::out);
|
||||
//file_is_open[il] = true;
|
||||
//}
|
||||
//*file[il] << label_ref << "\t" << type_ref << endl;
|
||||
|
||||
// Keep in memory for now:
|
||||
if (nthreads_in_memory[il] > dim[il] - 10) {
|
||||
(*this).Increase_Memory_Size (il, dim[il]);
|
||||
|
@ -158,23 +141,13 @@ namespace ABACUS {
|
|||
label[il] = Vect<string> (dim[il]);
|
||||
type[il] = Vect<int> (dim[il]);
|
||||
}
|
||||
|
||||
//cout << "\t\tDone including thread." << endl;
|
||||
//char a;
|
||||
//cin >> a;
|
||||
//cout << "OK for Include_Threads..." << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vect<Scan_Thread> Scan_Thread_Data::Extract_Next_Scan_Threads ()
|
||||
{
|
||||
//cout << "Calling Extract_Next_Scan_Threads..." << endl;
|
||||
|
||||
// Returns a vector of threads which are next in line for scanning.
|
||||
|
||||
//cout << "Here 1" << endl;
|
||||
|
||||
int il_used = lowest_il_with_nthreads_neq_0;
|
||||
Vect<Scan_Thread> next_in_line(nthreads_total[il_used]);
|
||||
|
||||
|
@ -206,25 +179,6 @@ namespace ABACUS {
|
|||
type[il_used] = Vect<int> (dim[il_used]);
|
||||
remove(filename[il_used].c_str());
|
||||
|
||||
/* Moved to Include_Thread
|
||||
// We save the higher-index in-memory threads to files if they are big enough:
|
||||
for (int il = il_used + 1; il < nlists; ++il)
|
||||
//if (nthreads_in_memory[il] > 0) {
|
||||
if (nthreads_in_memory[il] > 1000) {
|
||||
fstream outfile;
|
||||
outfile.open(filename[il].c_str(), fstream::out | fstream::app);
|
||||
for (int it = 0; it < nthreads_in_memory[il]; ++it)
|
||||
outfile << label[il][it] << "\t" << type[il][it] << endl;
|
||||
outfile.close();
|
||||
nthreads_on_disk[il] += nthreads_in_memory[il];
|
||||
|
||||
// We then reset these memory buffers
|
||||
dim[il] = 100;
|
||||
nthreads_in_memory[il] = 0;
|
||||
label[il] = Vect<string> (dim[il]);
|
||||
type[il] = Vect<int> (dim[il]);
|
||||
}
|
||||
*/
|
||||
// Find the next non-empty list:
|
||||
do {
|
||||
lowest_il_with_nthreads_neq_0 += 1;
|
||||
|
@ -234,11 +188,6 @@ namespace ABACUS {
|
|||
}
|
||||
} while (nthreads_total[lowest_il_with_nthreads_neq_0] == 0);
|
||||
|
||||
//cout << "Set lowest_il_with_nthreads_neq_0 to " << lowest_il_with_nthreads_neq_0 << endl;
|
||||
//cin >> a;
|
||||
|
||||
//cout << "OK for Extract_Next_Scan_Threads." << endl;
|
||||
|
||||
return(next_in_line);
|
||||
}
|
||||
|
||||
|
@ -258,7 +207,8 @@ namespace ABACUS {
|
|||
|
||||
void Scan_Thread_Data::Flush_to_Disk (int il)
|
||||
{
|
||||
if (il < 0 || il > nlists - 1) ABACUSerror("il out of range in Scan_Thread_Data::Flush_to_Disk.");
|
||||
if (il < 0 || il > nlists - 1)
|
||||
ABACUSerror("il out of range in Scan_Thread_Data::Flush_to_Disk.");
|
||||
|
||||
if (nthreads_in_memory[il] > 0) {
|
||||
fstream outfile;
|
||||
|
@ -288,7 +238,8 @@ namespace ABACUS {
|
|||
string nthreads_outfile_str = nthreads_outfile_strstream.str();
|
||||
|
||||
nthreads_outfile.open(nthreads_outfile_str.c_str());
|
||||
if (nthreads_outfile.fail()) ABACUSerror("Could not open outfile in Scan_Thread_Data::Save... ");
|
||||
if (nthreads_outfile.fail())
|
||||
ABACUSerror("Could not open outfile in Scan_Thread_Data::Save... ");
|
||||
|
||||
//cout << "Saving threads: nthreads_tot vector is" << endl;
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
|
|
|
@ -19,50 +19,25 @@ using namespace ABACUS;
|
|||
|
||||
namespace ABACUS {
|
||||
|
||||
/************************************/
|
||||
/*
|
||||
struct Root_Density {
|
||||
|
||||
int Npts; // how many points are used to describe each function
|
||||
DP lambdamax; // what the largest rapidity is
|
||||
Vect_DP lambda; // rapidity vector
|
||||
Vect_DP dlambda; // differential element
|
||||
Vect_DP value; // the root density itself
|
||||
Vect_DP prev_value; // results of previous iteration
|
||||
DP diff; // relative differences with previous iteration
|
||||
bool value_infty_set; // boolean, true if asymptotic value set
|
||||
DP value_infty; // asymptotic value, computed analytically
|
||||
|
||||
Root_Density ();
|
||||
Root_Density (int Npts_ref, DP lambdamax_ref);
|
||||
|
||||
Root_Density& operator= (const Root_Density& RefDensity);
|
||||
|
||||
DP Return_Value (DP lambda_ref); // evaluates the function for any argument using linear interpolation
|
||||
DP Set_Asymptotics (DP value_infty_ref); // sets value for lambda >= lambdamax
|
||||
|
||||
Root_Density Compress_and_Match_Densities (DP comp_factor); // returns a Root_Density with fewer points
|
||||
};
|
||||
*/
|
||||
|
||||
Root_Density::Root_Density ()
|
||||
Root_Density::Root_Density ()
|
||||
: Npts(1), lambdamax(0.0), lambda(Vect_DP(0.0, Npts)), dlambda(Vect_DP(0.0, Npts)), value(Vect_DP(0.0, Npts)),
|
||||
prev_value(Vect_DP(0.0, Npts)), diff(1.0e+6), value_infty_set(false), value_infty(0.0)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
Root_Density::Root_Density (int Npts_ref, DP lambdamax_ref)
|
||||
Root_Density::Root_Density (int Npts_ref, DP lambdamax_ref)
|
||||
: Npts(Npts_ref), lambdamax(lambdamax_ref), lambda(Vect_DP(Npts)), dlambda(Vect_DP(0.0, Npts)), value(Vect_DP(0.0, Npts)),
|
||||
prev_value(Vect_DP(0.0, Npts)), diff(1.0e+6), value_infty_set(false), value_infty(0.0)
|
||||
{
|
||||
{
|
||||
for (int i = 0; i < value.size(); ++i) {
|
||||
lambda[i] = lambdamax * (-(Npts - 1.0) + 2*i)/Npts;
|
||||
dlambda[i] = 2.0 * lambdamax/Npts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Root_Density& Root_Density::operator= (const Root_Density& RefDensity)
|
||||
{
|
||||
Root_Density& Root_Density::operator= (const Root_Density& RefDensity)
|
||||
{
|
||||
if (this != &RefDensity) {
|
||||
Npts = RefDensity.Npts;
|
||||
lambdamax = RefDensity.lambdamax;
|
||||
|
@ -76,10 +51,10 @@ Root_Density& Root_Density::operator= (const Root_Density& RefDensity)
|
|||
|
||||
}
|
||||
return(*this);
|
||||
}
|
||||
}
|
||||
|
||||
DP Root_Density::Return_Value (DP lambda_ref)
|
||||
{
|
||||
DP Root_Density::Return_Value (DP lambda_ref)
|
||||
{
|
||||
// This function returns a value for epsilon at any real lambda
|
||||
// using simple linear interpolation.
|
||||
// Degree 3 polynomical also programmed in, but commented out: no improvement.
|
||||
|
@ -116,44 +91,28 @@ DP Root_Density::Return_Value (DP lambda_ref)
|
|||
} // while ...
|
||||
|
||||
if (index < 0 || index >= Npts || lambda[index] > lambda_ref || lambda[index + 1] < lambda_ref) {
|
||||
cout << "Seeking index: " << index << "\t" << lambda[index] << "\t <=? " << lambda_ref << "\t<? " << lambda[index + 1] << endl;
|
||||
cout << "Seeking index: " << index << "\t" << lambda[index] << "\t <=? " << lambda_ref
|
||||
<< "\t<? " << lambda[index + 1] << endl;
|
||||
ABACUSerror("Calculating index wrong in Root_Density::Evaluate.");
|
||||
}
|
||||
|
||||
//if (index < 1 || index > Npts - 3)
|
||||
answer = ((value[index] * (lambda[index+1] - lambda_ref)
|
||||
+ value[index + 1] * (lambda_ref - lambda[index]))/(lambda[index+1] - lambda[index]));
|
||||
/*
|
||||
else {
|
||||
// Better: if possible, fit to polynomial going through 4 closest points
|
||||
Vect_DP xa (4);
|
||||
Vect_DP ya (4);
|
||||
DP dy;
|
||||
xa[0] = lambda[index - 1]; xa[1] = lambda[index]; xa[2] = lambda[index + 1]; xa[3] = lambda[index + 2];
|
||||
ya[0] = value[index - 1]; ya[1] = value[index]; ya[2] = value[index + 1]; ya[3] = value[index + 2];
|
||||
polint (xa, ya, lambda_ref, answer, dy); // sets answer to value at lambda_ref
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return(answer);
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density::Set_Asymptotics (DP value_infty_ref)
|
||||
{
|
||||
void Root_Density::Set_Asymptotics (DP value_infty_ref)
|
||||
{
|
||||
value_infty = value_infty_ref;
|
||||
value_infty_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
Root_Density Root_Density::Compress_and_Match_Densities (DP comp_factor)
|
||||
{
|
||||
Root_Density Root_Density::Compress_and_Match_Densities (DP comp_factor)
|
||||
{
|
||||
// Returns a 'compressed' version of the density, using 1/comp_factor as many points.
|
||||
|
||||
// PROBLEM: this implementation can lead to numerical instabilities.
|
||||
|
||||
//Root_Density compressed_density(Npts/comp_factor, lambdamax);
|
||||
|
||||
// Rather: use this implementation:
|
||||
int Npts_used = int(2.0 * lambdamax/(dlambda[0] * comp_factor));
|
||||
|
||||
Root_Density compressed_density(Npts_used, lambdamax);
|
||||
|
@ -164,10 +123,10 @@ Root_Density Root_Density::Compress_and_Match_Densities (DP comp_factor)
|
|||
compressed_density.value[i] = (*this).Return_Value (compressed_density.lambda[i]);
|
||||
|
||||
return(compressed_density);
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density::Save (const char* outfile_Cstr)
|
||||
{
|
||||
void Root_Density::Save (const char* outfile_Cstr)
|
||||
{
|
||||
ofstream outfile;
|
||||
outfile.open(outfile_Cstr);
|
||||
outfile.precision(16);
|
||||
|
@ -178,55 +137,29 @@ void Root_Density::Save (const char* outfile_Cstr)
|
|||
}
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************/
|
||||
/*
|
||||
struct Root_Density_Set {
|
||||
Root_Density_Set::Root_Density_Set () : ntypes(1), epsilon(Vect<Root_Density> (ntypes)), Npts_total(0), diff(1.0e+6)
|
||||
{
|
||||
}
|
||||
|
||||
int ntypes;
|
||||
Vect<Root_Density> epsilon;
|
||||
int Npts_total; // sum of all Npts of epsilon's
|
||||
DP diff; // sum of diff's of the epsilon's
|
||||
|
||||
Root_Density_Set ();
|
||||
Root_Density_Set (int ntypes_ref, int Npts_ref, DP lambdamax_ref);
|
||||
Root_Density_Set (int ntypes_ref, Vect_INT Npts_ref, Vect_DP lambdamax_ref);
|
||||
|
||||
Root_Density_Set& operator= (const Root_Density_Set& RefSet);
|
||||
|
||||
void Insert_new_function (DP asymptotic_value);
|
||||
void Extend_limits (Vect<bool> need_to_extend_limit);
|
||||
void Insert_new_points (Vect<Vect<bool> > need_new_point_around);
|
||||
|
||||
DP Return_Value (int n_ref, DP lambda_ref); // returns a value, no matter what.
|
||||
|
||||
Root_Density_Set Return_Compressed_and_Matched_Set (DP comp_factor);
|
||||
void Match_Densities (Root_Density_Set& RefSet);
|
||||
|
||||
void Save (const char* outfile_Cstr);
|
||||
};
|
||||
*/
|
||||
Root_Density_Set::Root_Density_Set () : ntypes(1), epsilon(Vect<Root_Density> (ntypes)), Npts_total(0), diff(1.0e+6)
|
||||
{
|
||||
}
|
||||
|
||||
Root_Density_Set::Root_Density_Set (int ntypes_ref, int Npts_ref, DP lambdamax_ref)
|
||||
Root_Density_Set::Root_Density_Set (int ntypes_ref, int Npts_ref, DP lambdamax_ref)
|
||||
: ntypes(ntypes_ref), epsilon(Vect<Root_Density> (ntypes_ref)), Npts_total(ntypes_ref * Npts_ref), diff(1.0e+6)
|
||||
{
|
||||
{
|
||||
for (int n = 0; n < ntypes; ++n) epsilon[n] = Root_Density(Npts_ref, lambdamax_ref);
|
||||
}
|
||||
}
|
||||
|
||||
Root_Density_Set::Root_Density_Set (int ntypes_ref, Vect_INT Npts_ref, Vect_DP lambdamax_ref)
|
||||
Root_Density_Set::Root_Density_Set (int ntypes_ref, Vect_INT Npts_ref, Vect_DP lambdamax_ref)
|
||||
: ntypes(ntypes_ref), epsilon(Vect<Root_Density> (ntypes_ref)), Npts_total(Npts_ref.sum()), diff(1.0e+6)
|
||||
{
|
||||
if (Npts_ref.size() != ntypes_ref || lambdamax_ref.size() != ntypes_ref) ABACUSerror("Wrong vector sizes in Root_Density_Set.");
|
||||
{
|
||||
if (Npts_ref.size() != ntypes_ref || lambdamax_ref.size() != ntypes_ref)
|
||||
ABACUSerror("Wrong vector sizes in Root_Density_Set.");
|
||||
for (int n = 0; n < ntypes; ++n) epsilon[n] = Root_Density(Npts_ref[n], lambdamax_ref[n]);
|
||||
}
|
||||
}
|
||||
|
||||
Root_Density_Set& Root_Density_Set::operator= (const Root_Density_Set& RefSet)
|
||||
{
|
||||
Root_Density_Set& Root_Density_Set::operator= (const Root_Density_Set& RefSet)
|
||||
{
|
||||
if (this != &RefSet) {
|
||||
ntypes = RefSet.ntypes;
|
||||
epsilon = RefSet.epsilon;
|
||||
|
@ -234,16 +167,15 @@ Root_Density_Set& Root_Density_Set::operator= (const Root_Density_Set& RefSet)
|
|||
diff = RefSet.diff;
|
||||
}
|
||||
return(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density_Set::Insert_new_function (DP asymptotic_value)
|
||||
{
|
||||
void Root_Density_Set::Insert_new_function (DP asymptotic_value)
|
||||
{
|
||||
// This function extends a set by adding one epsilon_n function on top
|
||||
|
||||
Root_Density_Set Updated_Set (ntypes + 1, 10, 10.0); // last two parameters are meaningless
|
||||
for (int n = 0; n < ntypes; ++n) Updated_Set.epsilon[n] = epsilon[n];
|
||||
|
||||
//Updated_Set.epsilon[ntypes] = Root_Density (epsilon[ntypes - 1].Npts, epsilon[ntypes - 1].lambdamax);
|
||||
Updated_Set.epsilon[ntypes] = Root_Density (50, epsilon[ntypes - 1].lambdamax);
|
||||
Updated_Set.epsilon[ntypes].Set_Asymptotics (asymptotic_value);
|
||||
|
||||
|
@ -253,16 +185,17 @@ void Root_Density_Set::Insert_new_function (DP asymptotic_value)
|
|||
ntypes = Updated_Set.ntypes;
|
||||
epsilon = Updated_Set.epsilon;
|
||||
Npts_total+= Updated_Set.epsilon[ntypes - 1].Npts;
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
|
||||
{
|
||||
void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
|
||||
{
|
||||
// Extend the limits of integration at each level, according to boolean
|
||||
|
||||
// The function extends the limits by 10% on both sides, putting the
|
||||
// extra values to value_infty.
|
||||
|
||||
if (need_to_extend_limit.size() != epsilon.size()) ABACUSerror("Wrong size need_to_extend_limit boolean in Extend_limits.");
|
||||
if (need_to_extend_limit.size() != epsilon.size())
|
||||
ABACUSerror("Wrong size need_to_extend_limit boolean in Extend_limits.");
|
||||
|
||||
Vect_INT nr_new_points_needed(0, ntypes);
|
||||
int total_nr_new_points_added = 0;
|
||||
|
@ -278,7 +211,8 @@ void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
|
|||
// How many new points do we add ? Say 5\% on each side:
|
||||
nr_new_points_needed[n] = ABACUS::max(1, epsilon[n].Npts/20);
|
||||
|
||||
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);
|
||||
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);
|
||||
epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
|
||||
|
||||
for (int i = 0; i < nr_new_points_needed[n]; ++i) {
|
||||
|
@ -302,8 +236,6 @@ void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
|
|||
|
||||
total_nr_new_points_added += 2 * nr_new_points_needed[n];
|
||||
|
||||
//cout << "Extending limits at level " << n << " with " << nr_new_points_needed[n] << " points on each side to " << epsilon[n].lambdamax << endl;
|
||||
|
||||
} // if (need
|
||||
} // for n
|
||||
|
||||
|
@ -313,31 +245,22 @@ void Root_Density_Set::Extend_limits (Vect<bool> need_to_extend_limit)
|
|||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density_Set::Insert_new_points (Vect<Vect<bool> > need_new_point_around)
|
||||
{
|
||||
void Root_Density_Set::Insert_new_points (Vect<Vect<bool> > need_new_point_around)
|
||||
{
|
||||
// need_new_point_around specifies whether a new point needs to be inserted around existing points.
|
||||
|
||||
// Count the number of new points needed per type:
|
||||
Vect_INT nr_new_points_needed(0, ntypes);
|
||||
int total_nr_new_points_needed = 0;
|
||||
for (int n = 0; n < ntypes; ++n) {
|
||||
if (need_new_point_around[n].size() != epsilon[n].Npts) ABACUSerror("Wrong size need_new_point_around boolean in Insert_new_points.");
|
||||
if (need_new_point_around[n].size() != epsilon[n].Npts)
|
||||
ABACUSerror("Wrong size need_new_point_around boolean in Insert_new_points.");
|
||||
for (int i = 0; i < epsilon[n].Npts; ++i)
|
||||
if (need_new_point_around[n][i]) nr_new_points_needed[n]++;
|
||||
total_nr_new_points_needed += nr_new_points_needed[n];
|
||||
}
|
||||
/*
|
||||
// Simplistic version: always keep equidistant points
|
||||
for (int n = 0; n < ntypes; ++n) {
|
||||
Root_Density epsilon_n_before_update = epsilon[n];
|
||||
epsilon[n] = Root_Density(epsilon_n_before_update.Npts + nr_new_points_needed[n], epsilon_n_before_update.lambdamax);
|
||||
epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
|
||||
for (int i = 0; i < epsilon[n].Npts; ++i)
|
||||
epsilon[n].value[i] = epsilon_n_before_update.Return_Value(epsilon[n].lambda[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
// Working version using non-equispaced points
|
||||
// Now update all data via interpolation:
|
||||
|
@ -345,7 +268,6 @@ void Root_Density_Set::Insert_new_points (Vect<Vect<bool> > need_new_point_aroun
|
|||
Root_Density epsilon_n_before_update = epsilon[n];
|
||||
epsilon[n] = Root_Density(epsilon_n_before_update.Npts + nr_new_points_needed[n], epsilon_n_before_update.lambdamax);
|
||||
epsilon[n].Set_Asymptotics(epsilon_n_before_update.value_infty);
|
||||
//cout << "Check: " << epsilon[n].Npts << " " << epsilon_n_before_update.Npts << endl;
|
||||
int nr_pts_added_n = 0;
|
||||
for (int i = 0; i < epsilon_n_before_update.Npts; ++i) {
|
||||
if (!need_new_point_around[n][i]) {
|
||||
|
@ -368,33 +290,17 @@ void Root_Density_Set::Insert_new_points (Vect<Vect<bool> > need_new_point_aroun
|
|||
ABACUSerror("Wrong counting of new points in Insert_new_points.");
|
||||
}
|
||||
|
||||
// Check:
|
||||
//for (int i = 0; i < epsilon[n].Npts - 1; ++i)
|
||||
//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)
|
||||
//{
|
||||
// cout << "Error at level " << n << "\ti " << i << "\t" << epsilon[n].lambda[i] << "\t" << epsilon[n].dlambda[i]
|
||||
// << "\t" << epsilon[n].lambda[i+1] << "\t" << epsilon[n].dlambda[i+1]
|
||||
// << "\t" << epsilon[n].lambda[i] + 0.5 *(epsilon[n].dlambda[i] + epsilon[n].dlambda[i+1]) - epsilon[n].lambda[i+1] << endl;
|
||||
// ABACUSerror("...");
|
||||
//}
|
||||
|
||||
} // for n
|
||||
|
||||
|
||||
//cout << "need_new_pt_above " << need_new_point_above[0] << endl << endl;
|
||||
//cout << "epsilon[0].lambda = " << epsilon[0].lambda << endl << endl;
|
||||
//cout << "epsilon[0].dlambda = " << epsilon[0].dlambda << endl << endl;
|
||||
//cout << "epsilon[0].value = " << epsilon[0].value << endl << endl;
|
||||
|
||||
Npts_total += total_nr_new_points_needed;
|
||||
|
||||
// Done !
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DP Root_Density_Set::Return_Value (int n_ref, DP lambda_ref)
|
||||
{
|
||||
DP Root_Density_Set::Return_Value (int n_ref, DP lambda_ref)
|
||||
{
|
||||
// Returns a value, no matter what !
|
||||
|
||||
if (n_ref < ntypes) return(epsilon[n_ref].Return_Value(lambda_ref));
|
||||
|
@ -402,10 +308,11 @@ DP Root_Density_Set::Return_Value (int n_ref, DP lambda_ref)
|
|||
else // assume asymptotic form of epsilon, proportional to n
|
||||
return(epsilon[ntypes - 1].Return_Value(lambda_ref) * n_ref/(ntypes - 1.0));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Root_Density_Set Root_Density_Set::Return_Compressed_and_Matched_Set (DP comp_factor)
|
||||
{ // Returns a set with 1/comp_factor as many points at each level
|
||||
Root_Density_Set Root_Density_Set::Return_Compressed_and_Matched_Set (DP comp_factor)
|
||||
{
|
||||
// Returns a set with 1/comp_factor as many points at each level
|
||||
|
||||
if (comp_factor >= 2.0)
|
||||
ABACUSerror("Compression factor too large in Return_Compressed_and_Matched_Set, numerical instability will occur.");
|
||||
|
@ -423,18 +330,19 @@ Root_Density_Set Root_Density_Set::Return_Compressed_and_Matched_Set (DP comp_fa
|
|||
Compressed_and_Matched_Set.epsilon[n] = (*this).epsilon[n].Compress_and_Match_Densities (comp_factor);
|
||||
|
||||
return(Compressed_and_Matched_Set);
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density_Set::Match_Densities (Root_Density_Set& RefSet)
|
||||
{ // matched densities to those in RefSet
|
||||
void Root_Density_Set::Match_Densities (Root_Density_Set& RefSet)
|
||||
{
|
||||
// matched densities to those in RefSet
|
||||
|
||||
for (int n = 0; n < ntypes; ++n)
|
||||
for (int i = 0; i < epsilon[n].Npts; ++i)
|
||||
epsilon[n].value[i] = RefSet.epsilon[n].Return_Value(epsilon[n].lambda[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Root_Density_Set::Save (const char* outfile_Cstr)
|
||||
{
|
||||
void Root_Density_Set::Save (const char* outfile_Cstr)
|
||||
{
|
||||
ofstream outfile;
|
||||
outfile.open(outfile_Cstr);
|
||||
outfile.precision(16);
|
||||
|
@ -451,7 +359,7 @@ void Root_Density_Set::Save (const char* outfile_Cstr)
|
|||
}
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -90,8 +90,6 @@ namespace ABACUS {
|
|||
rho_GS = LiebLin_rho_GS (c_int, k_F, lambdamax, Npts, req_prec);
|
||||
n_found = Density_GS (rho_GS);
|
||||
|
||||
//cout << "k_F " << k_F << "\tn_found " << n_found << endl;
|
||||
|
||||
} while (fabs(dk_F) > req_prec && dk_F > 1.0/Npts
|
||||
&& fabs(n - n_found) > req_prec && fabs(n - n_found) > 1.0/Npts);
|
||||
|
||||
|
@ -189,23 +187,6 @@ namespace ABACUS {
|
|||
|
||||
|
||||
// Finite T functions:
|
||||
/*
|
||||
// from ABACUS_TBA.h
|
||||
|
||||
struct LiebLin_TBA_Solution {
|
||||
|
||||
DP c_int;
|
||||
DP mu;
|
||||
DP nbar;
|
||||
DP kBT;
|
||||
Root_Density epsilon;
|
||||
Root_Density depsilon_dmu;
|
||||
Root_Density rho;
|
||||
Root_Density rhoh;
|
||||
|
||||
LiebLin_TBA_Solution (DP c_int_ref, DP mu_ref, DP kBT_ref, int Npts_ref, DP req_diff, int Max_Secs);
|
||||
};
|
||||
*/
|
||||
|
||||
LiebLin_TBA_Solution::LiebLin_TBA_Solution (DP c_int_ref, DP mu_ref, DP kBT_ref, DP req_diff, int Max_Secs)
|
||||
: c_int(c_int_ref), mu(mu_ref), kBT(kBT_ref)
|
||||
|
@ -218,20 +199,10 @@ namespace ABACUS {
|
|||
ebar = LiebLin_ebar_TBA (rho);
|
||||
sbar = LiebLin_sbar_TBA (rho, rhoh);
|
||||
}
|
||||
/*
|
||||
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)
|
||||
: c_int(c_int_ref), mu(mu_ref), kBT(kBT_ref)
|
||||
{
|
||||
epsilon = LiebLin_epsilon_TBA (c_int, mu, kBT, Npts_ref, req_diff, Max_Secs, prev_sol.epsilon);
|
||||
depsilon_dmu = LiebLin_depsilon_dmu_TBA (c_int, mu, kBT, Npts_ref, req_diff, Max_Secs, epsilon, prev_sol.depsilon_dmu);
|
||||
rho = LiebLin_rho_TBA (kBT, epsilon, depsilon_dmu);
|
||||
rhoh = LiebLin_rhoh_TBA (kBT, epsilon, depsilon_dmu);
|
||||
nbar = LiebLin_nbar_TBA (rho);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
LiebLin_TBA_Solution LiebLin_TBA_Solution_fixed_nbar_ebar (DP c_int, DP nbar_required, DP ebar_required, DP req_diff, int Max_Secs)
|
||||
LiebLin_TBA_Solution LiebLin_TBA_Solution_fixed_nbar_ebar (DP c_int, DP nbar_required, DP ebar_required,
|
||||
DP req_diff, int Max_Secs)
|
||||
{
|
||||
// This function finds the TBA solution for a required nbar and ebar (mean energy).
|
||||
// We here try to triangulate the temperature; the chemical potential is triangulated
|
||||
|
@ -263,26 +234,7 @@ namespace ABACUS {
|
|||
lnkBT += dlnkBT;
|
||||
tbasol = LiebLin_TBA_Solution_fixed_nbar(c_int, nbar_required, exp(lnkBT), req_diff, Max_Secs);
|
||||
niter++;
|
||||
//cout << setprecision(16) << "kBT: niter " << niter << "\tebar = " << tbasol.ebar << "\trequired = " << ebar_required << "\tlnkBT = " << lnkBT << "\tdlnkBT = " << dlnkBT << endl;
|
||||
}
|
||||
// FIRST VERSION
|
||||
|
||||
/* SECOND VERSION
|
||||
DP lnkBT = 1.0;
|
||||
DP dlnkBT = 1.0;
|
||||
|
||||
DP mu = 2.0;
|
||||
DP dmu = 1.0;
|
||||
|
||||
LiebLin_TBA_Solution tbasol = LiebLin_TBA_Solution(c_int, mu, kBT, req_diff, Max_Secs);
|
||||
DP mu_prev = mu;
|
||||
DP nbar_prev = tbasol.nbar;
|
||||
DP lnkBT_prev = lnkBT;
|
||||
DP ebar_prev = LiebLin_ebar_TBA (tbasol.rho);
|
||||
|
||||
DP dmu_prev, dnbardmu;
|
||||
DP dlnkBT_prev, debardlnkBT;
|
||||
*/ // SECOND VERSION
|
||||
|
||||
return(tbasol);
|
||||
}
|
||||
|
@ -292,48 +244,6 @@ namespace ABACUS {
|
|||
LiebLin_TBA_Solution LiebLin_TBA_Solution_fixed_nbar (DP c_int, DP nbar_required, DP kBT, DP req_diff, int Max_Secs)
|
||||
{
|
||||
// Find the required mu. Provide some initial guess.
|
||||
/*
|
||||
DP gamma_required = c_int/nbar_required;
|
||||
|
||||
|
||||
// We define a matrix of mu's (calculated once and for all and filled in here)
|
||||
// from which we can define an accurate first guess for mu, given gamma_required and kBT.
|
||||
|
||||
// The gamma's are by definition (1/16) * 2^{igamma},
|
||||
// and the kBT are (1/16) * 2^{iT}.
|
||||
int ndata = 16;
|
||||
Vect<DP> gamma(ndata);
|
||||
Vect<DP> Tred(ndata); // reduced temperature, kBT/
|
||||
for (int i = 0; i < ndata; ++i) {
|
||||
gamma[i] = 0.0625 * pow(2.0, i);
|
||||
T[i] = 0.0625 * pow(2.0, i);
|
||||
}
|
||||
SQMat<DP> mudata(ndata);
|
||||
// This data was computed separately, for unit filling, using 512 points, to accuracy 10^-4:
|
||||
|
||||
// Figure out which index igamma we should use:
|
||||
// (1/16) * 2^{igamma_low} <~ gamma_required, so
|
||||
int igamma_below = int(log(gamma_required * 16.0)/log(2.0));
|
||||
// Similarly,
|
||||
int iT_below = int(log(kBT * 16.0)/log(2.0));
|
||||
|
||||
igamma_below = ABACUS::max(igamma_below, 0);
|
||||
igamma_below = ABACUS::min(igamma_below, ndata - 1);
|
||||
iT_below = ABACUS::max(iT_below, 0);
|
||||
iT_below = ABACUS::min(iT_below, ndata - 1);
|
||||
// We use indices igamma_below, igamma_below + 1, iT_below, iT_below + 1 to guess mu:
|
||||
// do a four-point extrapolation,
|
||||
DP mu = ((gamma[igamma_below + 1] - gamma_required) * (T[iT_below + 1] - kBT) * mudata[igamma_below][iT_below]
|
||||
+ (gamma_required - gamma[igamma_below]) * (T[iT_below + 1] - kBT) * mudata[igamma_below + 1][iT_below]
|
||||
+ (gamma[igamma_below + 1] - gamma_required) * (kBT - T[iT_below]) * mudata[igamma_below][iT_below + 1]
|
||||
+ (gamma_required - gamma[igamma_below]) * (kBT - T[iT_below]) * mudata[igamma_below + 1][iT_below + 1])
|
||||
/((gamma[igamma_below + 1] - gamma[igamma_below]) * (T[iT_below + 1] - T[iT_below]));
|
||||
|
||||
// Translate to the required filling:
|
||||
|
||||
|
||||
DP dnbardmu = ;
|
||||
*/
|
||||
|
||||
DP mu = 2.0;
|
||||
DP dmu = 1.0;
|
||||
|
@ -360,7 +270,6 @@ namespace ABACUS {
|
|||
mu += dmu;
|
||||
tbasol = LiebLin_TBA_Solution(c_int, mu, kBT, req_diff, Max_Secs);
|
||||
niter++;
|
||||
//cout << setprecision(16) << "\tmu: niter " << niter << "\tnbar = " << tbasol.nbar << "\trequired = " << nbar_required<< "\tmu = " << mu << "\tdmu = " << dmu << endl;
|
||||
}
|
||||
|
||||
return(tbasol);
|
||||
|
@ -454,7 +363,9 @@ namespace ABACUS {
|
|||
int nr_pts_to_add_left = epsilon.Npts/10;
|
||||
int nr_pts_to_add_right = epsilon.Npts/10;
|
||||
Root_Density epsilon_before_update = epsilon;
|
||||
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]);
|
||||
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]);
|
||||
|
||||
// Initialize points added on left
|
||||
for (int i = 0; i < nr_pts_to_add_left; ++i) {
|
||||
|
@ -470,9 +381,13 @@ namespace ABACUS {
|
|||
}
|
||||
// Initialize points added on right
|
||||
for (int i = 0; i < nr_pts_to_add_right; ++i) {
|
||||
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];
|
||||
epsilon.dlambda[nr_pts_to_add_left + epsilon_before_update.Npts + i] = epsilon_before_update.dlambda[epsilon_before_update.Npts - 1];
|
||||
epsilon.value[nr_pts_to_add_left + epsilon_before_update.Npts + i] = epsilon_before_update.value[epsilon_before_update.Npts - 1];
|
||||
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];
|
||||
epsilon.dlambda[nr_pts_to_add_left + epsilon_before_update.Npts + i] =
|
||||
epsilon_before_update.dlambda[epsilon_before_update.Npts - 1];
|
||||
epsilon.value[nr_pts_to_add_left + epsilon_before_update.Npts + i] =
|
||||
epsilon_before_update.value[epsilon_before_update.Npts - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,14 +399,16 @@ namespace ABACUS {
|
|||
{
|
||||
|
||||
clock_t StartTime = clock();
|
||||
int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100; // give 30 seconds to wrap up, assume we time to 2% accuracy.
|
||||
int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100;
|
||||
// give 30 seconds to wrap up, assume we time to 2% accuracy.
|
||||
|
||||
// Set basic precision needed:
|
||||
DP running_prec = 1.0;
|
||||
|
||||
DP refine_fraction = 0.5; // value fraction of points to be refined
|
||||
|
||||
DP lambdamax_init = 10.0 * sqrt(ABACUS::max(1.0, kBT + mu)); // such that exp(-(lambdamax^2 - mu - Omega)/T) <~ machine_eps
|
||||
DP lambdamax_init = 10.0 * sqrt(ABACUS::max(1.0, kBT + mu));
|
||||
// such that exp(-(lambdamax^2 - mu - Omega)/T) <~ machine_eps
|
||||
|
||||
int Npts = 50;
|
||||
|
||||
|
@ -522,7 +439,6 @@ namespace ABACUS {
|
|||
// Refine... returns sum_delta_tni_dlambda, so running prec is estimated as...
|
||||
previous_running_prec = running_prec;
|
||||
running_prec = Refine_LiebLin_epsilon_TBA (epsilon, c_int, mu, kBT, refine_fraction);
|
||||
//cout << "ncycles = " << ncycles << "\trunning_prec = " << running_prec << endl;
|
||||
running_prec = ABACUS::min(running_prec, previous_running_prec);
|
||||
|
||||
// Now iterate to convergence for given discretization
|
||||
|
@ -537,11 +453,13 @@ namespace ABACUS {
|
|||
Vect<DP> Tln1plusemineps(epsilon.Npts);
|
||||
for (int i = 0; i < epsilon.Npts; ++i) {
|
||||
Tln1plusemineps[i] = epsilon.value[i] > 0.0 ?
|
||||
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)))
|
||||
//kBT * log(1.0 + exp(-epsilon.value[i]/kBT))
|
||||
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)))
|
||||
:
|
||||
-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)));
|
||||
//-epsilon.value[i] + kBT * log (1.0 + exp(epsilon.value[i]/kBT));
|
||||
-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)));
|
||||
// Keep previous rapidities:
|
||||
epsilon.prev_value[i] = epsilon.value[i];
|
||||
}
|
||||
|
@ -551,7 +469,11 @@ namespace ABACUS {
|
|||
for (int i = 0; i < epsilon.Npts; ++i) {
|
||||
a_2_Tln_conv[i] = 0.0;
|
||||
|
||||
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];
|
||||
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];
|
||||
|
||||
} // a_2_Tln_conv is now calculated
|
||||
|
||||
|
@ -563,9 +485,7 @@ namespace ABACUS {
|
|||
epsilon.value[i] -= a_2_Tln_conv[i];
|
||||
|
||||
// Include some damping:
|
||||
//epsilon.value[i] = 0.1 * epsilon.prev_value[i] + 0.9 * epsilon.value[i];
|
||||
epsilon.value[i] = 0.1 * epsilon.prev_value[i] + 0.9 * epsilon.value[i];
|
||||
//* (1.0 + (epsilon.value[i] - epsilon.prev_value[i])/fabs(epsilon.value[i] + epsilon.prev_value[i]));
|
||||
}
|
||||
|
||||
niter++;
|
||||
|
@ -582,15 +502,11 @@ namespace ABACUS {
|
|||
StopTime = clock();
|
||||
CPU_ticks += StopTime - StartTime;
|
||||
|
||||
//cout << "epsilon: niter = " << niter << "\tdiff = " << epsilon.diff << endl;
|
||||
//cout << epsilon.lambda[0] << "\t" << epsilon.dlambda[0] << endl;
|
||||
//cout << "a_2_Tln_conv[0] = " << a_2_Tln_conv[0] << "\tTln1plusemineps[0] = " << Tln1plusemineps[0] << endl;
|
||||
} while (niter < 5 || niter < niter_max && CPU_ticks < Max_CPU_ticks && epsilon.diff > 0.1*running_prec);
|
||||
|
||||
ncycles++;
|
||||
niter_tot += niter;
|
||||
|
||||
//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;
|
||||
} // do cycles
|
||||
while (ncycles < 5 || running_prec > req_diff && CPU_ticks < Max_CPU_ticks);
|
||||
|
||||
|
@ -603,7 +519,8 @@ namespace ABACUS {
|
|||
{
|
||||
|
||||
clock_t StartTime = clock();
|
||||
int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100; // give 30 seconds to wrap up, assume we time to 2% accuracy.
|
||||
int Max_CPU_ticks = 98 * (Max_Secs - 0) * CLOCKS_PER_SEC/100;
|
||||
// give 30 seconds to wrap up, assume we time to 2% accuracy.
|
||||
|
||||
Root_Density depsilon_dmu = epsilon;
|
||||
|
||||
|
@ -644,7 +561,10 @@ namespace ABACUS {
|
|||
a_2_depsover1plusepluseps_conv[i] = 0.0;
|
||||
|
||||
for (int j = 0; j < depsilon_dmu.Npts; ++j)
|
||||
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];
|
||||
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];
|
||||
}
|
||||
|
||||
// Reconstruct the depsilon_dmu function:
|
||||
|
@ -668,7 +588,6 @@ namespace ABACUS {
|
|||
StopTime = clock();
|
||||
CPU_ticks += StopTime - StartTime;
|
||||
|
||||
//cout << "depsilon_dmu: niter = " << niter << "\tdiff = " << depsilon_dmu.diff << endl;
|
||||
} while (niter < 5 || niter < niter_max && CPU_ticks < Max_CPU_ticks && depsilon_dmu.diff > req_diff);
|
||||
|
||||
return(depsilon_dmu);
|
||||
|
@ -717,7 +636,9 @@ namespace ABACUS {
|
|||
DP LiebLin_sbar_TBA (const Root_Density& rho, const Root_Density& rhoh)
|
||||
{
|
||||
DP sbar = 0.0;
|
||||
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];
|
||||
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];
|
||||
|
||||
return(sbar);
|
||||
}
|
||||
|
@ -743,20 +664,12 @@ namespace ABACUS {
|
|||
lambda_found[Nfound++] = 0.25 * (rho.lambda[i-1] + 3.0 * rho.lambda[i]);
|
||||
}
|
||||
else {
|
||||
//lambda_found[Nfound] = rho.lambda[i];
|
||||
// Better: center the lambda_found between these points:
|
||||
//lambda_found[Nfound] = rho.lambda[i-1] + (rho.lambda[i] - rho.lambda[i-1]) * ((Nfound + 1.0) - integral_prev)/(integral - integral_prev);
|
||||
lambda_found[Nfound] = 0.5 * (rho.lambda[i-1] + rho.lambda[i]);
|
||||
Nfound++;
|
||||
}
|
||||
}
|
||||
//cout << "\ti = " << i << "\tintegral = " << integral << "\tNfound = " << Nfound << endl;
|
||||
}
|
||||
//cout << "rho: " << rho.Npts << " points" << endl << rho.value << endl;
|
||||
//cout << "sym: " << rho.value[0] << " " << rho.value[rho.value.size() - 1]
|
||||
// << "\t" << rho.value[rho.value.size()/2] << " " << rho.value[rho.value.size()/2 + 1] << endl;
|
||||
//cout << "Found " << Nfound << " particles." << endl;
|
||||
//cout << "lambda_found = " << lambda_found << endl;
|
||||
|
||||
Vect<DP> lambda(N);
|
||||
// Fill up the found rapidities:
|
||||
|
@ -770,11 +683,9 @@ namespace ABACUS {
|
|||
for (int i = 0; i < N; ++i) {
|
||||
DP sum = 0.0;
|
||||
for (int j = 0; j < N; ++j) sum += 2.0 * atan((lambda[i] - lambda[j])/c_int);
|
||||
//Ix2[i] = 2.0* int((L * lambda[i] + sum)/twoPI) + (N % 2) - 1;
|
||||
// For N is even/odd, we want to round off to the nearest odd/even integer.
|
||||
Ix2[i] = 2.0 * floor((L* lambda[i] + sum)/twoPI + 0.5 * (N%2 ? 1 : 2)) + (N%2) - 1;
|
||||
}
|
||||
//cout << "Found quantum numbers " << endl << Ix2 << endl;
|
||||
|
||||
// Check that the quantum numbers are all distinct:
|
||||
bool allOK = false;
|
||||
|
@ -784,12 +695,10 @@ namespace ABACUS {
|
|||
allOK = true;
|
||||
for (int i = 0; i < N-1; ++i) if (Ix2[i] == Ix2[i+1]) allOK = false;
|
||||
}
|
||||
//cout << "Found modified quantum numbers " << endl << Ix2 << endl;
|
||||
|
||||
LiebLin_Bethe_State rhostate(c_int, L, N);
|
||||
rhostate.Ix2 = Ix2;
|
||||
rhostate.Compute_All(true);
|
||||
//cout << "rapidities of state found: " << rhostate.lambdaoc << endl;
|
||||
|
||||
return(rhostate);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ namespace ABACUS {
|
|||
conv = 0.0;
|
||||
for (int j = 0; j < rhotot_GS.Npts; ++j)
|
||||
conv += fabs(rhotot_GS.lambda[j]) > B ? 0.0 :
|
||||
XXZ_a2_kernel (sin2zeta, cos2zeta, rhotot_GS.lambda[i] - rhotot_GS.lambda[j]) * rhotot_GS.prev_value[j] * rhotot_GS.dlambda[j];
|
||||
XXZ_a2_kernel (sin2zeta, cos2zeta, rhotot_GS.lambda[i] - rhotot_GS.lambda[j])
|
||||
* rhotot_GS.prev_value[j] * rhotot_GS.dlambda[j];
|
||||
rhotot_GS.value[i] = XXZ_a1_kernel(sinzeta, coszeta, rhotot_GS.lambda[i]) - conv;
|
||||
}
|
||||
|
||||
|
@ -109,11 +110,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_rhotot_GS (zeta, B, rhotot_GS);
|
||||
//cout << rhotot_GS.diff << endl;
|
||||
niter ++;
|
||||
} while (rhotot_GS.diff > req_prec);
|
||||
|
||||
//cout << "rhotot: niter = " << niter << endl;
|
||||
return(rhotot_GS);
|
||||
}
|
||||
|
||||
|
@ -147,7 +146,6 @@ namespace ABACUS {
|
|||
XXZ_a2_kernel (sin2zeta, cos2zeta, eps_GS.lambda[i] - eps_GS.lambda[j])
|
||||
* eps_GS.prev_value[j] * eps_GS.dlambda[j];
|
||||
eps_GS.value[i] = Hz - PI * sinzeta * XXZ_a1_kernel(sinzeta, coszeta, eps_GS.lambda[i]) - conv;
|
||||
//cout << i << "\t" << eps_GS.lambda[i] << "\t" << eps_GS.value[i] << "\t" << conv << endl;
|
||||
}
|
||||
|
||||
// Calculate the sum of differences:
|
||||
|
@ -175,12 +173,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_eps_GS (zeta, Hz, eps_GS);
|
||||
//cout << eps_GS.diff << endl;
|
||||
niter++;
|
||||
//cout << niter << "\t" << eps_GS.diff << endl;
|
||||
} while (eps_GS.diff > req_prec);
|
||||
|
||||
//cout << "eps: niter = " << niter << endl;
|
||||
return(eps_GS);
|
||||
}
|
||||
|
||||
|
@ -232,11 +227,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_depsdlambda_GS (zeta, B, depsdlambda_GS);
|
||||
//cout << depsdlambda_GS.diff << endl;
|
||||
niter++;
|
||||
} while (depsdlambda_GS.diff > req_prec);
|
||||
|
||||
//cout << "depsdlambda: niter = " << niter << endl;
|
||||
return(depsdlambda_GS);
|
||||
}
|
||||
|
||||
|
@ -289,12 +282,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_b2BB_lambda_B (zeta, B, b2BB_lambda_B);
|
||||
//cout << eps_GS.diff << endl;
|
||||
niter++;
|
||||
} while (b2BB_lambda_B.diff > req_prec);
|
||||
|
||||
//if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
|
||||
//cout << "Kbackflow: niter = " << niter << endl;
|
||||
return(b2BB_lambda_B);
|
||||
}
|
||||
|
||||
|
@ -347,12 +337,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_b2BB_lambda_lambdap (zeta, B, lambdap, b2BB_lambda_lambdap);
|
||||
//cout << eps_GS.diff << endl;
|
||||
niter++;
|
||||
} while (b2BB_lambda_lambdap.diff > req_prec);
|
||||
|
||||
//if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
|
||||
//cout << "Kbackflow: niter = " << niter << endl;
|
||||
return(b2BB_lambda_lambdap);
|
||||
}
|
||||
|
||||
|
@ -368,14 +355,12 @@ namespace ABACUS {
|
|||
DP sin2zeta = sin(2.0*zeta);
|
||||
DP cos2zeta = cos(2.0*zeta);
|
||||
for (int i = 0; i < Kbackflow_GS.Npts; ++i) {
|
||||
//if (Kbackflow_GS.lambda[i] < -B || Kbackflow_GS.lambda[i] > lambda_p + lambda_h + B) Kbackflow_GS.value[i] = 0.0;
|
||||
if (false && fabs(Kbackflow_GS.lambda[i]) > B) Kbackflow_GS.value[i] = 0.0;
|
||||
else {
|
||||
// First, calculate the convolution
|
||||
conv = 0.0;
|
||||
for (int j = 0; j < Kbackflow_GS.Npts; ++j)
|
||||
conv += fabs(Kbackflow_GS.lambda[j]) > B ? 0.0 :
|
||||
//(Kbackflow_GS.lambda[i] < -B || Kbackflow_GS.lambda[i] > lambda_p + lambda_h + B) ? 0.0 :
|
||||
XXZ_a2_kernel (sin2zeta, cos2zeta, Kbackflow_GS.lambda[i] - Kbackflow_GS.lambda[j])
|
||||
* Kbackflow_GS.prev_value[j] * Kbackflow_GS.dlambda[j];
|
||||
Kbackflow_GS.value[i] = -XXZ_a2_kernel(sin2zeta, cos2zeta, Kbackflow_GS.lambda[i] - lambda_p)
|
||||
|
@ -407,12 +392,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_Kbackflow_GS (zeta, B, lambda_p, lambda_h, Kbackflow_GS);
|
||||
//cout << eps_GS.diff << endl;
|
||||
niter++;
|
||||
} while (Kbackflow_GS.diff > req_prec);
|
||||
|
||||
//if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
|
||||
//cout << "Kbackflow: niter = " << niter << endl;
|
||||
return(Kbackflow_GS);
|
||||
}
|
||||
|
||||
|
@ -465,12 +447,9 @@ namespace ABACUS {
|
|||
int niter = 0;
|
||||
do {
|
||||
Iterate_XXZ_Fbackflow_GS (zeta, B, lambda_p, lambda_h, Fbackflow_GS);
|
||||
//cout << eps_GS.diff << endl;
|
||||
niter++;
|
||||
} while (Fbackflow_GS.diff > req_prec);
|
||||
|
||||
//if (lambda_p + lambda_h + 2.0*B > 0.0) cout << "Nonzero backflow possible." << endl;
|
||||
//cout << "Fbackflow: niter = " << niter << endl;
|
||||
return(Fbackflow_GS);
|
||||
}
|
||||
|
||||
|
@ -519,199 +498,10 @@ namespace ABACUS {
|
|||
|
||||
do {
|
||||
Iterate_XXZ_Z_GS (zeta, B, Z_GS);
|
||||
//cout << depsdlambda_GS.diff << endl;
|
||||
} while (Z_GS.diff > req_prec);
|
||||
|
||||
return(Z_GS);
|
||||
}
|
||||
|
||||
/*
|
||||
void XXZ_Compare_Lattice_and_Continuum_Backflows_base_1010 (DP Delta, int N, int M, long long int id)
|
||||
{
|
||||
// Define the chain: J, Delta, h, Nsites
|
||||
Heis_Chain chain(1.0, Delta, 0.0, N);
|
||||
|
||||
// Define the base: chain, Mdown
|
||||
Heis_Base gbase(chain, M);
|
||||
|
||||
// Define the ground state
|
||||
XXZ_Bethe_State gstate(chain, gbase);
|
||||
|
||||
// Compute everything about the ground state
|
||||
gstate.Compute_All(true);
|
||||
|
||||
// Define the number of rapidities for an excited state
|
||||
Vect_INT Nrapidities(0, chain.Nstrings);
|
||||
Nrapidities[0] = M;
|
||||
|
||||
Vect_INT Nexcitations(0, 2* chain.Nstrings + 2);
|
||||
Nexcitations[0] = 0;
|
||||
Nexcitations[1] = 1;
|
||||
Nexcitations[2] = 0;
|
||||
Nexcitations[3] = 1;
|
||||
|
||||
// Define a base configuration for this set of rapidity numbers
|
||||
Heis_Base ebase (chain, Nrapidities);
|
||||
|
||||
// Define the excited state
|
||||
XXZ_Bethe_State estate(chain, ebase);
|
||||
|
||||
// Define an offset from a base and a number of holes
|
||||
Ix2_Offsets offsets(ebase, Nexcitations);
|
||||
|
||||
// Set the offset to the desired id
|
||||
offsets.Set_to_id (id);
|
||||
|
||||
// Set the offset data into the quantum numbers
|
||||
estate.Set_Ix2_Offsets(offsets);
|
||||
|
||||
// Compute everything about this eigenstate
|
||||
estate.Compute_All(true);
|
||||
|
||||
DP k_ext_N = estate.K - gstate.K;
|
||||
DP omega_N = estate.E - gstate.E;
|
||||
DP lambdap = estate.lambda[0][0];
|
||||
DP lambdah = 0.0;
|
||||
for (int alpha = 1; alpha < estate.base[0] - 1; ++alpha)
|
||||
if (estate.Ix2[0][alpha + 1] > estate.Ix2[0][alpha] + 2) {
|
||||
lambdah = 0.5 * (estate.lambda[0][alpha] + estate.lambda[0][alpha + 1]);
|
||||
}
|
||||
|
||||
|
||||
// Now solve the thermodynamic equations:
|
||||
DP req_prec = 1.0e-12;
|
||||
DP Hz_N = H_vs_M (Delta, N, M);
|
||||
cout << "Hz_N = " << Hz_N << endl;
|
||||
DP lambdamax = 4.0 * fabs(gstate.lambda[0][0]);
|
||||
int Npts = 2000;
|
||||
Root_Density eps_GS = XXZ_eps_GS (Delta, Hz_N, lambdamax, Npts, req_prec);
|
||||
|
||||
// We can read off the value of B from the obtained eps_GS function:
|
||||
DP B_eps = 0.0;
|
||||
int iB_eps = Npts/2;
|
||||
for (int i = Npts/2; i < Npts - 1; ++i)
|
||||
if (eps_GS.value[i] * eps_GS.value[i+1] < 0.0) {
|
||||
B_eps = 0.5 * (eps_GS.lambda[i] + eps_GS.lambda[i+1]);
|
||||
iB_eps = i;
|
||||
}
|
||||
if (B_eps == 0.0) {
|
||||
cout << "Delta = " << Delta << "\tN = " << N << "\tM = " << M << "\tHz_N = " << Hz_N << "\tid = " << id << endl;
|
||||
ABACUSerror("B not found.");
|
||||
}
|
||||
if (B_eps > 0.5 * lambdamax) {
|
||||
cout << "Delta = " << Delta << "\tN = " << N << "\tM = " << M << "\tHz_N = " << Hz_N << "\tid = " << id << endl;
|
||||
ABACUSerror("Use a higher value of lambdamax.");
|
||||
}
|
||||
//DP lambdamax = lambdamax_eps;
|
||||
//DP lambdamax = 2.0 * fabs(gstate.lambda[0][0]); // window of definition of Kbackflow is covered
|
||||
// Start by finding the appropriate B:
|
||||
DP B = DP(M)/N; // initial guess;
|
||||
DP B_old = B;
|
||||
DP dB = 0.5 * B; // variation we allow;
|
||||
DP m_TBA = 0.0;
|
||||
//Vect<Root_Density> rhotot_GS_iter(10);// = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
|
||||
Root_Density rhotot_GS = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
|
||||
int iter = 0;
|
||||
do {
|
||||
B_old = B;
|
||||
rhotot_GS = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
|
||||
m_TBA = 0.0;
|
||||
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];
|
||||
if (m_TBA < DP(M)/N) B += dB;
|
||||
else B -= dB;
|
||||
cout << "B_old = " << B_old << "\tB = " << B << "\tdB = " << dB << "\tm = " << m_TBA << "\tM/N = " << DP(M)/N << endl;
|
||||
dB *= 1.0/1.9;
|
||||
} while (dB > 0.001 && iter < 9);
|
||||
|
||||
cout << "Check of consistency: B_eps = " << B_eps << "\tB = " << B << "\tm_TBA = " << m_TBA << "\tM/N = " << DP(M)/N << endl;
|
||||
|
||||
//Root_Density rhotot_GS = XXZ_rhotot_GS (Delta, B, lambdamax, Npts, req_prec);
|
||||
Root_Density b2BB_lambda_B = XXZ_b2BB_lambda_B (Delta, B, lambdamax, Npts, req_prec);
|
||||
Root_Density Kbackflow_GS = XXZ_Kbackflow_GS (Delta, B, lambdamax, lambdap, lambdah, Npts, req_prec);
|
||||
Root_Density Fbackflow_GS = XXZ_Fbackflow_GS (Delta, B, lambdamax, lambdap, lambdah, Npts, req_prec);
|
||||
|
||||
// Calculate the momentum and energy of the TBA state:
|
||||
// Momentum:
|
||||
DP conv = 0.0;
|
||||
DP zeta = acos(Delta);
|
||||
for (int l = 0; l < rhotot_GS.Npts; ++l) {
|
||||
conv += fabs(rhotot_GS.lambda[l]) > B ? 0.0 :
|
||||
(XXZ_phi2_kernel(zeta, lambdap - rhotot_GS.lambda[l])
|
||||
- XXZ_phi2_kernel(zeta, lambdah - rhotot_GS.lambda[l]))
|
||||
* rhotot_GS.value[l] * rhotot_GS.dlambda[l];
|
||||
}
|
||||
DP k_ext_TBA = -XXZ_phi1_kernel (zeta, lambdap) + XXZ_phi1_kernel (zeta, lambdah) + conv;
|
||||
// Energy:
|
||||
conv = 0.0;
|
||||
DP sinzeta = sin(zeta);
|
||||
DP coszeta = cos(zeta);
|
||||
for (int l = 0; l < Kbackflow_GS.Npts; ++l)
|
||||
conv += fabs(Kbackflow_GS.lambda[l]) > B ? 0.0 :
|
||||
(Hz_N - PI * sinzeta * XXZ_a1_kernel(sinzeta, coszeta, Kbackflow_GS.lambda[l]))
|
||||
* Kbackflow_GS.value[l] * Kbackflow_GS.dlambda[l];
|
||||
DP omega_TBA = -PI * sin(zeta) * (XXZ_a1_kernel(sinzeta, coszeta, lambdap)
|
||||
- XXZ_a1_kernel(sinzeta, coszeta, lambdah)) + conv;
|
||||
|
||||
cout << "k_ext_N = " << k_ext_N << "\tk_ext_TBA = " << k_ext_TBA << "\tomega_N = " << omega_N << "\tomega_TBA = " << omega_TBA << endl;
|
||||
|
||||
// Get back to the finite lattice case:
|
||||
// Define densities as 1/N \sum_j delta (lambda - lambda_j); use Gaussian smoothing of functions.
|
||||
DP gwidth = 2.0 * B * log(DP(N))/M; // mean rapidity spacing times some factor, for smoothing of Gaussians
|
||||
DP gwidthsq = gwidth * gwidth;
|
||||
Vect_DP rhoGS_N (0.0, Npts);
|
||||
Vect_DP rhoexc_N (0.0, Npts);
|
||||
Vect_DP Kflow_N (0.0, Npts);
|
||||
for (int iout = 0; iout < Npts; ++iout) {
|
||||
DP lambdaout = rhotot_GS.lambda[iout];
|
||||
// We compute the densities at each point...
|
||||
for (int alpha = 0; alpha < M; ++alpha)
|
||||
rhoGS_N[iout] += exp(-(gstate.lambda[0][alpha] - lambdaout) * (gstate.lambda[0][alpha] - lambdaout)/gwidthsq);
|
||||
rhoGS_N[iout] /= N * sqrt(PI) * gwidth;
|
||||
for (int alpha = 1; alpha < estate.base[0]; ++alpha)
|
||||
rhoexc_N[iout] += exp(-(estate.lambda[0][alpha] - lambdaout) * (estate.lambda[0][alpha] - lambdaout)/gwidthsq);
|
||||
rhoexc_N[iout] /= N * sqrt(PI) * gwidth;
|
||||
|
||||
Kflow_N[iout] = N * (rhoexc_N[iout] - rhoGS_N[iout] + (1.0/N) * exp(-(lambdah - lambdaout) * (lambdah - lambdaout)/gwidthsq)/(sqrt(PI) * gwidth));
|
||||
} // for iout
|
||||
|
||||
cout << "Here 1" << endl;
|
||||
// Now produce a file with the density flow:
|
||||
stringstream flo_stringstream;
|
||||
flo_stringstream << "Flow_D_" << Delta << "_N_" << N << "_M_" << M << "_base_id_" << estate.base_id << "_type_id_" << estate.type_id
|
||||
<< "_id_" << estate.id << ".flo";
|
||||
string flo_string = flo_stringstream.str();
|
||||
const char* flo_Cstr = flo_string.c_str();
|
||||
|
||||
ofstream outfile_flo;
|
||||
outfile_flo.open(flo_Cstr);
|
||||
outfile_flo.precision(16);
|
||||
|
||||
for (int iout = 0; iout < Npts; ++iout)
|
||||
outfile_flo << rhotot_GS.lambda[iout] << "\t" << rhotot_GS.value[iout] << "\t" << rhoGS_N[iout] << "\t"
|
||||
<< rhoexc_N[iout] << "\t" << Kbackflow_GS.value[iout] << "\t"
|
||||
<< (fabs(Kbackflow_GS.lambda[iout]) > B ? 0.0 : Kbackflow_GS.value[iout]) - b2BB_lambda_B.value[iout] * Fbackflow_GS.value[iB_eps]
|
||||
+ b2BB_lambda_B.value[b2BB_lambda_B.Npts - 1 - iout] * Fbackflow_GS.value[Fbackflow_GS.Npts - 1 - iB_eps] << "\t" << Kflow_N[iout] << endl;
|
||||
|
||||
outfile_flo.close();
|
||||
|
||||
// ... and a file with the remainder of the data:
|
||||
stringstream dat_stringstream;
|
||||
dat_stringstream << "Flow_D_" << Delta << "_N_" << N << "_M_" << M << "_base_id_" << estate.base_id << "_type_id_" << estate.type_id
|
||||
<< "_id_" << estate.id << ".dat";
|
||||
string dat_string = dat_stringstream.str();
|
||||
const char* dat_Cstr = dat_string.c_str();
|
||||
|
||||
ofstream outfile_dat;
|
||||
outfile_dat.open(dat_Cstr);
|
||||
outfile_dat.precision(16);
|
||||
|
||||
outfile_dat << "lambdap\tlambdah\tk_ext_N\tk_ext_TBA\tomega_N\tomega_TBA"
|
||||
<< lambdap << "\t" << lambdah << "\t" << k_ext_N << "\t" << k_ext_TBA << "\t" << omega_N << "\t" << omega_TBA << endl;
|
||||
|
||||
outfile_dat.close();
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace ABACUS {
|
|||
|
||||
// Lieb-Liniger:
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
name << "LiebLin_";
|
||||
if (whichDSF == 'Z') name << "Z";
|
||||
|
@ -42,7 +43,6 @@ namespace ABACUS {
|
|||
else ABACUSerror("Option not implemented in Data_File_Name");
|
||||
|
||||
name << "_c_" << c_int << "_L_" << L << "_N_" << N;
|
||||
//if (fixed_iK) name << "_iK_" << iKneeded;
|
||||
if (defaultScanStatename == "") name << "_" << N << "_0_"; // simulates label of ground state
|
||||
else name << "_" << defaultScanStatename;
|
||||
if (iKmin == iKmax) name << "_iK_" << iKmin;
|
||||
|
@ -53,8 +53,8 @@ namespace ABACUS {
|
|||
return;
|
||||
}
|
||||
|
||||
//void Data_File_Name (stringstream& name, char whichDSF, bool fixed_iK, int iKneeded, LiebLin_Bethe_State& State, LiebLin_Bethe_State& RefScanState)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT, LiebLin_Bethe_State& State, LiebLin_Bethe_State& RefScanState, string defaultScanStatename)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT,
|
||||
LiebLin_Bethe_State& State, LiebLin_Bethe_State& RefScanState, string defaultScanStatename)
|
||||
{
|
||||
name << "LiebLin_";
|
||||
if (whichDSF == 'Z') name << "Z";
|
||||
|
@ -68,7 +68,6 @@ namespace ABACUS {
|
|||
else ABACUSerror("Option not implemented in Data_File_Name");
|
||||
|
||||
name << "_c_" << State.c_int << "_L_" << State.L << "_N_" << State.N;
|
||||
//if (fixed_iK) name << "_iK_" << iKneeded;
|
||||
if (defaultScanStatename == "") name << "_" << State.label;
|
||||
else name << "_" << defaultScanStatename;
|
||||
if (iKmin == iKmax) name << "_iK_" << iKmin; else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
|
@ -81,8 +80,8 @@ namespace ABACUS {
|
|||
|
||||
// Heisenberg:
|
||||
|
||||
//void Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, bool fixed_iK, int iKneeded, int N2)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax, DP kBT, int N2, string defaultScanStatename)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, DP Delta, int N, int M, int iKmin, int iKmax,
|
||||
DP kBT, int N2, string defaultScanStatename)
|
||||
{
|
||||
name << "HEIS_";
|
||||
if (whichDSF == 'Z') name << "Z";
|
||||
|
@ -104,21 +103,14 @@ namespace ABACUS {
|
|||
if (defaultScanStatename == "") name << "_" << M << "_0_"; // simulates label of ground state
|
||||
else name << "_" << defaultScanStatename;
|
||||
|
||||
//if (fixed_iK) {
|
||||
// name << "_iK_";
|
||||
// for (int i = 0; i < int(log10(DP(N/2))) - int(log10(DP(iKneeded))); ++i) name << "0";
|
||||
// name << iKneeded;
|
||||
//}
|
||||
// From ABACUS++G_8 onwards: for Heisenberg, always scan over all momentum integers
|
||||
//if (iKmin == iKmax) name << "_iK_" << iKmin; else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
if (kBT > 0.0) name << "_kBT_" << kBT;
|
||||
if (whichDSF == 'q') name << "_N2_" << N2;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//void Data_File_Name (stringstream& name, char whichDSF, bool fixed_iK, int iKneeded, Heis_Bethe_State& State, Heis_Bethe_State& RefScanState)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT, Heis_Bethe_State& State, Heis_Bethe_State& RefScanState, string defaultScanStatename)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT,
|
||||
Heis_Bethe_State& State, Heis_Bethe_State& RefScanState, string defaultScanStatename)
|
||||
{
|
||||
name << "HEIS_";
|
||||
if (whichDSF == 'Z') name << "Z";
|
||||
|
@ -139,15 +131,6 @@ namespace ABACUS {
|
|||
name << State.base.Mdown;
|
||||
if (defaultScanStatename == "") name << "_" << State.label;
|
||||
else name << "_" << defaultScanStatename;
|
||||
/*
|
||||
if (fixed_iK) {
|
||||
name << "_iK_";
|
||||
for (int i = 0; i < int(log10(DP(State.chain.Nsites/2))) - int(log10(DP(iKneeded))); ++i) name << "0";
|
||||
name << iKneeded;
|
||||
}
|
||||
*/
|
||||
// From ABACUS++G_8 onwards: for Heisenberg, always scan over all momentum integers
|
||||
//if (iKmin == iKmax) name << "_iK_" << iKmin; else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
if (kBT > 0.0) name << "_kBT_" << kBT;
|
||||
if (whichDSF == 'q') name << "_N2_" << RefScanState.chain.Nsites;
|
||||
|
||||
|
@ -155,9 +138,10 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
|
||||
// One-D spinless fermions:
|
||||
// One-D spinless fermions: IN DEVELOPMENT
|
||||
/*
|
||||
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)
|
||||
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)
|
||||
{
|
||||
name << "ODSLF_";
|
||||
if (whichDSF == 'Z') name << "Z";
|
||||
|
@ -178,8 +162,8 @@ namespace ABACUS {
|
|||
return;
|
||||
}
|
||||
|
||||
//void Data_File_Name (stringstream& name, char whichDSF, bool fixed_iK, int iKneeded, Heis_Bethe_State& State, Heis_Bethe_State& RefScanState)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT, ODSLF_Bethe_State& State, ODSLF_Bethe_State& RefScanState, string defaultScanStatename)
|
||||
void Data_File_Name (stringstream& name, char whichDSF, int iKmin, int iKmax, DP kBT,
|
||||
ODSLF_Bethe_State& State, ODSLF_Bethe_State& RefScanState, string defaultScanStatename)
|
||||
{
|
||||
name << "ODSLF_";
|
||||
if (whichDSF == 'Z') name << "Z";
|
||||
|
@ -205,6 +189,6 @@ namespace ABACUS {
|
|||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace ABACUS {
|
|||
DP omega;
|
||||
int iK;
|
||||
DP FF;
|
||||
//int conv;
|
||||
DP dev;
|
||||
string label;
|
||||
|
||||
|
@ -69,16 +68,13 @@ namespace ABACUS {
|
|||
DP SFfactor = 1.0;
|
||||
|
||||
while (RAW_infile.peek() != EOF) {
|
||||
//RAW_infile >> omega >> iK >> FF >> conv >> label;
|
||||
RAW_infile >> omega >> iK >> FF >> dev >> label;
|
||||
if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF
|
||||
//SSF[iK - iKmin] += FF * FF;
|
||||
for (int deltaiK = -DiK; deltaiK <= DiK; ++deltaiK)
|
||||
if (iK + deltaiK >= iKmin && iK + deltaiK <= iKmax)
|
||||
SSF[iK + deltaiK - iKmin] += Kweight[abs(deltaiK)] * FF * FF;
|
||||
for (int iomega = 0; iomega < Nom; ++iomega)
|
||||
if (big_gwidth_used > (d_omega = fabs(omegaout[iomega] - omega))) {
|
||||
//DSF[iomega][iK - iKmin] += FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
|
||||
SFfactor = FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
|
||||
ASF[iomega] += SFfactor;
|
||||
if (fabs(omega) > 1.0e-12) // exclude the delta function contribution coming from diagonal term, if present
|
||||
|
@ -107,7 +103,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream DSF_stringstream; string DSF_string;
|
||||
DSF_stringstream << prefix;
|
||||
//if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
if (DiK > 0) DSF_stringstream << "_DiK_" << DiK;
|
||||
DSF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".dsf";
|
||||
DSF_string = DSF_stringstream.str(); const char* DSF_Cstr = DSF_string.c_str();
|
||||
|
@ -125,7 +120,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream SSF_stringstream; string SSF_string;
|
||||
SSF_stringstream << prefix;
|
||||
//if (iKmin != iKmax) SSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
if (DiK > 0) SSF_stringstream << "_DiK_" << DiK;
|
||||
SSF_stringstream << ".ssf";
|
||||
SSF_string = SSF_stringstream.str(); const char* SSF_Cstr = SSF_string.c_str();
|
||||
|
@ -143,7 +137,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream ASF_stringstream; string ASF_string;
|
||||
ASF_stringstream << prefix;
|
||||
//if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
ASF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".asf";
|
||||
ASF_string = ASF_stringstream.str(); const char* ASF_Cstr = ASF_string.c_str();
|
||||
|
||||
|
@ -192,7 +185,6 @@ namespace ABACUS {
|
|||
DP omega;
|
||||
int iK;
|
||||
DP FF;
|
||||
//int conv;
|
||||
DP dev;
|
||||
string label;
|
||||
|
||||
|
@ -214,10 +206,6 @@ namespace ABACUS {
|
|||
for (int ns = 0; ns < weight.size(); ++ns) {
|
||||
|
||||
// Open the original raw file:
|
||||
//stringstream RAW_stringstream; string RAW_string;
|
||||
//RAW_stringstream << prefix << ".raw";
|
||||
//RAW_string = RAW_stringstream.str();
|
||||
//const char* RAW_Cstr = RAW_string.c_str();
|
||||
const char* RAW_Cstr = rawfilename[ns].c_str();
|
||||
|
||||
ifstream RAW_infile;
|
||||
|
@ -228,13 +216,11 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
while (RAW_infile.peek() != EOF) {
|
||||
//RAW_infile >> omega >> iK >> FF >> conv >> label;
|
||||
RAW_infile >> omega >> iK >> FF >> dev >> label;
|
||||
if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF)
|
||||
SSF[iK - iKmin] += weight[ns] * FF * FF;
|
||||
for (int iomega = 0; iomega < Nom; ++iomega)
|
||||
if (big_gwidth_used > (d_omega = fabs(omegaout[iomega] - omega))) {
|
||||
//DSF[iomega][iK - iKmin] += FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
|
||||
SFfactor = weight[ns] * FF * FF * exp(-d_omega*d_omega * oneovertwowidthsq);
|
||||
ASF[iomega] += SFfactor;
|
||||
if (fabs(omega) > 1.0e-12) // exclude the delta function contribution coming from diagonal term, if present
|
||||
|
@ -264,7 +250,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream DSF_stringstream; string DSF_string;
|
||||
DSF_stringstream << prefix;
|
||||
//if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
DSF_stringstream << "_ns_" << weight.size();
|
||||
if (DiK > 0) DSF_stringstream << "_DiK_" << DiK;
|
||||
DSF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".dsf";
|
||||
|
@ -283,7 +268,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream SSF_stringstream; string SSF_string;
|
||||
SSF_stringstream << prefix;
|
||||
//if (iKmin != iKmax) SSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
SSF_stringstream << "_ns_" << weight.size();
|
||||
SSF_stringstream << ".ssf";
|
||||
SSF_string = SSF_stringstream.str(); const char* SSF_Cstr = SSF_string.c_str();
|
||||
|
@ -301,7 +285,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream ASF_stringstream; string ASF_string;
|
||||
ASF_stringstream << prefix;
|
||||
//if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
ASF_stringstream << "_ns_" << weight.size();
|
||||
ASF_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << gwidth << ".asf";
|
||||
ASF_string = ASF_stringstream.str(); const char* ASF_Cstr = ASF_string.c_str();
|
||||
|
@ -317,7 +300,6 @@ namespace ABACUS {
|
|||
ASF_outfile.close();
|
||||
|
||||
|
||||
|
||||
// Check sums:
|
||||
DP sumdsf = 0.0;
|
||||
DP sumssf = 0.0;
|
||||
|
@ -361,7 +343,6 @@ namespace ABACUS {
|
|||
DP omega;
|
||||
int iK;
|
||||
DP FF;
|
||||
//int conv;
|
||||
DP dev;
|
||||
string label;
|
||||
|
||||
|
@ -373,7 +354,6 @@ namespace ABACUS {
|
|||
DP oneovertwowidthsq = 1.0/(2.0 * gwidth * gwidth);
|
||||
|
||||
while (RAW_infile.peek() != EOF) {
|
||||
//RAW_infile >> omega >> iK >> FF >> conv >> label;
|
||||
RAW_infile >> omega >> iK >> FF >> dev >> label;
|
||||
if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF)
|
||||
for (int iomega = 0; iomega < Nom; ++iomega)
|
||||
|
@ -390,7 +370,6 @@ namespace ABACUS {
|
|||
ASF[iomega] *= normalization_used;
|
||||
|
||||
// Output to .asf file
|
||||
|
||||
stringstream ASF_stringstream; string ASF_string;
|
||||
ASF_stringstream << prefix;
|
||||
//if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
|
|
|
@ -51,7 +51,6 @@ namespace ABACUS {
|
|||
DP omega;
|
||||
int iK;
|
||||
DP FF;
|
||||
//int conv;
|
||||
DP dev;
|
||||
string label;
|
||||
|
||||
|
@ -76,9 +75,10 @@ namespace ABACUS {
|
|||
// For iK > N, there are N states.
|
||||
|
||||
for (iK = iKmin; iK <= iKmax; ++iK)
|
||||
//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));
|
||||
// Make sure the width does not become lower than the omegaout raster:
|
||||
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)));
|
||||
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)));
|
||||
|
||||
|
||||
Vect_DP big_gwidth_used (iKmax - iKmin + 1);
|
||||
|
@ -95,14 +95,12 @@ namespace ABACUS {
|
|||
|
||||
DP FFsq = 0.0;
|
||||
while (RAW_infile.peek() != EOF) {
|
||||
//RAW_infile >> omega >> iK >> FF >> conv >> label;
|
||||
RAW_infile >> omega >> iK >> FF >> dev >> label;
|
||||
if (iK >= iKmin && iK <= iKmax && fabs(omega) > 1.0e-8) { // remove connected part of DSF
|
||||
FFsq = FF * FF;
|
||||
SSF[iK - iKmin] += FFsq;
|
||||
for (int iomega = 0; iomega < Nom; ++iomega)
|
||||
if (big_gwidth_used[iK - iKmin] > (d_omega = fabs(omegaout[iomega] - omega)))
|
||||
//DSF[iomega][iK - iKmin] += FF * FF * normalization_used[iK - iKmin] * exp(-d_omega*d_omega * oneovertwowidthsq[iK - iKmin]);
|
||||
for (int deltaiK = -DiK; deltaiK <= DiK; ++deltaiK)
|
||||
if (iK + deltaiK >= iKmin && iK + deltaiK <= iKmax)
|
||||
DSFS[iomega][iK + deltaiK - iKmin] += Kweight[abs(deltaiK)] * FFsq * normalization_used[iK + deltaiK - iKmin]
|
||||
|
@ -112,19 +110,13 @@ namespace ABACUS {
|
|||
RAW_infile.close();
|
||||
|
||||
// Reset proper normalization:
|
||||
//DP normalization_used = normalization * 1.0/(sqrt(twoPI) * gwidth); // Gaussian factor
|
||||
for (int iK = 0; iK < iKmax - iKmin + 1; ++iK) {
|
||||
SSF[iK] *= normalization/twoPI;
|
||||
//FSR[iK] *= normalization_used;
|
||||
//for (int iomega = 0; iomega < Nom; ++iomega)
|
||||
//DSF[iomega][iK] *= normalization_used;
|
||||
}
|
||||
|
||||
// Output to .dsfs and .ssf files
|
||||
|
||||
stringstream DSFS_stringstream; string DSFS_string;
|
||||
DSFS_stringstream << prefix;
|
||||
//if (iKmax != iKmin) DSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
if (DiK > 0) DSFS_stringstream << "_DiK_" << DiK;
|
||||
DSFS_stringstream << "_ommin_"<< ommin << "_ommax_" << ommax << "_Nom_" << Nom << "_w_" << width << ".dsfs";
|
||||
DSFS_string = DSFS_stringstream.str(); const char* DSFS_Cstr = DSFS_string.c_str();
|
||||
|
@ -143,7 +135,6 @@ namespace ABACUS {
|
|||
|
||||
stringstream SSF_stringstream; string SSF_string;
|
||||
SSF_stringstream << prefix;
|
||||
//if (iKmin != iKmax) SSF_stringstream << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
||||
SSF_stringstream << ".ssf";
|
||||
SSF_string = SSF_stringstream.str(); const char* SSF_Cstr = SSF_string.c_str();
|
||||
|
||||
|
@ -159,13 +150,10 @@ namespace ABACUS {
|
|||
|
||||
// Check sums:
|
||||
DP sumdsf = 0.0;
|
||||
//DP sumssf = 0.0;
|
||||
for (int iK = 0; iK < iKmax - iKmin + 1; ++iK) {
|
||||
//sumssf += FSR[iK];
|
||||
for (int iomega = 0; iomega < Nom; ++iomega)
|
||||
sumdsf += DSFS[iomega][iK];
|
||||
}
|
||||
//sumssf /= (iKmax - iKmin + 1);
|
||||
sumdsf /= (iKmax - iKmin + 1) * Nom;
|
||||
|
||||
return(sumdsf);
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace ABACUS {
|
|||
int* iK = new int[MAXDATA];
|
||||
DP* ff = new DP[MAXDATA];
|
||||
DP* ff_im = new DP[MAXDATA];
|
||||
//int* conv = new int[MAXDATA];
|
||||
DP* dev = new DP[MAXDATA];
|
||||
string* label = new string[MAXDATA];
|
||||
|
||||
|
@ -73,7 +72,6 @@ namespace ABACUS {
|
|||
infile >> iK[Ndata];
|
||||
if (whichDSF != 'Z') infile >> ff[Ndata];
|
||||
if (whichDSF == 'q') infile >> ff_im[Ndata]; // imaginary part of overlap, quench case
|
||||
//infile >> conv[Ndata];
|
||||
infile >> dev[Ndata];
|
||||
infile >> label[Ndata];
|
||||
|
||||
|
@ -98,17 +96,13 @@ namespace ABACUS {
|
|||
outfile << omega[index[Ndata - 1 - i] ] << "\t" << iK[index[Ndata - 1 - i] ];
|
||||
if (whichDSF != 'Z') outfile << "\t" << ff[index[Ndata - 1 - i] ];
|
||||
if (whichDSF == 'q') outfile << "\t" << ff_im[index[Ndata - 1 - i] ];
|
||||
outfile << "\t" //<< conv[index[Ndata - 1 - i] ] << "\t"
|
||||
<< dev[index[Ndata - 1 - i] ] << "\t"
|
||||
<< label[index[Ndata - 1 - i] ];
|
||||
outfile << "\t" << dev[index[Ndata - 1 - i] ] << "\t" << label[index[Ndata - 1 - i] ];
|
||||
}
|
||||
else if (optionchar == 'e') {
|
||||
outfile << omega[i] << "\t" << iK[index[i] ];
|
||||
if (whichDSF != 'Z') outfile << "\t" << ff[index[i] ];
|
||||
if (whichDSF == 'q') outfile << "\t" << ff_im[index[i] ];
|
||||
outfile << "\t" //<< conv[index[i] ] << "\t"
|
||||
<< dev[index[i] ] << "\t"
|
||||
<< label[index[i] ];
|
||||
outfile << "\t" << dev[index[i] ] << "\t" << label[index[i] ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +112,6 @@ namespace ABACUS {
|
|||
delete[] iK;
|
||||
delete[] ff;
|
||||
delete[] ff_im;
|
||||
//delete[] conv;
|
||||
delete[] dev;
|
||||
delete[] label;
|
||||
|
||||
|
|
|
@ -50,9 +50,7 @@ namespace ABACUS {
|
|||
{
|
||||
string::size_type i1 = label.find(LABELSEP);
|
||||
|
||||
//cout << "Extracting Base_Label from label " << label << endl;
|
||||
string baselabel = label.substr(0, i1);
|
||||
//cout << "Extracted Base_Label " << baselabel << endl;
|
||||
|
||||
return(baselabel);
|
||||
}
|
||||
|
@ -76,7 +74,6 @@ namespace ABACUS {
|
|||
int remainder = int_to_convert;
|
||||
stringstream result_strstrm;
|
||||
do {
|
||||
//cout << "remainder = " << remainder << "\tnext index = " << remainder - ABACUScodingsize * (remainder/ABACUScodingsize) << endl;
|
||||
result_strstrm << ABACUScoding[remainder - ABACUScodingsize * (remainder/ABACUScodingsize)];
|
||||
remainder /= ABACUScodingsize;
|
||||
} while (remainder > 0);
|
||||
|
@ -120,22 +117,13 @@ namespace ABACUS {
|
|||
string nexclabel = label.substr(i1+1, i2-i1-1);
|
||||
string Ix2exclabel = label.substr(i2+1);
|
||||
|
||||
//cout << "label: " << label << endl;
|
||||
//cout << "baselabel: " << baselabel << endl;
|
||||
//cout << "nexclabel: " << nexclabel << endl;
|
||||
//cout << "Ix2exclabel: " << Ix2exclabel << endl;
|
||||
|
||||
// Read off the base label: count the number of TYPESEP in baselabel
|
||||
int nbar = 0;
|
||||
for (unsigned int i = 0; i < baselabel.length(); ++i) if (baselabel[i] == TYPESEP) nbar++;
|
||||
|
||||
//cout << "nbar = " << nbar << endl;
|
||||
|
||||
// There are now nbar + 1 base label data:
|
||||
int ntypes = nbar + 1;
|
||||
|
||||
//cout << "ntypes = " << ntypes << endl;
|
||||
|
||||
Vect<int> type(ntypes); // integer type labels of the types present
|
||||
type[0] = 0; // always the case by convention
|
||||
Vect<int> M(ntypes); // how many particles of each type
|
||||
|
@ -183,8 +171,6 @@ namespace ABACUS {
|
|||
|
||||
} // else if ntypes > 1
|
||||
|
||||
//cout << "ntypes = " << ntypes << "\tM = " << M << endl;
|
||||
|
||||
// baselabel is now completely read
|
||||
|
||||
// Define some dud nex, Ix2old, Ix2exc:
|
||||
|
@ -213,22 +199,14 @@ namespace ABACUS {
|
|||
string nexclabel = label.substr(i1+1, i2-i1-1);
|
||||
string Ix2exclabel = label.substr(i2+1);
|
||||
|
||||
//cout << "label: " << label << endl;
|
||||
//cout << "baselabel: " << baselabel << endl;
|
||||
//cout << "nexclabel: " << nexclabel << endl;
|
||||
//cout << "Ix2exclabel: " << Ix2exclabel << endl;
|
||||
|
||||
// Read off the base label: count the number of TYPESEP in baselabel
|
||||
int nbar = 0;
|
||||
for (unsigned int i = 0; i < baselabel.length(); ++i) if (baselabel[i] == TYPESEP) nbar++;
|
||||
|
||||
//cout << "nbar = " << nbar << endl;
|
||||
|
||||
// There are now nbar + 1 base label data:
|
||||
int ntypes = nbar + 1;
|
||||
|
||||
//cout << "ntypes = " << ntypes << endl;
|
||||
|
||||
Vect<int> type(ntypes); // integer type labels of the types present
|
||||
type[0] = 0; // always the case by convention
|
||||
Vect<int> M(ntypes); // how many particles of each type
|
||||
|
@ -317,10 +295,6 @@ namespace ABACUS {
|
|||
|
||||
// nexc is now completely read
|
||||
|
||||
//cout << "typefound: " << type << endl;
|
||||
//cout << "Mfound: " << M << endl;
|
||||
//cout << "nexcfound: " << nexc << endl;
|
||||
|
||||
|
||||
// Now read off the (compressed) jexc and Ix2exc vectors of vectors:
|
||||
Vect<Vect<int> > Ix2old(ntypes); // which Ix2 will be excited
|
||||
|
@ -340,22 +314,17 @@ namespace ABACUS {
|
|||
}
|
||||
for (int iexc = 0; iexc < nexc[itype]; ++iexc) {
|
||||
//string::size_type i1 = Ix2exclabelremaining.find(INEXCSEP);
|
||||
string::size_type i2 = (iexc < nexc[itype] - 1 ? Ix2exclabelremaining.find(EXCSEP) : Ix2exclabelremaining.find(TYPESEP)); // careful here!
|
||||
//cout << "\t" << itype << "\t" << iexc << "\t" << Ix2exclabelremaining << "\t" << i1 << "\t" << i2 << endl;
|
||||
//string Ix2oldread = Ix2exclabelremaining.substr(0,i1);
|
||||
//string Ix2excread = Ix2exclabelremaining.substr(i1+1,i2-i1-1);
|
||||
string::size_type i2 = (iexc < nexc[itype] - 1 ? Ix2exclabelremaining.find(EXCSEP)
|
||||
: Ix2exclabelremaining.find(TYPESEP)); // careful here!
|
||||
string Ix2excIDread = Ix2exclabelremaining.substr(0,i2);
|
||||
int Ix2excID = Convert_STR_to_POSINT(Ix2excIDread);
|
||||
Ix2old[itype][iexc] = OriginIx2[type[itype] ][Ix2excID - M[itype] * (Ix2excID/M[itype])]; // index is remainder w/r to nr of strings of this type
|
||||
Ix2old[itype][iexc] = OriginIx2[type[itype] ][Ix2excID - M[itype] * (Ix2excID/M[itype])];
|
||||
// index is remainder w/r to nr of strings of this type
|
||||
// Convention: if remainder is even, moving left. If odd, moving right.
|
||||
// 0 means move one unit left, 1 means move one unit right, etc.
|
||||
//Ix2exc[itype][iexc] = Ix2old[itype][iexc] + (Ix2excID/M[itype] % 2 ? 2 : -2) * (Ix2excID/(2 * M[itype]) + 0);
|
||||
Ix2exc[itype][iexc] = Ix2old[itype][iexc] + (Ix2excID/M[itype] % 2 ? 2 : -2) * (Ix2excID/(2 * M[itype]) + 1); // ABACUS++T_8 onwards
|
||||
Ix2exc[itype][iexc] = Ix2old[itype][iexc] + (Ix2excID/M[itype] % 2 ? 2 : -2)
|
||||
* (Ix2excID/(2 * M[itype]) + 1); // ABACUS++T_8 onwards
|
||||
|
||||
//istringstream Ix2oldreadbuffer (Ix2oldread);
|
||||
//Ix2oldreadbuffer >> Ix2old[itype][iexc];
|
||||
//istringstream Ix2excreadbuffer (Ix2excread);
|
||||
//Ix2excreadbuffer >> Ix2exc[itype][iexc];
|
||||
// Remove everything up to index i2 in Ix2exclabelremaining
|
||||
Ix2exclabelremaining = Ix2exclabelremaining.substr(i2+1);
|
||||
}
|
||||
|
@ -363,47 +332,27 @@ namespace ABACUS {
|
|||
|
||||
// Now read off the Ix2old, Ix2exc of the last type: this is always done
|
||||
for (int iexc = 0; iexc < nexc[ntypes - 1] - 1; ++iexc) {
|
||||
//string::size_type i1 = Ix2exclabelremaining.find(INEXCSEP);
|
||||
string::size_type i2 = Ix2exclabelremaining.find(EXCSEP);
|
||||
//string Ix2oldread = Ix2exclabelremaining.substr(0,i1);
|
||||
//string Ix2excread = Ix2exclabelremaining.substr(i1+1,i2-i1-1);
|
||||
string Ix2excIDread = Ix2exclabelremaining.substr(0,i2);
|
||||
int Ix2excID = Convert_STR_to_POSINT(Ix2excIDread);
|
||||
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
|
||||
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
|
||||
// Convention: if remainder is even, moving left. If odd, moving right.
|
||||
//Ix2exc[ntypes - 1][iexc] = Ix2old[ntypes - 1][iexc] + (Ix2excID/M[ntypes - 1] % 2 ? 2 : -2) * (Ix2excID/(2 * M[ntypes - 1]) + 0);
|
||||
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
|
||||
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
|
||||
|
||||
//istringstream Ix2oldreadbuffer (Ix2oldread);
|
||||
//Ix2oldreadbuffer >> Ix2old[ntypes - 1][iexc];
|
||||
//istringstream Ix2excreadbuffer (Ix2excread);
|
||||
//Ix2excreadbuffer >> Ix2exc[ntypes - 1][iexc];
|
||||
// Remove everything up to index i2 in Ix2exclabelremaining
|
||||
Ix2exclabelremaining = Ix2exclabelremaining.substr(i2+1);
|
||||
}
|
||||
|
||||
// Now read off the last pair:
|
||||
int Ix2excID = Convert_STR_to_POSINT(Ix2exclabelremaining);
|
||||
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
|
||||
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
|
||||
// Convention: if remainder is even, moving left. If odd, moving right.
|
||||
//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);
|
||||
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
|
||||
|
||||
//string::size_type ilast = Ix2exclabelremaining.find(INEXCSEP);
|
||||
//string Ix2oldread = Ix2exclabelremaining.substr(0,ilast);
|
||||
//string Ix2excread = Ix2exclabelremaining.substr(ilast+1);
|
||||
//istringstream Ix2oldreadbuffer (Ix2oldread);
|
||||
//Ix2oldreadbuffer >> Ix2old[ntypes - 1][nexc[ntypes - 1] - 1];
|
||||
//istringstream Ix2excreadbuffer (Ix2excread);
|
||||
//Ix2excreadbuffer >> Ix2exc[ntypes - 1][nexc[ntypes - 1] - 1];
|
||||
|
||||
//cout << "nexc = " << endl;
|
||||
//cout << nexc << endl;
|
||||
//cout << "Ix2old and Ix2exc: " << endl;
|
||||
//for (int itype = 0; itype < ntypes; ++itype) {
|
||||
//cout << "Ix2old["<< itype << "]: " << Ix2old[itype] << endl;
|
||||
//cout << "Ix2exc["<< itype << "]: " << Ix2exc[itype] << endl;
|
||||
//}
|
||||
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
|
||||
|
||||
State_Label_Data labeldata (type, M, nexc, Ix2old, Ix2exc);
|
||||
|
||||
|
@ -421,43 +370,28 @@ namespace ABACUS {
|
|||
{
|
||||
// This function produces a compressed label.
|
||||
|
||||
//cout << "Label A" << endl;
|
||||
|
||||
//cout << "\t" << data.M.size() << endl;
|
||||
//cout << "\t" << data.M[0] << endl;
|
||||
|
||||
string label;
|
||||
|
||||
// Write the base:
|
||||
// First, particles of type 0:
|
||||
//cout << "Label A2" << endl;
|
||||
stringstream M0out;
|
||||
//cout << "Label A3" << endl;
|
||||
//cout << "\t" << data.M[0] << endl;
|
||||
M0out << data.M[0];
|
||||
//cout << "Label A4" << endl;
|
||||
label += M0out.str();
|
||||
//cout << "Label A5" << endl;
|
||||
|
||||
for (int itype = 1; itype < data.M.size(); ++itype) {
|
||||
//cout << "\ta" << itype << "\t" << data.M.size() << endl;
|
||||
if (data.M[itype] > 0) {
|
||||
label += TYPESEP;
|
||||
stringstream typeout;
|
||||
typeout << data.type[itype];
|
||||
label += typeout.str();
|
||||
label += EXCSEP;
|
||||
//cout << "\tc" << endl;
|
||||
stringstream Mout;
|
||||
Mout << data.M[itype];
|
||||
label += Mout.str();
|
||||
//cout << "\td" << endl;
|
||||
}
|
||||
}
|
||||
label += LABELSEP;
|
||||
|
||||
//cout << "Label B" << endl;
|
||||
|
||||
// Now the nexc:
|
||||
stringstream nexc0out;
|
||||
nexc0out << data.nexc[0];
|
||||
|
@ -470,8 +404,6 @@ namespace ABACUS {
|
|||
}
|
||||
label += LABELSEP;
|
||||
|
||||
//cout << "Label C" << endl;
|
||||
|
||||
// Now the displacements:
|
||||
// The conventions are as follows.
|
||||
// For each excitation, an integer number ID is given according to the following rules:
|
||||
|
@ -489,15 +421,15 @@ namespace ABACUS {
|
|||
int holeindex = -1;
|
||||
do {
|
||||
holeindex++;
|
||||
} while (OriginIx2[data.type[itype] ][holeindex] != data.Ix2old[itype][iexc] && holeindex < OriginIx2[data.type[itype] ].size() - 1);
|
||||
if (holeindex == OriginIx2[data.type[itype] ].size()) ABACUSerror("Going out of bounds in Compress_Label.");
|
||||
} while (OriginIx2[data.type[itype] ][holeindex] != data.Ix2old[itype][iexc]
|
||||
&& holeindex < OriginIx2[data.type[itype] ].size() - 1);
|
||||
if (holeindex == OriginIx2[data.type[itype] ].size())
|
||||
ABACUSerror("Going out of bounds in Compress_Label.");
|
||||
excID = excID * data.M[itype] + holeindex;
|
||||
label += Convert_POSINT_to_STR(excID);
|
||||
} // for iexc
|
||||
} // for itype
|
||||
|
||||
//cout << "Label D" << endl;
|
||||
|
||||
return(label);
|
||||
}
|
||||
|
||||
|
@ -512,13 +444,17 @@ namespace ABACUS {
|
|||
{
|
||||
// This function does not assume any ordering of the Ix2.
|
||||
|
||||
if (ScanIx2.size() != OriginIx2.size()) ABACUSerror("ScanIx2.size() != OriginIx2.size() in Find_Label.");
|
||||
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.");
|
||||
if (ScanIx2.size() != OriginIx2.size())
|
||||
ABACUSerror("ScanIx2.size() != OriginIx2.size() in Find_Label.");
|
||||
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.");
|
||||
|
||||
// Set the state ulabel:
|
||||
// Count the number of types present:
|
||||
int ntypespresent = 0;
|
||||
for (int is = 0; is < ScanIx2.size(); ++is) if (is == 0 || ScanIx2[is].size() > 0) ntypespresent++; // type 0 is by default always present
|
||||
for (int is = 0; is < ScanIx2.size(); ++is)
|
||||
if (is == 0 || ScanIx2[is].size() > 0) ntypespresent++; // type 0 is by default always present
|
||||
|
||||
Vect<int> type_ref(ntypespresent);
|
||||
Vect<int> M_ref(ntypespresent);
|
||||
|
@ -541,10 +477,15 @@ namespace ABACUS {
|
|||
for (int it = 0; it < ntypespresent; ++it) Ix2exc_ref[it] = Vect<int>(ABACUS::max(nexc_ref[it],1));
|
||||
for (int it = 0; it < ntypespresent; ++it) {
|
||||
int nexccheck = 0;
|
||||
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];
|
||||
if (nexccheck != nexc_ref[it]) ABACUSerror("Counting excitations wrong (1) in Return_State_Label");
|
||||
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];
|
||||
if (nexccheck != nexc_ref[it])
|
||||
ABACUSerror("Counting excitations wrong (1) in Return_State_Label");
|
||||
nexccheck = 0;
|
||||
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];
|
||||
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];
|
||||
if (nexccheck != nexc_ref[it]) {
|
||||
cout << OriginIx2 << endl;
|
||||
cout << ScanIx2 << endl;
|
||||
|
@ -572,19 +513,16 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
|
||||
//bool Set_to_Label (string label_ref, Vect<Vect<int> >& Ix2, const Vect<Vect<int> >& OriginIx2)
|
||||
|
||||
Vect<Vect<int> > Return_Ix2_from_Label (string label_ref, const Vect<Vect<int> >& OriginIx2)
|
||||
{
|
||||
// ASSUMPTIONS:
|
||||
// OriginIx2 is ordered.
|
||||
|
||||
//Ix2 = OriginIx2; // this will fail if the sizes are incompatible
|
||||
Vect<Vect<int> > Ix2 = OriginIx2; // this will fail if the sizes are incompatible
|
||||
|
||||
State_Label_Data labeldata = Read_State_Label (label_ref, OriginIx2);
|
||||
|
||||
//cout << "Read label OK" << endl;
|
||||
|
||||
// Now set the excitations:
|
||||
for (int it = 0; it < labeldata.type.size(); ++it)
|
||||
for (int iexc = 0; iexc < labeldata.nexc[it]; ++iexc)
|
||||
|
@ -596,12 +534,9 @@ namespace ABACUS {
|
|||
// Now reorder the Ix2 to follow convention:
|
||||
for (int il = 0; il < Ix2.size(); ++il) Ix2[il].QuickSort();
|
||||
|
||||
//cout << "Ix2 found = " << Ix2 << endl;
|
||||
|
||||
return(Ix2);
|
||||
//return(true);
|
||||
}
|
||||
// Specialization to Lieb-Liniger:
|
||||
|
||||
Vect<int> Return_Ix2_from_Label (string label_ref, const Vect<int>& OriginIx2)
|
||||
{
|
||||
Vect<Vect<int> > OriginIx2here(1);
|
||||
|
@ -611,47 +546,4 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
|
||||
/* DEPRECATED ++G_5
|
||||
// Conversion from one to the other:
|
||||
string Compress_Ulabel (string ulabel_ref, const Vect<Vect<int> >& OriginIx2)
|
||||
{
|
||||
// From a normal label, return a compressed one.
|
||||
State_Label_Data data = Read_State_Ulabel (ulabel_ref);
|
||||
|
||||
return(Return_State_Label(data, OriginIx2));
|
||||
}
|
||||
|
||||
string Compress_Ulabel (string ulabel_ref, const Vect<int>& OriginIx2)
|
||||
// if there is only one type
|
||||
{
|
||||
// From a normal label, return a compressed one.
|
||||
Vect<Vect<int> > OriginIx2here(1);
|
||||
OriginIx2here[0] = OriginIx2;
|
||||
|
||||
State_Label_Data data = Read_State_Ulabel (ulabel_ref);
|
||||
|
||||
return(Return_State_Label(data, OriginIx2here));
|
||||
}
|
||||
|
||||
string Uncompress_Label (string label_ref, const Vect<Vect<int> >& OriginIx2)
|
||||
{
|
||||
// From a compressed label, return a normal one.
|
||||
State_Label_Data data = Read_State_Label (label_ref, OriginIx2);
|
||||
|
||||
return(Return_State_Ulabel(data));
|
||||
}
|
||||
|
||||
string Uncompress_Label (string label_ref, const Vect<int>& OriginIx2)
|
||||
// if there is only one type
|
||||
{
|
||||
// From a compressed label, return a normal one.
|
||||
Vect<Vect<int> > OriginIx2here(1);
|
||||
OriginIx2here[0] = OriginIx2;
|
||||
|
||||
State_Label_Data data = Read_State_Label (label_ref, OriginIx2here);
|
||||
|
||||
return(Return_State_Ulabel(data));
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -41,9 +41,6 @@ namespace ABACUS {
|
|||
MPI_Comm_rank (comm, &rank);
|
||||
|
||||
MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
|
||||
//cout << "Client of rank " << rank << ": received request ";
|
||||
//for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
|
||||
//cout << "with tag " << status.MPI_TAG << endl;
|
||||
|
||||
|
||||
while (status.MPI_TAG) {
|
||||
|
@ -59,112 +56,12 @@ namespace ABACUS {
|
|||
client_result[7] = SF_4p_opt (client_request[2], client_request[3], client_request[4],
|
||||
int(client_request[5]), int(client_request[6]), Itable);
|
||||
MPI_Send (client_result, client_result_size, MPI_DOUBLE, server, status.MPI_TAG, comm);
|
||||
//cout << "Client of rank " << rank << " sending complete" << endl;
|
||||
|
||||
// Wait for subsequent request from server
|
||||
MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
|
||||
//cout << "Client of rank " << rank << ": received request ";
|
||||
//for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
|
||||
//cout << "with tag " << status.MPI_TAG << endl;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/*
|
||||
void SF_4p_kwKW_alpha_client (MPI_Comm comm, DP req_prec, int max_rec, I_table Itable)
|
||||
{
|
||||
int server = 0;
|
||||
int rank;
|
||||
|
||||
MPI_Status status;
|
||||
|
||||
int client_request_size = 2;
|
||||
DP client_request[client_request_size]; // this is k, alpha
|
||||
int client_result_size = 3;
|
||||
DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha
|
||||
|
||||
MPI_Comm_rank (comm, &rank);
|
||||
|
||||
MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
|
||||
//cout << "Client of rank " << rank << ": received request ";
|
||||
//for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
|
||||
//cout << "with tag " << status.MPI_TAG << endl;
|
||||
|
||||
Vect_DP args_to_SF_4p_kwKW_alpha(4);
|
||||
args_to_SF_4p_kwKW_alpha[2] = req_prec;
|
||||
args_to_SF_4p_kwKW_alpha[3] = DP(max_rec);
|
||||
|
||||
while (status.MPI_TAG) {
|
||||
|
||||
args_to_SF_4p_kwKW_alpha[0] = client_request[0];
|
||||
args_to_SF_4p_kwKW_alpha[1] = client_request[1];
|
||||
|
||||
// Result: SF_4p (k, omega)
|
||||
client_result[0] = client_request[0];
|
||||
client_result[1] = client_request[1];
|
||||
client_result[2] = SF_4p_kwKW_alpha (args_to_SF_4p_kwKW_alpha, Itable);
|
||||
|
||||
MPI_Send (client_result, client_result_size, MPI_DOUBLE, server, status.MPI_TAG, comm);
|
||||
//cout << "Client of rank " << rank << " sending complete" << endl;
|
||||
|
||||
// Wait for subsequent request from server
|
||||
MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
|
||||
//cout << "Client of rank " << rank << ": received request ";
|
||||
//for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
|
||||
//cout << "with tag " << status.MPI_TAG << endl;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SF_4p_kwKW_alpha_opt_client (MPI_Comm comm, DP req_prec, int Npts_K, int Npts_W, I_table Itable)
|
||||
{
|
||||
int server = 0;
|
||||
int rank;
|
||||
|
||||
MPI_Status status;
|
||||
|
||||
int client_request_size = 2;
|
||||
DP client_request[client_request_size]; // this is k, alpha
|
||||
int client_result_size = 3;
|
||||
DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha_opt
|
||||
|
||||
MPI_Comm_rank (comm, &rank);
|
||||
|
||||
MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
|
||||
//cout << "Client of rank " << rank << ": received request ";
|
||||
//for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
|
||||
//cout << "with tag " << status.MPI_TAG << endl;
|
||||
|
||||
Vect_DP args_to_SF_4p_kwKW_alpha_opt(5);
|
||||
args_to_SF_4p_kwKW_alpha_opt[2] = req_prec;
|
||||
args_to_SF_4p_kwKW_alpha_opt[3] = DP(Npts_K);
|
||||
args_to_SF_4p_kwKW_alpha_opt[4] = DP(Npts_W);
|
||||
|
||||
while (status.MPI_TAG) {
|
||||
|
||||
args_to_SF_4p_kwKW_alpha_opt[0] = client_request[0];
|
||||
args_to_SF_4p_kwKW_alpha_opt[1] = client_request[1];
|
||||
|
||||
// Result: SF_4p (k, omega)
|
||||
client_result[0] = client_request[0];
|
||||
client_result[1] = client_request[1];
|
||||
client_result[2] = SF_4p_kwKW_alpha_opt (args_to_SF_4p_kwKW_alpha_opt, Itable);
|
||||
|
||||
MPI_Send (client_result, client_result_size, MPI_DOUBLE, server, status.MPI_TAG, comm);
|
||||
//cout << "Client of rank " << rank << " sending complete" << endl;
|
||||
|
||||
// Wait for subsequent request from server
|
||||
MPI_Recv (client_request, client_request_size, MPI_DOUBLE, server, MPI_ANY_TAG, comm, &status);
|
||||
//cout << "Client of rank " << rank << ": received request ";
|
||||
//for (int i = 0; i < client_request_size; ++i) cout << client_request[i] << " ";
|
||||
//cout << "with tag " << status.MPI_TAG << endl;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -57,7 +57,6 @@ namespace ABACUS {
|
|||
for (int ik = 0; ik < dim_k; ++ik) {
|
||||
SF_outfile >> SF_4p[dim_k * iomega + ik];
|
||||
if (SF_4p[dim_k * iomega + ik] == 0.0) total_nr_req++;
|
||||
//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;
|
||||
|
||||
// We only load the LHS of the BZ, so we load N/2 empty values...
|
||||
}
|
||||
|
@ -87,11 +86,6 @@ namespace ABACUS {
|
|||
cout << total_nr_req << "\t" << index << endl;
|
||||
ABACUSerror("Not counting total_nr_req correctly in SF_4p_opt_server");
|
||||
}
|
||||
//ofstream SFsrc_outfile;
|
||||
//SFsrc_outfile.open(SFsrc_Cstr);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
int nr_machines;
|
||||
MPI_Comm_size (comm, &nr_machines);
|
||||
|
@ -129,22 +123,16 @@ namespace ABACUS {
|
|||
client_request[6] = DP(Npts_W);
|
||||
|
||||
MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
|
||||
//cout << "Server: sent request ";
|
||||
//for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
|
||||
//cout << "with tag " << scanning << " to client " << i << endl;
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
DP Actual_Time_MPI = MPI_Wtime();
|
||||
|
||||
//while (nr_returned < total_nr_req) {
|
||||
while (nr_returned < nr_sent_out) {
|
||||
|
||||
//cout << "Server: waiting for answers... " << endl;
|
||||
MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
|
||||
nr_returned++;
|
||||
//cout << "Server: received answer from client " << status.MPI_SOURCE << endl;
|
||||
|
||||
// unbuffer result
|
||||
SF_4p[dim_k * int(client_result[1]) + int(client_result[0])] = client_result[7];
|
||||
|
||||
|
@ -158,15 +146,10 @@ namespace ABACUS {
|
|||
client_request[3] = (needed_iomega[nr_sent_out] + 0.5) * omegamax/Nomega;
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
} // while (nr_returned < total_nr_req)
|
||||
|
||||
cout << endl << "Computed " << nr_returned << " points ouf of " << total_nr_req << " required. " << endl;
|
||||
|
||||
cout << endl << "Server saving file..." << endl;
|
||||
|
||||
// Output all data: double up to full [0, 2pi] interval in k with symmetry
|
||||
SF_outfile.seekp(0);
|
||||
for (int iomega = 0; iomega < Nomega; ++iomega) {
|
||||
|
@ -187,384 +170,5 @@ namespace ABACUS {
|
|||
return;
|
||||
}
|
||||
|
||||
/****************************************************
|
||||
|
||||
// TO COMPLETE FOR 5.5 (commented out in 5.7)
|
||||
|
||||
*********************************************************/
|
||||
/*
|
||||
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,
|
||||
int Max_Secs, bool refine)
|
||||
{
|
||||
double Start_Time_MPI = MPI_Wtime();
|
||||
|
||||
Heis_Write_w_File (Nomega, omegamax);
|
||||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_k_" << k_needed << "_No_" << Nomega << "_omax_" << omegamax
|
||||
<< "_prec_" << req_prec << "_Npts_K_" << Npts_K << "_Npts_W_" << Npts_W << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
fstream SF_outfile;
|
||||
if (!refine) SF_outfile.open(SF_Cstr, fstream::out | fstream::trunc);
|
||||
else SF_outfile.open(SF_Cstr, fstream::in | fstream::out);
|
||||
if (SF_outfile.fail()) ABACUSerror("Could not open SF_outfile... ");
|
||||
|
||||
SF_outfile.precision(12);
|
||||
|
||||
int dim_k = 1;
|
||||
|
||||
DP* SF_4p = new DP[dim_k * Nomega];
|
||||
|
||||
// Initialize to zero to be sure:
|
||||
for (int i = 0; i < Nomega * dim_k; ++i) SF_4p[i] = 0.0;
|
||||
|
||||
// If refining, load SF from existing file
|
||||
|
||||
int total_nr_req = 0;
|
||||
DP buff;
|
||||
if (refine) {
|
||||
for (int iomega = 0; iomega < Nomega; ++iomega) {
|
||||
for (int ik = 0; ik < dim_k; ++ik) {
|
||||
SF_outfile >> SF_4p[dim_k * iomega + ik];
|
||||
if (SF_4p[dim_k * iomega + ik] == 0.0) total_nr_req++;
|
||||
//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;
|
||||
|
||||
// We only load the LHS of the BZ, so we load N/2 empty values...
|
||||
}
|
||||
for (int ibuff = 0; ibuff < N/2; ++ibuff) SF_outfile >> buff;
|
||||
}
|
||||
}
|
||||
else if (!refine) total_nr_req = dim_k * Nomega;
|
||||
|
||||
// List iomega and ik which need to be computed:
|
||||
|
||||
int* needed_ik = new int[total_nr_req];
|
||||
int* needed_iomega = new int[total_nr_req];
|
||||
|
||||
int index = 0;
|
||||
for (int iomega = 0; iomega < Nomega; ++iomega)
|
||||
for (int ik = 0; ik < dim_k; ++ik) {
|
||||
if (SF_4p[dim_k * iomega + ik] == 0) {
|
||||
needed_ik[index] = ik;
|
||||
needed_iomega[index] = iomega;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
cout << total_nr_req << " points required." << endl;
|
||||
|
||||
if (index != total_nr_req) {
|
||||
cout << total_nr_req << "\t" << index << endl;
|
||||
ABACUSerror("Not counting total_nr_req correctly in SF_4p_opt_server");
|
||||
}
|
||||
//ofstream SFsrc_outfile;
|
||||
//SFsrc_outfile.open(SFsrc_Cstr);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
int nr_machines;
|
||||
MPI_Comm_size (comm, &nr_machines);
|
||||
int nr_clients = nr_machines - 1; // one for the server
|
||||
|
||||
int client_request_size = 7;
|
||||
DP client_request[client_request_size];
|
||||
// this is:
|
||||
// ik
|
||||
// iomega
|
||||
// k
|
||||
// omega
|
||||
// req_prec
|
||||
// Npts_K
|
||||
// Npts_W
|
||||
int client_result_size = 8;
|
||||
DP client_result[client_result_size]; // same, plus SF_4p
|
||||
|
||||
MPI_Status status;
|
||||
|
||||
int scanning = 1;
|
||||
|
||||
int nr_sent_out = 0;
|
||||
int nr_returned = 0;
|
||||
|
||||
for (int i = 1; i <= nr_clients && i <= total_nr_req; ++i) {
|
||||
|
||||
// Send request to client i, in the form of the req_id_array vector
|
||||
client_request[0] = DP(needed_ik[nr_sent_out]);
|
||||
client_request[1] = DP(needed_iomega[nr_sent_out]);
|
||||
client_request[2] = k_needed;//(twoPI * needed_ik[nr_sent_out])/N;
|
||||
client_request[3] = (needed_iomega[nr_sent_out] + 0.5) * omegamax/Nomega;
|
||||
client_request[4] = req_prec;
|
||||
client_request[5] = DP(Npts_K);
|
||||
client_request[6] = DP(Npts_W);
|
||||
|
||||
MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
|
||||
//cout << "Server: sent request ";
|
||||
//for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
|
||||
//cout << "with tag " << scanning << " to client " << i << endl;
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
DP Actual_Time_MPI = MPI_Wtime();
|
||||
|
||||
//while (nr_returned < total_nr_req) {
|
||||
while (nr_returned < nr_sent_out) {
|
||||
|
||||
//cout << "Server: waiting for answers... " << endl;
|
||||
MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
|
||||
nr_returned++;
|
||||
//cout << "Server: received answer from client " << status.MPI_SOURCE << endl;
|
||||
// unbuffer result
|
||||
SF_4p[int(client_result[1])] = client_result[7];
|
||||
|
||||
Actual_Time_MPI = MPI_Wtime();
|
||||
|
||||
// Send out new request if needed and time available
|
||||
if (nr_sent_out < total_nr_req && Actual_Time_MPI - Start_Time_MPI < Max_Secs) {
|
||||
client_request[0] = needed_ik[nr_sent_out];
|
||||
client_request[1] = needed_iomega[nr_sent_out];
|
||||
client_request[2] = k_needed;//(twoPI * needed_ik[nr_sent_out])/N;
|
||||
client_request[3] = (needed_iomega[nr_sent_out] + 0.5) * omegamax/Nomega;
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
} // while (nr_returned < total_nr_req)
|
||||
|
||||
cout << endl << "Computed " << nr_returned << " points ouf of " << total_nr_req << " required. " << endl;
|
||||
|
||||
cout << endl << "Server saving file..." << endl;
|
||||
|
||||
// Output all data:
|
||||
SF_outfile.seekp(0);
|
||||
for (int iomega = 0; iomega < Nomega; ++iomega) {
|
||||
SF_outfile << omega[iomega] << "\t" << SF_4p[iomega] << endl;
|
||||
}
|
||||
|
||||
SF_outfile.close();
|
||||
|
||||
cout << endl << "Done !" << endl;
|
||||
|
||||
// Send term signal to clients
|
||||
int scanning_completed = 0;
|
||||
for (int i = 1; i <= nr_clients; ++i)
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, i, scanning_completed, comm);
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Function producing a fixed k scan, with data file
|
||||
void SF_4p_rec_par (MPI_Comm comm, DP k, DP req_prec, int max_rec_w, int max_rec, I_table Itable)
|
||||
{
|
||||
int Npts_w = int(pow(3.0, max_rec_w + 2));
|
||||
|
||||
stringstream SFraw_stringstream;
|
||||
string SFraw_string;
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".raw";
|
||||
SFraw_string = SFraw_stringstream.str();
|
||||
const char* SFraw_Cstr = SFraw_string.c_str();
|
||||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
stringstream SFsrc_stringstream;
|
||||
string SFsrc_string;
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".src";
|
||||
SFsrc_string = SFsrc_stringstream.str();
|
||||
const char* SFsrc_Cstr = SFsrc_string.c_str();
|
||||
|
||||
ofstream SFraw_outfile;
|
||||
SFraw_outfile.open(SFraw_Cstr);
|
||||
//ofstream SFsrc_outfile;
|
||||
//SFsrc_outfile.open(SFsrc_Cstr);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
int nr_machines;
|
||||
MPI_Comm_size (comm, &nr_machines);
|
||||
int nr_clients = nr_machines - 1; // one for the server
|
||||
|
||||
int client_request_size = 2;
|
||||
DP client_request[client_request_size]; // this is k, alpha
|
||||
int client_result_size = 3;
|
||||
DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha
|
||||
|
||||
MPI_Status status;
|
||||
|
||||
int scanning = 1;
|
||||
|
||||
int total_nr_req = Npts_w;
|
||||
int nr_sent_out = 0;
|
||||
int nr_returned = 0;
|
||||
|
||||
Vect_DP alpha_req(Npts_w);
|
||||
for (int iw = 0; iw < Npts_w; ++iw) alpha_req[iw] = 0.5 * PI * (iw + 0.5)/Npts_w;
|
||||
|
||||
//cout << "alpha_req = " << alpha_req << endl;
|
||||
|
||||
for (int i = 1; i <= nr_clients && i <= total_nr_req; ++i) {
|
||||
|
||||
// Send request to client i, in the form of the req_id_array vector
|
||||
client_request[0] = k;
|
||||
client_request[1] = alpha_req[nr_sent_out];
|
||||
|
||||
MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
|
||||
//cout << "Server: sent request ";
|
||||
//for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
|
||||
//cout << "with tag " << scanning << " to client " << i << endl;
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
while (nr_returned < total_nr_req) {
|
||||
|
||||
//cout << "Server: waiting for answers... " << endl;
|
||||
MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
|
||||
nr_returned++;
|
||||
//cout << "Server: received answer from client " << status.MPI_SOURCE << endl;
|
||||
|
||||
// unbuffer result
|
||||
SFraw_outfile << client_result[1] << "\t" << client_result[2] << endl;
|
||||
|
||||
// Send out new request if needed
|
||||
if (nr_sent_out < total_nr_req) {
|
||||
client_request[1] = alpha_req[nr_sent_out];
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
} // while (nr_returned < total_nr_req)
|
||||
|
||||
// Send term signal to clients
|
||||
int scanning_completed = 0;
|
||||
for (int i = 1; i <= nr_clients; ++i)
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, i, scanning_completed, comm);
|
||||
|
||||
SFraw_outfile.close();
|
||||
|
||||
//SFsrc_outfile << answer << endl;
|
||||
//SFsrc_outfile.close();
|
||||
|
||||
// Translate raw data into SF_4p (k,omega) data
|
||||
|
||||
//Translate_raw_4p_data (k, max_rec_w, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
Translate_raw_4p_data (k, int(pow(3.0, max_rec_w + 2)), SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
stringstream SFraw_stringstream;
|
||||
string SFraw_string;
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".raw";
|
||||
SFraw_string = SFraw_stringstream.str();
|
||||
const char* SFraw_Cstr = SFraw_string.c_str();
|
||||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
stringstream SFsrc_stringstream;
|
||||
string SFsrc_string;
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".src";
|
||||
SFsrc_string = SFsrc_stringstream.str();
|
||||
const char* SFsrc_Cstr = SFsrc_string.c_str();
|
||||
|
||||
ofstream SFraw_outfile;
|
||||
SFraw_outfile.open(SFraw_Cstr);
|
||||
//ofstream SFsrc_outfile;
|
||||
//SFsrc_outfile.open(SFsrc_Cstr);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
int nr_machines;
|
||||
MPI_Comm_size (comm, &nr_machines);
|
||||
int nr_clients = nr_machines - 1; // one for the server
|
||||
|
||||
int client_request_size = 2;
|
||||
DP client_request[client_request_size]; // this is k, alpha
|
||||
int client_result_size = 3;
|
||||
DP client_result[client_result_size]; // this is k, alpha, SF_4p_kwKW_alpha_opt
|
||||
|
||||
MPI_Status status;
|
||||
|
||||
int scanning = 1;
|
||||
|
||||
int total_nr_req = Npts_w;
|
||||
int nr_sent_out = 0;
|
||||
int nr_returned = 0;
|
||||
|
||||
Vect_DP alpha_req(Npts_w);
|
||||
for (int iw = 0; iw < Npts_w; ++iw) alpha_req[iw] = 0.5 * PI * (iw + 0.5)/Npts_w;
|
||||
|
||||
//cout << "alpha_req = " << alpha_req << endl;
|
||||
|
||||
for (int i = 1; i <= nr_clients && i <= total_nr_req; ++i) {
|
||||
|
||||
// Send request to client i, in the form of the req_id_array vector
|
||||
client_request[0] = k;
|
||||
client_request[1] = alpha_req[nr_sent_out];
|
||||
|
||||
MPI_Send(client_request, client_request_size, MPI_DOUBLE, i, scanning, comm);
|
||||
//cout << "Server: sent request ";
|
||||
//for (int ii = 0; ii < client_request_size; ++ii) cout << client_request[ii] << " ";
|
||||
//cout << "with tag " << scanning << " to client " << i << endl;
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
while (nr_returned < total_nr_req) {
|
||||
|
||||
//cout << "Server: waiting for answers... " << endl;
|
||||
MPI_Recv (client_result, client_result_size, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status);
|
||||
nr_returned++;
|
||||
//cout << "Server: received answer from client " << status.MPI_SOURCE << endl;
|
||||
|
||||
// unbuffer result
|
||||
SFraw_outfile << client_result[1] << "\t" << client_result[2] << endl;
|
||||
|
||||
// Send out new request if needed
|
||||
if (nr_sent_out < total_nr_req) {
|
||||
client_request[1] = alpha_req[nr_sent_out];
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, status.MPI_SOURCE, scanning, comm);
|
||||
nr_sent_out++;
|
||||
//cout << "nr_sent_out = " << nr_sent_out << endl;
|
||||
}
|
||||
|
||||
} // while (nr_returned < total_nr_req)
|
||||
|
||||
// Send term signal to clients
|
||||
int scanning_completed = 0;
|
||||
for (int i = 1; i <= nr_clients; ++i)
|
||||
MPI_Send (client_request, client_request_size, MPI_DOUBLE, i, scanning_completed, comm);
|
||||
|
||||
SFraw_outfile.close();
|
||||
|
||||
//SFsrc_outfile << answer << endl;
|
||||
//SFsrc_outfile.close();
|
||||
|
||||
// Translate raw data into SF_4p (k,omega) data
|
||||
|
||||
//Translate_raw_4p_data (k, max_rec_w, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
Translate_raw_4p_data (k, Npts_w, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace ABACUS {
|
|||
|
||||
DP rho_used = fabs(rho);
|
||||
|
||||
if (rho_used > 10000.0) return(-PI * rho_used - 2.0 * Euler_Mascheroni); // CHECK THIS
|
||||
if (rho_used > 10000.0) return(-PI * rho_used - 2.0 * Euler_Mascheroni);
|
||||
|
||||
Vect_DP args(2);
|
||||
args[0] = 0.0;
|
||||
|
@ -37,12 +37,6 @@ namespace ABACUS {
|
|||
- 2.0 * Integrate_rec (Integrand_12, args, 0, t1, tinf, req_prec, 12)
|
||||
- Integrate_rec (Integrand_2, args, 0, 0.0, tinf, req_prec, 12);
|
||||
|
||||
/*
|
||||
DP answer = -2.0 * Euler_Mascheroni - 2.0 * log(4.0 * rho_used * t1)
|
||||
+ 2.0 * (Integrate_optimal (Integrand_11, args, 0, 0.0, t1, req_prec, 1.0e-30, 10000)).integ_est
|
||||
- 2.0 * (Integrate_optimal (Integrand_12, args, 0, t1, tinf, req_prec, 1.0e-30, 10000)).integ_est
|
||||
- (Integrate_optimal (Integrand_2, args, 0, 0.0, tinf, req_prec, 1.0e-30, 10000)).integ_est;
|
||||
*/
|
||||
return(answer);
|
||||
}
|
||||
|
||||
|
@ -53,14 +47,17 @@ namespace ABACUS {
|
|||
{
|
||||
// Careful ! This is S(k, omega) = S (k, w) |dw/domega| = 2 S(k, w)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
DP wu = twoPI * sin(0.5 * k);
|
||||
DP wl = PI * fabs(sin(k));
|
||||
|
||||
// Factor of 2: return S(k, omega), not S(k, w)
|
||||
// 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^{+-}
|
||||
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);
|
||||
// 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^{+-}
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -75,7 +72,8 @@ namespace ABACUS {
|
|||
|
||||
// 0.5 factor: 1 from Bougourzi, and 1/2 is S^{zz} = 1/2 * S^{+-}
|
||||
return(args[1] < wu && args[1] > wl ?
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
DP SF_2p_alt (Vect_DP args, I_table Itable)
|
||||
|
@ -87,8 +85,7 @@ namespace ABACUS {
|
|||
DP wu = twoPI * sin(0.5 * args[0]);
|
||||
DP wl = PI * fabs(sin(args[0]));
|
||||
|
||||
//DP w = wu * cos(args[1]);
|
||||
//DP factor = 1.0;
|
||||
|
||||
DP w = wl * cosh(args[1]);
|
||||
|
||||
if (w >= wu || w <= wl) return(0.0);
|
||||
|
@ -109,8 +106,6 @@ namespace ABACUS {
|
|||
DP wu = twoPI * sin(0.5 * args[0]);
|
||||
DP wl = PI * fabs(sin(args[0]));
|
||||
|
||||
//DP w = wu * cos(args[1]);
|
||||
//DP factor = 1.0;
|
||||
DP w = wl * cosh(args[1]);
|
||||
DP factor = sqrt((w * w - wl * wl)/(wu * wu - w * w));
|
||||
|
||||
|
@ -153,7 +148,6 @@ namespace ABACUS {
|
|||
args_to_SF_2p[1] = 0.0; // this will be w
|
||||
args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
|
||||
//return(Integrate_rec_using_table (SF_2p_alt, args_to_SF_2p, 1, Itable, 0.0, acos(wl/wu), req_prec, max_rec)/twoPI);
|
||||
return(Integrate_rec_using_table (SF_2p_alt, args_to_SF_2p, 1, Itable, 0.0, acosh(wu/wl), req_prec, max_rec)/twoPI);
|
||||
}
|
||||
|
||||
|
@ -168,7 +162,8 @@ namespace ABACUS {
|
|||
args_to_SF_2p_intw[2] = DP(max_rec);
|
||||
|
||||
// Factor 2: int[0, 2PI] = 2 int[0, PI]
|
||||
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);
|
||||
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);
|
||||
// 4 : because full integral gives 1/4, return value here is sr fraction obtained.
|
||||
}
|
||||
|
||||
|
@ -183,7 +178,8 @@ namespace ABACUS {
|
|||
args_to_SF_2p_intw[2] = DP(max_rec);
|
||||
|
||||
// Factor 2: int[0, 2PI] = 2 int[0, PI]
|
||||
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);
|
||||
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);
|
||||
// 4 : because full integral gives 1/4, return value here is sr fraction obtained.
|
||||
}
|
||||
|
||||
|
@ -210,7 +206,8 @@ namespace ABACUS {
|
|||
args_to_SF_2p[1] = 0.0; // this will be w
|
||||
args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
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 {
|
|||
args_to_SF_2p[1] = 0.0; // this will be alpha
|
||||
args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
DP SF_2p_check_fixed_k_sumrule_opt (DP k, DP req_prec, int Npts, I_table Itable)
|
||||
|
@ -240,7 +238,8 @@ namespace ABACUS {
|
|||
args_to_SF_2p[1] = 0.0; // this will be alpha
|
||||
args_to_SF_2p[2] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,9 +252,6 @@ namespace ABACUS {
|
|||
complex<DP> g[4];
|
||||
for (int l = 0; l < 4; ++l) g[l] = 0.0;
|
||||
|
||||
//DP prefactor = 256.0 * pow(PI, 14.0);
|
||||
//DP prefactor = 1.0; // All factors taken into account later
|
||||
|
||||
complex<DP> Plm[4];
|
||||
complex<DP> Pm[4];
|
||||
|
||||
|
@ -280,27 +276,7 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
// Do m = 0 terms:
|
||||
/*
|
||||
Pm[0] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj1[0]) - ln_Gamma(1.0 + irhoj1[0])
|
||||
+ ln_Gamma(-0.5 + irhoj2[0]) - ln_Gamma(1.0 + irhoj2[0])
|
||||
+ ln_Gamma(-0.5 + irhoj3[0]) - ln_Gamma(1.0 + irhoj3[0]));
|
||||
Pm[1] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj0[1]) - ln_Gamma(1.0 + irhoj0[1])
|
||||
+ ln_Gamma(-0.5 + irhoj2[1]) - ln_Gamma(1.0 + irhoj2[1])
|
||||
+ ln_Gamma(-0.5 + irhoj3[1]) - ln_Gamma(1.0 + irhoj3[1]));
|
||||
Pm[2] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj0[2]) - ln_Gamma(1.0 + irhoj0[2])
|
||||
+ ln_Gamma(-0.5 + irhoj1[2]) - ln_Gamma(1.0 + irhoj1[2])
|
||||
+ ln_Gamma(-0.5 + irhoj3[2]) - ln_Gamma(1.0 + irhoj3[2]));
|
||||
Pm[3] *= Gamma_min_0p5 * exp(ln_Gamma(-0.5 + irhoj0[3]) - ln_Gamma(1.0 + irhoj0[3])
|
||||
+ ln_Gamma(-0.5 + irhoj1[3]) - ln_Gamma(1.0 + irhoj1[3])
|
||||
+ ln_Gamma(-0.5 + irhoj2[3]) - ln_Gamma(1.0 + irhoj2[3]));
|
||||
*/
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
/*
|
||||
Pm[j] *= exp(ln_Gamma(-0.5 + irhoj0[j]) - ln_Gamma(1.0 + irhoj0[j])
|
||||
+ ln_Gamma(-0.5 + irhoj1[j]) - ln_Gamma(1.0 + irhoj1[j])
|
||||
+ ln_Gamma(-0.5 + irhoj2[j]) - ln_Gamma(1.0 + irhoj2[j])
|
||||
+ ln_Gamma(-0.5 + irhoj3[j]) - ln_Gamma(1.0 + irhoj3[j]));
|
||||
*/
|
||||
// Calling only Gamma (z) for Re(z) >= 0.5, in view of Lanczos method:
|
||||
Pm[j] *= exp(ln_Gamma(0.5 + irhoj0[j]) - ln_Gamma(1.0 + irhoj0[j])
|
||||
+ ln_Gamma(0.5 + irhoj1[j]) - ln_Gamma(1.0 + irhoj1[j])
|
||||
|
@ -315,23 +291,12 @@ namespace ABACUS {
|
|||
|
||||
if (j <= l) g[l] += Plm[j] * Pm[j]; // otherwise no m = 0 term
|
||||
|
||||
//cout << "j = " << j << "\tl = " << l << "\tPlm[j] = " << Plm[j] << "\tPm[j] = " << Pm[j] << "\tprod = " << Plm[j] * Pm[j] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
if (j == 0) g[0] += irhoj1[j] * irhoj2[j] * irhoj3[j] * Pm[j];
|
||||
if (j <= 1) g[1] += (-0.5 + irhoj0[j]) * irhoj2[j] * irhoj3[j] * Pm[j];
|
||||
if (j <= 2) g[2] += (-0.5 + irhoj0[j]) * (-0.5 + irhoj1[j]) * irhoj3[j] * Pm[j];
|
||||
g[3] += (-0.5 + irhoj0[j]) * (-0.5 + irhoj1[j]) * (-0.5 + irhoj2[j]) * Pm[j];
|
||||
}
|
||||
*/
|
||||
|
||||
DP sum_norm_gl = norm(g[0]) + norm(g[1]) + norm(g[2]) + norm(g[3]);
|
||||
DP old_sum_norm_gl = sum_norm_gl;
|
||||
|
||||
//cout << "|g1|^2 = " << prefactor * norm(g[0]) << "\t2 " << prefactor * norm(g[1]) << "\t3 " << prefactor * norm(g[2]) << "\t4 " << prefactor * norm(g[3]) << endl;
|
||||
|
||||
// Do m = 1, 2, ... terms:
|
||||
|
||||
|
@ -353,68 +318,17 @@ namespace ABACUS {
|
|||
Pm[j] *= (m - 1.5 + irhoj0[j]) * (m - 1.5 + irhoj1[j]) * (m - 1.5 + irhoj2[j]) * (m - 1.5 + irhoj3[j])
|
||||
/ ((DP(m) + irhoj0[j]) * (DP(m) + irhoj1[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]));
|
||||
|
||||
//for (int l = 0; l < 4; ++l) {
|
||||
|
||||
//Plm[j] = 1.0;
|
||||
//for (int i = 0; i < 4; ++i) if (i != l) Plm[j] *= m - (l > i ? 0.5 : 0.0) + II * (rho[j] - rho[i]);
|
||||
|
||||
//g[l] += Plm[j] * Pm[j];
|
||||
//}
|
||||
|
||||
// FASTER: unwrap l, i loops
|
||||
// l = 0:
|
||||
//Plm[j] = (DP(m) + II * (rho[j] - rho[1])) * (DP(m) + II * (rho[j] - rho[2])) * (DP(m) + II * (rho[j] - rho[3]));
|
||||
//Plm[j] = (DP(m) + irhoj1[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]);
|
||||
//g[0] += Plm[j] * Pm[j];
|
||||
g[0] += (DP(m) + irhoj1[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]) * Pm[j];
|
||||
// l = 1;
|
||||
//Plm[j] = (m - 0.5 + II * (rho[j] - rho[0])) * (DP(m) + II * (rho[j] - rho[2])) * (DP(m) + II * (rho[j] - rho[3]));
|
||||
//Plm[j] = (m - 0.5 + irhoj0[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]);
|
||||
//g[1] += Plm[j] * Pm[j];
|
||||
g[1] += (m - 0.5 + irhoj0[j]) * (DP(m) + irhoj2[j]) * (DP(m) + irhoj3[j]) * Pm[j];
|
||||
// l = 2;
|
||||
//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]));
|
||||
//Plm[j] = (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (DP(m) + irhoj3[j]);
|
||||
//g[2] += Plm[j] * Pm[j];
|
||||
g[2] += (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (DP(m) + irhoj3[j]) * Pm[j];
|
||||
// l = 3;
|
||||
//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]));
|
||||
//Plm[j] = (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (m - 0.5 + irhoj2[j]);
|
||||
//g[3] += Plm[j] * Pm[j];
|
||||
g[3] += (m - 0.5 + irhoj0[j]) * (m - 0.5 + irhoj1[j]) * (m - 0.5 + irhoj2[j]) * Pm[j];
|
||||
}
|
||||
|
||||
/*
|
||||
// Also unwrap j loop:
|
||||
Pm[0] *= (m - 1.5 + irhoj0[0]) * (m - 1.5 + irhoj1[0]) * (m - 1.5 + irhoj2[0]) * (m - 1.5 + irhoj3[0])
|
||||
/ ((DP(m) + irhoj0[0]) * (DP(m) + irhoj1[0]) * (DP(m) + irhoj2[0]) * (DP(m) + irhoj3[0]));
|
||||
Pm[1] *= (m - 1.5 + irhoj0[1]) * (m - 1.5 + irhoj1[1]) * (m - 1.5 + irhoj2[1]) * (m - 1.5 + irhoj3[1])
|
||||
/ ((DP(m) + irhoj0[1]) * (DP(m) + irhoj1[1]) * (DP(m) + irhoj2[1]) * (DP(m) + irhoj3[1]));
|
||||
Pm[2] *= (m - 1.5 + irhoj0[2]) * (m - 1.5 + irhoj1[2]) * (m - 1.5 + irhoj2[2]) * (m - 1.5 + irhoj3[2])
|
||||
/ ((DP(m) + irhoj0[2]) * (DP(m) + irhoj1[2]) * (DP(m) + irhoj2[2]) * (DP(m) + irhoj3[2]));
|
||||
Pm[3] *= (m - 1.5 + irhoj0[3]) * (m - 1.5 + irhoj1[3]) * (m - 1.5 + irhoj2[3]) * (m - 1.5 + irhoj3[3])
|
||||
/ ((DP(m) + irhoj0[3]) * (DP(m) + irhoj1[3]) * (DP(m) + irhoj2[3]) * (DP(m) + irhoj3[3]));
|
||||
|
||||
g[0] += ((DP(m) + irhoj1[0]) * (DP(m) + irhoj2[0]) * (DP(m) + irhoj3[0])) * Pm[0]
|
||||
+ ((DP(m)) * (DP(m) + irhoj2[1]) * (DP(m) + irhoj3[1])) * Pm[1]
|
||||
+ ((DP(m) + irhoj1[2]) * (DP(m)) * (DP(m) + irhoj3[0])) * Pm[2]
|
||||
+ ((DP(m) + irhoj1[3]) * (DP(m) + irhoj2[3]) * (DP(m))) * Pm[3];
|
||||
|
||||
g[1] += ((m - 0.5) * (DP(m) + irhoj2[0]) * (DP(m) + irhoj3[0])) * Pm[0]
|
||||
+ ((m - 0.5 + irhoj0[1]) * (DP(m) + irhoj2[1]) * (DP(m) + irhoj3[1])) * Pm[1]
|
||||
+ ((m - 0.5 + irhoj0[2]) * (DP(m)) * (DP(m) + irhoj3[2])) * Pm[2]
|
||||
+ ((m - 0.5 + irhoj0[3]) * (DP(m) + irhoj2[3]) * (DP(m))) * Pm[3];
|
||||
|
||||
g[2] += ((m - 0.5) * (m - 0.5 + irhoj1[0]) * (DP(m) + irhoj3[0])) * Pm[0]
|
||||
+ ((m - 0.5 + irhoj0[1]) * (m - 0.5) * (DP(m) + irhoj3[1])) * Pm[1]
|
||||
+ ((m - 0.5 + irhoj0[2]) * (m - 0.5 + irhoj1[2]) * (DP(m) + irhoj3[2])) * Pm[2]
|
||||
+ ((m - 0.5 + irhoj0[3]) * (m - 0.5 + irhoj1[3]) * (DP(m))) * Pm[3];
|
||||
|
||||
g[3] += ((m - 0.5) * (m - 0.5 + irhoj1[0]) * (m - 0.5 + irhoj2[0])) * Pm[0]
|
||||
+ ((m - 0.5 + irhoj0[1]) * (m - 0.5) * (m - 0.5 + irhoj2[1])) * Pm[1]
|
||||
+ ((m - 0.5 + irhoj0[2]) * (m - 0.5 + irhoj1[2]) * (m - 0.5)) * Pm[2]
|
||||
+ ((m - 0.5 + irhoj0[3]) * (m - 0.5 + irhoj1[3]) * (m - 0.5 + irhoj2[3])) * Pm[3];
|
||||
*/
|
||||
m++;
|
||||
|
||||
} while (m < m_to_reach);
|
||||
|
@ -423,11 +337,6 @@ namespace ABACUS {
|
|||
|
||||
} while (m < 10 || sum_norm_gl/old_sum_norm_gl - 1.0 > req_prec && m < 100000);
|
||||
|
||||
//cout << "g converged using " << m << " terms." << endl;
|
||||
|
||||
//cout << "|g1|^2 = " << prefactor * norm(g[0]) << "\t2 " << prefactor * norm(g[1]) << "\t3 " << prefactor * norm(g[2]) << "\t4 " << prefactor * norm(g[3]) << endl;
|
||||
|
||||
//return(prefactor * (norm(g[0]) + norm(g[1]) + norm(g[2]) + norm(g[3])));
|
||||
return(norm(g[0]) + norm(g[1]) + norm(g[2]) + norm(g[3]));
|
||||
|
||||
}
|
||||
|
@ -436,13 +345,8 @@ namespace ABACUS {
|
|||
{
|
||||
Vect_DP args(2);
|
||||
|
||||
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;
|
||||
//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;
|
||||
|
||||
//cout << "|A|^2 = " << exp(-2.0 * Integrate_rec (Integrand_A, args, 0, 0.0, 100.0, req_prec))
|
||||
// << "\t Gamma (1/4) = " << exp ((ln_Gamma(0.25))) << endl;
|
||||
//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;
|
||||
//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;
|
||||
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;
|
||||
|
||||
return(answer);
|
||||
}
|
||||
|
@ -459,18 +363,11 @@ namespace ABACUS {
|
|||
|
||||
sum_I_integrals = 0.0;
|
||||
for (int i1 = 0; i1 < 3; ++i1) for (int i2 = i1+1; i2 < 4; ++i2) {
|
||||
//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;
|
||||
//sum_I_integrals += I_integral(rho[i1] - rho[i2], req_prec);
|
||||
sum_I_integrals += Itable.Return_val (rho[i1] - rho[i2]);
|
||||
}
|
||||
//cout << "sum_I_integrals = " << sum_I_integrals << "\texp(-sum) = " << exp(-sum_I_integrals) << endl;
|
||||
|
||||
//sum_norm_g = 0.0;
|
||||
//for (int i = 0; i < 4; ++i) sum_norm_g += norm(g(i, rho));
|
||||
sum_norm_g = Sum_norm_gl (rho, req_prec);
|
||||
|
||||
//cout << "sum_norm_g = " << sum_norm_g << "\t sqrt() = " << sqrt(Wu * Wu - W * W) << endl;
|
||||
|
||||
return(exp(-sum_I_integrals) * sum_norm_g/sqrt(Wu * Wu - W * W));
|
||||
}
|
||||
|
||||
|
@ -498,7 +395,8 @@ namespace ABACUS {
|
|||
|
||||
DP argacos1, argacos2;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
DP acos1 = acos(argacos1);
|
||||
DP acos2 = acos(argacos2);
|
||||
|
@ -516,7 +414,7 @@ namespace ABACUS {
|
|||
p[3] = 0.5 * (K-k) - PI - acos2;
|
||||
}
|
||||
|
||||
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"); }
|
||||
for (int i = 0; i < 4; ++i) if (p[i] < -PI || p[i] > 0.0) return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@ -527,11 +425,9 @@ namespace ABACUS {
|
|||
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
// 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;
|
||||
|
||||
//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));
|
||||
return(answer);
|
||||
}
|
||||
|
||||
|
@ -583,12 +479,11 @@ namespace ABACUS {
|
|||
|
||||
if (!Set_p_given_kwKW (args_to_G[0], args_to_G[1], args_to_G[2], W, p)) return(0.0);
|
||||
|
||||
DP answer = J_fn (p, args_to_G[4], Itable) * 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))));
|
||||
DP answer = J_fn (p, args_to_G[4], Itable)
|
||||
* 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))));
|
||||
|
||||
if (is_nan(answer)) {
|
||||
cerr << setprecision(10) << "args_to_G1_fn_mid = " << args_to_G << "G1 = " << answer << "\tPut to zero..." << endl;
|
||||
//ABACUSerror("non !");
|
||||
answer = 0.0;
|
||||
}
|
||||
return(answer);
|
||||
|
@ -609,13 +504,12 @@ namespace ABACUS {
|
|||
if (!Set_p_given_kwKW (args_to_G[0], args_to_G[1], args_to_G[2], W, p)) return(0.0);
|
||||
|
||||
DP answer = J_fn (p, args_to_G[4], Itable)
|
||||
//* 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))));
|
||||
* 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)));
|
||||
|
||||
if (is_nan(answer)) {
|
||||
cerr << setprecision(10) << "args_to_G2_fn_mid = " << args_to_G << "G2 = " << answer << endl;
|
||||
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;
|
||||
//ABACUSerror("non !");
|
||||
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;
|
||||
answer = 0.0;
|
||||
}
|
||||
return(answer);
|
||||
|
@ -634,7 +528,8 @@ namespace ABACUS {
|
|||
DP Wu1 = args_to_G[6];
|
||||
DP Wu2 = args_to_G[7];
|
||||
|
||||
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)))));
|
||||
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)))));
|
||||
}
|
||||
|
||||
DP H_fn (Vect_DP args_to_H, I_table Itable)
|
||||
|
@ -657,8 +552,8 @@ namespace ABACUS {
|
|||
DP Wmin_used = Wmin (k, w, K);
|
||||
DP Wmax_used = Wmax (k, w, K);
|
||||
|
||||
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);
|
||||
//return(Riemann_Integrate_rec_using_table (G_fn, args_to_G, 3, Itable, 0.0, 10.0, 500));
|
||||
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);
|
||||
}
|
||||
|
||||
DP H2_fn (Vect_DP args_to_H, I_table Itable)
|
||||
|
@ -741,8 +636,10 @@ namespace ABACUS {
|
|||
DP alpha_L2 = 0.0;
|
||||
DP alpha_U2 = acos(Wmid/Wmax_used);
|
||||
|
||||
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]));
|
||||
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]));
|
||||
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]));
|
||||
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]));
|
||||
|
||||
return(answer);
|
||||
}
|
||||
|
@ -790,8 +687,10 @@ namespace ABACUS {
|
|||
DP alpha_L2 = 0.0;
|
||||
DP alpha_U2 = acos(Wmid/Wmax_used);
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
|
||||
return(answer);
|
||||
}
|
||||
|
@ -823,10 +722,9 @@ namespace ABACUS {
|
|||
args_to_G[9] = DP(max_rec);
|
||||
|
||||
return(Integrate_rec_using_table (G_fn_alt, args_to_G, 3, Itable, 0.0, acosh(Wmax_used/Wmin_used), req_prec, max_rec));
|
||||
//return(Riemann_Integrate_rec_using_table (G_fn, args_to_G, 3, Itable, 0.0, 10.0, 500));
|
||||
}
|
||||
|
||||
//DP SF_4p_kwKW (DP k, DP omega, DP req_prec, int max_rec, I_table Itable)
|
||||
|
||||
DP SF_4p_kwKW (Vect_DP args, I_table Itable)
|
||||
{
|
||||
// Translate:
|
||||
|
@ -842,21 +740,20 @@ namespace ABACUS {
|
|||
Vect_DP args_to_H(5);
|
||||
args_to_H[0] = k; // shift of PI in Bougourzi: because they do FM case.
|
||||
// We want AFM, so SF_4p (k, omega) is correctly obtained directly from the RHS of their formula.
|
||||
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)
|
||||
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)
|
||||
args_to_H[1] = w;
|
||||
args_to_H[2] = 0.0; // this is K
|
||||
args_to_H[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
args_to_H[4] = DP(max_rec);
|
||||
|
||||
if (w > wmax_4p(k) || w < wmin_4p(k)) {
|
||||
//cout << "w out of bounds in SF_4p: " << "wmin = " << PI * sin(k) << " wmax = " << 4.0 * PI * sin(0.25 * k) << " w = " << w << endl;
|
||||
return(0.0);
|
||||
}
|
||||
|
||||
DP prefactor = 2.0 * 0.5 * 4.0 * Compute_C4 (req_prec); // 4 comes from using p1 > p2 & p3 > p4 instead of whole interval.
|
||||
// 2 from Jacobian |dw/domega|
|
||||
// 0.5 from S^{zz} = S^{pm}/2
|
||||
//DP prefactor = 4.0;
|
||||
|
||||
// Define the K integral domain
|
||||
Domain<DP> Kdomain;
|
||||
|
@ -897,26 +794,17 @@ namespace ABACUS {
|
|||
Kdomain.Exclude (K3em, K3ep);
|
||||
}
|
||||
|
||||
//cout << "Kdomain: " << endl << Kdomain << endl;
|
||||
|
||||
// Use (K,W) -> (k-K, w-W) symmetry to restrict to K in [k/2, k/2+PI]
|
||||
Kdomain.Exclude (0.0, 0.5 * k);
|
||||
Kdomain.Exclude (0.5 * k + PI, twoPI);
|
||||
//Kdomain.Exclude (0.5 * k, 0.5 * k + PI);
|
||||
prefactor *= 2.0;
|
||||
|
||||
//cout << "Kdomain restricted: " << endl << Kdomain << endl;
|
||||
|
||||
DP answer = 0.0;
|
||||
|
||||
for (int idom = 0; idom < Kdomain.Ndomains(); ++idom)
|
||||
//answer += Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
//answer += Integrate_rec_using_table (H2_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
//answer += Integrate_rec_using_table (H_fn_alt, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom),
|
||||
req_prec, max_rec);
|
||||
|
||||
//return(prefactor * Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, req_prec, max_rec));
|
||||
//return(prefactor * Riemann_Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, 500));
|
||||
return (prefactor * answer);
|
||||
}
|
||||
|
||||
|
@ -938,21 +826,21 @@ namespace ABACUS {
|
|||
Vect_DP args_to_H(5);
|
||||
args_to_H[0] = k; // shift of PI in Bougourzi: because they do FM case.
|
||||
// We want AFM, so SF_4p (k, omega) is correctly obtained directly from the RHS of their formula.
|
||||
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)
|
||||
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)
|
||||
args_to_H[1] = w;
|
||||
args_to_H[2] = 0.0; // this is K
|
||||
args_to_H[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
args_to_H[4] = DP(Npts_W);
|
||||
|
||||
if (w > wmax_4p(k) || w < wmin_4p(k)) {
|
||||
//cout << "w out of bounds in SF_4p: " << "wmin = " << PI * sin(k) << " wmax = " << 4.0 * PI * sin(0.25 * k) << " w = " << w << endl;
|
||||
return(0.0);
|
||||
}
|
||||
|
||||
DP prefactor = 2.0 * 0.5 * 4.0 * Compute_C4 (req_prec); // 4 comes from using p1 > p2 & p3 > p4 instead of whole interval.
|
||||
DP prefactor = 2.0 * 0.5 * 4.0 * Compute_C4 (req_prec);
|
||||
// 4 comes from using p1 > p2 & p3 > p4 instead of whole interval.
|
||||
// 2 from Jacobian |dw/domega|
|
||||
// 0.5 from S^{zz} = S^{pm}/2
|
||||
//DP prefactor = 4.0;
|
||||
|
||||
// Define the K integral domain
|
||||
Domain<DP> Kdomain;
|
||||
|
@ -993,28 +881,17 @@ namespace ABACUS {
|
|||
Kdomain.Exclude (K3em, K3ep);
|
||||
}
|
||||
|
||||
//cout << "Kdomain: " << endl << Kdomain << endl;
|
||||
|
||||
// Use (K,W) -> (k-K, w-W) symmetry to restrict to K in [k, k+PI]
|
||||
Kdomain.Exclude (0.0, 0.5 * k);
|
||||
Kdomain.Exclude (0.5 * k + PI, twoPI);
|
||||
//Kdomain.Exclude (0.5 * k, 0.5 * k + PI);
|
||||
prefactor *= 2.0;
|
||||
|
||||
//cout << "Kdomain restricted: " << endl << Kdomain << endl;
|
||||
|
||||
DP answer = 0.0;
|
||||
|
||||
for (int idom = 0; idom < Kdomain.Ndomains(); ++idom)
|
||||
//answer += Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
//answer += Integrate_rec_using_table (H2_fn, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
//answer += Integrate_rec_using_table (H_fn_alt, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
//answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, max_rec);
|
||||
//answer += Integrate_rec_using_table (H_fn_mid, args_to_H, 2, Itable, Kdomain.xmin(idom), Kdomain.xmax(idom), req_prec, 1);
|
||||
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;
|
||||
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;
|
||||
|
||||
//return(prefactor * Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, req_prec, max_rec));
|
||||
//return(prefactor * Riemann_Integrate_rec_using_table (H_fn, args_to_H, 2, Itable, 0.0, twoPI, 500));
|
||||
return (prefactor * answer);
|
||||
}
|
||||
|
||||
|
@ -1070,11 +947,9 @@ namespace ABACUS {
|
|||
|
||||
Vect_DP args_to_SF_4p_kwKW = args;
|
||||
DP omegamin = 0.5 * wmin_4p (args[0]);
|
||||
//DP omegamax = 0.5 * wmax_4p (args[0]);
|
||||
|
||||
args_to_SF_4p_kwKW[1] = omegamin * cosh(args[1]);
|
||||
|
||||
//return((omegamax - omegamin) * sin(args[1]) * SF_4p_kwKW_opt (args_to_SF_4p_kwKW, Itable));
|
||||
return(omegamin * sinh(args[1]) * SF_4p_kwKW_opt (args_to_SF_4p_kwKW, Itable));
|
||||
}
|
||||
|
||||
|
@ -1117,7 +992,8 @@ namespace ABACUS {
|
|||
|
||||
/******************************************************************************************/
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
DP omegamin = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
DP omegamax = 0.5 * wmax_4p (k);
|
||||
|
@ -1127,7 +1003,6 @@ namespace ABACUS {
|
|||
DP alpha_in_old = -1.0;
|
||||
DP SF_in_old = -1.0;
|
||||
|
||||
//int dim_w = int(pow(3.0, max_rec_w + 2));
|
||||
DP* alpha = new DP[dim_w];
|
||||
DP* omega = new DP[dim_w];
|
||||
DP* SF_4p_dat = new DP[dim_w];
|
||||
|
@ -1167,8 +1042,6 @@ namespace ABACUS {
|
|||
|
||||
QuickSort (omega, index, 0, dim_w - 1);
|
||||
|
||||
//for (int j = 0; j < dim_w; ++j) cout << j << "\t" << omega[j] << "\t" << index[j] << endl;
|
||||
|
||||
DP fixed_k_sr_2p = 0.0;
|
||||
DP fixed_k_sr_4p = 0.0;
|
||||
DP full_sr_2p = 0.0;
|
||||
|
@ -1199,9 +1072,12 @@ namespace ABACUS {
|
|||
full_sr_2p += Jac_dalpha * SF_2p_dat[index[i] ];
|
||||
}
|
||||
|
||||
Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[dim_w - 2] ]) * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
|
||||
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] ]);
|
||||
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] ]);
|
||||
Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[dim_w - 2] ])
|
||||
* 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
|
||||
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] ]);
|
||||
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] ]);
|
||||
full_sr_4p += Jac_dalpha * (SF_4p_dat[index[dim_w - 2] ] + SF_4p_dat[index[dim_w - 1] ]);
|
||||
full_sr_2p += Jac_dalpha * (SF_2p_dat[index[dim_w - 2] ] + SF_2p_dat[index[dim_w - 1] ]);
|
||||
|
||||
|
@ -1234,19 +1110,18 @@ namespace ABACUS {
|
|||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
// Here, omega = omegamin * cosh(alpha)
|
||||
|
||||
DP omegamin = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax = 0.5 * wmax_4p (k);
|
||||
|
||||
DP alpha_in;
|
||||
DP SF_in;
|
||||
DP alpha_in_old = -1.0;
|
||||
DP SF_in_old = -1.0;
|
||||
|
||||
//int dim_w = int(pow(3.0, max_rec_w + 2));
|
||||
DP* alpha = new DP[dim_w];
|
||||
DP* omega = new DP[dim_w];
|
||||
DP* SF_4p_dat = new DP[dim_w];
|
||||
|
@ -1267,11 +1142,9 @@ namespace ABACUS {
|
|||
SFraw >> alpha_in >> SF_in;
|
||||
|
||||
alpha[i] = alpha_in;
|
||||
//omega[i] = omegamin + (omegamax - omegamin) * (1.0 - cos(alpha_in));
|
||||
omega[i] = omegamin * cosh(alpha_in);
|
||||
|
||||
// CAREFUL !!! SF_in is S (k, w), and we want S (k, omega) = 2 S(k, w)
|
||||
//SF_4p_dat[i] = 2.0 * SF_in/((omegamax - omegamin) * sin(alpha_in));
|
||||
SF_4p_dat[i] = 2.0 * SF_in/(omegamin * sinh(alpha_in));
|
||||
|
||||
SF_2p_dat[i] = SF_2p (k, omega[i], Itable); // This already is S(k, omega)
|
||||
|
@ -1288,13 +1161,10 @@ namespace ABACUS {
|
|||
|
||||
QuickSort (omega, index, 0, dim_w - 1);
|
||||
|
||||
//for (int j = 0; j < dim_w; ++j) cout << j << "\t" << omega[j] << "\t" << index[j] << endl;
|
||||
|
||||
DP fixed_k_sr_2p = 0.0;
|
||||
DP fixed_k_sr_4p = 0.0;
|
||||
DP full_sr_2p = 0.0;
|
||||
DP full_sr_4p = 0.0;
|
||||
//DP Jac_dalpha = 0.0; // This is domega = (omegamax - omegamin) sin alpha dalpha
|
||||
DP Jac_dalpha = 0.0; // This is domega = omegamin sinh alpha dalpha
|
||||
|
||||
ofstream SF;
|
||||
|
@ -1307,7 +1177,6 @@ namespace ABACUS {
|
|||
SF.close();
|
||||
|
||||
// Compute first moment sum rule
|
||||
//Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[1] ]) * 0.5 * (alpha[index[2] ] - alpha[index[0] ]);
|
||||
Jac_dalpha = omegamin * sinh(alpha[index[1] ]) * 0.5 * (alpha[index[2] ] - alpha[index[0] ]);
|
||||
fixed_k_sr_4p += Jac_dalpha * (omega[0] * SF_4p_dat[index[0] ] + omega[1] * SF_4p_dat[index[1] ]);
|
||||
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 {
|
|||
full_sr_2p += Jac_dalpha * (SF_2p_dat[index[0] ] + SF_2p_dat[index[1] ]);
|
||||
|
||||
for (int i = 2; i < dim_w - 2; ++i) {
|
||||
//Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[i] ]) * 0.5 * (alpha[index[i + 1] ] - alpha[index[i - 1] ]);
|
||||
Jac_dalpha = omegamin * sinh(alpha[index[i] ]) * 0.5 * (alpha[index[i + 1] ] - alpha[index[i - 1] ]);
|
||||
fixed_k_sr_4p += Jac_dalpha * omega[i] * SF_4p_dat[index[i] ];
|
||||
fixed_k_sr_2p += Jac_dalpha * omega[i] * SF_2p_dat[index[i] ];
|
||||
|
@ -1323,10 +1191,11 @@ namespace ABACUS {
|
|||
full_sr_2p += Jac_dalpha * SF_2p_dat[index[i] ];
|
||||
}
|
||||
|
||||
//Jac_dalpha = (omegamax - omegamin) * sin(alpha[index[dim_w - 2] ]) * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
|
||||
Jac_dalpha = omegamin * sinh(alpha[index[dim_w - 2] ]) * 0.5 * (alpha[index[dim_w - 1] ] - alpha[index[dim_w - 3] ]);
|
||||
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] ]);
|
||||
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] ]);
|
||||
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] ]);
|
||||
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] ]);
|
||||
full_sr_4p += Jac_dalpha * (SF_4p_dat[index[dim_w - 2] ] + SF_4p_dat[index[dim_w - 1] ]);
|
||||
full_sr_2p += Jac_dalpha * (SF_2p_dat[index[dim_w - 2] ] + SF_2p_dat[index[dim_w - 1] ]);
|
||||
|
||||
|
@ -1365,19 +1234,22 @@ namespace ABACUS {
|
|||
{
|
||||
stringstream SFraw_stringstream;
|
||||
string SFraw_string;
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".raw";
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w
|
||||
<< "_max_rec_" << max_rec << ".raw";
|
||||
SFraw_string = SFraw_stringstream.str();
|
||||
const char* SFraw_Cstr = SFraw_string.c_str();
|
||||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".dat";
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w
|
||||
<< "_max_rec_" << max_rec << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
stringstream SFsrc_stringstream;
|
||||
string SFsrc_string;
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w << "_max_rec_" << max_rec << ".src";
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_max_rec_w_" << max_rec_w
|
||||
<< "_max_rec_" << max_rec << ".src";
|
||||
SFsrc_string = SFsrc_stringstream.str();
|
||||
const char* SFsrc_Cstr = SFsrc_string.c_str();
|
||||
|
||||
|
@ -1386,16 +1258,13 @@ namespace ABACUS {
|
|||
ofstream SFsrc_outfile;
|
||||
SFsrc_outfile.open(SFsrc_Cstr, ofstream::app);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
Vect_DP args_to_SF(4);
|
||||
args_to_SF[0] = k;
|
||||
args_to_SF[1] = 0.0; // integration variable
|
||||
args_to_SF[2] = req_prec;
|
||||
args_to_SF[3] = DP(max_rec);
|
||||
|
||||
//DP answer = Integrate_rec_using_table (SF_4p_kwKW, args_to_SF, 1, Itable, omegamin_used, omegamax_used, req_prec, max_rec, SF_outfile);
|
||||
|
||||
// Version using omega = omegamin + (omegamax - omegamin) * (1-cos(alpha))
|
||||
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;
|
||||
|
||||
|
@ -1405,7 +1274,6 @@ namespace ABACUS {
|
|||
SFsrc_outfile.close();
|
||||
|
||||
// Translate raw data into SF_4p (k,omega) data
|
||||
|
||||
Translate_raw_4p_data (k, int(pow(3.0, max_rec_w + 2)), SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
|
||||
return(answer);
|
||||
|
@ -1415,22 +1283,22 @@ namespace ABACUS {
|
|||
{
|
||||
stringstream SFraw_stringstream;
|
||||
string SFraw_string;
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".raw";
|
||||
//SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.raw";
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_"
|
||||
<< Npts_K << "_" << Npts_W << ".raw";
|
||||
SFraw_string = SFraw_stringstream.str();
|
||||
const char* SFraw_Cstr = SFraw_string.c_str();
|
||||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".dat";
|
||||
//SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.dat";
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_"
|
||||
<< Npts_K << "_" << Npts_W << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
stringstream SFsrc_stringstream;
|
||||
string SFsrc_string;
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".src";
|
||||
//SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.src";
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_"
|
||||
<< Npts_K << "_" << Npts_W << ".src";
|
||||
SFsrc_string = SFsrc_stringstream.str();
|
||||
const char* SFsrc_Cstr = SFsrc_string.c_str();
|
||||
|
||||
|
@ -1439,9 +1307,6 @@ namespace ABACUS {
|
|||
ofstream SFsrc_outfile;
|
||||
SFsrc_outfile.open(SFsrc_Cstr);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
Vect_DP args_to_SF(5);
|
||||
args_to_SF[0] = k;
|
||||
args_to_SF[1] = 0.0; // integration variable
|
||||
|
@ -1450,9 +1315,11 @@ namespace ABACUS {
|
|||
args_to_SF[4] = DP(Npts_W);
|
||||
|
||||
// Version using omega = omegamin + (omegamax - omegamin) * (1-cos(alpha))
|
||||
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);
|
||||
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);
|
||||
// Version using omega = omegamin * cosh(alpha)
|
||||
//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);
|
||||
//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);
|
||||
answer.integ_est /= twoPI;
|
||||
answer.abs_prec /= twoPI;
|
||||
|
||||
|
@ -1462,9 +1329,7 @@ namespace ABACUS {
|
|||
SFsrc_outfile.close();
|
||||
|
||||
// Translate raw data into SF_4p (k,omega) data
|
||||
|
||||
Translate_raw_4p_data (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
//Translate_raw_4p_data_cosh (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
|
||||
return(answer);
|
||||
}
|
||||
|
@ -1578,7 +1443,8 @@ namespace ABACUS {
|
|||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec << "_max_rec_" << max_rec << ".dat";
|
||||
SF_stringstream << "SF_4p_N_" << N << "_Nw_" << Nomega << "_wmax_" << omegamax << "_prec_" << req_prec
|
||||
<< "_max_rec_" << max_rec << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
|
@ -1748,7 +1614,4 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -26,22 +26,22 @@ namespace ABACUS {
|
|||
{
|
||||
stringstream SFraw_stringstream;
|
||||
string SFraw_string;
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".raw";
|
||||
//SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.raw";
|
||||
SFraw_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K
|
||||
<< "_" << Npts_W << ".raw";
|
||||
SFraw_string = SFraw_stringstream.str();
|
||||
const char* SFraw_Cstr = SFraw_string.c_str();
|
||||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".dat";
|
||||
//SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.dat";
|
||||
SF_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K
|
||||
<< "_" << Npts_W << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
stringstream SFsrc_stringstream;
|
||||
string SFsrc_string;
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << ".src";
|
||||
//SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K << "_" << Npts_W << "_ch.src";
|
||||
SFsrc_stringstream << "SF_4p_k_" << k << "_prec_" << req_prec << "_Npts_" << Npts_w << "_" << Npts_K
|
||||
<< "_" << Npts_W << ".src";
|
||||
SFsrc_string = SFsrc_stringstream.str();
|
||||
const char* SFsrc_Cstr = SFsrc_string.c_str();
|
||||
|
||||
|
@ -50,8 +50,6 @@ namespace ABACUS {
|
|||
ofstream SFsrc_outfile;
|
||||
SFsrc_outfile.open(SFsrc_Cstr);
|
||||
|
||||
//DP omegamin_used = 0.5 * wmin_4p (k); // Correct for factor of 2 in E between me & Bougourzi
|
||||
//DP omegamax_used = 0.5 * wmax_4p (k);
|
||||
|
||||
Vect_DP args_to_SF(5);
|
||||
args_to_SF[0] = k;
|
||||
|
@ -73,7 +71,6 @@ namespace ABACUS {
|
|||
SFsrc_outfile.close();
|
||||
|
||||
// Translate raw data into SF_4p (k,omega) data
|
||||
|
||||
Translate_raw_4p_data (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
//Translate_raw_4p_data_cosh (k, answer.n_vals, SFraw_Cstr, SF_Cstr, SFsrc_Cstr, Itable);
|
||||
|
||||
|
|
|
@ -198,8 +198,6 @@ namespace ABACUS {
|
|||
omega = -0.5 * PI * (sinp0 + sinp1 + sinp2 + sin(p[3]));
|
||||
iomega = int(omega * Npts_o/omegamax);
|
||||
|
||||
//cout << ik << "\t" << iomega << endl;
|
||||
|
||||
J_fn_cont = J_fn (p, req_prec, Itable);
|
||||
sum_J_fn += (ik == Npts_p ? 1.0 : 2.0) * J_fn_cont;
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ namespace ABACUS {
|
|||
|
||||
return(answer);
|
||||
|
||||
//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)));
|
||||
}
|
||||
|
||||
DP I_xi_11_integral (DP xi, DP rho, DP req_prec, int max_nr_pts, DP t1bar)
|
||||
|
@ -124,16 +123,20 @@ namespace ABACUS {
|
|||
else if (args[0] >= 1.0) {
|
||||
DP expm2t = exp(-2.0 * args[0]);
|
||||
DP expm2txi = exp(-2.0*args[0]*args[2]);
|
||||
//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));
|
||||
//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));
|
||||
answer = 8.0 * (1.0 - expm2t*expm2txi) * expm2t *
|
||||
pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
|
||||
pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t)
|
||||
* (1.0 + expm2t) * (1.0 + expm2t));
|
||||
}
|
||||
|
||||
DP expm2t = exp(-2.0 * args[0]);
|
||||
DP expm2txi = exp(-2.0*args[0]*args[2]);
|
||||
//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));
|
||||
//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));
|
||||
answer = 8.0 * (1.0 - expm2t*expm2txi) * expm2t *
|
||||
pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t) * (1.0 + expm2t) * (1.0 + expm2t));
|
||||
pow(sin(2.0 * args[0] * args[1]), 2.0)/(args[0] * (1.0 - expm2txi) * (1.0 - expm2t)
|
||||
* (1.0 + expm2t) * (1.0 + expm2t));
|
||||
|
||||
return(answer);
|
||||
|
||||
|
@ -153,7 +156,8 @@ namespace ABACUS {
|
|||
else if (args[0] >= 1.0) {
|
||||
DP expm2t = exp(-2.0 * args[0]);
|
||||
DP expm2txi = exp(-2.0*args[0]*args[2]);
|
||||
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));
|
||||
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));
|
||||
}
|
||||
return(answer);
|
||||
}
|
||||
|
@ -170,9 +174,6 @@ namespace ABACUS {
|
|||
|
||||
DP answer = 0.0;
|
||||
|
||||
//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;
|
||||
|
||||
//else
|
||||
answer = PI * rho + log(0.5 * (1.0 + exp(-2.0 * PI * rho_used))) // This is I^{(21)}
|
||||
+ (Integrate_optimal (Integrand_xi_22, args, 0, 0.0, tinf, req_prec, req_prec, max_nr_pts)).integ_est;
|
||||
|
||||
|
@ -201,22 +202,20 @@ namespace ABACUS {
|
|||
{
|
||||
// Careful ! This is S(k, omega) = S (k, w) |dw/domega| = 2 S(k, w)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
DP vF = Fermi_velocity_XXZ_h0 (Delta); // in units of omega
|
||||
|
||||
//DP wu = twoPI * sin(0.5 * k);
|
||||
DP wu = 4.0 * vF * sin(0.5 * k);
|
||||
//DP wl = PI * fabs(sin(k));
|
||||
DP wl = 2.0 * vF * fabs(sin(k));
|
||||
|
||||
DP rho = acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI;
|
||||
DP xi = PI/acos(Delta) - 1.0;
|
||||
// Factor of 2: return S(k, omega), not S(k, w)
|
||||
// 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^{+-}
|
||||
//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);
|
||||
// 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^{+-}
|
||||
DP expmtwoPIrhooverxi = exp(-twoPI * rho/xi);
|
||||
//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);
|
||||
return(w < wu && w > wl ? 2.0 * pow(1.0 + 1.0/xi, 2.0) * exp(-Itable.Return_val (rho))
|
||||
* expmtwoPIrhooverxi/(sqrt(wu * wu - w * w)
|
||||
* (0.5 * (1.0 + expmtwoPIrhooverxi * expmtwoPIrhooverxi) + expmtwoPIrhooverxi * cos(PI/xi)))
|
||||
|
@ -236,30 +235,6 @@ namespace ABACUS {
|
|||
|
||||
return(Szz_XXZ_h0_2spinons (Delta, args[0], args[1], Itable));
|
||||
|
||||
/*
|
||||
|
||||
// This uses args[0] = k, args[1] = w, args[2] = xi
|
||||
|
||||
DP Delta = cos(PI/(args[2] + 1.0));
|
||||
|
||||
DP vF = Fermi_velocity_XXZ_h0 (Delta); // in units of omega
|
||||
|
||||
//DP wu = twoPI * sin(0.5 * k);
|
||||
DP wu = 4.0 * vF * sin(0.5 * args[0]);
|
||||
//DP wl = PI * fabs(sin(k));
|
||||
DP wl = 2.0 * vF * fabs(sin(args[0]));
|
||||
|
||||
DP rho = acosh(sqrt((wu * wu - wl * wl)/(args[1] * args[1] - wl * wl)))/PI;
|
||||
DP expmtwoPIrhooverxi = exp(-twoPI * rho/args[2]);
|
||||
|
||||
// 0.5 factor: 1 from Bougourzi, and 1/2 is S^{zz} = 1/2 * S^{+-}
|
||||
return(args[1] < wu && args[1] > wl ?
|
||||
//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);
|
||||
pow(1.0 + 1.0/args[2], 2.0) * exp(-Itable.Return_val (rho)) * expmtwoPIrhooverxi
|
||||
/(sqrt(wu * wu - args[1] * args[1])
|
||||
* (0.5 * (1.0 + expmtwoPIrhooverxi * expmtwoPIrhooverxi) + expmtwoPIrhooverxi * cos(PI/args[2]))) : 0.0);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
DP Szz_XXZ_h0_2spinons_alt (Vect_DP args, Integral_table Itable)
|
||||
|
@ -283,30 +258,6 @@ namespace ABACUS {
|
|||
DP Jacobian = sqrt(omega * omega - omegalow * omegalow);
|
||||
|
||||
return(Jacobian * Szz_XXZ_h0_2spinons (Delta, args[0], omega, Itable));
|
||||
|
||||
/*
|
||||
//DP wu = twoPI * sin(0.5 * k);
|
||||
DP wu = 4.0 * vF * sin(0.5 * args[0]);
|
||||
//DP wl = PI * fabs(sin(k));
|
||||
DP wl = 2.0 * vF * fabs(sin(args[0]));
|
||||
|
||||
//DP w = wu * cos(args[1]);
|
||||
//DP factor = 1.0;
|
||||
DP w = wl * cosh(args[1]);
|
||||
|
||||
if (w >= wu || w <= wl) return(0.0);
|
||||
|
||||
DP factor = sqrt((w * w - wl * wl)/(wu * wu - w * w));
|
||||
|
||||
DP rho = acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI;
|
||||
DP expmtwoPIrhooverxi = exp(-twoPI * rho/args[2]);
|
||||
|
||||
// 0.5 factor: 1 from Bougourzi, and 1/2 is S^{zz} = 1/2 * S^{+-}
|
||||
//return(factor * 0.5 * exp(-Itable.Return_val (acosh(sqrt((wu * wu - wl * wl)/(w * w - wl * wl)))/PI)));
|
||||
return(pow(1.0 + 1.0/args[2], 2.0) * factor
|
||||
* exp(-Itable.Return_val (rho)) * expmtwoPIrhooverxi/(0.5 * (1.0 + expmtwoPIrhooverxi * expmtwoPIrhooverxi) + expmtwoPIrhooverxi * cos(PI/args[2])));
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
DP Szz_XXZ_h0_2spinons_omega (Vect_DP args, Integral_table Itable)
|
||||
|
@ -450,7 +401,8 @@ namespace ABACUS {
|
|||
args[0] = 0.0;
|
||||
args[1] = xi;
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
DP Integrand_2_fSR_XXZ_h0 (Vect_DP args)
|
||||
|
@ -474,8 +426,10 @@ namespace ABACUS {
|
|||
args[0] = 0.0;
|
||||
args[1] = xi;
|
||||
|
||||
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)
|
||||
+ 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);
|
||||
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)
|
||||
+ 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);
|
||||
|
||||
return (-2.0 * (1.0 - cos(k)) * Xavg);
|
||||
}
|
||||
|
@ -495,7 +449,9 @@ namespace ABACUS {
|
|||
args_to_SF_2p[2] = PI/acos(Delta) - 1.0;
|
||||
args_to_SF_2p[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
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 {
|
|||
args_to_SF_2p[2] = PI/acos(Delta) - 1.0;
|
||||
args_to_SF_2p[3] = ABACUS::max(1.0e-14, 0.01 * req_prec);
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -527,7 +485,8 @@ namespace ABACUS {
|
|||
|
||||
stringstream SF_stringstream;
|
||||
string SF_string;
|
||||
SF_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega << "_ommax_" << omegamax << ".dat";
|
||||
SF_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega
|
||||
<< "_ommax_" << omegamax << ".dat";
|
||||
SF_string = SF_stringstream.str();
|
||||
const char* SF_Cstr = SF_string.c_str();
|
||||
|
||||
|
@ -571,7 +530,8 @@ namespace ABACUS {
|
|||
|
||||
stringstream SRC_stringstream;
|
||||
string SRC_string;
|
||||
SRC_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega << "_ommax_" << omegamax << ".src";
|
||||
SRC_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega
|
||||
<< "_ommax_" << omegamax << ".src";
|
||||
SRC_string = SRC_stringstream.str();
|
||||
const char* SRC_Cstr = SRC_string.c_str();
|
||||
|
||||
|
@ -585,7 +545,8 @@ namespace ABACUS {
|
|||
|
||||
stringstream SR1_stringstream;
|
||||
string SR1_string;
|
||||
SR1_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega << "_ommax_" << omegamax << ".sr1";
|
||||
SR1_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_N_" << N << "_Nom_" << Nomega
|
||||
<< "_ommax_" << omegamax << ".sr1";
|
||||
SR1_string = SR1_stringstream.str();
|
||||
const char* SR1_Cstr = SR1_string.c_str();
|
||||
|
||||
|
@ -606,9 +567,7 @@ namespace ABACUS {
|
|||
|
||||
for (int iK = 1; iK < dim_K; ++iK)
|
||||
SR1_outfile << iK << "\t" << K[iK] << "\t" << sr1[iK] * omegamax/(twoPI * Nomega)
|
||||
//<< "\t" << -((1.0 - cos(K[iK])) * 2.0 * (0.25 - log(2.0))/3.0) << "\t"
|
||||
<< "\t" << (1.0 - cos(K[iK])) * sr1factor << "\t"
|
||||
//<< -sr1[iK] * omegamax/(twoPI * Nomega)/((1.0 - cos(K[iK])) * 2.0 * (0.25 - log(2.0))/3.0) << endl;
|
||||
<< sr1[iK] * omegamax/(twoPI * Nomega)/((1.0 - cos(K[iK])) * sr1factor) << endl;
|
||||
|
||||
SR1_outfile.close();
|
||||
|
@ -636,7 +595,9 @@ namespace ABACUS {
|
|||
DP omegaup = 2.0 * vF * sin(0.5 * K);
|
||||
DP omegalow = vF * fabs(sin(K));
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
DP* SF_XXZ_2p_dat = new DP[Nomega];
|
||||
|
||||
|
@ -658,41 +619,8 @@ namespace ABACUS {
|
|||
|
||||
SF_outfile.close();
|
||||
|
||||
// Do sum rule files:
|
||||
/*
|
||||
NOT ACCURATE SINCE WE'RE PLOTTING SOMEWHAT OUTSIDE OF CONTINUUM AS WELL (to get nice figures)
|
||||
stringstream SR1_stringstream;
|
||||
string SR1_string;
|
||||
SR1_stringstream << "Szz_XXZ_h0_2spinons_Delta_" << Delta << "_Kover2PI_" << Kover2PI
|
||||
<< "_Nom_" << Nomega << ".sr1";
|
||||
SR1_string = SR1_stringstream.str();
|
||||
const char* SR1_Cstr = SR1_string.c_str();
|
||||
|
||||
ofstream SR1_outfile;
|
||||
SR1_outfile.open(SR1_Cstr);
|
||||
SR1_outfile.precision(14);
|
||||
|
||||
// Figure out the f-sumrule factor:
|
||||
int Nfsr = 600;
|
||||
int Mfsr = 300;
|
||||
DP Xavg = 0.0;
|
||||
if (Delta > 0.0) Xavg = X_avg ('x', Delta, Nfsr, Mfsr);
|
||||
else Xavg = 0.0;
|
||||
|
||||
DP sr1factor = 1.0;
|
||||
if (Delta > 0.0) sr1factor = -2.0 * Xavg/Nfsr;
|
||||
else sr1factor = 1.0;
|
||||
|
||||
SR1_outfile << Kover2PI << "\t" << sr1 * (omegaup - omegalow)/(twoPI * Nomega)
|
||||
<< "\t" << (1.0 - cos(K)) * sr1factor << "\t"
|
||||
<< sr1 * (omegaup - omegalow)/(twoPI * Nomega)/((1.0 - cos(K)) * sr1factor) << endl;
|
||||
|
||||
SR1_outfile.close();
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace ABACUS
|
||||
|
|
|
@ -20,7 +20,8 @@ using namespace std;
|
|||
namespace ABACUS {
|
||||
|
||||
Young_Tableau::Young_Tableau () : Nrows(0), Ncols(0), Row_L(0), Col_L(0), id(0LL), maxid(0LL),
|
||||
map(new long long int [1]), map_computed(false), idnr_reached(0LL), nboxes_reached(-1),
|
||||
map(new long long int [1]), map_computed(false),
|
||||
idnr_reached(0LL), nboxes_reached(-1),
|
||||
dimchoose(0), choose_table(0LL)
|
||||
{}
|
||||
|
||||
|
@ -47,32 +48,11 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
// Fill map with zeros:
|
||||
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
|
||||
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
|
||||
map[i] = 0LL;
|
||||
|
||||
}
|
||||
/* SEGFAULTS
|
||||
Young_Tableau::Young_Tableau (int Nr, int Nc, long long int idnr)
|
||||
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(idnr),
|
||||
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
|
||||
map(new long long int [YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
|
||||
map_computed(false), idnr_reached(0LL), nboxes_reached(-1),
|
||||
dimchoose (ABACUS::min(Nr, Nc) + 1),
|
||||
choose_table(new long long int[(Nr + Nc + 1) * dimchoose])
|
||||
{
|
||||
// Constructs Young tableau of given idnr, if consistent with Nr, Nc.
|
||||
|
||||
// Construct the choose_table
|
||||
for (int cti = 0; cti < Nr + Nc + 1; ++cti)
|
||||
for (int ctj = 0; ctj < dimchoose; ++ctj) {
|
||||
if (cti >= ctj) choose_table[dimchoose * cti + ctj] = choose_lli(cti, ctj);
|
||||
else choose_table[dimchoose * cti + ctj] = 0LL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1; ++i) map[i] = 0LL;
|
||||
|
||||
(*this).Set_to_id(idnr);
|
||||
}
|
||||
*/
|
||||
Young_Tableau::Young_Tableau (const Young_Tableau& RefTableau) // copy constructor
|
||||
: Nrows(RefTableau.Nrows), Ncols(RefTableau.Ncols), Row_L(new int[RefTableau.Nrows]), Col_L(new int[RefTableau.Ncols]),
|
||||
id(RefTableau.id), maxid(RefTableau.maxid),
|
||||
|
@ -93,47 +73,11 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
// The map:
|
||||
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];
|
||||
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];
|
||||
|
||||
}
|
||||
/*
|
||||
Young_Tableau::Young_Tableau (int Nr, int Nc, long long int* ref_choose_table, int dimref)
|
||||
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
|
||||
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
|
||||
//choose_table(new long long int[(Nr + Nc + 1) * (Nr + Nc + 1)]),
|
||||
choose_table(new long long int[(Nr + Nc + 1) * (ABACUS::min(Nr, Nc) + 1)]),
|
||||
//map(new long long int[ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT)]),
|
||||
map(new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
|
||||
map_computed(false), idnr_reached(0LL), nboxes_reached(-1)
|
||||
|
||||
{
|
||||
// Constructs empty tableau of appropriate size
|
||||
|
||||
for (int i = 0; i < Nrows; ++i) Row_L[i] = 0;
|
||||
for (int i = 0; i < Ncols; ++i) Col_L[i] = 0;
|
||||
|
||||
// Construct the choose_table
|
||||
|
||||
// Copy entries from reference table
|
||||
for (int cti = 0; cti < ABACUS::min(Nr + Nc + 1, dimref); ++cti)
|
||||
for (int ctj = 0; ctj < ABACUS::min(Nr + Nc + 1, dimref); ++ctj)
|
||||
choose_table[(Nr + Nc + 1) * cti + ctj] = cti >= ctj ? ref_choose_table[dimref * cti + ctj] : 0LL;
|
||||
|
||||
// add missing parts if there are any
|
||||
if (dimref < Nr + Nc + 1) {
|
||||
for (int cti = 0; cti < Nr + Nc + 1; ++cti)
|
||||
for (int ctj = dimref; ctj < Nr + Nc + 1; ++ctj)
|
||||
choose_table[(Nr + Nc + 1) * cti + ctj] = 0LL;
|
||||
for (int cti = dimref; cti < Nr + Nc + 1; ++cti)
|
||||
for (int ctj = 0; ctj < Nr + Nc + 1; ++ctj)
|
||||
choose_table[(Nr + Nc + 1) * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
|
||||
}
|
||||
|
||||
// The map:
|
||||
//for (int i = 0; i < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT); ++i) map[i] = 0LL;
|
||||
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
|
||||
}
|
||||
*/
|
||||
Young_Tableau::Young_Tableau (int Nr, int Nc, const Young_Tableau& RefTableau)
|
||||
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
|
||||
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
|
||||
|
@ -163,7 +107,8 @@ namespace ABACUS {
|
|||
choose_table[dimchoose * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
|
||||
|
||||
// The map:
|
||||
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
|
||||
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
|
||||
map[i] = 0LL;
|
||||
}
|
||||
|
||||
Young_Tableau& Young_Tableau::operator= (const Young_Tableau& RefTableau)
|
||||
|
@ -190,7 +135,9 @@ namespace ABACUS {
|
|||
|
||||
if (map != 0LL) delete[] map;
|
||||
map = new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1];
|
||||
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];
|
||||
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];
|
||||
map_computed = RefTableau.map_computed;
|
||||
idnr_reached = RefTableau.idnr_reached;
|
||||
nboxes_reached = RefTableau.nboxes_reached;
|
||||
|
@ -263,7 +210,8 @@ namespace ABACUS {
|
|||
}
|
||||
|
||||
else if (nboxes_to_dist > Ncols * (Nrows - level)) {
|
||||
cout << Nrows << "\t" << Ncols << "\t" << level << "\t" << nboxes_to_dist << "\t" << idnr_reached << "\t" << nboxes_reached << endl;
|
||||
cout << Nrows << "\t" << Ncols << "\t" << level << "\t" << nboxes_to_dist << "\t"
|
||||
<< idnr_reached << "\t" << nboxes_reached << endl;
|
||||
ABACUSerror("nboxes_to_dist too high");
|
||||
}
|
||||
else if (nboxes_to_dist == 0) {
|
||||
|
@ -309,10 +257,11 @@ namespace ABACUS {
|
|||
+ ABACUS::min(highest_occupied_row, Ncols_Desc - j)];
|
||||
|
||||
Vect_INT Desc_Desc_Row_L(highest_occupied_row);
|
||||
for (int i = 0; i < highest_occupied_row; ++i) Desc_Desc_Row_L[i] = Desc_Row_L[i] - Desc_Row_L[highest_occupied_row];
|
||||
for (int i = 0; i < highest_occupied_row; ++i)
|
||||
Desc_Desc_Row_L[i] = Desc_Row_L[i] - Desc_Row_L[highest_occupied_row];
|
||||
|
||||
answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row, Ncols_Desc - Desc_Row_L[highest_occupied_row],
|
||||
RefTableau);
|
||||
answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row,
|
||||
Ncols_Desc - Desc_Row_L[highest_occupied_row], RefTableau);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +330,8 @@ namespace ABACUS {
|
|||
int highest_occupied_row = Nrows - 1;
|
||||
while (Row_L[highest_occupied_row] == 0) highest_occupied_row--; // index of highest occupied row;
|
||||
|
||||
for (int j = 0; j < Row_L[highest_occupied_row]; ++j) idnr += choose_table[dimchoose * (highest_occupied_row + Ncols - j)
|
||||
for (int j = 0; j < Row_L[highest_occupied_row]; ++j)
|
||||
idnr += choose_table[dimchoose * (highest_occupied_row + Ncols - j)
|
||||
+ ABACUS::min(highest_occupied_row, Ncols - j)];
|
||||
|
||||
Vect_INT Desc_Row_L(highest_occupied_row);
|
||||
|
@ -432,7 +382,8 @@ namespace ABACUS {
|
|||
|
||||
Compute_id (0); // sets the id according to rule 0
|
||||
Compute_Map (idnr); // make sure the state map is computed
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
else ABACUSerror("Wrong option for Tableau ids");
|
||||
|
@ -448,13 +399,15 @@ namespace ABACUS {
|
|||
return(*this);
|
||||
}
|
||||
|
||||
Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option) // sets the tableau to the one corresponding to idnr
|
||||
Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option)
|
||||
// sets the tableau to the one corresponding to idnr
|
||||
{
|
||||
|
||||
if (option == 0) {
|
||||
|
||||
if ((idnr < 0) || ((maxid < idnr) && (Nrows*Ncols != 0))) {
|
||||
cout << "Nrows = " << Nrows << "\tNcols = " << Ncols << "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
|
||||
cout << "Nrows = " << Nrows << "\tNcols = " << Ncols
|
||||
<< "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
|
||||
ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
|
||||
}
|
||||
id = idnr;
|
||||
|
@ -489,7 +442,8 @@ namespace ABACUS {
|
|||
|
||||
else if (option == 1) {
|
||||
|
||||
if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0))) ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
|
||||
if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0)))
|
||||
ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
|
||||
|
||||
if (Nrows*Ncols == 0 && idnr != 0LL) ABACUSerror("Trying nonzero id on empty Tableau.");
|
||||
|
||||
|
@ -508,7 +462,8 @@ namespace ABACUS {
|
|||
sum += choose_table[dimchoose * Nrows + ndiag] * choose_table[dimchoose * Ncols + ndiag];
|
||||
}
|
||||
|
||||
long long int residual_id = idnr - 1 - sum + choose_table[dimchoose * Nrows + ndiag] * choose_table[dimchoose * Ncols + ndiag];
|
||||
long long int residual_id = idnr - 1 - sum + choose_table[dimchoose * Nrows + ndiag]
|
||||
* choose_table[dimchoose * Ncols + ndiag];
|
||||
|
||||
if (ndiag == 0 && idnr != 0LL) ABACUSerror("Zero ndiag for nonzero idnr in Tableau.");
|
||||
|
||||
|
@ -561,9 +516,12 @@ namespace ABACUS {
|
|||
|
||||
Young_Tableau& Young_Tableau::Set_Row_L (Vect_INT& Row_Lengths) // set row lengths to elements of given vector
|
||||
{
|
||||
if (Row_Lengths.size() != Nrows) ABACUSerror("Vector of incompatible dimension used to initialize Young Tableau.");
|
||||
if (Row_Lengths.size() != Nrows)
|
||||
ABACUSerror("Vector of incompatible dimension used to initialize Young Tableau.");
|
||||
|
||||
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.");
|
||||
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.");
|
||||
|
||||
for (int i = 0; i < Nrows; ++i) Row_L[i] = Row_Lengths[i];
|
||||
(*this).Set_Col_L_given_Row_L();
|
||||
|
@ -663,8 +621,6 @@ namespace ABACUS {
|
|||
{
|
||||
// adds a box to the lowest nonzero length Row, recomputes id, returns true if tableau has changed
|
||||
|
||||
//cout << "Check before: "; (*this).Print();
|
||||
|
||||
if (id == 0LL || Nrows == 0 || Ncols == 0) return(false); // Tableau is empty
|
||||
|
||||
// otherwise find the lowest nonzero row:
|
||||
|
@ -674,13 +630,12 @@ namespace ABACUS {
|
|||
if (iln0r < 0) ABACUSerror("id wrongly set in Young_Tableau (Raise_Lowest_Nonzero_Row).");
|
||||
// This should not happen, since if iln0r == -1, id should be 0.
|
||||
|
||||
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 !
|
||||
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 !
|
||||
Row_L[iln0r] += 1;
|
||||
Set_Col_L_given_Row_L();
|
||||
Compute_id();
|
||||
|
||||
//cout << "Check after: iln0r = " << iln0r; (*this).Print();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -693,26 +648,18 @@ namespace ABACUS {
|
|||
|
||||
// Important: allow raising first row if tableau is empty.
|
||||
|
||||
//cout << "Check before: "; (*this).Print();
|
||||
|
||||
if (Ncols == 0 || Nrows == 0) return(false); // no space !
|
||||
|
||||
// Find index of lowest nonzero row: can be -1 if Tableau is empty
|
||||
int iln0r = Nrows - 1;
|
||||
while (Row_L[iln0r] == 0 && iln0r >= 0) iln0r--;
|
||||
|
||||
//cout << "iln0r = " << iln0r << "\t" << Row_L[iln0r] << "\t" << Row_L[iln0r + 1] << endl;
|
||||
|
||||
//if (iln0r == Nrows - 1) return(false); // no row under that one; allow raising of row 0
|
||||
|
||||
if (iln0r == -1 && Row_L[0] < Ncols || iln0r >= 0 && iln0r < Nrows - 1 && Row_L[iln0r] > Row_L[iln0r + 1]) {
|
||||
// there is space for at least one more box !
|
||||
Row_L[iln0r + 1] += 1;
|
||||
Set_Col_L_given_Row_L();
|
||||
Compute_id();
|
||||
|
||||
//cout << "Check after: iln0r = " << iln0r; (*this).Print();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -836,8 +783,6 @@ namespace ABACUS {
|
|||
// descendents considered here are thus those for which the raised
|
||||
// box is the highest still occupied box of the originally boosted state.
|
||||
|
||||
//cout << "Tableau in Desc_Boosted: " << (*this) << endl;
|
||||
|
||||
int ndesc = 0;
|
||||
|
||||
// Is tableau non-empty ?
|
||||
|
@ -860,19 +805,17 @@ namespace ABACUS {
|
|||
if (!fixed_Nboxes) {
|
||||
// The convention here is that we *remove* the highest yet unraised box only
|
||||
|
||||
//cout << "Removing box from " << (*this) << " with id " << (*this).id << endl;
|
||||
Young_Tableau descendent_attempt = (*this);
|
||||
if (descendent_attempt.Lower_Row(level_from)) ndesc = 1;
|
||||
//cout << "Obtained: " << descendent_attempt << " with id " << descendent_attempt.id << endl;
|
||||
|
||||
//if (ndesc > 0) {
|
||||
if (ndesc == 1) {
|
||||
Vect<Young_Tableau> Tableau_desc(ndesc);
|
||||
//if (ndesc == 1) Tableau_desc[0] = descendent_attempt;
|
||||
Tableau_desc[0] = descendent_attempt;
|
||||
return(Tableau_desc);
|
||||
}
|
||||
else if (ndesc != 0) ABACUSerror("There should be either 0 or 1 descendents in Descended_Boosted_State with fixed_iK == true.");
|
||||
else if (ndesc != 0)
|
||||
ABACUSerror("There should be either 0 or 1 descendents in Descended_Boosted_State with fixed_iK == true.");
|
||||
|
||||
} // if (!fixed_Nboxes)
|
||||
|
||||
|
@ -886,10 +829,12 @@ namespace ABACUS {
|
|||
Young_Tableau Tableau_ref = (*this);
|
||||
Young_Tableau Tableau_check1 = (*this);
|
||||
bool check1 = (Tableau_check1.Lower_Row(level_from) && Tableau_check1.Raise_Lowest_Nonzero_Row());
|
||||
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
|
||||
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
|
||||
Young_Tableau Tableau_check2 = (*this);
|
||||
bool check2 = (Tableau_check2.Lower_Row(level_from) && Tableau_check2.Raise_Next_to_Lowest_Nonzero_Row());
|
||||
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
|
||||
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
|
||||
|
||||
if (ndesc > 0) {
|
||||
Vect<Young_Tableau> Tableau_desc(ndesc);
|
||||
|
@ -908,8 +853,6 @@ namespace ABACUS {
|
|||
// tries to add Nboxes to Tableau, returns number of boxes added.
|
||||
if (Ncols == 0 || Nrows == 0) return(0); // can't do anything !
|
||||
|
||||
//cout << "Requesting Nboxes " << Nboxes << " in tableau." << endl;
|
||||
|
||||
int Nboxes_added = 0;
|
||||
int previous_Row_L = 0;
|
||||
for (int working_level = 0; working_level < Nrows; ++working_level) {
|
||||
|
|
Loading…
Reference in New Issue