37 #include <Geant4/G4PhysicalConstants.hh>
38 #include <Geant4/G4SystemOfUnits.hh>
39 #include <Geant4/G4Element.hh>
40 #include <Geant4/G4Isotope.hh>
41 #include <Geant4/G4Material.hh>
58 xercesc::DOMElement* atomElement =
NewElement(
"atom");
59 atomElement->setAttributeNode(
NewAttribute(
"unit",
"g/mole"));
61 element->appendChild(atomElement);
67 xercesc::DOMElement* DElement =
NewElement(
"D");
68 DElement->setAttributeNode(
NewAttribute(
"unit",
"g/cm3"));
70 element->appendChild(DElement);
76 xercesc::DOMElement* PElement =
NewElement(
"P");
77 PElement->setAttributeNode(
NewAttribute(
"unit",
"pascal"));
79 element->appendChild(PElement);
85 xercesc::DOMElement* TElement =
NewElement(
"T");
88 element->appendChild(TElement);
94 xercesc::DOMElement* PElement =
NewElement(
"MEE");
97 element->appendChild(PElement);
105 xercesc::DOMElement* isotopeElement =
NewElement(
"isotope");
106 isotopeElement->setAttributeNode(
NewAttribute(
"name",name));
117 xercesc::DOMElement* elementElement =
NewElement(
"element");
118 elementElement->setAttributeNode(
NewAttribute(
"name",name));
122 if (NumberOfIsotopes>0)
124 const G4double* RelativeAbundanceVector =
126 for (
size_t i=0;i<NumberOfIsotopes;i++)
130 xercesc::DOMElement* fractionElement =
NewElement(
"fraction");
132 RelativeAbundanceVector[i]));
133 fractionElement->setAttributeNode(
NewAttribute(
"ref",fractionref));
134 elementElement->appendChild(fractionElement);
152 if (state==
kStateSolid) { state_str =
"solid"; }
else
154 if (state==
kStateGas) { state_str =
"gas"; }
158 xercesc::DOMElement* materialElement =
NewElement(
"material");
159 materialElement->setAttributeNode(
NewAttribute(
"name",name));
160 materialElement->setAttributeNode(
NewAttribute(
"state",state_str));
181 if ( (NumberOfElements>1)
187 for (
size_t i=0;i<NumberOfElements;i++)
192 xercesc::DOMElement* fractionElement =
NewElement(
"fraction");
194 MassFractionVector[i]));
195 fractionElement->setAttributeNode(
NewAttribute(
"ref",fractionref));
196 materialElement->appendChild(fractionElement);
215 xercesc::DOMElement* matrixElement =
NewElement(
"matrix");
216 matrixElement->setAttributeNode(
NewAttribute(
"name", matrixref));
217 matrixElement->setAttributeNode(
NewAttribute(
"coldim",
"2"));
218 std::ostringstream pvalues;
221 if (i!=0) { pvalues <<
" "; }
222 pvalues << pvec->
Energy(i) <<
" " << (*pvec)[i];
224 matrixElement->setAttributeNode(
NewAttribute(
"values", pvalues.str()));
232 xercesc::DOMElement* propElement;
239 std::map<
G4int, G4PhysicsOrderedFreeVector*,
240 std::less<G4int> >::const_iterator mpos;
242 std::less<G4int> >::const_iterator cpos;
245 for (mpos=pmap->begin(); mpos!=pmap->end(); mpos++)
257 matElement->appendChild(propElement);
261 G4String warn_message =
"Null pointer for material property -"
264 G4Exception(
"G4GDMLWriteMaterials::PropertyWrite()",
"NullPointer",
270 for (cpos=cmap->begin(); cpos!=cmap->end(); cpos++)
277 xercesc::DOMElement* constElement =
NewElement(
"constant");
280 constElement->setAttributeNode(
NewAttribute(
"value", cpos->second));
282 matElement->appendChild(propElement);
288 std::cout <<
"G4GDML: Writing materials..." << std::endl;