use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class DSSTPropagatorTest method testPropagationWithCentralBody.
@Test
public void testPropagationWithCentralBody() throws Exception {
// Central Body geopotential 4x4
final UnnormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getUnnormalizedProvider(4, 4);
final Frame earthFrame = CelestialBodyFactory.getEarth().getBodyOrientedFrame();
// GPS Orbit
final AbsoluteDate initDate = new AbsoluteDate(2007, 4, 16, 0, 46, 42.400, TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(26559890., 0.0041632, FastMath.toRadians(55.2), FastMath.toRadians(315.4985), FastMath.toRadians(130.7562), FastMath.toRadians(44.2377), PositionAngle.MEAN, FramesFactory.getEME2000(), initDate, provider.getMu());
// Set propagator with state and force model
setDSSTProp(new SpacecraftState(orbit));
dsstProp.addForceModel(new DSSTZonal(provider, 4, 3, 9));
dsstProp.addForceModel(new DSSTTesseral(earthFrame, Constants.WGS84_EARTH_ANGULAR_VELOCITY, provider, 4, 4, 4, 8, 4, 4, 2));
// 5 days propagation
final SpacecraftState state = dsstProp.propagate(initDate.shiftedBy(5. * 86400.));
// Ref GTDS_DSST:
// a = 26559.92081 km
// h/ey = 0.2731622444E-03
// k/ex = 0.4164167597E-02
// p/hy = -0.3399607878
// q/hx = 0.3971568634
// lM = 140.6375352Ā°
Assert.assertEquals(26559920.81, state.getA(), 1.e-1);
Assert.assertEquals(0.2731622444E-03, state.getEquinoctialEx(), 2.e-8);
Assert.assertEquals(0.4164167597E-02, state.getEquinoctialEy(), 2.e-8);
Assert.assertEquals(-0.3399607878, state.getHx(), 5.e-8);
Assert.assertEquals(0.3971568634, state.getHy(), 2.e-6);
Assert.assertEquals(140.6375352, FastMath.toDegrees(MathUtils.normalizeAngle(state.getLM(), FastMath.PI)), 5.e-3);
}
use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class DSSTPropagatorTest method testIssueMeanInclination.
@Test
public void testIssueMeanInclination() throws OrekitException {
final double earthAe = 6378137.0;
final double earthMu = 3.9860044E14;
final double earthJ2 = 0.0010826;
// Initialize the DSST propagator with only J2 perturbation
Orbit orb = new KeplerianOrbit(new TimeStampedPVCoordinates(new AbsoluteDate("1992-10-08T15:20:38.821", TimeScalesFactory.getUTC()), new Vector3D(5392808.809823, -4187618.3357927715, -44206.638015847195), new Vector3D(2337.4472786270794, 2474.0146611860464, 6778.507766114648)), FramesFactory.getTOD(false), earthMu);
final SpacecraftState ss = new SpacecraftState(orb);
final UnnormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getUnnormalizedProvider(earthAe, earthMu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { -earthJ2 } }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 } });
final Frame earthFrame = CelestialBodyFactory.getEarth().getBodyOrientedFrame();
DSSTForceModel zonal = new DSSTZonal(provider, 2, 1, 5);
DSSTForceModel tesseral = new DSSTTesseral(earthFrame, Constants.WGS84_EARTH_ANGULAR_VELOCITY, provider, 2, 0, 0, 2, 2, 0, 0);
final Collection<DSSTForceModel> forces = new ArrayList<DSSTForceModel>();
forces.add(zonal);
forces.add(tesseral);
// Computes J2 mean elements using the DSST osculating to mean converter
final Orbit meanOrb = DSSTPropagator.computeMeanState(ss, null, forces).getOrbit();
Assert.assertEquals(0.0164196, FastMath.toDegrees(orb.getI() - meanOrb.getI()), 1.0e-7);
}
use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class DSSTPropagatorTest method testOsculatingToMeanState.
@Test
public void testOsculatingToMeanState() throws IllegalArgumentException, OrekitException {
final SpacecraftState meanState = getGEOState();
final UnnormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getUnnormalizedProvider(2, 0);
final Frame earthFrame = CelestialBodyFactory.getEarth().getBodyOrientedFrame();
DSSTForceModel zonal = new DSSTZonal(provider, 2, 1, 5);
DSSTForceModel tesseral = new DSSTTesseral(earthFrame, Constants.WGS84_EARTH_ANGULAR_VELOCITY, provider, 2, 0, 0, 2, 2, 0, 0);
final Collection<DSSTForceModel> forces = new ArrayList<DSSTForceModel>();
forces.add(zonal);
forces.add(tesseral);
final SpacecraftState osculatingState = DSSTPropagator.computeOsculatingState(meanState, null, forces);
// there are no Gaussian force models, we don't need an attitude provider
final SpacecraftState computedMeanState = DSSTPropagator.computeMeanState(osculatingState, null, forces);
Assert.assertEquals(meanState.getA(), computedMeanState.getA(), 2.0e-8);
Assert.assertEquals(0.0, Vector3D.distance(meanState.getPVCoordinates().getPosition(), computedMeanState.getPVCoordinates().getPosition()), 2.0e-8);
}
use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class OrbitDetermination method createBody.
/**
* Create an orbit from input parameters
* @param parser input file parser
* @param mu central attraction coefficient
* @throws NoSuchElementException if input parameters are missing
* @throws OrekitException if body frame cannot be created
*/
private OneAxisEllipsoid createBody(final KeyValueFileParser<ParameterKey> parser) throws NoSuchElementException, OrekitException {
final Frame bodyFrame;
if (!parser.containsKey(ParameterKey.BODY_FRAME)) {
bodyFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
} else {
bodyFrame = parser.getEarthFrame(ParameterKey.BODY_FRAME);
}
final double equatorialRadius;
if (!parser.containsKey(ParameterKey.BODY_EQUATORIAL_RADIUS)) {
equatorialRadius = Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
} else {
equatorialRadius = parser.getDouble(ParameterKey.BODY_EQUATORIAL_RADIUS);
}
final double flattening;
if (!parser.containsKey(ParameterKey.BODY_INVERSE_FLATTENING)) {
flattening = Constants.WGS84_EARTH_FLATTENING;
} else {
flattening = 1.0 / parser.getDouble(ParameterKey.BODY_INVERSE_FLATTENING);
}
return new OneAxisEllipsoid(equatorialRadius, flattening, bodyFrame);
}
use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class FieldPropagation method main.
/**
* Program entry point.
* @param args program arguments (unused here)
* @throws IOException
* @throws OrekitException
*/
public static void main(String[] args) throws IOException, OrekitException {
// the goal of this example is to make a Montecarlo simulation giving an error on the semiaxis,
// the inclination and the RAAN. The interest of doing it with Orekit based on the
// DerivativeStructure is that instead of doing a large number of propagation around the initial
// point we will do a single propagation of the initial state, and thanks to the Taylor expansion
// we will see the evolution of the std deviation of the position, which is divided in the
// CrossTrack, the LongTrack and the Radial error.
// configure Orekit
File home = new File(System.getProperty("user.home"));
File orekitData = new File(home, "orekit-data");
if (!orekitData.exists()) {
System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
System.exit(1);
}
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.addProvider(new DirectoryCrawler(orekitData));
// output file in user's home directory
File workingDir = new File(System.getProperty("user.home"));
File errorFile = new File(workingDir, "error.txt");
System.out.println("Output file is in : " + errorFile.getAbsolutePath());
PrintWriter PW = new PrintWriter(errorFile, "UTF-8");
PW.printf("time \t\tCrossTrackErr \tLongTrackErr \tRadialErr \tTotalErr%n");
// setting the parametersĀ of the simulation
// Order of derivation of the DerivativeStructures
int params = 3;
int order = 3;
DSFactory factory = new DSFactory(params, order);
// number of samples of the montecarlo simulation
int montecarlo_size = 100;
// nominal values of the Orbital parameters
double a_nominal = 7.278E6;
double e_nominal = 1e-3;
double i_nominal = FastMath.toRadians(98.3);
double pa_nominal = FastMath.PI / 2;
double raan_nominal = 0.0;
double ni_nominal = 0.0;
// mean of the gaussian curve for each of the errors around the nominal values
// {a, i, RAAN}
double[] mean = { 0, 0, 0 };
// standard deviation of the gaussian curve for each of the errors around the nominal values
// {dA, dI, dRaan}
double[] dAdIdRaan = { 5, FastMath.toRadians(1e-3), FastMath.toRadians(1e-3) };
// time of integration
double final_Dt = 1 * 60 * 60;
// number of steps per orbit
double num_step_orbit = 10;
DerivativeStructure a_0 = factory.variable(0, a_nominal);
DerivativeStructure e_0 = factory.constant(e_nominal);
DerivativeStructure i_0 = factory.variable(1, i_nominal);
DerivativeStructure pa_0 = factory.constant(pa_nominal);
DerivativeStructure raan_0 = factory.variable(2, raan_nominal);
DerivativeStructure ni_0 = factory.constant(ni_nominal);
// sometimes we will need the field of the DerivativeStructure to build new instances
Field<DerivativeStructure> field = a_0.getField();
// sometimes we will need the zero of the DerivativeStructure to build new instances
DerivativeStructure zero = field.getZero();
// initializing the FieldAbsoluteDate with only the field it will generate the day J2000
FieldAbsoluteDate<DerivativeStructure> date_0 = new FieldAbsoluteDate<>(field);
// initialize a basic frame
Frame frame = FramesFactory.getEME2000();
// initialize the orbit
double mu = 3.9860047e14;
FieldKeplerianOrbit<DerivativeStructure> KO = new FieldKeplerianOrbit<>(a_0, e_0, i_0, pa_0, raan_0, ni_0, PositionAngle.ECCENTRIC, frame, date_0, mu);
// step of integration (how many times per orbit we take the mesures)
double int_step = KO.getKeplerianPeriod().getReal() / num_step_orbit;
// random generator to conduct an
long number = 23091991;
RandomGenerator RG = new Well19937a(number);
GaussianRandomGenerator NGG = new GaussianRandomGenerator(RG);
UncorrelatedRandomVectorGenerator URVG = new UncorrelatedRandomVectorGenerator(mean, dAdIdRaan, NGG);
double[][] rand_gen = new double[montecarlo_size][3];
for (int jj = 0; jj < montecarlo_size; jj++) {
rand_gen[jj] = URVG.nextVector();
}
//
FieldSpacecraftState<DerivativeStructure> SS_0 = new FieldSpacecraftState<>(KO);
// adding force models
ForceModel fModel_Sun = new ThirdBodyAttraction(CelestialBodyFactory.getSun());
ForceModel fModel_Moon = new ThirdBodyAttraction(CelestialBodyFactory.getMoon());
ForceModel fModel_HFAM = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getNormalizedProvider(18, 18));
// setting an hipparchus field integrator
OrbitType type = OrbitType.CARTESIAN;
double[][] tolerance = NumericalPropagator.tolerances(0.001, KO.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<DerivativeStructure> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
// setting of the field propagator, we used the numerical one in order to add the third body attraction
// and the holmes featherstone force models
FieldNumericalPropagator<DerivativeStructure> numProp = new FieldNumericalPropagator<>(field, integrator);
numProp.setOrbitType(type);
numProp.setInitialState(SS_0);
numProp.addForceModel(fModel_Sun);
numProp.addForceModel(fModel_Moon);
numProp.addForceModel(fModel_HFAM);
// with the master mode we will calulcate and print the error on every fixed step on the file error.txt
// we defined the StepHandler to do that giving him the random number generator,
// the size of the montecarlo simulation and the initial date
numProp.setMasterMode(zero.add(int_step), new MyStepHandler<DerivativeStructure>(rand_gen, montecarlo_size, date_0, PW));
//
long START = System.nanoTime();
FieldSpacecraftState<DerivativeStructure> finalState = numProp.propagate(date_0.shiftedBy(final_Dt));
long STOP = System.nanoTime();
System.out.println((STOP - START) / 1E6 + " ms");
System.out.println(finalState.getDate());
PW.close();
}
Aggregations