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

        private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double lineLength, Random rng)
        {
            Position finalPosition = SourceDefaults.DefaultPosition.Clone();

            switch (sourceProfile.SourceProfileType)
            {
            case SourceProfileType.Flat:
                // var flatProfile = sourceProfile as FlatSourceProfile;
                finalPosition = SourceToolbox.GetPositionInALineRandomFlat(
                    finalPosition,
                    lineLength,
                    rng);
                break;

            case SourceProfileType.Gaussian:
                var gaussianProfile = sourceProfile as GaussianSourceProfile;
                finalPosition = SourceToolbox.GetPositionInALineRandomGaussian(
                    finalPosition,
                    0.5 * lineLength,
                    gaussianProfile.BeamDiaFWHM,
                    rng);
                break;
            }
            return(finalPosition);
        }
        public void validate_static_method_getpositioninalinerandomgaussian()
        {
            Random rng = new MathNet.Numerics.Random.MersenneTwister(0);
            var    pos = SourceToolbox.GetPositionInALineRandomGaussian(_position, 0.5 * _lengthX, _bdFWHM, rng);

            Assert.Less(Math.Abs(pos.X - _tp[62]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Y - _tp[63]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Z - _tp[64]), ACCEPTABLE_PRECISION);
        }
Exemple #3
0
        protected abstract Direction GetFinalDirection(Position position); // position may or may not be needed

        private static Position GetFinalPosition(double beamDiameterFWHM, double lineLength, Random rng)
        {
            Position finalPosition = SourceDefaults.DefaultPosition.Clone();

            return(beamDiameterFWHM < 0.0
                ? SourceToolbox.GetPositionInALineRandomFlat(
                       finalPosition,
                       lineLength,
                       rng)
                : SourceToolbox.GetPositionInALineRandomGaussian(
                       finalPosition,
                       0.5 * lineLength,
                       beamDiameterFWHM,
                       rng));
        }