GeomConverter/src/org/lcsim/material
diff -u -r1.7 -r1.8
--- Material.java 1 Jul 2005 21:59:54 -0000 1.7
+++ Material.java 1 Jul 2005 22:36:00 -0000 1.8
@@ -11,6 +11,10 @@
*
* Material implementation, mostly based on Geant4's G4Material.
*
+ * NIL / RL calcs based on W.L.'s Matprop.
+ *
+ * http://www.slac.stanford.edu/comp/physics/matprop.html
+ *
*/
public class Material
{
@@ -18,7 +22,7 @@
public static final double DEFAULT_TEMPERATURE = 273.15;
/* Default pressure in atmospheres = 1.0 */
- public static final double DEFAULT_PRESSURE = 1.0;
+ public static final double DEFAULT_PRESSURE = 1.0;
/* 1 mole */
public static final double AVOGADRO = 6.022136736e23;
@@ -53,7 +57,7 @@
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;
@@ -230,7 +234,7 @@
{
_elements.add(element);
_massFractions.add(elCnt, fraction);
- ++_nElements;
+ ++_nElements;
}
++_nComponents;
}
@@ -274,7 +278,7 @@
if ( elCnt < _nElements )
{
double currFrac = _massFractions.get(elCnt);
- currFrac += fraction * material.getMassFractions().get(i) ;
+ currFrac += fraction * material.getMassFractions().get(i) ;
_massFractions.set(elCnt, currFrac);
}
/* Add a new element. */
@@ -323,12 +327,12 @@
if ( abs(1 - weightSum) > 0.001 )
{
//System.err.println("bad weight sum: " + weightSum);
-
+
//System.out.println("listing weights...");
//for ( int i = 0; i < _massFractions.size(); i++)
//{
- //System.out.println(_elements.get(i).getName() + " = " + _massFractions.get(i));
- //}
+ //System.out.println(_elements.get(i).getName() + " = " + _massFractions.get(i));
+ //}
throw new RuntimeException("Mass fractions do not sum to 1 within 0.001 tolerance for this material: " + getName() );
}
@@ -357,20 +361,53 @@
public int getNElements()
{
return _nElements;
- }
+ }
public void computeDerivedQuantities()
{
- computeNAtomsPerVolume();
+ //computeNAtomsPerVolume();
computeRadiationLength();
computeNuclearInteractionLength();
}
+ /* compute NIL based on mass fractions */
+ private double computeNuclearInteractionLength()
+ {
+ double NILinv = 0.0;
+
+ for (int i = 0; i < _nElements; i++)
+ {
+ MaterialElement me = _elements.get(i);
+ NILinv += _massFractions.get(i) / me.getNuclearInteractionLength();
+ }
+
+ _nuclearInteractionLength = (NILinv <= 0.0 ? MAX_NUCLEAR_INTERACTION_LENGTH : 1.0/NILinv);
+
+ return NILinv;
+ }
+
+ /** compute RL based on mass fractions */
+ private double computeRadiationLength()
+ {
+ double rlinv = 0.0;
+
+ for (int i = 0; i < _nElements; i++)
+ {
+ MaterialElement me = _elements.get(i);
+ rlinv += _massFractions.get(i) / me.getRadiationLength();
+ }
+
+ _radiationLength = (rlinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0/rlinv);
+
+ return rlinv;
+ }
+
+ /*
public void computeNAtomsPerVolume()
{
double Zi, Ai;
- _totalElectronsPerVolume = 0.0;
-
+ _totalElectronsPerVolume = 0.0;
+
for ( int i = 0; i < _nElements; i++)
{
Zi = _elements.get(i).getZ();
@@ -379,9 +416,9 @@
_nAtomsPerVolume.add(i, nElec);
_totalElectronsPerVolume += _nAtomsPerVolume.get(i);
_totalElectronsPerVolume += _nAtomsPerVolume.get(i) * Zi;
- }
- }
-
+ }
+ }
+
void computeRadiationLength()
{
double radinv = 0.0;
@@ -389,10 +426,12 @@
{
radinv += _nAtomsPerVolume.get(i) * ( _elements.get(i).getTsaiFactor() );
}
- _radiationLength = ( radinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0 / radinv);
+ _radiationLength = ( radinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0 / radinv);
}
+ */
/** compute nuclear interaction length in g/cm2 */
+ /*
void computeNuclearInteractionLength()
{
double NILinv = 0.0;
@@ -401,19 +440,10 @@
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);
}
-
- double estimateNuclearInteractionLength()
- {
- return ( 35.0 * pow(_A, (1/3)) );
- }
-
- double estimateRadiationLength()
- {
- return (180.0 * _A / ( _Z * _Z));
- }
+ */
public double getRadiationLength()
{
@@ -433,14 +463,15 @@
public String toString()
{
- return "Material=" + getName() + "; nComponents=" + _nComponents +
+ return "Material=" + getName() + "; nComponents=" + _nComponents +
"; nElements=" + _nElements + "; temp=" + _temp + "\t\n" +
- "pressure=" + _pressure + "; density=" + _density +
+ "pressure=" + _pressure + "; density=" + _density +
"; state=" + _state.toString() + "\t\n" + "elecPerVol=" +
- _totalElectronsPerVolume + "; NIL=" + _nuclearInteractionLength +
+ _totalElectronsPerVolume + "; NIL=" + _nuclearInteractionLength +
"; NILmat=" + getNuclearInteractionLengthForMaterial() +
- "; RL=" + _radiationLength +
- "; NILestimate: " + estimateNuclearInteractionLength() +
- "; RLestimate: " + estimateRadiationLength();
+ "; RL=" + _radiationLength;
+ // +
+ // "; NILestimate: " + estimateNuclearInteractionLength() +
+ // "; RLestimate: " + estimateRadiationLength();
}
}
\ No newline at end of file
GeomConverter/src/org/lcsim/material
diff -u -r1.4 -r1.5
--- MaterialElement.java 1 Jul 2005 21:59:54 -0000 1.4
+++ MaterialElement.java 1 Jul 2005 22:36:00 -0000 1.5
@@ -13,6 +13,8 @@
private double _ionizationPotential; // Ionization potential (eV)
private double _coulombCorrection;
private double _tsai;
+ private double _nuclearInteractionLength;
+ private double _radiationLength;
/*
private static String[] ElementNotes = {
@@ -50,7 +52,10 @@
_meltingPoint = mp;
_boilingPoint = bp;
_ionizationPotential = ip;
- MaterialManager.addElement(this);
+
+ computeDerivedQuantities();
+
+ MaterialManager.addElement(this);
}
MaterialElement(String name,
@@ -100,16 +105,7 @@
public double ionizationPotential()
{
return _ionizationPotential;
- }
-
- /*
- public String toString()
- {
- StringBuffer sb = new StringBuffer("ElementData: \n");
- sb.append(_fullName+" : "+_name+" Z= "+_Z+" A= "+_A+" density= "+_density+" MP= "+_meltingPoint+" BP= "+_boilingPoint+" IP= "+ _ionizationPotential+"\n");
- return sb.toString();
- }
- */
+ }
public String getName()
{
@@ -121,21 +117,50 @@
return _tsai;
}
+ public double getNuclearInteractionLength()
+ {
+ return _nuclearInteractionLength;
+ }
+
+ public double getRadiationLength()
+ {
+ return _radiationLength;
+ }
+
public void computeCoulombFactor()
{
/* calculate radiation length */
- _coulombCorrection = RadiationLengthCalculator.computeCoulombCorrection(_Z);
+ _coulombCorrection = MaterialCalculator.computeCoulombCorrection(_Z);
}
public void computeTsaiFactor()
{
/* compute Tsai factor, using Z plus coulomb (so it doesn't need to be recomputed) */
- _tsai = RadiationLengthCalculator.computeTsaiFactor(_Z, _coulombCorrection);
+ _tsai = MaterialCalculator.computeTsaiFactor(_Z, _coulombCorrection);
}
public void computeDerivedQuantities()
{
computeCoulombFactor();
- computeTsaiFactor();
+ computeTsaiFactor();
+ computeNuclearInteractionLength();
+ computeRadiationLength();
+ }
+
+ void computeNuclearInteractionLength()
+ {
+ _nuclearInteractionLength = MaterialCalculator.computeNuclearInteractionLengthEstimate( getZ() );
+ }
+
+ void computeRadiationLength()
+ {
+ _radiationLength = MaterialCalculator.computeRadiationLengthEstimate( getA(), getZ() );
+ }
+
+ public String toString()
+ {
+ return "Element=" + name() + "; Z=" + _Z + "; A=" + _A + "; N=" + _N + "; density=" + _density + "\n"
+ + "MP=" + _meltingPoint + "; BP=" + _boilingPoint + "; IonPoten=" + _ionizationPotential + "\n"
+ + "coulomb=" + _coulombCorrection + "; tsai=" + _tsai;
}
}
\ No newline at end of file