Esempio n. 1
0
 public BoltzmannGenerator(ParticleContainer cont, double temperature, ParticleInfo info,
                           int projectedCalls = 10000, int nDivisions = 10000) :
     base(cont, projectedCalls, nDivisions)
 {
     this.temperature = temperature;
     mass             = info.Mass;
     Setup();
 }
Esempio n. 2
0
        protected override double GetSpeed(ParticleInfo info)
        {
            double ran        = RandomGen.NextDouble();
            double speed      = minVal;
            double cumulative = 0;

            while (cumulative < ran)
            {
                speed      += increment;
                cumulative += increment * normalization * Function(speed);
            }

            return(speed);
        }
Esempio n. 3
0
        protected override double GetSpeed(ParticleInfo info)
        {
            bool   returnedValue = false;
            double randomSpeed   = 0;

            while (returnedValue == false)
            {
                double boltzmannConstant = 1.38 * Math.Pow(10, -23);
                // Pick speed between min and max
                randomSpeed = RandomGen.NextDouble(min, max);
                // Find probability of getting that speed
                double probability = 4 * Math.PI * Math.Pow((info.Mass / (2 * Math.PI * boltzmannConstant * temperature)), 1.5);
                probability *= randomSpeed * randomSpeed * Math.Pow(Math.E, -(info.Mass * randomSpeed * randomSpeed) / (2 * boltzmannConstant * temperature));
                // generate random double between 0,1. If <= probability, use that velocity. If not try again.
                double randNum = RandomGen.NextDouble();
                if (randNum <= probability)
                {
                    returnedValue = true;
                }
            }
            return(randomSpeed);
        }
        protected override double GetSpeed(ParticleInfo info)
        {
            double counter     = 0;
            double mass        = info.Mass;
            double temperature = 293.15;
            double result      = 0;
            double velo;

            while (counter < 1)
            {
                velo = RandomGen.NextDouble(minSpeed, maxSpeed);
                double equation = BoltzmannFunction(velo, mass, temperature);

                double rand = RandomGen.NextDouble();

                if (rand < equation)
                {
                    result = velo;
                    counter++;
                }
            }

            return(result);
        }
Esempio n. 5
0
 /// <summary>
 /// Choose a speed at random for a new particle
 /// </summary>
 abstract protected double GetSpeed(ParticleInfo info);
Esempio n. 6
0
 public Particle(Vector position, Vector velocity, ParticleInfo info)
 {
     Position = position;
     Velocity = velocity;
     Info     = info;
 }
Esempio n. 7
0
 override protected double GetSpeed(ParticleInfo info)
 {
     return(RandomGen.NextDouble(min, max));
 }
Esempio n. 8
0
        /// <summary>
        /// Create a new particle by name
        /// </summary>
        /// <param name="name">The name of the particle type to be created, as a string</param>
        public Particle MakeParticle(Vector position, Vector velocity, string name)
        {
            ParticleInfo info = Map[name];

            return(new Particle(position, velocity, info));
        }
Esempio n. 9
0
 /// <summary>
 /// Adds a particle type to the dictionary
 /// </summary>
 public void AddParticle(ParticleInfo info)
 {
     Map.Add(info.Name, info);
 }