Search in sources :

Example 41 with TimeComponents

use of org.orekit.time.TimeComponents 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)

Example 42 with TimeComponents

use of org.orekit.time.TimeComponents in project SpriteOrbits by ProjectPersephone.

the class SpritePropOrig 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;
        SpritePropOrig spriteProp = new SpritePropOrig(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"));
        spriteProp.run(out, propagationDuration, step, utc);
    } 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)

Example 43 with TimeComponents

use of org.orekit.time.TimeComponents in project Orekit by CS-SI.

the class StreamingOemWriter method dateToString.

/**
 * Convert a date to a string with more precision.
 *
 * @param components to convert to a String.
 * @return the String form of {@code date} with at least 9 digits of precision.
 */
static String dateToString(final DateTimeComponents components) {
    final TimeComponents time = components.getTime();
    final int hour = time.getHour();
    final int minute = time.getMinute();
    final double second = time.getSecond();
    // Decimal formatting classes could be static final if they were thread safe.
    final DecimalFormatSymbols locale = new DecimalFormatSymbols(STANDARDIZED_LOCALE);
    final DecimalFormat twoDigits = new DecimalFormat("00", locale);
    final DecimalFormat precise = new DecimalFormat("00.0########", locale);
    return components.getDate().toString() + "T" + twoDigits.format(hour) + ":" + twoDigits.format(minute) + ":" + precise.format(second);
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) DateTimeComponents(org.orekit.time.DateTimeComponents) TimeComponents(org.orekit.time.TimeComponents)

Example 44 with TimeComponents

use of org.orekit.time.TimeComponents in project Orekit by CS-SI.

the class ConstantThrustManeuverTest method testRoughBehaviour.

@Test
public void testRoughBehaviour() throws OrekitException {
    final double isp = 318;
    final double mass = 2500;
    final double a = 24396159;
    final double e = 0.72831215;
    final double i = FastMath.toRadians(7);
    final double omega = FastMath.toRadians(180);
    final double OMEGA = FastMath.toRadians(261);
    final double lv = 0;
    final double duration = 3653.99;
    final double f = 420;
    final double delta = FastMath.toRadians(-7.4978);
    final double alpha = FastMath.toRadians(351);
    final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
    final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
    final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
    final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
    Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
    Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);
    double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
    double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, absTolerance, relTolerance);
    integrator.setInitialStepSize(60);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);
    propagator.setInitialState(initialState);
    propagator.setAttitudeProvider(law);
    propagator.addForceModel(maneuver);
    final SpacecraftState finalorb = propagator.propagate(fireDate.shiftedBy(3800));
    final double massTolerance = FastMath.abs(maneuver.getFlowRate()) * maneuver.getEventsDetectors().findFirst().get().getThreshold();
    Assert.assertEquals(2007.8824544261233, finalorb.getMass(), massTolerance);
    Assert.assertEquals(2.6872, FastMath.toDegrees(MathUtils.normalizeAngle(finalorb.getI(), FastMath.PI)), 1e-4);
    Assert.assertEquals(28970, finalorb.getA() / 1000, 1);
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) InertialProvider(org.orekit.attitudes.InertialProvider) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 45 with TimeComponents

use of org.orekit.time.TimeComponents in project Orekit by CS-SI.

the class ConstantThrustManeuverTest method testNegativeDuration.

@Test
public void testNegativeDuration() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    ConstantThrustManeuver maneuver = new ConstantThrustManeuver(date, -10.0, 400.0, 300.0, Vector3D.PLUS_K, "1A-");
    ParameterDriver[] drivers = maneuver.getParametersDrivers();
    Assert.assertEquals(2, drivers.length);
    Assert.assertEquals("1A-thrust", drivers[0].getName());
    Assert.assertEquals("1A-flow rate", drivers[1].getName());
    EventDetector[] switches = maneuver.getEventsDetectors().toArray(EventDetector[]::new);
    Orbit o1 = dummyOrbit(date.shiftedBy(-11.0));
    Assert.assertTrue(switches[0].g(new SpacecraftState(o1)) < 0);
    Orbit o2 = dummyOrbit(date.shiftedBy(-9.0));
    Assert.assertTrue(switches[0].g(new SpacecraftState(o2)) > 0);
    Orbit o3 = dummyOrbit(date.shiftedBy(-1.0));
    Assert.assertTrue(switches[1].g(new SpacecraftState(o3)) < 0);
    Orbit o4 = dummyOrbit(date.shiftedBy(1.0));
    Assert.assertTrue(switches[1].g(new SpacecraftState(o4)) > 0);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) EventDetector(org.orekit.propagation.events.EventDetector) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) ParameterDriver(org.orekit.utils.ParameterDriver) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Aggregations

TimeComponents (org.orekit.time.TimeComponents)88 DateComponents (org.orekit.time.DateComponents)87 AbsoluteDate (org.orekit.time.AbsoluteDate)84 Test (org.junit.Test)72 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)55 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)55 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)47 Orbit (org.orekit.orbits.Orbit)44 SpacecraftState (org.orekit.propagation.SpacecraftState)42 CartesianOrbit (org.orekit.orbits.CartesianOrbit)35 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)35 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)32 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)28 PVCoordinates (org.orekit.utils.PVCoordinates)24 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)22 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)17 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)17 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)17 CircularOrbit (org.orekit.orbits.CircularOrbit)16 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)16