From 830ea15445d9f30cf520981388e07557fe2f8da3 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Mon, 15 Apr 2024 15:05:31 +0200 Subject: [PATCH 01/11] ENH: refactor retrieve arrays cached properties and controller sim post processing --- rocketpy/simulation/flight.py | 253 +++++++++++++++++++++------------- 1 file changed, 156 insertions(+), 97 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 77632d2f2..ef1b54bbe 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -593,7 +593,6 @@ def __init__( if self.rail_length <= 0: raise ValueError("Rail length must be a positive value.") self.parachutes = self.rocket.parachutes[:] - self._controllers = self.rocket._controllers[:] self.inclination = inclination self.heading = heading self.max_time = max_time @@ -607,6 +606,13 @@ def __init__( self.name = name self.equations_of_motion = equations_of_motion + # Controller initialization + self._controllers = self.rocket._controllers[:] + if self._controllers: + # reset controllable object to initial state (only airbrakes for now) + for air_brakes in self.rocket.air_brakes: + air_brakes.reset() + # Flight initialization self.__init_post_process_variables() self.__init_solution_monitors() @@ -1076,8 +1082,14 @@ def __init__( [self.t, parachute] ) + # If controlled flight, post process must be done on sim time + if self._controllers: + phase.derivative(self.t, self.y_sol, post_processing=True) + self.t_final = self.t self._calculate_pressure_signal() + if self._controllers: + self.__cache_post_process_variables() if verbose: print("Simulation Completed at Time: {:3.4f} s".format(self.t)) @@ -1089,6 +1101,25 @@ def __init_post_process_variables(self): self._bearing = Function(0) self._latitude = Function(0) self._longitude = Function(0) + # Initialize state derivatives, force and atmospheric arrays + self.ax_list = [] + self.ay_list = [] + self.az_list = [] + self.alpha1_list = [] + self.alpha2_list = [] + self.alpha3_list = [] + self.R1_list = [] + self.R2_list = [] + self.R3_list = [] + self.M1_list = [] + self.M2_list = [] + self.M3_list = [] + self.pressure_list = [] + self.density_list = [] + self.dynamic_viscosity_list = [] + self.speed_of_sound_list = [] + self.wind_velocity_x_list = [] + self.wind_velocity_y_list = [] def __init_solution_monitors(self): # Initialize solution monitors @@ -1181,10 +1212,28 @@ def __init_equations_of_motion(self): if self.equations_of_motion == "solid_propulsion": self.u_dot_generalized = self.u_dot - def __init_equations_of_motion(self): - """Initialize equations of motion.""" - if self.equations_of_motion == "solid_propulsion": - self.u_dot_generalized = self.u_dot + def __cache_post_process_variables(self): + """Cache post-process variables for simulations with controllers.""" + self.__retrieve_arrays = [ + self.ax_list, + self.ay_list, + self.az_list, + self.alpha1_list, + self.alpha2_list, + self.alpha3_list, + self.R1_list, + self.R2_list, + self.R3_list, + self.M1_list, + self.M2_list, + self.M3_list, + self.pressure_list, + self.density_list, + self.dynamic_viscosity_list, + self.speed_of_sound_list, + self.wind_velocity_x_list, + self.wind_velocity_y_list, + ] @cached_property def effective_1rl(self): @@ -1261,11 +1310,6 @@ def udot_rail1(self, t, u, post_processing=False): e0dot, e1dot, e2dot, e3dot, alpha1, alpha2, alpha3]. """ - # Check if post processing mode is on - if post_processing: - # Use u_dot post processing code - return self.u_dot_generalized(t, u, True) - # Retrieve integration data x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3 = u @@ -1296,6 +1340,17 @@ def udot_rail1(self, t, u, post_processing=False): else: ax, ay, az = 0, 0, 0 + if post_processing: + # Use u_dot post processing code for forces, moments and env data + self.u_dot_generalized(t, u, post_processing=True) + # Save feasible accelerations + self.ax_list[-1] = [t, ax] + self.ay_list[-1] = [t, ay] + self.az_list[-1] = [t, az] + self.alpha1_list[-1] = [t, 0] + self.alpha2_list[-1] = [t, 0] + self.alpha3_list[-1] = [t, 0] + return [vx, vy, vz, ax, ay, az, 0, 0, 0, 0, 0, 0, 0] def udot_rail2(self, t, u, post_processing=False): @@ -1585,6 +1640,13 @@ def u_dot(self, t, u, post_processing=False): ] if post_processing: + # Accelerations + self.ax_list.append([t, ax]) + self.ay_list.append([t, ay]) + self.az_list.append([t, az]) + self.alpha1_list.append([t, alpha1]) + self.alpha2_list.append([t, alpha2]) + self.alpha3_list.append([t, alpha3]) # Dynamics variables self.R1_list.append([t, R1]) self.R2_list.append([t, R2]) @@ -1860,6 +1922,13 @@ def u_dot_generalized(self, t, u, post_processing=False): u_dot = [*r_dot, *v_dot, *e_dot, *w_dot] if post_processing: + # Accelerations + self.ax_list.append([t, v_dot[0]]) + self.ay_list.append([t, v_dot[1]]) + self.az_list.append([t, v_dot[2]]) + self.alpha1_list.append([t, w_dot[0]]) + self.alpha2_list.append([t, w_dot[1]]) + self.alpha3_list.append([t, w_dot[2]]) # Dynamics variables self.R1_list.append([t, R1]) self.R2_list.append([t, R2]) @@ -1944,6 +2013,13 @@ def u_dot_parachute(self, t, u, post_processing=False): az = (Dz - 9.8 * mp) / (mp + ma) if post_processing: + # Accelerations + self.ax_list.append([t, ax]) + self.ay_list.append([t, ay]) + self.az_list.append([t, az]) + self.alpha1_list.append([t, 0]) + self.alpha2_list.append([t, 0]) + self.alpha3_list.append([t, 0]) # Dynamics variables self.R1_list.append([t, Dx]) self.R2_list.append([t, Dy]) @@ -1952,13 +2028,20 @@ def u_dot_parachute(self, t, u, post_processing=False): self.M2_list.append([t, 0]) self.M3_list.append([t, 0]) # Atmospheric Conditions - self.wind_velocity_x_list.append([t, self.env.wind_velocity_x(z)]) - self.wind_velocity_y_list.append([t, self.env.wind_velocity_y(z)]) - self.density_list.append([t, self.env.density(z)]) - self.dynamic_viscosity_list.append([t, self.env.dynamic_viscosity(z)]) - self.pressure_list.append([t, self.env.pressure(z)]) - self.speed_of_sound_list.append([t, self.env.speed_of_sound(z)]) - + self.wind_velocity_x_list.append( + [t, self.env.wind_velocity_x.get_value_opt(z)] + ) + self.wind_velocity_y_list.append( + [t, self.env.wind_velocity_y.get_value_opt(z)] + ) + self.density_list.append([t, self.env.density.get_value_opt(z)]) + self.dynamic_viscosity_list.append( + [t, self.env.dynamic_viscosity.get_value_opt(z)] + ) + self.pressure_list.append([t, self.env.pressure.get_value_opt(z)]) + self.speed_of_sound_list.append( + [t, self.env.speed_of_sound.get_value_opt(z)] + ) return [vx, vy, vz, ax, ay, az, 0, 0, 0, 0, 0, 0, 0] @cached_property @@ -2790,13 +2873,64 @@ def longitude(self): return np.column_stack((self.time, longitude)) + @cached_property + def __retrieve_arrays(self): + """post processing function to retrieve arrays from the integration + scheme and store them in lists for further analysis. + + Returns + ------- + temp_values: list + List containing the following arrays: ``ax`` , ``ay`` , ``az`` , + ``alpha1`` , ``alpha2`` , ``alpha3`` , ``R1`` , ``R2`` , ``R3`` , + ``M1`` , ``M2`` , ``M3`` , ``pressure`` , ``density`` , + ``dynamic_viscosity`` , ``speed_of_sound`` , ``wind_velocity_x`` , + ``wind_velocity_y``. + """ + # Go through each time step and calculate forces and atmospheric values + # Get flight phases + for phase_index, phase in self.time_iterator(self.FlightPhases): + init_time = phase.t + final_time = self.FlightPhases[phase_index + 1].t + current_derivative = phase.derivative + # Call callback functions + for callback in phase.callbacks: + callback(self) + # Loop through time steps in flight phase + for step in self.solution: # Can be optimized + if init_time < step[0] <= final_time or ( + init_time == self.t_initial and step[0] == self.t_initial + ): + # Call derivatives in post processing mode + current_derivative(step[0], step[1:], post_processing=True) + + temp_values = [ + self.ax_list, + self.ay_list, + self.az_list, + self.alpha1_list, + self.alpha2_list, + self.alpha3_list, + self.R1_list, + self.R2_list, + self.R3_list, + self.M1_list, + self.M2_list, + self.M3_list, + self.pressure_list, + self.density_list, + self.dynamic_viscosity_list, + self.speed_of_sound_list, + self.wind_velocity_x_list, + self.wind_velocity_y_list, + ] + + return temp_values + @cached_property def retrieve_acceleration_arrays(self): """Retrieve acceleration arrays from the integration scheme - Parameters - ---------- - Returns ------- ax: list @@ -2812,35 +2946,7 @@ def retrieve_acceleration_arrays(self): alpha3: list angular acceleration in z direction """ - # Initialize acceleration arrays - ax, ay, az = [[0, 0]], [[0, 0]], [[0, 0]] - alpha1, alpha2, alpha3 = [[0, 0]], [[0, 0]], [[0, 0]] - # Go through each time step and calculate accelerations - # Get flight phases - for phase_index, phase in self.time_iterator(self.FlightPhases): - init_time = phase.t - final_time = self.FlightPhases[phase_index + 1].t - current_derivative = phase.derivative - # Call callback functions - for callback in phase.callbacks: - callback(self) - # Loop through time steps in flight phase - for step in self.solution: # Can be optimized - if init_time < step[0] <= final_time: - # Get derivatives - u_dot = current_derivative(step[0], step[1:]) - # Get accelerations - ax_value, ay_value, az_value = u_dot[3:6] - alpha1_value, alpha2_value, alpha3_value = u_dot[10:] - # Save accelerations - ax.append([step[0], ax_value]) - ay.append([step[0], ay_value]) - az.append([step[0], az_value]) - alpha1.append([step[0], alpha1_value]) - alpha2.append([step[0], alpha2_value]) - alpha3.append([step[0], alpha3_value]) - - return ax, ay, az, alpha1, alpha2, alpha3 + return self.__retrieve_arrays[:6] @cached_property def retrieve_temporary_values_arrays(self): @@ -2877,54 +2983,7 @@ def retrieve_temporary_values_arrays(self): self.wind_velocity_y_list: list Wind velocity in y direction at each time step. """ - - # Initialize force and atmospheric arrays - self.R1_list = [] - self.R2_list = [] - self.R3_list = [] - self.M1_list = [] - self.M2_list = [] - self.M3_list = [] - self.pressure_list = [] - self.density_list = [] - self.dynamic_viscosity_list = [] - self.speed_of_sound_list = [] - self.wind_velocity_x_list = [] - self.wind_velocity_y_list = [] - - # Go through each time step and calculate forces and atmospheric values - # Get flight phases - for phase_index, phase in self.time_iterator(self.FlightPhases): - init_time = phase.t - final_time = self.FlightPhases[phase_index + 1].t - current_derivative = phase.derivative - # Call callback functions - for callback in phase.callbacks: - callback(self) - # Loop through time steps in flight phase - for step in self.solution: # Can be optimized - if init_time < step[0] <= final_time or ( - init_time == self.t_initial and step[0] == self.t_initial - ): - # Call derivatives in post processing mode - u_dot = current_derivative(step[0], step[1:], post_processing=True) - - temporary_values = [ - self.R1_list, - self.R2_list, - self.R3_list, - self.M1_list, - self.M2_list, - self.M3_list, - self.pressure_list, - self.density_list, - self.dynamic_viscosity_list, - self.speed_of_sound_list, - self.wind_velocity_x_list, - self.wind_velocity_y_list, - ] - - return temporary_values + return self.__retrieve_arrays[6:] def get_controller_observed_variables(self): """Retrieve the observed variables related to air brakes from the From b9a97a454880a3ffbb7194c9807304dfbea0899e Mon Sep 17 00:00:00 2001 From: MateusStano Date: Mon, 15 Apr 2024 15:06:01 +0200 Subject: [PATCH 02/11] ENH: add warning for improper time_overshoot --- rocketpy/simulation/flight.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index ef1b54bbe..178fdf4a0 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -609,6 +609,13 @@ def __init__( # Controller initialization self._controllers = self.rocket._controllers[:] if self._controllers: + if self.time_overshoot == True: + warnings.warn( + "time_overshoot is set to True, but controllers are present. " + "Controllers will not work properly. " + "Consider setting time_overshoot=False in the Flight object " + "to use controllers." + ) # reset controllable object to initial state (only airbrakes for now) for air_brakes in self.rocket.air_brakes: air_brakes.reset() From a66fc53323248c74db32874f8dff8ee8e5cd4289 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Mon, 15 Apr 2024 15:18:37 +0200 Subject: [PATCH 03/11] ENH: add reset function --- rocketpy/rocket/aero_surface.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rocketpy/rocket/aero_surface.py b/rocketpy/rocket/aero_surface.py index c5d154f3e..27f87cd5c 100644 --- a/rocketpy/rocket/aero_surface.py +++ b/rocketpy/rocket/aero_surface.py @@ -1978,8 +1978,9 @@ def __init__( brakes drag coefficient will be used for the entire rocket instead. Default is False. deployment_level : float, optional - Current deployment level, ranging from 0 to 1. Deployment level is the - fraction of the total airbrake area that is Deployment. Default is 0. + Initial deployment level, ranging from 0 to 1. Deployment level is + the fraction of the total airbrake area that is Deployment. Default + is 0. name : str, optional Name of the air brakes. Default is "AirBrakes". @@ -1997,6 +1998,7 @@ def __init__( self.reference_area = reference_area self.clamp = clamp self.override_rocket_drag = override_rocket_drag + self.initial_deployment_level = deployment_level self.deployment_level = deployment_level self.prints = _AirBrakesPrints(self) self.plots = _AirBrakesPlots(self) @@ -2023,6 +2025,12 @@ def deployment_level(self, value): ) self._deployment_level = value + def _reset(self): + """Resets the air brakes to their initial state. This is ran at the + beginning of each simulation to ensure the air brakes are in the correct + state.""" + self.deployment_level = self.initial_deployment_level + def evaluate_center_of_pressure(self): """Evaluates the center of pressure of the aerodynamic surface in local coordinates. From 7fe3d0ba3b805f4a134eb399be796f7cb2e20425 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Mon, 15 Apr 2024 16:12:39 +0200 Subject: [PATCH 04/11] ENH: optmize post process loop --- rocketpy/simulation/flight.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 178fdf4a0..9a81b81c0 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -618,7 +618,7 @@ def __init__( ) # reset controllable object to initial state (only airbrakes for now) for air_brakes in self.rocket.air_brakes: - air_brakes.reset() + air_brakes._reset() # Flight initialization self.__init_post_process_variables() @@ -2903,9 +2903,12 @@ def __retrieve_arrays(self): # Call callback functions for callback in phase.callbacks: callback(self) - # Loop through time steps in flight phase - for step in self.solution: # Can be optimized - if init_time < step[0] <= final_time or ( + # find index of initial and final time of phase in solution array + init_time_index = find_closest(self.time, init_time) + final_time_index = find_closest(self.time, final_time) + 1 + # Loop through time steps solution array + for step in self.solution[init_time_index:final_time_index]: + if init_time != step[0] or ( init_time == self.t_initial and step[0] == self.t_initial ): # Call derivatives in post processing mode From aaa3f7b953d7450eec6056c723f83afa82a67bbb Mon Sep 17 00:00:00 2001 From: MateusStano Date: Mon, 15 Apr 2024 16:52:49 +0200 Subject: [PATCH 05/11] DOCS: change accelerations names in docs --- rocketpy/simulation/flight.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 9a81b81c0..94e7f7fcd 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -2943,17 +2943,17 @@ def retrieve_acceleration_arrays(self): Returns ------- - ax: list + ax_list: list acceleration in x direction - ay: list + ay_list: list acceleration in y direction - az: list + az_list: list acceleration in z direction - alpha1: list + alpha1_list: list angular acceleration in x direction - alpha2: list + alpha2_list: list angular acceleration in y direction - alpha3: list + alpha3_list: list angular acceleration in z direction """ return self.__retrieve_arrays[:6] From a49baf4d0160ca01282b101daa9444b3872b44f7 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 25 Apr 2024 22:52:13 +0200 Subject: [PATCH 06/11] MNT: move controller initialization to private method --- rocketpy/simulation/flight.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 94e7f7fcd..9655b9e01 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -607,18 +607,7 @@ def __init__( self.equations_of_motion = equations_of_motion # Controller initialization - self._controllers = self.rocket._controllers[:] - if self._controllers: - if self.time_overshoot == True: - warnings.warn( - "time_overshoot is set to True, but controllers are present. " - "Controllers will not work properly. " - "Consider setting time_overshoot=False in the Flight object " - "to use controllers." - ) - # reset controllable object to initial state (only airbrakes for now) - for air_brakes in self.rocket.air_brakes: - air_brakes._reset() + self.__init_controllers() # Flight initialization self.__init_post_process_variables() @@ -1219,6 +1208,21 @@ def __init_equations_of_motion(self): if self.equations_of_motion == "solid_propulsion": self.u_dot_generalized = self.u_dot + def __init_controllers(self): + """Initialize controllers""" + self._controllers = self.rocket._controllers[:] + if self._controllers: + if self.time_overshoot == True: + warnings.warn( + "time_overshoot is set to True, but controllers are present. " + "Controllers will not work properly. " + "Consider setting time_overshoot=False in the Flight object " + "to use controllers." + ) + # reset controllable object to initial state (only airbrakes for now) + for air_brakes in self.rocket.air_brakes: + air_brakes._reset() + def __cache_post_process_variables(self): """Cache post-process variables for simulations with controllers.""" self.__retrieve_arrays = [ From 4974e8d7417e0d102088d40007b3c429aed1b896 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 25 Apr 2024 22:52:48 +0200 Subject: [PATCH 07/11] BUG: initialize state derivatives for controllers --- rocketpy/simulation/flight.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 9655b9e01..5fcb7c86e 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1188,6 +1188,11 @@ def __init_flight_state(self): self.out_of_rail_time = self.initial_solution[0] self.out_of_rail_time_index = 0 self.initial_derivative = self.u_dot_generalized + if self._controllers: + # Handle post process during simulation, get initial accel/forces + self.initial_derivative( + self.t_initial, self.initial_solution[1:], post_processing=True + ) def __init_solver_monitors(self): # Initialize solver monitors From 67515f64be6f1702d6497055fbb071f888ac5c09 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 25 Apr 2024 23:02:11 +0200 Subject: [PATCH 08/11] ENH: automatically disable time overshoot for controllers --- rocketpy/simulation/flight.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 3ff87ed52..e90d5d9b8 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1218,11 +1218,9 @@ def __init_controllers(self): self._controllers = self.rocket._controllers[:] if self._controllers: if self.time_overshoot == True: + self.time_overshoot = False warnings.warn( - "time_overshoot is set to True, but controllers are present. " - "Controllers will not work properly. " - "Consider setting time_overshoot=False in the Flight object " - "to use controllers." + "time_overshoot has been set to False due to the presence of controllers. " ) # reset controllable object to initial state (only airbrakes for now) for air_brakes in self.rocket.air_brakes: From 3b3549b85b4b4b5aae694c59dd5519a635d597c5 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Sun, 5 May 2024 16:33:40 +0200 Subject: [PATCH 09/11] ENH: finalize merge --- rocketpy/simulation/flight.py | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 898b8ddd7..5f282bf81 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1057,6 +1057,7 @@ def __init_solution_monitors(self): self.impact_state = np.array([0]) self.parachute_events = [] self.post_processed = False + self.__post_processed_variables = [] def __init_flight_state(self): """Initialize flight state variables.""" @@ -1148,26 +1149,7 @@ def __init_controllers(self): def __cache_post_process_variables(self): """Cache post-process variables for simulations with controllers.""" - self.__retrieve_arrays = [ - self.ax_list, - self.ay_list, - self.az_list, - self.alpha1_list, - self.alpha2_list, - self.alpha3_list, - self.R1_list, - self.R2_list, - self.R3_list, - self.M1_list, - self.M2_list, - self.M3_list, - self.pressure_list, - self.density_list, - self.dynamic_viscosity_list, - self.speed_of_sound_list, - self.wind_velocity_x_list, - self.wind_velocity_y_list, - ] + self.__evaluate_post_process = np.array(self.__post_processed_variables) @cached_property def effective_1rl(self): @@ -1289,12 +1271,7 @@ def udot_rail1(self, t, u, post_processing=False): # Use u_dot post processing code for forces, moments and env data self.u_dot_generalized(t, u, post_processing=True) # Save feasible accelerations - self.__post_processed_variables[-1][1] = ax - self.__post_processed_variables[-1][2] = ay - self.__post_processed_variables[-1][3] = az - self.__post_processed_variables[-1][4] = 0 - self.__post_processed_variables[-1][5] = 0 - self.__post_processed_variables[-1][6] = 0 + self.__post_processed_variables[-1][1:7] = [ax, ay, az, 0, 0, 0] return [vx, vy, vz, ax, ay, az, 0, 0, 0, 0, 0, 0, 0] From 8b91f0b8333bc884407c858bb7402bb286a51333 Mon Sep 17 00:00:00 2001 From: MateusStano <69485049+MateusStano@users.noreply.github.com> Date: Thu, 16 May 2024 09:12:54 -0300 Subject: [PATCH 10/11] MNT: remove True check Co-authored-by: Pedro Henrique Marinho Bressan <87212571+phmbressan@users.noreply.github.com> --- rocketpy/simulation/flight.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 64dccae71..1996a4d60 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1138,7 +1138,7 @@ def __init_controllers(self): """Initialize controllers""" self._controllers = self.rocket._controllers[:] if self._controllers: - if self.time_overshoot == True: + if self.time_overshoot: self.time_overshoot = False warnings.warn( "time_overshoot has been set to False due to the presence of controllers. " From 464f2017c46367857582b33b81c7379d4d39cd80 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 16 May 2024 14:40:50 +0200 Subject: [PATCH 11/11] ENH: remove __cache_post_process_variables --- rocketpy/simulation/flight.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 5f282bf81..523402fe1 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1005,7 +1005,8 @@ def __simulate(self, verbose): self.t_final = self.t self.__transform_pressure_signals_lists_to_functions() if self._controllers: - self.__cache_post_process_variables() + # cache post process variables + self.__evaluate_post_process = np.array(self.__post_processed_variables) if verbose: print(f"\n>>> Simulation Completed at Time: {self.t:3.4f} s") @@ -1147,10 +1148,6 @@ def __init_controllers(self): for air_brakes in self.rocket.air_brakes: air_brakes._reset() - def __cache_post_process_variables(self): - """Cache post-process variables for simulations with controllers.""" - self.__evaluate_post_process = np.array(self.__post_processed_variables) - @cached_property def effective_1rl(self): """Original rail length minus the distance measured from nozzle exit