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