public void CompiledTest()
        {
            var db = new Database {DirectoryPath = @"C:\Users\X-BrIdge Tech\Desktop\data"};
            db.Load();

            const int z = 22;
            var compiled =
                new PreprocessedCoefficients(
                    Elements.Get(z),
                    db.TotalMassAtten[z].GetValue,
                    new Region(0, 11000),
                    11000);

            // normal
            // AtomicNumber=22, Energy=1k,
            // lambda = 12.4A, ln_lambda = 2.5177
            // coherent_index = 8.677, coherent = 5868.2
            // incoherent = 6.6265e-29
            var expected = 5868.2;
            var actual = compiled.GetValue(1000);
            var delta = 5.0;
            Assert.AreEqual(expected, actual, delta);

            // normal
            // AtomicNumber=22, Energy=10k,
            // lambda = 1.24A, ln_lambda = 0.215...
            // coherent_index = 4.7071, coherent = 110.73
            // incoherent = 6.6047E-29
            expected = 110.7;
            actual = compiled.GetValue(10000);
            delta = 5;
            Assert.AreEqual(expected, actual, delta);
        }
Exemple #2
0
        public Window1ViewModel() {
            var path = Assembly.GetExecutingAssembly().Location;
            var dirPath = Path.GetDirectoryName(path);
            db = new Database {DirectoryPath = dirPath ?? ""};
            db.Load();

            Components = new ObservableCollection<Compo>();

            // au target modified kramers'
            var spe = ArrayFactory.ByFuncDouble(d => ModifiedKramersLaw(79, 1.206, 0.00041, d), 50000);
            var r = new Region(0, 50000);
            fluorescent = new Fluorescent {
                Database = db,
                Conditions = new MeasurementConditions {
                    IncidenceAngle = 60d.ToRadian(),
                    TakeoffAngle = 120d.ToRadian(),
                    Density_g_per_cm3 = 15.0,
                    Thickness_cm = 1.0,
                    TubeSpectrum = new Spectrum(spe, r)
                },
            };

            PropertyChanged += (s, e) => CalculateCommand.RaiseCanExecuteChanged();
            Components.CollectionChanged += (s, e) => CalculateCommand.RaiseCanExecuteChanged();
        }
        public void GetTotalMassAttenTest()
        {
            var db = new Database {DirectoryPath = @"C:\Users\X-BrIdge Tech\Desktop\data"};
            db.Load();

            Func<int, double, double> getValue =
                (z, energyEv) => db.TotalMassAtten[z].GetValue(energyEv);

            // normal
            // AtomicNumber=22, Energy=1k,
            // lambda = 12.4A, ln_lambda = 2.5177
            // coherent_index = 8.677, coherent = 5868.2
            // incoherent = 6.6265e-29
            var expected = 5868.2;
            var actual = getValue(22, 1000);
            var delta = 5.0;
            Assert.AreEqual(expected, actual, delta);

            // normal
            // AtomicNumber=22, Energy=10k,
            // lambda = 1.24A, ln_lambda = 0.215...
            // coherent_index = 4.7071, coherent = 110.73
            // incoherent = 6.6047E-29
            expected = 110.7;
            actual = getValue(22, 10000);
            delta = 5;
            Assert.AreEqual(expected, actual, delta);

            // errorbbf
            // AtomicNumber=0 (out of range), Energy=1k,
            Assert.Throws<KeyNotFoundException>(() => getValue(0, 1000));

            // error
            // AtomicNumber=22, Energy=10 (out of range)
            // expected to return 0.
            expected = 0;
            actual = getValue(22, 10);
            delta = 0.01;
            Assert.AreEqual(expected, actual, delta);

            // error
            // AtomicNumber=22, Energy=1000000 (out of range)
            // expected to return 0.
            expected = 0;
            actual = getValue(22, 1000000);
            delta = 0.01;
            Assert.AreEqual(expected, actual, delta);
        }
Exemple #4
0
 public DatabaseTest()
 {
     const string directory = @"C:\Users\X-BrIdge Tech\Desktop\data";
     db = new Database {DirectoryPath = directory};
     db.Load();
 }
Exemple #5
0
 public Fluorescent()
 {
     Database = new Database();
 }
        public void PhotoElectricAbsTest()
        {
            var db = new Database {DirectoryPath = @"C:\Users\X-BrIdge Tech\Desktop\data"};
            db.Load();

            Func<int, double, double> getValue =
                (z, energyEv) => db.PhotoElectricAbs[z].GetValue(energyEv);

            // REQUIREMENT
            // Basically, returns ln-ln division of the nearest upper
            // & lower point value.
            // Use a point value if Energy is near enough to point.X.
            // If there is two Y value for the same X value (AE:absorption edge),
            // use upper value (Energy <= AE.X)
            //     lower value (AE.X < Energy).

            // retusn 0 for invalId arguments.
            // error (Energy < limit)
            var actual = getValue(12, -1);
            Assert.AreEqual(0, actual);

            // error (Energy > limit)
            actual = getValue(12, 1E100);
            Assert.AreEqual(0, actual);

            // error (invalId atomic number)
            Assert.Throws<KeyNotFoundException>(() => getValue(-1, 1000));

            var expected = 1.277E-10;
            actual = getValue(12, 5.271E10);
            var delta = 1E-11;
            Assert.AreEqual(expected, actual, delta);

            expected = 1.342E-02;
            actual = getValue(28, 2.689E5);
            delta = 1E-3;
            Assert.AreEqual(expected, actual, delta);

            // normal (on the point)
            // Z=12, Energy=4E+3
            // expected=2.96E+02
            expected = 2.96E+02;
            actual = getValue(12, 4.0E+3);
            delta = 0.1;
            Assert.AreEqual(expected, actual, delta);

            // normal (on an absorption edge)
            // Z=12, Energy=1.31E+03
            // expected=5.44E+03(gets greater value)
            expected = 5.44E+03;
            actual = getValue(12, 1.31E+3);
            delta = 0.1;
            Assert.AreEqual(expected, actual, delta);

            // normal (whithin two points)
            // Z=12, Energy=3333
            // expected=490.72
            expected = 490.72;
            actual = getValue(12, 3333);
            delta = 0.5;
            Assert.AreEqual(expected, actual, delta);

            // normal (whithin absorption edge and another point)
            // Z=12, Energy=1410
            // expected=4587.21
            expected = 4587.21;
            actual = getValue(12, 1410);
            delta = 30;
            Assert.AreEqual(expected, actual, delta);

            // normal (whithin absorption edge and another point)
            // Z=12, Energy=1200
            // expected=564.27
            expected = 564.27;
            actual = getValue(12, 1200);
            delta = 0.5;
            Assert.AreEqual(expected, actual, delta);
        }