Beispiel #1
0
        public void validate_serialization_and_deserialization_of_gaussiansourceprofile_runs_successfully()
        {
            var source = new CustomCircularSourceInput
            {
                BeamDiameterFWHM = 1.0,
            };

            var sourceSerialized = VtsMonteCarloJsonSerializer.WriteToJson(source);

            var sourceDeserialized = VtsMonteCarloJsonSerializer.ReadFromJson <CustomCircularSourceInput>(sourceSerialized);

            Assert.IsTrue(sourceDeserialized.BeamDiameterFWHM == 1.0);
        }
Beispiel #2
0
        public void validate_serialization_and_deserialization_of_gaussiansourceprofile_runs_successfully()
        {
            var source = new CustomCircularSourceInput
            {
                SourceProfile = new GaussianSourceProfile(),
            };

            var sourceSerialized = VtsJsonSerializer.WriteToJson(source);

            var sourceDeserialized = VtsJsonSerializer.ReadFromJson <CustomCircularSourceInput>(sourceSerialized);

            Assert.IsTrue(sourceDeserialized.SourceProfile.SourceProfileType == SourceProfileType.Gaussian);
        }
        public void execute_Monte_Carlo()
        {
            // delete previously generated files
            clear_folders_and_files();

            var cylinderRadius  = 5.0;
            var tissueThickness = 2.0;

            // instantiate common classes
            var simulationOptions = new SimulationOptions(
                0, // reproducible
                RandomNumberGeneratorType.MersenneTwister,
                AbsorptionWeightingType.Discrete,
                PhaseFunctionType.HenyeyGreenstein,
                new List <DatabaseType>()
            {
            },         // databases to be written
                false, // track statistics
                0.0,   // RR threshold -> 0 = no RR performed
                0);
            var source = new CustomCircularSourceInput(
                cylinderRadius - 0.01,          // outer radius
                0.0,                            // inner radius
                new FlatSourceProfile(),
                new DoubleRange(0.0, 0.0),      // polar angle emission range
                new DoubleRange(0.0, 0.0),      // azimuthal angle emission range
                new Direction(0, 0, 1),         // normal to tissue
                new Position(0, 0, 0),          // center of beam on surface
                new PolarAzimuthalAngles(0, 0), // no beam rotation
                0);                             // 0=start in air, 1=start in tissue
            // debug with point source
            //var source = new DirectionalPointSourceInput(
            //    new Position(0.0, 0.0, 0.0),
            //    new Direction(0.0, 0.0, 1.0),
            //    //new Direction(1/Math.Sqrt(2), 0.0, 1/Math.Sqrt(2)),// debug with 45 degree direction and g=1.0
            //    1); // start inside tissue
            var detectors =
                new List <IDetectorInput>
            {
                new RSpecularDetectorInput(),
                new RDiffuseDetectorInput(), new ROfRhoDetectorInput()
                {
                    Rho = new DoubleRange(0.0, cylinderRadius, 11)
                },
                new TDiffuseDetectorInput(),
                new TOfRhoDetectorInput()
                {
                    Rho = new DoubleRange(0.0, cylinderRadius, 11)
                },
                new AOfRhoAndZDetectorInput()
                {
                    Rho = new DoubleRange(0.0, cylinderRadius, 11),
                    Z   = new DoubleRange(0, tissueThickness, 11)
                },
                new ATotalDetectorInput(),
                new ATotalBoundingVolumeDetectorInput()
            };

            _inputBoundedTissue = new SimulationInput(
                100,
                "",
                simulationOptions,
                source,
                new BoundingCylinderTissueInput(
                    new CaplessCylinderTissueRegion(
                        new Position(0, 0, tissueThickness / 2),
                        cylinderRadius,
                        tissueThickness,
                        new OpticalProperties(0.0, 1e-10, 1.0, 1.4)
                        ),
                    new ITissueRegion[]
            {
                new LayerTissueRegion(
                    new DoubleRange(double.NegativeInfinity, 0.0),
                    new OpticalProperties(0.0, 1e-10, 1.0, 1.0)),
                new LayerTissueRegion(                           // note two layer and one layer give same results Yay!
                    new DoubleRange(0.0, 1.0),
                    new OpticalProperties(0.01, 1.0, 0.8, 1.4)), // debug g=1.0
                new LayerTissueRegion(
                    new DoubleRange(1.0, tissueThickness),
                    new OpticalProperties(0.01, 1.0, 0.8, 1.4)),         // debug g=1.0
                new LayerTissueRegion(
                    new DoubleRange(tissueThickness, double.PositiveInfinity),
                    new OpticalProperties(0.0, 1e-10, 1.0, 1.0))
            }
                    ),
                detectors);
            _outputBoundedTissue = new MonteCarloSimulation(_inputBoundedTissue).Run();
        }