Beispiel #1
0
        public double erot(int isp, double temp_thermal, RanPark erandom)
        {
            double eng, a, erm, b;

            if (sparta.collide == null || sparta.collide.rotstyle == (int)Enum2.NONE)
            {
                return(0.0);
            }
            if (species[isp].rotdof < 2)
            {
                return(0.0);
            }

            if (species[isp].rotdof == 2)
            {
                eng = -Math.Log(erandom.uniform()) * sparta.update.boltz * temp_thermal;
            }
            else
            {
                a = 0.5 * sparta.particle.species[isp].rotdof - 1.0;
                while (true)
                {
                    // energy cut-off at 10 kT
                    erm = 10.0 * erandom.uniform();
                    b   = Math.Pow(erm / a, a) * Math.Exp(a - erm);
                    if (b > erandom.uniform())
                    {
                        break;
                    }
                }
                eng = erm * sparta.update.boltz * temp_thermal;
            }

            return(eng);
        }
Beispiel #2
0
        public Collide(SPARTA sparta, int narg, string[] arg)
        {
            this.sparta = sparta;
            int n = arg[0].Length + 1;

            style = string.Copy(arg[0]);

            n     = arg[1].Length + 1;
            mixID = string.Copy(arg[1]);

            random = new RanPark(sparta.update.ranmaster.uniform());
            double seed = sparta.update.ranmaster.uniform();

            random.reset(seed, sparta.comm.me, 100);

            ngroups = 0;

            npmax = 0;
            plist = null;

            nglocal = nglocalmax = 0;

            ngroup   = null;
            maxgroup = null;
            glist    = null;
            gpair    = null;

            maxdelete = 0;
            dellist   = null;

            vre_first      = 1;
            vre_start      = 1;
            vre_every      = 0;
            remainflag     = 1;
            vremax         = null;
            vremax_initial = null;
            remain         = null;
            rotstyle       = (int)Enum1.SMOOTH;
            vibstyle       = (int)Enum1.NONE;
            nearcp         = 0;
            nearlimit      = 10;

            recomb_ijflag = null;

            ambiflag    = 0;
            maxelectron = 0;
            elist       = null;
        }
Beispiel #3
0
        public double evib(int isp, double temp_thermal, RanPark erandom)
        {
            double eng, a, erm, b;

            int vibstyle = (int)Enum2.NONE;

            if (sparta.collide != null)
            {
                vibstyle = sparta.collide.vibstyle;
            }
            if (vibstyle == (int)Enum2.NONE || species[isp].vibdof < 2)
            {
                return(0.0);
            }

            eng = 0.0;
            if (vibstyle == (int)Enum2.DISCRETE && species[isp].vibdof == 2)
            {
                int ivib = Convert.ToInt32(-Math.Log(erandom.uniform()) * temp_thermal /
                                           sparta.particle.species[isp].vibtemp);
                eng = ivib * sparta.update.boltz * sparta.particle.species[isp].vibtemp;
            }
            else if (vibstyle == (int)Enum2.SMOOTH || species[isp].vibdof >= 2)
            {
                if (species[isp].vibdof == 2)
                {
                    eng = -Math.Log(erandom.uniform()) * sparta.update.boltz * temp_thermal;
                }
                else if (species[isp].vibdof > 2)
                {
                    a = 0.5 * sparta.particle.species[isp].vibdof - 1;
                    while (true)
                    {
                        // energy cut-off at 10 kT
                        erm = 10.0 * erandom.uniform();
                        b   = Math.Pow(erm / a, a) * Math.Exp(a - erm);
                        if (b > erandom.uniform())
                        {
                            break;
                        }
                    }
                    eng = erm * sparta.update.boltz * temp_thermal;
                }
            }

            return(eng);
        }
Beispiel #4
0
        public int copy, copymode;        // 1 if copy of class (prevents deallocation of
                                          //  base class when child copy is destroyed)

        // methods

        public void init()
        {
            for (int i = 0; i < nmixture; i++)
            {
                mixture[i].init();
            }

            // RNG for particle weighting

            if (wrandom == null)
            {
                wrandom = new RanPark(sparta.update.ranmaster.uniform());
                double seed = sparta.update.ranmaster.uniform();
                wrandom.reset(seed, me, 100);
            }

            // if first run after reading a restart file,
            // delete any custom particle attributes that have not been re-defined
            // use nactive since remove_custom() may alter ncustom

            if (custom_restart_flag != null)
            {
                int nactive = ncustom;
                for (int i = 0; i < nactive; i++)
                {
                    if (custom_restart_flag[i] == 0)
                    {
                        remove_custom(i);
                    }
                }
                //delete[] custom_restart_flag;
                custom_restart_flag = null;
            }

            // reallocate cellcount and first lists as needed
            // NOTE: when grid becomes dynamic, will need to do this in sort()

            //if (maxgrid < sparta.grid.nlocal) {
            //  maxgrid = sparta.grid.nlocal;
            //    memory.destroy(cellcount);
            //memory.destroy(first);
            //memory.create(first,maxgrid,"particle:first");
            //memory.create(cellcount,maxgrid,"particle:cellcount");
            // }
        }