IM-SRG++  0
Parameters.hh
1 
2 #include <map>
3 #include <string>
4 #include <sstream>
5 
6 double r2p = 0.770; // effective proton intrinsic charge radius squared
7 double r2n = -0.1149; // effective neutron intrisic charge radius squared
8 double DF = 0.033; // Darwin-Foldy correction to the charge radius
9 
10 
13 {
14  public:
15  static map<string,string> string_par;
16  static map<string,double> double_par;
17  static map<string,int> int_par;
18  static map<string,vector<string>> vec_par;
19 
20  Parameters(){};
21  Parameters(int, char**);
22  void ParseCommandLineArgs(int, char**);
23  void PrintOptions();
24  string s(string);
25  double d(string);
26  int i(string);
27  vector<string> v(string);
28  string DefaultFlowFile();
29  string DefaultIntFile();
30  bool help_mode;
31 };
32 
33 map<string,string> Parameters::string_par = {
34  {"2bme", "/itch/exch/BlockGen/me2j/chi2b_srg0800_eMax12_lMax10_hwHO020.me2j.gz"},
35  {"3bme", "none"},
36  {"core_generator", "atan"}, // generator used for core part of 2-step decoupling
37  {"valence_generator", "shell-model-atan"}, // generator used for valence decoupling and 1-step (also single-ref)
38  {"flowfile", "default"}, // name of output flow file
39  {"intfile", "default"}, // name of output interaction fille
40  {"fmt2", "me2j"}, // can also be navratil or Navratil to read Petr's TBME format
41  {"reference", "default"}, // nucleus used for HF and normal ordering.
42  {"valence_space", ""}, // either valence space or nucleus for single reference
43  {"custom_valence_space", ""}, // if the provided valence spaces just aren't good enough for you
44  {"basis", "HF"}, // use HF basis or oscillator basis. HF is better.
45  {"method", "magnus"}, // can be magnus or flow or a few other things
46  {"denominator_delta_orbit", "none"}, // pick specific orbit to apply the delta
47  {"LECs", "EM2.0_2.0"}, // low energy constants for the interaction, only used with Johannes' hdf5 file format
48  {"scratch", ""}, // scratch directory for writing operators in binary format
49  {"use_brueckner_bch", "false"}, // switch to Brueckner version of BCH
50  {"valence_file_format", "nushellx"}, // file format for valence space interaction
51  {"occ_file", "none"}, // name of file containing orbit occupations
52 };
53 
54 
55 map<string,double> Parameters::double_par = {
56  {"hw", 20.0},
57  {"smax", 200.0}, // maximum s. If we reach this, terminate even if we're not converged.
58  {"dsmax", 0.5}, // maximum step size
59  {"ds_0", 0.5}, // initial step size
60  {"domega", 0.5}, // max for norm of eta * ds
61  {"omega_norm_max", 0.25}, // norm of omega before we do the splitting
62  {"ode_tolerance", 1e-6}, // error tolerance for the ode solver
63  {"denominator_delta", 0}, // offset added to the denominator in the generator
64  {"BetaCM",0}, // Prefactor for Lawson-Glockner term
65 
66 };
67 
68 map<string,int> Parameters::int_par = {
69  {"A", -1}, // Aeff for kinetic energy. -1 means take A of reference
70  {"e3max", 12},
71  {"emax", 6},
72  {"lmax3", -1}, // lmax for the 3body interaction
73  {"nsteps", -1}, // do the decoupling in 1 step or core-then-valence. -1 means default
74  {"file2e1max", 12},
75  {"file2e2max", 24},
76  {"file2lmax", 10},
77  {"file3e1max", 12},
78  {"file3e2max", 24},
79  {"file3e3max", 12},
80 };
81 
82 map<string,vector<string>> Parameters::vec_par = {
83  {"Operators", {} },
84  {"SPWF",{} }, // single-particle wave functions in HF basis
85 };
86 
87 
88 Parameters::Parameters(int argc, char** argv)
89 {
90  help_mode = false;
91  ParseCommandLineArgs(argc, argv);
92 }
93 
94 void Parameters::ParseCommandLineArgs(int argc, char** argv)
95 {
96  for (int iarg=1; iarg<argc; ++iarg)
97  {
98  string arg = argv[iarg];
99  if (arg=="help" or arg=="-help" or arg=="--help")
100  {
101  cout << "\nUsage:\n\timsrg++ option1=variable1 option2=variable2...\n" << endl;
102  cout << "At minimum, the 2bme file is required.\n" << endl;
103  PrintOptions();
104  help_mode = true;
105  return;
106  }
107  size_t pos = arg.find("=");
108  string var = arg.substr(0,pos);
109  string val = arg.substr(pos+1);
110  if (string_par.find(var) != string_par.end() )
111  {
112  if (val.size() > 0)
113  istringstream(val) >> string_par[var];
114  cout << var << " => " << string_par[var] << endl;
115  }
116  else if (double_par.find(var) != double_par.end() )
117  {
118  if (val.size() > 0)
119  istringstream(val) >> double_par[var];
120  cout << var << " => " << double_par[var] << endl;
121  }
122  else if (int_par.find(var) != int_par.end() )
123  {
124  if (val.size() > 0)
125  istringstream(val) >> int_par[var];
126  cout << var << " => " << int_par[var] << endl;
127  }
128  else if (vec_par.find(var) != vec_par.end() )
129  {
130  if (val.size() > 0)
131  {
132  istringstream ss(val);
133  string tmp;
134  while( getline(ss,tmp,',')) vec_par[var].push_back(tmp);
135  }
136  cout << var << " => ";
137  for (auto x : vec_par[var]) cout << x << ",";
138  cout << endl;
139  }
140  else
141  {
142  cout << "Unkown parameter: " << var << " => " << val << endl;
143  }
144 
145  }
146  if (string_par["flowfile"]=="default") string_par["flowfile"] = DefaultFlowFile();
147  if (string_par["intfile"]=="default") string_par["intfile"] = DefaultIntFile();
148 }
149 
150 string Parameters::s(string key)
151 {
152  return string_par[key];
153 }
154 double Parameters::d(string key)
155 {
156  return double_par[key];
157 }
158 int Parameters::i(string key)
159 {
160  return int_par[key];
161 }
162 vector<string> Parameters::v(string key)
163 {
164  return vec_par[key];
165 }
166 
167 string Parameters::DefaultFlowFile()
168 {
169  char strbuf[200];
170  sprintf(strbuf, "output/BCH_%s_%s_%s_hw%.0f_e%d_A%d.dat",string_par["method"].c_str(),string_par["reference"].c_str(),string_par["valence_space"].c_str(),double_par["hw"],int_par["emax"],int_par["A"]);
171  return string(strbuf);
172 }
173 
174 string Parameters::DefaultIntFile()
175 {
176  char strbuf[200];
177  sprintf(strbuf, "output/%s_%s_%s_hw%.0f_e%d_A%d",string_par["method"].c_str(),string_par["reference"].c_str(),string_par["valence_space"].c_str(),double_par["hw"],int_par["emax"],int_par["A"]);
178  return string(strbuf);
179 }
180 
181 void Parameters::PrintOptions()
182 {
183  cout << "Input parameters and default values: " << endl;
184  for (auto& strpar : string_par)
185  {
186  cout << "\t" << left << setw(30) << strpar.first << ": " << strpar.second << endl;
187  }
188  for (auto& doublepar : double_par)
189  {
190  cout << "\t" << left << setw(30) <<doublepar.first << ": " << doublepar.second << endl;
191  }
192  for (auto& intpar : int_par)
193  {
194  cout << "\t" << left << setw(30) <<intpar.first << ": " << intpar.second << endl;
195  }
196  for (auto& vecpar : vec_par)
197  {
198  cout << "\t" << left << setw(30) << vecpar.first << ": ";
199  for (auto& op : vecpar.second) cout << op << ",";
200  cout << endl;
201  }
202 
203 }
204 
205 
Definition: Parameters.hh:12