Custom Force Extensions

Top  Previous  Next

A Custom Force Extension makes it possible to model your own forces that are not included in FreeFlyer's built-in force modeling capabilities. The Extension can be used to model any force that you want, including higher fidelity SRP models, polyhedral gravity models, and custom drag models. These forces can then be plugged into the FreeFlyer ForceModel object and evaluated at each stage of integration, thereby providing a high level of fidelity for applying the custom forces to a propagation process.

 

 

Creating a Custom Force Extension


Creating a Custom Force Extension requires only a few extra steps beyond those covered in the Anatomy of a FreeFlyer Extension guide:

 

Override the BaseTypeName Property

Override the BaseTypeName property and return AvailableBaseTypes.CustomForce:

public override string BaseTypeName

{

  get

  {

    return AvailableBaseTypes.CustomForce;

  }

}

 

Implement the ICustomForceExtension Interface

Inherit from the ICustomForceExtension interface:

 

public class MyCustomForce : ExtensionBase,

                            IFFObjectExtension,

                            ICustomForceExtension,

                            IMyCustomForce

{

 

Implement CalculateForce

Implement the ICustomForceExtension interface by implementing the CalculateForce method:

 

public bool CalculateForce(ISpacecraftIntegrationData integrationData,

                          out double [] calculatedForces)

{

  double [] position = new double[3];

 

  double earthMu = Host.SolarSystem.Earth.Mu;

 

  calculatedForces = new double[3];

 

  integrationData.GetPosition(out position);

 

  double r2 = position[0] * position[0] +

              position[1] * position[1] +

              position[2] * position[2];

 

  double force = (integrationData.Mass * -earthMu / r2) / Math.Sqrt(r2);

 

  calculatedForces[0] = force * position[0];

  calculatedForces[1] = force * position[1];

  calculatedForces[2] = force * position[2];

 

  return true;

}

 

 

Using the Custom Force Extension


Once your Custom Force Extension has been built and registered for use with FreeFlyer, you can include the force in the force model for a Spacecraft with the following script syntax:

 

MyCustomForce force;

 

Spacecraft mySpacecraft;

(mySpacecraft.Propagator AsType Integrator).ForceModel.AddForce(force);