Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // << 26 // 7 // >> 8 // $Id: G4gsmixt.cc,v 1.7 1999/12/15 14:49:43 gunter Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ 27 // 10 // 28 // by I.Hrivnacova, 27 Sep 99 11 // by I.Hrivnacova, 27 Sep 99 29 12 30 #include <iomanip> << 13 #include "g4std/iomanip" 31 #include <iomanip> << 14 #include "g4std/strstream" >> 15 #include "g4std/iomanip" >> 16 #include <math.h> 32 17 33 #include "globals.hh" 18 #include "globals.hh" 34 #include "G4SystemOfUnits.hh" << 35 << 36 #include "G3toG4.hh" 19 #include "G3toG4.hh" 37 #include "G3EleTable.hh" 20 #include "G3EleTable.hh" 38 #include "G3MatTable.hh" 21 #include "G3MatTable.hh" 39 #include "G4Material.hh" 22 #include "G4Material.hh" 40 #include "G4Isotope.hh" 23 #include "G4Isotope.hh" 41 24 42 void PG4gsmixt(G4String *tokens) << 25 void PG4gsmixt(G4String tokens[]) 43 { 26 { 44 // fill the parameter containers 27 // fill the parameter containers 45 G3fillParams(tokens,PTgsmixt); 28 G3fillParams(tokens,PTgsmixt); 46 29 47 // interpret the parameters 30 // interpret the parameters 48 G4String name = Spar[0].data(); 31 G4String name = Spar[0].data(); 49 G4int imate = Ipar[0]; 32 G4int imate = Ipar[0]; 50 G4int nlmat = Ipar[1]; 33 G4int nlmat = Ipar[1]; 51 //G4double dens = Rpar[0]*g/cm3; 34 //G4double dens = Rpar[0]*g/cm3; 52 G4double dens = Rpar[0]; 35 G4double dens = Rpar[0]; 53 G4double *a = Rpar + 1; 36 G4double *a = Rpar + 1; 54 G4double *z = Rpar + 1+std::abs(nlmat); << 37 G4double *z = Rpar + 1+abs(nlmat); 55 G4double *wmat = Rpar + 1 + 2*std::abs(nlm << 38 G4double *wmat = Rpar + 1 + 2*abs(nlmat); 56 /* << 39 57 for (int i=0; i<std::abs(nlmat); i++){ << 40 for (int i=0; i<abs(nlmat); i++){ 58 //Rpar[i]=Rpar[i]*g/mole; 41 //Rpar[i]=Rpar[i]*g/mole; 59 Rpar[i]=Rpar[i]; 42 Rpar[i]=Rpar[i]; 60 }; 43 }; 61 */ << 62 G4gsmixt(imate,name,a,z,dens,nlmat,wmat); 44 G4gsmixt(imate,name,a,z,dens,nlmat,wmat); 63 } 45 } 64 46 65 // replaced with G3EleTable 47 // replaced with G3EleTable 66 // only used G4Elements are created; 48 // only used G4Elements are created; 67 // !! no checking of given A of the element; 49 // !! no checking of given A of the element; 68 // 50 // 69 // extern G4Element* CreateElement(G4double ze 51 // extern G4Element* CreateElement(G4double zeff, G4double aeff, G4String matName); 70 52 71 53 72 void G4gsmixt(G4int imate, G4String name, G4do 54 void G4gsmixt(G4int imate, G4String name, G4double* a, G4double* z, 73 G4double dens, G4int nlmat, G4do 55 G4double dens, G4int nlmat, G4double* wmat) 74 { 56 { 75 // in Geant3: 57 // in Geant3: 76 // After a call with ratios by number (negat 58 // After a call with ratios by number (negative number of elements), 77 // the ratio array is changed to the ratio b 59 // the ratio array is changed to the ratio by weight, so all successive 78 // calls with the same array must specify th 60 // calls with the same array must specify the number of elements as 79 // positive 61 // positive 80 G4int i=0; 62 G4int i=0; 81 if (nlmat<0) { 63 if (nlmat<0) { 82 // in case of proportions given in atom co 64 // in case of proportions given in atom counts (nlmat<0), 83 // the wmat[i] are converted to weight fra 65 // the wmat[i] are converted to weight fractions 84 G4double aMol = 0.; 66 G4double aMol = 0.; 85 for (i=0; i<std::abs(nlmat); i++) { << 67 for (i=0; i<abs(nlmat); i++) { 86 // total molecular weight 68 // total molecular weight 87 aMol += wmat[i]*a[i]; 69 aMol += wmat[i]*a[i]; 88 } 70 } 89 if (aMol == 0.) { << 71 if (aMol == 0.) 90 G4String text = "G4mixt: Total molecular << 72 G4Exception("\nG4mixt: Total molecular weight in " + 91 G4Exception("G4gsmixt()", "G3toG40016", << 73 name + " = 0."); 92 return; << 74 for (i=0; i<abs(nlmat); i++) { 93 } << 94 for (i=0; i<std::abs(nlmat); i++) { << 95 // weight fractions 75 // weight fractions 96 wmat[i] = wmat[i]*a[i]/aMol; 76 wmat[i] = wmat[i]*a[i]/aMol; 97 } 77 } 98 } 78 } 99 79 100 // create material with given number of comp 80 // create material with given number of components 101 // (elements) 81 // (elements) 102 82 103 G4Material* material 83 G4Material* material 104 = new G4Material(name, dens*g/cm3, std::ab << 84 = new G4Material(name, dens*g/cm3, abs(nlmat)); 105 for (i=0; i<std::abs(nlmat); i++) { << 85 for (i=0; i<abs(nlmat); i++) { 106 // add units 86 // add units 107 // G4Element* element = G4Element(z[i], a[ 87 // G4Element* element = G4Element(z[i], a[i]*g/mole, name); 108 G4Element* element = G3Ele.GetEle(z[i]); 88 G4Element* element = G3Ele.GetEle(z[i]); 109 material->AddElement(element, wmat[i]); 89 material->AddElement(element, wmat[i]); 110 } 90 } 111 91 112 // add the material to the List 92 // add the material to the List 113 G3Mat.put(imate, material); 93 G3Mat.put(imate, material); 114 } 94 } 115 95 116 /* 96 /* 117 void G4gsmixt(G4int imate, G4String name, G4do 97 void G4gsmixt(G4int imate, G4String name, G4double a[], G4double z[], 118 G4double dens, G4int nlmat, G4do 98 G4double dens, G4int nlmat, G4double wmat[]){ 119 G4int nmate = std::abs(nlmat); << 99 G4int nmate = abs(nlmat); 120 G4String sname = name.strip(G4String::both); 100 G4String sname = name.strip(G4String::both); 121 G4double theDensity = dens*g/cm3; 101 G4double theDensity = dens*g/cm3; 122 102 123 G4Material* theMixture = new G4Material(name 103 G4Material* theMixture = new G4Material(name, dens, nmate); 124 G4bool ok=true; 104 G4bool ok=true; 125 for (int i=0; i< nmate; i++){ 105 for (int i=0; i< nmate; i++){ 126 G4Element* theElement = G3Ele.GetEle(z[i]) 106 G4Element* theElement = G3Ele.GetEle(z[i]); 127 if (nlmat>0) { 107 if (nlmat>0) { 128 G4double fractionmass = wmat[i]; 108 G4double fractionmass = wmat[i]; 129 ok = ok && std::abs(fractionmass)<=1.; << 109 ok = ok && abs(fractionmass)<=1.; 130 theMixture->AddElement(theElement, fract 110 theMixture->AddElement(theElement, fractionmass); 131 } else if (nlmat<0) { 111 } else if (nlmat<0) { 132 G4int natoms = wmat[i]; 112 G4int natoms = wmat[i]; 133 ok = ok && wmat[i] == natoms; 113 ok = ok && wmat[i] == natoms; 134 theMixture->AddElement(theElement, natom 114 theMixture->AddElement(theElement, natoms); 135 } else { 115 } else { 136 ok=false; 116 ok=false; 137 } 117 } 138 } 118 } 139 if (ok) { 119 if (ok) { 140 G3Mat.put(imate, theMixture); 120 G3Mat.put(imate, theMixture); 141 } else { 121 } else { 142 if (nlmat>0) { 122 if (nlmat>0) { 143 G4cerr << "G4gsmixt: for mixture '" << n 123 G4cerr << "G4gsmixt: for mixture '" << name 144 << "' some |weights|>1 : " << G4endl; 124 << "' some |weights|>1 : " << G4endl; 145 for (G4int i=0;i<nlmat; i++) { 125 for (G4int i=0;i<nlmat; i++) { 146 G4cerr << "Component " << std::setw(3) << i+ << 126 G4cerr << "Component " << G4std::setw(3) << i+1 << " fraction: " 147 << std::setw(10) << wmat[i] << G4endl << 127 << G4std::setw(10) << wmat[i] << G4endl; 148 } 128 } 149 } else if (nlmat<0) { 129 } else if (nlmat<0) { 150 G4cerr << "G4gsmixt: for mixture '" << n 130 G4cerr << "G4gsmixt: for mixture '" << name 151 << "' some #natoms are non-integer: " < 131 << "' some #natoms are non-integer: " << G4endl; 152 for (G4int i=0;i<nlmat; i++) { 132 for (G4int i=0;i<nlmat; i++) { 153 G4cerr << "Component " << std::setw(3) << i+ << 133 G4cerr << "Component " << G4std::setw(3) << i+1 << " #atoms " 154 << std::setw(10) << wmat[i] << G4endl << 134 << G4std::setw(10) << wmat[i] << G4endl; 155 } 135 } 156 } else { 136 } else { 157 G4cerr << "G4gsmixt: Number of component 137 G4cerr << "G4gsmixt: Number of components for mixture '" 158 << name << "' (" << nlmat << ") not all 138 << name << "' (" << nlmat << ") not allowed." << G4endl; 159 } 139 } 160 } 140 } 161 } 141 } 162 */ 142 */ 163 143 164 144 165 145 166 146