• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修订版5998581cb936ac699fdf1f9e987b8f72cdea22c6 (tree)
时间2011-01-05 18:59:57
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Inertia tensor is calculated.

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

更改概述

差异

--- a/doc/README.txt
+++ b/doc/README.txt
@@ -1,5 +1,30 @@
1-for 32 bit
1+
2+Compile:
3+ for 32 bit
24 $icc MolDS.cpp -lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
35
4-for 64 bit
6+ for 64 bit
57 $icc MolDS.cpp -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
8+
9+
10+Carring Out:
11+ $./a.out < input.in
12+
13+Principal Axes (Diagonalizing the inertia tensor):
14+ Write "principal-axes" in theory-directive.
15+
16+ E.g.
17+ THEORY
18+ principal-axes
19+ THEORY_END
20+
21+ -options
22+ option is "origin" only for setting the origin of the inertia tensor.
23+ options are written in inertia-directive in angstrom unit.
24+ Center of mass is used as origin when the "origin" is not set.
25+
26+ E.g.
27+ INERTIA
28+ origin 1.2 2.3 3.4
29+ INERTIA_END
30+
--- a/src/MolDS.cpp
+++ b/src/MolDS.cpp
@@ -108,6 +108,17 @@ int main(){
108108 delete zindoS;
109109 }
110110
111+ // Diagonalize Inertia Tensor
112+ else if(Parameters::GetInstance()->GetCurrentTheory() == PrincipalAxes && runingNormally){
113+ try{
114+ molecule->CalcPrincipalAxes();
115+ }
116+ catch(MolDSException ex){
117+ cout << ex.what() << endl;
118+ runingNormally = false;
119+ }
120+
121+ }
111122
112123 //Free
113124 LapackWrapper::DeleteInstance();
--- a/src/base/Enums.h
+++ b/src/base/Enums.h
@@ -11,6 +11,7 @@ RENUMSTR_BEGIN( TheoryType, TheoryTypeStr )
1111 RENUMSTR( CNDO2, "CNDO/2" )
1212 RENUMSTR( INDO, "INDO" )
1313 RENUMSTR( ZINDOS, "ZINDO/S" )
14+ RENUMSTR( PrincipalAxes, "Principal Axes" )
1415 RENUMSTR( NONE, "NONE" )
1516 RENUMSTR( TheoryType_end, "TheoryType_end" )
1617 RENUMSTR_END()
--- a/src/base/InputParser.h
+++ b/src/base/InputParser.h
@@ -43,11 +43,15 @@ private:
4343 string stringTheoryCNDO2;
4444 string stringTheoryINDO;
4545 string stringTheoryZINDOS;
46+ string stringTheoryPrincipalAxes;
4647 string stringTheoryNONE;
4748 string stringScf;
4849 string stringScfEnd;
4950 string stringScfMaxIter;
5051 string stringScfRmsDensity;
52+ string stringInertiaTensor;
53+ string stringInertiaTensorEnd;
54+ string stringInertiaTensorOrigin;
5155 void CalcMolecularBasics(Molecule* molecule);
5256 void OutputMolecularBasics(Molecule* molecule);
5357 void OutputScfConditions();
@@ -86,6 +90,10 @@ InputParser::InputParser(){
8690 this->stringTheoryCNDO2 = "cndo/2";
8791 this->stringTheoryINDO = "indo";
8892 this->stringTheoryZINDOS = "zindo/s";
93+ this->stringTheoryPrincipalAxes = "principal-axes";
94+ this->stringInertiaTensor = "inertia";
95+ this->stringInertiaTensorEnd = "inertia_end";
96+ this->stringInertiaTensorOrigin = "origin";
8997 this->stringTheoryNONE = "none";
9098 }
9199
@@ -159,9 +167,9 @@ void InputParser::Parse(Molecule* molecule){
159167 if(inputTerms[i].compare(this->stringGeometry) == 0){
160168 int j=i+1;
161169 while(inputTerms[j].compare(this->stringGeometryEnd) != 0){
162- double x = atof(inputTerms[j+1].c_str());
163- double y = atof(inputTerms[j+2].c_str());
164- double z = atof(inputTerms[j+3].c_str());
170+ double x = atof(inputTerms[j+1].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
171+ double y = atof(inputTerms[j+2].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
172+ double z = atof(inputTerms[j+3].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
165173 if(inputTerms[j] == "h"){
166174 molecule->GetAtomVect()->push_back(new Hatom(x, y, z));
167175 }
@@ -198,6 +206,23 @@ void InputParser::Parse(Molecule* molecule){
198206 i = j;
199207 }
200208
209+ // inertia tensor condition
210+ if(inputTerms[i].compare(this->stringInertiaTensor) == 0){
211+ int j=i+1;
212+ while(inputTerms[j].compare(this->stringInertiaTensorEnd) != 0){
213+ // origin
214+ if(inputTerms[j].compare(this->stringInertiaTensorOrigin) == 0){
215+ double x = atof(inputTerms[j+1].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
216+ double y = atof(inputTerms[j+2].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
217+ double z = atof(inputTerms[j+3].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
218+ molecule->SetInertiaTensorOrigin(x, y, z);
219+ j+=3;
220+ }
221+ j++;
222+ }
223+ i = j;
224+ }
225+
201226 // theory
202227 if(inputTerms[i].compare(this->stringTheory) == 0){
203228 int j=i+1;
@@ -218,10 +243,16 @@ void InputParser::Parse(Molecule* molecule){
218243 Parameters::GetInstance()->SetCurrentTheory(ZINDOS);
219244 }
220245
246+ // Princepal axes
247+ else if(inputTerms[j].compare(this->stringTheoryPrincipalAxes) == 0){
248+ Parameters::GetInstance()->SetCurrentTheory(PrincipalAxes);
249+ }
250+
221251 // NONE
222252 else if(inputTerms[j].compare(this->stringTheoryNONE) == 0){
223253 Parameters::GetInstance()->SetCurrentTheory(NONE);
224254 }
255+
225256 j++;
226257 }
227258 i = j;
@@ -300,6 +331,7 @@ bool InputParser::IsCommentOut(string tempStr){
300331
301332 }
302333
334+
303335 }
304336 #endif
305337
--- a/src/base/Molecule.h
+++ b/src/base/Molecule.h
@@ -16,9 +16,12 @@ class Molecule{
1616 private:
1717 vector<Atom*>* atomVect;
1818 double* COMXyz;
19+ double* inertiaTensorOrigin;
1920 bool wasCalculatedCOMXyz;
2021 int totalNumberAOs;
2122 int totalNumberValenceElectrons;
23+ void CalcInertiaTensor(double** inertiaTensor);
24+ void FreeInertiaTensorMoments(double** inertiaTensor, double* inertiaMoments);
2225 string messageTotalNumberAOs;
2326 string messageTotalNumberAtoms;
2427 string messageTotalNumberValenceElectrons;
@@ -41,11 +44,14 @@ public:
4144 void OutputCOMXyz();
4245 void OutputTotalNumberAtomsAOsValenceelectrons();
4346 void OutputConfiguration();
47+ void SetInertiaTensorOrigin(double x, double y, double z);
48+ void CalcPrincipalAxes();
4449 };
4550
4651 Molecule::Molecule(){
4752 this->atomVect = new vector<Atom*>;
4853 this->COMXyz = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(3);
54+ this->inertiaTensorOrigin = NULL;
4955 this->wasCalculatedCOMXyz = false;
5056 this->messageTotalNumberAOs = "\tTotal number of valence AOs: ";
5157 this->messageTotalNumberAtoms = "\tTotal number of atoms: ";
@@ -73,6 +79,11 @@ Molecule::~Molecule(){
7379 this->COMXyz = NULL;
7480 //cout << "COMXyz deleted\n";
7581 }
82+ if(this->inertiaTensorOrigin != NULL){
83+ MallocerFreer::GetInstance()->FreeDoubleMatrix1d(this->inertiaTensorOrigin);
84+ this->inertiaTensorOrigin = NULL;
85+ //cout << "inertiaTensorOrigin deleted\n";
86+ }
7687 }
7788
7889 vector<Atom*>* Molecule::GetAtomVect(){
@@ -175,6 +186,89 @@ void Molecule::OutputTotalNumberAtomsAOsValenceelectrons(){
175186 cout << this->messageTotalNumberValenceElectrons << this->totalNumberValenceElectrons << "\n\n";
176187 }
177188
189+void Molecule::SetInertiaTensorOrigin(double x, double y, double z){
190+ if(this->inertiaTensorOrigin == NULL){
191+ this->inertiaTensorOrigin = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(3);
192+ }
193+
194+ this->inertiaTensorOrigin[0] = x;
195+ this->inertiaTensorOrigin[1] = y;
196+ this->inertiaTensorOrigin[2] = z;
197+
198+}
199+
200+void Molecule::CalcPrincipalAxes(){
201+
202+ if(this->inertiaTensorOrigin == NULL){
203+ this->SetInertiaTensorOrigin(this->COMXyz[0], this->COMXyz[1], this->COMXyz[2]);
204+ }
205+
206+ double** inertiaTensor = MallocerFreer::GetInstance()->MallocDoubleMatrix2d(3, 3);
207+ double* inertiaMoments = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(3);
208+
209+ try{
210+ this->CalcInertiaTensor(inertiaTensor);
211+
212+ // ToDo: diagonalization!!!!!!
213+
214+ }
215+ catch(MolDSException ex){
216+ this->FreeInertiaTensorMoments(inertiaTensor, inertiaMoments);
217+ throw ex;
218+ }
219+
220+ this->FreeInertiaTensorMoments(inertiaTensor, inertiaMoments);
221+
222+}
223+
224+void Molecule::CalcInertiaTensor(double** inertiaTensor){
225+
226+ Atom* atom;
227+ double x;
228+ double y;
229+ double z;
230+ double atomicMass;
231+ for(int a=0; a<this->atomVect->size(); a++){
232+ atom = (*this->atomVect)[a];
233+ atomicMass = atom->GetAtomicMass();
234+ x = atom->GetXyz()[0] - this->inertiaTensorOrigin[0];
235+ y = atom->GetXyz()[1] - this->inertiaTensorOrigin[1];
236+ z = atom->GetXyz()[2] - this->inertiaTensorOrigin[2];
237+
238+ inertiaTensor[0][0] += atomicMass*(y*y + z*z);
239+ inertiaTensor[0][1] -= atomicMass*x*y;
240+ inertiaTensor[0][2] -= atomicMass*x*z;
241+
242+ inertiaTensor[1][0] -= atomicMass*y*x;
243+ inertiaTensor[1][1] += atomicMass*(x*x + z*z);
244+ inertiaTensor[1][2] -= atomicMass*y*z;
245+
246+ inertiaTensor[2][0] -= atomicMass*z*x;
247+ inertiaTensor[2][1] -= atomicMass*z*y;
248+ inertiaTensor[2][2] += atomicMass*(x*x + y*y);
249+
250+ }
251+
252+}
253+
254+void Molecule::FreeInertiaTensorMoments(double** inertiaTensor, double* inertiaMoments){
255+
256+ if(inertiaTensor != NULL){
257+ MallocerFreer::GetInstance()->FreeDoubleMatrix2d(inertiaTensor, 3);
258+ inertiaTensor = NULL;
259+ //cout << "inertiaTensor deleted\n";
260+ }
261+
262+ if(inertiaMoments != NULL){
263+ MallocerFreer::GetInstance()->FreeDoubleMatrix1d(inertiaMoments);
264+ inertiaMoments = NULL;
265+ //cout << "inertiaMoments deleted\n";
266+ }
267+
268+}
269+
270+
271+
178272 }
179273 #endif
180274
--- a/src/base/Parameters.h
+++ b/src/base/Parameters.h
@@ -24,6 +24,7 @@ private:
2424 double eV2AU;
2525 double angstrom2AU;
2626 double kayser2AU;
27+ double gMolin2AU;
2728 double bondingAdjustParameterK; //see (3.79) in J. A. Pople book
2829 TheoryType currentTheory;
2930
@@ -38,6 +39,7 @@ public:
3839 double GetEV2AU();
3940 double GetAngstrom2AU();
4041 double GetKayser2AU();
42+ double GetGMolin2AU();
4143 double GetBondingAdjustParameterK();
4244 TheoryType GetCurrentTheory();
4345 void SetCurrentTheory(TheoryType theory);
@@ -73,6 +75,7 @@ void Parameters::SetDefaultValues(){
7375 this->thresholdSCF = pow(10.0, -8.0);
7476 this->maxIterationsSCF = 100;
7577 this->currentTheory = CNDO2;
78+ this->gMolin2AU = pow(10.0,5.0)/(6.0221415*9.1095);
7679 }
7780
7881 double Parameters::GetThresholdSCF(){
@@ -103,6 +106,10 @@ double Parameters::GetKayser2AU(){
103106 return this->kayser2AU;
104107 }
105108
109+double Parameters::GetGMolin2AU(){
110+ return this->gMolin2AU;
111+}
112+
106113 double Parameters::GetBondingAdjustParameterK(){
107114 return this->bondingAdjustParameterK;
108115 }
--- a/src/base/atoms/Atom.h
+++ b/src/base/atoms/Atom.h
@@ -160,9 +160,9 @@ double* Atom::GetXyz(){
160160 }
161161
162162 void Atom::SetXyz(double x, double y, double z){
163- xyz[0]= x * Parameters::GetInstance()->GetAngstrom2AU();
164- xyz[1]= y * Parameters::GetInstance()->GetAngstrom2AU();
165- xyz[2]= z * Parameters::GetInstance()->GetAngstrom2AU();
163+ xyz[0]= x;
164+ xyz[1]= y;
165+ xyz[2]= z;
166166 }
167167
168168 vector<OrbitalType> Atom::GetValence(){
--- a/src/base/atoms/Catom.h
+++ b/src/base/atoms/Catom.h
@@ -16,7 +16,7 @@ public:
1616
1717 Catom::Catom(double x, double y, double z) : Atom(x, y, z){
1818 this->atomType = C;
19- this->atomicMass = 12.0107;
19+ this->atomicMass = 12.0107*Parameters::GetInstance()->GetGMolin2AU();
2020 this->valence.push_back(s);
2121 this->valence.push_back(py);
2222 this->valence.push_back(pz);
--- a/src/base/atoms/Hatom.h
+++ b/src/base/atoms/Hatom.h
@@ -17,7 +17,7 @@ public:
1717
1818 Hatom::Hatom(double x, double y, double z) : Atom(x, y, z){
1919 this->atomType = H;
20- this->atomicMass = 1.00794;
20+ this->atomicMass = 1.00794*Parameters::GetInstance()->GetGMolin2AU();
2121 this->valence.push_back(s);
2222 this->bondingParameter = -9.0*Parameters::GetInstance()->GetEV2AU();
2323 this->bondingParameterSZindo = -9.0*Parameters::GetInstance()->GetEV2AU();
--- a/src/base/atoms/Liatom.h
+++ b/src/base/atoms/Liatom.h
@@ -17,7 +17,7 @@ public:
1717
1818 Liatom::Liatom(double x, double y, double z) : Atom(x, y, z){
1919 this->atomType = Li;
20- this->atomicMass = 6.941;
20+ this->atomicMass = 6.941*Parameters::GetInstance()->GetGMolin2AU();
2121 this->valence.push_back(s);
2222 this->valence.push_back(py);
2323 this->valence.push_back(pz);
--- a/src/base/atoms/Satom.h
+++ b/src/base/atoms/Satom.h
@@ -16,7 +16,7 @@ public:
1616
1717 Satom::Satom(double x, double y, double z) : Atom(x, y, z){
1818 this->atomType = S;
19- this->atomicMass = 32.066;
19+ this->atomicMass = 32.066*Parameters::GetInstance()->GetGMolin2AU();
2020 this->valence.push_back(s);
2121 this->valence.push_back(py);
2222 this->valence.push_back(pz);
--- a/src/input.in
+++ b/src/input.in
@@ -7,9 +7,15 @@ THEORY
77 //cndo/2
88 //indo
99 //zindo/s
10- none
10+ //none
11+ principal-axes
1112 THEORY_END
1213
14+INERTIA
15+ origin 1.0 2.0 3.0
16+INERTIA_END
17+
18+
1319 //metane
1420 //GEOMETRY
1521 // C -0.37687006 0.95490165 0.00000000