Program: 133568
Project: 133568
Buggy source:
/** 
 * This operation updates the properties for this material based on the code from John Ankner's compound calculator written in Visual Basic. The code was ported for the Reflectivity Model. Calculates the number density, scattering length density, true (coherent) scattering length absorption coefficient, and the incoherent scattering length absorption coefficient all from the density of the material (in g/cm^3) and its components. If called on a elemental material, does nothing.
 */
public void updateProperties(){
  if (!isElemental()) {
    final double nA=6.02E23;
    double numberDensity=0;
    double muMAbs=0;
    double muMInc=0;
    double b=0;
    double density=getProperty(DENSITY);
    int molMass=0;
    List<MaterialStack> list=getComponents();
    for (    MaterialStack stack : list) {
      molMass+=stack.getAmount() * (stack.getMaterial().getProperty(ATOMIC_MASS));
    }
    if (list.size() > 0 && molMass >= 1) {
      numberDensity=(1E-24) * (nA) * (density / molMass);
      for (int j=0; j < list.size(); j++) {
        MaterialStack stack=list.get(j);
        Material mat=stack.getMaterial();
        int N=stack.getAmount();
        double cohb=mat.getProperty(COHERENT_SCAT_LENGTH);
        b+=N * cohb;
        double massPercent=mat.getProperty(ATOMIC_MASS) / molMass;
        muMAbs+=N * massPercent * (mat.getProperty(MASS_ABS_COHERENT));
        muMInc+=N * massPercent * (mat.getProperty(MASS_ABS_INCOHERENT));
      }
    }
    setProperty(ATOMIC_MASS,molMass);
    setProperty(NUMBER_DENSITY,numberDensity);
    setProperty(SCAT_LENGTH_DENSITY,numberDensity * b);
    muMAbs*=1E-24 * getProperty(DENSITY);
    setProperty(MASS_ABS_COHERENT,muMAbs);
    muMInc*=1E-24 * getProperty(DENSITY);
    setProperty(MASS_ABS_INCOHERENT,muMInc);
  }
}

Fixed version (ground truth):
/** 
 * This operation updates the properties for this material based on the code from John Ankner's compound calculator written in Visual Basic. The code was ported for the Reflectivity Model. Calculates the number density, scattering length density, true (coherent) scattering length absorption coefficient, and the incoherent scattering length absorption coefficient all from the density of the material (in g/cm^3) and its components. If called on a elemental material, does nothing.
 */
public void updateProperties(){
  if (!isElemental()) {
    final double nA=6.02E23;
    double numberDensity=0;
    double muMAbs=0;
    double muMInc=0;
    double b=0;
    double density=getProperty(DENSITY);
    double molMass=0;
    List<MaterialStack> list=getComponents();
    for (    MaterialStack stack : list) {
      molMass+=(stack.getAmount() * (stack.getMaterial().getProperty(ATOMIC_MASS)));
      System.out.println("String_Node_Str" + stack.getMaterial().getName() + "String_Node_Str"+ molMass);
    }
    if (list.size() > 0 && molMass >= 1) {
      numberDensity=(1E-24) * (nA) * (density / molMass);
      for (int j=0; j < list.size(); j++) {
        MaterialStack stack=list.get(j);
        Material mat=stack.getMaterial();
        int N=stack.getAmount();
        double cohb=1E-5 * mat.getProperty(COHERENT_SCAT_LENGTH);
        b+=N * cohb;
        double massPercent=mat.getProperty(ATOMIC_MASS) / molMass;
        muMAbs+=N * massPercent * (mat.getProperty(MASS_ABS_COHERENT));
        muMInc+=N * massPercent * (mat.getProperty(MASS_ABS_INCOHERENT));
      }
    }
    setProperty(ATOMIC_MASS,molMass);
    setProperty(NUMBER_DENSITY,numberDensity);
    setProperty(SCAT_LENGTH_DENSITY,numberDensity * b);
    muMAbs*=1E-24 * getProperty(DENSITY);
    setProperty(MASS_ABS_COHERENT,muMAbs);
    muMInc*=1E-24 * getProperty(DENSITY);
    setProperty(MASS_ABS_INCOHERENT,muMInc);
  }
}