ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/utils/sysbuilder/QuickBass.cpp
Revision: 821
Committed: Fri Oct 24 22:17:45 2003 UTC (20 years, 8 months ago) by mmeineke
File size: 6408 byte(s)
Log Message:
put QuickBass, MoLocator, and latticeBuilder into a Builder Library
overhauled latticeBilayer into its own program. Removed sysBuild from the Makefile

File Contents

# Content
1 #include <iostream>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <math.h>
5 #include <string.h>
6
7 #include "QuickBass.hpp"
8 #include "latticeBuilder.hpp"
9
10 #include "simError.h"
11 #include "parse_me.h"
12 #include "MakeStamps.hpp"
13 #include "Globals.hpp"
14
15 // this routine is defined in BASS_interface.cpp
16 extern void set_interface_stamps( MakeStamps* ms, Globals* g );
17
18 bassInfo bsInfo;
19
20 void parseBuildBass(char* in_name){
21 int i;
22 char* id;
23
24 MakeStamps* the_stamps = NULL;
25 Globals* the_globals = NULL;
26 Component** the_components = NULL;
27 LinkedMolStamp* headStamp = NULL;
28 LinkedMolStamp* currStamp;
29
30 bsInfo.componentsNmol = NULL;
31 bsInfo.compStamps = NULL;
32 bsInfo.havePressure = 0;
33 bsInfo.haveTauBarostat = 0;
34 bsInfo.haveTauThermostat = 0;
35 bsInfo.haveQmass = 0;
36
37 //Nanobuilder components.
38 bsInfo.latticeType = FCC_LATTICE_TYPE; // set lattice type to FCC.
39 bsInfo.hasVacancies = 0; //set vacancies to false.
40 bsInfo.buildCoreShell = 0;
41
42 bsInfo.latticeSpacing = 0.0;
43 bsInfo.coreRadius = 0.0;
44 bsInfo.particleRadius = 0.0;
45 bsInfo.shellRadius = 0.0;
46 bsInfo.vacancyRadius = 0.0;
47 bsInfo.vacancyFraction = 0.0;
48 bsInfo.soluteX = 0.0;
49
50
51
52 headStamp = new LinkedMolStamp();
53 the_stamps = new MakeStamps();
54 the_globals = new Globals();
55 set_interface_stamps( the_stamps, the_globals );
56
57 // open and parse the bass file.
58
59 set_interface_stamps( the_stamps, the_globals );
60 yacc_BASS( in_name );
61
62 // set the easy ones first
63 bsInfo.targetTemp = the_globals->getTargetTemp();
64 bsInfo.dt = the_globals->getDt();
65 bsInfo.runTime = the_globals->getRunTime();
66
67 // get the ones we know are there, yet still may need some work.
68 bsInfo.nComponents = the_globals->getNComponents();
69 strcpy( bsInfo.forceField, the_globals->getForceField() );
70
71 // get the ensemble:
72 strcpy( bsInfo.ensemble, the_globals->getEnsemble() );
73 if( !strcasecmp( bsInfo.ensemble, "NPT" ) ) {
74
75 if (the_globals->haveTargetPressure()){
76 bsInfo.targetPressure = the_globals->getTargetPressure();
77 bsInfo.havePressure = 1;
78 }
79 else {
80 sprintf( painCave.errMsg,
81 "sysBuild error: If you use the constant pressure\n"
82 " ensemble, you must set targetPressure.\n"
83 " This was found in the BASS file.\n");
84 painCave.isFatal = 1;
85 simError();
86 }
87
88 if (the_globals->haveTauThermostat()){
89 bsInfo.tauThermostat = the_globals->getTauThermostat();
90 bsInfo.haveTauThermostat = 1;;
91 }
92 else if (the_globals->haveQmass()){
93 bsInfo.Qmass = the_globals->getQmass();
94 bsInfo.haveQmass = 1;
95 }
96 else {
97 sprintf( painCave.errMsg,
98 "sysBuild error: If you use one of the constant temperature\n"
99 " ensembles, you must set either tauThermostat or qMass.\n"
100 " Neither of these was found in the BASS file.\n");
101 painCave.isFatal = 1;
102 simError();
103 }
104
105 if (the_globals->haveTauBarostat()){
106 bsInfo.tauBarostat = the_globals->getTauBarostat();
107 bsInfo.haveTauBarostat = 1;
108 }
109 else {
110 sprintf( painCave.errMsg,
111 "sysBuild error: If you use the constant pressure\n"
112 " ensemble, you must set tauBarostat.\n"
113 " This was found in the BASS file.\n");
114 painCave.isFatal = 1;
115 simError();
116 }
117
118 }
119 else if ( !strcasecmp( bsInfo.ensemble, "NVT") ) {
120
121 if (the_globals->haveTauThermostat()){
122 bsInfo.tauThermostat = the_globals->getTauThermostat();
123 bsInfo.haveTauThermostat = 1;
124 }
125 else if (the_globals->haveQmass()){
126 bsInfo.Qmass = the_globals->getQmass();
127 bsInfo.haveQmass = 1;
128 }
129 else {
130 sprintf( painCave.errMsg,
131 "sysBuild error: If you use one of the constant temperature\n"
132 " ensembles, you must set either tauThermostat or qMass.\n"
133 " Neither of these was found in the BASS file.\n");
134 painCave.isFatal = 1;
135 simError();
136 }
137
138 }
139 else if ( !strcasecmp( bsInfo.ensemble, "NVE") ) {
140
141 // nothing special for now
142 }
143 else {
144 sprintf( painCave.errMsg,
145 "sysBuild Warning. Unrecognized Ensemble -> %s, "
146 "reverting to NVE for this simulation.\n",
147 bsInfo.ensemble );
148 painCave.isFatal = 0;
149 simError();
150 strcpy( bsInfo.ensemble, "NVE" );
151 }
152
153
154 // get the components and calculate the tot_nMol and indvidual n_mol
155
156 the_components = the_globals->getComponents();
157 bsInfo.componentsNmol = new int[bsInfo.nComponents];
158 bsInfo.compStamps = new MoleculeStamp*[bsInfo.nComponents];
159 bsInfo.totNmol = 0;
160 for( i=0; i<bsInfo.nComponents; i++ ){
161
162 if( !the_components[i]->haveNMol() ){
163 // we have a problem
164 sprintf( painCave.errMsg,
165 "sysBuild Error. No component NMol"
166 " given. Cannot calculate the number of atoms.\n" );
167 painCave.isFatal = 1;
168 simError();
169 }
170
171 bsInfo.totNmol += the_components[i]->getNMol();
172 bsInfo.componentsNmol[i] = the_components[i]->getNMol();
173 }
174
175 // make an array of molecule stamps that match the components used.
176 // also extract the used stamps out into a separate linked list
177
178 for( i=0; i<bsInfo.nComponents; i++ ){
179
180 id = the_components[i]->getType();
181 bsInfo.compStamps[i] = NULL;
182
183 // check to make sure the component isn't already in the list
184
185 bsInfo.compStamps[i] = headStamp->match( id );
186 if( bsInfo.compStamps[i] == NULL ){
187
188 // extract the component from the list;
189
190 currStamp = the_stamps->extractMolStamp( id );
191 if( currStamp == NULL ){
192 sprintf( painCave.errMsg,
193 "sysBuild error: Component \"%s\" was not found in the "
194 "list of declared molecules\n",
195 id );
196 painCave.isFatal = 1;
197 simError();
198 }
199
200 headStamp->add( currStamp );
201 bsInfo.compStamps[i] = headStamp->match( id );
202 }
203 }
204
205 // get and set the boxSize
206
207 bsInfo.haveBox = false;
208
209 if( the_globals->haveBox() ){
210 bsInfo.boxX = the_globals->getBox();
211 bsInfo.boxY = the_globals->getBox();
212 bsInfo.boxZ = the_globals->getBox();
213 bsInfo.haveBox = true;
214 }
215 else if( the_globals->haveDensity() ){
216
217 double vol;
218 vol = (double)bsInfo.totNmol / the_globals->getDensity();
219 bsInfo.boxX = pow( vol, ( 1.0 / 3.0 ) );
220 bsInfo.boxY = bsInfo.boxX;
221 bsInfo.boxZ = bsInfo.boxY;
222 bsInfo.haveBox = true;
223 }
224 }