Commit 7ce8b2d3 authored by Bryan's avatar Bryan

Commit for issue #401

parent bdf73944
......@@ -97,4 +97,7 @@
</module>
<module name="FileTabCharacter"/>
<module name="NewlineAtEndOfFile"/>
</module>
<module name="Header">
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
</module>
\ No newline at end of file
......@@ -576,6 +576,23 @@
<artifactId>maven-site-plugin</artifactId>
<version>${orekit.maven-site-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugins</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<enableRulesSummary>false</enableRulesSummary>
<headerLocation>${basedir}/license-header.txt</headerLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
......
......@@ -732,21 +732,21 @@ public abstract class AbstractIntegratedPropagator extends AbstractPropagator {
public int getDimension() {
return dimension;
}
@Override
public void init(final double t0, final double[] primary0,
final double[] secondary0, final double finalTime) {
final double[] secondary0, final double finalTime) {
try {
// update space dynamics view
// use only ODE elements
SpacecraftState initialState = stateMapper.mapArrayToState(t0, primary0, null, true);
initialState = updateAdditionalStates(initialState);
final AbsoluteDate target = stateMapper.mapDoubleToDate(finalTime);
equations.init(initialState, target);
equations.init(initialState, target);
} catch (OrekitException oe) {
throw new OrekitExceptionWrapper(oe);
}
}
/** {@inheritDoc} */
......
......@@ -65,7 +65,7 @@ public interface AdditionalEquations {
* @return name of the additional state
*/
String getName();
/**
* Initialize the equations at the start of propagation. This method will be
* called before any calls to {@link #computeDerivatives(SpacecraftState)}.
......
package org.orekit.propagation.integration;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator;
import org.hipparchus.ode.nonstiff.DormandPrince853Integrator;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.orekit.Utils;
import org.orekit.errors.OrekitException;
import org.orekit.forces.gravity.potential.GravityFieldFactory;
import org.orekit.forces.gravity.potential.SHMFormatReader;
import org.orekit.frames.FramesFactory;
import org.orekit.orbits.EquinoctialOrbit;
import org.orekit.orbits.Orbit;
import org.orekit.orbits.OrbitType;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.numerical.NumericalPropagator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.PVCoordinates;
public class InitAdditionalEquationsTest {
private NumericalPropagator propagator;
private AbsoluteDate initDate;
private double mu;
private SpacecraftState initialState;
/** Test for issue #401 */
@Test
public void testInitAdd() throws OrekitException {
// setup
// mutable holders
SpacecraftState[] actualState = new SpacecraftState[1];
AbsoluteDate[] actualDate = new AbsoluteDate[1];
InitCheckerEquations checker = new InitCheckerEquations() {
@Override
public void init(SpacecraftState initialState, AbsoluteDate target) {
actualState[0] = initialState;
actualDate[0] = target;
}
};
checker.initCheckerEquations();
Assert.assertFalse(checker.wasCalled());
AbsoluteDate target = initDate.shiftedBy(60);
// action
propagator.propagate(target);
// verify
Assert.assertTrue(checker.wasCalled());
}
@Before
public void setUp() throws OrekitException {
Utils.setDataRoot("regular-data:potential/shm-format");
GravityFieldFactory.addPotentialCoefficientsReader(new SHMFormatReader("^eigen_cg03c_coef$", false));
mu = GravityFieldFactory.getUnnormalizedProvider(0, 0).getMu();
final Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
final Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
initDate = AbsoluteDate.J2000_EPOCH;
final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity),
FramesFactory.getEME2000(), initDate, mu);
initialState = new SpacecraftState(orbit);
double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit, OrbitType.EQUINOCTIAL);
AdaptiveStepsizeIntegrator integrator =
new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(60);
propagator = new NumericalPropagator(integrator);
propagator.setInitialState(initialState);
}
@After
public void tearDown() {
initDate = null;
initialState = null;
propagator = null;
}
private static class InitCheckerEquations implements AdditionalEquations {
private boolean called;
@Override
public String getName() {
return null;
}
@Override
public double[] computeDerivatives(SpacecraftState s, double[] pDot)
throws OrekitException {
return null;
}
public void initCheckerEquations() {
boolean checker = false;
}
public void init() {
boolean checker = true;
}
public boolean wasCalled() {
return called;
}
}
}
......@@ -129,37 +129,6 @@ public class NumericalPropagatorTest {
Assert.assertThat(actualState[0].getPVCoordinates(),
OrekitMatchers.pvIs(initialState.getPVCoordinates()));
}
/** Test for issue #401 */
@Test
public void testInitAdd() throws OrekitException {
// setup
// mutable holders
SpacecraftState[] actualState = new SpacecraftState[1];
AbsoluteDate[] actualDate = new AbsoluteDate[1];
InitCheckerEquations checker = new InitCheckerEquations() {
@Override
public void init(SpacecraftState initialState, AbsoluteDate target) {
actualState[0] = initialState;
actualDate[0] = target;
}
};
checker.initCheckerEquations();
Assert.assertFalse(checker.wasCalled());
// action
AbsoluteDate target = initDate.shiftedBy(60);
SpacecraftState finalState = propagator.propagate(target);
// verify
if(finalState.getOrbit() != initialState.getOrbit())
checker.init();
Assert.assertTrue(checker.wasCalled());
}
@Test
public void testEphemerisModeWithHandler() throws OrekitException {
......@@ -1558,35 +1527,6 @@ public class NumericalPropagatorTest {
}
}
private static class InitCheckerEquations implements AdditionalEquations {
private boolean called;
@Override
public String getName() {
return null;
}
@Override
public double[] computeDerivatives(SpacecraftState s, double[] pDot)
throws OrekitException {
return null;
}
public void initCheckerEquations() {
called = false;
}
public void init() {
called = true;
}
public boolean wasCalled() {
return called;
}
}
}
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