Ejemplo n.º 1
0
    static private void vp(List <Body> bv, int nstep)
    {
        MathVector dacc = MathVector.makeMathVector();
        MathVector dvel = MathVector.makeMathVector();
        double     dthf = 0.5 * BH.DTIME;

        for (int i = 0; i < bv.Count; ++i)
        {
            Body       b    = bv[i];
            MathVector acc1 = b.newAcc.cloneMathVector();
            if (nstep > 0)
            {
                dacc.subtraction2(acc1, b.acc);
                dvel.multScalar2(dacc, dthf);
                dvel.addition(b.vel);
                b.vel = dvel.cloneMathVector();
            }

            b.acc = acc1.cloneMathVector();

            dvel.multScalar2(b.acc, dthf);

            MathVector vel1 = b.vel.cloneMathVector();
            vel1.addition(dvel);
            MathVector dpos = vel1.cloneMathVector();
            dpos.multScalar1(BH.DTIME);
            dpos.addition(b.pos);
            b.pos = dpos.cloneMathVector();
            vel1.addition(dvel);
            b.vel = vel1.cloneMathVector();
        }
    }
Ejemplo n.º 2
0
    /**
     * Compute a single body-body or body-cell interaction
     */
    public HG gravSub(HG hg)
    {
        MathVector dr = MathVector.makeMathVector();

        dr.subtraction2(pos, hg.pos0);

        double drsq  = dr.dotProduct() + (EPS * EPS);
        double drabs = Math.Sqrt(drsq);

        double phii = mass / drabs;

        hg.phi0 -= phii;
        double mor3 = phii / drsq;

        dr.multScalar1(mor3);
        hg.acc0.addition(dr);
        return(hg);
    }