47 : fMaterialMessenger(0)
57 static G4bool bmat = false ;
65 AddMaterial(
"Vacuum",
"H", density,
"gas",temperature,pressure);
67 density = 1.290*
mg/
cm3;
75 density=2.3290*
g/
cm3 ;
98 G4cerr <<
" AddMaterial : material " <<name
99 <<
" already exists." <<
G4endl;
105 char *tokenPtr1 = NULL;
109 G4int ncomponents, natoms;
111 size_t ls,
id=0, ll, lr;
114 sname =
new char[strlen(formula)+1];
115 strcpy(sname,formula);
116 tokenPtr1 = strtok(sname,
"-");
118 while (tokenPtr1 != NULL) {
120 tokenPtr1 = strtok( NULL,
"-");
125 G4cout << name <<
" "<< formula <<
" " << density/(
g/
cm3) <<
" " << tem <<
" "
129 aMaterial =
new G4Material(name, density, ncomponents);
130 }
else if (state ==
"solid" && tem > 0.) {
131 aMaterial =
new G4Material(name, density, ncomponents,
133 }
else if (state ==
"gas" && pres > 0.) {
134 aMaterial =
new G4Material(name, density, ncomponents,
137 if (aMaterial == 0) {
143 sname=
new char[strlen(formula)+1];
144 strcpy(sname,formula);
145 tokenPtr1 = strtok(sname,
"-");
147 while (tokenPtr1 != NULL) {
155 id = s0.find_first_of(s1);
156 element = s0.substr(0,
id);
158 if (element.length() == 1) element.insert(0,
" ");
159 for (i = 0; i<110; i++) {
160 if (element ==
fELU[i])
break;
163 for (i = 0; i<110; i++) {
164 if (element ==
fELL[i])
break;
167 for (i = 0; i<110; i++) {
168 if (element ==
fEUU[i])
break;
174 G4cerr <<
"AddMaterial : Invalid element in material formula."
184 if (
id == std::string::npos) {
187 natoms = atoi((s0.substr(
id,ls-
id)).c_str());
189 if (natoms < 1) fatoms = atof((s0.substr(
id,ls-
id)).c_str());
193 element = s0.substr(0,ll);
194 isotope = atoi((s0.substr(ll+1,lr-ll)).c_str());
195 if (element.length() == 1) element.insert(0,
" ");
196 for (i = 0; i<110; i++) {
197 if (element ==
fELU[i])
break;
200 for (i = 0; i<110; i++) {
201 if (element ==
fELL[i])
break;
204 for (i = 0; i<110; i++) {
205 if (element ==
fEUU[i])
break;
210 G4cerr <<
"AddMaterial : Invalid element in material formula."
220 isotopename = element+s0.substr(ll+1,lr-ll-1);
221 if (lr == std::string::npos ) {
224 natoms = atoi((s0.substr(lr+1,ls-lr)).c_str());
226 if (natoms < 1) fatoms = atof((s0.substr(
id,ls-
id)).c_str());
227 if (fatoms == 0.) natoms = 1;
269 tokenPtr1 = strtok( NULL,
"-");
277 G4cout <<
" fMaterial:" <<name <<
" with formula: " <<formula <<
" added! "
289 G4cerr <<
"DeleteMaterial : Invalid material index " <<j <<
"." <<
G4endl;
292 G4cerr <<
"It seems there is no mechanism in G4 for deleting a material yet!"
301 G4cerr <<
"It seems there is no mechanism in G4 for deleting a material yet!"
322 <<
" materials defined." <<
G4endl;
323 for (
size_t i = 0; i<
fMaterial.size(); i++)
324 G4cout <<
" fMaterial Index " <<std::setw(3) <<i+1 <<
" "
325 <<std::setw(14) <<
fMaterial[i]->GetName()
326 <<
" density: " <<std::setw(6) <<std::setprecision(3)
static const G4String fELU[110]
std::vector< G4Element * > fElement
static G4Element * GetElement(G4String name, G4bool warning=true)
Definition of the exrdmMaterialMessenger class.
static const G4String fEUU[110]
std::vector< G4Material * > fMaterial
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4int GetMaterialIndex(G4String)
static G4Isotope * GetIsotope(const G4String &name, G4bool warning=false)
void AddMaterial(G4String, G4String, G4double, G4String, G4double tem=CLHEP::STP_Temperature, G4double pres=CLHEP::STP_Pressure)
Definition of the exrdmMaterial class.
std::vector< G4Isotope * > fIsotope
G4GLOB_DLL std::ostream G4cout
exrdmMaterialMessenger * fMaterialMessenger
void DeleteMaterial(G4int)
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
static const double perCent
static const double kelvin
Definition of the exrdmMaterialData class.
void AddElement(G4Element *element, G4int nAtoms)
static const G4double fA[110]
static const G4String fELL[110]
G4GLOB_DLL std::ostream G4cerr