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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /g3tog4/src/G4gsmixt.cc (Version 11.3.0) and /g3tog4/src/G4gsmixt.cc (Version 9.1.p3)


  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 // $Id: G4gsmixt.cc,v 1.13 2006/06/29 18:14:37 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-01-patch-03 $
 27 //                                                 29 //
 28 // by I.Hrivnacova, 27 Sep 99                      30 // by I.Hrivnacova, 27 Sep 99
 29                                                    31 
                                                   >>  32 #include "globals.hh"
 30 #include <iomanip>                                 33 #include <iomanip>
 31 #include <iomanip>                                 34 #include <iomanip>
 32                                                    35 
 33 #include "globals.hh"                          << 
 34 #include "G4SystemOfUnits.hh"                  << 
 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 */                                             << 
 62     G4gsmixt(imate,name,a,z,dens,nlmat,wmat);      61     G4gsmixt(imate,name,a,z,dens,nlmat,wmat);
 63 }                                                  62 }
 64                                                    63 
 65 // replaced with G3EleTable                        64 // replaced with G3EleTable 
 66 // only used G4Elements are created;               65 // only used G4Elements are created;
 67 // !! no checking of given A of the element;       66 // !! no checking of given A of the element;
 68 //                                                 67 //
 69 // extern G4Element* CreateElement(G4double ze     68 // extern G4Element* CreateElement(G4double zeff, G4double aeff, G4String matName);
 70                                                    69 
 71                                                    70 
 72 void G4gsmixt(G4int imate, G4String name, G4do     71 void G4gsmixt(G4int imate, G4String name, G4double* a, G4double* z,
 73               G4double dens, G4int nlmat, G4do     72               G4double dens, G4int nlmat, G4double* wmat)
 74 {                                                  73 {
 75   // in Geant3:                                    74   // in Geant3:
 76   // After a call with ratios by number (negat     75   // After a call with ratios by number (negative number of elements), 
 77   // the ratio array is changed to the ratio b     76   // the ratio array is changed to the ratio by weight, so all successive 
 78   // calls with the same array must specify th     77   // calls with the same array must specify the number of elements as 
 79   // positive                                      78   // positive 
 80   G4int i=0;                                       79   G4int i=0;
 81   if (nlmat<0) {                                   80   if (nlmat<0) {
 82     // in case of proportions given in atom co     81     // in case of proportions given in atom counts (nlmat<0),
 83     // the wmat[i] are converted to weight fra     82     // the wmat[i] are converted to weight fractions
 84     G4double aMol = 0.;                            83     G4double aMol = 0.;
 85     for (i=0; i<std::abs(nlmat); i++) {            84     for (i=0; i<std::abs(nlmat); i++) { 
 86       // total molecular weight                    85       // total molecular weight 
 87       aMol += wmat[i]*a[i];                        86       aMol += wmat[i]*a[i]; 
 88     }                                              87     }  
 89     if (aMol == 0.) {                          <<  88     if (aMol == 0.)
 90       G4String text = "G4mixt: Total molecular <<  89       G4Exception("\nG4mixt: Total molecular weight in " +
 91       G4Exception("G4gsmixt()", "G3toG40016",  <<  90         name + " = 0.");       
 92       return;                                  << 
 93     }                                          << 
 94     for (i=0; i<std::abs(nlmat); i++) {            91     for (i=0; i<std::abs(nlmat); i++) {
 95       // weight fractions                          92       // weight fractions
 96       wmat[i] = wmat[i]*a[i]/aMol;                 93       wmat[i] = wmat[i]*a[i]/aMol;
 97     }                                              94     }
 98   }                                                95   }
 99                                                    96 
100   // create material with given number of comp     97   // create material with given number of components
101   // (elements)                                    98   // (elements)
102                                                    99 
103   G4Material* material                            100   G4Material* material 
104     = new G4Material(name, dens*g/cm3, std::ab    101     = new G4Material(name, dens*g/cm3, std::abs(nlmat));
105   for (i=0; i<std::abs(nlmat); i++) {             102   for (i=0; i<std::abs(nlmat); i++) {
106     // add units                                  103     // add units
107     // G4Element* element = G4Element(z[i], a[    104     // G4Element* element = G4Element(z[i], a[i]*g/mole, name);
108     G4Element* element = G3Ele.GetEle(z[i]);      105     G4Element* element = G3Ele.GetEle(z[i]);
109     material->AddElement(element, wmat[i]);       106     material->AddElement(element, wmat[i]);    
110   }                                               107   }
111                                                   108 
112   // add the material to the List                 109   // add the material to the List
113   G3Mat.put(imate, material);                     110   G3Mat.put(imate, material);
114 }                                                 111 }
115                                                   112 
116 /*                                                113 /*
117 void G4gsmixt(G4int imate, G4String name, G4do    114 void G4gsmixt(G4int imate, G4String name, G4double a[], G4double z[],
118               G4double dens, G4int nlmat, G4do    115               G4double dens, G4int nlmat, G4double wmat[]){
119   G4int nmate = std::abs(nlmat);                  116   G4int nmate = std::abs(nlmat);
120   G4String sname = name.strip(G4String::both);    117   G4String sname = name.strip(G4String::both);
121   G4double theDensity = dens*g/cm3;               118   G4double theDensity = dens*g/cm3;
122                                                   119 
123   G4Material* theMixture = new G4Material(name    120   G4Material* theMixture = new G4Material(name, dens, nmate); 
124   G4bool ok=true;                                 121   G4bool ok=true;
125   for (int i=0; i< nmate; i++){                   122   for (int i=0; i< nmate; i++){
126     G4Element* theElement = G3Ele.GetEle(z[i])    123     G4Element* theElement = G3Ele.GetEle(z[i]);
127     if (nlmat>0) {                                124     if (nlmat>0) {
128       G4double fractionmass = wmat[i];            125       G4double fractionmass = wmat[i];
129       ok = ok && std::abs(fractionmass)<=1.;      126       ok = ok && std::abs(fractionmass)<=1.;
130       theMixture->AddElement(theElement, fract    127       theMixture->AddElement(theElement, fractionmass);
131     } else if (nlmat<0) {                         128     } else if (nlmat<0) {
132       G4int natoms = wmat[i];                     129       G4int natoms = wmat[i];
133       ok = ok && wmat[i] == natoms;               130       ok = ok && wmat[i] == natoms;
134       theMixture->AddElement(theElement, natom    131       theMixture->AddElement(theElement, natoms);
135     } else {                                      132     } else {
136       ok=false;                                   133       ok=false;
137     }                                             134     }
138   }                                               135   }
139   if (ok) {                                       136   if (ok) {
140     G3Mat.put(imate, theMixture);                 137     G3Mat.put(imate, theMixture);
141   } else {                                        138   } else {
142     if (nlmat>0) {                                139     if (nlmat>0) {
143       G4cerr << "G4gsmixt: for mixture '" << n    140       G4cerr << "G4gsmixt: for mixture '" << name 
144        << "' some |weights|>1 : " << G4endl;      141        << "' some |weights|>1 : " << G4endl;
145       for (G4int i=0;i<nlmat; i++) {              142       for (G4int i=0;i<nlmat; i++) {
146   G4cerr << "Component " << std::setw(3) << i+    143   G4cerr << "Component " << std::setw(3) << i+1 << " fraction: "
147          << std::setw(10) << wmat[i] << G4endl    144          << std::setw(10) << wmat[i] << G4endl;
148       }                                           145       }
149     } else if (nlmat<0) {                         146     } else if (nlmat<0) {
150       G4cerr << "G4gsmixt: for mixture '" << n    147       G4cerr << "G4gsmixt: for mixture '" << name 
151        << "' some #natoms are non-integer: " <    148        << "' some #natoms are non-integer: " << G4endl;
152       for (G4int i=0;i<nlmat; i++) {              149       for (G4int i=0;i<nlmat; i++) {
153   G4cerr << "Component " << std::setw(3) << i+    150   G4cerr << "Component " << std::setw(3) << i+1 << " #atoms "
154          << std::setw(10) << wmat[i] << G4endl    151          << std::setw(10) << wmat[i] << G4endl;
155       }                                           152       }
156     } else {                                      153     } else {
157       G4cerr << "G4gsmixt: Number of component    154       G4cerr << "G4gsmixt: Number of components for mixture '" 
158        << name << "' (" << nlmat << ") not all    155        << name << "' (" << nlmat << ") not allowed." << G4endl;
159     }                                             156     }
160   }                                               157   }
161 }                                                 158 }
162 */                                                159 */
163                                                   160 
164                                                   161 
165                                                   162 
166                                                   163