private static double GetLnLnDivision(EnergyValue a, EnergyValue b, double energyEv)
 {
     Func<double, double> ln = Math.Log;
     var lnValue = ln(a.Value) +
                   (ln(energyEv) - ln(a.Energy_eV))
                   *(ln(b.Value) - ln(a.Value))
                   /(ln(b.Energy_eV) - ln(a.Energy_eV));
     return Math.Exp(lnValue);
 }
 private static bool IsIn(EnergyValue a, EnergyValue b, double energyEv)
 {
     var r = new Region(a.Energy_eV, b.Energy_eV);
     return r.IsIn(energyEv);
 }
Esempio n. 3
0
        private static IEnumerable<EnergyValue> LoadPhotoElectricAbsorptionCoefficients([NotNull] string path)
        {
            if (!File.Exists(path))
                throw new ArgumentException("file not found!");

            var csvLines = File.ReadAllLines(path)
                .NotNull().NotStartsWith("#");
            var list = new List<EnergyValue>();

            foreach (var s in csvLines.Select(line => line.Split(Delimeter))) {
                try {
                    var ev = new EnergyValue {
                        AtomicNumber = int.Parse(s[0]),
                        Energy_eV = double.Parse(s[1]),
                        Value = double.Parse(s[2])
                    };

                    const double epsilon = 0.0001;
                    Func<EnergyValue, bool> matches =
                        item => item.AtomicNumber == ev.AtomicNumber && item.Energy_eV.Equals(ev.Energy_eV);
                    if (list.Any(matches)) {
                        var existing = list.First(matches);
                        if (existing.Value > ev.Value) ev.Value -= epsilon;
                        else ev.Value += epsilon;
                    }

                    list.Add(ev);
                }
                catch (FormatException fe) {
                    throw new FormatException(
                        "Wrong format in " + (list.Count() + 1) + " th photo electric absorption coefficient.", fe);
                }
            }

            return list;
        }