public void validate_CircularAngledFromPoint_source()
        {
            Random  rng                    = new MathNet.Numerics.Random.MersenneTwister(0); // not really necessary here, as this is now the default
            ITissue tissue                 = new MultiLayerTissue();
            var     profile                = new FlatSourceProfile();
            var     _radius                = 1.0;
            var     _pointLocation         = new Position(0, 0, -1); // put directly above
            var     _translationFromOrigin = new Position(0, 0, 0);

            var ps = new CircularAngledFromPointSource(_radius, profile, _pointLocation, _translationFromOrigin)
            {
                Rng = rng
            };
            var photon = ps.GetNextPhoton(tissue);

            // make sure initial position is at tissue surface
            Assert.AreEqual(photon.DP.Position.Z, 0.0);
            // make sure initial position is inside radius
            Assert.IsTrue(Math.Sqrt(
                              (photon.DP.Position.X - _translationFromOrigin.X) *
                              (photon.DP.Position.X - _translationFromOrigin.X) +
                              (photon.DP.Position.Y - _translationFromOrigin.Y) *
                              (photon.DP.Position.Y - _translationFromOrigin.Y)) <= _radius);
            // make sure angle is less than 45 degrees
            Assert.IsTrue(photon.DP.Direction.Uz >= 1 / Math.Sqrt(2));
        }
        public void validate_CircularAngledFromCircle_source()
        {
            Random  rng             = new MathNet.Numerics.Random.MersenneTwister(0); // not really necessary here, as this is now the default
            ITissue tissue          = new MultiLayerTissue();
            var     _profile        = new FlatSourceProfile();
            var     _radiusOnTissue = 10.0;
            var     _radiusInAir    = 0.0;
            var     _circleInAirTranslationFromOrigin = new Position(0, 0, -10);

            var ps = new CircularAngledFromCircleSource(
                _radiusOnTissue,
                _profile,
                _radiusInAir,
                _circleInAirTranslationFromOrigin)
            {
                Rng = rng
            };
            var photon = ps.GetNextPhoton(tissue);

            // make sure initial position is at tissue surface
            Assert.AreEqual(photon.DP.Position.Z, 0.0);
            // make sure initial position is inside radius
            Assert.IsTrue(Math.Sqrt(photon.DP.Position.X * photon.DP.Position.X +
                                    photon.DP.Position.Y * photon.DP.Position.Y) <= _radiusOnTissue);
            // make sure angle is less than 45 degrees
            Assert.IsTrue(photon.DP.Direction.Uz >= 1 / Math.Sqrt(2));
        }
示例#3
0
        public void validate_general_constructor_with_flat_profiletype_for_isotropic_line_source_test()
        {
            Random  rng     = new MathNet.Numerics.Random.MersenneTwister(0); // not really necessary here, as this is now the default
            ITissue tissue  = new MultiLayerTissue();
            var     profile = new FlatSourceProfile();


            var ps = new IsotropicLineSource(_lengthX, profile, _direction, _translation, _angPair)
            {
                Rng = rng
            };

            var photon = ps.GetNextPhoton(tissue);

            Assert.Less(Math.Abs(photon.DP.Direction.Ux - _tp[42]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Direction.Uy - _tp[43]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Direction.Uz - _tp[44]), ACCEPTABLE_PRECISION);

            Assert.Less(Math.Abs(photon.DP.Position.X - _tp[45]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Position.Y - _tp[46]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Position.Z - _tp[47]), ACCEPTABLE_PRECISION);
        }
        public void validate_general_constructor_with_flat_profiletype_for_custom_circular_source_test()
        {
            read_data();

            Random  rng     = new MathNet.Numerics.Random.MersenneTwister(0); // not really necessary here, as this is now the default
            ITissue tissue  = new MultiLayerTissue();
            var     profile = new FlatSourceProfile();


            var ps = new CustomCircularSource(_outRad, _inRad, profile, _polRange, _aziRange, _direction, _translation, _angPair)
            {
                Rng = rng
            };

            var photon = ps.GetNextPhoton(tissue);

            Assert.Less(Math.Abs(photon.DP.Direction.Ux - _tp[25]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Direction.Uy - _tp[26]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Direction.Uz - _tp[27]), ACCEPTABLE_PRECISION);

            Assert.Less(Math.Abs(photon.DP.Position.X - _tp[28]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Position.Y - _tp[29]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Position.Z - _tp[30]), ACCEPTABLE_PRECISION);
        }
        public void validate_general_constructor_with_flat_profiletype_for_directional_rectangular_source_test()
        {
            read_data();

            Random  rng     = new MathNet.Numerics.Random.MersenneTwister(0); // not really necessary here, as this is now the default
            ITissue tissue  = new MultiLayerTissue();
            var     profile = new FlatSourceProfile();


            var ps = new DirectionalRectangularSource(_polarAngle, _lengthX, _widthY, profile, _direction, _translation, _angPair)
            {
                Rng = rng
            };

            var photon = ps.GetNextPhoton(tissue);

            Assert.Less(Math.Abs(photon.DP.Direction.Ux - _tp[85]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Direction.Uy - _tp[86]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Direction.Uz - _tp[87]), ACCEPTABLE_PRECISION);

            Assert.Less(Math.Abs(photon.DP.Position.X - _tp[88]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Position.Y - _tp[89]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(photon.DP.Position.Z - _tp[90]), ACCEPTABLE_PRECISION);
        }