GeomConverter/src/org/lcsim/material
diff -N MaterialElementData.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MaterialElementData.java 30 Jun 2005 00:37:50 -0000 1.1
@@ -0,0 +1,125 @@
+package org.lcsim.material;
+import java.util.Map;
+import java.util.TreeMap;
+/**
+ * Ported from lelaps.
+ *
+ */
+public class MaterialElementData
+{
+ //
+ // name fullName Z A density melts at boils at ion. pot.
+ //
+ public final static MaterialElement vacuum = new MaterialElement( "vacuum", "vacuum" , 0, 0.0 , 0.0 , 0.0 , 0.0 , 0.0 );
+ public final static MaterialElement Hydrogen = new MaterialElement( "H" , "Hydrogen" , 1, 1.00794 , 0.0708 , 13.81 , 20.28 , 13.598 );
+ public final static MaterialElement Deuterium = new MaterialElement( "D" , "Deuterium" , 1, 2.0140 , 0.16 , 15.0 , 23.4 , -1 );
+ public final static MaterialElement Helium = new MaterialElement( "He", "Helium" , 2, 4.002602 , 0.124901 , 0.94999999, 4.22 , 24.587 );
+ public final static MaterialElement Lithium = new MaterialElement( "Li", "Lithium" , 3, 6.941 , 0.534 , 453.65 , 1615.15 , 5.392 );
+ public final static MaterialElement Beryllium = new MaterialElement( "Be", "Beryllium" , 4, 9.012182 , 1.85 , 1560.15 , 2744.15 , 9.323 );
+ public final static MaterialElement Boron = new MaterialElement( "B" , "Boron" , 5, 10.811 , 2.37 , 2348.15 , 4273.15 , 8.298 );
+ public final static MaterialElement Carbon = new MaterialElement( "C" , "Carbon" , 6, 12.0107 , 2.2670 , 4765.15 , 4115.15 , 11.260 );
+ public final static MaterialElement Nitrogen = new MaterialElement( "N" , "Nitrogen" , 7, 14.00674 , 0.807 , 63.15 , 77.36 , 14.534 );
+ public final static MaterialElement Oxygen = new MaterialElement( "O" , "Oxygen" , 8, 15.9994 , 1.141 , 54.36 , 90.2 , 13.618 );
+ public final static MaterialElement Fluorine = new MaterialElement( "F" , "Fluorine" , 9, 18.9984032, 1.50 , 53.53 , 85.03 , 17.423 );
+ public final static MaterialElement Neon = new MaterialElement( "Ne", "Neon" , 10, 20.1797 , 1.204 , 24.56 , 27.07 , 21.565 );
+ public final static MaterialElement Sodium = new MaterialElement( "Na", "Sodium" , 11, 22.989770 , 0.97 , 370.95 , 1156.15 , 5.139 );
+ public final static MaterialElement Magnesium = new MaterialElement( "Mg", "Magnesium" , 12, 24.3050 , 1.74 , 923.15 , 1363.15 , 7.646 );
+ public final static MaterialElement Aluminum = new MaterialElement( "Al", "Aluminum" , 13, 26.981538 , 2.70 , 933.47 , 2792.15 , 5.986 );
+ public final static MaterialElement Silicon = new MaterialElement( "Si", "Silicon" , 14, 28.0855 , 2.3296 , 1687.15 , 3538.15 , 8.152 );
+ public final static MaterialElement Phosphorus = new MaterialElement( "P" , "Phosphorus" , 15, 30.973761 , 1.82 , 317.3 , 553.65 , 10.487 );
+ public final static MaterialElement Sulfur = new MaterialElement( "S" , "Sulfur" , 16, 32.066 , 2.067 , 388.36 , 717.75 , 10.360 );
+ public final static MaterialElement Chlorine = new MaterialElement( "Cl", "Chlorine" , 17, 35.4527 , 1.56 , 171.65 , 239.11 , 12.968 );
+ public final static MaterialElement Argon = new MaterialElement( "Ar", "Argon" , 18, 39.948 , 1.396 , 83.8 , 87.3 , 15.760 );
+ public final static MaterialElement Potassium = new MaterialElement( "K" , "Potassium" , 19, 39.0983 , 0.89 , 336.53 , 1032.15 , 4.341 );
+ public final static MaterialElement Calcium = new MaterialElement( "Ca", "Calcium" , 20, 40.078 , 1.54 , 1115.15 , 1757.15 , 6.113 );
+ public final static MaterialElement Scandium = new MaterialElement( "Sc", "Scandium" , 21, 44.955910 , 2.99 , 1814.15 , 3109.15 , 6.561 );
+ public final static MaterialElement Titanium = new MaterialElement( "Ti", "Titanium" , 22, 47.867 , 4.5 , 1941.15 , 3560.15 , 6.828 );
+ public final static MaterialElement Vanadium = new MaterialElement( "V" , "Vanadium" , 23, 50.9415 , 6.0 , 2183.15 , 3680.15 , 6.746 );
+ public final static MaterialElement Chromium = new MaterialElement( "Cr", "Chromium" , 24, 51.9961 , 7.15 , 2180.15 , 2944.15 , 6.767 );
+ public final static MaterialElement Manganese = new MaterialElement( "Mn", "Manganese" , 25, 54.938049 , 7.3 , 1519.15 , 2334.15 , 7.434 );
+ public final static MaterialElement Iron = new MaterialElement( "Fe", "Iron" , 26, 55.845 , 7.875 , 1811.15 , 3134.15 , 7.902 );
+ public final static MaterialElement Cobalt = new MaterialElement( "Co", "Cobalt" , 27, 58.933200 , 8.86 , 1768.15 , 3200.15 , 7.881 );
+ public final static MaterialElement Nickel = new MaterialElement( "Ni", "Nickel" , 28, 58.6934 , 8.912 , 1728.15 , 3186.15 , 7.640 );
+ public final static MaterialElement Copper = new MaterialElement( "Cu", "Copper" , 29, 63.546 , 8.933 , 1357.77 , 2835.15 , 7.726 );
+ public final static MaterialElement Zinc = new MaterialElement( "Zn", "Zinc" , 30, 65.39 , 7.134 , 692.68 , 1180.15 , 9.394 );
+ public final static MaterialElement Gallium = new MaterialElement( "Ga", "Gallium" , 31, 69.723 , 5.91 , 302.91 , 2477.15 , 5.999 );
+ public final static MaterialElement Germanium = new MaterialElement( "Ge", "Germanium" , 32, 72.61 , 5.323 , 1211.4 , 3106.15 , 7.900 );
+ public final static MaterialElement Arsenic = new MaterialElement( "As", "Arsenic" , 33, 74.92160 , 5.776 , 1090.15 , 887.15 , 9.815 );
+ public final static MaterialElement Selenium = new MaterialElement( "Se", "Selenium" , 34, 78.96 , 4.809 , 494.15 , 958.15 , 9.752 );
+ public final static MaterialElement Bromine = new MaterialElement( "Br", "Bromine" , 35, 79.904 , 3.11 , 265.95 , 331.95 , 11.814 );
+ public final static MaterialElement Krypton = new MaterialElement( "Kr", "Krypton" , 36, 83.80 , 2.418 , 115.79 , 119.93 , 14.000 );
+ public final static MaterialElement Rubidium = new MaterialElement( "Rb", "Rubidium" , 37, 85.4678 , 1.53 , 312.46 , 961.15 , 4.177 );
+ public final static MaterialElement Strontium = new MaterialElement( "Sr", "Strontium" , 38, 87.62 , 2.64 , 1050.15 , 1655.15 , 5.695 );
+ public final static MaterialElement Yttrium = new MaterialElement( "Y" , "Yttrium" , 39, 88.90585 , 4.47 , 1795.15 , 3618.15 , 6.217 );
+ public final static MaterialElement Zirconium = new MaterialElement( "Zr", "Zirconium" , 40, 91.224 , 6.52 , 2128.15 , 4682.15 , 6.634 );
+ public final static MaterialElement Niobium = new MaterialElement( "Nb", "Niobium" , 41, 92.90638 , 8.57 , 2750.15 , 5017.15 , 6.759 );
+ public final static MaterialElement Molybdenum = new MaterialElement( "Mo", "Molybdenum" , 42, 95.94 , 10.2 , 2896.15 , 4912.15 , 7.092 );
+ public final static MaterialElement Technetium = new MaterialElement( "Tc", "Technetium" , 43, 98 , 11 , 2430.15 , 4538.15 , 7.28 );
+ public final static MaterialElement Ruthenium = new MaterialElement( "Ru", "Ruthenium" , 44, 101.07 , 12.1 , 2607.15 , 4423.15 , 7.361 );
+ public final static MaterialElement densitydium = new MaterialElement( "Rh", "densitydium" , 45, 102.90550 , 12.4 , 2237.15 , 3968.15 , 7.459 );
+ public final static MaterialElement Palladium = new MaterialElement( "Pd", "Palladium" , 46, 106.42 , 12.0 , 1828.05 , 3236.15 , 8.337 );
+ public final static MaterialElement Silver = new MaterialElement( "Ag", "Silver" , 47, 107.8682 , 10.501 , 1234.93 , 2435.15 , 7.576 );
+ public final static MaterialElement Cadmium = new MaterialElement( "Cd", "Cadmium" , 48, 112.411 , 8.69 , 594.22 , 1040.15 , 8.994 );
+ public final static MaterialElement Indium = new MaterialElement( "In", "Indium" , 49, 114.818 , 7.31 , 429.75 , 2345.15 , 5.786 );
+ public final static MaterialElement Tin = new MaterialElement( "Sn", "Tin" , 50, 118.710 , 7.287 , 505.08 , 2875.15 , 7.344 );
+ public final static MaterialElement Antimony = new MaterialElement( "Sb", "Antimony" , 51, 121.760 , 6.685 , 903.78 , 1860.15 , 8.64 );
+ public final static MaterialElement Tellurium = new MaterialElement( "Te", "Tellurium" , 52, 127.60 , 6.232 , 722.66 , 1261.15 , 9.010 );
+ public final static MaterialElement Iodine = new MaterialElement( "I" , "Iodine" , 53, 126.90447 , 4.93 , 386.85 , 457.55 , 10.451 );
+ public final static MaterialElement Xenon = new MaterialElement( "Xe", "Xenon" , 54, 131.29 , 2.953 , 161.4 , 165.11 , 12.130 );
+ public final static MaterialElement Cesium = new MaterialElement( "Cs", "Cesium" , 55, 132.90545 , 1.93 , 301.59 , 944.15 , 3.894 );
+ public final static MaterialElement Barium = new MaterialElement( "Ba", "Barium" , 56, 137.327 , 3.62 , 1000.15 , 2170.15 , 5.212 );
+ public final static MaterialElement Lanthanum = new MaterialElement( "La", "Lanthanum" , 57, 138.9055 , 6.15 , 1191.15 , 3737.15 , 5.577 );
+ public final static MaterialElement Cerium = new MaterialElement( "Ce", "Cerium" , 58, 140.116 , 8.16 , 1071.15 , 3716.15 , 5.539 );
+ public final static MaterialElement Praseodymium = new MaterialElement( "Pr", "Praseodymium" , 59, 140.90765 , 6.77 , 1204.15 , 3793.15 , 5.464 );
+ public final static MaterialElement Neodymium = new MaterialElement( "Nd", "Neodymium" , 60, 144.24 , 7.01 , 1294.15 , 3347.15 , 5.525 );
+ public final static MaterialElement Promethium = new MaterialElement( "Pm", "Promethium" , 61, 145 , 7.26 , 1315.15 , 3273.15 , 5.55 );
+ public final static MaterialElement Samarium = new MaterialElement( "Sm", "Samarium" , 62, 150.36 , 7.52 , 1347.15 , 2067.15 , 5.644 );
+ public final static MaterialElement Europium = new MaterialElement( "Eu", "Europium" , 63, 151.964 , 5.24 , 1095.15 , 1869.15 , 5.670 );
+ public final static MaterialElement Gadolinium = new MaterialElement( "Gd", "Gadolinium" , 64, 157.25 , 7.90 , 1586.15 , 3546.15 , 6.150 );
+ public final static MaterialElement Terbium = new MaterialElement( "Tb", "Terbium" , 65, 158.92534 , 8.23 , 1629.15 , 3503.15 , 5.864 );
+ public final static MaterialElement Dysprosium = new MaterialElement( "Dy", "Dysprosium" , 66, 162.50 , 8.55 , 1685.15 , 2840.15 , 5.939 );
+ public final static MaterialElement Holmium = new MaterialElement( "Ho", "Holmium" , 67, 164.93032 , 8.80 , 1747.15 , 2973.15 , 6.022 );
+ public final static MaterialElement Erbium = new MaterialElement( "Er", "Erbium" , 68, 167.26 , 9.07 , 1802.15 , 3141.15 , 6.108 );
+ public final static MaterialElement Thulium = new MaterialElement( "Tm", "Thulium" , 69, 168.93421 , 9.32 , 1818.15 , 2223.15 , 6.184 );
+ public final static MaterialElement Ytterbium = new MaterialElement( "Yb", "Ytterbium" , 70, 173.04 , 6.90 , 1092.15 , 1469.15 , 6.254 );
+ public final static MaterialElement Lutetium = new MaterialElement( "Lu", "Lutetium" , 71, 174.967 , 9.84 , 1936.15 , 3675.15 , 5.426 );
+ public final static MaterialElement Hafnium = new MaterialElement( "Hf", "Hafnium" , 72, 178.49 , 13.3 , 2506.15 , 4876.15 , 6.825 );
+ public final static MaterialElement Tantalum = new MaterialElement( "Ta", "Tantalum" , 73, 180.9479 , 16.4 , 3290.15 , 5731.15 , 7.89 );
+ public final static MaterialElement Tungsten = new MaterialElement( "W" , "Tungsten" , 74, 183.84 , 19.3 , 3695.15 , 5828.15 , 7.98 );
+ public final static MaterialElement Rhenium = new MaterialElement( "Re", "Rhenium" , 75, 186.207 , 20.8 , 3459.15 , 5869.15 , 7.88 );
+ public final static MaterialElement Osmium = new MaterialElement( "Os", "Osmium" , 76, 190.23 , 22.5 , 3306.15 , 5285.15 , 8.7 );
+ public final static MaterialElement Iridium = new MaterialElement( "Ir", "Iridium" , 77, 192.217 , 22.5 , 2719.15 , 4701.15 , 9.1 );
+ public final static MaterialElement Platinum = new MaterialElement( "Pt", "Platinum" , 78, 195.078 , 21.46 , 2041.55 , 4098.15 , 9.0 );
+ public final static MaterialElement Gold = new MaterialElement( "Au", "Gold" , 79, 196.96655 , 19.282 , 1337.33 , 3129.15 , 9.226 );
+ public final static MaterialElement Mercury = new MaterialElement( "Hg", "Mercury" , 80, 200.59 , 13.5336 , 234.32 , 629.88 , 10.438 );
+ public final static MaterialElement Thallium = new MaterialElement( "Tl", "Thallium" , 81, 204.3833 , 11.8 , 577.15 , 1746.15 , 6.108 );
+ public final static MaterialElement Lead = new MaterialElement( "Pb", "Lead" , 82, 207.2 , 11.342 , 600.61 , 2022.15 , 7.417 );
+ public final static MaterialElement Bismuth = new MaterialElement( "Bi", "Bismuth" , 83, 208.98038 , 9.807 , 544.55 , 1837.15 , 7.289 );
+ public final static MaterialElement Polonium = new MaterialElement( "Po", "Polonium" , 84, 209 , 9.32 , 527.15 , 1235.15 , 8.417 );
+ public final static MaterialElement Astatine = new MaterialElement( "At", "Astatine" , 85, 210 , -1 , 575.15 , -1 , -1 );
+ public final static MaterialElement Radon = new MaterialElement( "Rn", "Radon" , 86, 222 , 4.4 , 202.15 , 211.45 , 10.749 );
+ public final static MaterialElement Francium = new MaterialElement( "Fr", "Francium" , 87, 223 , -1 , 300.15 , -1 , -1 );
+ public final static MaterialElement Radium = new MaterialElement( "Ra", "Radium" , 88, 226 , 5 , 973.15 , -1 , 5.279 );
+ public final static MaterialElement Actinium = new MaterialElement( "Ac", "Actinium" , 89, 227 , 10.07 , 1324.15 , 3471.15 , 5.17 );
+ public final static MaterialElement Thorium = new MaterialElement( "Th", "Thorium" , 90, 232.0381 , 11.72 , 2023.15 , 5061.15 , 6.08 );
+ public final static MaterialElement Protactinium = new MaterialElement( "Pa", "Protactinium" , 91, 231.03588 , 15.37 , 1845.15 , -1 , 5.89 );
+ public final static MaterialElement Uranium = new MaterialElement( "U" , "Uranium" , 92, 238.0289 , 18.95 , 1408.15 , 4404.15 , 6.194 );
+ public final static MaterialElement Neptunium = new MaterialElement( "Np", "Neptunium" , 93, 237 , 20.25 , 917.15 , -1 , 6.266 );
+ public final static MaterialElement Plutonium = new MaterialElement( "Pu", "Plutonium" , 94, 244 , 19.84 , 913.15 , 3501.15 , 6.06 );
+ public final static MaterialElement Americium = new MaterialElement( "Am", "Americium" , 95, 243 , 13.69 , 1449.15 , 2284.15 , 5.993 );
+ public final static MaterialElement Curium = new MaterialElement( "Cm", "Curium" , 96, 247 , 13.51 , 1618.15 , -1 , 6.02 );
+ public final static MaterialElement Berkelium = new MaterialElement( "Bk", "Berkelium" , 97, 247 , 14 , 1323.15 , -1 , 6.23 );
+ public final static MaterialElement Californium = new MaterialElement( "Cf", "Californium" , 98, 251 , -1 , 1173.15 , -1 , 6.30 );
+ public final static MaterialElement Einsteinium = new MaterialElement( "Es", "Einsteinium" , 99, 252 , -1 , 1133.15 , -1 , 6.42 );
+ public final static MaterialElement Fermium = new MaterialElement( "Fm", "Fermium" , 100, 257 , -1 , 1800.15 , -1 , 6.50 );
+ public final static MaterialElement Mendelevium = new MaterialElement( "Md", "Mendelevium" , 101, 258 , -1 , 1100.15 , -1 , 6.58 );
+ public final static MaterialElement Nobelium = new MaterialElement( "No", "Nobelium" , 102, 259 , -1 , 1100.15 , -1 , 6.65 );
+ public final static MaterialElement Lawrencium = new MaterialElement( "Lr", "Lawrencium" , 103, 262 , -1 , 1900.15 , -1 , -1 );
+ public final static MaterialElement Rutherfordium = new MaterialElement( "Rf", "Rutherfordium" , 104, 261 , -1 , -1 , -1 , -1 );
+ public final static MaterialElement Hahnium = new MaterialElement( "Ha", "Hahnium" , 105, 262 , -1 , -1 , -1 , -1 );
+ public final static MaterialElement Seaborgium = new MaterialElement( "Sg", "Seaborgium" , 106, 266 , -1 , -1 , -1 , -1 );
+ public final static MaterialElement Nielsbohrium = new MaterialElement( "Ns", "Nielsbohrium" , 107, 264 , -1 , -1 , -1 , -1 );
+ public final static MaterialElement Hassium = new MaterialElement( "Hs", "Hassium" , 108, 269 , -1 , -1 , -1 , -1 );
+ public final static MaterialElement Meitnerium = new MaterialElement( "Mt", "Meitnerium" , 109, 268 , -1 , -1 , -1 , -1 );
+ // Last element:
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/material
diff -u -r1.1 -r1.2
--- Material.java 9 Jun 2005 03:30:22 -0000 1.1
+++ Material.java 30 Jun 2005 00:37:49 -0000 1.2
@@ -1,821 +1,286 @@
package org.lcsim.material;
-import java.util.Random;
import static java.lang.Math.sqrt;
+import static java.lang.Math.abs;
+import java.util.List;
+import java.util.ArrayList;
/**
+ * @author jeremym
*
+ * Material implementation, mostly based on G4Material.
*
*/
public class Material
{
+ double _temp;
+ double _pressure;
+ double _density;
+ boolean _isElement;
+ public double _Zeff;
+ public double _Aeff;
+ public double _Neff;
+ MaterialState _state;
+ String _name;
+ String _formula;
+
+ private List<MaterialElement> _elements = new ArrayList<MaterialElement>();
+ private List<Double> _massFractions = new ArrayList<Double>();
+ private List<Integer> _atoms = new ArrayList<Integer>();
+
+ int _nComponents;
+ int _nComponentsMax;
+ int _nElements;
- //
- // Constructors. Only use these for creating vacuum.
- // Use derived classes CEElement, CECompound and CEMixture for
- // other materials.
- //
public Material()
{
- _Z=0;
+ _Zeff=0;
_state = MaterialState.UNKNOWN;
_isElement = false;
_name = "Vacuum";
- }
- public Material(String name)
+ }
+
+ /* Construct base material with all info. */
+ public Material(String name,
+ double z,
+ double a,
+ double density,
+ MaterialState state,
+ double temp,
+ double pressure)
{
- _Z=0;
- _state = MaterialState.UNKNOWN;
- _isElement = false;
_name = name;
- }
- public Material(Material mat)
- {
- _name = mat._name;
-
- _Z = mat._Z;
- _A = mat._A;
- _ZoverA = mat._ZoverA;
- _rho = mat._rho;
-
- _a = mat._a;
- _m = mat._m;
- _X0 = mat._X0;
- _X1 = mat._X1;
- _Cbar = mat._Cbar;
- _I = mat._I;
- _molecularWeight = mat._molecularWeight;
- _plen = mat._plen;
- _Cbar = mat._Cbar;
- _Xa = mat._Xa;
- _rho_STP = mat._rho_STP;
- _P = mat._P;
- _T = mat._T;
- _ASP = mat._ASP;
- _BSP = mat._BSP;
- _state = mat._state;
- _isElement = mat._isElement;
-
- _radLength = mat._radLength;
- _intLength = mat._intLength;
- _Ec = mat._Ec;
- _rMoliere = mat._rMoliere;
-
- _radLength_m = mat._radLength_m;
- _intLength_m = mat._intLength_m;
- _Ec_GeV = mat._Ec_GeV;
- _rMoliere_m = mat._rMoliere_m;
-
- _F1 = mat._F1;
- _F2 = mat._F2;
- _F3 = mat._F3;
- _F4 = mat._F4;
- _F5 = mat._F5;
-
- _chi_c_sq_over_pl = mat._chi_c_sq_over_pl;
- _chi_alpha_sq = mat._chi_alpha_sq;
-
- _v_over_pl = mat._v_over_pl;
-
- _cached_momentum = mat._cached_momentum;
- _cached_beta = mat._cached_beta;
- _cached_charge = mat._cached_charge;
-
- }
- //
- // methods
- //
-
- //
- // Scatter vector q by a random amount based on calculated sigma of
- // gaussian distribution in azimuth and using a flat distribution in phi.
- // returns 1 if a scatter did occur.
- //
- // Scatter vector q by a random amount based on sigma, gaussian-distributed
- // in azimuth and flat in phi. The algorithm is the one from Lynch and
- // Dahl, NIMPR B58 (1991), 6-10, with a 2% accuracy.
- //
- // Need to make some variables static, or not give all wafers a new
- // material, for a small speed increase
- //
- public boolean scatter(double[] q,
- double momentum, // Momentum in GeV/c
- double beta, // v/c
- double pathlength, // Pathlength in m
- double charge) // Charge in elementary charge units
- {
- // if ((physics & (CEM_MULTIPLE_SCATTERING | CEM_ENERGY_LOSS)) == 0) return(0);
-
- if ((charge == 0.0) || (pathlength == 0.0) || (momentum == 0.0)
- || (_Z <= 0.0)) return false;
-
-
- if (charge < 0.0) charge = - charge;
- //
- // recalculate stuff if needed
- //
- if ((Math.abs(momentum - _cached_momentum) > CEM_EPSILON) ||
- (Math.abs(beta - _cached_beta) > CEM_EPSILON) ||
- (Math.abs(charge - _cached_charge) > CEM_EPSILON))
- {
- _cached_momentum = momentum;
- _cached_beta = beta;
- _cached_charge = charge;
- //
- // Convert momentum to MeV
- //
-
- momentum *= 1000.0;
-
- double f = charge / (momentum * beta);
- _chi_c_sq_over_pl = _F1 * f * f;
-
- f = _F3 * charge * charge / (beta * beta);
- _chi_alpha_sq = _F2 * (1.0 + f) / (momentum * momentum);
-
- _v_over_pl = _F4 * _chi_c_sq_over_pl / _chi_alpha_sq;
+ _density = density;
+ _state = state;
+ _temp = temp;
+ _pressure = pressure;
+ _formula = " ";
+
+ if ( z <= 0 )
+ {
+ throw new IllegalArgumentException("Z must be >= 0.");
}
- double v = _v_over_pl * pathlength;
- //
- // No scattering unless we have accumulated enough material
- //
- if (v < 1000.0) return false;
-
- double sigma_sq = _F5 * _chi_c_sq_over_pl * pathlength;
-
- if (v > 1.0e6) sigma_sq *= Math.log(v) - 1.0;
- else sigma_sq *= ((1.0 + v) / v) * Math.log(1.0 + v) - 1.0;
-
- double sigma = Math.sqrt(sigma_sq);
- double theta = sigma * _ran.nextGaussian();
-
- double sintheta = Math.sin(theta);
- double costheta = Math.cos(theta);
- //
- // Since theta comes back either positive or negative, we only need
- // to generate phi in PI rather than two PI.
- //
- double phi = Math.PI * _ran.nextDouble();
- double sinphi = Math.sin(phi);
- double cosphi = Math.cos(phi);
-
- double qx = sintheta * cosphi;
- double qy = sintheta * sinphi;
- double qz = costheta;
- //
- // The following algorithm is also used in EGS4 (routine UPHI).
- //
- double z = q[2];
- double cosalpha = z;
- double sinalpha = Math.sqrt(1.0 - cosalpha * cosalpha);
-
- // if (physics & CEM_MULTIPLE_SCATTERING) {
- if (sinalpha < 1.0e-10)
- {
- q[0] = qx;
- q[1] = qy;
- q[2] = qz;
- }
- else
- {
- //
- // transform back to q
- //
- double x = q[0];
- double y = q[1];
-
- double cosbeta = x / sinalpha;
- double sinbeta = y / sinalpha;
- double qxz = qx * z;
-
- q[0] = qxz * cosbeta + qz * x - qy * sinbeta;
- q[1] = qxz * sinbeta + qz * y + qy * cosbeta;
- q[2] = -qx * sinalpha + qz * z;
- }
- // }
-
- return true;
- }
- //
- // Return the energy loss. Uses Sternheimer/Peierls
- //
- public double energyLoss(double beta, // v/c
- double restE, // Rest energy in GeV
- double pathlength, // Pathlength in m
- double charge ) // Charge in elementary charge units
- {
- // if (((physics & CEM_ENERGY_LOSS) == 0) || (Z <= 0.0) || (charge == 0.0) ||
- // (beta <= 0.0) || (restE <= 0.0)) return(0.0);
- if((_Z <= 0.0) || (charge == 0.0) || (beta <= 0.0) || (restE <= 0.0)) return 0.;
- double QsQ = charge * charge;
-
- double betasq = beta * beta;
- double bgsq = betasq / (1.0 - betasq);
- //
- // 2
- // X = log10(beta * gamma) = 0.5 * log10( (beta * gamma) )
- // (saves a sqrt)
- //
- double X = 0.5 * Math.log(bgsq)/2.3026;
- //
- // Eq. 1-2: delta
- //
- double delta;
- if (X < _X0)
+ _Zeff = z;
+
+ if ( a <= 0 )
{
- delta = 0.0;
+ throw new IllegalArgumentException("A must be >= 0.");
}
- else
+
+ _Aeff = a;
+
+ _nComponents = _nComponentsMax = _nElements = 1;
+ _isElement = true;
+
+ MaterialElement element = MaterialManager.getElement(name);
+
+ if ( element == null )
{
- delta = 4.6052 * X - _Cbar;
- if (X < _X1)
- {
- double x1minusx = _X1 - X;
- delta += _a * Math.pow(x1minusx, _m);
- }
+ throw new RuntimeException("Corresponding element not found for material by name: " + name);
}
- //
- // In the following, remember that 2log(p/m0 c) = 4.6052 * X
- //
- double dE = 0.0;
- //
- // Use average energy loss, because we don't do delta rays.
- // The pathlength (in g/cm^2) is computed using the material's
- // actual rho so the Sternheimer "eta" correction is implicit.
- //
- double s = 0.000511 / restE;
- double Wmax = 1.022 * bgsq / (1.0 + s * (2.0 * Math.sqrt(1.0 + bgsq) + s));
- //
- // Eq. 55: Average energy loss in MeV:
- //
- dE = QsQ * _ASP * pathlength / betasq * (_BSP + 0.693 + 4.6052 * X + Math.log(Wmax) -
- 2.0 * betasq - delta);
- //
- // Just in case we need these sometime, here are the other equations:
- //
- // double W0 = 1.0; // MeV
- //
- // Eq. 60: Restricted energy loss in MeV:
- //
- // dE = QsQ * ASP * pathlength / betasq * (BSP + 0.693 + 4.6052 * X + log(W0) -
- // betasq - delta);
- //
- // Eq. 63: Most probable energy loss (Landau) in MeV for thin material is:
- //
- // dE = QsQ * ASP * pathlength / betasq * (BSP + 0.891 + 4.6052 * X + log(ASP * t / betasq) -
- // betasq - delta);
- //
- dE *= 0.001; // in GeV
- if (dE < 0.0) dE = 0.0;
- return dE;
- }
-
- public boolean isMaterial()
- { return(_Z > 0.0); }
- //
- // Set material name
- //
- public void setName(String name )
+
+ _elements.add(element);
+ _massFractions.add(1.0);
+ }
+
+ public Material(String name,
+ int nComponents,
+ double density,
+ MaterialState state,
+ double temp,
+ double pressure
+ )
{
_name = name;
+ _density = density;
+ _state = state;
+ _temp = temp;
+ _pressure = pressure;
+ _formula = " ";
+
+ if ( nComponents <= 0 )
+ {
+ throw new IllegalArgumentException("nComponents must be >= 0.");
+ }
+
+ _nComponentsMax = nComponents;
+ _nComponents = _nElements = 0;
+ _isElement = false;
}
- public void addName(String name)
+
+ int getNumberOfElements()
{
+ return _nElements;
}
- //
- // Get information about this material
- //
- public String name( )
- { return(_name); }
-
- public int getNumberOfParts()
- {
- return 1;
- }
- public Material partialMaterial(int index)
- {
- return this;
- }
- public double getPartialVolume(int index)
- {
- return 0.;
- }
- public double getPartialWeight(int index)
- {
- return 0.;
- }
-
-
+ List<MaterialElement> getElements()
+ {
+ return _elements;
+ }
+ List<Double> getMassFractions()
+ {
+ return _massFractions;
+ }
- double rho( )
- { return _rho; }; // density (g/cc)
- double Z()
- { return _Z; }; // "Z"
- double A()
- { return _A; }; // "A"
- double ZoverA()
- { return _ZoverA; }; // Z/A
- double I()
- { return _I; }; // excitation potential (eV)
- double P()
- { return _P; }; // pressure (atm)
- double T()
- { return _T; }; // temperature (K)
- double MolWeight()
- { return _molecularWeight; }; // mol. weight (g/mol)
- MaterialState state()
- { return _state; }; // gas or solid/liquid
- double RadLength()
- { return _radLength; }; // rad. length (g/cmsq)
- double RadLength_m()
- { return _radLength_m; }; // rad. length (m)
- double IntLength()
- { return _intLength; }; // int. length (g/cmsq)
- double IntLength_m()
- { return _intLength_m; }; // int. length (m)
- double Ec()
- { return _Ec; }; // crit. energy (MeV)
- double Ec_GeV()
- { return _Ec_GeV; }; // crit. energy (GeV)
- double MoliereRadius()
- { return _rMoliere; }; // Moliere radius (g/cmsq)
- double MoliereRadius_m()
- { return _rMoliere_m; }; // Moliere radius (m)
- //
- // Turn multiple scattering/energy loss on/off
- //
- public static void setInteracting(int p)
- { _physics = p; };
- public static int interacting()
- { return _physics; };
-
-
-
- protected String _name; // optional name of the material
- //
- // Commonly needed quantities
- //
- // Z is only used for multiple scattering.
- // Z is the atomic number in units of e.
- // In compounds, it is calculated as an effective Z using
- //
- // Z (Z + 1) n = Sum Zi (Zi + 1) ni
- //
- // where Zi are the effective Z's and ni the partial number densities
- // of the constituent materials: ni = (Ni/NA)/V (mol/cc), and n is the
- // overal number density of compound n = (N/NA)/V = (Sum Ni / NA) / V
- // = Sum ni.
- //
- protected double _Z;
- //
- // A is inly used for multiple scattering.
- // A is the atomic weight of the material in g/mol.
- // For compounds it is calculated as
- //
- // A = rho / n = rho / Sum ni
- //
- protected double _A;
- //
- // ZoverA is only used for energy loss.
- // For elements, it is simply Z / A, but for compounds it is
- // computed as
- //
- // <Z / A> = Sum ni Zi / Sum ni Ai
- //
- // where the ni are as defined above.
- //
- protected double _ZoverA;
- //
- // rho is the material density in g/cc. For compounds it is
- // calculated as:
- //
- // rho = Sum rho_i Vi / V
- //
- protected double _rho;
- //
- // molecularWeight is the molecular weight of the material in g/mol
- // and is equal to A for simple elements (but for e.g. O2 it is
- // 2 * A).
- //
- protected double _molecularWeight;
- //
- // state is the state of the material: unknown, solid or gas.
- //
- //cng should be enum
- //
- protected MaterialState _state;
- //
- // Is this an element?
- //
- protected boolean _isElement;
- //
- // Set constants in this material for multiple scattering
- //
- ////
- //
- // Derived classes must set Z, A, rho, state, is_element, P, T and I.
- // They must then call setMultipleScattering() and setSternheimerPeierls()
- // to set the rest.
- //
- ////
- protected void setMultipleScattering()
- {
- _F1 = 0.157 * _Z * (_Z + 1) / _A;
- _F2 = 2.007e-5 * Math.pow(_Z, 2.0/3.0);
- _F3 = 3.34 * _Z * _Z * CEM_ALPHA_FINE_SQ;
-
- double F = 0.98;
- _F4 = 0.5 / (1.0 - F);
- _F5 = 1.0 / (1.0 + F * F);
-
- _cached_momentum = -1.0;
- _cached_beta = -1.0;
- _cached_charge = -1000.0;
-
- }
- //
- // Set constants in this material for energy loss
- //
- protected void setSternheimerPeierls()
- {
- if (_Z <= 0.0) return;
- //
- // This section calculates the coefficients for the most probable energy
- // loss according to the general algorithm developed by Sternheimer and
- // Peierls[1]. The procedure results a.o. in the computation of five
- // density effect parameters a, m, X0, Cbar and X1, such that the density
- // effect contribution can be written as
- // m
- // delta(X) = 4.6052 X - Cbar + a (X1 - X) (X0 < X < X1)
- // = 4.6052 X - Cbar (X > X1)
- // = 0 (X < X0)
- //
- // Since a parametrization of the mean excitation potential is used,
- // a computation of these parameters for each substance individually is
- // more accurate[2], so where available, tabulated results should be
- // used.
- //
- // References:
- // 1. Sternheimer & Peierls, Phys. Rev. B 3, 3681 (1971).
- // 2. Sternheimer, Seltzer & Berger, Phys Rev B 26, 6067 (1982)
- //
- // All formulas quoted below are from Ref 1.
- //
- // - Note that in ref 1 on page 3687, there is the potential for confusion
- // - about NTP and STP. It reads: "It should be emphasized [...] all pertain
- // - to the gas at normal temperature (0 C) and pressure (1 atm)." This
- // - is commonly referred to as STP ("standard temperature and pressure").
- // - NTP ("normal temperature and pressure") is 25 C, 1 atm.
- //
- // Eta = rho(P, T)/rho(STP), i.e. the factor the STP density needs to
- // be multiplied by to get the already calculated density rho for temperature
- // T and pressure P:
- //
- double eta = 1.0;
- _rho_STP = _rho;
- if (_state.equals(MaterialState.GAS) )
- {
- eta = _P * (273.15 / _T);
- _rho_STP = _rho / eta;
- }
- //
- // Eq. 5: plasma energy (eV).
- // All of this must be calculated (for gasses) at STP first (for solids and
- // liquids it doesn't matter, or at least this assumes so). At other than
- // STP there are density corrections to Cbar, X0 and X1, and they are taken
- // into account using eta at the end.
- //
- _plen = 28.8 * Math.sqrt(_rho_STP * _ZoverA);
- //
- // Eq. 3: C-bar = -C
- //
- _Cbar = 2.0 * Math.log(_I / _plen) + 1.0;
- //
- // Eq. 8: Xa = Cbar / 4.6052
- //
- _Xa = _Cbar / 4.6052;
-
- if (_state.equals( MaterialState.GAS) )
- {
- //
- // Eq. 29-30: X1 for gasses
- //
- if (_Cbar < 12.25) _X1 = 4.0;
- else _X1 = 5.0;
+ /**
+ * Add element by atom count.
+ *
+ * Based on G4Material::AddElement() .
+ */
+ void addElement(MaterialElement element,
+ int nAtoms)
+ {
+ if ( _nElements < _nComponentsMax )
+ {
+ _elements.add(element);
+ _atoms.add( _nElements, nAtoms);
+ _nComponents = ++_nElements;
}
else
{
- //
- // Eq. 27-28: X1 for solids/liquids
- //
- if (_I < 100.0) _X1 = 2.0;
- else _X1 = 3.0;
- }
- //
- // m
- //
- _m = 3.0;
-
- if (_state.equals(MaterialState.GAS) )
- {
- //
- // Eq. 37-42: X0 for gasses
- //
- if (_Cbar < 10.0) _X0 = 1.6;
- else if (_Cbar < 10.5) _X0 = 1.7;
- else if (_Cbar < 11.0) _X0 = 1.8;
- else if (_Cbar < 11.5) _X0 = 1.9;
- else if (_Cbar < 13.804) _X0 = 2.0;
- else _X0 = 0.326 * _Cbar - 2.5;
+ throw new RuntimeException("Attempting to add more than declared number of elements for this material: " + _name);
}
- else
+
+ if ( isFilled() )
{
- //
- // Eq. 33-36: X0 for solids/liquids
- //
- if (_I < 100.0)
+ double Zmol = 0;
+ double Amol = 0;
+
+ int atomCnt = 0;
+ for ( MaterialElement e : _elements )
{
- if (_Cbar < 3.681) _X0 = 0.2;
- else _X0 = 0.326 * _Cbar - 1.0;
- _X1 = 2.0;
+ Amol += _atoms.get(atomCnt) * e.getA();
+ ++atomCnt;
}
- else
+
+ int massCnt = 0;
+ for ( MaterialElement ee : _elements )
{
- if (_Cbar < 5.215) _X0 = 0.2;
- else _X0 = 0.326 * _Cbar - 1.5;
- _X1 = 3.0;
- }
- }
- //
- // Eq. 9: a
- //
- _a = 4.6052 * (_Xa - _X0) / Math.pow(_X1 - _X0, _m);
- //
- // Eq. 25: A (MeV / (g /cm2))
- //
- _ASP = 0.1536 * _ZoverA;
- //
- // Eq. 26: B
- //
- _BSP = Math.log(511.0e9 / (_I * _I));
- //
- // Eta, the factor the density needs to be multiplied by to
- // correct for temperature and pressure to not be at STP:
- //
- if (_state.equals(MaterialState.GAS) )
- {
- double _eta_corr_1 = 0.5 * Math.log(eta)/2.3026; // recall log10(x) = log(x)/log(10);
- double _eta_corr_2 = 4.6052 * _eta_corr_1;
- //
- // Eq. 47,48,50: If gas under pressure (1.e. eta != 1.0) adjust paramters
- //
- _Cbar -= _eta_corr_2;
- _X1 -= _eta_corr_1;
- _X0 -= _eta_corr_1;
+ _massFractions.add(_atoms.get(massCnt) * ee.getA() / Amol);
+ ++massCnt;
+ }
}
}
- public String getName()
+ /** Add element by fraction of mass. */
+ void addElement(MaterialElement element,
+ double fraction)
{
- return _name;
- }
-
- public void print()
- {
- if (_Z <= 0.0)
+ if ( _nComponents < _nComponentsMax )
{
- System.out.printf("CEMaterial: === vacuum ===\n");
- }
- else
- {
- if (_state == MaterialState.GAS)
- {
- System.out.printf("CEMaterial: === %s (gas at P=%g atm and T=%g K) ===\n", getName(), _P, _T);
- }
- else if (_state == MaterialState.CONDENSED)
+ int elCnt = 0;
+ while (( elCnt < _nElements ) && element != _elements.get(elCnt)) elCnt++;
+
+ /* Element already exists. Increase the mass fraction. */
+ if (elCnt < _nElements)
{
- System.out.printf("CEMaterial: === %s (solid or liquid at density %g g/cc) ===\n", getName(), _rho);
+ double currFrac = _massFractions.get(elCnt);
+ currFrac += fraction;
+ _massFractions.add(elCnt, currFrac);
}
+ /* Element does not exist. Add a new mass fraction. */
else
{
- System.out.printf("CEMaterial: === %s (treated as solid at density %g g/cc) ===\n", getName(), _rho);
+ _elements.add(element);
+ _massFractions.add(elCnt, fraction);
+ ++_nElements;
}
- System.out.printf(" ----- Composition: -----\n");
- printComposition(1);
- System.out.printf(" ----- Properties: -----\n");
- System.out.printf(" Z = %.4g A = %.4g Average Z/A = %.4g Molecular weigt = %.4g g/mol\n\n",
- _Z, _A, _ZoverA, _molecularWeight);
- System.out.printf(" Average density = %10.4g g/cc Density at STP = %10.4g g/cc\n",
- _rho, _rho_STP);
- System.out.printf(" Ion. potential = %10.4g eV Plasma energy = %10.4g eV\n\n",
- _I, _plen);
- System.out.printf(" Radiation length = %10.4g g/cm2 or %10.4g cm\n",
- _radLength, _radLength_m * 100.0);
- System.out.printf(" Hadronic interaction length = %10.4g g/cm2 or %10.4g cm\n\n",
- _intLength, _intLength_m * 100.0);
- System.out.printf(" Moliere radius = %10.4g g/cm2 or %10.4g cm\n",
- _rMoliere, _rMoliere_m * 100.0);
- System.out.printf(" Critical energy = %10.4g MeV\n",
- _Ec);
- System.out.printf(" ----- Sternheimer/Peierls coefficients: -----\n");
- System.out.printf(" A = %10.4g B = %10.4g Cbar = %10.4g Xa = %10.4g\n",
- _ASP, _BSP, _Cbar, _Xa);
- System.out.printf(" a = %10.4g m = %10.4g X0 = %10.4g X1 = %10.4g\n",
- _a, _m, _X0, _X1);
- System.out.printf(" ----- Sample dEdx (MeV) in 1 g/cm^2 (%g cm) material -----\n", 1.0 / _rho);
-
- double me = 0.000511;
- double mmu = 0.105;
- double mp = 0.935;
- double p1 = 0.1;
- double p2 = 1.0;
- double p3 = 10.0;
- double p4 = 100.0;
- System.out.printf(" p (MeV) : %10.4g %10.4g %10.4g %10.4g\n", p1 * 1000., p2 * 1000.,
- p3 * 1000., p4 * 1000.);
- System.out.printf(" - - - - - + - - - - - - - - - - - - - - - - - - - - - - -\n");
- System.out.printf(" dE/dx e : %10.4g %10.4g %10.4g %10.4g\n",
- 1000.0 * energyLoss(p1 / sqrt(me * me + p1 * p1), me, 1.0, 1.0),
- 1000.0 * energyLoss(p2 / sqrt(me * me + p2 * p2), me, 1.0, 1.0),
- 1000.0 * energyLoss(p3 / sqrt(me * me + p3 * p3), me, 1.0, 1.0),
- 1000.0 * energyLoss(p4 / sqrt(me * me + p4 * p4), me, 1.0, 1.0) );
- System.out.printf(" dE/dx mu : %10.4g %10.4g %10.4g %10.4g\n",
- 1000.0 * energyLoss(p1 / sqrt(mmu * mmu + p1 * p1), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(p2 / sqrt(mmu * mmu + p2 * p2), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(p3 / sqrt(mmu * mmu + p3 * p3), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(p4 / sqrt(mmu * mmu + p4 * p4), mmu, 1.0, 1.0) );
- System.out.printf(" dE/dx p : %10.4g %10.4g %10.4g %10.4g\n",
- 1000.0 * energyLoss(p1 / sqrt(mp * mp + p1 * p1), mp, 1.0, 1.0),
- 1000.0 * energyLoss(p2 / sqrt(mp * mp + p2 * p2), mp, 1.0, 1.0),
- 1000.0 * energyLoss(p3 / sqrt(mp * mp + p3 * p3), mp, 1.0, 1.0),
- 1000.0 * energyLoss(p4 / sqrt(mp * mp + p4 * p4), mp, 1.0, 1.0) );
- double bg1 = 0.3;
- double bg2 = 1.0;
- double bg3 = 3.0;
- double bg4 = 10.0;
- double bg5 = 100.0;
- double bg6 = 1000.0;
- System.out.printf(" + \n");
- System.out.printf(" betagamma : %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g\n", bg1, bg2, bg3, bg4,
- bg5, bg6);
- System.out.printf(" - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
- System.out.printf(" dE/dx e : %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g\n",
- 1000.0 * energyLoss(sqrt(bg1 * bg1 / (1.0 + bg1 * bg1)), me, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg2 * bg2 / (1.0 + bg2 * bg2)), me, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg3 * bg3 / (1.0 + bg3 * bg3)), me, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg4 * bg4 / (1.0 + bg4 * bg4)), me, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg5 * bg5 / (1.0 + bg5 * bg5)), me, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg6 * bg6 / (1.0 + bg6 * bg6)), me, 1.0, 1.0) );
- System.out.printf(" dE/dx mu : %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g\n",
- 1000.0 * energyLoss(sqrt(bg1 * bg1 / (1.0 + bg1 * bg1)), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg2 * bg2 / (1.0 + bg2 * bg2)), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg3 * bg3 / (1.0 + bg3 * bg3)), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg4 * bg4 / (1.0 + bg4 * bg4)), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg5 * bg5 / (1.0 + bg5 * bg5)), mmu, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg6 * bg6 / (1.0 + bg6 * bg6)), mmu, 1.0, 1.0) );
- System.out.printf(" dE/dx p : %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g\n",
- 1000.0 * energyLoss(sqrt(bg1 * bg1 / (1.0 + bg1 * bg1)), mp, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg2 * bg2 / (1.0 + bg2 * bg2)), mp, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg3 * bg3 / (1.0 + bg3 * bg3)), mp, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg4 * bg4 / (1.0 + bg4 * bg4)), mp, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg5 * bg5 / (1.0 + bg5 * bg5)), mp, 1.0, 1.0),
- 1000.0 * energyLoss(sqrt(bg6 * bg6 / (1.0 + bg6 * bg6)), mp, 1.0, 1.0) );
- }
- }
-
-
- public void printComposition()
- {
- System.out.printf("Material %s consists of:\n", _name);
- printComposition(1);
- return;
+ }
+ else
+ {
+ throw new RuntimeException("Attempting to add more than declared number of components to material: " + getName() );
+ }
+
+ if ( isFilled() )
+ {
+ checkMassSum();
+ }
}
- public void printComposition(int level)
+ /** Add material by fraction of mass. */
+ void addMaterial(Material material,
+ double fraction)
{
- if (getNumberOfParts() == 1)
+ if ( _atoms.size() > 0 )
{
- System.out.println("100% "+ _name);
+ throw new RuntimeException("Material is already defined by atoms: " + getName());
}
- else
+
+ if ( _nComponents < _nComponentsMax )
{
- for (int i = 0; i < getNumberOfParts(); i++)
+ /* Loop over elements in the material. */
+ for ( int i = 0; i < material.getNumberOfElements(); i++)
{
- System.out.printf("%*s %6.3g%% %s (by volume)", level * 3, "", getPartialVolume(i) * 100.0,
- partialMaterial(i).getName());
- if (partialMaterial(i).getNumberOfParts() == 1)
+ MaterialElement element = material.getElements().get(i);
+ int elCnt = 0;
+ /* Find the element. */
+ while (elCnt < _nElements && element != _elements.get(elCnt))
{
- System.out.printf("\n");
+ ++elCnt;
+ }
+ if ( elCnt < _nElements )
+ {
+ double currFrac = _massFractions.get(elCnt);
+ currFrac += fraction;
+ _massFractions.add(elCnt, currFrac);
}
else
{
- System.out.printf(", which consists of:\n");
- partialMaterial(i).printComposition(level + 1);
+ _elements.add(element);
+
+ /**
+ * Add the fraction of this element, normalized to the percentage in the material's
+ * mass fraction list.
+ */
+ _massFractions.add(elCnt, fraction * material.getMassFractions().get(i));
+ ++_nElements;
}
}
+ ++_nComponents;
+ }
+ else
+ {
+ throw new RuntimeException("Attempting to add more than declared number of components for material: " + getName() );
+ }
+
+ if ( isFilled() )
+ {
+ checkMassSum();
}
- return;
}
-
- // attributes
+ private boolean isFilled()
+ {
+ return _nElements == _nComponentsMax;
+ }
- //
- // Radiation length
- //
- protected double _radLength;
- protected double _radLength_m;
- //
- // Interaction length
- //
- protected double _intLength;
- protected double _intLength_m;
- //
- // Sternheimer parameters
- //
- protected double _I; // mean excitation potential
- protected double _plen; // plasma energy in eV
- protected double _Cbar; // Sternheimer/Peierls variables
- protected double _Xa;
- protected double _a;
- protected double _m;
- protected double _X0;
- protected double _X1;
- protected double _ASP;
- protected double _BSP;
- protected double _rho_STP; // density at STP (0 C, 1 atm)
- //
- // Pressure/temperature
- //
- protected double _P; // Pressure in atm
- protected double _T; // Temperature in K
-
- //
- // Grindhammer/Peters shower simulation parameters
- //
- protected double _Ec; // Critical energy in MeV
- protected double _Ec_GeV; // Critical energy in GeV
- protected double _rMoliere; // Moliere radius in g/cmsq
- protected double _rMoliere_m; // Moliere radius in m
-
-
- //
- // Calculated values for multiple scattering.
- //
- private double _F1, _F2, _F3, _F4, _F5; // precalculated values
- //
- // Values that are recalculated only when momentum and/or particle change
- //
- private double _chi_c_sq_over_pl; // square of Moliere characteristic angle
- // divided by pathlength
- private double _chi_alpha_sq; // square of Moliere screening angle
-
- private double _v_over_pl; // 0.5 Omega/(1 - F) / pathlength
- // with Omega * pathlength =
- // chi_c_sq_over_x/chi_alpha_sq
- // the mean number of scatters
- //
- // Used to check if recalculation is needed
- //
- private double _cached_momentum;
- private double _cached_beta;
- private double _cached_charge;
- //
- // Flag to turn energy loss/mult. sc. on or off
- //
- private static int _physics;
-
- private Random _ran = new Random();
-
- // constants
- public static double ALPHA_EM =0.00729735252; // 1/137.036
- public static double CEM_ALPHA_FINE_SQ =0.0000532513538; // (1/137.036)^2
- public static double CEM_EPSILON =1.0e-6; // GeV or electron charge unit
-
- public static double AvogN =6.022136736e23; // 1/moles
- public static double r_e =2.8179409238e-15; // m
- public static double Mec2 =0.5109990615e-3; // GeV
- public static double Mec2_2 =1.02199812e-3; // GeV
-
- // public static int CEM_STATE_UNKNOWN = 2;
- // public static int CEM_STATE_CONDENSED = 0;
- // public static int CEM_STATE_GAS = 2;
[truncated at 1000 lines; 45 more skipped]