I'm simulating the orbit of an object multiple times and it works perfectly most of the time, but sometimes this error appears and I don't know how to fix it.
NAN found in derivative for PointMassForce force element 3, Value is -nan(ind)
NAN found in derivative for PointMassForce force element 4, Value is -nan(ind)
NAN found in derivative for PointMassForce force element 5, Value is -nan(ind)
ODEModel Exception Thrown: The ForceModel DeepSpaceProp_ForceModel generated a derivative that is not a number
The initial ephemeris of the object is taken from a SPICE SPK kernel and the only thing I'm changing between each simulation run is the starting epoch. The mission sequence starts off with an SPK propagator which just loads the initial ephemeris at the epoch I set. The stopping condition for the SPK propagator is ElapsedSecs = 0
so it immediately moves on to the deep space propagator which is giving me the error. (I'm not just using the SPK propagator because the path of the object is going to be changed).
Here are the settings for the deep space propagator:
Create Propagator DeepSpaceProp;
GMAT DeepSpaceProp.FM = DeepSpaceProp_ForceModel;
GMAT DeepSpaceProp.Type = PrinceDormand78;
GMAT DeepSpaceProp.InitialStepSize = 600;
GMAT DeepSpaceProp.Accuracy = 1e-10;
GMAT DeepSpaceProp.MinStep = 0;
GMAT DeepSpaceProp.MaxStep = 864000;
GMAT DeepSpaceProp.MaxStepAttempts = 50;
GMAT DeepSpaceProp.StopIfAccuracyIsViolated = true;
EDIT
The error goes away when the SPK propagator is run for 1 second instead of immediately stopping. I'm not sure why this works since for most epochs this isn't a problem.
Just to clarify, changing the starting epoch only affects the object's starting ephemeris.