Skip to content

Commit

Permalink
The methods renewed more order implemented also the magnetic field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pouyan Azari committed Dec 3, 2015
1 parent 2f5e734 commit dcf768b
Show file tree
Hide file tree
Showing 8 changed files with 1,097 additions and 16 deletions.
2 changes: 1 addition & 1 deletion OrekitJava/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<classpathentry kind="src" path="lib/orekit-7.0/src/test/resources"/>
<classpathentry kind="src" path="lib/orekit-7.0/src/main/java"/>
<classpathentry kind="src" path="lib/orekit-7.0/src/tutorials/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="lib/commons-math3-3.4.1-javadoc.jar"/>
<classpathentry kind="lib" path="lib/commons-math3-3.4.1.jar"/>
<classpathentry kind="lib" path="lib/commons-net-3.3.jar"/>
Expand Down
6 changes: 3 additions & 3 deletions OrekitJava/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=1.7
721 changes: 721 additions & 0 deletions OrekitJava/pathdef.m

Large diffs are not rendered by default.

106 changes: 97 additions & 9 deletions OrekitJava/test/de/netsat/orekit/matlab/MagenticFieldTest.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
package de.netsat.orekit.matlab;

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeIntegrator;
import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator;
import org.orekit.attitudes.Attitude;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.bodies.OneAxisEllipsoid;
import org.orekit.errors.OrekitException;
import org.orekit.frames.Frame;
import org.orekit.frames.FramesFactory;
import org.orekit.models.earth.GeoMagneticElements;
import org.orekit.models.earth.GeoMagneticField;
import org.orekit.orbits.KeplerianOrbit;
import org.orekit.orbits.OrbitType;

import de.netsat.orekit.NetSatConfiguration;
import de.netsat.orekit.matlab.loadScripts;
import de.netsat.orekit.matlab.MatlabPushHandler;

import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.numerical.NumericalPropagator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.IERSConventions;
import org.orekit.utils.PVCoordinates;
import org.orekit.utils.TimeStampedAngularCoordinates;

import matlabcontrol.MatlabConnectionException;
import matlabcontrol.MatlabInvocationException;
import matlabcontrol.MatlabProxy;

public class MagenticFieldTest {

/**
*
* @param mi
* @return
* @throws MatlabInvocationException
* @throws OrekitException
*/
public static SpacecraftState runNumericalPropagatorlocal(MatlabInterface mi)
throws MatlabInvocationException, OrekitException

{
String[] options = { "velocity" };
NetSatConfiguration.init();
int sat_nr = 1;
Object[] returningObject;
returningObject = mi.returningEval("setNumericalPropagatorSettings()", 5);
Expand All @@ -28,27 +53,90 @@ public static SpacecraftState runNumericalPropagatorlocal(MatlabInterface mi)
double maxstep = ((double[]) returningObject[2])[0];
double duration = ((double[]) returningObject[3])[0];
double outputStepSize = ((double[]) returningObject[4])[0];

final OrbitType propagationType = OrbitType.KEPLERIAN;
final double[][] tolerances = NumericalPropagator.tolerances(positionTolerance, keplerOrbit, propagationType);
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxstep, tolerances[0],
tolerances[1]);
NumericalPropagator numericPropagator = new NumericalPropagator(integrator);
numericPropagator.setOrbitType(propagationType);
SpacecraftState finalState = numericPropagator.propagate(keplerOrbit.getDate().shiftedBy(duration));

return finalState;


SpacecraftState initialState = new SpacecraftState(keplerOrbit,
new Attitude(FramesFactory.getEME2000(),
new TimeStampedAngularCoordinates(keplerOrbit.getDate(),
new PVCoordinates(new Vector3D(10, 10), new Vector3D(1, 2)),
new PVCoordinates(new Vector3D(15, 3), new Vector3D(1, 2)))),
1.0);

NumericalPropagator numericPropagator = new NumericalPropagator(integrator);
numericPropagator.setInitialState(initialState);
// new matlabPushStepHandler(mi);
numericPropagator.setMasterMode(outputStepSize, new MatlabPushHandler(mi, options));
SpacecraftState finalState = numericPropagator.propagate(keplerOrbit.getDate().shiftedBy(duration));

return finalState;

}

/**
* Set the variable in matltab (the variable should be the type double or
* could be casted to double.
*
* @param mi
* @param name
* @param value
* @throws MatlabInvocationException
*/
public void setVariableInMatlab(MatlabInterface mi, String name, double value) throws MatlabInvocationException {

mi.getProxy().setVariable(name, value);
}

/**
* Converts the ECI Coordinates (R;V) to Latitude, Longitude, Altitude
* (L;L;A). The point it uses the ITRF (Inertial Terrestrial reference frame
* for the frame.
*
* @param ECICoordinates
* @param oae
* @param date
* @return
* @throws OrekitException
*/
public static GeodeticPoint getLLA(Vector3D ECICoordinates, OneAxisEllipsoid oae, AbsoluteDate date)
throws OrekitException {
return oae.transform(ECICoordinates, FramesFactory.getITRF(IERSConventions.IERS_2010, true), date);
}

/**
* Calculates the magnetic field in a given ECI points.
*
* @param ECICoordinates
* @param oae
* @param date
* @param model
* @return
* @throws OrekitException
*/
public static Vector3D calculateMagenticField(Vector3D ECICoordinates, OneAxisEllipsoid oae, AbsoluteDate date,
GeoMagneticField model) throws OrekitException {
GeodeticPoint geop = getLLA(ECICoordinates, oae, date);
// The altitude which is delivered by the getLLA function is in m it
// should be converted to KM.
double altitude = geop.getAltitude() / 1000;
double latitude = geop.getLatitude();
double longtitude = geop.getLongitude();
GeoMagneticElements geome = model.calculateField(Math.toDegrees(latitude), Math.toDegrees(longtitude),
altitude);
return geome.getFieldVector();
}

public static void main(String[] args)
throws OrekitException, MatlabConnectionException, MatlabInvocationException {
//Object[] obj = null;
// Object[] obj = null;
MatlabInterface mi;
mi = new MatlabInterface(MatlabInterface.MATLAB_PATH, null);
//obj = runNumericalPropagatorlocal(mi);
SpacecraftState obj = runNumericalPropagatorlocal(mi);

//System.out.println(((double[]) obj[1])[0]);
// System.out.println(((double[]) obj[1])[0]);
}

}
2 changes: 1 addition & 1 deletion OrekitJava/test/de/netsat/orekit/matlab/Maneuvers.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public SpacecraftState resetState(final ApsideDetector detector, final Spacecraf

}

private static class matlabPushStepHandler implements OrekitFixedStepHandler {
public static class matlabPushStepHandler implements OrekitFixedStepHandler {
MatlabInterface mi;
Vector3D[] position_history;

Expand Down
Loading

0 comments on commit dcf768b

Please sign in to comment.