Revisión | 5fffb26b6616ac88b69ee5388ed07db66420f873 (tree) |
---|---|
Tiempo | 2013-05-23 19:23:28 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Cache of distance of each atom is implemented to be used. #31421
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1354 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -475,7 +475,8 @@ int InputParser::ParseMolecularGeometry(Molecule* molecule, vector<string>* inpu | ||
475 | 475 | else if((*inputTerms)[parseIndex] == "s"){ |
476 | 476 | atomType = S; |
477 | 477 | } |
478 | - Atom* atom = AtomFactory::Create(atomType, x, y, z); | |
478 | + int index = molecule->GetNumberAtoms(); | |
479 | + Atom* atom = AtomFactory::Create(atomType, index, x, y, z); | |
479 | 480 | molecule->AddAtom(atom); |
480 | 481 | parseIndex += 4; |
481 | 482 | } |
@@ -77,6 +77,7 @@ void Molecule::CopyInitialize(const Molecule& rhs){ | ||
77 | 77 | for(int i=0; i<rhs.atomVect->size(); i++){ |
78 | 78 | Atom* atom = (*rhs.atomVect)[i]; |
79 | 79 | this->atomVect->push_back(AtomFactory::Create(atom->GetAtomType(), |
80 | + atom->GetIndex(), | |
80 | 81 | atom->GetXyz()[XAxis], |
81 | 82 | atom->GetXyz()[YAxis], |
82 | 83 | atom->GetXyz()[ZAxis], |
@@ -252,13 +253,14 @@ void Molecule::CalcDistanceMatrix(){ | ||
252 | 253 | } |
253 | 254 | for(int a=0; a<this->atomVect->size(); a++){ |
254 | 255 | const Atom& atomA = *(*this->atomVect)[a]; |
255 | - for(int b=0; b<this->atomVect->size(); b++){ | |
256 | + for(int b=a; b<this->atomVect->size(); b++){ | |
256 | 257 | const Atom& atomB = *(*this->atomVect)[b]; |
257 | 258 | double distance=0.0; |
258 | 259 | distance = sqrt( pow(atomA.GetXyz()[0] - atomB.GetXyz()[0], 2.0) |
259 | 260 | +pow(atomA.GetXyz()[1] - atomB.GetXyz()[1], 2.0) |
260 | 261 | +pow(atomA.GetXyz()[2] - atomB.GetXyz()[2], 2.0) ); |
261 | 262 | this->distanceMatrix[a][b] = distance; |
263 | + this->distanceMatrix[b][a] = distance; | |
262 | 264 | } |
263 | 265 | } |
264 | 266 | } |
@@ -680,17 +682,11 @@ void Molecule::OutputTranslatingConditions(double const* translatingDifference) | ||
680 | 682 | } |
681 | 683 | |
682 | 684 | double Molecule::GetDistanceAtoms(int indexAtomA, int indexAtomB) const{ |
683 | - const Atom& atomA = *(*this->atomVect)[indexAtomA]; | |
684 | - const Atom& atomB = *(*this->atomVect)[indexAtomB]; | |
685 | - return this->GetDistanceAtoms(atomA, atomB); | |
685 | + return this->distanceMatrix[indexAtomA][indexAtomB]; | |
686 | 686 | } |
687 | 687 | |
688 | 688 | double Molecule::GetDistanceAtoms(const Atom& atomA, const Atom& atomB) const{ |
689 | - double distance=0.0; | |
690 | - distance = sqrt( pow(atomA.GetXyz()[0] - atomB.GetXyz()[0], 2.0) | |
691 | - +pow(atomA.GetXyz()[1] - atomB.GetXyz()[1], 2.0) | |
692 | - +pow(atomA.GetXyz()[2] - atomB.GetXyz()[2], 2.0) ); | |
693 | - return distance; | |
689 | + return this->GetDistanceAtoms(atomA.GetIndex(), atomB.GetIndex()); | |
694 | 690 | } |
695 | 691 | |
696 | 692 | void Molecule::SynchronizeConfigurationTo(const Molecule& ref){ |
@@ -38,7 +38,7 @@ using namespace std; | ||
38 | 38 | using namespace MolDS_base; |
39 | 39 | |
40 | 40 | namespace MolDS_base_atoms{ |
41 | -Atom::Atom(){ | |
41 | +Atom::Atom(int index){ | |
42 | 42 | this->SetMessages(); |
43 | 43 | this->xyz = NULL; |
44 | 44 | this->pxyz = NULL; |
@@ -51,6 +51,7 @@ Atom::Atom(){ | ||
51 | 51 | MallocerFreer::GetInstance()->Free<double>(&this->pxyz, CartesianType_end); |
52 | 52 | throw MolDSException(ex.what()); |
53 | 53 | } |
54 | + this->index = index; | |
54 | 55 | } |
55 | 56 | |
56 | 57 | Atom::~Atom(){ |
@@ -22,8 +22,9 @@ namespace MolDS_base_atoms{ | ||
22 | 22 | |
23 | 23 | class Atom : public MolDS_base::PrintController{ |
24 | 24 | public: |
25 | - Atom(); | |
25 | + Atom(int index); | |
26 | 26 | virtual ~Atom(); |
27 | + inline int GetIndex() const{return this->index;} | |
27 | 28 | double* GetXyz() const; |
28 | 29 | void SetXyz(double x, double y, double z) const; |
29 | 30 | double* GetPxyz() const; |
@@ -224,6 +225,7 @@ protected: | ||
224 | 225 | double pm3DBondingParameterP; // Table II in ref. [MH_2007] for H, C, N, O, and Table IV in re. [MMHBV_2007] for S. |
225 | 226 | double pm3DAlpha; // Table II in ref. [MH_2007] for H, C, N, O, and Table IV in re. [MMHBV_2007] for S. |
226 | 227 | private: |
228 | + Atom(); | |
227 | 229 | std::string errorMessageIonPot; |
228 | 230 | std::string errorMessageAtomType; |
229 | 231 | std::string errorMessageNumberValences; |
@@ -276,6 +278,7 @@ private: | ||
276 | 278 | std::string errorMessageSetXyzCoordinatesNull; |
277 | 279 | std::string errorMessageGetPxyzMomentaNull; |
278 | 280 | std::string errorMessageSetPxyzMomentaNull; |
281 | + int index; | |
279 | 282 | void SetMessages(); |
280 | 283 | double GetRealAngularPartAO(double theta, |
281 | 284 | double phi, |
@@ -33,7 +33,7 @@ | ||
33 | 33 | using namespace std; |
34 | 34 | using namespace MolDS_base; |
35 | 35 | namespace MolDS_base_atoms{ |
36 | -Catom::Catom() : Atom(){ | |
36 | +Catom::Catom(int index) : Atom(index){ | |
37 | 37 | this->SetAtomicParameters(); |
38 | 38 | } |
39 | 39 |
@@ -21,8 +21,9 @@ | ||
21 | 21 | namespace MolDS_base_atoms{ |
22 | 22 | class Catom : public Atom { |
23 | 23 | public: |
24 | - Catom(); | |
24 | + Catom(int index); | |
25 | 25 | private: |
26 | + Catom(); | |
26 | 27 | void SetAtomicParameters(); |
27 | 28 | }; |
28 | 29 | } |
@@ -35,7 +35,7 @@ using namespace MolDS_base; | ||
35 | 35 | |
36 | 36 | namespace MolDS_base_atoms{ |
37 | 37 | |
38 | -Hatom::Hatom() : Atom(){ | |
38 | +Hatom::Hatom(int index) : Atom(index){ | |
39 | 39 | this->SetAtomicParameters(); |
40 | 40 | } |
41 | 41 |
@@ -22,8 +22,9 @@ namespace MolDS_base_atoms{ | ||
22 | 22 | |
23 | 23 | class Hatom : public Atom { |
24 | 24 | public: |
25 | - Hatom(); | |
25 | + Hatom(int index); | |
26 | 26 | private: |
27 | + Hatom(); | |
27 | 28 | void SetAtomicParameters(); |
28 | 29 | }; |
29 | 30 |
@@ -34,7 +34,7 @@ using namespace std; | ||
34 | 34 | using namespace MolDS_base; |
35 | 35 | |
36 | 36 | namespace MolDS_base_atoms{ |
37 | -Liatom::Liatom() : Atom(){ | |
37 | +Liatom::Liatom(int index) : Atom(index){ | |
38 | 38 | this->SetAtomicParameters(); |
39 | 39 | } |
40 | 40 |
@@ -21,8 +21,9 @@ | ||
21 | 21 | namespace MolDS_base_atoms{ |
22 | 22 | class Liatom : public Atom { |
23 | 23 | public: |
24 | - Liatom(); | |
24 | + Liatom(int index); | |
25 | 25 | private: |
26 | + Liatom(); | |
26 | 27 | void SetAtomicParameters(); |
27 | 28 | }; |
28 | 29 | } |
@@ -33,7 +33,7 @@ | ||
33 | 33 | using namespace std; |
34 | 34 | using namespace MolDS_base; |
35 | 35 | namespace MolDS_base_atoms{ |
36 | -Natom::Natom() : Atom(){ | |
36 | +Natom::Natom(int index) : Atom(index){ | |
37 | 37 | this->SetAtomicParameters(); |
38 | 38 | } |
39 | 39 |
@@ -21,8 +21,9 @@ | ||
21 | 21 | namespace MolDS_base_atoms{ |
22 | 22 | class Natom : public Atom { |
23 | 23 | public: |
24 | - Natom(); | |
24 | + Natom(int index); | |
25 | 25 | private: |
26 | + Natom(); | |
26 | 27 | void SetAtomicParameters(); |
27 | 28 | }; |
28 | 29 | } |
@@ -33,7 +33,7 @@ | ||
33 | 33 | using namespace std; |
34 | 34 | using namespace MolDS_base; |
35 | 35 | namespace MolDS_base_atoms{ |
36 | -Oatom::Oatom() : Atom(){ | |
36 | +Oatom::Oatom(int index) : Atom(index){ | |
37 | 37 | this->SetAtomicParameters(); |
38 | 38 | } |
39 | 39 |
@@ -21,8 +21,9 @@ | ||
21 | 21 | namespace MolDS_base_atoms{ |
22 | 22 | class Oatom : public Atom { |
23 | 23 | public: |
24 | - Oatom(); | |
24 | + Oatom(int index); | |
25 | 25 | private: |
26 | + Oatom(); | |
26 | 27 | void SetAtomicParameters(); |
27 | 28 | }; |
28 | 29 | } |
@@ -33,7 +33,7 @@ | ||
33 | 33 | using namespace std; |
34 | 34 | using namespace MolDS_base; |
35 | 35 | namespace MolDS_base_atoms{ |
36 | -Satom::Satom() : Atom(){ | |
36 | +Satom::Satom(int index) : Atom(index){ | |
37 | 37 | this->SetAtomicParameters(); |
38 | 38 | } |
39 | 39 |
@@ -21,8 +21,9 @@ | ||
21 | 21 | namespace MolDS_base_atoms{ |
22 | 22 | class Satom : public Atom { |
23 | 23 | public: |
24 | - Satom(); | |
24 | + Satom(int index); | |
25 | 25 | private: |
26 | + Satom(); | |
26 | 27 | void SetAtomicParameters(); |
27 | 28 | }; |
28 | 29 | } |
@@ -43,25 +43,25 @@ namespace MolDS_base_factories{ | ||
43 | 43 | string AtomFactory::errorMessageNotEnableAtom = "Error in base::AtomFactory::Create: Not Enable AtomType is set."; |
44 | 44 | string AtomFactory::errorMessageAtomType = "\tatom type = "; |
45 | 45 | |
46 | -Atom* AtomFactory::Create(AtomType atomType, double x, double y, double z, double px, double py, double pz){ | |
46 | +Atom* AtomFactory::Create(AtomType atomType, int index, double x, double y, double z, double px, double py, double pz){ | |
47 | 47 | Atom* atom=NULL; |
48 | 48 | if(atomType == H){ |
49 | - atom = new Hatom(); | |
49 | + atom = new Hatom(index); | |
50 | 50 | } |
51 | 51 | else if(atomType == Li){ |
52 | - atom = new Liatom(); | |
52 | + atom = new Liatom(index); | |
53 | 53 | } |
54 | 54 | else if(atomType == C){ |
55 | - atom = new Catom(); | |
55 | + atom = new Catom(index); | |
56 | 56 | } |
57 | 57 | else if(atomType == N){ |
58 | - atom = new Natom(); | |
58 | + atom = new Natom(index); | |
59 | 59 | } |
60 | 60 | else if(atomType == O){ |
61 | - atom = new Oatom(); | |
61 | + atom = new Oatom(index); | |
62 | 62 | } |
63 | 63 | else if(atomType == S){ |
64 | - atom = new Satom(); | |
64 | + atom = new Satom(index); | |
65 | 65 | } |
66 | 66 | else{ |
67 | 67 | stringstream ss; |
@@ -74,11 +74,11 @@ Atom* AtomFactory::Create(AtomType atomType, double x, double y, double z, doubl | ||
74 | 74 | return atom; |
75 | 75 | } |
76 | 76 | |
77 | -Atom* AtomFactory::Create(AtomType atomType, double x, double y, double z){ | |
77 | +Atom* AtomFactory::Create(AtomType atomType, int index, double x, double y, double z){ | |
78 | 78 | double px=0.0; |
79 | 79 | double py=0.0; |
80 | 80 | double pz=0.0; |
81 | - return AtomFactory::Create(atomType, x, y, z, px, py, pz); | |
81 | + return AtomFactory::Create(atomType, index, x, y, z, px, py, pz); | |
82 | 82 | } |
83 | 83 | } |
84 | 84 |
@@ -24,6 +24,7 @@ namespace MolDS_base_factories{ | ||
24 | 24 | class AtomFactory{ |
25 | 25 | public: |
26 | 26 | static MolDS_base_atoms::Atom* Create(MolDS_base::AtomType atomType, |
27 | + int index, | |
27 | 28 | double x, |
28 | 29 | double y, |
29 | 30 | double z, |
@@ -31,6 +32,7 @@ public: | ||
31 | 32 | double py, |
32 | 33 | double pz); |
33 | 34 | static MolDS_base_atoms::Atom* Create(MolDS_base::AtomType atomType, |
35 | + int index, | |
34 | 36 | double x, |
35 | 37 | double y, |
36 | 38 | double z); |