• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão7aafa752ada28b36f25c48c6f56e0df0946ce89e (tree)
Hora2012-11-09 15:34:28
AutorMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Mensagem de Log

hopping module for NASCO is implemented. #28791

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1113 1136aad2-a195-0410-b898-f5ea1d11b9d8

Mudança Sumário

Diff

--- a/src/nasco/NASCO.cpp
+++ b/src/nasco/NASCO.cpp
@@ -82,23 +82,26 @@ void NASCO::DoNASCO(Molecule& molecule){
8282 boost::uniform_real<> range(0, 1);
8383 boost::variate_generator<boost::mt19937&, boost::uniform_real<> > realRand( realGenerator, range );
8484
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;
9394
9495 // initial calculation
96+ elecState = Parameters::GetInstance()->GetInitialElectronicStateNASCO();
9597 currentES->DoSCF();
9698 currentES->DoCIS();
9799 matrixForce = currentES->GetForce(elecState);
98100
99101 // 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);
102105 this->OutputLog("\n");
103106 molecule.OutputConfiguration();
104107 molecule.OutputXyzCOM();
@@ -120,16 +123,7 @@ void NASCO::DoNASCO(Molecule& molecule){
120123 this->UpdateMomenta(molecule, matrixForce, dt);
121124
122125 // 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);
133127
134128 // update electronic structure
135129 requireGuess = (s==0);
@@ -144,49 +138,13 @@ void NASCO::DoNASCO(Molecule& molecule){
144138
145139 // calculate overlaps
146140 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-
156141 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-
166142 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-
179143 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+
190148 // Synchronous molecular configuration and electronic states
191149 this->SynchronousMolecularConfiguration(molecule, tmpMolecule);
192150 swap(currentES, tmpES);
@@ -194,7 +152,8 @@ void NASCO::DoNASCO(Molecule& molecule){
194152 tmpES->SetMolecule(&tmpMolecule);
195153
196154 // 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);
198157 molecule.OutputConfiguration();
199158 molecule.OutputXyzCOM();
200159 molecule.OutputXyzCOC();
@@ -212,7 +171,9 @@ void NASCO::DoNASCO(Molecule& molecule){
212171 this->OutputLog(this->messageEndNASCO);
213172 }
214173
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{
216177 for(int a=0; a<molecule.GetNumberAtoms(); a++){
217178 Atom* atom = molecule.GetAtom(a);
218179 for(int i=0; i<CartesianType_end; i++){
@@ -221,6 +182,21 @@ void NASCO::UpdateMomenta(Molecule& molecule, double const* const* matrixForce,
221182 }
222183 }
223184
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+
224200 void NASCO::SynchronousMolecularConfiguration(Molecule& target,
225201 const Molecule& refference) const{
226202 for(int a=0; a<target.GetNumberAtoms(); a++){
@@ -234,29 +210,58 @@ void NASCO::SynchronousMolecularConfiguration(Molecule& target,
234210 target.CalcXyzCOM();
235211 }
236212
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+
237241 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]: ";
256260 }
257261
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{
260265 double eV2AU = Parameters::GetInstance()->GetEV2AU();
261266 double coreKineticEnergy = 0.0;
262267 for(int a=0; a<molecule.GetNumberAtoms(); a++){
@@ -294,8 +299,11 @@ double NASCO::OutputEnergies(const ElectronicStructure& electronicStructure, con
294299 return (coreKineticEnergy + electronicStructure.GetElectronicEnergy(elecState));
295300 }
296301
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);
299307 double eV2AU = Parameters::GetInstance()->GetEV2AU();
300308 this->OutputLog(boost::format("\t\t%s\t%e\t%e\n\n") % this->messageErrorEnergy.c_str()
301309 % (initialEnergy - energy)
--- a/src/nasco/NASCO.h
+++ b/src/nasco/NASCO.h
@@ -30,7 +30,7 @@ public:
3030 ~NASCO();
3131 void DoNASCO(MolDS_base::Molecule& molecule);
3232 private:
33- std::string messageinitialConditionNASCO;
33+ std::string messageInitialConditionNASCO;
3434 std::string messageStartNASCO;
3535 std::string messageEndNASCO;
3636 std::string messageStartStepNASCO;
@@ -44,6 +44,7 @@ private:
4444 std::string messageElectronicEnergyVdW;
4545 std::string messageTotalEnergy;
4646 std::string messageErrorEnergy;
47+ std::string messageElectronicState;
4748 std::string messageTime;
4849 std::string errorMessageNotEnebleTheoryType;
4950 std::string errorMessageTheoryType;
@@ -51,11 +52,29 @@ private:
5152 void CheckEnableTheoryType(MolDS_base::TheoryType theoryType);
5253 void SetMessages();
5354 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;
5561 void SynchronousMolecularConfiguration(MolDS_base::Molecule& target,
5662 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;
5978 void MallocOverlapsDifferentMolecules(double*** overlapAOs,
6079 double*** overlapMOs,
6180 double*** overlapSingleSDs,