NumericalPropagationWithUsedDV 4.4 : Différence entre versions
De Wiki
(Page créée avec « <syntaxhighlight lang="java"> public class NumericalPropagationWithUsedDV { public static void main(String[] args) throws PatriusException { Locale.s... ») |
|||
(Une révision intermédiaire par le même utilisateur non affichée) | |||
Ligne 21 : | Ligne 21 : | ||
// Initial orbit | // Initial orbit | ||
final double sma = 7200.e+3; | final double sma = 7200.e+3; | ||
− | final double ecc = 0. | + | final double ecc = 0.; |
final double inc = FastMath.toRadians(98.); | final double inc = FastMath.toRadians(98.); | ||
final double pa = FastMath.toRadians(0.); | final double pa = FastMath.toRadians(0.); | ||
Ligne 31 : | Ligne 31 : | ||
final KeplerianOrbit iniOrbit = new KeplerianOrbit(par, GCRF, date0); | final KeplerianOrbit iniOrbit = new KeplerianOrbit(par, GCRF, date0); | ||
− | |||
// Creating a mass model (see also specific example) | // Creating a mass model (see also specific example) | ||
final AssemblyBuilder builder = new AssemblyBuilder(); | final AssemblyBuilder builder = new AssemblyBuilder(); | ||
Ligne 59 : | Ligne 58 : | ||
// We create a spacecratftstate | // We create a spacecratftstate | ||
final SpacecraftState iniState = new SpacecraftState(iniOrbit, mm); | final SpacecraftState iniState = new SpacecraftState(iniOrbit, mm); | ||
− | |||
// Initialization of the Runge Kutta integrator with a 2 s step | // Initialization of the Runge Kutta integrator with a 2 s step | ||
Ligne 71 : | Ligne 69 : | ||
// Forcing integration using cartesian equations | // Forcing integration using cartesian equations | ||
propagator.setOrbitType(OrbitType.CARTESIAN); | propagator.setOrbitType(OrbitType.CARTESIAN); | ||
− | |||
− | |||
final ArrayList<DateDetector> listOfEvents = new ArrayList<DateDetector>(); | final ArrayList<DateDetector> listOfEvents = new ArrayList<DateDetector>(); | ||
Ligne 80 : | Ligne 76 : | ||
listOfEvents.add(eventImp); | listOfEvents.add(eventImp); | ||
// Creation of the impulsive maneuver | // Creation of the impulsive maneuver | ||
− | final Vector3D deltaV = new Vector3D( | + | final double dv = 20.; |
+ | final Vector3D deltaV = new Vector3D(dv, 0., 0.); | ||
final ImpulseManeuver imp = new ImpulseManeuver(eventImp, deltaV, prop, mm, tank, LOFType.TNW); | final ImpulseManeuver imp = new ImpulseManeuver(eventImp, deltaV, prop, mm, tank, LOFType.TNW); | ||
// Duration of the maneuver to reach the initial semi major axis | // Duration of the maneuver to reach the initial semi major axis | ||
− | final double duration = | + | final double duration = 49.4933; |
+ | System.out.println(duration); | ||
// Creation of the continuous thrust maneuver | // Creation of the continuous thrust maneuver | ||
− | final AbsoluteDate startDate = date0.shiftedBy | + | final AbsoluteDate startDate = date0.shiftedBy(iniOrbit.getKeplerianPeriod()-0.5*duration); |
final DateDetector eventStart = new DateDetector(startDate); | final DateDetector eventStart = new DateDetector(startDate); | ||
final DateDetector eventEnd = new DateDetector(startDate.shiftedBy(duration)); | final DateDetector eventEnd = new DateDetector(startDate.shiftedBy(duration)); | ||
Ligne 108 : | Ligne 106 : | ||
propagator.setAttitudeProvider(attitudeLaw); | propagator.setAttitudeProvider(attitudeLaw); | ||
− | |||
− | |||
// Dt to get information just before/after an event | // Dt to get information just before/after an event | ||
final double dt = 1.e-6; | final double dt = 1.e-6; | ||
Ligne 128 : | Ligne 124 : | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
Ligne 143 : | Ligne 133 : | ||
System.out.println(" Ergols Mass = "+sc.getMass("TANK")+" kg"); | System.out.println(" Ergols Mass = "+sc.getMass("TANK")+" kg"); | ||
System.out.println(" Semi major axis = "+sc.getA()/1000.+" km"); | System.out.println(" Semi major axis = "+sc.getA()/1000.+" km"); | ||
+ | System.out.println(" Eccentricity = "+sc.getE()); | ||
} | } | ||
− | + | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version actuelle en date du 4 octobre 2019 à 14:32
public class NumericalPropagationWithUsedDV { public static void main(String[] args) throws PatriusException { Locale.setDefault(Locale.US); // Patrius Dataset initialization (needed for example to get the UTC time) PatriusDataset.addResourcesFromPatriusDataset() ; // Recovery of the UTC time scale using a "factory" (not to duplicate such unique object) final TimeScale TUC = TimeScalesFactory.getUTC(); // Date of the orbit given in UTC time scale) final AbsoluteDate date0 = new AbsoluteDate("2010-01-01T12:00:00.000", TUC); // Getting the frame with wich will defined the orbit parameters // As for time scale, we will use also a "factory". final Frame GCRF = FramesFactory.getGCRF(); // Initial orbit final double sma = 7200.e+3; final double ecc = 0.; final double inc = FastMath.toRadians(98.); final double pa = FastMath.toRadians(0.); final double raan = FastMath.toRadians(0.); final double anm = FastMath.toRadians(0.); final double MU = Constants.WGS84_EARTH_MU; final KeplerianParameters par = new KeplerianParameters(sma, ecc, inc, pa, raan, anm, PositionAngle.MEAN, MU); final KeplerianOrbit iniOrbit = new KeplerianOrbit(par, GCRF, date0); // Creating a mass model (see also specific example) final AssemblyBuilder builder = new AssemblyBuilder(); // Main part final double iniMass = 900.; builder.addMainPart("MAIN"); builder.addProperty(new MassProperty(iniMass), "MAIN"); // Tank part (ergols mass) final double ergolsMass = 100.; final TankProperty tank = new TankProperty(ergolsMass); builder.addPart("TANK", "MAIN", Transform.IDENTITY); builder.addProperty(tank, "TANK"); // Engine part final double isp = 300.; final double thrust = 400.; final PropulsiveProperty prop = new PropulsiveProperty(thrust, isp); // au lieu de new PropulsiveProperty("PROP", thrust, isp); builder.addPart("PROP", "MAIN", Transform.IDENTITY); builder.addProperty(prop, "PROP"); final Assembly assembly = builder.returnAssembly(); final MassProvider mm = new MassModel(assembly); // We create a spacecratftstate final SpacecraftState iniState = new SpacecraftState(iniOrbit, mm); // Initialization of the Runge Kutta integrator with a 2 s step final double pasRk = 2.; final FirstOrderIntegrator integrator = new ClassicalRungeKuttaIntegrator(pasRk); // Initialization of the propagator final NumericalPropagator propagator = new NumericalPropagator(integrator); propagator.resetInitialState(iniState); // Forcing integration using cartesian equations propagator.setOrbitType(OrbitType.CARTESIAN); final ArrayList<DateDetector> listOfEvents = new ArrayList<DateDetector>(); // Event corresponding to the criteria to trigger the impulsive maneuver final DateDetector eventImp = new DateDetector(date0.shiftedBy(10.)); listOfEvents.add(eventImp); // Creation of the impulsive maneuver final double dv = 20.; final Vector3D deltaV = new Vector3D(dv, 0., 0.); final ImpulseManeuver imp = new ImpulseManeuver(eventImp, deltaV, prop, mm, tank, LOFType.TNW); // Duration of the maneuver to reach the initial semi major axis final double duration = 49.4933; System.out.println(duration); // Creation of the continuous thrust maneuver final AbsoluteDate startDate = date0.shiftedBy(iniOrbit.getKeplerianPeriod()-0.5*duration); final DateDetector eventStart = new DateDetector(startDate); final DateDetector eventEnd = new DateDetector(startDate.shiftedBy(duration)); listOfEvents.add(eventStart); listOfEvents.add(eventEnd); final Vector3D direction = new Vector3D(-1., 0., 0.); final ContinuousThrustManeuver man = new ContinuousThrustManeuver(eventStart, eventEnd, prop, direction, mm, tank); // Creation of the sequence of maneuver ManeuversSequence seq = new ManeuversSequence(0., 0.); seq.add(imp); seq.add(man); // Adding the maneuver sequence to the propagator seq.applyTo(propagator); // Adding additional state propagator.setMassProviderEquation(mm); // Adding an attitude law (or attitude sequence : mandatory) final AttitudeLaw attitudeLaw = new LofOffset(LOFType.TNW, RotationOrder.ZYX, 0., 0., 0.); propagator.setAttitudeProvider(attitudeLaw); // Dt to get information just before/after an event final double dt = 1.e-6; for (int i = 0; i < listOfEvents.size(); i++) { System.out.println("\nEVENT #"+i); System.out.println("Before ..."); final AbsoluteDate dateBefore = listOfEvents.get(i).getDate().shiftedBy(-dt); final SpacecraftState finalStateBefore = propagator.propagate(dateBefore); printResults(dateBefore.toString(TUC), finalStateBefore, imp, man); System.out.println("After ..."); final AbsoluteDate dateAfter = listOfEvents.get(i).getDate().shiftedBy(dt); final SpacecraftState finalStateAfter = propagator.propagate(dateAfter); printResults(dateAfter.toString(TUC), finalStateAfter, imp, man); } } private static void printResults ( final String sdate, final SpacecraftState sc, final ImpulseManeuver imp, final ContinuousThrustManeuver man ) throws PatriusException { System.out.println(" Date = "+sdate); System.out.println(" Impulsive Maneuver = "+imp.getUsedDV()+" m/s"); System.out.println(" Continuous Maneuver = "+man.getUsedDV()+" m/s"); System.out.println(" Ergols Mass = "+sc.getMass("TANK")+" kg"); System.out.println(" Semi major axis = "+sc.getA()/1000.+" km"); System.out.println(" Eccentricity = "+sc.getE()); } }