47 |
|
|
48 |
|
namespace oopse { |
49 |
|
|
50 |
< |
void SimCreator::parseFile(const std::string mdFileName, MakeStamps* stamps, Globals* globals){ |
50 |
> |
void SimCreator::parseFile(const std::string mdFileName, MakeStamps* stamps, Globals* simParams){ |
51 |
|
|
52 |
|
#ifdef IS_MPI |
53 |
|
|
54 |
|
if (worldRank == 0) { |
55 |
|
#endif // is_mpi |
56 |
|
|
57 |
< |
globals->initalize(); |
58 |
< |
set_interface_stamps(stamps, globals); |
57 |
> |
simParams->initalize(); |
58 |
> |
set_interface_stamps(stamps, simParams); |
59 |
|
|
60 |
|
#ifdef IS_MPI |
61 |
|
|
69 |
|
|
70 |
|
throwMPIEvent(NULL); |
71 |
|
} else { |
72 |
< |
set_interface_stamps(stamps, globals); |
72 |
> |
set_interface_stamps(stamps, simParams); |
73 |
|
mpiEventInit(); |
74 |
|
MPIcheckPoint(); |
75 |
|
mpiEventLoop(); |
83 |
|
|
84 |
|
MakeStamps * stamps = new MakeStamps(); |
85 |
|
|
86 |
< |
Globals * globals = new Globals(); |
86 |
> |
Globals * simParams = new Globals(); |
87 |
|
|
88 |
|
//parse meta-data file |
89 |
< |
parseFile(mdFileName, stamps, globals); |
89 |
> |
parseFile(mdFileName, stamps, simParams); |
90 |
|
|
91 |
|
//create the force field |
92 |
|
ForceField * ff = ForceFieldFactory::getInstance()->createForceField( |
93 |
< |
globals->getForceField()); |
93 |
> |
simParams->getForceField()); |
94 |
|
|
95 |
|
if (ff == NULL) { |
96 |
|
sprintf(painCave.errMsg, "ForceField Factory can not create %s force field\n", |
97 |
< |
globals->getForceField()); |
97 |
> |
simParams->getForceField()); |
98 |
|
painCave.isFatal = 1; |
99 |
|
simError(); |
100 |
|
} |
102 |
|
std::string forcefieldFileName; |
103 |
|
forcefieldFileName = ff->getForceFieldFileName(); |
104 |
|
|
105 |
< |
if (globals->haveForceFieldVariant()) { |
105 |
> |
if (simParams->haveForceFieldVariant()) { |
106 |
|
//If the force field has variant, the variant force field name will be |
107 |
|
//Base.variant.frc. For exampel EAM.u6.frc |
108 |
|
|
109 |
< |
std::string variant = globals->getForceFieldVariant(); |
109 |
> |
std::string variant = simParams->getForceFieldVariant(); |
110 |
|
|
111 |
|
std::string::size_type pos = forcefieldFileName.rfind(".frc"); |
112 |
|
variant = "." + variant; |
122 |
|
|
123 |
|
//extract the molecule stamps |
124 |
|
std::vector < std::pair<MoleculeStamp *, int> > moleculeStampPairs; |
125 |
< |
compList(stamps, globals, moleculeStampPairs); |
125 |
> |
compList(stamps, simParams, moleculeStampPairs); |
126 |
|
|
127 |
|
//create SimInfo |
128 |
< |
SimInfo * info = new SimInfo(moleculeStampPairs, ff, globals); |
128 |
> |
SimInfo * info = new SimInfo(moleculeStampPairs, ff, simParams); |
129 |
|
|
130 |
|
//gather parameters (SimCreator only retrieves part of the parameters) |
131 |
|
gatherParameters(info, mdFileName); |
159 |
|
|
160 |
|
//setup seed for random number generator |
161 |
|
int seedValue; |
162 |
< |
Globals * globals = info->getGlobals(); |
162 |
> |
Globals * simParams = info->getSimParams(); |
163 |
|
|
164 |
< |
if (globals->haveSeed()) { |
165 |
< |
seedValue = globals->getSeed(); |
164 |
> |
if (simParams->haveSeed()) { |
165 |
> |
seedValue = simParams->getSeed(); |
166 |
|
|
167 |
|
if (seedValue / 1000000000 == 0) { |
168 |
|
sprintf(painCave.errMsg, |
205 |
|
|
206 |
|
#endif |
207 |
|
|
208 |
< |
} //end of globals->haveSeed() |
208 |
> |
} //end of simParams->haveSeed() |
209 |
|
|
210 |
|
info->setSeed(seedValue); |
211 |
|
|
218 |
|
if (worldRank == 0) { |
219 |
|
#endif // is_mpi |
220 |
|
|
221 |
< |
if (globals->haveFinalConfig()) { |
222 |
< |
prefix = getPrefix(globals->getFinalConfig()); |
221 |
> |
if (simParams->haveFinalConfig()) { |
222 |
> |
prefix = getPrefix(simParams->getFinalConfig()); |
223 |
|
} else { |
224 |
|
prefix = getPrefix(mdfile); |
225 |
|
} |
409 |
|
} //end for(int i=0) |
410 |
|
} |
411 |
|
|
412 |
< |
void SimCreator::compList(MakeStamps *stamps, Globals* globals, |
412 |
> |
void SimCreator::compList(MakeStamps *stamps, Globals* simParams, |
413 |
|
std::vector < std::pair<MoleculeStamp *, int> > &moleculeStampPairs) { |
414 |
|
int i; |
415 |
|
char * id; |
416 |
|
MoleculeStamp * currentStamp; |
417 |
< |
Component** the_components = globals->getComponents(); |
418 |
< |
int n_components = globals->getNComponents(); |
417 |
> |
Component** the_components = simParams->getComponents(); |
418 |
> |
int n_components = simParams->getNComponents(); |
419 |
|
|
420 |
< |
if (!globals->haveNMol()) { |
420 |
> |
if (!simParams->haveNMol()) { |
421 |
|
// we don't have the total number of molecules, so we assume it is |
422 |
|
// given in each component |
423 |
|
|
596 |
|
} |
597 |
|
|
598 |
|
void SimCreator::loadCoordinates(SimInfo* info) { |
599 |
< |
Globals* globals; |
600 |
< |
globals = info->getGlobals(); |
599 |
> |
Globals* simParams; |
600 |
> |
simParams = info->getSimParams(); |
601 |
|
|
602 |
< |
if (!globals->haveInitialConfig()) { |
602 |
> |
if (!simParams->haveInitialConfig()) { |
603 |
|
sprintf(painCave.errMsg, |
604 |
|
"Cannot intialize a simulation without an initial configuration file.\n"); |
605 |
|
painCave.isFatal = 1;; |
606 |
|
simError(); |
607 |
|
} |
608 |
|
|
609 |
< |
DumpReader reader(info, globals->getInitialConfig()); |
609 |
> |
DumpReader reader(info, simParams->getInitialConfig()); |
610 |
|
int nframes = reader.getNFrames(); |
611 |
|
|
612 |
|
if (nframes > 0) { |
614 |
|
} else { |
615 |
|
//invalid initial coordinate file |
616 |
|
sprintf(painCave.errMsg, "Initial configuration file %s should at least contain one frame\n", |
617 |
< |
globals->getInitialConfig()); |
617 |
> |
simParams->getInitialConfig()); |
618 |
|
painCave.isFatal = 1; |
619 |
|
simError(); |
620 |
|
} |