Exemplo n.º 1
0
        public void FillDs()
        {
            dE = 0;
            dV = 0;
            //dRo = 0;
            var h = owner2.h;

            foreach (var neib in neib_lst)
            {
                var Vij     = V - neib.V;
                var ximinxj = X - neib.X;
                var dw      = KernelF.dWdr(ximinxj, h);



                var signXij = Math.Sign(ximinxj);

                double II = 0d;
                if (Vij * signXij < 0)
                {
                    var mu_ij = (h * Vij * ximinxj) / (ximinxj * ximinxj + h * h * owner2.e2);
                    II = 2 * ((-mu_ij * owner2.alpha * 0.5 * (Math.Sqrt(owner2.gamma * P / Ro) + Math.Sqrt(owner2.gamma * neib.P / neib.Ro)) + owner2.betta * mu_ij * mu_ij) / (Ro + neib.Ro));
                }



                //dRo += neib.M * Vij * signXij * dw;

                dE += 0.5 * neib.M * Vij * signXij * dw
                      * (neib.P / (neib.Ro * neib.Ro) + P / (Ro * Ro) + II);
                dV -= neib.M * signXij * dw
                      * (neib.P / (neib.Ro * neib.Ro) + P / (Ro * Ro) + II);
            }
        }
Exemplo n.º 2
0
        public OneDemExample(double dx_gr = 0d) : base()
        {
            dx_granica = dx_gr;
            int n_pm = perc * scaler;


            var dx1 = boardL / n_pm;

            for (int i = 0; i < n_pm; i++)
            {
                Particles.Add(new Particle()
                {
                    Name = i.ToString(),
                    X    = -boardL + i * dx1,
                    Ro   = 1,
                    P    = 1,
                    E    = 2.5,
                    V    = 0
                });
            }
            var dx2 = boardL / (Np - n_pm);

            for (int i = n_pm; i < Np; i++)
            {
                Particles.Add(new Particle()
                {
                    Name = i.ToString(),
                    X    = (i - n_pm) * dx2 + dx_granica,
                    Ro   = 0.25,
                    P    = 0.1795,
                    E    = 1.795,
                    V    = 0
                });
            }

            for (int i = -1; i > -Np_wall - 1; i--)
            {
                Wall.Add(new Particle()
                {
                    Name   = (i).ToString(),
                    X      = -boardL + (i) * dx1,
                    Ro     = 1,
                    P      = 1,
                    E      = 2.5,
                    V      = 0,
                    IsWall = true
                });
            }
            for (int i = Np + 1; i <= Np + Np_wall; i++)
            {
                Wall.Add(new Particle()
                {
                    Name   = (i).ToString(),
                    X      = (i - n_pm - 1) * dx2 + dx_granica,
                    Ro     = 0.25,
                    P      = 0.1795,
                    E      = 1.795,
                    V      = 0,
                    IsWall = true
                });
            }

            var all = Particles.Concat(Wall).OrderBy(p => p.X);

            AllParticles.AddRange(all);

            AllParticles.ForEach(p => p.M = 0.6 / n_pm);

            for (int i = 0; i < AllParticles.Count; i++)
            {
                AllParticles[i].MInd = i;
            }

            var xs    = AllParticles.Select(p => p.X).ToArray();
            var walls = AllParticles.Select(p => p.IsWall).ToArray();

            SynchMeBefore += SynchMeAfterAct;

            foreach (var p in Particles)
            {
                AddChild(p);
            }
            Particles.ForEach(p => p.SetDts());



            var mhi  = Particles.Where(p => p.P > 0.3).Sum(p => p.M);
            var mlo  = Particles.Where(p => p.P < 0.3).Sum(p => p.M);
            var mall = Particles.Sum(p => p.M);

            foreach (var part in AllParticles)
            {
                part.Ro = AllParticles.Sum(p => p.M * KernelF.W(part.X - p.X, h));
            }
            foreach (var p in Particles)
            {
                p.P = GetP(p);
            }

            SynchMeAfter += SynchMeAfterAct;
            //SynchMeForNext += t => {
            //    foreach(var p in Particles) {
            //        p.P = GetP(p);
            //    }
            //};

            particles_par = Particles.AsParallel();
        }
Exemplo n.º 3
0
        public void FillRos()
        {
            var h = owner2.h;

            Ro = neib_lst.Sum(n => n.M * KernelF.W(X - n.X, h)) + M * KernelF.W(0, h);
        }