use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testPresentParameterLift.
@Test
public void testPresentParameterLift() throws OrekitException {
SpacecraftState state = propagator.getInitialState();
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 2.0, 0.4, 1.0, 0.0);
FieldVector3D<DerivativeStructure> a = s.dragAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), 1.0e-6, Vector3D.PLUS_I, getDragParameters(s), DragSensitive.LIFT_RATIO);
Assert.assertEquals(5.58e-10, a.getNorm().getReal(), 1.0e-12);
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testOnlyLiftWithoutReflection.
@Test
public void testOnlyLiftWithoutReflection() throws OrekitException {
AbsoluteDate initialDate = propagator.getInitialState().getDate();
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, 1.0, 1.0, 1.0, 0.0);
Vector3D earthRot = new Vector3D(0.0, 0.0, 7.292115e-4);
for (double dt = 0; dt < 4000; dt += 60) {
AbsoluteDate date = initialDate.shiftedBy(dt);
SpacecraftState state = propagator.propagate(date);
// simple Earth fixed atmosphere
Vector3D p = state.getPVCoordinates().getPosition();
Vector3D v = state.getPVCoordinates().getVelocity();
Vector3D vAtm = Vector3D.crossProduct(earthRot, p);
Vector3D relativeVelocity = vAtm.subtract(v);
Vector3D drag = s.dragAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), 0.001, relativeVelocity, getDragParameters(s));
Assert.assertTrue(Vector3D.angle(relativeVelocity, drag) > 0.167);
Assert.assertTrue(Vector3D.angle(relativeVelocity, drag) < 0.736);
Vector3D sunDirection = sun.getPVCoordinates(date, state.getFrame()).getPosition().normalize();
Vector3D flux = new Vector3D(-4.56e-6, sunDirection);
Vector3D radiation = s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), flux, getRadiationParameters(s));
Assert.assertEquals(0.0, Vector3D.angle(flux, radiation), 1.0e-9);
}
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testWrongParameterRadiation.
@Test
public void testWrongParameterRadiation() throws OrekitException {
SpacecraftState state = propagator.getInitialState();
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 0.0, 1.0, 0.0);
try {
s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), Vector3D.PLUS_I, getRadiationParameters(s), "wrong");
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, oe.getSpecifier());
Assert.assertEquals("wrong", (String) oe.getParts()[0]);
}
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class HarmonicParametricAccelerationTest method doTestEquivalentManeuver.
private <T extends RealFieldElement<T>> void doTestEquivalentManeuver(final Field<T> field, final double mass, final AttitudeProvider maneuverLaw, final ConstantThrustManeuver maneuver, final AttitudeProvider accelerationLaw, final HarmonicParametricAcceleration parametricAcceleration, final double positionTolerance) throws OrekitException {
FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(field, new SpacecraftState(initialOrbit, maneuverLaw.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame()), mass));
double[][] tolerance = FieldNumericalPropagator.tolerances(field.getZero().add(10), initialState.getOrbit(), initialState.getOrbit().getType());
// propagator 0 uses a maneuver that is so efficient it does not consume any fuel
// (hence mass remains constant)
AdaptiveStepsizeFieldIntegrator<T> integrator0 = new DormandPrince853FieldIntegrator<>(field, 0.001, 100, tolerance[0], tolerance[1]);
integrator0.setInitialStepSize(field.getZero().add(60));
final FieldNumericalPropagator<T> propagator0 = new FieldNumericalPropagator<>(field, integrator0);
propagator0.setInitialState(initialState);
propagator0.setAttitudeProvider(maneuverLaw);
propagator0.addForceModel(maneuver);
propagator0.setEphemerisMode();
propagator0.propagate(initialState.getDate(), initialState.getDate().shiftedBy(1000.0));
FieldBoundedPropagator<T> ephemeris0 = propagator0.getGeneratedEphemeris();
// propagator 1 uses a constant acceleration
AdaptiveStepsizeFieldIntegrator<T> integrator1 = new DormandPrince853FieldIntegrator<>(field, 0.001, 100, tolerance[0], tolerance[1]);
integrator1.setInitialStepSize(field.getZero().add(60));
final FieldNumericalPropagator<T> propagator1 = new FieldNumericalPropagator<>(field, integrator1);
propagator1.setInitialState(initialState);
propagator1.setAttitudeProvider(accelerationLaw);
propagator1.addForceModel(parametricAcceleration);
propagator1.setEphemerisMode();
propagator1.propagate(initialState.getDate(), initialState.getDate().shiftedBy(1000.0));
FieldBoundedPropagator<T> ephemeris1 = propagator1.getGeneratedEphemeris();
for (double dt = 1; dt < 999; dt += 10) {
FieldAbsoluteDate<T> t = initialState.getDate().shiftedBy(dt);
FieldVector3D<T> p0 = ephemeris0.propagate(t).getPVCoordinates().getPosition();
FieldVector3D<T> p1 = ephemeris1.propagate(t).getPVCoordinates().getPosition();
Assert.assertEquals(0, FieldVector3D.distance(p0, p1).getReal(), positionTolerance);
}
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class HarmonicParametricAccelerationTest method testCoefficientsDetermination.
@Test
public void testCoefficientsDetermination() throws OrekitException {
final double mass = 2500;
final Orbit orbit = new CircularOrbit(7500000.0, 1.0e-4, 1.0e-3, 1.7, 0.3, 0.5, PositionAngle.TRUE, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 2, 3), TimeComponents.H00, TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
final double period = orbit.getKeplerianPeriod();
AttitudeProvider maneuverLaw = new LofOffset(orbit.getFrame(), LOFType.VNC);
SpacecraftState initialState = new SpacecraftState(orbit, maneuverLaw.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
double dP = 10.0;
double minStep = 0.001;
double maxStep = 100;
double[][] tolerance = NumericalPropagator.tolerances(dP, orbit, orbit.getType());
// generate PV measurements corresponding to a tangential maneuver
AdaptiveStepsizeIntegrator integrator0 = new DormandPrince853Integrator(minStep, maxStep, tolerance[0], tolerance[1]);
integrator0.setInitialStepSize(60);
final NumericalPropagator propagator0 = new NumericalPropagator(integrator0);
propagator0.setInitialState(initialState);
propagator0.setAttitudeProvider(maneuverLaw);
ForceModel hpaRefX1 = new HarmonicParametricAcceleration(Vector3D.PLUS_I, true, "refX1", null, period, 1);
ForceModel hpaRefY1 = new HarmonicParametricAcceleration(Vector3D.PLUS_J, true, "refY1", null, period, 1);
ForceModel hpaRefZ2 = new HarmonicParametricAcceleration(Vector3D.PLUS_K, true, "refZ2", null, period, 2);
hpaRefX1.getParametersDrivers()[0].setValue(2.4e-2);
hpaRefX1.getParametersDrivers()[1].setValue(3.1);
hpaRefY1.getParametersDrivers()[0].setValue(4.0e-2);
hpaRefY1.getParametersDrivers()[1].setValue(0.3);
hpaRefZ2.getParametersDrivers()[0].setValue(1.0e-2);
hpaRefZ2.getParametersDrivers()[1].setValue(1.8);
propagator0.addForceModel(hpaRefX1);
propagator0.addForceModel(hpaRefY1);
propagator0.addForceModel(hpaRefZ2);
final List<ObservedMeasurement<?>> measurements = new ArrayList<>();
propagator0.setMasterMode(10.0, (state, isLast) -> measurements.add(new PV(state.getDate(), state.getPVCoordinates().getPosition(), state.getPVCoordinates().getVelocity(), 1.0e-3, 1.0e-6, 1.0)));
propagator0.propagate(orbit.getDate().shiftedBy(900));
// set up an estimator to retrieve the maneuver as several harmonic accelerations in inertial frame
final NumericalPropagatorBuilder propagatorBuilder = new NumericalPropagatorBuilder(orbit, new DormandPrince853IntegratorBuilder(minStep, maxStep, dP), PositionAngle.TRUE, dP);
propagatorBuilder.addForceModel(new HarmonicParametricAcceleration(Vector3D.PLUS_I, true, "X1", null, period, 1));
propagatorBuilder.addForceModel(new HarmonicParametricAcceleration(Vector3D.PLUS_J, true, "Y1", null, period, 1));
propagatorBuilder.addForceModel(new HarmonicParametricAcceleration(Vector3D.PLUS_K, true, "Z2", null, period, 2));
final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(), propagatorBuilder);
estimator.setParametersConvergenceThreshold(1.0e-2);
estimator.setMaxIterations(20);
estimator.setMaxEvaluations(100);
for (final ObservedMeasurement<?> measurement : measurements) {
estimator.addMeasurement(measurement);
}
// we will estimate only the force model parameters, not the orbit
for (final ParameterDriver d : estimator.getOrbitalParametersDrivers(false).getDrivers()) {
d.setSelected(false);
}
setParameter(estimator, "X1 γ", 1.0e-2);
setParameter(estimator, "X1 φ", 4.0);
setParameter(estimator, "Y1 γ", 1.0e-2);
setParameter(estimator, "Y1 φ", 0.0);
setParameter(estimator, "Z2 γ", 1.0e-2);
setParameter(estimator, "Z2 φ", 1.0);
estimator.estimate();
Assert.assertTrue(estimator.getIterationsCount() < 15);
Assert.assertTrue(estimator.getEvaluationsCount() < 15);
Assert.assertEquals(0.0, estimator.getOptimum().getRMS(), 1.0e-5);
Assert.assertEquals(hpaRefX1.getParametersDrivers()[0].getValue(), getParameter(estimator, "X1 γ"), 1.e-12);
Assert.assertEquals(hpaRefX1.getParametersDrivers()[1].getValue(), getParameter(estimator, "X1 φ"), 1.e-12);
Assert.assertEquals(hpaRefY1.getParametersDrivers()[0].getValue(), getParameter(estimator, "Y1 γ"), 1.e-12);
Assert.assertEquals(hpaRefY1.getParametersDrivers()[1].getValue(), getParameter(estimator, "Y1 φ"), 1.e-12);
Assert.assertEquals(hpaRefZ2.getParametersDrivers()[0].getValue(), getParameter(estimator, "Z2 γ"), 1.e-12);
Assert.assertEquals(hpaRefZ2.getParametersDrivers()[1].getValue(), getParameter(estimator, "Z2 φ"), 1.e-12);
}
Aggregations