예제 #1
0
        public void validate_class_can_be_serialized_as_part_of_SimulationInput()
        {
            var detectorInput = new ROfRhoDetectorInput()
            {
                Rho = new DoubleRange(10, 20, 51)
            };

            try
            {
                new SimulationInput(
                    10,
                    "",
                    new SimulationOptions(),
                    new DirectionalPointSourceInput(),
                    new MultiLayerTissueInput(),
                    new List <IDetectorInput>
                {
                    (ROfRhoDetectorInput)detectorInput
                }
                    ).WriteToJson("test.txt");
            }
            catch
            {
                Assert.Fail("SimulationInput class could not be serialized.");
            }

            //var simInputCloned = FileIO.ReadFromXML<SimulationInput>("test");

            //Assert.AreEqual(simInputCloned.DetectorInput.Rho.Start, 10);
        }
예제 #2
0
        public void validate_deserialized_class_is_correct()
        {
            var i = new ROfRhoDetectorInput()
            {
                Rho = new DoubleRange(10, 20, 51)
            };
            var iCloned = Clone(i);

            Assert.AreEqual(iCloned.Rho.Start, 10);
        }
예제 #3
0
        public void validate_ROfRhoDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile()
        {
            string         detectorName  = "testrofrho";
            IDetectorInput detectorInput = new ROfRhoDetectorInput()
            {
                Rho = new DoubleRange(0, 10, 4), TallySecondMoment = false, Name = detectorName
            };
            var detector = (ROfRhoDetector)detectorInput.CreateDetector();

            detector.Mean = new double[] { 100, 200, 300 };
            DetectorIO.WriteDetectorToFile(detector, "");
            var dcloned = (ROfRhoDetector)DetectorIO.ReadDetectorFromFile(detectorName, "");

            Assert.AreEqual(dcloned.Name, detectorName);
            Assert.AreEqual(dcloned.Mean[0], 100);
            Assert.AreEqual(dcloned.Mean[1], 200);
            Assert.AreEqual(dcloned.Mean[2], 300);
        }
예제 #4
0
        public void demonstrate_basic_mc_creation()
        {
            var detectorInput = new ROfRhoDetectorInput
            {
                TallyType         = "ROfRho",
                Name              = "My First Detector",
                TallySecondMoment = false,
                Rho = new DoubleRange(0, 1, 5),
            };

            var simInput = new SimulationInput {
                DetectorInputs = new[] { detectorInput }
            };

            var sim = simInput.CreateSimulation();

            var results = sim.Run();

            IDetector detector;

            var rOfRhoDetector = results.ResultsDictionary.TryGetValue(detectorInput.Name, out detector);

            Assert.NotNull(rOfRhoDetector);
        }