ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Restraints.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Restraints.cpp (file contents):
Revision 1187 by chrisfen, Sat May 22 18:16:18 2004 UTC vs.
Revision 1221 by chrisfen, Wed Jun 2 14:56:18 2004 UTC

# Line 23 | Line 23 | Restraints::Restraints(int nMolInfo, double lambdaVal,
23  
24    const char *jolt = " \t\n;,";
25  
26 <  strcpy(springName, "HarmSpringConsts.txt");
26 > #ifdef IS_MPI
27 >  if(worldRank == 0 ){
28 > #endif // is_mpi
29  
30 <  ifstream springs(springName);
31 <
32 <  if (!springs) {
33 <    sprintf(painCave.errMsg,
34 <            "Restraints Warning: Unable to open HarmSpringConsts.txt for reading.\n"
35 <            "\tDefault spring constants will be loaded. If you want to specify\n"
36 <            "\tspring constants, include a three line HarmSpringConsts.txt file\n"
37 <            "\tin the current directory.\n");
38 <    painCave.isFatal = 0;
39 <    simError();  
40 <
41 <    // load default spring constants
42 <    kDist  = 6;  // spring constant in units of kcal/(mol*ang^2)
43 <    kTheta = 7.5;   // in units of kcal/mol
44 <    kOmega = 13.5;   // in units of kcal/mol
45 <    return;
30 >    strcpy(springName, "HarmSpringConsts.txt");
31 >    
32 >    ifstream springs(springName);
33 >    
34 >    if (!springs) {
35 >      sprintf(painCave.errMsg,
36 >              "In Restraints: Unable to open HarmSpringConsts.txt for reading.\n"
37 >              "\tDefault spring constants will be loaded. If you want to specify\n"
38 >              "\tspring constants, include a three line HarmSpringConsts.txt file\n"
39 >              "\tin the current directory.\n");
40 >      painCave.severity = OOPSE_WARNING;
41 >      painCave.isFatal = 0;
42 >      simError();  
43 >      
44 >      // load default spring constants
45 >      kDist  = 6;  // spring constant in units of kcal/(mol*ang^2)
46 >      kTheta = 7.5;   // in units of kcal/mol
47 >      kOmega = 13.5;   // in units of kcal/mol
48 >    } else  {
49 >      
50 >      springs.getline(inLine,999,'\n');
51 >      springs.getline(inLine,999,'\n');
52 >      token = strtok(inLine,jolt);
53 >      token = strtok(NULL,jolt);
54 >      strcpy(inValue,token);
55 >      kDist = (atof(inValue));
56 >      springs.getline(inLine,999,'\n');
57 >      token = strtok(inLine,jolt);
58 >      token = strtok(NULL,jolt);
59 >      strcpy(inValue,token);
60 >      kTheta = (atof(inValue));
61 >      springs.getline(inLine,999,'\n');
62 >      token = strtok(inLine,jolt);
63 >      token = strtok(NULL,jolt);
64 >      strcpy(inValue,token);
65 >      kOmega = (atof(inValue));
66 >      springs.close();
67 >    }
68 > #ifdef IS_MPI
69    }
70 <
71 <  springs.getline(inLine,999,'\n');
72 <  springs.getline(inLine,999,'\n');
73 <  token = strtok(inLine,jolt);
74 <  token = strtok(NULL,jolt);
75 <  strcpy(inValue,token);
76 <  kDist = (atof(inValue));
77 <  springs.getline(inLine,999,'\n');
53 <  token = strtok(inLine,jolt);
54 <  token = strtok(NULL,jolt);
55 <  strcpy(inValue,token);
56 <  kTheta = (atof(inValue));
57 <  springs.getline(inLine,999,'\n');
58 <  token = strtok(inLine,jolt);
59 <  token = strtok(NULL,jolt);
60 <  strcpy(inValue,token);
61 <  kOmega = (atof(inValue));
62 <  springs.close();
70 >  
71 >  MPI_Bcast(&kDist, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
72 >  MPI_Bcast(&kTheta, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
73 >  MPI_Bcast(&kOmega, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
74 >  
75 >  sprintf( checkPointMsg,
76 >           "Sucessfully opened and read spring file.\n");
77 >  MPIcheckPoint();
78  
79 <  cout << "The Spring Constants are:\n\tkDist  = " << kDist << "\n\tkTheta = " << kTheta << "\n\tkOmega = " << kOmega << "\n";
79 > #endif // is_mpi
80 >  
81 >  sprintf(painCave.errMsg,
82 >          "The spring constants for thermodynamic integration are:\n"
83 >          "\tkDist = %lf\n"
84 >          "\tkTheta = %lf\n"
85 >          "\tkOmega = %lf\n", kDist, kTheta, kOmega);
86 >  painCave.severity = OOPSE_INFO;
87 >  painCave.isFatal = 0;
88 >  simError();  
89   }
90  
91   Restraints::~Restraints(){
# Line 140 | Line 164 | double Restraints::Calc_Restraint_Forces(vector<StuntD
164    double tempPotent;
165    double factor;
166    double spaceTrq[3];
167 <  double omega;
167 >  double omegaPass;
168  
169    tolerance = 5.72957795131e-7;
170  
# Line 154 | Line 178 | double Restraints::Calc_Restraint_Forces(vector<StuntD
178        vecParticles[i]->getA(A);
179        Calc_rVal( pos, i );
180        Calc_body_thetaVal( A, i );
181 <      vecParticles[i]->getZangle(omega);
182 <      Calc_body_omegaVal( A, omega );
181 >      omegaPass = vecParticles[i]->getZangle();
182 >      Calc_body_omegaVal( A, omegaPass );
183  
184        if (omega > PI || omega < -PI)
185          cout << "oops... " << omega << "\n";
# Line 275 | Line 299 | void Restraints::Store_Init_Info(vector<StuntDouble*>
299    if (!angleIn) {
300      sprintf(painCave.errMsg,
301              "Restraints Warning: The lack of a zAngle.ang file is mildly\n"
302 <            "\tunsettling... This means you arestarting from the idealCrystal.in\n"
303 <            "\treference configuration, so the omega values will all be set to\n"
304 <            "\tzero. If this isn't the case, you should question your results.\n");
302 >            "\tunsettling... This means the simulation is starting from the\n"
303 >            "\tidealCrystal.in reference configuration, so the omega values\n"
304 >            "\twill all be set to zero. If this is not the case, you should\n"
305 >            "\tquestion your results.\n");
306      painCave.isFatal = 0;
307      simError();  
308    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines