예제 #1
0
        protected abstract Direction GetFinalDirection(); // position may or may not be needed

        private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double cubeLengthX, double cubeWidthY, double cubeHeightZ, Random rng)
        {
            Position finalPosition = null;

            switch (sourceProfile.SourceProfileType)
            {
            case SourceProfileType.Flat:
                // var flatProfile = sourceProfile as FlatSourceProfile;
                SourceToolbox.GetPositionInACuboidRandomFlat(
                    SourceDefaults.DefaultPosition.Clone(),
                    cubeLengthX,
                    cubeWidthY,
                    cubeHeightZ,
                    rng);
                break;

            case SourceProfileType.Gaussian:
                var gaussianProfile = sourceProfile as GaussianSourceProfile;
                finalPosition = SourceToolbox.GetPositionInACuboidRandomGaussian(
                    SourceDefaults.DefaultPosition.Clone(),
                    0.5 * cubeLengthX,
                    0.5 * cubeWidthY,
                    0.5 * cubeHeightZ,
                    gaussianProfile.BeamDiaFWHM,
                    rng);
                break;
            }
            return(finalPosition);
        }
        public void validate_static_method_getpositioninacuboidrandomflat()
        {
            Random rng = new MathNet.Numerics.Random.MersenneTwister(0);
            var    pos = SourceToolbox.GetPositionInACuboidRandomFlat(_position, _lengthX, _widthY, _heightZ, rng);

            Assert.Less(Math.Abs(pos.X - _tp[53]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Y - _tp[54]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Z - _tp[55]), ACCEPTABLE_PRECISION);
        }
예제 #3
0
        protected abstract Direction GetFinalDirection(); // position may or may not be needed

        private static Position GetFinalPosition(double beamDiameterFWHM, double cubeLengthX, double cubeWidthY, double cubeHeightZ, Random rng)
        {
            return(beamDiameterFWHM < 0.0
                ? SourceToolbox.GetPositionInACuboidRandomFlat(
                       SourceDefaults.DefaultPosition.Clone(),
                       cubeLengthX,
                       cubeWidthY,
                       cubeHeightZ,
                       rng)
                : SourceToolbox.GetPositionInACuboidRandomGaussian(
                       SourceDefaults.DefaultPosition.Clone(),
                       0.5 * cubeLengthX,
                       0.5 * cubeWidthY,
                       0.5 * cubeHeightZ,
                       beamDiameterFWHM,
                       rng));
        }