• 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

修订版a4c877c5b378cf4244531dffe42910db615ca627 (tree)
时间2011-01-06 20:30:44
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Logic for translating molecule is added.

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

更改概述

差异

--- a/doc/README.txt
+++ b/doc/README.txt
@@ -75,4 +75,23 @@ Rotate Molecule:
7575 ROTATE_END
7676
7777
78+Translate Molecule:
79+ Write "translate" in theory-directive.
80+
81+ E.g.
82+ THEORY
83+ translate
84+ THEORY_END
85+
86+ -options
87+ "difference" indicates difference for the translation in angstrom unit.
88+ This option is written in translate-directive.
89+ Default values are 0, 0, and 0.
90+
91+ E.g.
92+ TRANSLATE
93+ difference 12 30 45
94+ TRANSLATE_END
95+
96+
7897
--- a/src/MolDS.cpp
+++ b/src/MolDS.cpp
@@ -120,6 +120,18 @@ int main(){
120120
121121 }
122122
123+ // Translate molecule
124+ else if(Parameters::GetInstance()->GetCurrentTheory() == Translate && runingNormally){
125+ try{
126+ molecule->Translate();
127+ }
128+ catch(MolDSException ex){
129+ cout << ex.what() << endl;
130+ runingNormally = false;
131+ }
132+
133+ }
134+
123135 // Rotate molecule
124136 else if(Parameters::GetInstance()->GetCurrentTheory() == Rotate && runingNormally){
125137 try{
--- a/src/base/Enums.h
+++ b/src/base/Enums.h
@@ -12,6 +12,7 @@ RENUMSTR_BEGIN( TheoryType, TheoryTypeStr )
1212 RENUMSTR( INDO, "INDO" )
1313 RENUMSTR( ZINDOS, "ZINDO/S" )
1414 RENUMSTR( PrincipalAxes, "PrincipalAxes" )
15+ RENUMSTR( Translate, "Translate" )
1516 RENUMSTR( Rotate, "Rotate" )
1617 RENUMSTR( NONE, "NONE" )
1718 RENUMSTR( TheoryType_end, "TheoryType_end" )
--- a/src/base/InputParser.h
+++ b/src/base/InputParser.h
@@ -46,6 +46,7 @@ private:
4646 string stringTheoryINDO;
4747 string stringTheoryZINDOS;
4848 string stringTheoryPrincipalAxes;
49+ string stringTheoryTranslate;
4950 string stringTheoryRotate;
5051 string stringTheoryNONE;
5152 string stringGeometry;
@@ -66,6 +67,9 @@ private:
6667 string stringRotatingType;
6768 string stringRotatingTypeAxis;
6869 string stringRotatingTypeEularAngle;
70+ string stringTranslate;
71+ string stringTranslateEnd;
72+ string stringTranslatingDifference;
6973 void CalcMolecularBasics(Molecule* molecule);
7074 void OutputMolecularBasics(Molecule* molecule);
7175 void OutputScfConditions();
@@ -91,6 +95,7 @@ InputParser::InputParser(){
9195 this->stringTheoryINDO = "indo";
9296 this->stringTheoryZINDOS = "zindo/s";
9397 this->stringTheoryPrincipalAxes = "principal_axes";
98+ this->stringTheoryTranslate = "translate";
9499 this->stringTheoryRotate = "rotate";
95100 this->stringTheoryNONE = "none";
96101 this->stringGeometry = "geometry";
@@ -113,6 +118,9 @@ InputParser::InputParser(){
113118 this->stringRotatingType = "type";
114119 this->stringRotatingTypeAxis = "axis";
115120 this->stringRotatingTypeEularAngle = "eular_angle";
121+ this->stringTranslate = "translate";
122+ this->stringTranslateEnd = "translate_end";
123+ this->stringTranslatingDifference = "difference";
116124 }
117125
118126 InputParser::~InputParser(){
@@ -241,6 +249,23 @@ void InputParser::Parse(Molecule* molecule){
241249 i = j;
242250 }
243251
252+ // translating condition
253+ if(inputTerms[i].compare(this->stringTranslate) == 0){
254+ int j=i+1;
255+ while(inputTerms[j].compare(this->stringTranslateEnd) != 0){
256+ // origin
257+ if(inputTerms[j].compare(this->stringTranslatingDifference) == 0){
258+ double x = atof(inputTerms[j+1].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
259+ double y = atof(inputTerms[j+2].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
260+ double z = atof(inputTerms[j+3].c_str()) * Parameters::GetInstance()->GetAngstrom2AU();
261+ molecule->SetTranslatingDifference(x, y, z);
262+ j+=3;
263+ }
264+ j++;
265+ }
266+ i = j;
267+ }
268+
244269 // rotating condition
245270 if(inputTerms[i].compare(this->stringRotate) == 0){
246271 int j=i+1;
@@ -315,6 +340,11 @@ void InputParser::Parse(Molecule* molecule){
315340 Parameters::GetInstance()->SetCurrentTheory(PrincipalAxes);
316341 }
317342
343+ // Translate
344+ else if(inputTerms[j].compare(this->stringTheoryTranslate) == 0){
345+ Parameters::GetInstance()->SetCurrentTheory(Translate);
346+ }
347+
318348 // Rotate
319349 else if(inputTerms[j].compare(this->stringTheoryRotate) == 0){
320350 Parameters::GetInstance()->SetCurrentTheory(Rotate);
--- a/src/base/Molecule.h
+++ b/src/base/Molecule.h
@@ -35,6 +35,8 @@ public:
3535 void SetRotatingAngle(double angle);
3636 void SetRotatingEularAngles(double alpha, double beta, double gamma);
3737 void SetRotatingType(RotatingType rotatingType);
38+ void SetTranslatingDifference(double x, double y, double z);
39+ void Translate();
3840 private:
3941 vector<Atom*>* atomVect;
4042 double* COMXyz;
@@ -42,6 +44,7 @@ private:
4244 double* rotatingOrigin;
4345 double* rotatingAxis;
4446 double rotatingAngle;
47+ double* translatingDifference;
4548 EularAngle* rotatingEularAngles;
4649 RotatingType rotatingType;
4750 bool wasCalculatedCOMXyz;
@@ -52,6 +55,7 @@ private:
5255 void OutputPrincipalAxes(double** inertiaTensor, double* inertiaMoments);
5356 void OutputInertiaTensorOrigin();
5457 void OutputRotatingConditions();
58+ void OutputTranslatingConditions();
5559 string messageTotalNumberAOs;
5660 string messageTotalNumberAtoms;
5761 string messageTotalNumberValenceElectrons;
@@ -81,6 +85,11 @@ private:
8185 string messageRotatingType;
8286 string messageRotatingEularAngles;
8387 string messageRotatingEularAnglesTitle;
88+ string messageStartTranslate;
89+ string messageDoneTranslate;
90+ string messageTranslatingDifference;
91+ string messageTranslatingDifferenceTitleAU;
92+ string messageTranslatingDifferenceTitleAng;
8493 };
8594
8695 Molecule::Molecule(){
@@ -102,8 +111,8 @@ Molecule::Molecule(){
102111 this->messageCOM = "\tCenter of Mass:\n";
103112 this->messageCOMTitleAU = "\t\t| x [a.u.] | y[a.u.] | z[a.u.] |\n";
104113 this->messageCOMTitleAng = "\t\t| x [angst.] | y[angst.] | z[angst.] |\n";
105- this->messageStartPrincipalAxes = "********** START: Principal Axes Analysis **********\n";
106- this->messageDonePrincipalAxes = "********** DONE: Principal Axes Analysis ***********\n\n\n";
114+ this->messageStartPrincipalAxes = "********** START: Principal Axes of Inertia **********\n";
115+ this->messageDonePrincipalAxes = "********** DONE: Principal Axes of Inertia ***********\n\n\n";
107116 this->messagePrincipalAxes = "\tPrincipal Axes:\n";
108117 this->messagePrincipalAxesTitleAU = "\t\t| inertia moments [a.u.] | x [a.u.] | y[a.u.] | z[a.u.] | (normalized)\n";
109118 this->messagePrincipalAxesTitleAng = "\t\t| inertia moments [g*angust**2/mol] | x [angst.] | y[angst.] | z[angst.] | (not normalized)\n";
@@ -122,6 +131,11 @@ Molecule::Molecule(){
122131 this->messageRotatingType = "\tType: ";
123132 this->messageRotatingEularAngles = "\tEular Angles:\n";
124133 this->messageRotatingEularAnglesTitle = "\t\t| alpha[degree] | beta[degree] | gamma[degree] |\n";
134+ this->messageStartTranslate = "********** START: Translate molecule **********\n";
135+ this->messageDoneTranslate = "********** DONE: Translate molecule ***********\n\n\n";
136+ this->messageTranslatingDifference = "\tTranslating Difference:\n";
137+ this->messageTranslatingDifferenceTitleAU = "\t\t| x [a.u.] | y[a.u.] | z[a.u.] |\n";
138+ this->messageTranslatingDifferenceTitleAng = "\t\t| x [angst.] | y[angst.] | z[angst.] |\n";
125139 }
126140
127141 Molecule::~Molecule(){
@@ -159,6 +173,11 @@ Molecule::~Molecule(){
159173 this->rotatingEularAngles = NULL;
160174 //cout << "rotatingEularAngles deleted\n";
161175 }
176+ if(this->translatingDifference != NULL){
177+ MallocerFreer::GetInstance()->FreeDoubleMatrix1d(this->translatingDifference);
178+ this->translatingDifference = NULL;
179+ //cout << "translatingDifference deleted\n";
180+ }
162181 }
163182
164183 vector<Atom*>* Molecule::GetAtomVect(){
@@ -180,7 +199,7 @@ void Molecule::CalcCOMXyz(){
180199 double atomicMass;
181200
182201 for(int j=0; j<3; j++){
183- this->COMXyz[j] += 0.0;
202+ this->COMXyz[j] = 0.0;
184203 }
185204
186205 for(int i=0; i<this->atomVect->size(); i++){
@@ -514,6 +533,62 @@ void Molecule::OutputRotatingConditions(){
514533 this->rotatingEularAngles->GetGamma()/degree2Radian);
515534 }
516535
536+}
537+
538+void Molecule::SetTranslatingDifference(double x, double y, double z){
539+ if(this->translatingDifference == NULL){
540+ this->translatingDifference = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(3);
541+ }
542+
543+ this->translatingDifference[0] = x;
544+ this->translatingDifference[1] = y;
545+ this->translatingDifference[2] = z;
546+
547+}
548+
549+void Molecule::Translate(){
550+
551+ cout << this->messageStartTranslate;
552+
553+ if(this->translatingDifference == NULL){
554+ this->SetTranslatingDifference(0.0, 0.0, 0.0);
555+ }
556+
557+
558+ this->OutputTranslatingConditions();
559+
560+ Atom* atom;
561+ for(int i=0; i<this->atomVect->size(); i++){
562+ atom = (*this->atomVect)[i];
563+ atom->GetXyz()[0] += this->translatingDifference[0];
564+ atom->GetXyz()[1] += this->translatingDifference[1];
565+ atom->GetXyz()[2] += this->translatingDifference[2];
566+ }
567+
568+ this->wasCalculatedCOMXyz = false;
569+ this->CalcCOMXyz();
570+
571+ this->OutputConfiguration();
572+ this->OutputCOMXyz();
573+
574+ cout << this->messageDoneTranslate;
575+}
576+
577+void Molecule::OutputTranslatingConditions(){
578+
579+ double angst2AU = Parameters::GetInstance()->GetAngstrom2AU();
580+
581+ // rotating origin
582+ cout << this->messageTranslatingDifference;
583+ cout << this->messageTranslatingDifferenceTitleAng;
584+ printf("\t\t%e\t%e\t%e\n\n",this->translatingDifference[0]/angst2AU,
585+ this->translatingDifference[1]/angst2AU,
586+ this->translatingDifference[2]/angst2AU);
587+
588+ cout << this->messageTranslatingDifferenceTitleAU;
589+ printf("\t\t%e\t%e\t%e\n\n",this->translatingDifference[0],
590+ this->translatingDifference[1],
591+ this->translatingDifference[2]);
517592
518593 }
519594
--- a/src/input.in
+++ b/src/input.in
@@ -8,7 +8,8 @@ THEORY
88 //indo
99 //zindo/s
1010 //none
11- principal_axes
11+ //principal_axes
12+ translate
1213 //rotate
1314 THEORY_END
1415
@@ -17,14 +18,20 @@ INERTIA
1718 INERTIA_END
1819
1920 ROTATE
20- type axis
21+ //type axis
2122 //type eular_angle
22- origin 1.0 2.0 3.0
23- axis 3.0 4.0 5.0
24- angle 30
25- angles 15 25 35
23+ //origin 1.0 2.0 3.0
24+ //axis 3.0 4.0 5.0
25+ //angle 30
26+ //angles 15 25 35
2627 ROTATE_END
2728
29+TRANSLATE
30+ //difference 100.0 200.0 300.0
31+TRANSLATE_END
32+
33+
34+
2835 //metane
2936 //GEOMETRY
3037 // C -0.37687006 0.95490165 0.00000000