Public Member Functions | |
BLCMDmaterial () | |
Constructor. | |
~BLCMDmaterial () | |
Destructor. | |
G4String | commandName () |
commandName() returns "material" | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() executes the command associated with this element. | |
void | defineNamedArgs () |
defineNamedArgs() defines the named arguments for the command. | |
void | help (bool detailed) |
help() prints the help. | |
Private Attributes | |
G4double | a |
G4double | z |
G4double | density |
G4double | pressure |
G4double | temperature |
G4String | state |
G4String | keep |
G4String | kill |
G4String | require |
G4Material * | material |
bool | complete_description |
BLCMDmaterial::BLCMDmaterial | ( | ) |
Constructor.
References a, BLCMDTYPE_AUX, complete_description, density, keep, kill, material, pressure, BLCommand::registerCommand(), require, BLCommand::setDescription(), BLCommand::setSynopsis(), state, temperature, UNDEFINED, and z.
00093 : BLCommand() 00094 { 00095 registerCommand(BLCMDTYPE_AUX); 00096 setSynopsis("construct a new material."); 00097 setDescription("This is an interface to G4Material.\n" 00098 "This command is rarely required, because elements and most " 00099 "common materials are available via the NIST database. " 00100 "Any material available from the NIST database can simply " 00101 "be used -- if it is unknown then it " 00102 "will be automatically defined from the database. " 00103 "Uncommon materials or nonstandard densities must be defined " 00104 "with this command.\n\n" 00105 "The first argument to this command is the material name, " 00106 "which is always required; density is also required. " 00107 "The command to define an element (e.g. with non-standard " 00108 "density) is:\n" 00109 " material H2 Z=1 A=1.01 density=0.000090\n" 00110 "A mixture or compound is a combination of known materials " 00111 "and/or elements; the command is:\n" 00112 " material water H,0.1119 O,0.8881 density=1.0\n" 00113 "The numbers following the element names are their mass " 00114 "fractions (note that WATER is available from the NIST db). " 00115 "Either type of command can optionally have: pressure, " 00116 "temperature, state.\n\n" 00117 "With no arguments, this command prints the current material " 00118 "table. Note that 'G4_' is prepended to the names of most " 00119 "materials that are obtained from the NIST database; 'G4_Al' " 00120 "and 'Al' refer to the same material (unless one was " 00121 "previously defined using this command).\n\n" 00122 "The following three arguments permit track filtering for all " 00123 "volumes made of this material:\n" 00124 " keep A comma-separated list of particle names to keep.\n" 00125 " kill A comma-separated list of particle names to kill.\n" 00126 " require An expression that must evaluate nonzero or the " 00127 "track\n" 00128 " is killed.\n" 00129 "The require expression uses global coordinates and can use " 00130 "the followng track variables:\n" 00131 " x,y,z,Px,Py,Pz,t,PDGid,EventID,TrackID,ParentID,wt\n\n" 00132 "The following materials are known from the NIST database, " 00133 "and will be automatically created on first use:\n\n"); 00134 // cannot call GetNistMaterialNames() here, so defer to the help() 00135 // function, based on complete_description. 00136 00137 // default values 00138 a = z = density = UNDEFINED; 00139 pressure = STP_Pressure; 00140 temperature = STP_Temperature; 00141 state = ""; 00142 keep = ""; 00143 kill = ""; 00144 require = ""; 00145 material = 0; 00146 complete_description = false; 00147 }
G4String BLCMDmaterial::commandName | ( | ) | [inline, virtual] |
int BLCMDmaterial::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() executes the command associated with this element.
Implements BLCommand.
References a, density, BLCommand::getMaterial(), BLCommand::handleNamedArgs(), keep, kill, material, pressure, BLCommand::printError(), require, snprintf, state, temperature, UNDEFINED, and z.
00150 { 00151 if(argv.size() < 1) { 00152 G4cout << *G4Material::GetMaterialTable() << G4endl; 00153 return 0; 00154 } 00155 00156 // default values 00157 a = z = density = UNDEFINED; 00158 pressure = STP_Pressure; 00159 temperature = STP_Temperature; 00160 state = ""; 00161 keep = ""; 00162 kill = ""; 00163 require = ""; 00164 material = 0; 00165 00166 G4String name = argv[0]; 00167 00168 int retval = handleNamedArgs(namedArgs); 00169 00170 G4State s = kStateUndefined; 00171 switch(state.c_str()[0]) { 00172 case 'g': case 'G': s = kStateGas; break; 00173 case 'l': case 'L': s = kStateLiquid; break; 00174 case 's': case 'S': s = kStateSolid; break; 00175 } 00176 00177 if(density == UNDEFINED) { 00178 printError("material: density is required."); 00179 return -1; 00180 } 00181 00182 if(argv.size() > 1) { // mixture of other materials 00183 int nComponents = argv.size() - 1; 00184 material = new G4Material(name,density,nComponents,s, 00185 temperature,pressure); 00186 int i; 00187 G4double sum = 0.0; 00188 G4String mix; 00189 for(i=1; i<=nComponents; ++i) { 00190 unsigned int j = argv[i].find(','); 00191 if(j == argv[i].npos) break; 00192 G4String p = argv[i].substr(0,j); 00193 G4Material *m = getMaterial(p); 00194 if(!m) break; 00195 char *q = 0; 00196 G4double f = strtod(argv[i].substr(j+1).c_str(),&q); 00197 if(!q || *q != '\0') break; 00198 material->AddMaterial(m,f); 00199 sum += f; 00200 char tmp[64]; 00201 snprintf(tmp,sizeof(tmp),"%.2f*%s",f,p.c_str()); 00202 if(i > 1) mix += "+"; 00203 mix += tmp; 00204 } 00205 if(i != nComponents+1 || sum < 0.99 || sum > 1.01) { 00206 printError("material %-6s invalid mixture/compound", 00207 name.c_str()); 00208 return -1; 00209 } 00210 printf("material %-6s Mixture: %s\n",name.c_str(),mix.c_str()); 00211 printf(" density=%.3f temperature=%.0f pressure=%.1f\n", 00212 density/(gram/cm3),temperature,pressure/atmosphere); 00213 } else { // standalone material 00214 if(a == UNDEFINED || z == UNDEFINED) { 00215 printError("material: need A and/or Z"); 00216 return -1; 00217 } 00218 material = new G4Material(name,z,a,density,s,temperature, 00219 pressure); 00220 printf("material %-6s Z=%.2f A=%.2f\n",name.c_str(),z, 00221 a/(gram/mole)); 00222 printf(" density=%.3f temperature=%.0f pressure=%.1f\n", 00223 density/(gram/cm3),temperature,pressure/atmosphere); 00224 } 00225 00226 if(keep != "" || kill != "" || require != "") 00227 new MaterialFilter(keep,kill,require,material); 00228 00229 return retval; 00230 }
void BLCMDmaterial::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References a, BLCommand::argDouble(), BLCommand::argString(), density, keep, kill, pressure, require, state, temperature, and z.
00233 { 00234 argDouble(a,"a","Effective Atomic Weight of the material (g/mole)",gram/mole); 00235 argDouble(z,"z","Effective Atomic Number of the material"); 00236 argDouble(density,"density","Density of the material (gm/cm^3)",gram/cm3); 00237 argDouble(pressure,"pressure","Pressure of the material (Atm)",atmosphere); 00238 argDouble(temperature,"temperature","Temperature of the material (K)"); 00239 argString(state,"state","State of the material (g,l, or s)"); 00240 argDouble(a,"A","Synonym for a (g/mole)",gram/mole); 00241 argDouble(z,"Z","Synonym for z"); 00242 argString(keep,"keep","A comma-separated list of particle names to keep" 00243 " (all others are killed; ignored if empty)."); 00244 argString(kill,"kill","A comma-separated list of particle names to kill."); 00245 argString(require,"require","An expression that must evaluate nonzero " 00246 "or the track is killed."); 00247 }
void BLCMDmaterial::help | ( | bool | detailed | ) | [virtual] |
help() prints the help.
Reimplemented from BLCommand.
References complete_description, BLCommand::description, and BLCommand::help().
00250 { 00251 if(!complete_description) { 00252 complete_description = true; 00253 G4NistManager *m = G4NistManager::Instance(); 00254 const std::vector<G4String> &v=m->GetNistMaterialNames(); 00255 for(unsigned i=0; i<v.size(); ++i) { 00256 const char *p = v[i].c_str(); 00257 if(strncmp(p,"G4_",3) == 0) p += 3; // omit the initial "G4_" 00258 description += p; 00259 description += " "; 00260 } 00261 description += "Stainless304 Stainless316 lHe "; 00262 description += "\n\nAliases: LHe=lHe Air=AIR, H2O=WATER, " 00263 "Vacuum=Galactic, LH2=lH2, " 00264 "Scintillator=POLYSTYRENE\n"; 00265 } 00266 00267 BLCommand::help(detailed); 00268 }
G4double BLCMDmaterial::a [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4double BLCMDmaterial::z [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4double BLCMDmaterial::density [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4double BLCMDmaterial::pressure [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4double BLCMDmaterial::temperature [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4String BLCMDmaterial::state [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4String BLCMDmaterial::keep [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4String BLCMDmaterial::kill [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4String BLCMDmaterial::require [private] |
Referenced by BLCMDmaterial(), command(), and defineNamedArgs().
G4Material* BLCMDmaterial::material [private] |
Referenced by BLCMDmaterial(), and command().
bool BLCMDmaterial::complete_description [private] |
Referenced by BLCMDmaterial(), and help().