• 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

Revisión5fffb26b6616ac88b69ee5388ed07db66420f873 (tree)
Tiempo2013-05-23 19:23:28
AutorMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

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

Cambiar Resumen

Diferencia incremental

--- a/src/base/InputParser.cpp
+++ b/src/base/InputParser.cpp
@@ -475,7 +475,8 @@ int InputParser::ParseMolecularGeometry(Molecule* molecule, vector<string>* inpu
475475 else if((*inputTerms)[parseIndex] == "s"){
476476 atomType = S;
477477 }
478- Atom* atom = AtomFactory::Create(atomType, x, y, z);
478+ int index = molecule->GetNumberAtoms();
479+ Atom* atom = AtomFactory::Create(atomType, index, x, y, z);
479480 molecule->AddAtom(atom);
480481 parseIndex += 4;
481482 }
--- a/src/base/Molecule.cpp
+++ b/src/base/Molecule.cpp
@@ -77,6 +77,7 @@ void Molecule::CopyInitialize(const Molecule& rhs){
7777 for(int i=0; i<rhs.atomVect->size(); i++){
7878 Atom* atom = (*rhs.atomVect)[i];
7979 this->atomVect->push_back(AtomFactory::Create(atom->GetAtomType(),
80+ atom->GetIndex(),
8081 atom->GetXyz()[XAxis],
8182 atom->GetXyz()[YAxis],
8283 atom->GetXyz()[ZAxis],
@@ -252,13 +253,14 @@ void Molecule::CalcDistanceMatrix(){
252253 }
253254 for(int a=0; a<this->atomVect->size(); a++){
254255 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++){
256257 const Atom& atomB = *(*this->atomVect)[b];
257258 double distance=0.0;
258259 distance = sqrt( pow(atomA.GetXyz()[0] - atomB.GetXyz()[0], 2.0)
259260 +pow(atomA.GetXyz()[1] - atomB.GetXyz()[1], 2.0)
260261 +pow(atomA.GetXyz()[2] - atomB.GetXyz()[2], 2.0) );
261262 this->distanceMatrix[a][b] = distance;
263+ this->distanceMatrix[b][a] = distance;
262264 }
263265 }
264266 }
@@ -680,17 +682,11 @@ void Molecule::OutputTranslatingConditions(double const* translatingDifference)
680682 }
681683
682684 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];
686686 }
687687
688688 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());
694690 }
695691
696692 void Molecule::SynchronizeConfigurationTo(const Molecule& ref){
--- a/src/base/atoms/Atom.cpp
+++ b/src/base/atoms/Atom.cpp
@@ -38,7 +38,7 @@ using namespace std;
3838 using namespace MolDS_base;
3939
4040 namespace MolDS_base_atoms{
41-Atom::Atom(){
41+Atom::Atom(int index){
4242 this->SetMessages();
4343 this->xyz = NULL;
4444 this->pxyz = NULL;
@@ -51,6 +51,7 @@ Atom::Atom(){
5151 MallocerFreer::GetInstance()->Free<double>(&this->pxyz, CartesianType_end);
5252 throw MolDSException(ex.what());
5353 }
54+ this->index = index;
5455 }
5556
5657 Atom::~Atom(){
--- a/src/base/atoms/Atom.h
+++ b/src/base/atoms/Atom.h
@@ -22,8 +22,9 @@ namespace MolDS_base_atoms{
2222
2323 class Atom : public MolDS_base::PrintController{
2424 public:
25- Atom();
25+ Atom(int index);
2626 virtual ~Atom();
27+ inline int GetIndex() const{return this->index;}
2728 double* GetXyz() const;
2829 void SetXyz(double x, double y, double z) const;
2930 double* GetPxyz() const;
@@ -224,6 +225,7 @@ protected:
224225 double pm3DBondingParameterP; // Table II in ref. [MH_2007] for H, C, N, O, and Table IV in re. [MMHBV_2007] for S.
225226 double pm3DAlpha; // Table II in ref. [MH_2007] for H, C, N, O, and Table IV in re. [MMHBV_2007] for S.
226227 private:
228+ Atom();
227229 std::string errorMessageIonPot;
228230 std::string errorMessageAtomType;
229231 std::string errorMessageNumberValences;
@@ -276,6 +278,7 @@ private:
276278 std::string errorMessageSetXyzCoordinatesNull;
277279 std::string errorMessageGetPxyzMomentaNull;
278280 std::string errorMessageSetPxyzMomentaNull;
281+ int index;
279282 void SetMessages();
280283 double GetRealAngularPartAO(double theta,
281284 double phi,
--- a/src/base/atoms/Catom.cpp
+++ b/src/base/atoms/Catom.cpp
@@ -33,7 +33,7 @@
3333 using namespace std;
3434 using namespace MolDS_base;
3535 namespace MolDS_base_atoms{
36-Catom::Catom() : Atom(){
36+Catom::Catom(int index) : Atom(index){
3737 this->SetAtomicParameters();
3838 }
3939
--- a/src/base/atoms/Catom.h
+++ b/src/base/atoms/Catom.h
@@ -21,8 +21,9 @@
2121 namespace MolDS_base_atoms{
2222 class Catom : public Atom {
2323 public:
24- Catom();
24+ Catom(int index);
2525 private:
26+ Catom();
2627 void SetAtomicParameters();
2728 };
2829 }
--- a/src/base/atoms/Hatom.cpp
+++ b/src/base/atoms/Hatom.cpp
@@ -35,7 +35,7 @@ using namespace MolDS_base;
3535
3636 namespace MolDS_base_atoms{
3737
38-Hatom::Hatom() : Atom(){
38+Hatom::Hatom(int index) : Atom(index){
3939 this->SetAtomicParameters();
4040 }
4141
--- a/src/base/atoms/Hatom.h
+++ b/src/base/atoms/Hatom.h
@@ -22,8 +22,9 @@ namespace MolDS_base_atoms{
2222
2323 class Hatom : public Atom {
2424 public:
25- Hatom();
25+ Hatom(int index);
2626 private:
27+ Hatom();
2728 void SetAtomicParameters();
2829 };
2930
--- a/src/base/atoms/Liatom.cpp
+++ b/src/base/atoms/Liatom.cpp
@@ -34,7 +34,7 @@ using namespace std;
3434 using namespace MolDS_base;
3535
3636 namespace MolDS_base_atoms{
37-Liatom::Liatom() : Atom(){
37+Liatom::Liatom(int index) : Atom(index){
3838 this->SetAtomicParameters();
3939 }
4040
--- a/src/base/atoms/Liatom.h
+++ b/src/base/atoms/Liatom.h
@@ -21,8 +21,9 @@
2121 namespace MolDS_base_atoms{
2222 class Liatom : public Atom {
2323 public:
24- Liatom();
24+ Liatom(int index);
2525 private:
26+ Liatom();
2627 void SetAtomicParameters();
2728 };
2829 }
--- a/src/base/atoms/Natom.cpp
+++ b/src/base/atoms/Natom.cpp
@@ -33,7 +33,7 @@
3333 using namespace std;
3434 using namespace MolDS_base;
3535 namespace MolDS_base_atoms{
36-Natom::Natom() : Atom(){
36+Natom::Natom(int index) : Atom(index){
3737 this->SetAtomicParameters();
3838 }
3939
--- a/src/base/atoms/Natom.h
+++ b/src/base/atoms/Natom.h
@@ -21,8 +21,9 @@
2121 namespace MolDS_base_atoms{
2222 class Natom : public Atom {
2323 public:
24- Natom();
24+ Natom(int index);
2525 private:
26+ Natom();
2627 void SetAtomicParameters();
2728 };
2829 }
--- a/src/base/atoms/Oatom.cpp
+++ b/src/base/atoms/Oatom.cpp
@@ -33,7 +33,7 @@
3333 using namespace std;
3434 using namespace MolDS_base;
3535 namespace MolDS_base_atoms{
36-Oatom::Oatom() : Atom(){
36+Oatom::Oatom(int index) : Atom(index){
3737 this->SetAtomicParameters();
3838 }
3939
--- a/src/base/atoms/Oatom.h
+++ b/src/base/atoms/Oatom.h
@@ -21,8 +21,9 @@
2121 namespace MolDS_base_atoms{
2222 class Oatom : public Atom {
2323 public:
24- Oatom();
24+ Oatom(int index);
2525 private:
26+ Oatom();
2627 void SetAtomicParameters();
2728 };
2829 }
--- a/src/base/atoms/Satom.cpp
+++ b/src/base/atoms/Satom.cpp
@@ -33,7 +33,7 @@
3333 using namespace std;
3434 using namespace MolDS_base;
3535 namespace MolDS_base_atoms{
36-Satom::Satom() : Atom(){
36+Satom::Satom(int index) : Atom(index){
3737 this->SetAtomicParameters();
3838 }
3939
--- a/src/base/atoms/Satom.h
+++ b/src/base/atoms/Satom.h
@@ -21,8 +21,9 @@
2121 namespace MolDS_base_atoms{
2222 class Satom : public Atom {
2323 public:
24- Satom();
24+ Satom(int index);
2525 private:
26+ Satom();
2627 void SetAtomicParameters();
2728 };
2829 }
--- a/src/base/factories/AtomFactory.cpp
+++ b/src/base/factories/AtomFactory.cpp
@@ -43,25 +43,25 @@ namespace MolDS_base_factories{
4343 string AtomFactory::errorMessageNotEnableAtom = "Error in base::AtomFactory::Create: Not Enable AtomType is set.";
4444 string AtomFactory::errorMessageAtomType = "\tatom type = ";
4545
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){
4747 Atom* atom=NULL;
4848 if(atomType == H){
49- atom = new Hatom();
49+ atom = new Hatom(index);
5050 }
5151 else if(atomType == Li){
52- atom = new Liatom();
52+ atom = new Liatom(index);
5353 }
5454 else if(atomType == C){
55- atom = new Catom();
55+ atom = new Catom(index);
5656 }
5757 else if(atomType == N){
58- atom = new Natom();
58+ atom = new Natom(index);
5959 }
6060 else if(atomType == O){
61- atom = new Oatom();
61+ atom = new Oatom(index);
6262 }
6363 else if(atomType == S){
64- atom = new Satom();
64+ atom = new Satom(index);
6565 }
6666 else{
6767 stringstream ss;
@@ -74,11 +74,11 @@ Atom* AtomFactory::Create(AtomType atomType, double x, double y, double z, doubl
7474 return atom;
7575 }
7676
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){
7878 double px=0.0;
7979 double py=0.0;
8080 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);
8282 }
8383 }
8484
--- a/src/base/factories/AtomFactory.h
+++ b/src/base/factories/AtomFactory.h
@@ -24,6 +24,7 @@ namespace MolDS_base_factories{
2424 class AtomFactory{
2525 public:
2626 static MolDS_base_atoms::Atom* Create(MolDS_base::AtomType atomType,
27+ int index,
2728 double x,
2829 double y,
2930 double z,
@@ -31,6 +32,7 @@ public:
3132 double py,
3233 double pz);
3334 static MolDS_base_atoms::Atom* Create(MolDS_base::AtomType atomType,
35+ int index,
3436 double x,
3537 double y,
3638 double z);