Beispiel #1
0
//----------------------------------------------------------------------------
void PhysicsModule::Initialize (double time, double deltaTime, double x,
    double w, double theta, double xDot, double wDot, double thetaDot)
{
    mTime = time;
    mDeltaTime = deltaTime;

    // state variables
    mState[0] = x;
    mState[1] = xDot;
    mState[2] = w;
    mState[3] = wDot;
    mState[4] = theta;
    mState[5] = thetaDot;

    // auxiliary variables
    SinAngle = Mathd::Sin(Angle);
    CosAngle = Mathd::Cos(Angle);
    mAux[0] = Mu*Gravity;  // c/m in the one-particle system example
    mAux[1] = Gravity*SinAngle;

    // RK4 differential equation solver.  Since mSolver is a base class
    // pointer, you can instead create a solver of whatever class you prefer.
    delete0(mSolver);
    mSolver = new0 OdeRungeKutta4d(4, mDeltaTime, OdeFunction, mAux);

    // Set up for angular speed.
    mTheta0 = theta;
    mThetaDer0 = thetaDot;

    double xx = XLocExt*XLocExt;
    double xy = XLocExt*YLocExt;
    double yy = YLocExt*YLocExt;
    double tmp1 = xx + yy;
    double tmp2 = Mathd::Sqrt(tmp1);
    double tmp3 = 4.0*xy/3.0;
    double tmp4 = 0.5*Mathd::Log((tmp2 + XLocExt)/(tmp2 - XLocExt));
    double tmp5 = 0.5*Mathd::Log((tmp2 + YLocExt)/(tmp2 - YLocExt));
    double numer = tmp3*tmp2 + XLocExt*xx*tmp5 + YLocExt*yy*tmp4;
    double denom = tmp3*tmp1;
    double coeff = Mu*Gravity*numer/denom;

    double angSpeed = Mathd::FAbs(thetaDot);
    if (angSpeed > Mathd::ZERO_TOLERANCE)
    {
        mAngVelCoeff = coeff/angSpeed;
    }
    else
    {
        mAngVelCoeff = 0.0;
    }
}
//----------------------------------------------------------------------------
void PhysicsModule::Initialize (double time, double deltaTime, double radius,
    double theta, double radiusDot, double thetaDot)
{
    mTime = time;
    mDeltaTime = deltaTime;

    // state variables
    mState[0] = theta;
    mState[1] = thetaDot;
    mState[2] = radius;
    mState[3] = radiusDot;

    // Compute c0 and c1 in the potential energy function V(theta).
    double gm = Gravity*Mass;
    double gm2 = gm*Mass;
    double radiusSqr = radius*radius;
    double alpha = Mass*radiusSqr*thetaDot;
    double g2m4da2 = gm2*gm2/(alpha*alpha);
    double v0 = -gm/radius;
    double dv0 = gm2*radiusDot/alpha;
    double v0Plus = v0 + g2m4da2;
    double sinTheta0 = Mathd::Sin(theta);
    double cosTheta0 = Mathd::Cos(theta);
    double c0 = v0Plus*sinTheta0 + dv0*cosTheta0;
    double c1 = v0Plus*cosTheta0 - dv0*sinTheta0;

    // Auxiliary variables needed by function DTheta(...).
    mAux[0] = c0;
    mAux[1] = c1;
    mAux[2] = g2m4da2;
    mAux[3] = alpha/(gm*gm2);

    // ellipse parameters
    double gamma0 = radiusSqr*Mathd::FAbs(thetaDot);
    double tmp0 = radiusSqr*radius*thetaDot*thetaDot - gm;
    double tmp1 = radiusSqr*radiusDot*thetaDot;
    double gamma1 = Mathd::Sqrt(tmp0*tmp0 + tmp1*tmp1);
    mEccentricity = gamma1/gm;
    mRho = gamma0*gamma0/gamma1;
    double tmp2 = 1.0 - mEccentricity*mEccentricity;
    assertion(tmp2 > 0.0, "Invalid eccentricity.\n");
    mMajorAxis = mRho*mEccentricity/tmp2;
    mMinorAxis = mMajorAxis*Mathd::Sqrt(tmp2);

    // RK4 differential equation solver.  Since mSolver is a base class
    // pointer, you can instead create a solver of whatever class you prefer.
    delete0(mSolver);
    mSolver = new0 OdeRungeKutta4d(1, mDeltaTime, OdeFunction, mAux);
}
Beispiel #3
0
//----------------------------------------------------------------------------
void PhysicsModule::Initialize (double time, double deltaTime, double theta,
    double thetaDot)
{
    mTime = time;
    mDeltaTime = deltaTime;

    // state variables
    mState[0] = theta;
    mState[1] = thetaDot;

    // auxiliary variables
    mAux[0] = GDivL;
    mAux[1] = CDivM;

    // RK4 differential equation solver.  Since mSolver is a base class
    // pointer, you can instead create a solver of whatever class you prefer.
    delete0(mSolver);
    mSolver = new0 OdeRungeKutta4d(2, mDeltaTime, OdeFunction, mAux);
}
Beispiel #4
0
//----------------------------------------------------------------------------
void PhysicsModule::Initialize (double time, double deltaTime, double x,
    double w, double xDer, double wDer)
{
    mTime = time;
    mDeltaTime = deltaTime;

    // state variables
    mState[0] = x;
    mState[1] = xDer;
    mState[2] = w;
    mState[3] = wDer;

    // auxiliary variables
    mAux[0] = Friction/Mass;
    mAux[1] = Gravity*Mathd::Sin(Angle);

    // RK4 differential equation solver.  Since m_pkSolver is a base class
    // pointer, you can instead create a solver of whatever class you prefer.
    delete0(mSolver);
    mSolver = new0 OdeRungeKutta4d(4, mDeltaTime, OdeFunction, mAux);
}
//----------------------------------------------------------------------------
void PhysicsModule::Initialize (double time, double deltaTime, double theta,
    double phi, double thetaDot, double phiDot)
{
    mTime = time;
    mDeltaTime = deltaTime;

    // state variables
    mState[0] = theta;
    mState[1] = thetaDot;
    mState[2] = phi;
    mState[3] = phiDot;

    // auxiliary variables
    mAux[0] = AngularSpeed*Mathd::Sin(Latitude);  // w*sin(lat)
    mAux[1] = AngularSpeed*Mathd::Cos(Latitude);  // w*cos(lat)
    mAux[2] = GDivL;

    // RK4 differential equation solver.  Since mSolver is a base class
    // pointer, you can instead create a solver of whatever class you prefer.
    delete0(mSolver);
    mSolver = new0 OdeRungeKutta4d(4, mDeltaTime, OdeFunction, mAux);
}
//----------------------------------------------------------------------------
void PhysicsModule::Initialize (double time, double deltaTime, double y1,
    double y2, double y1Dot, double y2Dot)
{
    mTime = time;
    mDeltaTime = deltaTime;

    // state variables
    mState[0] = y1;     // y1(0)
    mState[1] = y1Dot;  // y1'(0)
    mState[2] = y2;     // y2(0)
    mState[3] = y2Dot;  // y2'(0)

    // auxiliary variables
    mAux[0] = A1*A1;   // a1^2
    mAux[1] = A2*A2;   // a2^2
    mAux[2] = Gravity; // g

    // RK4 differential equation solver.  Since mSolver is a base class
    // pointer, you can instead create a solver of whatever class you prefer.
    delete0(mSolver);
    mSolver = new0 OdeRungeKutta4d(4, mDeltaTime, OdeFunction, mAux);
}