1 |
#include <cstdlib> |
2 |
#include <cstring> |
3 |
#include <cmath> |
4 |
|
5 |
#include "simError.h" |
6 |
#include "parse_me.h" |
7 |
#include "MakeStamps.hpp" |
8 |
#include "Globals.hpp" |
9 |
#include "SimInfo.hpp" |
10 |
#include "ReadWrite.hpp" |
11 |
|
12 |
|
13 |
#include "sysBuild.hpp" |
14 |
#include "bilayerSys.hpp" |
15 |
|
16 |
|
17 |
// this routine is defined in BASS_interface.cpp |
18 |
extern void set_interface_stamps( MakeStamps* ms, Globals* g ); |
19 |
|
20 |
void buildRandomBilayer( sysBuildInfo info ); |
21 |
|
22 |
|
23 |
void buildBilayer( sysBuildInfo info ){ |
24 |
|
25 |
if( info.isRandom ){ |
26 |
buildRandomBilayer( info ); |
27 |
} |
28 |
else{ |
29 |
|
30 |
sprintf( painCave.errMsg, |
31 |
"Cannot currently create a non-random bilayer.\n" ); |
32 |
painCave.isFatal = 1; |
33 |
simError(); |
34 |
} |
35 |
} |
36 |
|
37 |
|
38 |
|
39 |
void buildRandomBilayer( sysBuildInfo info ){ |
40 |
|
41 |
MakeStamps* the_stamps; |
42 |
Globals* the_globals; |
43 |
SimInfo* simnfo; |
44 |
bwMolLinked bwInfo; |
45 |
|
46 |
// init the bwInfo |
47 |
|
48 |
bwinfo.components = NULL; |
49 |
|
50 |
bwInfo.havePressure = 0; |
51 |
bwInfo.haveTauBarrostat = 0; |
52 |
bwInfo.haveTauTemp = 0; |
53 |
bwInfo.haveQmass = 0; |
54 |
|
55 |
|
56 |
// create parser and read the Bas file |
57 |
|
58 |
simnfo = new SimInfo(); |
59 |
the_stamps = new MakeStamps(); |
60 |
the_globals = new Globals(); |
61 |
set_interface_stamps( the_stamps, the_globals ); |
62 |
|
63 |
yacc_BASS( info.in_name ); |
64 |
|
65 |
|
66 |
|
67 |
// set the easy ones first |
68 |
bwInfo.targetTemp = the_globals->getTargetTemp(); |
69 |
bwInfo.dt = the_globals->getDt(); |
70 |
bwInfo.runTime = the_globals->getRunTime(); |
71 |
|
72 |
// get the ones we know are there, yet still may need some work. |
73 |
bwInfo.nComponents = the_globals->getNComponents(); |
74 |
strcpy( bwInfo.forceField, the_globals->getForceField() ); |
75 |
|
76 |
// get the ensemble: |
77 |
strcpy( bwInfo.ensemble, the_globals->getEnsemble() ); |
78 |
if( !strcasecmp( bwInfo.ensemble, "NPT" ) ) { |
79 |
|
80 |
if (the_globals->haveTargetPressure()){ |
81 |
bwInfo.targetPressure = the_globals->getTargetPressure(); |
82 |
bwInfo.havePressure = 1; |
83 |
} |
84 |
else { |
85 |
sprintf( painCave.errMsg, |
86 |
"buildBilayer error: If you use the constant pressure\n" |
87 |
" ensemble, you must set targetPressure.\n" |
88 |
" This was found in the BASS file.\n"); |
89 |
painCave.isFatal = 1; |
90 |
simError(); |
91 |
} |
92 |
|
93 |
if (the_globals->haveTauThermostat()){ |
94 |
bwInfo.tauThermostat = the_globals->getTauThermostat(); |
95 |
bwInfo.haveTauThermostat = 1;; |
96 |
} |
97 |
else if (the_globals->haveQmass()){ |
98 |
bwinfo.Qmass = the_globals->getQmass(); |
99 |
bwInfo.haveQmass = 1; |
100 |
} |
101 |
else { |
102 |
sprintf( painCave.errMsg, |
103 |
"buildBilayer error: If you use one of the constant temperature\n" |
104 |
" ensembles, you must set either tauThermostat or qMass.\n" |
105 |
" Neither of these was found in the BASS file.\n"); |
106 |
painCave.isFatal = 1; |
107 |
simError(); |
108 |
} |
109 |
|
110 |
if (the_globals->haveTauBarostat()){ |
111 |
bwInfo.tauBarostat = the_globals->getTauBarostat(); |
112 |
bwInfo.haveTauBarostat = 1; |
113 |
} |
114 |
else { |
115 |
sprintf( painCave.errMsg, |
116 |
"SimSetup error: If you use the constant pressure\n" |
117 |
" ensemble, you must set tauBarostat.\n" |
118 |
" This was found in the BASS file.\n"); |
119 |
painCave.isFatal = 1; |
120 |
simError(); |
121 |
} |
122 |
|
123 |
} else if ( !strcasecmp( ensemble, "NVT") ) { |
124 |
the_extendedsystem = new ExtendedSystem( simnfo ); |
125 |
the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); |
126 |
|
127 |
if (the_globals->haveTauThermostat()) |
128 |
the_extendedsystem->setTauThermostat(the_globals->getTauThermostat()); |
129 |
else if (the_globals->haveQmass()) |
130 |
the_extendedsystem->setQmass(the_globals->getQmass()); |
131 |
else { |
132 |
sprintf( painCave.errMsg, |
133 |
"SimSetup error: If you use one of the constant temperature\n" |
134 |
" ensembles, you must set either tauThermostat or qMass.\n" |
135 |
" Neither of these was found in the BASS file.\n"); |
136 |
painCave.isFatal = 1; |
137 |
simError(); |
138 |
} |
139 |
|
140 |
} else if ( !strcasecmp( ensemble, "NVE") ) { |
141 |
} else { |
142 |
sprintf( painCave.errMsg, |
143 |
"SimSetup Warning. Unrecognized Ensemble -> %s, " |
144 |
"reverting to NVE for this simulation.\n", |
145 |
ensemble ); |
146 |
painCave.isFatal = 0; |
147 |
simError(); |
148 |
strcpy( ensemble, "NVE" ); |
149 |
} |
150 |
strcpy( simnfo->ensemble, ensemble ); |
151 |
|
152 |
|
153 |
|
154 |
delete stamps; |
155 |
delete globals; |
156 |
} |