Commit f2fa92dc authored by Pascal Parraud's avatar Pascal Parraud

The ephemeris produced by numerical propagator now checks date validity in propagate method.

parent 7343f4d3
......@@ -7,10 +7,6 @@
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-math/2.0-SNAPSHOT/commons-math-2.0-SNAPSHOT.jar" sourcepath="/M2_REPO/org/apache/commons/commons-math/2.0-SNAPSHOT/commons-math-2.0-SNAPSHOT-sources.jar">
<attributes>
<attribute name="javadoc_location" value="http://commons.apache.org/math/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-math/2.0-SNAPSHOT/commons-math-2.0-SNAPSHOT.jar" sourcepath="/M2_REPO/org/apache/commons/commons-math/2.0-SNAPSHOT/commons-math-2.0-SNAPSHOT-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
#Mon Mar 17 09:40:50 MET 2008
#Fri Sep 19 17:39:05 CEST 2008
eclipse.preferences.version=1
formatter_profile=_SpaceRoots
formatter_settings_version=11
......@@ -7,3 +7,4 @@ org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.javadoc=false
org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\n * \n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
......@@ -41,6 +41,14 @@
<role>developer</role>
</roles>
</developer>
<developer>
<name>Pascal Parraud</name>
<id>pascal</id>
<email>Pascal.Parraud at c-s dot fr</email>
<roles>
<role>developer</role>
</roles>
</developer>
<developer>
<name>V&#233;ronique Pommier-Maurussane</name>
<id>v&#233;ronique</id>
......
......@@ -118,6 +118,12 @@ class IntegratedEphemeris implements BoundedPropagator, ModeHandler, StepHandler
/** {@inheritDoc} */
public SpacecraftState propagate(final AbsoluteDate date)
throws PropagationException {
if ((date.compareTo(minDate) < 0) || (date.compareTo(maxDate) > 0)) {
throw new PropagationException("out of range date for ephemerides: {0}",
new Object[] {
date
});
}
model.setInterpolatedTime(date.durationFrom(startDate));
final double[] state = model.getInterpolatedState();
......
......@@ -156,3 +156,7 @@ file\ {0}\ is\ not\ a\ JPL\ ephemerides\ binary\ file = \
out\ of\ range\ date\ for\ {0}\ ephemerides:\ {1} = \
out of range date for {0} ephemerides: {1}
out\ of\ range\ date\ for\ ephemerides:\ {0} = \
out of range date for ephemerides: {0}
\ No newline at end of file
......@@ -154,3 +154,7 @@ inconsistent\ values\ of\ ephemerides\ chunks\ duration\ in\ JPL\ ephemerides\ f
out\ of\ range\ date\ for\ {0}\ ephemerides:\ {1} = \
date hors du domaine de validit\u00e9 des \u00e9ph\u00e9m\u00e9rides \u00ab {0} \u00bb : {1}
out\ of\ range\ date\ for\ ephemerides:\ {0} = \
date hors du domaine de validit\u00e9 des \u00e9ph\u00e9m\u00e9rides : {0}
\ No newline at end of file
......@@ -154,3 +154,7 @@ inconsistent\ values\ of\ ephemerides\ chunks\ duration\ in\ JPL\ ephemerides\ f
out\ of\ range\ date\ for\ {0}\ ephemerides:\ {1} = \
data fuori dell''intervallo di validit\u00e0 per le effemeridi {0}: {1}
out\ of\ range\ date\ for\ ephemerides:\ {0} = \
data fuori dell''intervallo di validit\u00e0 per le effemeridi: {0}
\ No newline at end of file
......@@ -22,6 +22,9 @@
<body>
<release version="4.0" date="TBD"
description="TBD">
<action dev="pascal" type="fix">
The ephemeris produced by numerical propagator now checks date validity in propagate method.
</action>
<action dev="luc" type="add" due-to="Francesco Coccoluto">
Added italian localization for error messages.
</action>
......
/* Copyright 2002-2008 CS Communication & Systèmes
* Licensed to CS Communication & Systèmes (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.cs.examples.frames;
import org.apache.commons.math.geometry.Rotation;
import org.apache.commons.math.geometry.Vector3D;
import org.orekit.errors.OrekitException;
import org.orekit.frames.Frame;
import org.orekit.frames.Transform;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.PVCoordinates;
import fr.cs.examples.Autoconfiguration;
/** Orekit tutorial for transform and frames support.
* <p>The aim of this tutorial is to manipulate transforms, frames and position and velocity coordinates.<p>
* @author Fabien Maussion
* @author Pascal Parraud
* @version $Revision$ $Date$
*/
public class Frames1 {
public static void main(String[] args) {
try {
// configure Orekit
Autoconfiguration.configureOrekit();
// initial point in frame 1 :
Frame frame1 = new Frame(Frame.getEME2000(), Transform.IDENTITY, "frame 1");
PVCoordinates pointP1 = new PVCoordinates(Vector3D.PLUS_I, Vector3D.PLUS_I);
System.out.println(" point P1 in frame 1 : " + pointP1);
// translation transform
// We want to translate frame1 to the right at the speed of 1 so that P1 is fixed in it.
Transform frame1toframe2 = new Transform(Vector3D.MINUS_I, Vector3D.MINUS_I);
// in vectorial transform convention, the translation is actually minusI !
Frame frame2 = new Frame(frame1, frame1toframe2, "frame 2");
PVCoordinates pointP2 = frame1.getTransformTo(frame2, new AbsoluteDate())
.transformPVCoordinates(pointP1);
System.out.println(" point P1 in frame 2 : " + pointP2);
// rotation transform
// We want to rotate frame1 of minus PI/2
// so that P1 has now for coordinates :
// position : (0,1,0) and velocity : (-2, 1, 0)
Rotation R = new Rotation(Vector3D.PLUS_K, Math.PI/2);
// in vectorial transform convention, the rotation is actually PLUS pi/2 !
Transform frame1toframe3 = new Transform(R, new Vector3D(0, 0, -2));
Frame frame3 = new Frame(frame1, frame1toframe3, "frame 3");
PVCoordinates pointP3 = frame1.getTransformTo(frame3, new AbsoluteDate())
.transformPVCoordinates(pointP1);
System.out.println(" point P1 in frame 3 : " + pointP3);
// combine translation and rotation
// The origin of the frame 2 should become the point P3 in frame 3.
// Let's check this result by combining two transforms in the frame tree :
PVCoordinates initialPoint = new PVCoordinates(new Vector3D(0,0,0), new Vector3D(0,0,0));
PVCoordinates finalPoint = frame2.getTransformTo(frame3, new AbsoluteDate())
.transformPVCoordinates(initialPoint);
System.out.println(" origin of frame 2 expressed in frame 3 : " + finalPoint);
} catch (OrekitException oe) {
System.err.println(oe.getMessage());
}
}
}
......@@ -17,6 +17,10 @@
package fr.cs.examples.frames;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import org.apache.commons.math.geometry.Rotation;
import org.apache.commons.math.geometry.Vector3D;
import org.orekit.errors.OrekitException;
......@@ -41,37 +45,74 @@ public class TransformAndFrames {
// configure Orekit
Autoconfiguration.configureOrekit();
final DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(Locale.US);
final DecimalFormat pv = new DecimalFormat("##0.00", symbols);
// initial point in frame 1 :
Frame frame1 = new Frame(Frame.getEME2000(), Transform.IDENTITY, "frame 1");
PVCoordinates pointP1 = new PVCoordinates(Vector3D.PLUS_I, Vector3D.PLUS_I);
System.out.println(" point P1 in frame 1 : ");
System.out.println(" position : "
+ pv.format(pointP1.getPosition().getX()) + " "
+ pv.format(pointP1.getPosition().getY()) + " "
+ pv.format(pointP1.getPosition().getZ()));
System.out.println(" velocity : "
+ pv.format(pointP1.getVelocity().getX()) + " "
+ pv.format(pointP1.getVelocity().getY()) + " "
+ pv.format(pointP1.getVelocity().getZ()));
// translation transform
/* We want to translate frame1 to the right at the speed of 1 so that P1 is fixed in it. */
// We want to translate frame1 to the right at the speed of 1 so that P1 is fixed in it.
Transform frame1toframe2 = new Transform(Vector3D.MINUS_I, Vector3D.MINUS_I);
// in vectorial transform convention, the translation is actually minusI !
Frame frame2 = new Frame(frame1, frame1toframe2, "frame 2");
PVCoordinates pointP2 = frame1.getTransformTo(frame2, new AbsoluteDate())
.transformPVCoordinates(pointP1);
System.out.println(" point P1 in frame 2 : " + pointP2);
System.out.println(" point P1 in frame 2 : ");
System.out.println(" position : "
+ pv.format(pointP2.getPosition().getX()) + " "
+ pv.format(pointP2.getPosition().getY()) + " "
+ pv.format(pointP2.getPosition().getZ()));
System.out.println(" velocity : "
+ pv.format(pointP2.getVelocity().getX()) + " "
+ pv.format(pointP2.getVelocity().getY()) + " "
+ pv.format(pointP2.getVelocity().getZ()));
// rotation transform
/* We want to rotate frame1 of minus PI/2 so that P1 has now for coordinates :
* position : (0,1,0) and velocity : (-2, 1, 0) */
// We want to rotate frame1 of minus PI/2
// so that P1 has now for coordinates :
// position : (0,1,0) and velocity : (-2, 1, 0)
Rotation R = new Rotation(Vector3D.PLUS_K, Math.PI/2);
// in vectorial transform convention, the rotation is actually PLUS pi/2 !
Transform frame1toframe3 = new Transform(R, new Vector3D(0, 0, -2));
Frame frame3 = new Frame(frame1, frame1toframe3, "frame 3");
PVCoordinates pointP3 = frame1.getTransformTo(frame3, new AbsoluteDate())
.transformPVCoordinates(pointP1);
System.out.println(" point P1 in frame 3 : " + pointP3);
System.out.println(" point P1 in frame 3 : ");
System.out.println(" position : "
+ pv.format(pointP3.getPosition().getX()) + " "
+ pv.format(pointP3.getPosition().getY()) + " "
+ pv.format(pointP3.getPosition().getZ()));
System.out.println(" velocity : "
+ pv.format(pointP3.getVelocity().getX()) + " "
+ pv.format(pointP3.getVelocity().getY()) + " "
+ pv.format(pointP3.getVelocity().getZ()));
// combine translation and rotation
/* The origin of the frame 2 should become the point P3 in frame 3.
* Let's check this result by combining two transforms in the frame tree : */
// The origin of the frame 2 should become the point P3 in frame 3.
// Let's check this result by combining two transforms in the frame tree :
PVCoordinates initialPoint = new PVCoordinates(new Vector3D(0,0,0), new Vector3D(0,0,0));
PVCoordinates finalPoint = frame2.getTransformTo(frame3, new AbsoluteDate())
.transformPVCoordinates(initialPoint);
System.out.println(" origin of frame 2 expressed in frame 3 : " + finalPoint);
System.out.println(" origin of frame 2 expressed in frame 3 : ");
System.out.println(" position : "
+ pv.format(finalPoint.getPosition().getX()) + " "
+ pv.format(finalPoint.getPosition().getY()) + " "
+ pv.format(finalPoint.getPosition().getZ()));
System.out.println(" velocity : "
+ pv.format(finalPoint.getVelocity().getX()) + " "
+ pv.format(finalPoint.getVelocity().getY()) + " "
+ pv.format(finalPoint.getVelocity().getZ()));
} catch (OrekitException oe) {
System.err.println(oe.getMessage());
......
......@@ -18,11 +18,13 @@
package fr.cs.examples.propagation;
import org.apache.commons.math.ode.FirstOrderIntegrator;
import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
import org.apache.commons.math.ode.nonstiff.GraggBulirschStoerIntegrator;
import org.orekit.errors.OrekitException;
import org.orekit.forces.ForceModel;
import org.orekit.forces.gravity.CunninghamAttractionModel;
import org.orekit.frames.Frame;
import org.orekit.orbits.EquinoctialOrbit;
import org.orekit.orbits.KeplerianOrbit;
import org.orekit.orbits.Orbit;
import org.orekit.propagation.BoundedPropagator;
......@@ -31,13 +33,14 @@ import org.orekit.propagation.numerical.NumericalPropagator;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScale;
import org.orekit.time.UTCScale;
import fr.cs.examples.Autoconfiguration;
/** The aim of this tutorial is to manipulate the Numerical propagator
* and the force models.
* @author Fabien Maussion
/** Orekit tutorial for ephemeris mode propagation.
* <p>This tutorial shows a basic usage of the ephemeris mode in conjunction with a numerical propagator.<p>
* @author Pascal Parraud
* @version $Revision$ $Date$
*/
public class EphemerisMode {
......@@ -51,74 +54,65 @@ public class EphemerisMode {
// configure Orekit
Autoconfiguration.configureOrekit();
// physical constants :
double mu = 3.9860064e+14; // gravitation coefficient
double ae = 6378136.460; // equatorial radius in meter
double c20 = -1.08262631303e-3; // J2 potential coefficent
Frame ITRF2005 = Frame.getITRF2005(); // terrestrial frame at an arbitrary date
// Initial state definition :
// parameters :
// Initial orbit parameters
double a = 24396159; // semi major axis in meters
double e = 0.72831215; // eccentricity
double i = Math.toRadians(7); // inclination
double omega = Math.toRadians(180); // perigee argument
double raan = Math.toRadians(261); // right ascencion of ascending node
double raan = Math.toRadians(261); // right ascension of ascending node
double lv = 0; // mean anomaly
double mass = 2500; // mass of the spacecraft in Kg
// date and frame
AbsoluteDate initialDate = new AbsoluteDate(new DateComponents(2004, 01, 01),
new TimeComponents(23, 30, 00.000),
UTCScale.getInstance());
// Inertial frame
Frame inertialFrame = Frame.getEME2000();
// OREKIT objects construction:
// Initial date in UTC time scale
TimeScale utc = UTCScale.getInstance();
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
// gravitation coefficient
double mu = 3.986004415e+14;
// Orbit construction as Keplerian
Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lv,
KeplerianOrbit.MEAN_ANOMALY,
inertialFrame, initialDate, mu);
SpacecraftState initialState = new SpacecraftState(initialOrbit, mass);
/* ***************** */
/* Extrapolation */
/* ***************** */
// Integrator
FirstOrderIntegrator integrator = new GraggBulirschStoerIntegrator(1, 1000, 0, 1.0e-8);
// adaptive step integrator with a minimum step of 1 and a maximum step of 1000, and a relative precision of 1.0e-8
// Numerical propagation with no perturbation (only keplerian movement)
// Using a very simple integrator with a fixed step: classical Runge-Kutta
double stepSize = 10.; // the step is ten seconds
FirstOrderIntegrator integrator = new ClassicalRungeKuttaIntegrator(stepSize);
NumericalPropagator propagator = new NumericalPropagator(integrator);
// Perturbing gravity field :
double[][] c = new double[3][1];
c[0][0] = 0.0;
c[2][0] = c20;
double[][] s = new double[3][1]; // potential coeffs arrays (only J2 is considered here)
ForceModel cunningham = new CunninghamAttractionModel(ITRF2005, ae, mu, c, s);
propagator.addForceModel(cunningham);
// propagation with storage of the results in an integrated ephemeris
AbsoluteDate finalDate = new AbsoluteDate(initialDate, 500);
propagator.setInitialState(initialState);
// Set the propagator to ephemeris mode
propagator.setEphemerisMode();
SpacecraftState finalState = propagator.propagate(finalDate);
// Initialize propagation
SpacecraftState initialState = new SpacecraftState(initialOrbit);
propagator.setInitialState(initialState);
// Propagation with storage of the results in an integrated ephemeris
SpacecraftState finalState = propagator.propagate(new AbsoluteDate(initialDate, 6000.));
BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
System.out.println(" Final state : " + finalState.getOrbit());
AbsoluteDate intermediateDate = new AbsoluteDate(initialDate, 214);
System.out.println(" Ephemeris defined from " + ephemeris.getMinDate() + " to " + ephemeris.getMaxDate());
AbsoluteDate intermediateDate = new AbsoluteDate(initialDate, 3000.);
SpacecraftState intermediateState = ephemeris.propagate(intermediateDate);
System.out.println(" intermediate state : " + intermediateState.getOrbit());
System.out.println(" date : " + intermediateState.getDate());
System.out.println(" " + intermediateState.getOrbit());
intermediateDate = new AbsoluteDate(initialDate, -214.);
intermediateState = ephemeris.propagate(intermediateDate);
System.out.println(" date : " + intermediateState.getDate());
System.out.println(" " + intermediateState.getOrbit());
intermediateDate = initialDate;
intermediateState = ephemeris.propagate(intermediateDate);
System.out.println(" date : " + intermediateState.getDate());
System.out.println(" " + intermediateState.getOrbit());
EquinoctialOrbit orbini = new EquinoctialOrbit(initialOrbit);
System.out.println(" " + orbini.toString());
} catch (OrekitException oe) {
System.err.println(oe.getMessage());
......
......@@ -107,12 +107,14 @@ public class MasterMode {
// Add force model to the propagator
propagator.addForceModel(cunningham);
// Set up operating mode as master mode for the propagator
propagator.setMasterMode(100, new TutorialStepHandler());
// Set up operating mode for the propagator as master mode
// with fixed step and specialized step handler
propagator.setMasterMode(60., new TutorialStepHandler());
// Extrapolate from the initial to the final date
SpacecraftState finalState = propagator.propagate(new AbsoluteDate(initialDate, 1000.));
System.out.println(" Final state : " + finalState.getOrbit());
SpacecraftState finalState = propagator.propagate(new AbsoluteDate(initialDate, 630.));
System.out.println(" Final date : " + finalState.getDate());
System.out.println(" Final state : " + finalState.getOrbit());
} catch (OrekitException oe) {
System.err.println(oe.getMessage());
......@@ -120,7 +122,7 @@ public class MasterMode {
}
/** Specialized step handler.
* <p>This class extends the step handler in order to print on the output stream at each step.<p>
* <p>This class extends the step handler in order to print on the output stream at the given step.<p>
* @author Pascal Parraud
*/
private static class TutorialStepHandler implements OrekitFixedStepHandler {
......@@ -133,8 +135,8 @@ public class MasterMode {
}
public void handleStep(SpacecraftState currentState, boolean isLast) {
System.out.println(" step time : " + currentState.getDate());
System.out.println(" step state : " + currentState.getOrbit());
System.out.println(" time : " + currentState.getDate());
System.out.println(" " + currentState.getOrbit());
if (isLast) {
System.out.println(" this was the last step ");
}
......
......@@ -17,28 +17,22 @@
package fr.cs.examples.propagation;
import org.apache.commons.math.ode.FirstOrderIntegrator;
import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
import org.orekit.errors.OrekitException;
import org.orekit.frames.Frame;
import org.orekit.orbits.KeplerianOrbit;
import org.orekit.orbits.Orbit;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.analytical.KeplerianPropagator;
import org.orekit.propagation.numerical.NumericalPropagator;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScale;
import org.orekit.time.UTCScale;
/** Orekit tutorial for various propagation methods.
* <p>The aim of this tutorial is to manipulate spacecraft states
* and to propagate them using different methods.<p>
* @author Fabien Maussion
/** Orekit tutorial for slave mode propagation.
* <p>This tutorial shows a basic usage of the slave mode in which the user drives all the propagation.<p>
* @author Pascal Parraud
* @version $Revision$ $Date$
*/
public class PropagationMethods {
public class SlaveMode {
/** Program entry point.
* @param args program arguments (unused here)
......@@ -46,62 +40,57 @@ public class PropagationMethods {
public static void main(String[] args) {
try {
// physical constants :
double mu = 3.9860064e+14; // gravitation coefficient
// Initial state definition :
// parameters :
// Initial orbit parameters
double a = 24396159; // semi major axis in meters
double e = 0.72831215; // eccentricity
double i = Math.toRadians(7); // inclination
double omega = Math.toRadians(180); // perigee argument
double raan = Math.toRadians(261); // right ascention of ascending node
double raan = Math.toRadians(261); // right ascension of ascending node
double lv = 0; // mean anomaly
// date and frame
AbsoluteDate initialDate = new AbsoluteDate(new DateComponents(2004, 01, 01),
new TimeComponents(23, 30, 00.000),
UTCScale.getInstance());
// Inertial frame
Frame inertialFrame = Frame.getEME2000();
// OREKIT objects construction:
// Initial date in UTC time scale
TimeScale utc = UTCScale.getInstance();
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
// gravitation coefficient
double mu = 3.9860064e+14;
// Orbit construction as Keplerian
Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lv,
KeplerianOrbit.MEAN_ANOMALY,
inertialFrame, initialDate, mu);
/* ***************** */
/* Extrapolation */
/* ***************** */
// Simple Keplerian extrapolation
// Simple extrapolation with Keplerian motion
KeplerianPropagator kepler = new KeplerianPropagator(initialOrbit);
double deltaT = 1000; // extrapolation length in seconds
AbsoluteDate finalDate = new AbsoluteDate(initialDate, deltaT);
SpacecraftState finalState = kepler.propagate(finalDate);
System.out.println(" Final parameters with deltaT = " + deltaT + " s : " +
finalState.getOrbit());
deltaT = -1000; // extrapolation length in seconds
finalDate = new AbsoluteDate(initialDate, deltaT);
finalState = kepler.propagate(finalDate);
System.out.println(" Final parameters with deltaT = " + deltaT + " s : " +
finalState.getOrbit());
// numerical propagation with no perturbation (only keplerian movement)
// we use a very simple integrator with a fixed step: classical Runge-Kutta
double stepSize = 1.; // the step is one second
FirstOrderIntegrator integrator = new ClassicalRungeKuttaIntegrator(stepSize);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setInitialState(new SpacecraftState(initialOrbit));
finalState = propagator.propagate(finalDate);
System.out.println(" Final parameters with deltaT = " + deltaT + " s : " +
finalState.getOrbit());
// Set the propagator to slave mode (could be omitted as it is the default mode)
kepler.setSlaveMode();
// Overall duration in seconds for extrapolation
double duration = 600.;
// Stop date
final AbsoluteDate finalDate = new AbsoluteDate(initialDate, duration, utc);
// Step duration in seconds
double stepT = 60.;
// Extrapolation loop
int cpt = 1;
AbsoluteDate extrapDate = initialDate;
while (extrapDate.compareTo(finalDate) <= 0) {
SpacecraftState currentState = kepler.propagate(extrapDate);
System.out.println("step " + cpt++);
System.out.println(" time : " + currentState.getDate());
System.out.println(" " + currentState.getOrbit());
extrapDate = new AbsoluteDate(extrapDate, stepT, utc);
}
} catch (OrekitException oe) {
System.err.println(oe.getMessage());
......
......@@ -26,6 +26,7 @@ import org.orekit.frames.Frame;
import org.orekit.frames.TopocentricFrame;
import org.orekit.orbits.KeplerianOrbit;
import org.orekit.orbits.Orbit;
import org.orekit.propagation.Propagator;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.analytical.KeplerianPropagator;
import org.orekit.propagation.events.ElevationDetector;
......@@ -62,7 +63,7 @@ public class VisibilityCheck {
Orbit initialOrbit = new KeplerianOrbit(pvCoordinates, inertialFrame, initialDate, mu);
// Propagator : consider a simple keplerian motion (could be more elaborate)
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
Propagator kepler = new KeplerianPropagator(initialOrbit);
// Earth and frame
double ae = 6378137.0; // equatorial radius in meter
......@@ -83,10 +84,10 @@ public class VisibilityCheck {
final EventDetector sta1Visi = new VisibilityDetector(maxcheck, elevation, sta1Frame);
// Add event to be detected
propagator.addEventDetector(sta1Visi);
kepler.addEventDetector(sta1Visi);
// Extrapolate from the initial date to the first raising or until the fixed duration
SpacecraftState finalState = propagator.propagate(new AbsoluteDate(initialDate, 1500.));
SpacecraftState finalState = kepler.propagate(new AbsoluteDate(initialDate, 1500.));
System.out.println(" Final state : " + finalState.getDate());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment