54 static G4bool bmat = false ;
62 AddMaterial(
"Vacuum",
"H", density,
"gas",temperature,pressure);
64 density = 1.290*
mg/
cm3;
72 density=2.3290*
g/
cm3 ;
84 delete fMaterialMessenger;
93 for (i = 0; i<fMaterial.size(); i++) {
94 if (fMaterial[i]->GetName() ==
name) {
95 G4cerr <<
" AddMaterial : material " <<name
96 <<
" already exists." <<
G4endl;
102 char *tokenPtr1 = NULL;
106 G4int ncomponents, natoms;
108 size_t ls,
id=0, ll, lr;
111 sname =
new char[strlen(formula)+1];
112 strcpy(sname,formula);
113 tokenPtr1 = strtok(sname,
"-");
115 while (tokenPtr1 != NULL) {
117 tokenPtr1 = strtok( NULL,
"-");
122 G4cout << name <<
" "<< formula <<
" " << density/(
g/
cm3) <<
" " << tem <<
" "
126 aMaterial =
new G4Material(name, density, ncomponents);
127 }
else if (state ==
"solid" && tem > 0.) {
128 aMaterial =
new G4Material(name, density, ncomponents,
130 }
else if (state ==
"gas" && pres > 0.) {
131 aMaterial =
new G4Material(name, density, ncomponents,
134 if (aMaterial == 0) {
140 sname=
new char[strlen(formula)+1];
141 strcpy(sname,formula);
142 tokenPtr1 = strtok(sname,
"-");
144 while (tokenPtr1 != NULL) {
152 id = s0.find_first_of(s1);
153 element = s0.substr(0,
id);
155 if (element.length() == 1) element.insert(0,
" ");
156 for (i = 0; i<110; i++) {
157 if (element == fELU[i])
break;
160 for (i = 0; i<110; i++) {
161 if (element == fELL[i])
break;
164 for (i = 0; i<110; i++) {
165 if (element == fEUU[i])
break;
171 G4cerr <<
"AddMaterial : Invalid element in material formula."
181 if (
id == std::string::npos) {
184 natoms = atoi((s0.substr(
id,ls-
id)).c_str());
186 if (natoms < 1) fatoms = atof((s0.substr(
id,ls-
id)).c_str());
190 element = s0.substr(0,ll);
191 isotope = atoi((s0.substr(ll+1,lr-ll)).c_str());
192 if (element.length() == 1) element.insert(0,
" ");
193 for (i = 0; i<110; i++) {
194 if (element == fELU[i])
break;
197 for (i = 0; i<110; i++) {
198 if (element == fELL[i])
break;
201 for (i = 0; i<110; i++) {
202 if (element == fEUU[i])
break;
207 G4cerr <<
"AddMaterial : Invalid element in material formula."
217 isotopename = element+s0.substr(ll+1,lr-ll-1);
218 if (lr == std::string::npos ) {
221 natoms = atoi((s0.substr(lr+1,ls-lr)).c_str());
223 if (natoms < 1) fatoms = atof((s0.substr(
id,ls-
id)).c_str());
224 if (fatoms == 0.) natoms = 1;
235 fIsotope.push_back(aIsotope);
241 fElement.push_back(aElement);
257 fElement.push_back(aElement);
266 tokenPtr1 = strtok( NULL,
"-");
273 fMaterial.push_back(aMaterial);
274 G4cout <<
" fMaterial:" <<name <<
" with formula: " <<formula <<
" added! "
276 G4cout <<
" Nb of fMaterial = " <<fMaterial.size() <<
G4endl;
277 G4cout <<
" Nb of fIsotope = " <<fIsotope.size() <<
G4endl;
278 G4cout <<
" Nb of fElement = " <<fElement.size() <<
G4endl;
285 if (i > fMaterial.size()) {
286 G4cerr <<
"DeleteMaterial : Invalid material index " <<j <<
"." <<
G4endl;
289 G4cerr <<
"It seems there is no mechanism in G4 for deleting a material yet!"
298 G4cerr <<
"It seems there is no mechanism in G4 for deleting a material yet!"
307 for (i = 0; i < fMaterial.size(); i++) {
308 if (fMaterial[i]->GetName() ==
name)
break;
311 if (i == fMaterial.size()) k = -1;
318 G4cout <<
" There are" <<std::setw(3) <<fMaterial.size()
319 <<
" materials defined." <<
G4endl;
320 for (
size_t i = 0; i< fMaterial.size(); i++)
321 G4cout <<
" fMaterial Index " <<std::setw(3) <<i+1 <<
" "
322 <<std::setw(14) <<fMaterial[i]->GetName()
323 <<
" density: " <<std::setw(6) <<std::setprecision(3)