Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
g3tog4
src
G4gsmixt.cc
Go to the documentation of this file.
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$
28
//
29
// by I.Hrivnacova, 27 Sep 99
30
31
#include <iomanip>
32
#include <iomanip>
33
34
#include "
globals.hh
"
35
#include "
G4SystemOfUnits.hh
"
36
37
#include "
G3toG4.hh
"
38
#include "
G3EleTable.hh
"
39
#include "
G3MatTable.hh
"
40
#include "
G4Material.hh
"
41
#include "
G4Isotope.hh
"
42
43
void
PG4gsmixt
(
G4String
*tokens)
44
{
45
// fill the parameter containers
46
G3fillParams
(tokens,
PTgsmixt
);
47
48
// interpret the parameters
49
G4String
name
=
Spar
[0].
data
();
50
G4int
imate =
Ipar
[0];
51
G4int
nlmat =
Ipar
[1];
52
//G4double dens = Rpar[0]*g/cm3;
53
G4double
dens =
Rpar
[0];
54
G4double
*
a
=
Rpar
+ 1;
55
G4double
*
z
=
Rpar
+ 1+std::abs(nlmat);
56
G4double
*wmat =
Rpar
+ 1 + 2*std::abs(nlmat);
57
/*
58
for (int i=0; i<std::abs(nlmat); i++){
59
//Rpar[i]=Rpar[i]*g/mole;
60
Rpar[i]=Rpar[i];
61
};
62
*/
63
G4gsmixt
(imate,name,a,z,dens,nlmat,wmat);
64
}
65
66
// replaced with G3EleTable
67
// only used G4Elements are created;
68
// !! no checking of given A of the element;
69
//
70
// extern G4Element* CreateElement(G4double zeff, G4double aeff, G4String matName);
71
72
73
void
G4gsmixt
(
G4int
imate,
G4String
name
,
G4double
*
a
,
G4double
*
z
,
74
G4double
dens,
G4int
nlmat,
G4double
* wmat)
75
{
76
// in Geant3:
77
// After a call with ratios by number (negative number of elements),
78
// the ratio array is changed to the ratio by weight, so all successive
79
// calls with the same array must specify the number of elements as
80
// positive
81
G4int
i=0;
82
if
(nlmat<0) {
83
// in case of proportions given in atom counts (nlmat<0),
84
// the wmat[i] are converted to weight fractions
85
G4double
aMol = 0.;
86
for
(i=0; i<std::abs(nlmat); i++) {
87
// total molecular weight
88
aMol += wmat[i]*a[i];
89
}
90
if
(aMol == 0.) {
91
G4String
text =
"G4mixt: Total molecular weight in "
+ name +
" = 0."
;
92
G4Exception
(
"G4gsmixt()"
,
"G3toG40016"
,
FatalException
, text);
93
return
;
94
}
95
for
(i=0; i<std::abs(nlmat); i++) {
96
// weight fractions
97
wmat[i] = wmat[i]*a[i]/aMol;
98
}
99
}
100
101
// create material with given number of components
102
// (elements)
103
104
G4Material
*
material
105
=
new
G4Material
(name, dens*
g
/
cm3
, std::abs(nlmat));
106
for
(i=0; i<std::abs(nlmat); i++) {
107
// add units
108
// G4Element* element = G4Element(z[i], a[i]*g/mole, name);
109
G4Element
* element =
G3Ele
.
GetEle
(z[i]);
110
material->
AddElement
(element, wmat[i]);
111
}
112
113
// add the material to the List
114
G3Mat
.
put
(imate, material);
115
}
116
117
/*
118
void G4gsmixt(G4int imate, G4String name, G4double a[], G4double z[],
119
G4double dens, G4int nlmat, G4double wmat[]){
120
G4int nmate = std::abs(nlmat);
121
G4String sname = name.strip(G4String::both);
122
G4double theDensity = dens*g/cm3;
123
124
G4Material* theMixture = new G4Material(name, dens, nmate);
125
G4bool ok=true;
126
for (int i=0; i< nmate; i++){
127
G4Element* theElement = G3Ele.GetEle(z[i]);
128
if (nlmat>0) {
129
G4double fractionmass = wmat[i];
130
ok = ok && std::abs(fractionmass)<=1.;
131
theMixture->AddElement(theElement, fractionmass);
132
} else if (nlmat<0) {
133
G4int natoms = wmat[i];
134
ok = ok && wmat[i] == natoms;
135
theMixture->AddElement(theElement, natoms);
136
} else {
137
ok=false;
138
}
139
}
140
if (ok) {
141
G3Mat.put(imate, theMixture);
142
} else {
143
if (nlmat>0) {
144
G4cerr << "G4gsmixt: for mixture '" << name
145
<< "' some |weights|>1 : " << G4endl;
146
for (G4int i=0;i<nlmat; i++) {
147
G4cerr << "Component " << std::setw(3) << i+1 << " fraction: "
148
<< std::setw(10) << wmat[i] << G4endl;
149
}
150
} else if (nlmat<0) {
151
G4cerr << "G4gsmixt: for mixture '" << name
152
<< "' some #natoms are non-integer: " << G4endl;
153
for (G4int i=0;i<nlmat; i++) {
154
G4cerr << "Component " << std::setw(3) << i+1 << " #atoms "
155
<< std::setw(10) << wmat[i] << G4endl;
156
}
157
} else {
158
G4cerr << "G4gsmixt: Number of components for mixture '"
159
<< name << "' (" << nlmat << ") not allowed." << G4endl;
160
}
161
}
162
}
163
*/
164
165
166
Generated on Sat May 25 2013 14:33:09 for Geant4 by
1.8.4