Propagation loop from apogee to perigee and so on

Hi all,

I am new to orekit and as a basic start I want to propagate a spacecraft from perigee to apogee over and over again.

Later I want to extract the ephemeris.

I do the following (orekit in Matlab), only showing the relevant parts here:

Setup the event triggers:

trigger_aps = ApsideDetector(initialOrbit);
trigger_apo = trigger_aps.withHandler(StopOnDecreasing); % change to stop at apogee
trigger_peri = trigger_aps.withHandler(StopOnIncreasing); % change to stop at perigee

The loop, I want 5 time prop to apo and to peri

for i=1:5
    % prop to apo
    propagator.addEventDetector(trigger_apo);
    initialState = propagator.propagate(initialState.getDate().shiftedBy(86400*2));
    propagator.clearEventsDetectors;
    % prop to peri
    propagator.addEventDetector(trigger_peri);
    initialState = propagator.propagate(initialState.getDate().shiftedBy(86400*2));
    propagator.clearEventsDetectors;
end

Later I retrieve the ephemeris from the propagator:
ephemeris = generator.getGeneratedEphemeris();

Somehow I dont end up with what I am looking for.
If I only prop to apo with the event and get the eph here, all looks good.
However the step of removing the apo event, adding the peri event and continue the prop does not. Do I need to update/set the propagation state after the prop to apo manually or sth. In order to have the propagator continue the prop from apo?

Generally I am asking myself how such a “sequential” propagation is the best to handle here. I want to use the “event” triggers capability properly instead of looping timewise. But for this I would need a dynamic way of setting/unsetting events or get the understanding how to access the “EventHandler” when it calls the “eventOccured” method in order to customize what to do when an event occurs.

I am sorry for this confusing question, I am a orekit noob still…

Cheers, Alex

Hi @afu and welcome to the Orekit forum !

By default, the propagator sets its initial state to the final state after propagating so this should not be the issue.

Considering your whole post, i think it could be interesting to understand the point of doing it sequentially. Could you further detail your need ?

Cheers,
Vincent

Dear Vincent, thank you!

good to hear that the prop updates the state after the propagation.
However where I see the issue is when I do try to retrieve the ephemeris after the two propagations:

(another more simple example, of two propagation sequences):

    initialState1 = propagator.propagate(initialState.getDate(),initialState.getDate().shiftedBy(86400));
    initialState2 = propagator.propagate(initialState1.getDate(),initialState1.getDate().shiftedBy(86400));

So I propagate the spacecraft for 1 day, afterwards again for 1 day

however if I e.g. do the following, it complains that the ephemeris is out of range for the requested time, and tells me it starts at “day 2” so after 86400s to 2*86400s.
But somehow the ephemeris is not stored/retrievable for the first propagation sequence.
How do I cope with that? So how do I get a continuous ephemeris generated even though I propagate sequentially?

pos = ephemeris.getPosition(initialDate.shiftedBy(1000),inertialFrame);

Cheers, Alex

I am not sure I understand what you want to do.
If you use a numerical propagator, set up ephemeris generation and then performs several propagations, then the stored ephemeris is overridden each time you start a new propagation (the internal storing step handler clears its ephemeris when its init method is called).

If you want to get a complete ephemeris covering the full operation, I would propose two different solutions:

  • propagate only once, counting apogees and perigees and then stopping after you have reached the number you want
  • propagate several times, but retrieve the ephemeris at the end of each individual propagations and later use AggregateBoundedPropagator to combine them

I think the former solution is simpler and very slightly more efficient.

2 Likes

Thank you!

For this test I chose the AggregateBoundedPropagator.

It works. A related question is as follows:

  1. Prop to apogee
  2. Prop to perigee
  3. Prop till apogee and perform impulsive maneuver
  4. Prop to perigee

This is how I implemented this sequence:

trigger_aps = ApsideDetector(initialOrbit);
trigger_apo = trigger_aps.withHandler(StopOnDecreasing); % chnage to stop at apogee
% switch to stop at perigee
trigger_peri = trigger_aps.withHandler(StopOnIncreasing); % chnage to stop at perigee

% create imp man
maneuver = ImpulseManeuver(trigger_apo,Vector3D(200, 0.0, 0.0),350.0);


logger = EventsLogger();

eph_col = java.util.ArrayList();

% loop from peri to apo
state = initialState;
for i=1:1
    % prop to apo
    propagator.addEventDetector(logger.monitorDetector(trigger_apo))
    propagator.addEventDetector(trigger_apo);
    state = propagator.propagate(state.getDate(),state.getDate().shiftedBy(86400));
    ephemeris = generator.getGeneratedEphemeris();
    eph_col.add(ephemeris);
    propagator.clearEventsDetectors

    % prop to peri
   propagator.addEventDetector(logger.monitorDetector(trigger_peri))
   propagator.addEventDetector(trigger_peri);
   state = propagator.propagate(state.getDate(),state.getDate().shiftedBy(86400));
   ephemeris = generator.getGeneratedEphemeris();
   eph_col.add(ephemeris);
    propagator.clearEventsDetectors;
 
    % imp maneuver at apo 
     propagator.addEventDetector(logger.monitorDetector(maneuver))
     propagator.addEventDetector(maneuver);
     state = propagator.propagate(state.getDate(),state.getDate().shiftedBy(86400));
     ephemeris = generator.getGeneratedEphemeris();
     eph_col.add(ephemeris);
     propagator.clearEventsDetectors;  
     
      % prop to peri
      propagator.addEventDetector(logger.monitorDetector(trigger_peri))
      propagator.addEventDetector(trigger_peri);
      state = propagator.propagate(state.getDate(),state.getDate().shiftedBy(86400));
      ephemeris = generator.getGeneratedEphemeris();
      eph_col.add(ephemeris);
      propagator.clearEventsDetectors
end


% combine ephemeris of each sequence into one
all = AggregateBoundedPropagator(eph_col);

% get events logged
events = logger.getLoggedEvents;

Problem is: the event “maneuver” obviously is triggered on reaching the apogee. So it does not stop and removes the event from the list, it just continues.
Also changing the eventhandler to “StopOnEvent” does not help.

How do I bring it in order to stop the propagation after the “maneuver” event was applied?

Cheers

ImpulseManeuver uses only one event detector, because, well, it is impulsive.
You could either switch to continous maneuvers which has both a start and stop detector, or you could just add another detector that triggers just after the apogee, by wrapping a regular ApsideDetector within an EventShifter with a shift set to a tiny amount like one picosecond or one femtosecond to be sure it triggers after the maneuver.

Hi there,

If you want to stop propagation when the maneuver is applied, I suggest applying it somewhat by hand. Basically you use your event (here apside) detector with StopOnEvent as handler. You retrieve the SpacecraftState from propagate, let’s call it state.
Then simply retrieve the output of this call:
impulseManeuver.getHandler().resetState(state, impulseManeuver).
where you’ve built impulseManeuver with an arbitrary trigger since you’re not using it basically.

Cheers,
Romain.