Skip to content

Commit e45ae76

Browse files
committed
ENH: add time_overshoot option to rocketpy.stochastic_flight
Since the new StochasticAirBrake class is defined, we need the 'time_overshoot' option in the Flight class to ensure that the time step defined in the simulation is the controller sampling rate. The MonteCarlo class has had to be modified as well to include this option.
1 parent f0ebdda commit e45ae76

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

rocketpy/simulation/monte_carlo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ def __run_single_simulation(self):
458458
heading=self.flight._randomize_heading(),
459459
initial_solution=self.flight.initial_solution,
460460
terminate_on_apogee=self.flight.terminate_on_apogee,
461+
time_overshoot=self.flight.time_overshoot,
461462
)
462463

463464
def __evaluate_flight_inputs(self, sim_idx):

rocketpy/stochastic/stochastic_flight.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class StochasticFlight(StochasticModel):
2929
terminate_on_apogee : bool
3030
Whether or not the flight should terminate on apogee. This attribute
3131
can not be randomized.
32+
time_overshoot : bool
33+
If False, the simulation will run at the time step defined by the controller
34+
sampling rate. Be aware that this will make the simulation run much slower.
3235
"""
3336

3437
def __init__(
@@ -39,6 +42,7 @@ def __init__(
3942
heading=None,
4043
initial_solution=None,
4144
terminate_on_apogee=None,
45+
time_overshoot=None,
4246
):
4347
"""Initializes the Stochastic Flight class.
4448
@@ -63,11 +67,18 @@ def __init__(
6367
terminate_on_apogee : bool, optional
6468
Whether or not the flight should terminate on apogee. This attribute
6569
can not be randomized.
70+
time_overshoot : bool
71+
If False, the simulation will run at the time step defined by the controller
72+
sampling rate. Be aware that this will make the simulation run much slower.
6673
"""
6774
if terminate_on_apogee is not None:
6875
assert isinstance(terminate_on_apogee, bool), (
6976
"`terminate_on_apogee` must be a boolean"
7077
)
78+
if time_overshoot is not None:
79+
assert isinstance(time_overshoot, bool), (
80+
"`time_overshoot` must be a boolean"
81+
)
7182
super().__init__(
7283
flight,
7384
rail_length=rail_length,
@@ -77,6 +88,7 @@ def __init__(
7788

7889
self.initial_solution = initial_solution
7990
self.terminate_on_apogee = terminate_on_apogee
91+
self.time_overshoot = time_overshoot
8092

8193
def _validate_initial_solution(self, initial_solution):
8294
if initial_solution is not None:
@@ -128,4 +140,5 @@ def create_object(self):
128140
heading=generated_dict["heading"],
129141
initial_solution=self.initial_solution,
130142
terminate_on_apogee=self.terminate_on_apogee,
143+
time_overshoot=self.time_overshoot,
131144
)

0 commit comments

Comments
 (0)