GeomConverter/src/org/lcsim/material
diff -u -r1.5 -r1.6
--- Material.java 1 Jul 2005 00:06:26 -0000 1.5
+++ Material.java 1 Jul 2005 21:49:10 -0000 1.6
@@ -2,23 +2,42 @@
import static java.lang.Math.sqrt;
import static java.lang.Math.abs;
+import static java.lang.Math.pow;
import java.util.List;
import java.util.ArrayList;
/**
* @author jeremym
*
- * Material implementation, mostly based on G4Material.
+ * Material implementation, mostly based on Geant4's G4Material.
*
*/
public class Material
{
- /** Default temperature in kelvin = 1.0 */
+ /* Default temperature in kelvin = 1.0 */
public static final double DEFAULT_TEMPERATURE = 273.15;
- /** Default pressure in atmospheres = 1.0 */
+ /* Default pressure in atmospheres = 1.0 */
public static final double DEFAULT_PRESSURE = 1.0;
+ /* 1 mole */
+ public static final double AVOGADRO = 6.022136736e23;
+
+ public static final double MAX_RADIATION_LENGTH = java.lang.Double.MAX_VALUE;
+ public static final double MAX_NUCLEAR_INTERACTION_LENGTH = java.lang.Double.MAX_VALUE;
+
+ /* nuclear interaction length factor in g/cm2 */
+ public static final double LAMBDA0 = 35.0;
+
+ /* atomic mass unit (rest mass) in MeV */
+ public static final double AMU_C2 = 931.49432;
+
+ /* speed of light in mm/s */
+ public static final double C_LIGHT = 299.792458;
+
+ /* atomic mass unit */
+ public static final double AMU = AMU_C2 / (C_LIGHT * C_LIGHT);
+
double _temp;
double _pressure;
double _density;
@@ -33,11 +52,22 @@
private List<MaterialElement> _elements = new ArrayList<MaterialElement>();
private List<Double> _massFractions = new ArrayList<Double>();
private List<Integer> _atoms = new ArrayList<Integer>();
+ private List<Double> _nAtomsPerVolume = new ArrayList<Double>();
+
+ /* electrons per element */
+ double _totalElectronsPerVolume;
+
+ /* radiation length */
+ double _radiationLength;
+
+ /* nuclear interaction length in g/cm2 */
+ double _nuclearInteractionLength;
int _nComponents;
int _nComponentsMax;
int _nElements;
+ /*
public Material()
{
_Z=0;
@@ -45,6 +75,7 @@
_isElement = false;
_name = "Vacuum";
}
+ */
/* Construct base material with all info, creating a MaterialElement, also. */
public Material(String name,
@@ -82,6 +113,8 @@
MaterialManager.addElement(new MaterialElement(_name, _Z, _A) );
_massFractions.add(1.0);
+ computeDerivedQuantities();
+
MaterialManager.addMaterial(this);
}
@@ -169,6 +202,8 @@
_massFractions.add(_atoms.get(massCnt) * ee.getA() / Amol);
++massCnt;
}
+
+ computeDerivedQuantities();
}
}
@@ -207,6 +242,7 @@
if ( isFilled() )
{
checkMassSum();
+ computeDerivedQuantities();
}
}
@@ -321,8 +357,78 @@
public int getNElements()
{
return _nElements;
- }
+ }
+
+ public void computeDerivedQuantities()
+ {
+ computeNAtomsPerVolume();
+ computeRadiationLength();
+ computeNuclearInteractionLength();
+ }
+
+ public void computeNAtomsPerVolume()
+ {
+ double Zi, Ai;
+ _totalElectronsPerVolume = 0.0;
+
+ for ( int i = 0; i < _nElements; i++)
+ {
+ Zi = _elements.get(i).getZ();
+ Ai = _elements.get(i).getA();
+ double nElec = AVOGADRO * _density * _massFractions.get(i) / Ai;
+ _nAtomsPerVolume.add(i, nElec);
+ _totalElectronsPerVolume += _nAtomsPerVolume.get(i);
+ _totalElectronsPerVolume += _nAtomsPerVolume.get(i) * Zi;
+ }
+ }
+
+ void computeRadiationLength()
+ {
+ double radinv = 0.0;
+ for ( int i = 0; i < _nElements; i++)
+ {
+ radinv += _nAtomsPerVolume.get(i) * ( _elements.get(i).getTsaiFactor() );
+ }
+ _radiationLength = ( radinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0 / radinv);
+ }
+
+ /** compute nuclear interaction length in g/cm2 */
+ void computeNuclearInteractionLength()
+ {
+ double NILinv = 0.0;
+ for ( int i = 0; i < _nElements; i++)
+ {
+ NILinv += _nAtomsPerVolume.get(i) * pow(_elements.get(i).getN(), 0.6666667);
+ }
+ NILinv *= AMU/LAMBDA0;
+
+ _nuclearInteractionLength = (NILinv <= 0.0 ? MAX_NUCLEAR_INTERACTION_LENGTH : 1.0/NILinv);
+ }
+
+ public double getRadiationLength()
+ {
+ return _radiationLength;
+ }
+
+ /* get radiation length for this material in mm */
+ public double getNuclearInteractionLengthForMaterial()
+ {
+ return ( _nuclearInteractionLength / _density) * 10;
+ }
- // 1 mole
- //public static double AvogN = 6.022136736e23;
+ public double getNuclearInteractionLength()
+ {
+ return _nuclearInteractionLength;
+ }
+
+ public String toString()
+ {
+ return "name=" + getName() + "; nComponents=" + _nComponents +
+ "; nElements=" + _nElements + "; temp=" + _temp +
+ "; pressure=" + _pressure + "; density=" + _density +
+ "; state=" + _state.toString() + "; elecPerVol=" +
+ _totalElectronsPerVolume + "; NIL=" + _nuclearInteractionLength +
+ "; NILmat=" + getNuclearInteractionLengthForMaterial() +
+ "; RL=" + _radiationLength;
+ }
}
\ No newline at end of file