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