Révision | a30645e9f3f3e568d518cc5d87980a1cf67ed3e9 (tree) |
---|---|
l'heure | 2011-01-06 10:39:30 |
Auteur | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Principal Axes is calculated.
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@35 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -6,6 +6,7 @@ | ||
6 | 6 | #include<iostream> |
7 | 7 | #include<vector> |
8 | 8 | #include"atoms/Atom.h" |
9 | +#include"../mkl_wrapper/LapackWrapper.h" | |
9 | 10 | |
10 | 11 | using namespace std; |
11 | 12 | using namespace MolDS_base_atoms; |
@@ -22,6 +23,8 @@ private: | ||
22 | 23 | int totalNumberValenceElectrons; |
23 | 24 | void CalcInertiaTensor(double** inertiaTensor); |
24 | 25 | void FreeInertiaTensorMoments(double** inertiaTensor, double* inertiaMoments); |
26 | + void OutputPrincipalAxes(double** inertiaTensor, double* inertiaMoments); | |
27 | + void OutputInertiaTensorOrigin(); | |
25 | 28 | string messageTotalNumberAOs; |
26 | 29 | string messageTotalNumberAtoms; |
27 | 30 | string messageTotalNumberValenceElectrons; |
@@ -31,6 +34,12 @@ private: | ||
31 | 34 | string messageCOM; |
32 | 35 | string messageCOMTitleAU; |
33 | 36 | string messageCOMTitleAng; |
37 | + string messagePrincipalAxes; | |
38 | + string messagePrincipalAxesTitleAU; | |
39 | + string messagePrincipalAxesTitleAng; | |
40 | + string messageInertiaTensorOrigin; | |
41 | + string messageInertiaTensorOriginTitleAU; | |
42 | + string messageInertiaTensorOriginTitleAng; | |
34 | 43 | public: |
35 | 44 | Molecule(); |
36 | 45 | ~Molecule(); |
@@ -62,6 +71,12 @@ Molecule::Molecule(){ | ||
62 | 71 | this->messageCOM = "\tCenter of Mass:\n"; |
63 | 72 | this->messageCOMTitleAU = "\t\t| x [a.u.] | y[a.u.] | z[a.u.] |\n"; |
64 | 73 | this->messageCOMTitleAng = "\t\t| x [angst.] | y[angst.] | z[angst.] |\n"; |
74 | + this->messagePrincipalAxes = "\tPrincipal Axes:\n"; | |
75 | + this->messagePrincipalAxesTitleAU = "\t\t| inertia moments [a.u.] | x [a.u.] | y[a.u.] | z[a.u.] | (normalized)\n"; | |
76 | + this->messagePrincipalAxesTitleAng = "\t\t| inertia moments [g*angust**2/mol] | x [angst.] | y[angst.] | z[angst.] | (not normalized)\n"; | |
77 | + this->messageInertiaTensorOrigin = "\tInertia Tensor Origin:\n"; | |
78 | + this->messageInertiaTensorOriginTitleAU = "\t\t| x [a.u.] | y[a.u.] | z[a.u.] |\n"; | |
79 | + this->messageInertiaTensorOriginTitleAng = "\t\t| x [angst.] | y[angst.] | z[angst.] |\n"; | |
65 | 80 | } |
66 | 81 | |
67 | 82 | Molecule::~Molecule(){ |
@@ -186,6 +201,49 @@ void Molecule::OutputTotalNumberAtomsAOsValenceelectrons(){ | ||
186 | 201 | cout << this->messageTotalNumberValenceElectrons << this->totalNumberValenceElectrons << "\n\n"; |
187 | 202 | } |
188 | 203 | |
204 | +void Molecule::OutputPrincipalAxes(double** inertiaTensor, double* inertiaMoments){ | |
205 | + double ang2AU = Parameters::GetInstance()->GetAngstrom2AU(); | |
206 | + double gMolin2AU = Parameters::GetInstance()->GetGMolin2AU(); | |
207 | + | |
208 | + cout << this->messagePrincipalAxes; | |
209 | + cout << this->messagePrincipalAxesTitleAng; | |
210 | + for(int i=0; i<3; i++){ | |
211 | + printf("\t\t%e\t%e\t%e\t%e\n",inertiaMoments[i]/gMolin2AU, | |
212 | + inertiaTensor[i][0]/ang2AU, | |
213 | + inertiaTensor[i][1]/ang2AU, | |
214 | + inertiaTensor[i][2]/ang2AU); | |
215 | + } | |
216 | + cout << "\n"; | |
217 | + | |
218 | + cout << this->messagePrincipalAxesTitleAU; | |
219 | + for(int i=0; i<3; i++){ | |
220 | + printf("\t\t%e\t%e\t%e\t%e\n",inertiaMoments[i], | |
221 | + inertiaTensor[i][0], | |
222 | + inertiaTensor[i][1], | |
223 | + inertiaTensor[i][2]); | |
224 | + } | |
225 | + cout << "\n"; | |
226 | + | |
227 | +} | |
228 | + | |
229 | +void Molecule::OutputInertiaTensorOrigin(){ | |
230 | + double ang2AU = Parameters::GetInstance()->GetAngstrom2AU(); | |
231 | + | |
232 | + cout << this->messageInertiaTensorOrigin; | |
233 | + cout << this->messageInertiaTensorOriginTitleAng; | |
234 | + printf("\t\t%e\t%e\t%e\n",this->inertiaTensorOrigin[0]/ang2AU, | |
235 | + this->inertiaTensorOrigin[1]/ang2AU, | |
236 | + this->inertiaTensorOrigin[2]/ang2AU); | |
237 | + cout << "\n"; | |
238 | + | |
239 | + cout << this->messageInertiaTensorOriginTitleAU; | |
240 | + printf("\t\t%e\t%e\t%e\n",this->inertiaTensorOrigin[0], | |
241 | + this->inertiaTensorOrigin[1], | |
242 | + this->inertiaTensorOrigin[2]); | |
243 | + cout << "\n"; | |
244 | + | |
245 | +} | |
246 | + | |
189 | 247 | void Molecule::SetInertiaTensorOrigin(double x, double y, double z){ |
190 | 248 | if(this->inertiaTensorOrigin == NULL){ |
191 | 249 | this->inertiaTensorOrigin = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(3); |
@@ -209,8 +267,13 @@ void Molecule::CalcPrincipalAxes(){ | ||
209 | 267 | try{ |
210 | 268 | this->CalcInertiaTensor(inertiaTensor); |
211 | 269 | |
212 | - // ToDo: diagonalization!!!!!! | |
213 | - | |
270 | + bool calcEigenVectors = true; | |
271 | + MolDS_mkl_wrapper::LapackWrapper::GetInstance()->Dsyevd(inertiaTensor, | |
272 | + inertiaMoments, | |
273 | + 3, | |
274 | + calcEigenVectors); | |
275 | + this->OutputPrincipalAxes(inertiaTensor, inertiaMoments); | |
276 | + this->OutputInertiaTensorOrigin(); | |
214 | 277 | } |
215 | 278 | catch(MolDSException ex){ |
216 | 279 | this->FreeInertiaTensorMoments(inertiaTensor, inertiaMoments); |
@@ -12,7 +12,7 @@ THEORY | ||
12 | 12 | THEORY_END |
13 | 13 | |
14 | 14 | INERTIA |
15 | - origin 1.0 2.0 3.0 | |
15 | + //origin 1.0 2.0 3.0 | |
16 | 16 | INERTIA_END |
17 | 17 | |
18 | 18 |