Пример #1
0
        public double CalculateFz(ovf2 mRef, ovf2 m)
        {
            int    Ny  = mRef.header.ynodes;
            double fz  = 0;
            double vol = mRef.header.xstepsize * mRef.header.ystepsize * mRef.header.zstepsize;
            double mom = vol * MaterialMs;

            for (int i = 0; i < Ny; i++)
            {
                Vector[] row0 = mRef.GetRow(i, 0);
                Vector[] rowf = m.GetRow(i, 0);
                Vector[] dm   = vecSub(rowf, row0);
                for (int j = 0; j < dm.Count(); j++)
                {
                    Vector mf = new Vector(dm[j].x * mom, dm[j].y * mom, dm[j].z * mom);
                    //Vector mf = new Vector(0, 0, dm[j].z * mom);
                    Vector r = m.GetPos(j, i, 0);
                    //double fzi = dipole.Fz(mf, r);
                    double fzi = dipole.Fz_ip(mf, r);
                    //if (fzi > 0)
                    //   Console.WriteLine(fzi.ToString());
                    fz += fzi;
                }
            }

            return(fz);
        }
Пример #2
0
        public double CalculateFzConditional(ovf2 mRef, ovf2 m, CalcCondition ccond, MagnetizationByPosition MsAtPos, List <int> plotChoice, string cond)
        {
            //int Ny = mRef.header.ynodes;
            int    Ny = m.header.ynodes;
            double fz = 0;
            //double vol = mRef.header.xstepsize * mRef.header.ystepsize * mRef.header.zstepsize;
            double vol = m.header.xstepsize * m.header.ystepsize * m.header.zstepsize;

            for (int i = 0; i < Ny; i++)
            {
                Vector[] dm = m.GetRow(i, 0);
                if (mRef != null)
                {
                    Vector[] row0 = mRef.GetRow(i, 0);
                    dm = vecSub(dm, row0);
                }

                for (int j = 0; j < dm.Count(); j++)
                {
                    //Vector mf = new Vector(dm[j].x * mom, dm[j].y * mom, dm[j].z * mom);
                    Vector r = m.GetPos(j, i, 0);
                    //Vector mf = new Vector(0, 0, dm[j].z * MsAtPos(r) * vol);
                    Vector mf  = new Vector(dm[j].x * MsAtPos(r) * vol, dm[j].y * MsAtPos(r) * vol, dm[j].z * MsAtPos(r) * vol);
                    double fzi = 0;
                    if (plotChoice[0] == 0)
                    {
                        if (plotChoice[1] == 1)
                        {
                            fzi = dipole.Fz(mf, r);
                        }
                        else if (plotChoice[1] == 2)
                        {
                            fzi = dipole.Fz_ip(mf, r);
                        }
                        else if (plotChoice[1] == 3)
                        {
                            fzi = dipole.Fz_ipy(mf, r);
                        }
                    }
                    if (plotChoice[0] == 1)
                    {
                        if (plotChoice[1] == 1)
                        {
                            fzi = dm[j].z;
                        }
                        else if (plotChoice[1] == 2)
                        {
                            fzi = dm[j].x;
                        }
                        else if (plotChoice[1] == 3)
                        {
                            fzi = dm[j].y;
                        }
                    }
                    //double fzi = dipole.Fz(mf, r);
                    //double fzi = dipole.Fz_ip(mf, r);
                    if (ccond(r, cond))
                    {
                        fz += fzi;
                    }
                }
            }

            return(fz);
        }