00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "QMCInput.h"
00014 #include <iomanip>
00015
00016 QMCInput::QMCInput()
00017 {
00018 }
00019
00020 void QMCInput::setMPIParameters(int my_rank, int nprocs)
00021 {
00022 flags.my_rank = my_rank;
00023 flags.nprocs = nprocs;
00024 }
00025
00026 void QMCInput::read(string inputfile)
00027 {
00028 flags.read_flags(inputfile);
00029
00030 Molecule.initialize(flags.Natoms, flags.psuedo_gridLevel);
00031 Molecule.readGeometry(inputfile);
00032 flags.use_psuedopotential = Molecule.readPsuedoPotential(inputfile);
00033
00034 BF.initialize(&flags, &Molecule);
00035 BF.read(inputfile);
00036
00037 WF.read(flags.charge, flags.Norbitals, flags.Nbasisfunc, flags.Ndeterminants,
00038 flags.trial_function_type, inputfile);
00039
00040 if(Molecule.getNuclearCharge() != WF.getNumberElectrons() + flags.charge)
00041 {
00042 clog << "Error: incorrect number of electrons." << endl;
00043 clog << " Nuclear charge = " << Molecule.getNuclearCharge() << endl;
00044 clog << " Number electrons = " << WF.getNumberElectrons() << endl;
00045 clog << " Electronic charge = " << flags.charge << endl;
00046 exit(0);
00047 }
00048
00049 JP.read(Molecule.NucleiTypes,flags.link_Jastrow_parameters,flags.replace_electron_nucleus_cusps,
00050 WF.getNumberElectrons(true),WF.getNumberElectrons(false),inputfile);
00051
00052 outputer = QMCConfigIO(WF.getNumberElectrons());
00053 }
00054
00055 void QMCInput::openConfigFile()
00056 {
00057 if(flags.print_configs == 1)
00058 outputer.open(flags.config_file_name,true);
00059 }
00060
00061 int QMCInput::getNumberAIParameters()
00062 {
00063 int numAI = 0;
00064 numAI += JP.getNumberJWParameters();
00065 numAI += WF.getNumberCIParameters();
00066 numAI += WF.getNumberORParameters();
00067 return numAI;
00068 }
00069
00070 Array1D<double> QMCInput::getAIParameters()
00071 {
00072 Array1D<double> params(getNumberAIParameters());
00073
00074 int shift = 0;
00075 JP.getJWParameters(params,shift);
00076
00077 shift += JP.getNumberJWParameters();
00078 WF.getCIParameters(params,shift);
00079
00080 shift += WF.getNumberCIParameters();
00081 WF.getORParameters(params,shift);
00082
00083 return params;
00084 }
00085
00086 void QMCInput::setAIParameters(Array1D<double> & params)
00087 {
00088 int shift = 0;
00089 JP.setJWParameters(params,shift);
00090
00091 shift += JP.getNumberJWParameters();
00092 WF.setCIParameters(params,shift);
00093
00094 shift += WF.getNumberCIParameters();
00095 WF.setORParameters(params,shift);
00096 }
00097
00098 void QMCInput::printArray(ostream & strm,
00099 string name, int num,
00100 Array1D<double> & array, int & start,
00101 int margin, int width, int prec, int numPerRow)
00102 {
00103 if(num <= 0) return;
00104
00105 strm << setw(margin) << name;
00106
00107 for(int ai=0; ai<num; ai++)
00108 {
00109 if(ai%numPerRow == 0 && ai != 0)
00110 strm << endl << setw(margin) << " ";
00111
00112 strm.width(width);
00113 strm.precision(prec);
00114 strm << array(ai + start);
00115 }
00116 strm << endl;
00117 start += num;
00118 }
00119
00120 void QMCInput::printAIParameters(ostream & strm,
00121 string name,
00122 int margin,
00123 Array1D<double> & array,
00124 bool forcePrintOrbitals)
00125 {
00126 if(array.dim1() <= 0) return;
00127
00128
00129
00130
00131
00132
00133
00134 int width = 20;
00135 int prec = 12;
00136 margin += 7;
00137
00138 int shift = 0;
00139 printArray(strm, name + " UD = ", JP.getNumberEupEdnParameters(),
00140 array, shift, margin, width, prec, 5);
00141 printArray(strm, name + " UU = ", JP.getNumberEupEupParameters(),
00142 array, shift, margin, width, prec, 5);
00143 printArray(strm, name + " DD = ", JP.getNumberEdnEdnParameters(),
00144 array, shift, margin, width, prec, 5);
00145
00146 printArray(strm, name + " NE = ", JP.getNumberNEParameters(),
00147 array, shift, margin, width, prec, 5);
00148
00149 printArray(strm, name + " NUD = ", JP.getNumberNEupEdnParameters(),
00150 array, shift, margin, width, prec, 5);
00151 printArray(strm, name + " NUU = ", JP.getNumberNEupEupParameters(),
00152 array, shift, margin, width, prec, 5);
00153 printArray(strm, name + " NDD = ", JP.getNumberNEdnEdnParameters(),
00154 array, shift, margin, width, prec, 5);
00155
00156 printArray(strm, name + " CI = ", WF.getNumberCIParameters(),
00157 array, shift, margin, width, prec, 5);
00158
00159 if(forcePrintOrbitals || WF.getNumberORParameters() < 25)
00160 printArray(strm, name + " OR = ", WF.getNumberORParameters(),
00161 array, shift, margin, width, prec, 5);
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 }
00191
00192 void QMCInput::printAISummary()
00193 {
00194 int width = 10;
00195 int numAI = globalInput.getNumberAIParameters();
00196
00197 clog << "There are currently " << numAI << " optimizable parameters:" << endl;
00198
00199 int num = globalInput.JP.getNumberEEParameters();
00200 if(num != 0) clog << setw(width) << num << " Electron-Electron Jastrow parameters" << endl;
00201
00202 num = globalInput.JP.getNumberNEParameters();
00203 if(num != 0) clog << setw(width) << num << " Nuclear-Electron Jastrow parameters" << endl;
00204
00205 num = globalInput.JP.getNumberNEupEdnParameters();
00206 if(num != 0) clog << setw(width) << num << " NEupEdn Jastrow parameters" << endl;
00207
00208 num = globalInput.JP.getNumberNEupEupParameters();
00209 if(num != 0) clog << setw(width) << num << " NEupEup Jastrow parameters" << endl;
00210
00211 num = globalInput.JP.getNumberNEdnEdnParameters();
00212 if(num != 0) clog << setw(width) << num << " NEdnEdn Jastrow parameters" << endl;
00213
00214 num = globalInput.WF.getNumberCIParameters();
00215 if(num != 0) clog << setw(width) << num << " CI parameters" << endl;
00216
00217 num = globalInput.WF.getNumberORParameters();
00218 if(num != 0) clog << setw(width) << num << " orbital parameters" << endl;
00219 }
00220
00221 ostream& operator<<(ostream & strm, QMCInput & Input)
00222 {
00223 strm << Input.flags;
00224 strm << Input.Molecule;
00225 strm << Input.BF;
00226 strm << Input.WF;
00227 strm << Input.JP << endl;
00228
00229 return strm;
00230 }