@@ -32,6 +32,9 @@ class StochasticFlight(StochasticModel):
3232 time_overshoot : bool
3333 If False, the simulation will run at the time step defined by the controller
3434 sampling rate. Be aware that this will make the simulation run much slower.
35+ max_time : int, float
36+ The maximum time of the flight simulation. If the flight simulation
37+ reaches this time, it will terminate. This attribute can not be randomized.
3538 """
3639
3740 def __init__ (
@@ -43,6 +46,7 @@ def __init__(
4346 initial_solution = None ,
4447 terminate_on_apogee = None ,
4548 time_overshoot = None ,
49+ max_time = None ,
4650 ):
4751 """Initializes the Stochastic Flight class.
4852
@@ -70,6 +74,9 @@ def __init__(
7074 time_overshoot : bool
7175 If False, the simulation will run at the time step defined by the controller
7276 sampling rate. Be aware that this will make the simulation run much slower.
77+ max_time : int, float
78+ The maximum time of the flight simulation. If the flight simulation
79+ reaches this time, it will terminate. This attribute can not be randomized.
7380 """
7481 if terminate_on_apogee is not None :
7582 assert isinstance (terminate_on_apogee , bool ), (
@@ -78,6 +85,9 @@ def __init__(
7885 if time_overshoot is not None :
7986 if not isinstance (time_overshoot , bool ):
8087 raise TypeError ("`time_overshoot` must be a boolean" )
88+ if max_time is not None :
89+ if not isinstance (max_time , (int , float )):
90+ raise TypeError ("`max_time` must be a number" )
8191 super ().__init__ (
8292 flight ,
8393 rail_length = rail_length ,
@@ -87,6 +97,10 @@ def __init__(
8797
8898 self .initial_solution = initial_solution
8999 self .terminate_on_apogee = terminate_on_apogee
100+ if max_time is None :
101+ self .max_time = flight .max_time
102+ else :
103+ self .max_time = max_time
90104 if time_overshoot is None :
91105 self .time_overshoot = flight .time_overshoot
92106 else :
@@ -135,12 +149,21 @@ def create_object(self):
135149 generated_dict = next (self .dict_generator ())
136150 # TODO: maybe we should use generated_dict["rail_length"] instead
137151 return Flight (
152+ rocket = self .obj .rocket ,
138153 environment = self .obj .env ,
139154 rail_length = self ._randomize_rail_length (),
140- rocket = self .obj .rocket ,
141155 inclination = generated_dict ["inclination" ],
142156 heading = generated_dict ["heading" ],
143157 initial_solution = self .initial_solution ,
144158 terminate_on_apogee = self .terminate_on_apogee ,
159+ max_time = self .max_time ,
160+ max_time_step = self .obj .max_time_step ,
161+ min_time_step = self .obj .min_time_step ,
162+ rtol = self .obj .rtol ,
163+ atol = self .obj .atol ,
145164 time_overshoot = self .time_overshoot ,
165+ name = self .obj .name ,
166+ equations_of_motion = self .obj .equations_of_motion ,
167+ ode_solver = self .obj .ode_solver ,
168+ simulation_mode = self .obj .simulation_mode ,
146169 )
0 commit comments