Search in sources :

Example 16 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class FunctionalDetectorTest method testFunctionalDetector.

/**
 * Check {@link FunctionalDetector}.
 *
 * @throws OrekitException on error.
 */
@Test
public void testFunctionalDetector() throws OrekitException {
    // setup
    GFunction g = SpacecraftState::getMass;
    EventHandler<EventDetector> handler = (s, detector, increasing) -> Action.STOP;
    // action
    FunctionalDetector detector = new FunctionalDetector().withMaxIter(1).withThreshold(2).withMaxCheck(3).withGFunction(g).withHandler(handler);
    // verify
    MatcherAssert.assertThat(detector.getMaxIterationCount(), CoreMatchers.is(1));
    MatcherAssert.assertThat(detector.getThreshold(), CoreMatchers.is(2.0));
    MatcherAssert.assertThat(detector.getMaxCheckInterval(), CoreMatchers.is(3.0));
    MatcherAssert.assertThat(detector.getHandler(), CoreMatchers.is(handler));
    MatcherAssert.assertThat(detector.getGFunction(), CoreMatchers.is(g));
    SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(new Vector3D(1, 2, 3), new Vector3D(4, 5, 6)), FramesFactory.getGCRF(), AbsoluteDate.CCSDS_EPOCH, 4), 5);
    MatcherAssert.assertThat(detector.g(state), CoreMatchers.is(5.0));
    MatcherAssert.assertThat(detector.eventOccurred(null, false), CoreMatchers.is(Action.STOP));
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) CoreMatchers(org.hamcrest.CoreMatchers) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FramesFactory(org.orekit.frames.FramesFactory) Test(org.junit.Test) PVCoordinates(org.orekit.utils.PVCoordinates) MatcherAssert(org.hamcrest.MatcherAssert) EventHandler(org.orekit.propagation.events.handlers.EventHandler) OrekitException(org.orekit.errors.OrekitException) SpacecraftState(org.orekit.propagation.SpacecraftState) GFunction(org.orekit.propagation.events.FunctionalDetector.GFunction) Action(org.orekit.propagation.events.handlers.EventHandler.Action) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) GFunction(org.orekit.propagation.events.FunctionalDetector.GFunction) Test(org.junit.Test)

Example 17 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class ApsideDetectorTest method setUp.

@Before
public void setUp() throws OrekitException {
    Utils.setDataRoot("regular-data");
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(506.0, 943.0, 7450);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CartesianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU);
    propagator = new EcksteinHechlerPropagator(orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
}
Also used : EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) CartesianOrbit(org.orekit.orbits.CartesianOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Example 18 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class PositionAngleDetectorTest method doTest.

private void doTest(final OrbitType orbitType, final PositionAngle positionAngle, final double angle, final int expectedCrossings) throws OrekitException {
    PositionAngleDetector d = new PositionAngleDetector(orbitType, positionAngle, angle).withMaxCheck(60).withThreshold(1.e-10).withHandler(new ContinueOnEvent<PositionAngleDetector>());
    Assert.assertEquals(60.0, d.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(1.0e-10, d.getThreshold(), 1.0e-15);
    Assert.assertEquals(orbitType, d.getOrbitType());
    Assert.assertEquals(positionAngle, d.getPositionAngle());
    Assert.assertEquals(angle, d.getAngle(), 1.0e-14);
    Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, d.getMaxIterationCount());
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(506.0, 943.0, 7450);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CartesianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU);
    Propagator propagator = new EcksteinHechlerPropagator(orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(d));
    propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY));
    double[] array = new double[6];
    for (LoggedEvent e : logger.getLoggedEvents()) {
        SpacecraftState state = e.getState();
        orbitType.mapOrbitToArray(state.getOrbit(), positionAngle, array, null);
        Assert.assertEquals(angle, MathUtils.normalizeAngle(array[5], angle), 1.0e-10);
    }
    Assert.assertEquals(15, logger.getLoggedEvents().size());
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator)

Example 19 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class SolarBodyTest method testPropagationVsEphemeris.

@Test
public void testPropagationVsEphemeris() throws OrekitException {
    Utils.setDataRoot("regular-data");
    // Creation of the celestial bodies of the solar system
    final CelestialBody sun = CelestialBodyFactory.getSun();
    final CelestialBody mercury = CelestialBodyFactory.getMercury();
    final CelestialBody venus = CelestialBodyFactory.getVenus();
    final CelestialBody earth = CelestialBodyFactory.getEarth();
    final CelestialBody mars = CelestialBodyFactory.getMars();
    final CelestialBody jupiter = CelestialBodyFactory.getJupiter();
    final CelestialBody saturn = CelestialBodyFactory.getSaturn();
    final CelestialBody uranus = CelestialBodyFactory.getUranus();
    final CelestialBody neptune = CelestialBodyFactory.getNeptune();
    final CelestialBody pluto = CelestialBodyFactory.getPluto();
    // Starting and end dates
    final AbsoluteDate startingDate = new AbsoluteDate(2000, 1, 2, TimeScalesFactory.getUTC());
    AbsoluteDate endDate = startingDate.shiftedBy(30 * Constants.JULIAN_DAY);
    final Frame icrf = FramesFactory.getICRF();
    // fake orbit around negligible point mass at solar system barycenter
    double negligibleMu = 1.0e-3;
    SpacecraftState initialState = new SpacecraftState(new CartesianOrbit(venus.getPVCoordinates(startingDate, icrf), icrf, startingDate, negligibleMu));
    // Creation of the numerical propagator
    final double[][] tol = NumericalPropagator.tolerances(1000, initialState.getOrbit(), OrbitType.CARTESIAN);
    AbstractIntegrator dop1 = new DormandPrince853Integrator(1.0, 1.0e5, tol[0], tol[1]);
    NumericalPropagator propag = new NumericalPropagator(dop1);
    propag.setOrbitType(OrbitType.CARTESIAN);
    propag.setInitialState(initialState);
    propag.setMu(negligibleMu);
    // Creation of the ForceModels
    propag.addForceModel(new BodyAttraction(sun));
    propag.addForceModel(new BodyAttraction(mercury));
    propag.addForceModel(new BodyAttraction(earth));
    propag.addForceModel(new BodyAttraction(mars));
    propag.addForceModel(new BodyAttraction(jupiter));
    propag.addForceModel(new BodyAttraction(saturn));
    propag.addForceModel(new BodyAttraction(uranus));
    propag.addForceModel(new BodyAttraction(neptune));
    propag.addForceModel(new BodyAttraction(pluto));
    // checks are done within the step handler
    propag.setMasterMode(1000.0, new OrekitFixedStepHandler() {

        public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
            // propagated position should remain within 1400m of ephemeris for one month
            Vector3D propagatedP = currentState.getPVCoordinates(icrf).getPosition();
            Vector3D ephemerisP = venus.getPVCoordinates(currentState.getDate(), icrf).getPosition();
            Assert.assertEquals(0, Vector3D.distance(propagatedP, ephemerisP), 1400.0);
        }
    });
    propag.propagate(startingDate, endDate);
}
Also used : Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) AbstractIntegrator(org.hipparchus.ode.AbstractIntegrator) OrekitException(org.orekit.errors.OrekitException) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) Test(org.junit.Test)

Example 20 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project SpriteOrbits by ProjectPersephone.

the class SpriteProp method main.

/**
 * @param args
 */
public static void main(String[] args) {
    PrintStream out = null;
    try {
        // set up orekit data
        // for this to work, the orekit-data.zip file avaiable at the following URL
        // must be put in the current working directory
        // URL:     https://www.orekit.org/forge/projects/orekit/files
        File userDir = new File(System.getProperty("user.dir"));
        File orekitZip = new File(userDir, "orekit-data.zip");
        DataProvidersManager.getInstance().addProvider(new ZipJarCrawler(orekitZip));
        // reference models
        // this is the frame labeled J2K in the NASA page
        final Frame eme2000 = FramesFactory.getEME2000();
        final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        final TimeScale utc = TimeScalesFactory.getUTC();
        // central attraction coefficient MU
        final double mu = Constants.EIGEN5C_EARTH_MU;
        // set up some data, ideally, this should be provided as input to the program
        // ISS orbit is from http://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/orbit/ISS/SVPOST.html
        // 
        // Coasting Arc #15 (Orbit 3386)
        // ---------------------------------------
        // 
        // Vector Time (GMT): 2014/055/16:27:06.921
        // Vector Time (MET): N/A
        // Weight (LBS)     : 911651.1
        // 
        // ...
        // 
        // J2K Cartesian
        // --------------------------------
        // X    =         2998767.75
        // Y    =        -6097451.56  meter
        // ...              Z    =         -141448.92
        // XDOT =        4323.077242
        // YDOT =        1994.291706  meter/sec
        // ZDOT =        6000.774574
        // we start small, we can increase this later
        final int numberOfSprites = 12;
        // (m/s)
        final double relativeReleaseVelocity = 1.0;
        final AbsoluteDate releaseDate = new // year, month, day
        AbsoluteDate(// year, month, day
        2014, // year, month, day
        3, // year, month, day
        1, // hours, minutes, seconds
        12, // hours, minutes, seconds
        0, // hours, minutes, seconds
        0.0, utc);
        final CartesianOrbit kickSatOrbit = new CartesianOrbit(new // position (m)
        PVCoordinates(// position (m)
        new Vector3D(2998767.75, -6097451.56, -141448.92), // velocity (m/s)
        new Vector3D(4323.077242, 1994.291706, 6000.774574)), eme2000, new // year, day in year as NASA page above
        AbsoluteDate(// year, day in year as NASA page above
        new DateComponents(2014, 55), // hour in day
        new TimeComponents(16, 27, 6.921), utc), mu);
        // kg
        final double kickSatMass = 10.0;
        // m^2
        final double kickSatCrossSection = 0.03;
        // no units
        final double kickSatDragCoeff = 2.2;
        // kg
        final double spriteMass = 0.01;
        // m^2
        final double spriteCrossSection = 2.5e-3;
        // no units
        final double spriteDragCoeff = 2.2;
        SpriteProp spriteProp = new SpriteProp(numberOfSprites, kickSatOrbit, kickSatMass, kickSatCrossSection, kickSatDragCoeff, spriteMass, spriteCrossSection, spriteDragCoeff, relativeReleaseVelocity, releaseDate, itrf);
        // days after release
        final double propagationDuration = 0.2;
        // seconds
        final double step = 60.0;
        // out = new PrintStream(new File(userDir, "sprites-prop.txt"));
        out = new PrintStream(new File(userDir, "orbits.json"));
        out.format(Locale.US, "[");
        spriteProp.run(out, propagationDuration, step, utc);
        out.format(Locale.US, "]");
    } catch (IOException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (OrekitException e) {
        e.printStackTrace();
    } finally {
        if (out != null) {
            out.close();
        }
    }
}
Also used : PrintStream(java.io.PrintStream) Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) IOException(java.io.IOException) TimeScale(org.orekit.time.TimeScale) GeodeticPoint(org.orekit.bodies.GeodeticPoint) AbsoluteDate(org.orekit.time.AbsoluteDate) Vector3D(org.apache.commons.math3.geometry.euclidean.threed.Vector3D) ZipJarCrawler(org.orekit.data.ZipJarCrawler) OrekitException(org.orekit.errors.OrekitException) File(java.io.File)

Aggregations

CartesianOrbit (org.orekit.orbits.CartesianOrbit)57 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)48 AbsoluteDate (org.orekit.time.AbsoluteDate)43 SpacecraftState (org.orekit.propagation.SpacecraftState)38 Test (org.junit.Test)37 PVCoordinates (org.orekit.utils.PVCoordinates)32 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)28 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)25 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)22 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)20 Frame (org.orekit.frames.Frame)17 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)15 OrekitException (org.orekit.errors.OrekitException)14 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)14 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)13 BoundedPropagator (org.orekit.propagation.BoundedPropagator)11 Propagator (org.orekit.propagation.Propagator)10 TimeScale (org.orekit.time.TimeScale)10 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)9