Revisão | 7aafa752ada28b36f25c48c6f56e0df0946ce89e (tree) |
---|---|
Hora | 2012-11-09 15:34:28 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
hopping module for NASCO is implemented. #28791
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1113 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -82,23 +82,26 @@ void NASCO::DoNASCO(Molecule& molecule){ | ||
82 | 82 | boost::uniform_real<> range(0, 1); |
83 | 83 | boost::variate_generator<boost::mt19937&, boost::uniform_real<> > realRand( realGenerator, range ); |
84 | 84 | |
85 | - const int totalSteps = Parameters::GetInstance()->GetTotalStepsNASCO(); | |
86 | - const double dt = Parameters::GetInstance()->GetTimeWidthNASCO(); | |
87 | - const int numElecStatesNASCO = Parameters::GetInstance()->GetNumberElectronicStatesNASCO(); | |
88 | - int elecState = 0; //Parameters::GetInstance()->GetElectronicStateIndexNASCO(); | |
89 | - double time = 0.0; | |
90 | - bool requireGuess = false; | |
91 | - double** matrixForce = NULL; | |
92 | - double initialEnergy = 0.0; | |
85 | + const int totalSteps = Parameters::GetInstance()->GetTotalStepsNASCO(); | |
86 | + const double dt = Parameters::GetInstance()->GetTimeWidthNASCO(); | |
87 | + const int numElecStates = Parameters::GetInstance()->GetNumberElectronicStatesNASCO(); | |
88 | + int elecState = 0; | |
89 | + int nonAdiabaticPhaseIndex = 0; | |
90 | + double time = 0.0; | |
91 | + bool requireGuess = false; | |
92 | + double** matrixForce = NULL; | |
93 | + double initialEnergy = 0.0; | |
93 | 94 | |
94 | 95 | // initial calculation |
96 | + elecState = Parameters::GetInstance()->GetInitialElectronicStateNASCO(); | |
95 | 97 | currentES->DoSCF(); |
96 | 98 | currentES->DoCIS(); |
97 | 99 | matrixForce = currentES->GetForce(elecState); |
98 | 100 | |
99 | 101 | // output initial conditions |
100 | - this->OutputLog(this->messageinitialConditionNASCO); | |
101 | - initialEnergy = this->OutputEnergies(*currentES, molecule); | |
102 | + this->OutputLog(this->messageInitialConditionNASCO); | |
103 | + this->OutputLog(boost::format("%s%d\n\n") % this->messageElectronicState % elecState ); | |
104 | + initialEnergy = this->OutputEnergies(*currentES, molecule, elecState); | |
102 | 105 | this->OutputLog("\n"); |
103 | 106 | molecule.OutputConfiguration(); |
104 | 107 | molecule.OutputXyzCOM(); |
@@ -120,16 +123,7 @@ void NASCO::DoNASCO(Molecule& molecule){ | ||
120 | 123 | this->UpdateMomenta(molecule, matrixForce, dt); |
121 | 124 | |
122 | 125 | // update coordinates |
123 | - for(int a=0; a<molecule.GetNumberAtoms(); a++){ | |
124 | - Atom* atom = molecule.GetAtom(a); | |
125 | - Atom* tmpAtom = tmpMolecule.GetAtom(a); | |
126 | - double coreMass = tmpAtom->GetCoreMass(); | |
127 | - for(int i=0; i<CartesianType_end; i++){ | |
128 | - tmpAtom->GetXyz()[i] = atom->GetXyz()[i] + dt*atom->GetPxyz()[i]/coreMass; | |
129 | - } | |
130 | - } | |
131 | - tmpMolecule.CalcXyzCOM(); | |
132 | - tmpMolecule.CalcXyzCOC(); | |
126 | + this->UpdateCoordinates(tmpMolecule, molecule, dt); | |
133 | 127 | |
134 | 128 | // update electronic structure |
135 | 129 | requireGuess = (s==0); |
@@ -144,49 +138,13 @@ void NASCO::DoNASCO(Molecule& molecule){ | ||
144 | 138 | |
145 | 139 | // calculate overlaps |
146 | 140 | currentES->CalcOverlapAOsWithAnotherConfiguration(overlapAOs, tmpMolecule); |
147 | - cout << "overlapAOs" << endl; | |
148 | - for(int i=0; i<molecule.GetTotalNumberAOs(); i++){ | |
149 | - for(int j=0; j<molecule.GetTotalNumberAOs(); j++){ | |
150 | - printf("%e\t",overlapAOs[i][j]); | |
151 | - } | |
152 | - cout << endl; | |
153 | - } | |
154 | - cout << endl; | |
155 | - | |
156 | 141 | currentES->CalcOverlapMOsWithAnotherElectronicStructure(overlapMOs, overlapAOs, *tmpES); |
157 | - cout << "overlapMOs" << endl; | |
158 | - for(int i=0; i<molecule.GetTotalNumberAOs(); i++){ | |
159 | - for(int j=0; j<molecule.GetTotalNumberAOs(); j++){ | |
160 | - printf("%e\t",overlapMOs[i][j]); | |
161 | - } | |
162 | - cout << endl; | |
163 | - } | |
164 | - cout << endl; | |
165 | - | |
166 | 142 | currentES->CalcOverlapSingletSDsWithAnotherElectronicStructure(overlapSingletSDs, overlapMOs); |
167 | - int dimOverlapSingletSDs = Parameters::GetInstance()->GetActiveOccCIS() | |
168 | - *Parameters::GetInstance()->GetActiveOccCIS() | |
169 | - +1; | |
170 | - cout << "overlap singlet slater determinants" << endl; | |
171 | - for(int i=0; i<dimOverlapSingletSDs; i++){ | |
172 | - for(int j=0; j<dimOverlapSingletSDs; j++){ | |
173 | - printf("%e\t",overlapSingletSDs[i][j]); | |
174 | - } | |
175 | - cout << endl; | |
176 | - } | |
177 | - cout << endl; | |
178 | - | |
179 | 143 | currentES->CalcOverlapESsWithAnotherElectronicStructure(overlapESs, overlapSingletSDs, *tmpES); |
180 | - int dimOverlapESs = Parameters::GetInstance()->GetNumberElectronicStatesNASCO(); | |
181 | - cout << "overlapESs" << endl; | |
182 | - for(int i=0; i<dimOverlapESs; i++){ | |
183 | - for(int j=0; j<dimOverlapESs; j++){ | |
184 | - printf("%e\t",overlapESs[i][j]); | |
185 | - } | |
186 | - cout << endl; | |
187 | - } | |
188 | - cout << endl; | |
189 | - | |
144 | + | |
145 | + // decide next eigenstates | |
146 | + this->DecideNextElecState(&elecState, &nonAdiabaticPhaseIndex, numElecStates, overlapESs, &realRand); | |
147 | + | |
190 | 148 | // Synchronous molecular configuration and electronic states |
191 | 149 | this->SynchronousMolecularConfiguration(molecule, tmpMolecule); |
192 | 150 | swap(currentES, tmpES); |
@@ -194,7 +152,8 @@ void NASCO::DoNASCO(Molecule& molecule){ | ||
194 | 152 | tmpES->SetMolecule(&tmpMolecule); |
195 | 153 | |
196 | 154 | // output results |
197 | - this->OutputEnergies(*currentES, initialEnergy, molecule); | |
155 | + this->OutputLog(boost::format("%s%d\n\n") % this->messageElectronicState % elecState ); | |
156 | + this->OutputEnergies(*currentES, molecule, initialEnergy, elecState); | |
198 | 157 | molecule.OutputConfiguration(); |
199 | 158 | molecule.OutputXyzCOM(); |
200 | 159 | molecule.OutputXyzCOC(); |
@@ -212,7 +171,9 @@ void NASCO::DoNASCO(Molecule& molecule){ | ||
212 | 171 | this->OutputLog(this->messageEndNASCO); |
213 | 172 | } |
214 | 173 | |
215 | -void NASCO::UpdateMomenta(Molecule& molecule, double const* const* matrixForce, double dt) const{ | |
174 | +void NASCO::UpdateMomenta(Molecule& molecule, | |
175 | + double const* const* matrixForce, | |
176 | + const double dt) const{ | |
216 | 177 | for(int a=0; a<molecule.GetNumberAtoms(); a++){ |
217 | 178 | Atom* atom = molecule.GetAtom(a); |
218 | 179 | for(int i=0; i<CartesianType_end; i++){ |
@@ -221,6 +182,21 @@ void NASCO::UpdateMomenta(Molecule& molecule, double const* const* matrixForce, | ||
221 | 182 | } |
222 | 183 | } |
223 | 184 | |
185 | +void NASCO::UpdateCoordinates(Molecule& tmpMolecule, | |
186 | + const Molecule& molecule, | |
187 | + const double dt) const{ | |
188 | + for(int a=0; a<molecule.GetNumberAtoms(); a++){ | |
189 | + Atom* atom = molecule.GetAtom(a); | |
190 | + Atom* tmpAtom = tmpMolecule.GetAtom(a); | |
191 | + double coreMass = tmpAtom->GetCoreMass(); | |
192 | + for(int i=0; i<CartesianType_end; i++){ | |
193 | + tmpAtom->GetXyz()[i] = atom->GetXyz()[i] + dt*atom->GetPxyz()[i]/coreMass; | |
194 | + } | |
195 | + } | |
196 | + tmpMolecule.CalcXyzCOM(); | |
197 | + tmpMolecule.CalcXyzCOC(); | |
198 | +} | |
199 | + | |
224 | 200 | void NASCO::SynchronousMolecularConfiguration(Molecule& target, |
225 | 201 | const Molecule& refference) const{ |
226 | 202 | for(int a=0; a<target.GetNumberAtoms(); a++){ |
@@ -234,29 +210,58 @@ void NASCO::SynchronousMolecularConfiguration(Molecule& target, | ||
234 | 210 | target.CalcXyzCOM(); |
235 | 211 | } |
236 | 212 | |
213 | +void NASCO::DecideNextElecState(int* elecState, | |
214 | + int* nonAdiabaticPhaseIndex, | |
215 | + int numElecStates, | |
216 | + double const* const* overlapESs, | |
217 | + boost::random::variate_generator< | |
218 | + boost::random::mt19937&, | |
219 | + boost::uniform_real<> | |
220 | + > (*realRand)) const{ | |
221 | + double normalizedConstantHoppProbability=0.0; | |
222 | + for(int i=0; i<numElecStates; i++){ | |
223 | + normalizedConstantHoppProbability += fabs(overlapESs[i][*elecState]); | |
224 | + } | |
225 | + int hoppingDestinationState=0; | |
226 | + double hoppingProbability=0.0; | |
227 | + while(true){ | |
228 | + hoppingDestinationState = static_cast<int>(numElecStates*(*realRand)()); | |
229 | + hoppingProbability = fabs(overlapESs[hoppingDestinationState][*elecState]) | |
230 | + /normalizedConstantHoppProbability; | |
231 | + if((*realRand)() < hoppingProbability){ | |
232 | + if(overlapESs[hoppingDestinationState][*elecState]<0.0){ | |
233 | + *nonAdiabaticPhaseIndex += 1; | |
234 | + } | |
235 | + *elecState = hoppingDestinationState; | |
236 | + break; | |
237 | + } | |
238 | + } | |
239 | +} | |
240 | + | |
237 | 241 | void NASCO::SetMessages(){ |
238 | - this->errorMessageTheoryType = "\ttheory type = "; | |
239 | - this->errorMessageNotEnebleTheoryType | |
240 | - = "Error in nasco::NASCO::CheckEnableTheoryType: Non available theory is set.\n"; | |
241 | - this->messageStartNASCO = "********** START: Molecular dynamics **********\n"; | |
242 | - this->messageEndNASCO = "********** DONE: Molecular dynamics **********\n"; | |
243 | - this->messageinitialConditionNASCO = "\n\t========= Initial conditions \n"; | |
244 | - this->messageStartStepNASCO = "\n\t========== START: NASCO step "; | |
245 | - this->messageEndStepNASCO = "\t========== DONE: NASCO step "; | |
246 | - this->messageEnergies = "\tEnergies:\n"; | |
247 | - this->messageEnergiesTitle = "\t\t|\tkind\t\t\t| [a.u.] | [eV] | \n"; | |
248 | - this->messageCoreKineticEnergy = "Core kinetic: "; | |
249 | - this->messageCoreRepulsionEnergy = "Core repulsion: "; | |
250 | - this->messageVdWCorrectionEnergy = "VdW correction: "; | |
251 | - this->messageElectronicEnergy = "Electronic\n\t\t(inc. core rep.):"; | |
252 | - this->messageElectronicEnergyVdW = "Electronic\n\t\t(inc. core rep. and vdW):"; | |
253 | - this->messageTotalEnergy = "Total: "; | |
254 | - this->messageErrorEnergy = "Error: "; | |
255 | - this->messageTime = "\tTime in [fs]: "; | |
242 | + this->errorMessageTheoryType = "\ttheory type = "; | |
243 | + this->errorMessageNotEnebleTheoryType = "Error in nasco::NASCO::CheckEnableTheoryType: Non available theory is set.\n"; | |
244 | + this->messageStartNASCO = "********** START: NASCO **********\n"; | |
245 | + this->messageEndNASCO = "********** DONE: NASCO **********\n"; | |
246 | + this->messageInitialConditionNASCO = "\n\t========= Initial conditions \n"; | |
247 | + this->messageStartStepNASCO = "\n\t========== START: NASCO step "; | |
248 | + this->messageEndStepNASCO = "\t========== DONE: NASCO step "; | |
249 | + this->messageEnergies = "\tEnergies:\n"; | |
250 | + this->messageEnergiesTitle = "\t\t|\tkind\t\t\t| [a.u.] | [eV] | \n"; | |
251 | + this->messageCoreKineticEnergy = "Core kinetic: "; | |
252 | + this->messageCoreRepulsionEnergy = "Core repulsion: "; | |
253 | + this->messageVdWCorrectionEnergy = "VdW correction: "; | |
254 | + this->messageElectronicEnergy = "Electronic\n\t\t(inc. core rep.):"; | |
255 | + this->messageElectronicEnergyVdW = "Electronic\n\t\t(inc. core rep. and vdW):"; | |
256 | + this->messageTotalEnergy = "Total: "; | |
257 | + this->messageErrorEnergy = "Error: "; | |
258 | + this->messageElectronicState = "\tElectronic eigenstate: "; | |
259 | + this->messageTime = "\tTime in [fs]: "; | |
256 | 260 | } |
257 | 261 | |
258 | -double NASCO::OutputEnergies(const ElectronicStructure& electronicStructure, const Molecule& molecule){ | |
259 | - int elecState = 0; //Parameters::GetInstance()->GetElectronicStateIndexNASCO(); | |
262 | +double NASCO::OutputEnergies(const ElectronicStructure& electronicStructure, | |
263 | + const Molecule& molecule, | |
264 | + int elecState) const{ | |
260 | 265 | double eV2AU = Parameters::GetInstance()->GetEV2AU(); |
261 | 266 | double coreKineticEnergy = 0.0; |
262 | 267 | for(int a=0; a<molecule.GetNumberAtoms(); a++){ |
@@ -294,8 +299,11 @@ double NASCO::OutputEnergies(const ElectronicStructure& electronicStructure, con | ||
294 | 299 | return (coreKineticEnergy + electronicStructure.GetElectronicEnergy(elecState)); |
295 | 300 | } |
296 | 301 | |
297 | -void NASCO::OutputEnergies(const ElectronicStructure& electronicStructure, double initialEnergy, const Molecule& molecule){ | |
298 | - double energy = this->OutputEnergies(electronicStructure, molecule); | |
302 | +void NASCO::OutputEnergies(const ElectronicStructure& electronicStructure, | |
303 | + const Molecule& molecule, | |
304 | + const double initialEnergy, | |
305 | + int elecState) const{ | |
306 | + double energy = this->OutputEnergies(electronicStructure, molecule, elecState); | |
299 | 307 | double eV2AU = Parameters::GetInstance()->GetEV2AU(); |
300 | 308 | this->OutputLog(boost::format("\t\t%s\t%e\t%e\n\n") % this->messageErrorEnergy.c_str() |
301 | 309 | % (initialEnergy - energy) |
@@ -30,7 +30,7 @@ public: | ||
30 | 30 | ~NASCO(); |
31 | 31 | void DoNASCO(MolDS_base::Molecule& molecule); |
32 | 32 | private: |
33 | - std::string messageinitialConditionNASCO; | |
33 | + std::string messageInitialConditionNASCO; | |
34 | 34 | std::string messageStartNASCO; |
35 | 35 | std::string messageEndNASCO; |
36 | 36 | std::string messageStartStepNASCO; |
@@ -44,6 +44,7 @@ private: | ||
44 | 44 | std::string messageElectronicEnergyVdW; |
45 | 45 | std::string messageTotalEnergy; |
46 | 46 | std::string messageErrorEnergy; |
47 | + std::string messageElectronicState; | |
47 | 48 | std::string messageTime; |
48 | 49 | std::string errorMessageNotEnebleTheoryType; |
49 | 50 | std::string errorMessageTheoryType; |
@@ -51,11 +52,29 @@ private: | ||
51 | 52 | void CheckEnableTheoryType(MolDS_base::TheoryType theoryType); |
52 | 53 | void SetMessages(); |
53 | 54 | void SetEnableTheoryTypes(); |
54 | - void UpdateMomenta(MolDS_base::Molecule& molecule, double const* const* matrixForce, double dt) const; | |
55 | + void UpdateMomenta(MolDS_base::Molecule& molecule, | |
56 | + double const* const* matrixForce, | |
57 | + const double dt) const; | |
58 | + void UpdateCoordinates(MolDS_base::Molecule& tmpMolecule, | |
59 | + const MolDS_base::Molecule& molecule, | |
60 | + const double dt) const; | |
55 | 61 | void SynchronousMolecularConfiguration(MolDS_base::Molecule& target, |
56 | 62 | const MolDS_base::Molecule& refference) const; |
57 | - void OutputEnergies(const MolDS_base::ElectronicStructure& electronicStructure, double initialEnergy, const MolDS_base::Molecule& molecule); | |
58 | - double OutputEnergies(const MolDS_base::ElectronicStructure& electronicStructure, const MolDS_base::Molecule& molecule); | |
63 | + void DecideNextElecState(int* elecState, | |
64 | + int* nonAdiabaticPhaseIndex, | |
65 | + int numElecStates, | |
66 | + double const* const* overlapESs, | |
67 | + boost::random::variate_generator< | |
68 | + boost::random::mt19937&, | |
69 | + boost::uniform_real<> | |
70 | + > (*realRand)) const; | |
71 | + void OutputEnergies(const MolDS_base::ElectronicStructure& electronicStructure, | |
72 | + const MolDS_base::Molecule& molecule, | |
73 | + const double initialEnergy, | |
74 | + const int elecState) const; | |
75 | + double OutputEnergies(const MolDS_base::ElectronicStructure& electronicStructure, | |
76 | + const MolDS_base::Molecule& molecule, | |
77 | + const int elecState) const; | |
59 | 78 | void MallocOverlapsDifferentMolecules(double*** overlapAOs, |
60 | 79 | double*** overlapMOs, |
61 | 80 | double*** overlapSingleSDs, |