00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // by I.Hrivnacova, 27 Sep 99 00030 00031 #include <iomanip> 00032 #include <iomanip> 00033 00034 #include "globals.hh" 00035 #include "G4SystemOfUnits.hh" 00036 00037 #include "G3toG4.hh" 00038 #include "G3EleTable.hh" 00039 #include "G3MatTable.hh" 00040 #include "G4Material.hh" 00041 #include "G4Isotope.hh" 00042 00043 void PG4gsmixt(G4String *tokens) 00044 { 00045 // fill the parameter containers 00046 G3fillParams(tokens,PTgsmixt); 00047 00048 // interpret the parameters 00049 G4String name = Spar[0].data(); 00050 G4int imate = Ipar[0]; 00051 G4int nlmat = Ipar[1]; 00052 //G4double dens = Rpar[0]*g/cm3; 00053 G4double dens = Rpar[0]; 00054 G4double *a = Rpar + 1; 00055 G4double *z = Rpar + 1+std::abs(nlmat); 00056 G4double *wmat = Rpar + 1 + 2*std::abs(nlmat); 00057 /* 00058 for (int i=0; i<std::abs(nlmat); i++){ 00059 //Rpar[i]=Rpar[i]*g/mole; 00060 Rpar[i]=Rpar[i]; 00061 }; 00062 */ 00063 G4gsmixt(imate,name,a,z,dens,nlmat,wmat); 00064 } 00065 00066 // replaced with G3EleTable 00067 // only used G4Elements are created; 00068 // !! no checking of given A of the element; 00069 // 00070 // extern G4Element* CreateElement(G4double zeff, G4double aeff, G4String matName); 00071 00072 00073 void G4gsmixt(G4int imate, G4String name, G4double* a, G4double* z, 00074 G4double dens, G4int nlmat, G4double* wmat) 00075 { 00076 // in Geant3: 00077 // After a call with ratios by number (negative number of elements), 00078 // the ratio array is changed to the ratio by weight, so all successive 00079 // calls with the same array must specify the number of elements as 00080 // positive 00081 G4int i=0; 00082 if (nlmat<0) { 00083 // in case of proportions given in atom counts (nlmat<0), 00084 // the wmat[i] are converted to weight fractions 00085 G4double aMol = 0.; 00086 for (i=0; i<std::abs(nlmat); i++) { 00087 // total molecular weight 00088 aMol += wmat[i]*a[i]; 00089 } 00090 if (aMol == 0.) { 00091 G4String text = "G4mixt: Total molecular weight in " + name + " = 0."; 00092 G4Exception("G4gsmixt()", "G3toG40016", FatalException, text); 00093 return; 00094 } 00095 for (i=0; i<std::abs(nlmat); i++) { 00096 // weight fractions 00097 wmat[i] = wmat[i]*a[i]/aMol; 00098 } 00099 } 00100 00101 // create material with given number of components 00102 // (elements) 00103 00104 G4Material* material 00105 = new G4Material(name, dens*g/cm3, std::abs(nlmat)); 00106 for (i=0; i<std::abs(nlmat); i++) { 00107 // add units 00108 // G4Element* element = G4Element(z[i], a[i]*g/mole, name); 00109 G4Element* element = G3Ele.GetEle(z[i]); 00110 material->AddElement(element, wmat[i]); 00111 } 00112 00113 // add the material to the List 00114 G3Mat.put(imate, material); 00115 } 00116 00117 /* 00118 void G4gsmixt(G4int imate, G4String name, G4double a[], G4double z[], 00119 G4double dens, G4int nlmat, G4double wmat[]){ 00120 G4int nmate = std::abs(nlmat); 00121 G4String sname = name.strip(G4String::both); 00122 G4double theDensity = dens*g/cm3; 00123 00124 G4Material* theMixture = new G4Material(name, dens, nmate); 00125 G4bool ok=true; 00126 for (int i=0; i< nmate; i++){ 00127 G4Element* theElement = G3Ele.GetEle(z[i]); 00128 if (nlmat>0) { 00129 G4double fractionmass = wmat[i]; 00130 ok = ok && std::abs(fractionmass)<=1.; 00131 theMixture->AddElement(theElement, fractionmass); 00132 } else if (nlmat<0) { 00133 G4int natoms = wmat[i]; 00134 ok = ok && wmat[i] == natoms; 00135 theMixture->AddElement(theElement, natoms); 00136 } else { 00137 ok=false; 00138 } 00139 } 00140 if (ok) { 00141 G3Mat.put(imate, theMixture); 00142 } else { 00143 if (nlmat>0) { 00144 G4cerr << "G4gsmixt: for mixture '" << name 00145 << "' some |weights|>1 : " << G4endl; 00146 for (G4int i=0;i<nlmat; i++) { 00147 G4cerr << "Component " << std::setw(3) << i+1 << " fraction: " 00148 << std::setw(10) << wmat[i] << G4endl; 00149 } 00150 } else if (nlmat<0) { 00151 G4cerr << "G4gsmixt: for mixture '" << name 00152 << "' some #natoms are non-integer: " << G4endl; 00153 for (G4int i=0;i<nlmat; i++) { 00154 G4cerr << "Component " << std::setw(3) << i+1 << " #atoms " 00155 << std::setw(10) << wmat[i] << G4endl; 00156 } 00157 } else { 00158 G4cerr << "G4gsmixt: Number of components for mixture '" 00159 << name << "' (" << nlmat << ") not allowed." << G4endl; 00160 } 00161 } 00162 } 00163 */ 00164 00165 00166