use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testParametersDrivers.
@Test
public void testParametersDrivers() throws OrekitException {
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft.Facet[] facets = new BoxAndSolarArraySpacecraft.Facet[] { new BoxAndSolarArraySpacecraft.Facet(Vector3D.MINUS_I, 3.0), new BoxAndSolarArraySpacecraft.Facet(Vector3D.PLUS_I, 3.0), new BoxAndSolarArraySpacecraft.Facet(Vector3D.MINUS_J, 3.0), new BoxAndSolarArraySpacecraft.Facet(Vector3D.PLUS_J, 3.0), new BoxAndSolarArraySpacecraft.Facet(Vector3D.MINUS_K, 3.0), new BoxAndSolarArraySpacecraft.Facet(Vector3D.PLUS_K, 3.0) };
BoxAndSolarArraySpacecraft s1 = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, 2.0, 0.8, 0.1);
Assert.assertEquals(1, s1.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s1.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s1.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(2, s1.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s1.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s1.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s1.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s1.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s2 = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, 2.0, 0.4, 0.8, 0.1);
Assert.assertEquals(2, s2.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s2.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s2.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(DragSensitive.LIFT_RATIO, s2.getDragParametersDrivers()[1].getName());
Assert.assertEquals(0.4, s2.getDragParametersDrivers()[1].getValue(), 1.0e-15);
Assert.assertEquals(2, s2.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s2.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s2.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s2.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s2.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s3 = new BoxAndSolarArraySpacecraft(facets, sun, 20.0, Vector3D.PLUS_J, 2.0, 0.8, 0.1);
Assert.assertEquals(1, s3.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s3.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s3.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(2, s3.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s3.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s3.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s3.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s3.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s4 = new BoxAndSolarArraySpacecraft(facets, sun, 20.0, Vector3D.PLUS_J, 2.0, 0.4, 0.8, 0.1);
Assert.assertEquals(2, s4.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s4.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s4.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(DragSensitive.LIFT_RATIO, s4.getDragParametersDrivers()[1].getName());
Assert.assertEquals(0.4, s4.getDragParametersDrivers()[1].getValue(), 1.0e-15);
Assert.assertEquals(2, s4.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s4.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s4.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s4.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s4.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s5 = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, AbsoluteDate.J2000_EPOCH, Vector3D.PLUS_I, 7.292e-5, 2.0, 0.8, 0.1);
Assert.assertEquals(1, s5.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s5.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s5.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(2, s5.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s5.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s5.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s5.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s5.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s6 = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, AbsoluteDate.J2000_EPOCH, Vector3D.PLUS_I, 7.292e-5, 2.0, 0.4, 0.8, 0.1);
Assert.assertEquals(2, s6.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s6.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s6.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(DragSensitive.LIFT_RATIO, s6.getDragParametersDrivers()[1].getName());
Assert.assertEquals(0.4, s6.getDragParametersDrivers()[1].getValue(), 1.0e-15);
Assert.assertEquals(2, s6.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s6.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s6.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s6.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s6.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s7 = new BoxAndSolarArraySpacecraft(facets, sun, 20.0, Vector3D.PLUS_J, AbsoluteDate.J2000_EPOCH, Vector3D.PLUS_I, 7.292e-5, 2.0, 0.8, 0.1);
Assert.assertEquals(1, s7.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s7.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s7.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(2, s7.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s7.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s7.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s7.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s7.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
BoxAndSolarArraySpacecraft s8 = new BoxAndSolarArraySpacecraft(facets, sun, 20.0, Vector3D.PLUS_J, AbsoluteDate.J2000_EPOCH, Vector3D.PLUS_I, 7.292e-5, 2.0, 0.4, 0.8, 0.1);
Assert.assertEquals(2, s8.getDragParametersDrivers().length);
Assert.assertEquals(DragSensitive.DRAG_COEFFICIENT, s8.getDragParametersDrivers()[0].getName());
Assert.assertEquals(2.0, s8.getDragParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(DragSensitive.LIFT_RATIO, s8.getDragParametersDrivers()[1].getName());
Assert.assertEquals(0.4, s8.getDragParametersDrivers()[1].getValue(), 1.0e-15);
Assert.assertEquals(2, s8.getRadiationParametersDrivers().length);
Assert.assertEquals(RadiationSensitive.ABSORPTION_COEFFICIENT, s8.getRadiationParametersDrivers()[0].getName());
Assert.assertEquals(0.8, s8.getRadiationParametersDrivers()[0].getValue(), 1.0e-15);
Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, s8.getRadiationParametersDrivers()[1].getName());
Assert.assertEquals(0.1, s8.getRadiationParametersDrivers()[1].getValue(), 1.0e-15);
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class OrekitEphemerisFileTest method testWritingToOEM.
@Test
public void testWritingToOEM() throws OrekitException, IOException {
final double muTolerance = 1e-12;
final double positionTolerance = 1e-8;
final double velocityTolerance = 1e-8;
final String satId = "SATELLITE1";
final double sma = 10000000;
final double inc = Math.toRadians(45.0);
final double ecc = 0.001;
final double raan = 0.0;
final double pa = 0.0;
final double ta = 0.0;
final AbsoluteDate date = new AbsoluteDate();
final Frame frame = FramesFactory.getGCRF();
final CelestialBody body = CelestialBodyFactory.getEarth();
final double mu = body.getGM();
KeplerianOrbit initialOrbit = new KeplerianOrbit(sma, ecc, inc, pa, raan, ta, PositionAngle.TRUE, frame, date, mu);
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
final double propagationDurationSeconds = 86400.0;
final double stepSizeSeconds = 60.0;
List<SpacecraftState> states = new ArrayList<SpacecraftState>();
for (double dt = 0.0; dt < propagationDurationSeconds; dt += stepSizeSeconds) {
states.add(propagator.propagate(date.shiftedBy(dt)));
}
OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
OrekitSatelliteEphemeris satellite = ephemerisFile.addSatellite(satId);
satellite.addNewSegment(states);
String tempOemFile = Files.createTempFile("OrekitEphemerisFileTest", ".oem").toString();
new OEMWriter().write(tempOemFile, ephemerisFile);
EphemerisFile ephemerisFromFile = new OEMParser().parse(tempOemFile);
Files.delete(Paths.get(tempOemFile));
EphemerisSegment segment = ephemerisFromFile.getSatellites().get(satId).getSegments().get(0);
assertEquals(states.get(0).getDate(), segment.getStart());
assertEquals(states.get(states.size() - 1).getDate(), segment.getStop());
assertEquals(states.size(), segment.getCoordinates().size());
assertEquals(frame, segment.getFrame());
assertEquals(body.getName().toUpperCase(), segment.getFrameCenterString());
assertEquals(body.getGM(), segment.getMu(), muTolerance);
for (int i = 0; i < states.size(); i++) {
TimeStampedPVCoordinates expected = states.get(i).getPVCoordinates();
TimeStampedPVCoordinates actual = segment.getCoordinates().get(i);
assertEquals(expected.getDate(), actual.getDate());
assertEquals(0.0, Vector3D.distance(expected.getPosition(), actual.getPosition()), positionTolerance);
assertEquals(0.0, Vector3D.distance(expected.getVelocity(), actual.getVelocity()), velocityTolerance);
}
// test ingested ephemeris generates access intervals
final OneAxisEllipsoid parentShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final double latitude = 0.0;
final double longitude = 0.0;
final double altitude = 0.0;
final GeodeticPoint point = new GeodeticPoint(latitude, longitude, altitude);
final TopocentricFrame topo = new TopocentricFrame(parentShape, point, "testPoint1");
final ElevationDetector elevationDetector = new ElevationDetector(topo);
final EphemerisSegmentPropagator ephemerisSegmentPropagator = new EphemerisSegmentPropagator(segment);
final EventsLogger lookupLogger = new EventsLogger();
ephemerisSegmentPropagator.addEventDetector(lookupLogger.monitorDetector(elevationDetector));
final EventsLogger referenceLogger = new EventsLogger();
propagator.clearEventsDetectors();
propagator.addEventDetector(referenceLogger.monitorDetector(elevationDetector));
propagator.propagate(segment.getStart(), segment.getStop());
ephemerisSegmentPropagator.propagate(segment.getStart(), segment.getStop());
final double dateEpsilon = 1.0e-9;
assertTrue(referenceLogger.getLoggedEvents().size() > 0);
assertEquals(referenceLogger.getLoggedEvents().size(), lookupLogger.getLoggedEvents().size());
for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
LoggedEvent actual = lookupLogger.getLoggedEvents().get(i);
assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
}
final Propagator embeddedPropagator = segment.getPropagator();
final EventsLogger embeddedPropLogger = new EventsLogger();
embeddedPropagator.addEventDetector(embeddedPropLogger.monitorDetector(elevationDetector));
embeddedPropagator.propagate(segment.getStart(), segment.getStop());
assertEquals(referenceLogger.getLoggedEvents().size(), embeddedPropLogger.getLoggedEvents().size());
for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
LoggedEvent actual = embeddedPropLogger.getLoggedEvents().get(i);
assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
}
final List<SpacecraftState> readInStates = new ArrayList<SpacecraftState>();
segment.getCoordinates().forEach(c -> {
try {
readInStates.add(new SpacecraftState(new CartesianOrbit(c, frame, mu)));
} catch (IllegalArgumentException | OrekitException e) {
fail(e.getLocalizedMessage());
}
});
final int interpolationPoints = 5;
Ephemeris directEphemProp = new Ephemeris(readInStates, interpolationPoints);
final EventsLogger directEphemPropLogger = new EventsLogger();
directEphemProp.addEventDetector(directEphemPropLogger.monitorDetector(elevationDetector));
directEphemProp.propagate(segment.getStart(), segment.getStop());
assertEquals(referenceLogger.getLoggedEvents().size(), directEphemPropLogger.getLoggedEvents().size());
for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
LoggedEvent actual = directEphemPropLogger.getLoggedEvents().get(i);
assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
}
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testNormalFixedRateField.
@Test
public void testNormalFixedRateField() throws OrekitException {
AbsoluteDate initialDate = propagator.getInitialState().getDate();
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, initialDate, Vector3D.PLUS_K, 1.0e-3, 0.0, 1.0, 0.0);
Field<Decimal64> field = Decimal64Field.getInstance();
for (double dt = 0; dt < 4000; dt += 60) {
AbsoluteDate date = initialDate.shiftedBy(dt);
SpacecraftState state = propagator.propagate(date);
FieldVector3D<Decimal64> normal = s.getNormal(new FieldAbsoluteDate<>(field, state.getDate()), state.getFrame(), new FieldVector3D<>(field, state.getPVCoordinates().getPosition()), new FieldRotation<>(field, state.getAttitude().getRotation()));
Assert.assertEquals(0, FieldVector3D.dotProduct(normal, Vector3D.PLUS_J).getReal(), 1.0e-16);
}
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testPlaneSpecularReflection.
@Test
public void testPlaneSpecularReflection() throws OrekitException {
AbsoluteDate initialDate = propagator.getInitialState().getDate();
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 0.0, 0.0, 1.0);
for (double dt = 0; dt < 4000; dt += 60) {
AbsoluteDate date = initialDate.shiftedBy(dt);
SpacecraftState state = propagator.propagate(date);
Vector3D sunDirection = sun.getPVCoordinates(date, state.getFrame()).getPosition().normalize();
Vector3D flux = new Vector3D(-4.56e-6, sunDirection);
Vector3D acceleration = s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), flux, getRadiationParameters(s));
Vector3D normal = state.getAttitude().getRotation().applyInverseTo(s.getNormal(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation()));
// solar array normal is slightly misaligned with Sun direction due to Sun being out of orbital plane
Assert.assertEquals(15.1, FastMath.toDegrees(Vector3D.angle(sunDirection, normal)), 0.11);
// radiation pressure is exactly opposed to solar array normal as there is only specular reflection
Assert.assertEquals(180.0, FastMath.toDegrees(Vector3D.angle(acceleration, normal)), 1.0e-3);
}
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testNormalOptimalRotationDouble.
@Test
public void testNormalOptimalRotationDouble() throws OrekitException {
AbsoluteDate initialDate = propagator.getInitialState().getDate();
CelestialBody sun = CelestialBodyFactory.getSun();
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 0.0, 1.0, 0.0);
for (double dt = 0; dt < 4000; dt += 60) {
AbsoluteDate date = initialDate.shiftedBy(dt);
SpacecraftState state = propagator.propagate(date);
Vector3D normal = s.getNormal(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation());
Assert.assertEquals(0, Vector3D.dotProduct(normal, Vector3D.PLUS_J), 1.0e-16);
}
}
Aggregations