public PreprocessedDatabase([NotNull] IDatabase db, [NotNull] IEnumerable<Element> target, Region region_eV, int n) { if (db == null) throw new ArgumentNullException("db"); if (target == null) throw new ArgumentNullException("target"); var elements = target as Element[] ?? target.ToArray(); var zs = elements.Select(e => e.AtomicNumber).ToArray(); var lineGroups = db.LineGroups.Where(lg => zs.Contains(lg.AtomicNumber)); LineGroups = new ReadOnlyCollection<LineGroup>(lineGroups.ToList()); TotalMassAtten = new ElementCoefficientCollection(); foreach (var e in elements) { var tma = db.TotalMassAtten[e.AtomicNumber]; var compiled = new PreprocessedCoefficients(e, tma.GetValue, region_eV, n); TotalMassAtten.Add(compiled); } PhotoElectricAbs = new ElementCoefficientCollection(); foreach (var e in elements) { var pea = db.PhotoElectricAbs[e.AtomicNumber]; var compiled = new PreprocessedCoefficients(e, pea.GetValue, region_eV, n); PhotoElectricAbs.Add(compiled); } }
public Database() { TotalMassAtten = new ElementCoefficientCollection(); TotalMassAtten.AddRange( Elements.All.Select(e => new TotalMassAttenuationCoefficient(e.AtomicNumber))); PhotoElectricAbs = new ElementCoefficientCollection(); PhotoElectricAbs.AddRange( Elements.All.Select(e => new PhotoElectricAbsorptionCoefficient(e.AtomicNumber))); }
public void GetValueTest() { var collection = new ElementCoefficientCollection(); var h = Elements.Get("H"); var na = Elements.Get("Na"); collection.Add(new DummyCoef {Element = h}); collection.Add(new DummyCoef {Element = na}); var c1 = new Composition(); c1[1] = 0.9; c1[11] = 0.1; const double energy = 12345; var expected = (h.MassNumber*0.9 + na.MassNumber*0.1)*energy; var actual = collection.GetValue(c1, energy); Assert.AreEqual(expected, actual); }