1 |
< |
#include <cstdlib> |
1 |
> |
#include <algorithm> |
2 |
> |
#include <stdlib.h> |
3 |
|
#include <iostream> |
4 |
< |
#include <cmath> |
5 |
< |
|
4 |
> |
#include <math.h> |
5 |
> |
#include <string> |
6 |
> |
#include <sprng.h> |
7 |
|
#include "SimSetup.hpp" |
8 |
+ |
#include "ReadWrite.hpp" |
9 |
|
#include "parse_me.h" |
10 |
|
#include "Integrator.hpp" |
11 |
|
#include "simError.h" |
12 |
+ |
//#include "ConjugateMinimizer.hpp" |
13 |
+ |
#include "OOPSEMinimizer.hpp" |
14 |
|
|
15 |
|
#ifdef IS_MPI |
16 |
|
#include "mpiBASS.h" |
17 |
|
#include "mpiSimulation.hpp" |
18 |
|
#endif |
19 |
|
|
20 |
+ |
// some defines for ensemble and Forcefield cases |
21 |
+ |
|
22 |
+ |
#define NVE_ENS 0 |
23 |
+ |
#define NVT_ENS 1 |
24 |
+ |
#define NPTi_ENS 2 |
25 |
+ |
#define NPTf_ENS 3 |
26 |
+ |
#define NPTxyz_ENS 4 |
27 |
+ |
|
28 |
+ |
|
29 |
+ |
#define FF_DUFF 0 |
30 |
+ |
#define FF_LJ 1 |
31 |
+ |
#define FF_EAM 2 |
32 |
+ |
#define FF_H2O 3 |
33 |
+ |
|
34 |
+ |
using namespace std; |
35 |
+ |
|
36 |
+ |
/** |
37 |
+ |
* Check whether dividend is divisble by divisor or not |
38 |
+ |
*/ |
39 |
+ |
bool isDivisible(double dividend, double divisor){ |
40 |
+ |
double tolerance = 0.000001; |
41 |
+ |
double quotient; |
42 |
+ |
double diff; |
43 |
+ |
int intQuotient; |
44 |
+ |
|
45 |
+ |
quotient = dividend / divisor; |
46 |
+ |
|
47 |
+ |
if (quotient < 0) |
48 |
+ |
quotient = -quotient; |
49 |
+ |
|
50 |
+ |
intQuotient = int (quotient + tolerance); |
51 |
+ |
|
52 |
+ |
diff = fabs(fabs(dividend) - intQuotient * fabs(divisor)); |
53 |
+ |
|
54 |
+ |
if (diff <= tolerance) |
55 |
+ |
return true; |
56 |
+ |
else |
57 |
+ |
return false; |
58 |
+ |
} |
59 |
+ |
|
60 |
|
SimSetup::SimSetup(){ |
61 |
+ |
|
62 |
+ |
initSuspend = false; |
63 |
+ |
isInfoArray = 0; |
64 |
+ |
nInfo = 1; |
65 |
+ |
|
66 |
|
stamps = new MakeStamps(); |
67 |
|
globals = new Globals(); |
68 |
< |
|
68 |
> |
|
69 |
> |
|
70 |
|
#ifdef IS_MPI |
71 |
< |
strcpy( checkPointMsg, "SimSetup creation successful" ); |
71 |
> |
strcpy(checkPointMsg, "SimSetup creation successful"); |
72 |
|
MPIcheckPoint(); |
73 |
|
#endif // IS_MPI |
74 |
|
} |
78 |
|
delete globals; |
79 |
|
} |
80 |
|
|
81 |
< |
void SimSetup::parseFile( char* fileName ){ |
81 |
> |
void SimSetup::setSimInfo(SimInfo* the_info, int theNinfo){ |
82 |
> |
info = the_info; |
83 |
> |
nInfo = theNinfo; |
84 |
> |
isInfoArray = 1; |
85 |
> |
initSuspend = true; |
86 |
> |
} |
87 |
|
|
88 |
+ |
|
89 |
+ |
void SimSetup::parseFile(char* fileName){ |
90 |
|
#ifdef IS_MPI |
91 |
< |
if( worldRank == 0 ){ |
91 |
> |
if (worldRank == 0){ |
92 |
|
#endif // is_mpi |
93 |
< |
|
93 |
> |
|
94 |
|
inFileName = fileName; |
95 |
< |
set_interface_stamps( stamps, globals ); |
96 |
< |
|
95 |
> |
set_interface_stamps(stamps, globals); |
96 |
> |
|
97 |
|
#ifdef IS_MPI |
98 |
|
mpiEventInit(); |
99 |
|
#endif |
100 |
|
|
101 |
< |
yacc_BASS( fileName ); |
101 |
> |
yacc_BASS(fileName); |
102 |
|
|
103 |
|
#ifdef IS_MPI |
104 |
|
throwMPIEvent(NULL); |
105 |
|
} |
106 |
< |
else receiveParse(); |
106 |
> |
else{ |
107 |
> |
receiveParse(); |
108 |
> |
} |
109 |
|
#endif |
110 |
|
|
111 |
|
} |
112 |
|
|
113 |
|
#ifdef IS_MPI |
114 |
|
void SimSetup::receiveParse(void){ |
115 |
< |
|
116 |
< |
set_interface_stamps( stamps, globals ); |
117 |
< |
mpiEventInit(); |
118 |
< |
MPIcheckPoint(); |
59 |
< |
mpiEventLoop(); |
60 |
< |
|
115 |
> |
set_interface_stamps(stamps, globals); |
116 |
> |
mpiEventInit(); |
117 |
> |
MPIcheckPoint(); |
118 |
> |
mpiEventLoop(); |
119 |
|
} |
120 |
|
|
121 |
|
#endif // is_mpi |
122 |
|
|
123 |
< |
void SimSetup::createSim( void ){ |
123 |
> |
void SimSetup::createSim(void){ |
124 |
|
|
125 |
< |
MakeStamps *the_stamps; |
68 |
< |
Globals* the_globals; |
69 |
< |
int i, j; |
125 |
> |
// gather all of the information from the Bass file |
126 |
|
|
127 |
< |
// get the stamps and globals; |
72 |
< |
the_stamps = stamps; |
73 |
< |
the_globals = globals; |
127 |
> |
gatherInfo(); |
128 |
|
|
129 |
< |
// set the easy ones first |
76 |
< |
simnfo->target_temp = the_globals->getTargetTemp(); |
77 |
< |
simnfo->dt = the_globals->getDt(); |
78 |
< |
simnfo->run_time = the_globals->getRunTime(); |
129 |
> |
// creation of complex system objects |
130 |
|
|
131 |
< |
// get the ones we know are there, yet still may need some work. |
81 |
< |
n_components = the_globals->getNComponents(); |
82 |
< |
strcpy( force_field, the_globals->getForceField() ); |
83 |
< |
strcpy( ensemble, the_globals->getEnsemble() ); |
84 |
< |
strcpy( simnfo->ensemble, ensemble ); |
131 |
> |
sysObjectsCreation(); |
132 |
|
|
133 |
< |
strcpy( simnfo->mixingRule, the_globals->getMixingRule() ); |
87 |
< |
simnfo->usePBC = the_globals->getPBC(); |
88 |
< |
|
133 |
> |
// check on the post processing info |
134 |
|
|
135 |
+ |
finalInfoCheck(); |
136 |
|
|
137 |
< |
if( !strcmp( force_field, "TraPPE" ) ) the_ff = new TraPPEFF(); |
92 |
< |
else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); |
93 |
< |
else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); |
94 |
< |
else if( !strcmp( force_field, "LJ" ) ) the_ff = new LJ_FF(); |
95 |
< |
else{ |
96 |
< |
sprintf( painCave.errMsg, |
97 |
< |
"SimSetup Error. Unrecognized force field -> %s\n", |
98 |
< |
force_field ); |
99 |
< |
painCave.isFatal = 1; |
100 |
< |
simError(); |
101 |
< |
} |
137 |
> |
// initialize the system coordinates |
138 |
|
|
139 |
< |
#ifdef IS_MPI |
140 |
< |
strcpy( checkPointMsg, "ForceField creation successful" ); |
105 |
< |
MPIcheckPoint(); |
106 |
< |
#endif // is_mpi |
139 |
> |
if ( !initSuspend ){ |
140 |
> |
initSystemCoords(); |
141 |
|
|
142 |
< |
|
142 |
> |
if( !(globals->getUseInitTime()) ) |
143 |
> |
info[0].currentTime = 0.0; |
144 |
> |
} |
145 |
|
|
146 |
< |
// get the components and calculate the tot_nMol and indvidual n_mol |
111 |
< |
the_components = the_globals->getComponents(); |
112 |
< |
components_nmol = new int[n_components]; |
113 |
< |
comp_stamps = new MoleculeStamp*[n_components]; |
146 |
> |
// make the output filenames |
147 |
|
|
148 |
< |
if( !the_globals->haveNMol() ){ |
116 |
< |
// we don't have the total number of molecules, so we assume it is |
117 |
< |
// given in each component |
148 |
> |
makeOutNames(); |
149 |
|
|
150 |
< |
tot_nmol = 0; |
151 |
< |
for( i=0; i<n_components; i++ ){ |
152 |
< |
|
153 |
< |
if( !the_components[i]->haveNMol() ){ |
154 |
< |
// we have a problem |
155 |
< |
sprintf( painCave.errMsg, |
125 |
< |
"SimSetup Error. No global NMol or component NMol" |
126 |
< |
" given. Cannot calculate the number of atoms.\n" ); |
127 |
< |
painCave.isFatal = 1; |
128 |
< |
simError(); |
129 |
< |
} |
130 |
< |
|
131 |
< |
tot_nmol += the_components[i]->getNMol(); |
132 |
< |
components_nmol[i] = the_components[i]->getNMol(); |
133 |
< |
} |
134 |
< |
} |
135 |
< |
else{ |
136 |
< |
sprintf( painCave.errMsg, |
137 |
< |
"SimSetup error.\n" |
138 |
< |
"\tSorry, the ability to specify total" |
139 |
< |
" nMols and then give molfractions in the components\n" |
140 |
< |
"\tis not currently supported." |
141 |
< |
" Please give nMol in the components.\n" ); |
142 |
< |
painCave.isFatal = 1; |
143 |
< |
simError(); |
144 |
< |
|
145 |
< |
|
146 |
< |
// tot_nmol = the_globals->getNMol(); |
147 |
< |
|
148 |
< |
// //we have the total number of molecules, now we check for molfractions |
149 |
< |
// for( i=0; i<n_components; i++ ){ |
150 |
< |
|
151 |
< |
// if( !the_components[i]->haveMolFraction() ){ |
152 |
< |
|
153 |
< |
// if( !the_components[i]->haveNMol() ){ |
154 |
< |
// //we have a problem |
155 |
< |
// std::cerr << "SimSetup error. Neither molFraction nor " |
156 |
< |
// << " nMol was given in component |
157 |
< |
|
158 |
< |
} |
159 |
< |
|
160 |
< |
#ifdef IS_MPI |
161 |
< |
strcpy( checkPointMsg, "Have the number of components" ); |
162 |
< |
MPIcheckPoint(); |
163 |
< |
#endif // is_mpi |
164 |
< |
|
165 |
< |
// make an array of molecule stamps that match the components used. |
166 |
< |
// also extract the used stamps out into a separate linked list |
167 |
< |
|
168 |
< |
simnfo->nComponents = n_components; |
169 |
< |
simnfo->componentsNmol = components_nmol; |
170 |
< |
simnfo->compStamps = comp_stamps; |
171 |
< |
simnfo->headStamp = new LinkedMolStamp(); |
150 |
> |
if (globals->haveMinimizer()) |
151 |
> |
// make minimizer |
152 |
> |
makeMinimizer(); |
153 |
> |
else |
154 |
> |
// make the integrator |
155 |
> |
makeIntegrator(); |
156 |
|
|
173 |
– |
char* id; |
174 |
– |
LinkedMolStamp* headStamp = simnfo->headStamp; |
175 |
– |
LinkedMolStamp* currentStamp = NULL; |
176 |
– |
for( i=0; i<n_components; i++ ){ |
177 |
– |
|
178 |
– |
id = the_components[i]->getType(); |
179 |
– |
comp_stamps[i] = NULL; |
180 |
– |
|
181 |
– |
// check to make sure the component isn't already in the list |
182 |
– |
|
183 |
– |
comp_stamps[i] = headStamp->match( id ); |
184 |
– |
if( comp_stamps[i] == NULL ){ |
185 |
– |
|
186 |
– |
// extract the component from the list; |
187 |
– |
|
188 |
– |
currentStamp = the_stamps->extractMolStamp( id ); |
189 |
– |
if( currentStamp == NULL ){ |
190 |
– |
sprintf( painCave.errMsg, |
191 |
– |
"SimSetup error: Component \"%s\" was not found in the " |
192 |
– |
"list of declared molecules\n", |
193 |
– |
id ); |
194 |
– |
painCave.isFatal = 1; |
195 |
– |
simError(); |
196 |
– |
} |
197 |
– |
|
198 |
– |
headStamp->add( currentStamp ); |
199 |
– |
comp_stamps[i] = headStamp->match( id ); |
200 |
– |
} |
201 |
– |
} |
202 |
– |
|
157 |
|
#ifdef IS_MPI |
158 |
< |
strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); |
159 |
< |
MPIcheckPoint(); |
206 |
< |
#endif // is_mpi |
207 |
< |
|
158 |
> |
mpiSim->mpiRefresh(); |
159 |
> |
#endif |
160 |
|
|
161 |
+ |
// initialize the Fortran |
162 |
|
|
163 |
+ |
initFortran(); |
164 |
+ |
} |
165 |
|
|
211 |
– |
// caclulate the number of atoms, bonds, bends and torsions |
166 |
|
|
167 |
< |
tot_atoms = 0; |
168 |
< |
tot_bonds = 0; |
169 |
< |
tot_bends = 0; |
170 |
< |
tot_torsions = 0; |
171 |
< |
for( i=0; i<n_components; i++ ){ |
172 |
< |
|
173 |
< |
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
174 |
< |
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
175 |
< |
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
176 |
< |
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
177 |
< |
} |
167 |
> |
void SimSetup::makeMolecules(void){ |
168 |
> |
int k; |
169 |
> |
int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
170 |
> |
molInit molInfo; |
171 |
> |
DirectionalAtom* dAtom; |
172 |
> |
LinkedAssign* extras; |
173 |
> |
LinkedAssign* current_extra; |
174 |
> |
AtomStamp* currentAtom; |
175 |
> |
BondStamp* currentBond; |
176 |
> |
BendStamp* currentBend; |
177 |
> |
TorsionStamp* currentTorsion; |
178 |
|
|
179 |
< |
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
179 |
> |
bond_pair* theBonds; |
180 |
> |
bend_set* theBends; |
181 |
> |
torsion_set* theTorsions; |
182 |
|
|
183 |
< |
simnfo->n_atoms = tot_atoms; |
228 |
< |
simnfo->n_bonds = tot_bonds; |
229 |
< |
simnfo->n_bends = tot_bends; |
230 |
< |
simnfo->n_torsions = tot_torsions; |
231 |
< |
simnfo->n_SRI = tot_SRI; |
232 |
< |
simnfo->n_mol = tot_nmol; |
183 |
> |
//init the forceField paramters |
184 |
|
|
185 |
< |
|
235 |
< |
#ifdef IS_MPI |
185 |
> |
the_ff->readParams(); |
186 |
|
|
237 |
– |
// divide the molecules among processors here. |
238 |
– |
|
239 |
– |
mpiSim = new mpiSimulation( simnfo ); |
240 |
– |
|
241 |
– |
|
187 |
|
|
188 |
< |
globalIndex = mpiSim->divideLabor(); |
188 |
> |
// init the atoms |
189 |
> |
|
190 |
> |
double phi, theta, psi; |
191 |
> |
double sux, suy, suz; |
192 |
> |
double Axx, Axy, Axz, Ayx, Ayy, Ayz, Azx, Azy, Azz; |
193 |
> |
double ux, uy, uz, u, uSqr; |
194 |
|
|
195 |
+ |
for (k = 0; k < nInfo; k++){ |
196 |
+ |
the_ff->setSimInfo(&(info[k])); |
197 |
|
|
198 |
+ |
atomOffset = 0; |
199 |
+ |
excludeOffset = 0; |
200 |
+ |
for (i = 0; i < info[k].n_mol; i++){ |
201 |
+ |
stampID = info[k].molecules[i].getStampID(); |
202 |
|
|
203 |
< |
// set up the local variables |
204 |
< |
|
205 |
< |
int localMol, allMol; |
206 |
< |
int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
207 |
< |
|
252 |
< |
allMol = 0; |
253 |
< |
localMol = 0; |
254 |
< |
local_atoms = 0; |
255 |
< |
local_bonds = 0; |
256 |
< |
local_bends = 0; |
257 |
< |
local_torsions = 0; |
258 |
< |
for( i=0; i<n_components; i++ ){ |
203 |
> |
molInfo.nAtoms = comp_stamps[stampID]->getNAtoms(); |
204 |
> |
molInfo.nBonds = comp_stamps[stampID]->getNBonds(); |
205 |
> |
molInfo.nBends = comp_stamps[stampID]->getNBends(); |
206 |
> |
molInfo.nTorsions = comp_stamps[stampID]->getNTorsions(); |
207 |
> |
molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions; |
208 |
|
|
209 |
< |
for( j=0; j<components_nmol[i]; j++ ){ |
210 |
< |
|
211 |
< |
if( mpiSim->getMyMolStart() <= allMol && |
212 |
< |
allMol <= mpiSim->getMyMolEnd() ){ |
213 |
< |
|
265 |
< |
local_atoms += comp_stamps[i]->getNAtoms(); |
266 |
< |
local_bonds += comp_stamps[i]->getNBonds(); |
267 |
< |
local_bends += comp_stamps[i]->getNBends(); |
268 |
< |
local_torsions += comp_stamps[i]->getNTorsions(); |
269 |
< |
localMol++; |
270 |
< |
} |
271 |
< |
allMol++; |
272 |
< |
} |
273 |
< |
} |
274 |
< |
local_SRI = local_bonds + local_bends + local_torsions; |
275 |
< |
|
209 |
> |
molInfo.myAtoms = &(info[k].atoms[atomOffset]); |
210 |
> |
molInfo.myExcludes = &(info[k].excludes[excludeOffset]); |
211 |
> |
molInfo.myBonds = new Bond * [molInfo.nBonds]; |
212 |
> |
molInfo.myBends = new Bend * [molInfo.nBends]; |
213 |
> |
molInfo.myTorsions = new Torsion * [molInfo.nTorsions]; |
214 |
|
|
215 |
< |
simnfo->n_atoms = mpiSim->getMyNlocal(); |
216 |
< |
|
217 |
< |
if( local_atoms != simnfo->n_atoms ){ |
280 |
< |
sprintf( painCave.errMsg, |
281 |
< |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's" |
282 |
< |
" localAtom (%d) are note equal.\n", |
283 |
< |
simnfo->n_atoms, |
284 |
< |
local_atoms ); |
285 |
< |
painCave.isFatal = 1; |
286 |
< |
simError(); |
287 |
< |
} |
215 |
> |
theBonds = new bond_pair[molInfo.nBonds]; |
216 |
> |
theBends = new bend_set[molInfo.nBends]; |
217 |
> |
theTorsions = new torsion_set[molInfo.nTorsions]; |
218 |
|
|
219 |
< |
simnfo->n_bonds = local_bonds; |
290 |
< |
simnfo->n_bends = local_bends; |
291 |
< |
simnfo->n_torsions = local_torsions; |
292 |
< |
simnfo->n_SRI = local_SRI; |
293 |
< |
simnfo->n_mol = localMol; |
219 |
> |
// make the Atoms |
220 |
|
|
221 |
< |
strcpy( checkPointMsg, "Passed nlocal consistency check." ); |
222 |
< |
MPIcheckPoint(); |
223 |
< |
|
224 |
< |
|
225 |
< |
#endif // is_mpi |
226 |
< |
|
221 |
> |
for (j = 0; j < molInfo.nAtoms; j++){ |
222 |
> |
currentAtom = comp_stamps[stampID]->getAtom(j); |
223 |
> |
if (currentAtom->haveOrientation()){ |
224 |
> |
dAtom = new DirectionalAtom((j + atomOffset), |
225 |
> |
info[k].getConfiguration()); |
226 |
> |
info[k].n_oriented++; |
227 |
> |
molInfo.myAtoms[j] = dAtom; |
228 |
|
|
229 |
< |
// create the atom and short range interaction arrays |
229 |
> |
// Directional Atoms have standard unit vectors which are oriented |
230 |
> |
// in space using the three Euler angles. We assume the standard |
231 |
> |
// unit vector was originally along the z axis below. |
232 |
|
|
233 |
< |
Atom::createArrays(simnfo->n_atoms); |
234 |
< |
the_atoms = new Atom*[simnfo->n_atoms]; |
235 |
< |
the_molecules = new Molecule[simnfo->n_mol]; |
233 |
> |
phi = currentAtom->getEulerPhi() * M_PI / 180.0; |
234 |
> |
theta = currentAtom->getEulerTheta() * M_PI / 180.0; |
235 |
> |
psi = currentAtom->getEulerPsi()* M_PI / 180.0; |
236 |
> |
|
237 |
> |
Axx = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
238 |
> |
Axy = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
239 |
> |
Axz = sin(theta) * sin(psi); |
240 |
> |
|
241 |
> |
Ayx = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
242 |
> |
Ayy = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
243 |
> |
Ayz = sin(theta) * cos(psi); |
244 |
> |
|
245 |
> |
Azx = sin(phi) * sin(theta); |
246 |
> |
Azy = -cos(phi) * sin(theta); |
247 |
> |
Azz = cos(theta); |
248 |
|
|
249 |
+ |
sux = 0.0; |
250 |
+ |
suy = 0.0; |
251 |
+ |
suz = 1.0; |
252 |
|
|
253 |
< |
if( simnfo->n_SRI ){ |
254 |
< |
Exclude::createArray(simnfo->n_SRI); |
255 |
< |
the_excludes = new Exclude*[simnfo->n_SRI]; |
312 |
< |
simnfo->globalExcludes = new int; |
313 |
< |
simnfo->n_exclude = tot_SRI; |
314 |
< |
} |
315 |
< |
else{ |
316 |
< |
|
317 |
< |
Exclude::createArray( 1 ); |
318 |
< |
the_excludes = new Exclude*; |
319 |
< |
the_excludes[0] = new Exclude(0); |
320 |
< |
the_excludes[0]->setPair( 0,0 ); |
321 |
< |
simnfo->globalExcludes = new int; |
322 |
< |
simnfo->globalExcludes[0] = 0; |
323 |
< |
simnfo->n_exclude = 0; |
324 |
< |
} |
253 |
> |
ux = (Axx * sux) + (Ayx * suy) + (Azx * suz); |
254 |
> |
uy = (Axy * sux) + (Ayy * suy) + (Azy * suz); |
255 |
> |
uz = (Axz * sux) + (Ayz * suy) + (Azz * suz); |
256 |
|
|
257 |
< |
// set the arrays into the SimInfo object |
257 |
> |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
258 |
|
|
259 |
< |
simnfo->atoms = the_atoms; |
260 |
< |
simnfo->sr_interactions = the_sris; |
261 |
< |
simnfo->nGlobalExcludes = 0; |
262 |
< |
simnfo->excludes = the_excludes; |
259 |
> |
u = sqrt(uSqr); |
260 |
> |
ux = ux / u; |
261 |
> |
uy = uy / u; |
262 |
> |
uz = uz / u; |
263 |
|
|
264 |
+ |
dAtom->setSUx(ux); |
265 |
+ |
dAtom->setSUy(uy); |
266 |
+ |
dAtom->setSUz(uz); |
267 |
+ |
} |
268 |
+ |
else{ |
269 |
+ |
molInfo.myAtoms[j] = new GeneralAtom((j + atomOffset), |
270 |
+ |
info[k].getConfiguration()); |
271 |
+ |
} |
272 |
+ |
molInfo.myAtoms[j]->setType(currentAtom->getType()); |
273 |
|
|
274 |
< |
// get some of the tricky things that may still be in the globals |
274 |
> |
#ifdef IS_MPI |
275 |
|
|
276 |
< |
|
337 |
< |
if( the_globals->haveBox() ){ |
338 |
< |
simnfo->box_x = the_globals->getBox(); |
339 |
< |
simnfo->box_y = the_globals->getBox(); |
340 |
< |
simnfo->box_z = the_globals->getBox(); |
341 |
< |
} |
342 |
< |
else if( the_globals->haveDensity() ){ |
276 |
> |
molInfo.myAtoms[j]->setGlobalIndex(globalIndex[j + atomOffset]); |
277 |
|
|
278 |
< |
double vol; |
279 |
< |
vol = (double)tot_nmol / the_globals->getDensity(); |
346 |
< |
simnfo->box_x = pow( vol, ( 1.0 / 3.0 ) ); |
347 |
< |
simnfo->box_y = simnfo->box_x; |
348 |
< |
simnfo->box_z = simnfo->box_x; |
349 |
< |
} |
350 |
< |
else{ |
351 |
< |
if( !the_globals->haveBoxX() ){ |
352 |
< |
sprintf( painCave.errMsg, |
353 |
< |
"SimSetup error, no periodic BoxX size given.\n" ); |
354 |
< |
painCave.isFatal = 1; |
355 |
< |
simError(); |
356 |
< |
} |
357 |
< |
simnfo->box_x = the_globals->getBoxX(); |
278 |
> |
#endif // is_mpi |
279 |
> |
} |
280 |
|
|
281 |
< |
if( !the_globals->haveBoxY() ){ |
282 |
< |
sprintf( painCave.errMsg, |
283 |
< |
"SimSetup error, no periodic BoxY size given.\n" ); |
284 |
< |
painCave.isFatal = 1; |
285 |
< |
simError(); |
364 |
< |
} |
365 |
< |
simnfo->box_y = the_globals->getBoxY(); |
281 |
> |
// make the bonds |
282 |
> |
for (j = 0; j < molInfo.nBonds; j++){ |
283 |
> |
currentBond = comp_stamps[stampID]->getBond(j); |
284 |
> |
theBonds[j].a = currentBond->getA() + atomOffset; |
285 |
> |
theBonds[j].b = currentBond->getB() + atomOffset; |
286 |
|
|
287 |
< |
if( !the_globals->haveBoxZ() ){ |
288 |
< |
sprintf( painCave.errMsg, |
369 |
< |
"SimSetup error, no periodic BoxZ size given.\n" ); |
370 |
< |
painCave.isFatal = 1; |
371 |
< |
simError(); |
372 |
< |
} |
373 |
< |
simnfo->box_z = the_globals->getBoxZ(); |
374 |
< |
} |
287 |
> |
exI = theBonds[j].a; |
288 |
> |
exJ = theBonds[j].b; |
289 |
|
|
290 |
+ |
// exclude_I must always be the smaller of the pair |
291 |
+ |
if (exI > exJ){ |
292 |
+ |
tempEx = exI; |
293 |
+ |
exI = exJ; |
294 |
+ |
exJ = tempEx; |
295 |
+ |
} |
296 |
|
#ifdef IS_MPI |
297 |
< |
strcpy( checkPointMsg, "Box size set up" ); |
298 |
< |
MPIcheckPoint(); |
299 |
< |
#endif // is_mpi |
297 |
> |
tempEx = exI; |
298 |
> |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
299 |
> |
tempEx = exJ; |
300 |
> |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
301 |
|
|
302 |
+ |
info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
303 |
+ |
#else // isn't MPI |
304 |
|
|
305 |
< |
// initialize the arrays |
305 |
> |
info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
306 |
> |
#endif //is_mpi |
307 |
> |
} |
308 |
> |
excludeOffset += molInfo.nBonds; |
309 |
|
|
310 |
< |
the_ff->setSimInfo( simnfo ); |
310 |
> |
//make the bends |
311 |
> |
for (j = 0; j < molInfo.nBends; j++){ |
312 |
> |
currentBend = comp_stamps[stampID]->getBend(j); |
313 |
> |
theBends[j].a = currentBend->getA() + atomOffset; |
314 |
> |
theBends[j].b = currentBend->getB() + atomOffset; |
315 |
> |
theBends[j].c = currentBend->getC() + atomOffset; |
316 |
|
|
317 |
< |
makeAtoms(); |
318 |
< |
simnfo->identArray = new int[simnfo->n_atoms]; |
319 |
< |
for(i=0; i<simnfo->n_atoms; i++){ |
320 |
< |
simnfo->identArray[i] = the_atoms[i]->getIdent(); |
321 |
< |
} |
322 |
< |
|
323 |
< |
if( tot_bonds ){ |
324 |
< |
makeBonds(); |
325 |
< |
} |
317 |
> |
if (currentBend->haveExtras()){ |
318 |
> |
extras = currentBend->getExtras(); |
319 |
> |
current_extra = extras; |
320 |
> |
|
321 |
> |
while (current_extra != NULL){ |
322 |
> |
if (!strcmp(current_extra->getlhs(), "ghostVectorSource")){ |
323 |
> |
switch (current_extra->getType()){ |
324 |
> |
case 0: |
325 |
> |
theBends[j].ghost = current_extra->getInt() + atomOffset; |
326 |
> |
theBends[j].isGhost = 1; |
327 |
> |
break; |
328 |
> |
|
329 |
> |
case 1: |
330 |
> |
theBends[j].ghost = (int) current_extra->getDouble() + |
331 |
> |
atomOffset; |
332 |
> |
theBends[j].isGhost = 1; |
333 |
> |
break; |
334 |
> |
|
335 |
> |
default: |
336 |
> |
sprintf(painCave.errMsg, |
337 |
> |
"SimSetup Error: ghostVectorSource was neither a " |
338 |
> |
"double nor an int.\n" |
339 |
> |
"-->Bend[%d] in %s\n", |
340 |
> |
j, comp_stamps[stampID]->getID()); |
341 |
> |
painCave.isFatal = 1; |
342 |
> |
simError(); |
343 |
> |
} |
344 |
> |
} |
345 |
> |
else{ |
346 |
> |
sprintf(painCave.errMsg, |
347 |
> |
"SimSetup Error: unhandled bend assignment:\n" |
348 |
> |
" -->%s in Bend[%d] in %s\n", |
349 |
> |
current_extra->getlhs(), j, comp_stamps[stampID]->getID()); |
350 |
> |
painCave.isFatal = 1; |
351 |
> |
simError(); |
352 |
> |
} |
353 |
> |
|
354 |
> |
current_extra = current_extra->getNext(); |
355 |
> |
} |
356 |
> |
} |
357 |
|
|
358 |
< |
if( tot_bends ){ |
359 |
< |
makeBends(); |
360 |
< |
} |
358 |
> |
if (!theBends[j].isGhost){ |
359 |
> |
exI = theBends[j].a; |
360 |
> |
exJ = theBends[j].c; |
361 |
> |
} |
362 |
> |
else{ |
363 |
> |
exI = theBends[j].a; |
364 |
> |
exJ = theBends[j].b; |
365 |
> |
} |
366 |
|
|
367 |
< |
if( tot_torsions ){ |
368 |
< |
makeTorsions(); |
369 |
< |
} |
367 |
> |
// exclude_I must always be the smaller of the pair |
368 |
> |
if (exI > exJ){ |
369 |
> |
tempEx = exI; |
370 |
> |
exI = exJ; |
371 |
> |
exJ = tempEx; |
372 |
> |
} |
373 |
> |
#ifdef IS_MPI |
374 |
> |
tempEx = exI; |
375 |
> |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
376 |
> |
tempEx = exJ; |
377 |
> |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
378 |
|
|
379 |
+ |
info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
380 |
+ |
#else // isn't MPI |
381 |
+ |
info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
382 |
+ |
#endif //is_mpi |
383 |
+ |
} |
384 |
+ |
excludeOffset += molInfo.nBends; |
385 |
|
|
386 |
< |
if (the_globals->getUseRF() ) { |
387 |
< |
simnfo->useReactionField = 1; |
388 |
< |
|
389 |
< |
if( !the_globals->haveECR() ){ |
390 |
< |
sprintf( painCave.errMsg, |
391 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
411 |
< |
"box length for the electrostaticCutoffRadius.\n" |
412 |
< |
"I hope you have a very fast processor!\n"); |
413 |
< |
painCave.isFatal = 0; |
414 |
< |
simError(); |
415 |
< |
double smallest; |
416 |
< |
smallest = simnfo->box_x; |
417 |
< |
if (simnfo->box_y <= smallest) smallest = simnfo->box_y; |
418 |
< |
if (simnfo->box_z <= smallest) smallest = simnfo->box_z; |
419 |
< |
simnfo->ecr = 0.5 * smallest; |
420 |
< |
} else { |
421 |
< |
simnfo->ecr = the_globals->getECR(); |
422 |
< |
} |
386 |
> |
for (j = 0; j < molInfo.nTorsions; j++){ |
387 |
> |
currentTorsion = comp_stamps[stampID]->getTorsion(j); |
388 |
> |
theTorsions[j].a = currentTorsion->getA() + atomOffset; |
389 |
> |
theTorsions[j].b = currentTorsion->getB() + atomOffset; |
390 |
> |
theTorsions[j].c = currentTorsion->getC() + atomOffset; |
391 |
> |
theTorsions[j].d = currentTorsion->getD() + atomOffset; |
392 |
|
|
393 |
< |
if( !the_globals->haveEST() ){ |
394 |
< |
sprintf( painCave.errMsg, |
426 |
< |
"SimSetup Warning: using default value of 0.05 * the " |
427 |
< |
"electrostaticCutoffRadius for the electrostaticSkinThickness\n" |
428 |
< |
); |
429 |
< |
painCave.isFatal = 0; |
430 |
< |
simError(); |
431 |
< |
simnfo->est = 0.05 * simnfo->ecr; |
432 |
< |
} else { |
433 |
< |
simnfo->est = the_globals->getEST(); |
434 |
< |
} |
435 |
< |
|
436 |
< |
if(!the_globals->haveDielectric() ){ |
437 |
< |
sprintf( painCave.errMsg, |
438 |
< |
"SimSetup Error: You are trying to use Reaction Field without" |
439 |
< |
"setting a dielectric constant!\n" |
440 |
< |
); |
441 |
< |
painCave.isFatal = 1; |
442 |
< |
simError(); |
443 |
< |
} |
444 |
< |
simnfo->dielectric = the_globals->getDielectric(); |
445 |
< |
} else { |
446 |
< |
if (simnfo->n_dipoles) { |
447 |
< |
|
448 |
< |
if( !the_globals->haveECR() ){ |
449 |
< |
sprintf( painCave.errMsg, |
450 |
< |
"SimSetup Warning: using default value of 1/2 the smallest" |
451 |
< |
"box length for the electrostaticCutoffRadius.\n" |
452 |
< |
"I hope you have a very fast processor!\n"); |
453 |
< |
painCave.isFatal = 0; |
454 |
< |
simError(); |
455 |
< |
double smallest; |
456 |
< |
smallest = simnfo->box_x; |
457 |
< |
if (simnfo->box_y <= smallest) smallest = simnfo->box_y; |
458 |
< |
if (simnfo->box_z <= smallest) smallest = simnfo->box_z; |
459 |
< |
simnfo->ecr = 0.5 * smallest; |
460 |
< |
} else { |
461 |
< |
simnfo->ecr = the_globals->getECR(); |
462 |
< |
} |
463 |
< |
|
464 |
< |
if( !the_globals->haveEST() ){ |
465 |
< |
sprintf( painCave.errMsg, |
466 |
< |
"SimSetup Warning: using default value of 5% of the" |
467 |
< |
"electrostaticCutoffRadius for the " |
468 |
< |
"electrostaticSkinThickness\n" |
469 |
< |
); |
470 |
< |
painCave.isFatal = 0; |
471 |
< |
simError(); |
472 |
< |
simnfo->est = 0.05 * simnfo->ecr; |
473 |
< |
} else { |
474 |
< |
simnfo->est = the_globals->getEST(); |
475 |
< |
} |
476 |
< |
} |
477 |
< |
} |
393 |
> |
exI = theTorsions[j].a; |
394 |
> |
exJ = theTorsions[j].d; |
395 |
|
|
396 |
+ |
// exclude_I must always be the smaller of the pair |
397 |
+ |
if (exI > exJ){ |
398 |
+ |
tempEx = exI; |
399 |
+ |
exI = exJ; |
400 |
+ |
exJ = tempEx; |
401 |
+ |
} |
402 |
|
#ifdef IS_MPI |
403 |
< |
strcpy( checkPointMsg, "electrostatic parameters check out" ); |
404 |
< |
MPIcheckPoint(); |
405 |
< |
#endif // is_mpi |
403 |
> |
tempEx = exI; |
404 |
> |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
405 |
> |
tempEx = exJ; |
406 |
> |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
407 |
|
|
408 |
< |
if( the_globals->haveInitialConfig() ){ |
409 |
< |
|
410 |
< |
InitializeFromFile* fileInit; |
411 |
< |
#ifdef IS_MPI // is_mpi |
412 |
< |
if( worldRank == 0 ){ |
413 |
< |
#endif //is_mpi |
490 |
< |
fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); |
491 |
< |
#ifdef IS_MPI |
492 |
< |
}else fileInit = new InitializeFromFile( NULL ); |
493 |
< |
#endif |
494 |
< |
fileInit->read_xyz( simnfo ); // default velocities on |
408 |
> |
info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
409 |
> |
#else // isn't MPI |
410 |
> |
info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
411 |
> |
#endif //is_mpi |
412 |
> |
} |
413 |
> |
excludeOffset += molInfo.nTorsions; |
414 |
|
|
496 |
– |
delete fileInit; |
497 |
– |
} |
498 |
– |
else{ |
415 |
|
|
416 |
< |
#ifdef IS_MPI |
416 |
> |
// send the arrays off to the forceField for init. |
417 |
|
|
418 |
< |
// no init from bass |
419 |
< |
|
420 |
< |
sprintf( painCave.errMsg, |
421 |
< |
"Cannot intialize a parallel simulation without an initial configuration file.\n" ); |
422 |
< |
painCave.isFatal; |
507 |
< |
simError(); |
508 |
< |
|
509 |
< |
#else |
418 |
> |
the_ff->initializeAtoms(molInfo.nAtoms, molInfo.myAtoms); |
419 |
> |
the_ff->initializeBonds(molInfo.nBonds, molInfo.myBonds, theBonds); |
420 |
> |
the_ff->initializeBends(molInfo.nBends, molInfo.myBends, theBends); |
421 |
> |
the_ff->initializeTorsions(molInfo.nTorsions, molInfo.myTorsions, |
422 |
> |
theTorsions); |
423 |
|
|
511 |
– |
initFromBass(); |
424 |
|
|
425 |
+ |
info[k].molecules[i].initialize(molInfo); |
426 |
|
|
514 |
– |
#endif |
515 |
– |
} |
427 |
|
|
428 |
+ |
atomOffset += molInfo.nAtoms; |
429 |
+ |
delete[] theBonds; |
430 |
+ |
delete[] theBends; |
431 |
+ |
delete[] theTorsions; |
432 |
+ |
} |
433 |
+ |
} |
434 |
+ |
|
435 |
|
#ifdef IS_MPI |
436 |
< |
strcpy( checkPointMsg, "Successfully read in the initial configuration" ); |
436 |
> |
sprintf(checkPointMsg, "all molecules initialized succesfully"); |
437 |
|
MPIcheckPoint(); |
438 |
|
#endif // is_mpi |
439 |
|
|
440 |
+ |
// clean up the forcefield |
441 |
|
|
442 |
< |
|
443 |
< |
|
444 |
< |
|
442 |
> |
the_ff->calcRcut(); |
443 |
> |
the_ff->cleanMe(); |
444 |
> |
} |
445 |
|
|
446 |
< |
|
447 |
< |
#ifdef IS_MPI |
448 |
< |
if( worldRank == 0 ){ |
449 |
< |
#endif // is_mpi |
450 |
< |
|
451 |
< |
if( the_globals->haveFinalConfig() ){ |
452 |
< |
strcpy( simnfo->finalName, the_globals->getFinalConfig() ); |
446 |
> |
void SimSetup::initFromBass(void){ |
447 |
> |
int i, j, k; |
448 |
> |
int n_cells; |
449 |
> |
double cellx, celly, cellz; |
450 |
> |
double temp1, temp2, temp3; |
451 |
> |
int n_per_extra; |
452 |
> |
int n_extra; |
453 |
> |
int have_extra, done; |
454 |
> |
|
455 |
> |
double vel[3]; |
456 |
> |
vel[0] = 0.0; |
457 |
> |
vel[1] = 0.0; |
458 |
> |
vel[2] = 0.0; |
459 |
> |
|
460 |
> |
temp1 = (double) tot_nmol / 4.0; |
461 |
> |
temp2 = pow(temp1, (1.0 / 3.0)); |
462 |
> |
temp3 = ceil(temp2); |
463 |
> |
|
464 |
> |
have_extra = 0; |
465 |
> |
if (temp2 < temp3){ |
466 |
> |
// we have a non-complete lattice |
467 |
> |
have_extra = 1; |
468 |
> |
|
469 |
> |
n_cells = (int) temp3 - 1; |
470 |
> |
cellx = info[0].boxL[0] / temp3; |
471 |
> |
celly = info[0].boxL[1] / temp3; |
472 |
> |
cellz = info[0].boxL[2] / temp3; |
473 |
> |
n_extra = tot_nmol - (4 * n_cells * n_cells * n_cells); |
474 |
> |
temp1 = ((double) n_extra) / (pow(temp3, 3.0) - pow(n_cells, 3.0)); |
475 |
> |
n_per_extra = (int) ceil(temp1); |
476 |
> |
|
477 |
> |
if (n_per_extra > 4){ |
478 |
> |
sprintf(painCave.errMsg, |
479 |
> |
"SimSetup error. There has been an error in constructing" |
480 |
> |
" the non-complete lattice.\n"); |
481 |
> |
painCave.isFatal = 1; |
482 |
> |
simError(); |
483 |
|
} |
484 |
< |
else{ |
485 |
< |
strcpy( simnfo->finalName, inFileName ); |
486 |
< |
char* endTest; |
487 |
< |
int nameLength = strlen( simnfo->finalName ); |
488 |
< |
endTest = &(simnfo->finalName[nameLength - 5]); |
489 |
< |
if( !strcmp( endTest, ".bass" ) ){ |
490 |
< |
strcpy( endTest, ".eor" ); |
491 |
< |
} |
492 |
< |
else if( !strcmp( endTest, ".BASS" ) ){ |
493 |
< |
strcpy( endTest, ".eor" ); |
494 |
< |
} |
495 |
< |
else{ |
496 |
< |
endTest = &(simnfo->finalName[nameLength - 4]); |
497 |
< |
if( !strcmp( endTest, ".bss" ) ){ |
498 |
< |
strcpy( endTest, ".eor" ); |
499 |
< |
} |
500 |
< |
else if( !strcmp( endTest, ".mdl" ) ){ |
501 |
< |
strcpy( endTest, ".eor" ); |
502 |
< |
} |
503 |
< |
else{ |
504 |
< |
strcat( simnfo->finalName, ".eor" ); |
505 |
< |
} |
506 |
< |
} |
558 |
< |
} |
559 |
< |
|
560 |
< |
// make the sample and status out names |
561 |
< |
|
562 |
< |
strcpy( simnfo->sampleName, inFileName ); |
563 |
< |
char* endTest; |
564 |
< |
int nameLength = strlen( simnfo->sampleName ); |
565 |
< |
endTest = &(simnfo->sampleName[nameLength - 5]); |
566 |
< |
if( !strcmp( endTest, ".bass" ) ){ |
567 |
< |
strcpy( endTest, ".dump" ); |
568 |
< |
} |
569 |
< |
else if( !strcmp( endTest, ".BASS" ) ){ |
570 |
< |
strcpy( endTest, ".dump" ); |
571 |
< |
} |
572 |
< |
else{ |
573 |
< |
endTest = &(simnfo->sampleName[nameLength - 4]); |
574 |
< |
if( !strcmp( endTest, ".bss" ) ){ |
575 |
< |
strcpy( endTest, ".dump" ); |
484 |
> |
} |
485 |
> |
else{ |
486 |
> |
n_cells = (int) temp3; |
487 |
> |
cellx = info[0].boxL[0] / temp3; |
488 |
> |
celly = info[0].boxL[1] / temp3; |
489 |
> |
cellz = info[0].boxL[2] / temp3; |
490 |
> |
} |
491 |
> |
|
492 |
> |
current_mol = 0; |
493 |
> |
current_comp_mol = 0; |
494 |
> |
current_comp = 0; |
495 |
> |
current_atom_ndx = 0; |
496 |
> |
|
497 |
> |
for (i = 0; i < n_cells ; i++){ |
498 |
> |
for (j = 0; j < n_cells; j++){ |
499 |
> |
for (k = 0; k < n_cells; k++){ |
500 |
> |
makeElement(i * cellx, j * celly, k * cellz); |
501 |
> |
|
502 |
> |
makeElement(i * cellx + 0.5 * cellx, j * celly + 0.5 * celly, k * cellz); |
503 |
> |
|
504 |
> |
makeElement(i * cellx, j * celly + 0.5 * celly, k * cellz + 0.5 * cellz); |
505 |
> |
|
506 |
> |
makeElement(i * cellx + 0.5 * cellx, j * celly, k * cellz + 0.5 * cellz); |
507 |
|
} |
577 |
– |
else if( !strcmp( endTest, ".mdl" ) ){ |
578 |
– |
strcpy( endTest, ".dump" ); |
579 |
– |
} |
580 |
– |
else{ |
581 |
– |
strcat( simnfo->sampleName, ".dump" ); |
582 |
– |
} |
508 |
|
} |
509 |
< |
|
510 |
< |
strcpy( simnfo->statusName, inFileName ); |
511 |
< |
nameLength = strlen( simnfo->statusName ); |
512 |
< |
endTest = &(simnfo->statusName[nameLength - 5]); |
513 |
< |
if( !strcmp( endTest, ".bass" ) ){ |
514 |
< |
strcpy( endTest, ".stat" ); |
515 |
< |
} |
516 |
< |
else if( !strcmp( endTest, ".BASS" ) ){ |
517 |
< |
strcpy( endTest, ".stat" ); |
518 |
< |
} |
519 |
< |
else{ |
520 |
< |
endTest = &(simnfo->statusName[nameLength - 4]); |
521 |
< |
if( !strcmp( endTest, ".bss" ) ){ |
522 |
< |
strcpy( endTest, ".stat" ); |
509 |
> |
} |
510 |
> |
|
511 |
> |
if (have_extra){ |
512 |
> |
done = 0; |
513 |
> |
|
514 |
> |
int start_ndx; |
515 |
> |
for (i = 0; i < (n_cells + 1) && !done; i++){ |
516 |
> |
for (j = 0; j < (n_cells + 1) && !done; j++){ |
517 |
> |
if (i < n_cells){ |
518 |
> |
if (j < n_cells){ |
519 |
> |
start_ndx = n_cells; |
520 |
> |
} |
521 |
> |
else |
522 |
> |
start_ndx = 0; |
523 |
> |
} |
524 |
> |
else |
525 |
> |
start_ndx = 0; |
526 |
> |
|
527 |
> |
for (k = start_ndx; k < (n_cells + 1) && !done; k++){ |
528 |
> |
makeElement(i * cellx, j * celly, k * cellz); |
529 |
> |
done = (current_mol >= tot_nmol); |
530 |
> |
|
531 |
> |
if (!done && n_per_extra > 1){ |
532 |
> |
makeElement(i * cellx + 0.5 * cellx, j * celly + 0.5 * celly, |
533 |
> |
k * cellz); |
534 |
> |
done = (current_mol >= tot_nmol); |
535 |
> |
} |
536 |
> |
|
537 |
> |
if (!done && n_per_extra > 2){ |
538 |
> |
makeElement(i * cellx, j * celly + 0.5 * celly, |
539 |
> |
k * cellz + 0.5 * cellz); |
540 |
> |
done = (current_mol >= tot_nmol); |
541 |
> |
} |
542 |
> |
|
543 |
> |
if (!done && n_per_extra > 3){ |
544 |
> |
makeElement(i * cellx + 0.5 * cellx, j * celly, |
545 |
> |
k * cellz + 0.5 * cellz); |
546 |
> |
done = (current_mol >= tot_nmol); |
547 |
> |
} |
548 |
> |
} |
549 |
|
} |
599 |
– |
else if( !strcmp( endTest, ".mdl" ) ){ |
600 |
– |
strcpy( endTest, ".stat" ); |
601 |
– |
} |
602 |
– |
else{ |
603 |
– |
strcat( simnfo->statusName, ".stat" ); |
604 |
– |
} |
550 |
|
} |
606 |
– |
|
607 |
– |
#ifdef IS_MPI |
551 |
|
} |
609 |
– |
#endif // is_mpi |
610 |
– |
|
611 |
– |
// set the status, sample, and themal kick times |
612 |
– |
|
613 |
– |
if( the_globals->haveSampleTime() ){ |
614 |
– |
simnfo->sampleTime = the_globals->getSampleTime(); |
615 |
– |
simnfo->statusTime = simnfo->sampleTime; |
616 |
– |
simnfo->thermalTime = simnfo->sampleTime; |
617 |
– |
} |
618 |
– |
else{ |
619 |
– |
simnfo->sampleTime = the_globals->getRunTime(); |
620 |
– |
simnfo->statusTime = simnfo->sampleTime; |
621 |
– |
simnfo->thermalTime = simnfo->sampleTime; |
622 |
– |
} |
552 |
|
|
553 |
< |
if( the_globals->haveStatusTime() ){ |
554 |
< |
simnfo->statusTime = the_globals->getStatusTime(); |
553 |
> |
for (i = 0; i < info[0].n_atoms; i++){ |
554 |
> |
info[0].atoms[i]->setVel(vel); |
555 |
|
} |
556 |
+ |
} |
557 |
|
|
558 |
< |
if( the_globals->haveThermalTime() ){ |
559 |
< |
simnfo->thermalTime = the_globals->getThermalTime(); |
560 |
< |
} |
558 |
> |
void SimSetup::makeElement(double x, double y, double z){ |
559 |
> |
int k; |
560 |
> |
AtomStamp* current_atom; |
561 |
> |
DirectionalAtom* dAtom; |
562 |
> |
double rotMat[3][3]; |
563 |
> |
double pos[3]; |
564 |
|
|
565 |
< |
// check for the temperature set flag |
565 |
> |
for (k = 0; k < comp_stamps[current_comp]->getNAtoms(); k++){ |
566 |
> |
current_atom = comp_stamps[current_comp]->getAtom(k); |
567 |
> |
if (!current_atom->havePosition()){ |
568 |
> |
sprintf(painCave.errMsg, |
569 |
> |
"SimSetup:initFromBass error.\n" |
570 |
> |
"\tComponent %s, atom %s does not have a position specified.\n" |
571 |
> |
"\tThe initialization routine is unable to give a start" |
572 |
> |
" position.\n", |
573 |
> |
comp_stamps[current_comp]->getID(), current_atom->getType()); |
574 |
> |
painCave.isFatal = 1; |
575 |
> |
simError(); |
576 |
> |
} |
577 |
|
|
578 |
< |
if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet(); |
578 |
> |
pos[0] = x + current_atom->getPosX(); |
579 |
> |
pos[1] = y + current_atom->getPosY(); |
580 |
> |
pos[2] = z + current_atom->getPosZ(); |
581 |
|
|
582 |
+ |
info[0].atoms[current_atom_ndx]->setPos(pos); |
583 |
|
|
584 |
< |
// // make the longe range forces and the integrator |
584 |
> |
if (info[0].atoms[current_atom_ndx]->isDirectional()){ |
585 |
> |
dAtom = (DirectionalAtom *) info[0].atoms[current_atom_ndx]; |
586 |
|
|
587 |
< |
// new AllLong( simnfo ); |
587 |
> |
rotMat[0][0] = 1.0; |
588 |
> |
rotMat[0][1] = 0.0; |
589 |
> |
rotMat[0][2] = 0.0; |
590 |
|
|
591 |
< |
if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo, the_ff ); |
592 |
< |
if( !strcmp( force_field, "DipoleTest" ) ) new Symplectic( simnfo, the_ff ); |
593 |
< |
if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic( simnfo, the_ff ); |
644 |
< |
if( !strcmp( force_field, "LJ" ) ) new Verlet( *simnfo, the_ff ); |
591 |
> |
rotMat[1][0] = 0.0; |
592 |
> |
rotMat[1][1] = 1.0; |
593 |
> |
rotMat[1][2] = 0.0; |
594 |
|
|
595 |
+ |
rotMat[2][0] = 0.0; |
596 |
+ |
rotMat[2][1] = 0.0; |
597 |
+ |
rotMat[2][2] = 1.0; |
598 |
|
|
599 |
+ |
dAtom->setA(rotMat); |
600 |
+ |
} |
601 |
|
|
602 |
< |
// initialize the Fortran |
649 |
< |
|
650 |
< |
simnfo->refreshSim(); |
651 |
< |
|
652 |
< |
if( !strcmp( simnfo->mixingRule, "standard") ){ |
653 |
< |
the_ff->initForceField( LB_MIXING_RULE ); |
602 |
> |
current_atom_ndx++; |
603 |
|
} |
655 |
– |
else if( !strcmp( simnfo->mixingRule, "explicit") ){ |
656 |
– |
the_ff->initForceField( EXPLICIT_MIXING_RULE ); |
657 |
– |
} |
658 |
– |
else{ |
659 |
– |
sprintf( painCave.errMsg, |
660 |
– |
"SimSetup Error: unknown mixing rule -> \"%s\"\n", |
661 |
– |
simnfo->mixingRule ); |
662 |
– |
painCave.isFatal = 1; |
663 |
– |
simError(); |
664 |
– |
} |
604 |
|
|
605 |
+ |
current_mol++; |
606 |
+ |
current_comp_mol++; |
607 |
|
|
608 |
< |
#ifdef IS_MPI |
609 |
< |
strcpy( checkPointMsg, |
610 |
< |
"Successfully intialized the mixingRule for Fortran." ); |
611 |
< |
MPIcheckPoint(); |
671 |
< |
#endif // is_mpi |
608 |
> |
if (current_comp_mol >= components_nmol[current_comp]){ |
609 |
> |
current_comp_mol = 0; |
610 |
> |
current_comp++; |
611 |
> |
} |
612 |
|
} |
613 |
|
|
614 |
|
|
615 |
< |
void SimSetup::makeMolecules( void ){ |
615 |
> |
void SimSetup::gatherInfo(void){ |
616 |
> |
int i; |
617 |
|
|
618 |
< |
int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
619 |
< |
molInit info; |
679 |
< |
DirectionalAtom* dAtom; |
680 |
< |
LinkedAssign* extras; |
681 |
< |
LinkedAssign* current_extra; |
682 |
< |
AtomStamp* currentAtom; |
683 |
< |
BondStamp* currentBond; |
684 |
< |
BendStamp* currentBend; |
685 |
< |
TorsionStamp* currentTorsion; |
686 |
< |
|
687 |
< |
//init the forceField paramters |
618 |
> |
ensembleCase = -1; |
619 |
> |
ffCase = -1; |
620 |
|
|
621 |
< |
the_ff->readParams(); |
621 |
> |
// set the easy ones first |
622 |
|
|
623 |
< |
|
624 |
< |
// init the molecules |
623 |
> |
for (i = 0; i < nInfo; i++){ |
624 |
> |
info[i].target_temp = globals->getTargetTemp(); |
625 |
> |
info[i].dt = globals->getDt(); |
626 |
> |
info[i].run_time = globals->getRunTime(); |
627 |
> |
} |
628 |
> |
n_components = globals->getNComponents(); |
629 |
|
|
694 |
– |
atomOffset = 0; |
695 |
– |
excludeOffset = 0; |
696 |
– |
for(i=0; i<simnfo->n_mol; i++){ |
697 |
– |
|
698 |
– |
stampID = the_molecules[i].getStampID(); |
630 |
|
|
631 |
< |
info.nAtoms = comp_stamps[stampID]->getNAtoms(); |
701 |
< |
info.nBonds = comp_stamps[stampID]->getNBonds(); |
702 |
< |
info.nBends = comp_stamps[stampID]->getNBends(); |
703 |
< |
info.nTorsions = comp_stamps[stampID]->getNTorsions(); |
704 |
< |
info.nExcludes = info.nBonds + info.nBends + info.nTorsions; |
631 |
> |
// get the forceField |
632 |
|
|
633 |
< |
info.myAtoms = &the_atoms[atomOffset]; |
707 |
< |
info.myExcludes = &the_excludes[excludeOffset]; |
708 |
< |
info.myBonds = new Bond*[info.nBonds]; |
709 |
< |
info.myBends = new Bend*[info.nBends]; |
710 |
< |
info.myTorsions = new Torsions*[info.nTorsions]; |
633 |
> |
strcpy(force_field, globals->getForceField()); |
634 |
|
|
635 |
< |
theBonds = new bond_pair[info.nBonds]; |
636 |
< |
theBends = new bend_set[info.nBends]; |
637 |
< |
theTorsions = new torsion_set[info.nTorsions]; |
638 |
< |
|
639 |
< |
// make the Atoms |
640 |
< |
|
641 |
< |
for(j=0; j<info.nAtoms; j++){ |
642 |
< |
|
643 |
< |
currentAtom = theComponents[stampID]->getAtom( j ); |
644 |
< |
if( currentAtom->haveOrientation() ){ |
645 |
< |
|
646 |
< |
dAtom = new DirectionalAtom(j + atomOffset); |
647 |
< |
simnfo->n_oriented++; |
648 |
< |
info.myAtoms[j] = dAtom; |
649 |
< |
|
650 |
< |
ux = currentAtom->getOrntX(); |
651 |
< |
uy = currentAtom->getOrntY(); |
652 |
< |
uz = currentAtom->getOrntZ(); |
730 |
< |
|
731 |
< |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
732 |
< |
|
733 |
< |
u = sqrt( uSqr ); |
734 |
< |
ux = ux / u; |
735 |
< |
uy = uy / u; |
736 |
< |
uz = uz / u; |
737 |
< |
|
738 |
< |
dAtom->setSUx( ux ); |
739 |
< |
dAtom->setSUy( uy ); |
740 |
< |
dAtom->setSUz( uz ); |
741 |
< |
} |
742 |
< |
else{ |
743 |
< |
info.myAtoms[j] = new GeneralAtom(j + atomOffset); |
744 |
< |
} |
745 |
< |
info.myAtoms[j]->setType( currentAtom->getType() ); |
746 |
< |
|
747 |
< |
#ifdef IS_MPI |
748 |
< |
|
749 |
< |
info.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] ); |
750 |
< |
|
751 |
< |
#endif // is_mpi |
752 |
< |
} |
753 |
< |
|
754 |
< |
// make the bonds |
755 |
< |
for(j=0; j<info.nBonds; j++){ |
756 |
< |
|
757 |
< |
currentBond = comp_stamps[stampID]->getBond( j ); |
758 |
< |
theBonds[j].a = currentBond->getA() + atomOffset; |
759 |
< |
theBonds[j].b = currentBond->getB() + atomOffset; |
635 |
> |
if (!strcasecmp(force_field, "DUFF")){ |
636 |
> |
ffCase = FF_DUFF; |
637 |
> |
} |
638 |
> |
else if (!strcasecmp(force_field, "LJ")){ |
639 |
> |
ffCase = FF_LJ; |
640 |
> |
} |
641 |
> |
else if (!strcasecmp(force_field, "EAM")){ |
642 |
> |
ffCase = FF_EAM; |
643 |
> |
} |
644 |
> |
else if (!strcasecmp(force_field, "WATER")){ |
645 |
> |
ffCase = FF_H2O; |
646 |
> |
} |
647 |
> |
else{ |
648 |
> |
sprintf(painCave.errMsg, "SimSetup Error. Unrecognized force field -> %s\n", |
649 |
> |
force_field); |
650 |
> |
painCave.isFatal = 1; |
651 |
> |
simError(); |
652 |
> |
} |
653 |
|
|
654 |
< |
exI = theBonds[i].a; |
762 |
< |
exJ = theBonds[i].b; |
654 |
> |
// get the ensemble |
655 |
|
|
656 |
< |
// exclude_I must always be the smaller of the pair |
765 |
< |
if( exI > exJ ){ |
766 |
< |
tempEx = exI; |
767 |
< |
exI = exJ; |
768 |
< |
exJ = tempEx; |
769 |
< |
} |
770 |
< |
#ifdef IS_MPI |
771 |
< |
tempEx = exI; |
772 |
< |
exI = the_atoms[tempEx]->getGlobalIndex() + 1; |
773 |
< |
tempEx = exJ; |
774 |
< |
exJ = the_atoms[tempEx]->getGlobalIndex() + 1; |
775 |
< |
|
776 |
< |
the_excludes[j+excludeOffset]->setPair( exI, exJ ); |
777 |
< |
#else // isn't MPI |
778 |
< |
the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
779 |
< |
#endif //is_mpi |
780 |
< |
} |
781 |
< |
excludeOffset += info.nBonds; |
656 |
> |
strcpy(ensemble, globals->getEnsemble()); |
657 |
|
|
658 |
< |
//make the bends |
659 |
< |
for(j=0; j<info.nBends; j++){ |
660 |
< |
|
661 |
< |
currentBend = comp_stamps[stampID]->getBend( j ); |
662 |
< |
theBends[j].a = currentBend->getA() + atomOffset; |
663 |
< |
theBends[j].b = currentBend->getB() + atomOffset; |
664 |
< |
theBends[j].c = currentBend->getC() + atomOffset; |
665 |
< |
|
666 |
< |
if( currentBend->haveExtras() ){ |
667 |
< |
|
668 |
< |
extras = current_bend->getExtras(); |
669 |
< |
current_extra = extras; |
670 |
< |
|
671 |
< |
while( current_extra != NULL ){ |
672 |
< |
if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){ |
673 |
< |
|
674 |
< |
switch( current_extra->getType() ){ |
675 |
< |
|
676 |
< |
case 0: |
677 |
< |
theBends[j].ghost = |
678 |
< |
current_extra->getInt() + atomOffset; |
679 |
< |
theBends[j].isGhost = 1; |
680 |
< |
break; |
681 |
< |
|
682 |
< |
case 1: |
808 |
< |
theBends[j].ghost = |
809 |
< |
(int)current_extra->getDouble() + atomOffset; |
810 |
< |
theBends[j].isGhost = 1; |
811 |
< |
break; |
812 |
< |
|
813 |
< |
default: |
814 |
< |
sprintf( painCave.errMsg, |
815 |
< |
"SimSetup Error: ghostVectorSource was neiter a " |
816 |
< |
"double nor an int.\n" |
817 |
< |
"-->Bend[%d] in %s\n", |
818 |
< |
j, comp_stamps[stampID]->getID() ); |
819 |
< |
painCave.isFatal = 1; |
820 |
< |
simError(); |
821 |
< |
} |
822 |
< |
} |
823 |
< |
|
824 |
< |
else{ |
825 |
< |
|
826 |
< |
sprintf( painCave.errMsg, |
827 |
< |
"SimSetup Error: unhandled bend assignment:\n" |
828 |
< |
" -->%s in Bend[%d] in %s\n", |
829 |
< |
current_extra->getlhs(), |
830 |
< |
j, comp_stamps[stampID]->getID() ); |
831 |
< |
painCave.isFatal = 1; |
832 |
< |
simError(); |
833 |
< |
} |
834 |
< |
|
835 |
< |
current_extra = current_extra->getNext(); |
836 |
< |
} |
837 |
< |
} |
838 |
< |
|
839 |
< |
if( !theBends[j].isGhost ){ |
840 |
< |
|
841 |
< |
exI = theBends[j].a; |
842 |
< |
exJ = theBends[j].c; |
843 |
< |
} |
844 |
< |
else{ |
845 |
< |
|
846 |
< |
exI = theBends[j].a; |
847 |
< |
exJ = theBends[j].b; |
848 |
< |
} |
849 |
< |
|
850 |
< |
// exclude_I must always be the smaller of the pair |
851 |
< |
if( exI > exJ ){ |
852 |
< |
tempEx = exI; |
853 |
< |
exI = exJ; |
854 |
< |
exJ = tempEx; |
855 |
< |
} |
856 |
< |
#ifdef IS_MPI |
857 |
< |
tempEx = exI; |
858 |
< |
exI = the_atoms[tempEx]->getGlobalIndex() + 1; |
859 |
< |
tempEx = exJ; |
860 |
< |
exJ = the_atoms[tempEx]->getGlobalIndex() + 1; |
861 |
< |
|
862 |
< |
the_excludes[j+excludeOffset]->setPair( exI, exJ ); |
863 |
< |
#else // isn't MPI |
864 |
< |
the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
865 |
< |
#endif //is_mpi |
866 |
< |
} |
867 |
< |
excludeOffset += info.nBends; |
658 |
> |
if (!strcasecmp(ensemble, "NVE")){ |
659 |
> |
ensembleCase = NVE_ENS; |
660 |
> |
} |
661 |
> |
else if (!strcasecmp(ensemble, "NVT")){ |
662 |
> |
ensembleCase = NVT_ENS; |
663 |
> |
} |
664 |
> |
else if (!strcasecmp(ensemble, "NPTi") || !strcasecmp(ensemble, "NPT")){ |
665 |
> |
ensembleCase = NPTi_ENS; |
666 |
> |
} |
667 |
> |
else if (!strcasecmp(ensemble, "NPTf")){ |
668 |
> |
ensembleCase = NPTf_ENS; |
669 |
> |
} |
670 |
> |
else if (!strcasecmp(ensemble, "NPTxyz")){ |
671 |
> |
ensembleCase = NPTxyz_ENS; |
672 |
> |
} |
673 |
> |
else{ |
674 |
> |
sprintf(painCave.errMsg, |
675 |
> |
"SimSetup Warning. Unrecognized Ensemble -> %s \n" |
676 |
> |
"\treverting to NVE for this simulation.\n", |
677 |
> |
ensemble); |
678 |
> |
painCave.isFatal = 0; |
679 |
> |
simError(); |
680 |
> |
strcpy(ensemble, "NVE"); |
681 |
> |
ensembleCase = NVE_ENS; |
682 |
> |
} |
683 |
|
|
684 |
< |
for(j=0; j<info.nTorsions; j++){ |
685 |
< |
|
871 |
< |
currentTorsion = comp_stamps[stampID]->getTorsion( j ); |
872 |
< |
theTorsions[j].a = currentTorsion->getA() + atomOffset; |
873 |
< |
theTorsions[j].b = currentTorsion->getB() + atomOffset; |
874 |
< |
theTorsions[j].c = currentTorsion->getC() + atomOffset; |
875 |
< |
theTorsions[j].d = currentTorsion->getD() + atomOffset; |
876 |
< |
|
877 |
< |
exI = theTorsions[j].a; |
878 |
< |
exJ = theTorsions[j].d; |
684 |
> |
for (i = 0; i < nInfo; i++){ |
685 |
> |
strcpy(info[i].ensemble, ensemble); |
686 |
|
|
687 |
< |
// exclude_I must always be the smaller of the pair |
881 |
< |
if( exI > exJ ){ |
882 |
< |
tempEx = exI; |
883 |
< |
exI = exJ; |
884 |
< |
exJ = tempEx; |
885 |
< |
} |
886 |
< |
#ifdef IS_MPI |
887 |
< |
tempEx = exI; |
888 |
< |
exI = the_atoms[tempEx]->getGlobalIndex() + 1; |
889 |
< |
tempEx = exJ; |
890 |
< |
exJ = the_atoms[tempEx]->getGlobalIndex() + 1; |
891 |
< |
|
892 |
< |
the_excludes[j+excludeOffset]->setPair( exI, exJ ); |
893 |
< |
#else // isn't MPI |
894 |
< |
the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
895 |
< |
#endif //is_mpi |
896 |
< |
} |
897 |
< |
excludeOffset += info.nTorsions; |
687 |
> |
// get the mixing rule |
688 |
|
|
689 |
< |
|
689 |
> |
strcpy(info[i].mixingRule, globals->getMixingRule()); |
690 |
> |
info[i].usePBC = globals->getPBC(); |
691 |
> |
} |
692 |
|
|
693 |
+ |
// get the components and calculate the tot_nMol and indvidual n_mol |
694 |
|
|
695 |
+ |
the_components = globals->getComponents(); |
696 |
+ |
components_nmol = new int[n_components]; |
697 |
|
|
698 |
|
|
699 |
+ |
if (!globals->haveNMol()){ |
700 |
+ |
// we don't have the total number of molecules, so we assume it is |
701 |
+ |
// given in each component |
702 |
|
|
703 |
+ |
tot_nmol = 0; |
704 |
+ |
for (i = 0; i < n_components; i++){ |
705 |
+ |
if (!the_components[i]->haveNMol()){ |
706 |
+ |
// we have a problem |
707 |
+ |
sprintf(painCave.errMsg, |
708 |
+ |
"SimSetup Error. No global NMol or component NMol given.\n" |
709 |
+ |
"\tCannot calculate the number of atoms.\n"); |
710 |
+ |
painCave.isFatal = 1; |
711 |
+ |
simError(); |
712 |
+ |
} |
713 |
|
|
714 |
< |
void SimSetup::makeAtoms( void ){ |
714 |
> |
tot_nmol += the_components[i]->getNMol(); |
715 |
> |
components_nmol[i] = the_components[i]->getNMol(); |
716 |
> |
} |
717 |
> |
} |
718 |
> |
else{ |
719 |
> |
sprintf(painCave.errMsg, |
720 |
> |
"SimSetup error.\n" |
721 |
> |
"\tSorry, the ability to specify total" |
722 |
> |
" nMols and then give molfractions in the components\n" |
723 |
> |
"\tis not currently supported." |
724 |
> |
" Please give nMol in the components.\n"); |
725 |
> |
painCave.isFatal = 1; |
726 |
> |
simError(); |
727 |
> |
} |
728 |
|
|
729 |
< |
int i, j, k, index; |
730 |
< |
double ux, uy, uz, uSqr, u; |
731 |
< |
AtomStamp* current_atom; |
729 |
> |
//check whether sample time, status time, thermal time and reset time are divisble by dt |
730 |
> |
if (!isDivisible(globals->getSampleTime(), globals->getDt())){ |
731 |
> |
sprintf(painCave.errMsg, |
732 |
> |
"Sample time is not divisible by dt.\n" |
733 |
> |
"\tThis will result in samples that are not uniformly\n" |
734 |
> |
"\tdistributed in time. If this is a problem, change\n" |
735 |
> |
"\tyour sampleTime variable.\n"); |
736 |
> |
painCave.isFatal = 0; |
737 |
> |
simError(); |
738 |
> |
} |
739 |
|
|
740 |
< |
DirectionalAtom* dAtom; |
741 |
< |
int molIndex, molStart, molEnd, nMemb, lMolIndex; |
740 |
> |
if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
741 |
> |
sprintf(painCave.errMsg, |
742 |
> |
"Status time is not divisible by dt.\n" |
743 |
> |
"\tThis will result in status reports that are not uniformly\n" |
744 |
> |
"\tdistributed in time. If this is a problem, change \n" |
745 |
> |
"\tyour statusTime variable.\n"); |
746 |
> |
painCave.isFatal = 0; |
747 |
> |
simError(); |
748 |
> |
} |
749 |
|
|
750 |
< |
lMolIndex = 0; |
751 |
< |
molIndex = 0; |
752 |
< |
index = 0; |
753 |
< |
for( i=0; i<n_components; i++ ){ |
750 |
> |
if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ |
751 |
> |
sprintf(painCave.errMsg, |
752 |
> |
"Thermal time is not divisible by dt.\n" |
753 |
> |
"\tThis will result in thermalizations that are not uniformly\n" |
754 |
> |
"\tdistributed in time. If this is a problem, change \n" |
755 |
> |
"\tyour thermalTime variable.\n"); |
756 |
> |
painCave.isFatal = 0; |
757 |
> |
simError(); |
758 |
> |
} |
759 |
|
|
760 |
< |
for( j=0; j<components_nmol[i]; j++ ){ |
760 |
> |
if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ |
761 |
> |
sprintf(painCave.errMsg, |
762 |
> |
"Reset time is not divisible by dt.\n" |
763 |
> |
"\tThis will result in integrator resets that are not uniformly\n" |
764 |
> |
"\tdistributed in time. If this is a problem, change\n" |
765 |
> |
"\tyour resetTime variable.\n"); |
766 |
> |
painCave.isFatal = 0; |
767 |
> |
simError(); |
768 |
> |
} |
769 |
|
|
770 |
< |
#ifdef IS_MPI |
923 |
< |
if( mpiSim->getMyMolStart() <= molIndex && |
924 |
< |
molIndex <= mpiSim->getMyMolEnd() ){ |
925 |
< |
#endif // is_mpi |
770 |
> |
// set the status, sample, and thermal kick times |
771 |
|
|
772 |
< |
molStart = index; |
773 |
< |
nMemb = comp_stamps[i]->getNAtoms(); |
774 |
< |
for( k=0; k<comp_stamps[i]->getNAtoms(); k++ ){ |
775 |
< |
|
776 |
< |
current_atom = comp_stamps[i]->getAtom( k ); |
777 |
< |
if( current_atom->haveOrientation() ){ |
778 |
< |
|
779 |
< |
dAtom = new DirectionalAtom(index); |
780 |
< |
simnfo->n_oriented++; |
781 |
< |
the_atoms[index] = dAtom; |
782 |
< |
|
938 |
< |
ux = current_atom->getOrntX(); |
939 |
< |
uy = current_atom->getOrntY(); |
940 |
< |
uz = current_atom->getOrntZ(); |
941 |
< |
|
942 |
< |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
943 |
< |
|
944 |
< |
u = sqrt( uSqr ); |
945 |
< |
ux = ux / u; |
946 |
< |
uy = uy / u; |
947 |
< |
uz = uz / u; |
948 |
< |
|
949 |
< |
dAtom->setSUx( ux ); |
950 |
< |
dAtom->setSUy( uy ); |
951 |
< |
dAtom->setSUz( uz ); |
952 |
< |
} |
953 |
< |
else{ |
954 |
< |
the_atoms[index] = new GeneralAtom(index); |
955 |
< |
} |
956 |
< |
the_atoms[index]->setType( current_atom->getType() ); |
957 |
< |
the_atoms[index]->setIndex( index ); |
958 |
< |
|
959 |
< |
// increment the index and repeat; |
960 |
< |
index++; |
961 |
< |
} |
962 |
< |
|
963 |
< |
molEnd = index -1; |
964 |
< |
the_molecules[lMolIndex].setNMembers( nMemb ); |
965 |
< |
the_molecules[lMolIndex].setStartAtom( molStart ); |
966 |
< |
the_molecules[lMolIndex].setEndAtom( molEnd ); |
967 |
< |
the_molecules[lMolIndex].setStampID( i ); |
968 |
< |
lMolIndex++; |
772 |
> |
for (i = 0; i < nInfo; i++){ |
773 |
> |
if (globals->haveSampleTime()){ |
774 |
> |
info[i].sampleTime = globals->getSampleTime(); |
775 |
> |
info[i].statusTime = info[i].sampleTime; |
776 |
> |
info[i].thermalTime = info[i].sampleTime; |
777 |
> |
} |
778 |
> |
else{ |
779 |
> |
info[i].sampleTime = globals->getRunTime(); |
780 |
> |
info[i].statusTime = info[i].sampleTime; |
781 |
> |
info[i].thermalTime = info[i].sampleTime; |
782 |
> |
} |
783 |
|
|
784 |
< |
#ifdef IS_MPI |
785 |
< |
} |
972 |
< |
#endif //is_mpi |
973 |
< |
|
974 |
< |
molIndex++; |
784 |
> |
if (globals->haveStatusTime()){ |
785 |
> |
info[i].statusTime = globals->getStatusTime(); |
786 |
|
} |
976 |
– |
} |
787 |
|
|
788 |
< |
#ifdef IS_MPI |
789 |
< |
for( i=0; i<mpiSim->getMyNlocal(); i++ ) the_atoms[i]->setGlobalIndex( globalIndex[i] ); |
790 |
< |
|
981 |
< |
delete[] globalIndex; |
788 |
> |
if (globals->haveThermalTime()){ |
789 |
> |
info[i].thermalTime = globals->getThermalTime(); |
790 |
> |
} |
791 |
|
|
792 |
< |
mpiSim->mpiRefresh(); |
793 |
< |
#endif //IS_MPI |
794 |
< |
|
795 |
< |
the_ff->initializeAtoms(); |
796 |
< |
} |
792 |
> |
info[i].resetIntegrator = 0; |
793 |
> |
if( globals->haveResetTime() ){ |
794 |
> |
info[i].resetTime = globals->getResetTime(); |
795 |
> |
info[i].resetIntegrator = 1; |
796 |
> |
} |
797 |
|
|
798 |
< |
void SimSetup::makeBonds( void ){ |
798 |
> |
// check for the temperature set flag |
799 |
> |
|
800 |
> |
if (globals->haveTempSet()) |
801 |
> |
info[i].setTemp = globals->getTempSet(); |
802 |
|
|
803 |
< |
int i, j, k, index, offset, molIndex, exI, exJ, tempEx; |
992 |
< |
bond_pair* the_bonds; |
993 |
< |
BondStamp* current_bond; |
803 |
> |
// check for the extended State init |
804 |
|
|
805 |
< |
the_bonds = new bond_pair[tot_bonds]; |
806 |
< |
index = 0; |
807 |
< |
offset = 0; |
808 |
< |
molIndex = 0; |
805 |
> |
info[i].useInitXSstate = globals->getUseInitXSstate(); |
806 |
> |
info[i].orthoTolerance = globals->getOrthoBoxTolerance(); |
807 |
> |
|
808 |
> |
} |
809 |
> |
|
810 |
> |
//setup seed for random number generator |
811 |
> |
int seedValue; |
812 |
|
|
813 |
< |
for( i=0; i<n_components; i++ ){ |
813 |
> |
if (globals->haveSeed()){ |
814 |
> |
seedValue = globals->getSeed(); |
815 |
|
|
816 |
< |
for( j=0; j<components_nmol[i]; j++ ){ |
816 |
> |
if(seedValue / 1E9 == 0){ |
817 |
> |
sprintf(painCave.errMsg, |
818 |
> |
"Seed for sprng library should contain at least 9 digits\n" |
819 |
> |
"OOPSE will generate a seed for user\n"); |
820 |
> |
painCave.isFatal = 0; |
821 |
> |
simError(); |
822 |
|
|
823 |
< |
#ifdef IS_MPI |
824 |
< |
if( mpiSim->getMyMolStart() <= molIndex && |
825 |
< |
molIndex <= mpiSim->getMyMolEnd() ){ |
826 |
< |
#endif // is_mpi |
827 |
< |
|
828 |
< |
for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){ |
829 |
< |
|
830 |
< |
current_bond = comp_stamps[i]->getBond( k ); |
831 |
< |
the_bonds[index].a = current_bond->getA() + offset; |
832 |
< |
the_bonds[index].b = current_bond->getB() + offset; |
833 |
< |
|
834 |
< |
exI = the_bonds[index].a; |
835 |
< |
exJ = the_bonds[index].b; |
823 |
> |
//using seed generated by system instead of invalid seed set by user |
824 |
> |
#ifndef IS_MPI |
825 |
> |
seedValue = make_sprng_seed(); |
826 |
> |
#else |
827 |
> |
if (worldRank == 0){ |
828 |
> |
seedValue = make_sprng_seed(); |
829 |
> |
} |
830 |
> |
MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD); |
831 |
> |
#endif |
832 |
> |
} |
833 |
> |
}//end of if branch of globals->haveSeed() |
834 |
> |
else{ |
835 |
> |
|
836 |
> |
#ifndef IS_MPI |
837 |
> |
seedValue = make_sprng_seed(); |
838 |
> |
#else |
839 |
> |
if (worldRank == 0){ |
840 |
> |
seedValue = make_sprng_seed(); |
841 |
> |
} |
842 |
> |
MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD); |
843 |
> |
#endif |
844 |
> |
}//end of globals->haveSeed() |
845 |
|
|
846 |
< |
// exclude_I must always be the smaller of the pair |
847 |
< |
if( exI > exJ ){ |
848 |
< |
tempEx = exI; |
849 |
< |
exI = exJ; |
1022 |
< |
exJ = tempEx; |
1023 |
< |
} |
1024 |
< |
|
1025 |
< |
|
846 |
> |
for (int i = 0; i < nInfo; i++){ |
847 |
> |
info[i].setSeed(seedValue); |
848 |
> |
} |
849 |
> |
|
850 |
|
#ifdef IS_MPI |
851 |
+ |
strcpy(checkPointMsg, "Successfully gathered all information from Bass\n"); |
852 |
+ |
MPIcheckPoint(); |
853 |
+ |
#endif // is_mpi |
854 |
+ |
} |
855 |
|
|
1028 |
– |
the_excludes[index*2] = |
1029 |
– |
the_atoms[exI]->getGlobalIndex() + 1; |
1030 |
– |
the_excludes[index*2 + 1] = |
1031 |
– |
the_atoms[exJ]->getGlobalIndex() + 1; |
856 |
|
|
857 |
< |
#else // isn't MPI |
858 |
< |
|
859 |
< |
the_excludes[index*2] = exI + 1; |
860 |
< |
the_excludes[index*2 + 1] = exJ + 1; |
861 |
< |
// fortran index from 1 (hence the +1 in the indexing) |
862 |
< |
#endif //is_mpi |
863 |
< |
|
864 |
< |
// increment the index and repeat; |
865 |
< |
index++; |
866 |
< |
} |
867 |
< |
offset += comp_stamps[i]->getNAtoms(); |
868 |
< |
|
857 |
> |
void SimSetup::finalInfoCheck(void){ |
858 |
> |
int index; |
859 |
> |
int usesDipoles; |
860 |
> |
int i; |
861 |
> |
|
862 |
> |
for (i = 0; i < nInfo; i++){ |
863 |
> |
// check electrostatic parameters |
864 |
> |
|
865 |
> |
index = 0; |
866 |
> |
usesDipoles = 0; |
867 |
> |
while ((index < info[i].n_atoms) && !usesDipoles){ |
868 |
> |
usesDipoles = (info[i].atoms[index])->hasDipole(); |
869 |
> |
index++; |
870 |
> |
} |
871 |
> |
|
872 |
|
#ifdef IS_MPI |
873 |
< |
} |
873 |
> |
int myUse = usesDipoles; |
874 |
> |
MPI_Allreduce(&myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
875 |
|
#endif //is_mpi |
1048 |
– |
|
1049 |
– |
molIndex++; |
1050 |
– |
} |
1051 |
– |
} |
876 |
|
|
877 |
< |
the_ff->initializeBonds( the_bonds ); |
1054 |
< |
} |
877 |
> |
double theEcr, theEst; |
878 |
|
|
879 |
< |
void SimSetup::makeBends( void ){ |
879 |
> |
if (globals->getUseRF()){ |
880 |
> |
info[i].useReactionField = 1; |
881 |
|
|
882 |
< |
int i, j, k, index, offset, molIndex, exI, exJ, tempEx; |
883 |
< |
bend_set* the_bends; |
884 |
< |
BendStamp* current_bend; |
885 |
< |
LinkedAssign* extras; |
886 |
< |
LinkedAssign* current_extra; |
887 |
< |
|
882 |
> |
if (!globals->haveECR()){ |
883 |
> |
sprintf(painCave.errMsg, |
884 |
> |
"SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
885 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
886 |
> |
"\tfor the electrostaticCutoffRadius.\n"); |
887 |
> |
painCave.isFatal = 0; |
888 |
> |
simError(); |
889 |
> |
theEcr = 15.0; |
890 |
> |
} |
891 |
> |
else{ |
892 |
> |
theEcr = globals->getECR(); |
893 |
> |
} |
894 |
|
|
895 |
< |
the_bends = new bend_set[tot_bends]; |
896 |
< |
index = 0; |
897 |
< |
offset = 0; |
898 |
< |
molIndex = 0; |
899 |
< |
for( i=0; i<n_components; i++ ){ |
895 |
> |
if (!globals->haveEST()){ |
896 |
> |
sprintf(painCave.errMsg, |
897 |
> |
"SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
898 |
> |
"\tOOPSE will use a default value of\n" |
899 |
> |
"\t0.05 * electrostaticCutoffRadius\n" |
900 |
> |
"\tfor the electrostaticSkinThickness\n"); |
901 |
> |
painCave.isFatal = 0; |
902 |
> |
simError(); |
903 |
> |
theEst = 0.05 * theEcr; |
904 |
> |
} |
905 |
> |
else{ |
906 |
> |
theEst = globals->getEST(); |
907 |
> |
} |
908 |
|
|
909 |
< |
for( j=0; j<components_nmol[i]; j++ ){ |
909 |
> |
info[i].setDefaultEcr(theEcr, theEst); |
910 |
|
|
911 |
+ |
if (!globals->haveDielectric()){ |
912 |
+ |
sprintf(painCave.errMsg, |
913 |
+ |
"SimSetup Error: No Dielectric constant was set.\n" |
914 |
+ |
"\tYou are trying to use Reaction Field without" |
915 |
+ |
"\tsetting a dielectric constant!\n"); |
916 |
+ |
painCave.isFatal = 1; |
917 |
+ |
simError(); |
918 |
+ |
} |
919 |
+ |
info[i].dielectric = globals->getDielectric(); |
920 |
+ |
} |
921 |
+ |
else{ |
922 |
+ |
if (usesDipoles){ |
923 |
+ |
if (!globals->haveECR()){ |
924 |
+ |
sprintf(painCave.errMsg, |
925 |
+ |
"SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
926 |
+ |
"\tOOPSE will use a default value of 15.0 angstroms" |
927 |
+ |
"\tfor the electrostaticCutoffRadius.\n"); |
928 |
+ |
painCave.isFatal = 0; |
929 |
+ |
simError(); |
930 |
+ |
theEcr = 15.0; |
931 |
+ |
} |
932 |
+ |
else{ |
933 |
+ |
theEcr = globals->getECR(); |
934 |
+ |
} |
935 |
+ |
|
936 |
+ |
if (!globals->haveEST()){ |
937 |
+ |
sprintf(painCave.errMsg, |
938 |
+ |
"SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
939 |
+ |
"\tOOPSE will use a default value of\n" |
940 |
+ |
"\t0.05 * electrostaticCutoffRadius\n" |
941 |
+ |
"\tfor the electrostaticSkinThickness\n"); |
942 |
+ |
painCave.isFatal = 0; |
943 |
+ |
simError(); |
944 |
+ |
theEst = 0.05 * theEcr; |
945 |
+ |
} |
946 |
+ |
else{ |
947 |
+ |
theEst = globals->getEST(); |
948 |
+ |
} |
949 |
+ |
|
950 |
+ |
info[i].setDefaultEcr(theEcr, theEst); |
951 |
+ |
} |
952 |
+ |
} |
953 |
+ |
} |
954 |
|
#ifdef IS_MPI |
955 |
< |
if( mpiSim->getMyMolStart() <= molIndex && |
956 |
< |
molIndex <= mpiSim->getMyMolEnd() ){ |
957 |
< |
#endif // is_mpi |
955 |
> |
strcpy(checkPointMsg, "post processing checks out"); |
956 |
> |
MPIcheckPoint(); |
957 |
> |
#endif // is_mpi |
958 |
> |
} |
959 |
> |
|
960 |
> |
void SimSetup::initSystemCoords(void){ |
961 |
> |
int i; |
962 |
|
|
963 |
< |
for( k=0; k<comp_stamps[i]->getNBends(); k++ ){ |
1079 |
< |
|
1080 |
< |
current_bend = comp_stamps[i]->getBend( k ); |
1081 |
< |
the_bends[index].a = current_bend->getA() + offset; |
1082 |
< |
the_bends[index].b = current_bend->getB() + offset; |
1083 |
< |
the_bends[index].c = current_bend->getC() + offset; |
1084 |
< |
|
1085 |
< |
if( current_bend->haveExtras() ){ |
1086 |
< |
|
1087 |
< |
extras = current_bend->getExtras(); |
1088 |
< |
current_extra = extras; |
1089 |
< |
|
1090 |
< |
while( current_extra != NULL ){ |
1091 |
< |
if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){ |
1092 |
< |
|
1093 |
< |
switch( current_extra->getType() ){ |
1094 |
< |
|
1095 |
< |
case 0: |
1096 |
< |
the_bends[index].ghost = |
1097 |
< |
current_extra->getInt() + offset; |
1098 |
< |
the_bends[index].isGhost = 1; |
1099 |
< |
break; |
1100 |
< |
|
1101 |
< |
case 1: |
1102 |
< |
the_bends[index].ghost = |
1103 |
< |
(int)current_extra->getDouble() + offset; |
1104 |
< |
the_bends[index].isGhost = 1; |
1105 |
< |
break; |
1106 |
< |
|
1107 |
< |
default: |
1108 |
< |
sprintf( painCave.errMsg, |
1109 |
< |
"SimSetup Error: ghostVectorSource was neiter a " |
1110 |
< |
"double nor an int.\n" |
1111 |
< |
"-->Bend[%d] in %s\n", |
1112 |
< |
k, comp_stamps[i]->getID() ); |
1113 |
< |
painCave.isFatal = 1; |
1114 |
< |
simError(); |
1115 |
< |
} |
1116 |
< |
} |
1117 |
< |
|
1118 |
< |
else{ |
1119 |
< |
|
1120 |
< |
sprintf( painCave.errMsg, |
1121 |
< |
"SimSetup Error: unhandled bend assignment:\n" |
1122 |
< |
" -->%s in Bend[%d] in %s\n", |
1123 |
< |
current_extra->getlhs(), |
1124 |
< |
k, comp_stamps[i]->getID() ); |
1125 |
< |
painCave.isFatal = 1; |
1126 |
< |
simError(); |
1127 |
< |
} |
1128 |
< |
|
1129 |
< |
current_extra = current_extra->getNext(); |
1130 |
< |
} |
1131 |
< |
} |
1132 |
< |
|
1133 |
< |
if( !the_bends[index].isGhost ){ |
1134 |
< |
|
1135 |
< |
exI = the_bends[index].a; |
1136 |
< |
exJ = the_bends[index].c; |
1137 |
< |
} |
1138 |
< |
else{ |
1139 |
< |
|
1140 |
< |
exI = the_bends[index].a; |
1141 |
< |
exJ = the_bends[index].b; |
1142 |
< |
} |
1143 |
< |
|
1144 |
< |
// exclude_I must always be the smaller of the pair |
1145 |
< |
if( exI > exJ ){ |
1146 |
< |
tempEx = exI; |
1147 |
< |
exI = exJ; |
1148 |
< |
exJ = tempEx; |
1149 |
< |
} |
963 |
> |
char* inName; |
964 |
|
|
965 |
+ |
(info[0].getConfiguration())->createArrays(info[0].n_atoms); |
966 |
|
|
967 |
< |
#ifdef IS_MPI |
967 |
> |
for (i = 0; i < info[0].n_atoms; i++) |
968 |
> |
info[0].atoms[i]->setCoords(); |
969 |
|
|
970 |
< |
the_excludes[(index + tot_bonds)*2] = |
971 |
< |
the_atoms[exI]->getGlobalIndex() + 1; |
972 |
< |
the_excludes[(index + tot_bonds)*2 + 1] = |
973 |
< |
the_atoms[exJ]->getGlobalIndex() + 1; |
1158 |
< |
|
1159 |
< |
#else // isn't MPI |
1160 |
< |
|
1161 |
< |
the_excludes[(index + tot_bonds)*2] = exI + 1; |
1162 |
< |
the_excludes[(index + tot_bonds)*2 + 1] = exJ + 1; |
1163 |
< |
// fortran index from 1 (hence the +1 in the indexing) |
1164 |
< |
#endif //is_mpi |
1165 |
< |
|
1166 |
< |
|
1167 |
< |
// increment the index and repeat; |
1168 |
< |
index++; |
1169 |
< |
} |
1170 |
< |
offset += comp_stamps[i]->getNAtoms(); |
1171 |
< |
|
1172 |
< |
#ifdef IS_MPI |
1173 |
< |
} |
970 |
> |
if (globals->haveInitialConfig()){ |
971 |
> |
InitializeFromFile* fileInit; |
972 |
> |
#ifdef IS_MPI // is_mpi |
973 |
> |
if (worldRank == 0){ |
974 |
|
#endif //is_mpi |
975 |
< |
|
976 |
< |
molIndex++; |
975 |
> |
inName = globals->getInitialConfig(); |
976 |
> |
fileInit = new InitializeFromFile(inName); |
977 |
> |
#ifdef IS_MPI |
978 |
|
} |
979 |
+ |
else |
980 |
+ |
fileInit = new InitializeFromFile(NULL); |
981 |
+ |
#endif |
982 |
+ |
fileInit->readInit(info); // default velocities on |
983 |
+ |
|
984 |
+ |
delete fileInit; |
985 |
|
} |
986 |
+ |
else{ |
987 |
+ |
|
988 |
+ |
// no init from bass |
989 |
+ |
|
990 |
+ |
sprintf(painCave.errMsg, |
991 |
+ |
"Cannot intialize a simulation without an initial configuration file.\n"); |
992 |
+ |
painCave.isFatal = 1;; |
993 |
+ |
simError(); |
994 |
+ |
|
995 |
+ |
} |
996 |
|
|
997 |
|
#ifdef IS_MPI |
998 |
< |
sprintf( checkPointMsg, |
1182 |
< |
"Successfully created the bends list.\n" ); |
998 |
> |
strcpy(checkPointMsg, "Successfully read in the initial configuration"); |
999 |
|
MPIcheckPoint(); |
1000 |
|
#endif // is_mpi |
1185 |
– |
|
1186 |
– |
|
1187 |
– |
the_ff->initializeBends( the_bends ); |
1001 |
|
} |
1002 |
|
|
1190 |
– |
void SimSetup::makeTorsions( void ){ |
1003 |
|
|
1004 |
< |
int i, j, k, index, offset, molIndex, exI, exJ, tempEx; |
1005 |
< |
torsion_set* the_torsions; |
1194 |
< |
TorsionStamp* current_torsion; |
1004 |
> |
void SimSetup::makeOutNames(void){ |
1005 |
> |
int k; |
1006 |
|
|
1196 |
– |
the_torsions = new torsion_set[tot_torsions]; |
1197 |
– |
index = 0; |
1198 |
– |
offset = 0; |
1199 |
– |
molIndex = 0; |
1200 |
– |
for( i=0; i<n_components; i++ ){ |
1007 |
|
|
1008 |
< |
for( j=0; j<components_nmol[i]; j++ ){ |
1008 |
> |
for (k = 0; k < nInfo; k++){ |
1009 |
> |
#ifdef IS_MPI |
1010 |
> |
if (worldRank == 0){ |
1011 |
> |
#endif // is_mpi |
1012 |
|
|
1013 |
+ |
if (globals->haveFinalConfig()){ |
1014 |
+ |
strcpy(info[k].finalName, globals->getFinalConfig()); |
1015 |
+ |
} |
1016 |
+ |
else{ |
1017 |
+ |
strcpy(info[k].finalName, inFileName); |
1018 |
+ |
char* endTest; |
1019 |
+ |
int nameLength = strlen(info[k].finalName); |
1020 |
+ |
endTest = &(info[k].finalName[nameLength - 5]); |
1021 |
+ |
if (!strcmp(endTest, ".bass")){ |
1022 |
+ |
strcpy(endTest, ".eor"); |
1023 |
+ |
} |
1024 |
+ |
else if (!strcmp(endTest, ".BASS")){ |
1025 |
+ |
strcpy(endTest, ".eor"); |
1026 |
+ |
} |
1027 |
+ |
else{ |
1028 |
+ |
endTest = &(info[k].finalName[nameLength - 4]); |
1029 |
+ |
if (!strcmp(endTest, ".bss")){ |
1030 |
+ |
strcpy(endTest, ".eor"); |
1031 |
+ |
} |
1032 |
+ |
else if (!strcmp(endTest, ".mdl")){ |
1033 |
+ |
strcpy(endTest, ".eor"); |
1034 |
+ |
} |
1035 |
+ |
else{ |
1036 |
+ |
strcat(info[k].finalName, ".eor"); |
1037 |
+ |
} |
1038 |
+ |
} |
1039 |
+ |
} |
1040 |
+ |
|
1041 |
+ |
// make the sample and status out names |
1042 |
+ |
|
1043 |
+ |
strcpy(info[k].sampleName, inFileName); |
1044 |
+ |
char* endTest; |
1045 |
+ |
int nameLength = strlen(info[k].sampleName); |
1046 |
+ |
endTest = &(info[k].sampleName[nameLength - 5]); |
1047 |
+ |
if (!strcmp(endTest, ".bass")){ |
1048 |
+ |
strcpy(endTest, ".dump"); |
1049 |
+ |
} |
1050 |
+ |
else if (!strcmp(endTest, ".BASS")){ |
1051 |
+ |
strcpy(endTest, ".dump"); |
1052 |
+ |
} |
1053 |
+ |
else{ |
1054 |
+ |
endTest = &(info[k].sampleName[nameLength - 4]); |
1055 |
+ |
if (!strcmp(endTest, ".bss")){ |
1056 |
+ |
strcpy(endTest, ".dump"); |
1057 |
+ |
} |
1058 |
+ |
else if (!strcmp(endTest, ".mdl")){ |
1059 |
+ |
strcpy(endTest, ".dump"); |
1060 |
+ |
} |
1061 |
+ |
else{ |
1062 |
+ |
strcat(info[k].sampleName, ".dump"); |
1063 |
+ |
} |
1064 |
+ |
} |
1065 |
+ |
|
1066 |
+ |
strcpy(info[k].statusName, inFileName); |
1067 |
+ |
nameLength = strlen(info[k].statusName); |
1068 |
+ |
endTest = &(info[k].statusName[nameLength - 5]); |
1069 |
+ |
if (!strcmp(endTest, ".bass")){ |
1070 |
+ |
strcpy(endTest, ".stat"); |
1071 |
+ |
} |
1072 |
+ |
else if (!strcmp(endTest, ".BASS")){ |
1073 |
+ |
strcpy(endTest, ".stat"); |
1074 |
+ |
} |
1075 |
+ |
else{ |
1076 |
+ |
endTest = &(info[k].statusName[nameLength - 4]); |
1077 |
+ |
if (!strcmp(endTest, ".bss")){ |
1078 |
+ |
strcpy(endTest, ".stat"); |
1079 |
+ |
} |
1080 |
+ |
else if (!strcmp(endTest, ".mdl")){ |
1081 |
+ |
strcpy(endTest, ".stat"); |
1082 |
+ |
} |
1083 |
+ |
else{ |
1084 |
+ |
strcat(info[k].statusName, ".stat"); |
1085 |
+ |
} |
1086 |
+ |
} |
1087 |
+ |
|
1088 |
|
#ifdef IS_MPI |
1205 |
– |
if( mpiSim->getMyMolStart() <= molIndex && |
1206 |
– |
molIndex <= mpiSim->getMyMolEnd() ){ |
1207 |
– |
#endif // is_mpi |
1089 |
|
|
1090 |
< |
for( k=0; k<comp_stamps[i]->getNTorsions(); k++ ){ |
1090 |
> |
} |
1091 |
> |
#endif // is_mpi |
1092 |
> |
} |
1093 |
> |
} |
1094 |
|
|
1211 |
– |
current_torsion = comp_stamps[i]->getTorsion( k ); |
1212 |
– |
the_torsions[index].a = current_torsion->getA() + offset; |
1213 |
– |
the_torsions[index].b = current_torsion->getB() + offset; |
1214 |
– |
the_torsions[index].c = current_torsion->getC() + offset; |
1215 |
– |
the_torsions[index].d = current_torsion->getD() + offset; |
1095 |
|
|
1096 |
< |
exI = the_torsions[index].a; |
1097 |
< |
exJ = the_torsions[index].d; |
1096 |
> |
void SimSetup::sysObjectsCreation(void){ |
1097 |
> |
int i, k; |
1098 |
|
|
1099 |
< |
|
1100 |
< |
// exclude_I must always be the smaller of the pair |
1101 |
< |
if( exI > exJ ){ |
1102 |
< |
tempEx = exI; |
1103 |
< |
exI = exJ; |
1104 |
< |
exJ = tempEx; |
1105 |
< |
} |
1099 |
> |
// create the forceField |
1100 |
> |
|
1101 |
> |
createFF(); |
1102 |
> |
|
1103 |
> |
// extract componentList |
1104 |
> |
|
1105 |
> |
compList(); |
1106 |
|
|
1107 |
+ |
// calc the number of atoms, bond, bends, and torsions |
1108 |
|
|
1109 |
+ |
calcSysValues(); |
1110 |
+ |
|
1111 |
|
#ifdef IS_MPI |
1112 |
< |
|
1231 |
< |
the_excludes[(index + tot_bonds + tot_bends)*2] = |
1232 |
< |
the_atoms[exI]->getGlobalIndex() + 1; |
1233 |
< |
the_excludes[(index + tot_bonds + tot_bends)*2 + 1] = |
1234 |
< |
the_atoms[exJ]->getGlobalIndex() + 1; |
1235 |
< |
|
1236 |
< |
#else // isn't MPI |
1237 |
< |
|
1238 |
< |
the_excludes[(index + tot_bonds + tot_bends)*2] = exI + 1; |
1239 |
< |
the_excludes[(index + tot_bonds + tot_bends)*2 + 1] = exJ + 1; |
1240 |
< |
// fortran indexes from 1 (hence the +1 in the indexing) |
1241 |
< |
#endif //is_mpi |
1242 |
< |
|
1112 |
> |
// divide the molecules among the processors |
1113 |
|
|
1114 |
< |
// increment the index and repeat; |
1115 |
< |
index++; |
1246 |
< |
} |
1247 |
< |
offset += comp_stamps[i]->getNAtoms(); |
1114 |
> |
mpiMolDivide(); |
1115 |
> |
#endif //is_mpi |
1116 |
|
|
1117 |
< |
#ifdef IS_MPI |
1250 |
< |
} |
1251 |
< |
#endif //is_mpi |
1117 |
> |
// create the atom and SRI arrays. Also initialize Molecule Stamp ID's |
1118 |
|
|
1119 |
< |
molIndex++; |
1119 |
> |
makeSysArrays(); |
1120 |
> |
|
1121 |
> |
// make and initialize the molecules (all but atomic coordinates) |
1122 |
> |
|
1123 |
> |
makeMolecules(); |
1124 |
> |
|
1125 |
> |
for (k = 0; k < nInfo; k++){ |
1126 |
> |
info[k].identArray = new int[info[k].n_atoms]; |
1127 |
> |
for (i = 0; i < info[k].n_atoms; i++){ |
1128 |
> |
info[k].identArray[i] = info[k].atoms[i]->getIdent(); |
1129 |
|
} |
1130 |
|
} |
1256 |
– |
|
1257 |
– |
the_ff->initializeTorsions( the_torsions ); |
1131 |
|
} |
1132 |
|
|
1260 |
– |
void SimSetup::initFromBass( void ){ |
1133 |
|
|
1134 |
< |
int i, j, k; |
1135 |
< |
int n_cells; |
1136 |
< |
double cellx, celly, cellz; |
1137 |
< |
double temp1, temp2, temp3; |
1138 |
< |
int n_per_extra; |
1267 |
< |
int n_extra; |
1268 |
< |
int have_extra, done; |
1134 |
> |
void SimSetup::createFF(void){ |
1135 |
> |
switch (ffCase){ |
1136 |
> |
case FF_DUFF: |
1137 |
> |
the_ff = new DUFF(); |
1138 |
> |
break; |
1139 |
|
|
1140 |
< |
temp1 = (double)tot_nmol / 4.0; |
1141 |
< |
temp2 = pow( temp1, ( 1.0 / 3.0 ) ); |
1142 |
< |
temp3 = ceil( temp2 ); |
1140 |
> |
case FF_LJ: |
1141 |
> |
the_ff = new LJFF(); |
1142 |
> |
break; |
1143 |
|
|
1144 |
< |
have_extra =0; |
1145 |
< |
if( temp2 < temp3 ){ // we have a non-complete lattice |
1146 |
< |
have_extra =1; |
1144 |
> |
case FF_EAM: |
1145 |
> |
the_ff = new EAM_FF(); |
1146 |
> |
break; |
1147 |
|
|
1148 |
< |
n_cells = (int)temp3 - 1; |
1149 |
< |
cellx = simnfo->box_x / temp3; |
1150 |
< |
celly = simnfo->box_y / temp3; |
1281 |
< |
cellz = simnfo->box_z / temp3; |
1282 |
< |
n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells ); |
1283 |
< |
temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) ); |
1284 |
< |
n_per_extra = (int)ceil( temp1 ); |
1148 |
> |
case FF_H2O: |
1149 |
> |
the_ff = new WATER(); |
1150 |
> |
break; |
1151 |
|
|
1152 |
< |
if( n_per_extra > 4){ |
1153 |
< |
sprintf( painCave.errMsg, |
1154 |
< |
"SimSetup error. There has been an error in constructing" |
1289 |
< |
" the non-complete lattice.\n" ); |
1152 |
> |
default: |
1153 |
> |
sprintf(painCave.errMsg, |
1154 |
> |
"SimSetup Error. Unrecognized force field in case statement.\n"); |
1155 |
|
painCave.isFatal = 1; |
1156 |
|
simError(); |
1292 |
– |
} |
1157 |
|
} |
1294 |
– |
else{ |
1295 |
– |
n_cells = (int)temp3; |
1296 |
– |
cellx = simnfo->box_x / temp3; |
1297 |
– |
celly = simnfo->box_y / temp3; |
1298 |
– |
cellz = simnfo->box_z / temp3; |
1299 |
– |
} |
1158 |
|
|
1159 |
< |
current_mol = 0; |
1160 |
< |
current_comp_mol = 0; |
1161 |
< |
current_comp = 0; |
1162 |
< |
current_atom_ndx = 0; |
1159 |
> |
#ifdef IS_MPI |
1160 |
> |
strcpy(checkPointMsg, "ForceField creation successful"); |
1161 |
> |
MPIcheckPoint(); |
1162 |
> |
#endif // is_mpi |
1163 |
> |
} |
1164 |
|
|
1306 |
– |
for( i=0; i < n_cells ; i++ ){ |
1307 |
– |
for( j=0; j < n_cells; j++ ){ |
1308 |
– |
for( k=0; k < n_cells; k++ ){ |
1165 |
|
|
1166 |
< |
makeElement( i * cellx, |
1167 |
< |
j * celly, |
1168 |
< |
k * cellz ); |
1166 |
> |
void SimSetup::compList(void){ |
1167 |
> |
int i; |
1168 |
> |
char* id; |
1169 |
> |
LinkedMolStamp* headStamp = new LinkedMolStamp(); |
1170 |
> |
LinkedMolStamp* currentStamp = NULL; |
1171 |
> |
comp_stamps = new MoleculeStamp * [n_components]; |
1172 |
|
|
1173 |
< |
makeElement( i * cellx + 0.5 * cellx, |
1174 |
< |
j * celly + 0.5 * celly, |
1316 |
< |
k * cellz ); |
1173 |
> |
// make an array of molecule stamps that match the components used. |
1174 |
> |
// also extract the used stamps out into a separate linked list |
1175 |
|
|
1176 |
< |
makeElement( i * cellx, |
1177 |
< |
j * celly + 0.5 * celly, |
1178 |
< |
k * cellz + 0.5 * cellz ); |
1176 |
> |
for (i = 0; i < nInfo; i++){ |
1177 |
> |
info[i].nComponents = n_components; |
1178 |
> |
info[i].componentsNmol = components_nmol; |
1179 |
> |
info[i].compStamps = comp_stamps; |
1180 |
> |
info[i].headStamp = headStamp; |
1181 |
> |
} |
1182 |
|
|
1183 |
< |
makeElement( i * cellx + 0.5 * cellx, |
1184 |
< |
j * celly, |
1185 |
< |
k * cellz + 0.5 * cellz ); |
1183 |
> |
|
1184 |
> |
for (i = 0; i < n_components; i++){ |
1185 |
> |
id = the_components[i]->getType(); |
1186 |
> |
comp_stamps[i] = NULL; |
1187 |
> |
|
1188 |
> |
// check to make sure the component isn't already in the list |
1189 |
> |
|
1190 |
> |
comp_stamps[i] = headStamp->match(id); |
1191 |
> |
if (comp_stamps[i] == NULL){ |
1192 |
> |
// extract the component from the list; |
1193 |
> |
|
1194 |
> |
currentStamp = stamps->extractMolStamp(id); |
1195 |
> |
if (currentStamp == NULL){ |
1196 |
> |
sprintf(painCave.errMsg, |
1197 |
> |
"SimSetup error: Component \"%s\" was not found in the " |
1198 |
> |
"list of declared molecules\n", |
1199 |
> |
id); |
1200 |
> |
painCave.isFatal = 1; |
1201 |
> |
simError(); |
1202 |
|
} |
1203 |
+ |
|
1204 |
+ |
headStamp->add(currentStamp); |
1205 |
+ |
comp_stamps[i] = headStamp->match(id); |
1206 |
|
} |
1207 |
|
} |
1208 |
|
|
1209 |
< |
if( have_extra ){ |
1210 |
< |
done = 0; |
1209 |
> |
#ifdef IS_MPI |
1210 |
> |
strcpy(checkPointMsg, "Component stamps successfully extracted\n"); |
1211 |
> |
MPIcheckPoint(); |
1212 |
> |
#endif // is_mpi |
1213 |
> |
} |
1214 |
|
|
1215 |
< |
int start_ndx; |
1216 |
< |
for( i=0; i < (n_cells+1) && !done; i++ ){ |
1334 |
< |
for( j=0; j < (n_cells+1) && !done; j++ ){ |
1215 |
> |
void SimSetup::calcSysValues(void){ |
1216 |
> |
int i; |
1217 |
|
|
1218 |
< |
if( i < n_cells ){ |
1218 |
> |
int* molMembershipArray; |
1219 |
|
|
1220 |
< |
if( j < n_cells ){ |
1221 |
< |
start_ndx = n_cells; |
1222 |
< |
} |
1223 |
< |
else start_ndx = 0; |
1224 |
< |
} |
1225 |
< |
else start_ndx = 0; |
1220 |
> |
tot_atoms = 0; |
1221 |
> |
tot_bonds = 0; |
1222 |
> |
tot_bends = 0; |
1223 |
> |
tot_torsions = 0; |
1224 |
> |
for (i = 0; i < n_components; i++){ |
1225 |
> |
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
1226 |
> |
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
1227 |
> |
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
1228 |
> |
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
1229 |
> |
} |
1230 |
|
|
1231 |
< |
for( k=start_ndx; k < (n_cells+1) && !done; k++ ){ |
1231 |
> |
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
1232 |
> |
molMembershipArray = new int[tot_atoms]; |
1233 |
|
|
1234 |
< |
makeElement( i * cellx, |
1235 |
< |
j * celly, |
1236 |
< |
k * cellz ); |
1237 |
< |
done = ( current_mol >= tot_nmol ); |
1234 |
> |
for (i = 0; i < nInfo; i++){ |
1235 |
> |
info[i].n_atoms = tot_atoms; |
1236 |
> |
info[i].n_bonds = tot_bonds; |
1237 |
> |
info[i].n_bends = tot_bends; |
1238 |
> |
info[i].n_torsions = tot_torsions; |
1239 |
> |
info[i].n_SRI = tot_SRI; |
1240 |
> |
info[i].n_mol = tot_nmol; |
1241 |
|
|
1242 |
< |
if( !done && n_per_extra > 1 ){ |
1243 |
< |
makeElement( i * cellx + 0.5 * cellx, |
1244 |
< |
j * celly + 0.5 * celly, |
1355 |
< |
k * cellz ); |
1356 |
< |
done = ( current_mol >= tot_nmol ); |
1357 |
< |
} |
1242 |
> |
info[i].molMembershipArray = molMembershipArray; |
1243 |
> |
} |
1244 |
> |
} |
1245 |
|
|
1246 |
< |
if( !done && n_per_extra > 2){ |
1360 |
< |
makeElement( i * cellx, |
1361 |
< |
j * celly + 0.5 * celly, |
1362 |
< |
k * cellz + 0.5 * cellz ); |
1363 |
< |
done = ( current_mol >= tot_nmol ); |
1364 |
< |
} |
1246 |
> |
#ifdef IS_MPI |
1247 |
|
|
1248 |
< |
if( !done && n_per_extra > 3){ |
1249 |
< |
makeElement( i * cellx + 0.5 * cellx, |
1250 |
< |
j * celly, |
1251 |
< |
k * cellz + 0.5 * cellz ); |
1252 |
< |
done = ( current_mol >= tot_nmol ); |
1253 |
< |
} |
1254 |
< |
} |
1248 |
> |
void SimSetup::mpiMolDivide(void){ |
1249 |
> |
int i, j, k; |
1250 |
> |
int localMol, allMol; |
1251 |
> |
int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
1252 |
> |
|
1253 |
> |
mpiSim = new mpiSimulation(info); |
1254 |
> |
|
1255 |
> |
globalIndex = mpiSim->divideLabor(); |
1256 |
> |
|
1257 |
> |
// set up the local variables |
1258 |
> |
|
1259 |
> |
mol2proc = mpiSim->getMolToProcMap(); |
1260 |
> |
molCompType = mpiSim->getMolComponentType(); |
1261 |
> |
|
1262 |
> |
allMol = 0; |
1263 |
> |
localMol = 0; |
1264 |
> |
local_atoms = 0; |
1265 |
> |
local_bonds = 0; |
1266 |
> |
local_bends = 0; |
1267 |
> |
local_torsions = 0; |
1268 |
> |
globalAtomIndex = 0; |
1269 |
> |
|
1270 |
> |
|
1271 |
> |
for (i = 0; i < n_components; i++){ |
1272 |
> |
for (j = 0; j < components_nmol[i]; j++){ |
1273 |
> |
if (mol2proc[allMol] == worldRank){ |
1274 |
> |
local_atoms += comp_stamps[i]->getNAtoms(); |
1275 |
> |
local_bonds += comp_stamps[i]->getNBonds(); |
1276 |
> |
local_bends += comp_stamps[i]->getNBends(); |
1277 |
> |
local_torsions += comp_stamps[i]->getNTorsions(); |
1278 |
> |
localMol++; |
1279 |
> |
} |
1280 |
> |
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ |
1281 |
> |
info[0].molMembershipArray[globalAtomIndex] = allMol; |
1282 |
> |
globalAtomIndex++; |
1283 |
|
} |
1284 |
+ |
|
1285 |
+ |
allMol++; |
1286 |
|
} |
1287 |
|
} |
1288 |
+ |
local_SRI = local_bonds + local_bends + local_torsions; |
1289 |
|
|
1290 |
+ |
info[0].n_atoms = mpiSim->getMyNlocal(); |
1291 |
|
|
1292 |
< |
for( i=0; i<simnfo->n_atoms; i++ ){ |
1293 |
< |
simnfo->atoms[i]->set_vx( 0.0 ); |
1294 |
< |
simnfo->atoms[i]->set_vy( 0.0 ); |
1295 |
< |
simnfo->atoms[i]->set_vz( 0.0 ); |
1292 |
> |
if (local_atoms != info[0].n_atoms){ |
1293 |
> |
sprintf(painCave.errMsg, |
1294 |
> |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's\n" |
1295 |
> |
"\tlocalAtom (%d) are not equal.\n", |
1296 |
> |
info[0].n_atoms, local_atoms); |
1297 |
> |
painCave.isFatal = 1; |
1298 |
> |
simError(); |
1299 |
|
} |
1300 |
+ |
|
1301 |
+ |
info[0].n_bonds = local_bonds; |
1302 |
+ |
info[0].n_bends = local_bends; |
1303 |
+ |
info[0].n_torsions = local_torsions; |
1304 |
+ |
info[0].n_SRI = local_SRI; |
1305 |
+ |
info[0].n_mol = localMol; |
1306 |
+ |
|
1307 |
+ |
strcpy(checkPointMsg, "Passed nlocal consistency check."); |
1308 |
+ |
MPIcheckPoint(); |
1309 |
|
} |
1310 |
|
|
1311 |
< |
void SimSetup::makeElement( double x, double y, double z ){ |
1311 |
> |
#endif // is_mpi |
1312 |
|
|
1387 |
– |
int k; |
1388 |
– |
AtomStamp* current_atom; |
1389 |
– |
DirectionalAtom* dAtom; |
1390 |
– |
double rotMat[3][3]; |
1313 |
|
|
1314 |
< |
for( k=0; k<comp_stamps[current_comp]->getNAtoms(); k++ ){ |
1314 |
> |
void SimSetup::makeSysArrays(void){ |
1315 |
> |
|
1316 |
> |
#ifndef IS_MPI |
1317 |
> |
int k, j; |
1318 |
> |
#endif // is_mpi |
1319 |
> |
int i, l; |
1320 |
|
|
1321 |
< |
current_atom = comp_stamps[current_comp]->getAtom( k ); |
1322 |
< |
if( !current_atom->havePosition() ){ |
1323 |
< |
sprintf( painCave.errMsg, |
1397 |
< |
"SimSetup:initFromBass error.\n" |
1398 |
< |
"\tComponent %s, atom %s does not have a position specified.\n" |
1399 |
< |
"\tThe initialization routine is unable to give a start" |
1400 |
< |
" position.\n", |
1401 |
< |
comp_stamps[current_comp]->getID(), |
1402 |
< |
current_atom->getType() ); |
1403 |
< |
painCave.isFatal = 1; |
1404 |
< |
simError(); |
1405 |
< |
} |
1321 |
> |
Atom** the_atoms; |
1322 |
> |
Molecule* the_molecules; |
1323 |
> |
Exclude** the_excludes; |
1324 |
|
|
1407 |
– |
the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() ); |
1408 |
– |
the_atoms[current_atom_ndx]->setY( y + current_atom->getPosY() ); |
1409 |
– |
the_atoms[current_atom_ndx]->setZ( z + current_atom->getPosZ() ); |
1325 |
|
|
1326 |
< |
if( the_atoms[current_atom_ndx]->isDirectional() ){ |
1326 |
> |
for (l = 0; l < nInfo; l++){ |
1327 |
> |
// create the atom and short range interaction arrays |
1328 |
|
|
1329 |
< |
dAtom = (DirectionalAtom *)the_atoms[current_atom_ndx]; |
1329 |
> |
the_atoms = new Atom * [info[l].n_atoms]; |
1330 |
> |
the_molecules = new Molecule[info[l].n_mol]; |
1331 |
> |
int molIndex; |
1332 |
|
|
1333 |
< |
rotMat[0][0] = 1.0; |
1416 |
< |
rotMat[0][1] = 0.0; |
1417 |
< |
rotMat[0][2] = 0.0; |
1333 |
> |
// initialize the molecule's stampID's |
1334 |
|
|
1335 |
< |
rotMat[1][0] = 0.0; |
1420 |
< |
rotMat[1][1] = 1.0; |
1421 |
< |
rotMat[1][2] = 0.0; |
1335 |
> |
#ifdef IS_MPI |
1336 |
|
|
1423 |
– |
rotMat[2][0] = 0.0; |
1424 |
– |
rotMat[2][1] = 0.0; |
1425 |
– |
rotMat[2][2] = 1.0; |
1337 |
|
|
1338 |
< |
dAtom->setA( rotMat ); |
1338 |
> |
molIndex = 0; |
1339 |
> |
for (i = 0; i < mpiSim->getTotNmol(); i++){ |
1340 |
> |
if (mol2proc[i] == worldRank){ |
1341 |
> |
the_molecules[molIndex].setStampID(molCompType[i]); |
1342 |
> |
the_molecules[molIndex].setMyIndex(molIndex); |
1343 |
> |
the_molecules[molIndex].setGlobalIndex(i); |
1344 |
> |
molIndex++; |
1345 |
> |
} |
1346 |
|
} |
1347 |
|
|
1348 |
< |
current_atom_ndx++; |
1431 |
< |
} |
1348 |
> |
#else // is_mpi |
1349 |
|
|
1350 |
< |
current_mol++; |
1351 |
< |
current_comp_mol++; |
1350 |
> |
molIndex = 0; |
1351 |
> |
globalAtomIndex = 0; |
1352 |
> |
for (i = 0; i < n_components; i++){ |
1353 |
> |
for (j = 0; j < components_nmol[i]; j++){ |
1354 |
> |
the_molecules[molIndex].setStampID(i); |
1355 |
> |
the_molecules[molIndex].setMyIndex(molIndex); |
1356 |
> |
the_molecules[molIndex].setGlobalIndex(molIndex); |
1357 |
> |
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ |
1358 |
> |
info[l].molMembershipArray[globalAtomIndex] = molIndex; |
1359 |
> |
globalAtomIndex++; |
1360 |
> |
} |
1361 |
> |
molIndex++; |
1362 |
> |
} |
1363 |
> |
} |
1364 |
|
|
1436 |
– |
if( current_comp_mol >= components_nmol[current_comp] ){ |
1365 |
|
|
1366 |
< |
current_comp_mol = 0; |
1367 |
< |
current_comp++; |
1366 |
> |
#endif // is_mpi |
1367 |
> |
|
1368 |
> |
|
1369 |
> |
if (info[l].n_SRI){ |
1370 |
> |
Exclude::createArray(info[l].n_SRI); |
1371 |
> |
the_excludes = new Exclude * [info[l].n_SRI]; |
1372 |
> |
for (int ex = 0; ex < info[l].n_SRI; ex++){ |
1373 |
> |
the_excludes[ex] = new Exclude(ex); |
1374 |
> |
} |
1375 |
> |
info[l].globalExcludes = new int; |
1376 |
> |
info[l].n_exclude = info[l].n_SRI; |
1377 |
> |
} |
1378 |
> |
else{ |
1379 |
> |
Exclude::createArray(1); |
1380 |
> |
the_excludes = new Exclude * ; |
1381 |
> |
the_excludes[0] = new Exclude(0); |
1382 |
> |
the_excludes[0]->setPair(0, 0); |
1383 |
> |
info[l].globalExcludes = new int; |
1384 |
> |
info[l].globalExcludes[0] = 0; |
1385 |
> |
info[l].n_exclude = 0; |
1386 |
> |
} |
1387 |
> |
|
1388 |
> |
// set the arrays into the SimInfo object |
1389 |
> |
|
1390 |
> |
info[l].atoms = the_atoms; |
1391 |
> |
info[l].molecules = the_molecules; |
1392 |
> |
info[l].nGlobalExcludes = 0; |
1393 |
> |
info[l].excludes = the_excludes; |
1394 |
> |
|
1395 |
> |
the_ff->setSimInfo(info); |
1396 |
|
} |
1397 |
|
} |
1398 |
+ |
|
1399 |
+ |
void SimSetup::makeIntegrator(void){ |
1400 |
+ |
int k; |
1401 |
+ |
|
1402 |
+ |
NVE<RealIntegrator>* myNVE = NULL; |
1403 |
+ |
NVT<RealIntegrator>* myNVT = NULL; |
1404 |
+ |
NPTi<NPT<RealIntegrator> >* myNPTi = NULL; |
1405 |
+ |
NPTf<NPT<RealIntegrator> >* myNPTf = NULL; |
1406 |
+ |
NPTxyz<NPT<RealIntegrator> >* myNPTxyz = NULL; |
1407 |
+ |
|
1408 |
+ |
for (k = 0; k < nInfo; k++){ |
1409 |
+ |
switch (ensembleCase){ |
1410 |
+ |
case NVE_ENS: |
1411 |
+ |
if (globals->haveZconstraints()){ |
1412 |
+ |
setupZConstraint(info[k]); |
1413 |
+ |
myNVE = new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff); |
1414 |
+ |
} |
1415 |
+ |
else{ |
1416 |
+ |
myNVE = new NVE<RealIntegrator>(&(info[k]), the_ff); |
1417 |
+ |
} |
1418 |
+ |
|
1419 |
+ |
info->the_integrator = myNVE; |
1420 |
+ |
break; |
1421 |
+ |
|
1422 |
+ |
case NVT_ENS: |
1423 |
+ |
if (globals->haveZconstraints()){ |
1424 |
+ |
setupZConstraint(info[k]); |
1425 |
+ |
myNVT = new ZConstraint<NVT<RealIntegrator> >(&(info[k]), the_ff); |
1426 |
+ |
} |
1427 |
+ |
else |
1428 |
+ |
myNVT = new NVT<RealIntegrator>(&(info[k]), the_ff); |
1429 |
+ |
|
1430 |
+ |
myNVT->setTargetTemp(globals->getTargetTemp()); |
1431 |
+ |
|
1432 |
+ |
if (globals->haveTauThermostat()) |
1433 |
+ |
myNVT->setTauThermostat(globals->getTauThermostat()); |
1434 |
+ |
else{ |
1435 |
+ |
sprintf(painCave.errMsg, |
1436 |
+ |
"SimSetup error: If you use the NVT\n" |
1437 |
+ |
"\tensemble, you must set tauThermostat.\n"); |
1438 |
+ |
painCave.isFatal = 1; |
1439 |
+ |
simError(); |
1440 |
+ |
} |
1441 |
+ |
|
1442 |
+ |
info->the_integrator = myNVT; |
1443 |
+ |
break; |
1444 |
+ |
|
1445 |
+ |
case NPTi_ENS: |
1446 |
+ |
if (globals->haveZconstraints()){ |
1447 |
+ |
setupZConstraint(info[k]); |
1448 |
+ |
myNPTi = new ZConstraint<NPTi<NPT <RealIntegrator> > >(&(info[k]), the_ff); |
1449 |
+ |
} |
1450 |
+ |
else |
1451 |
+ |
myNPTi = new NPTi<NPT<RealIntegrator> >(&(info[k]), the_ff); |
1452 |
+ |
|
1453 |
+ |
myNPTi->setTargetTemp(globals->getTargetTemp()); |
1454 |
+ |
|
1455 |
+ |
if (globals->haveTargetPressure()) |
1456 |
+ |
myNPTi->setTargetPressure(globals->getTargetPressure()); |
1457 |
+ |
else{ |
1458 |
+ |
sprintf(painCave.errMsg, |
1459 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1460 |
+ |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1461 |
+ |
painCave.isFatal = 1; |
1462 |
+ |
simError(); |
1463 |
+ |
} |
1464 |
+ |
|
1465 |
+ |
if (globals->haveTauThermostat()) |
1466 |
+ |
myNPTi->setTauThermostat(globals->getTauThermostat()); |
1467 |
+ |
else{ |
1468 |
+ |
sprintf(painCave.errMsg, |
1469 |
+ |
"SimSetup error: If you use an NPT\n" |
1470 |
+ |
"\tensemble, you must set tauThermostat.\n"); |
1471 |
+ |
painCave.isFatal = 1; |
1472 |
+ |
simError(); |
1473 |
+ |
} |
1474 |
+ |
|
1475 |
+ |
if (globals->haveTauBarostat()) |
1476 |
+ |
myNPTi->setTauBarostat(globals->getTauBarostat()); |
1477 |
+ |
else{ |
1478 |
+ |
sprintf(painCave.errMsg, |
1479 |
+ |
"SimSetup error: If you use an NPT\n" |
1480 |
+ |
"\tensemble, you must set tauBarostat.\n"); |
1481 |
+ |
painCave.isFatal = 1; |
1482 |
+ |
simError(); |
1483 |
+ |
} |
1484 |
+ |
|
1485 |
+ |
info->the_integrator = myNPTi; |
1486 |
+ |
break; |
1487 |
+ |
|
1488 |
+ |
case NPTf_ENS: |
1489 |
+ |
if (globals->haveZconstraints()){ |
1490 |
+ |
setupZConstraint(info[k]); |
1491 |
+ |
myNPTf = new ZConstraint<NPTf<NPT <RealIntegrator> > >(&(info[k]), the_ff); |
1492 |
+ |
} |
1493 |
+ |
else |
1494 |
+ |
myNPTf = new NPTf<NPT <RealIntegrator> >(&(info[k]), the_ff); |
1495 |
+ |
|
1496 |
+ |
myNPTf->setTargetTemp(globals->getTargetTemp()); |
1497 |
+ |
|
1498 |
+ |
if (globals->haveTargetPressure()) |
1499 |
+ |
myNPTf->setTargetPressure(globals->getTargetPressure()); |
1500 |
+ |
else{ |
1501 |
+ |
sprintf(painCave.errMsg, |
1502 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1503 |
+ |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1504 |
+ |
painCave.isFatal = 1; |
1505 |
+ |
simError(); |
1506 |
+ |
} |
1507 |
+ |
|
1508 |
+ |
if (globals->haveTauThermostat()) |
1509 |
+ |
myNPTf->setTauThermostat(globals->getTauThermostat()); |
1510 |
+ |
|
1511 |
+ |
else{ |
1512 |
+ |
sprintf(painCave.errMsg, |
1513 |
+ |
"SimSetup error: If you use an NPT\n" |
1514 |
+ |
"\tensemble, you must set tauThermostat.\n"); |
1515 |
+ |
painCave.isFatal = 1; |
1516 |
+ |
simError(); |
1517 |
+ |
} |
1518 |
+ |
|
1519 |
+ |
if (globals->haveTauBarostat()) |
1520 |
+ |
myNPTf->setTauBarostat(globals->getTauBarostat()); |
1521 |
+ |
|
1522 |
+ |
else{ |
1523 |
+ |
sprintf(painCave.errMsg, |
1524 |
+ |
"SimSetup error: If you use an NPT\n" |
1525 |
+ |
"\tensemble, you must set tauBarostat.\n"); |
1526 |
+ |
painCave.isFatal = 1; |
1527 |
+ |
simError(); |
1528 |
+ |
} |
1529 |
+ |
|
1530 |
+ |
info->the_integrator = myNPTf; |
1531 |
+ |
break; |
1532 |
+ |
|
1533 |
+ |
case NPTxyz_ENS: |
1534 |
+ |
if (globals->haveZconstraints()){ |
1535 |
+ |
setupZConstraint(info[k]); |
1536 |
+ |
myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff); |
1537 |
+ |
} |
1538 |
+ |
else |
1539 |
+ |
myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff); |
1540 |
+ |
|
1541 |
+ |
myNPTxyz->setTargetTemp(globals->getTargetTemp()); |
1542 |
+ |
|
1543 |
+ |
if (globals->haveTargetPressure()) |
1544 |
+ |
myNPTxyz->setTargetPressure(globals->getTargetPressure()); |
1545 |
+ |
else{ |
1546 |
+ |
sprintf(painCave.errMsg, |
1547 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1548 |
+ |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1549 |
+ |
painCave.isFatal = 1; |
1550 |
+ |
simError(); |
1551 |
+ |
} |
1552 |
+ |
|
1553 |
+ |
if (globals->haveTauThermostat()) |
1554 |
+ |
myNPTxyz->setTauThermostat(globals->getTauThermostat()); |
1555 |
+ |
else{ |
1556 |
+ |
sprintf(painCave.errMsg, |
1557 |
+ |
"SimSetup error: If you use an NPT\n" |
1558 |
+ |
"\tensemble, you must set tauThermostat.\n"); |
1559 |
+ |
painCave.isFatal = 1; |
1560 |
+ |
simError(); |
1561 |
+ |
} |
1562 |
+ |
|
1563 |
+ |
if (globals->haveTauBarostat()) |
1564 |
+ |
myNPTxyz->setTauBarostat(globals->getTauBarostat()); |
1565 |
+ |
else{ |
1566 |
+ |
sprintf(painCave.errMsg, |
1567 |
+ |
"SimSetup error: If you use an NPT\n" |
1568 |
+ |
"\tensemble, you must set tauBarostat.\n"); |
1569 |
+ |
painCave.isFatal = 1; |
1570 |
+ |
simError(); |
1571 |
+ |
} |
1572 |
+ |
|
1573 |
+ |
info->the_integrator = myNPTxyz; |
1574 |
+ |
break; |
1575 |
+ |
|
1576 |
+ |
default: |
1577 |
+ |
sprintf(painCave.errMsg, |
1578 |
+ |
"SimSetup Error. Unrecognized ensemble in case statement.\n"); |
1579 |
+ |
painCave.isFatal = 1; |
1580 |
+ |
simError(); |
1581 |
+ |
} |
1582 |
+ |
} |
1583 |
+ |
} |
1584 |
+ |
|
1585 |
+ |
void SimSetup::initFortran(void){ |
1586 |
+ |
info[0].refreshSim(); |
1587 |
+ |
|
1588 |
+ |
if (!strcmp(info[0].mixingRule, "standard")){ |
1589 |
+ |
the_ff->initForceField(LB_MIXING_RULE); |
1590 |
+ |
} |
1591 |
+ |
else if (!strcmp(info[0].mixingRule, "explicit")){ |
1592 |
+ |
the_ff->initForceField(EXPLICIT_MIXING_RULE); |
1593 |
+ |
} |
1594 |
+ |
else{ |
1595 |
+ |
sprintf(painCave.errMsg, "SimSetup Error: unknown mixing rule -> \"%s\"\n", |
1596 |
+ |
info[0].mixingRule); |
1597 |
+ |
painCave.isFatal = 1; |
1598 |
+ |
simError(); |
1599 |
+ |
} |
1600 |
+ |
|
1601 |
+ |
|
1602 |
+ |
#ifdef IS_MPI |
1603 |
+ |
strcpy(checkPointMsg, "Successfully intialized the mixingRule for Fortran."); |
1604 |
+ |
MPIcheckPoint(); |
1605 |
+ |
#endif // is_mpi |
1606 |
+ |
} |
1607 |
+ |
|
1608 |
+ |
void SimSetup::setupZConstraint(SimInfo& theInfo){ |
1609 |
+ |
int nZConstraints; |
1610 |
+ |
ZconStamp** zconStamp; |
1611 |
+ |
|
1612 |
+ |
if (globals->haveZconstraintTime()){ |
1613 |
+ |
//add sample time of z-constraint into SimInfo's property list |
1614 |
+ |
DoubleData* zconsTimeProp = new DoubleData(); |
1615 |
+ |
zconsTimeProp->setID(ZCONSTIME_ID); |
1616 |
+ |
zconsTimeProp->setData(globals->getZconsTime()); |
1617 |
+ |
theInfo.addProperty(zconsTimeProp); |
1618 |
+ |
} |
1619 |
+ |
else{ |
1620 |
+ |
sprintf(painCave.errMsg, |
1621 |
+ |
"ZConstraint error: If you use a ZConstraint,\n" |
1622 |
+ |
"\tyou must set zconsTime.\n"); |
1623 |
+ |
painCave.isFatal = 1; |
1624 |
+ |
simError(); |
1625 |
+ |
} |
1626 |
+ |
|
1627 |
+ |
//push zconsTol into siminfo, if user does not specify |
1628 |
+ |
//value for zconsTol, a default value will be used |
1629 |
+ |
DoubleData* zconsTol = new DoubleData(); |
1630 |
+ |
zconsTol->setID(ZCONSTOL_ID); |
1631 |
+ |
if (globals->haveZconsTol()){ |
1632 |
+ |
zconsTol->setData(globals->getZconsTol()); |
1633 |
+ |
} |
1634 |
+ |
else{ |
1635 |
+ |
double defaultZConsTol = 0.01; |
1636 |
+ |
sprintf(painCave.errMsg, |
1637 |
+ |
"ZConstraint Warning: Tolerance for z-constraint method is not specified.\n" |
1638 |
+ |
"\tOOPSE will use a default value of %f.\n" |
1639 |
+ |
"\tTo set the tolerance, use the zconsTol variable.\n", |
1640 |
+ |
defaultZConsTol); |
1641 |
+ |
painCave.isFatal = 0; |
1642 |
+ |
simError(); |
1643 |
+ |
|
1644 |
+ |
zconsTol->setData(defaultZConsTol); |
1645 |
+ |
} |
1646 |
+ |
theInfo.addProperty(zconsTol); |
1647 |
+ |
|
1648 |
+ |
//set Force Subtraction Policy |
1649 |
+ |
StringData* zconsForcePolicy = new StringData(); |
1650 |
+ |
zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID); |
1651 |
+ |
|
1652 |
+ |
if (globals->haveZconsForcePolicy()){ |
1653 |
+ |
zconsForcePolicy->setData(globals->getZconsForcePolicy()); |
1654 |
+ |
} |
1655 |
+ |
else{ |
1656 |
+ |
sprintf(painCave.errMsg, |
1657 |
+ |
"ZConstraint Warning: No force subtraction policy was set.\n" |
1658 |
+ |
"\tOOPSE will use PolicyByMass.\n" |
1659 |
+ |
"\tTo set the policy, use the zconsForcePolicy variable.\n"); |
1660 |
+ |
painCave.isFatal = 0; |
1661 |
+ |
simError(); |
1662 |
+ |
zconsForcePolicy->setData("BYMASS"); |
1663 |
+ |
} |
1664 |
+ |
|
1665 |
+ |
theInfo.addProperty(zconsForcePolicy); |
1666 |
+ |
|
1667 |
+ |
//set zcons gap |
1668 |
+ |
DoubleData* zconsGap = new DoubleData(); |
1669 |
+ |
zconsGap->setID(ZCONSGAP_ID); |
1670 |
+ |
|
1671 |
+ |
if (globals->haveZConsGap()){ |
1672 |
+ |
zconsGap->setData(globals->getZconsGap()); |
1673 |
+ |
theInfo.addProperty(zconsGap); |
1674 |
+ |
} |
1675 |
+ |
|
1676 |
+ |
//set zcons fixtime |
1677 |
+ |
DoubleData* zconsFixtime = new DoubleData(); |
1678 |
+ |
zconsFixtime->setID(ZCONSFIXTIME_ID); |
1679 |
+ |
|
1680 |
+ |
if (globals->haveZConsFixTime()){ |
1681 |
+ |
zconsFixtime->setData(globals->getZconsFixtime()); |
1682 |
+ |
theInfo.addProperty(zconsFixtime); |
1683 |
+ |
} |
1684 |
+ |
|
1685 |
+ |
|
1686 |
+ |
//Determine the name of ouput file and add it into SimInfo's property list |
1687 |
+ |
//Be careful, do not use inFileName, since it is a pointer which |
1688 |
+ |
//point to a string at master node, and slave nodes do not contain that string |
1689 |
+ |
|
1690 |
+ |
string zconsOutput(theInfo.finalName); |
1691 |
+ |
|
1692 |
+ |
zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; |
1693 |
+ |
|
1694 |
+ |
StringData* zconsFilename = new StringData(); |
1695 |
+ |
zconsFilename->setID(ZCONSFILENAME_ID); |
1696 |
+ |
zconsFilename->setData(zconsOutput); |
1697 |
+ |
|
1698 |
+ |
theInfo.addProperty(zconsFilename); |
1699 |
+ |
|
1700 |
+ |
//setup index, pos and other parameters of z-constraint molecules |
1701 |
+ |
nZConstraints = globals->getNzConstraints(); |
1702 |
+ |
theInfo.nZconstraints = nZConstraints; |
1703 |
+ |
|
1704 |
+ |
zconStamp = globals->getZconStamp(); |
1705 |
+ |
ZConsParaItem tempParaItem; |
1706 |
+ |
|
1707 |
+ |
ZConsParaData* zconsParaData = new ZConsParaData(); |
1708 |
+ |
zconsParaData->setID(ZCONSPARADATA_ID); |
1709 |
+ |
|
1710 |
+ |
for (int i = 0; i < nZConstraints; i++){ |
1711 |
+ |
tempParaItem.havingZPos = zconStamp[i]->haveZpos(); |
1712 |
+ |
tempParaItem.zPos = zconStamp[i]->getZpos(); |
1713 |
+ |
tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); |
1714 |
+ |
tempParaItem.kRatio = zconStamp[i]->getKratio(); |
1715 |
+ |
|
1716 |
+ |
zconsParaData->addItem(tempParaItem); |
1717 |
+ |
} |
1718 |
+ |
|
1719 |
+ |
//check the uniqueness of index |
1720 |
+ |
if(!zconsParaData->isIndexUnique()){ |
1721 |
+ |
sprintf(painCave.errMsg, |
1722 |
+ |
"ZConstraint Error: molIndex is not unique!\n"); |
1723 |
+ |
painCave.isFatal = 1; |
1724 |
+ |
simError(); |
1725 |
+ |
} |
1726 |
+ |
|
1727 |
+ |
//sort the parameters by index of molecules |
1728 |
+ |
zconsParaData->sortByIndex(); |
1729 |
+ |
|
1730 |
+ |
//push data into siminfo, therefore, we can retrieve later |
1731 |
+ |
theInfo.addProperty(zconsParaData); |
1732 |
+ |
} |
1733 |
+ |
|
1734 |
+ |
void SimSetup::makeMinimizer(){ |
1735 |
+ |
|
1736 |
+ |
OOPSEMinimizer* myOOPSEMinimizer; |
1737 |
+ |
MinimizerParameterSet* param; |
1738 |
+ |
char minimizerName[100]; |
1739 |
+ |
|
1740 |
+ |
for (int i = 0; i < nInfo; i++){ |
1741 |
+ |
|
1742 |
+ |
//prepare parameter set for minimizer |
1743 |
+ |
param = new MinimizerParameterSet(); |
1744 |
+ |
param->setDefaultParameter(); |
1745 |
+ |
|
1746 |
+ |
if (globals->haveMinimizer()){ |
1747 |
+ |
param->setFTol(globals->getMinFTol()); |
1748 |
+ |
} |
1749 |
+ |
|
1750 |
+ |
if (globals->haveMinGTol()){ |
1751 |
+ |
param->setGTol(globals->getMinGTol()); |
1752 |
+ |
} |
1753 |
+ |
|
1754 |
+ |
if (globals->haveMinMaxIter()){ |
1755 |
+ |
param->setMaxIteration(globals->getMinMaxIter()); |
1756 |
+ |
} |
1757 |
+ |
|
1758 |
+ |
if (globals->haveMinWriteFrq()){ |
1759 |
+ |
param->setMaxIteration(globals->getMinMaxIter()); |
1760 |
+ |
} |
1761 |
+ |
|
1762 |
+ |
if (globals->haveMinWriteFrq()){ |
1763 |
+ |
param->setWriteFrq(globals->getMinWriteFrq()); |
1764 |
+ |
} |
1765 |
+ |
|
1766 |
+ |
if (globals->haveMinStepSize()){ |
1767 |
+ |
param->setStepSize(globals->getMinStepSize()); |
1768 |
+ |
} |
1769 |
+ |
|
1770 |
+ |
if (globals->haveMinLSMaxIter()){ |
1771 |
+ |
param->setLineSearchMaxIteration(globals->getMinLSMaxIter()); |
1772 |
+ |
} |
1773 |
+ |
|
1774 |
+ |
if (globals->haveMinLSTol()){ |
1775 |
+ |
param->setLineSearchTol(globals->getMinLSTol()); |
1776 |
+ |
} |
1777 |
+ |
|
1778 |
+ |
strcpy(minimizerName, globals->getMinimizer()); |
1779 |
+ |
|
1780 |
+ |
if (!strcasecmp(minimizerName, "CG")){ |
1781 |
+ |
myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param); |
1782 |
+ |
} |
1783 |
+ |
else if (!strcasecmp(minimizerName, "SD")){ |
1784 |
+ |
//myOOPSEMinimizer = MinimizerFactory.creatMinimizer("", &(info[i]), the_ff, param); |
1785 |
+ |
myOOPSEMinimizer = new SDMinimizer(&(info[i]), the_ff, param); |
1786 |
+ |
} |
1787 |
+ |
else{ |
1788 |
+ |
sprintf(painCave.errMsg, |
1789 |
+ |
"SimSetup error: Unrecognized Minimizer, use Conjugate Gradient \n"); |
1790 |
+ |
painCave.isFatal = 0; |
1791 |
+ |
simError(); |
1792 |
+ |
|
1793 |
+ |
myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param); |
1794 |
+ |
} |
1795 |
+ |
info[i].the_integrator = myOOPSEMinimizer; |
1796 |
+ |
|
1797 |
+ |
//store the minimizer into simInfo |
1798 |
+ |
info[i].the_minimizer = myOOPSEMinimizer; |
1799 |
+ |
info[i].has_minimizer = true; |
1800 |
+ |
} |
1801 |
+ |
|
1802 |
+ |
} |