/** * A class of utilities that are useful for multiple programs and so * get put in their own class. */ import java.util.Vector; public final class StressCalculator extends Object { /** * Actually calculates more than just the SLD's of a set of a compound * it also calculates some cross sections. * The nine output parameters included in the output array are * output[0] = Real neutron SLD * output[1] = Imaginary neutron SLD * output[2] = Real Cu Kalpha SLD * output[3] = Imaginary Cu Kalpha SLD * output[4] = Real Mo Kalpha SLD * output[5] = Imaginary Mo Kalpha SLD * output[6] = Incoherent neutron macroscopic cross section * output[7] = Neutron macroscopic absorption cross section * output[8] = Neutron 1/e length */ public static StressOutput calculateStress(double volume, double pathlength, double precision, int material, String unitType) { StressOutput output = new StressOutput(); String crystalPlane = ""; double k = 0.0; double mu = 0.0; switch (material) { case 0: crystalPlane = "211"; mu=.12; k=2919.89; break; case 1: crystalPlane = "311"; mu=.1202; k=2164.83; break; case 2: crystalPlane = "311"; mu=.0115; k=10828.96; break; } output.plane = new String(crystalPlane); if (unitType.equalsIgnoreCase("ksi")) { precision = precision*6.89476; //convert to MPa } double time = k/(volume*precision*precision)*Math.exp(mu*pathlength); output.time = time; return output; } }