Skip to content

Commit

Permalink
ENH: changes due to new RailButtons and Component classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano committed Jun 23, 2023
1 parent 2e774e0 commit a044a6d
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 127 deletions.
19 changes: 13 additions & 6 deletions rocketpy/Dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def run_dispersion(
# Checks export_list
self.export_list = self.__check_export_list(export_list)

# Initializes inputs_dict in case of error in the first iteration
inputs_dict = {}

# Initialize counter and timer
i = self.num_of_loaded_sims if append else 0
initial_wall_time = time()
Expand Down Expand Up @@ -383,23 +386,26 @@ def run_dispersion(
]
for item in d.items()
)
# TODO: I believe the positions are not being saved
# need to check if they are and fix if not
if self.rocket.motors:
for motor in self.rocket.motors:
for motor in self.rocket.motors.get_components():
inputs_dict.update(motor.last_rnd_dict)
if self.rocket.nosecones:
for nosecone in self.rocket.nosecones:
for nosecone in self.rocket.nosecones.get_components():
inputs_dict.update(nosecone.last_rnd_dict)
if self.rocket.fins:
for fin in self.rocket.fins:
for fin in self.rocket.fins.get_components():
inputs_dict.update(fin.last_rnd_dict)
if self.rocket.tails:
for tail in self.rocket.tails:
for tail in self.rocket.tails.get_components():
inputs_dict.update(tail.last_rnd_dict)
if self.rocket.parachutes:
for parachute in self.rocket.parachutes:
inputs_dict.update(parachute.last_rnd_dict)
if self.rocket.rail_buttons:
inputs_dict.update(self.rocket.rail_buttons.last_rnd_dict)
if self.rocket.rail_buttons.get_components():
for rail_buttons in self.rocket.rail_buttons.get_components():
inputs_dict.update(rail_buttons.last_rnd_dict)
# Export inputs and outputs to file
self.__export_flight_data(
setting=inputs_dict,
Expand All @@ -410,6 +416,7 @@ def run_dispersion(
except (TypeError, ValueError, KeyError, AttributeError) as error:
print(f"Error on iteration {i}: {error}\n")
error_file.write(f"{inputs_dict}\n")
raise error
except KeyboardInterrupt:
print("Keyboard Interrupt, file saved.")
error_file.write(f"{inputs_dict}\n")
Expand Down
7 changes: 3 additions & 4 deletions rocketpy/monte_carlo/mc_aero_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ class as a base class, see its documentation for more information.
"""

rail_buttons: RailButtons = Field(..., exclude=True)
upper_button_position: Any = 0
lower_button_position: Any = 0
buttons_distance: Any = 0
angular_position: Any = 0
name: List[StrictStr] = []

def create_object(self):
"""Creates a RailButtons object from the randomly generated input arguments.
Expand All @@ -207,8 +207,7 @@ def create_object(self):
"""
gen_dict = next(self.dict_generator())
obj = RailButtons(
upper_button_position=gen_dict["upper_button_position"],
lower_button_position=gen_dict["lower_button_position"],
buttons_distance=gen_dict["buttons_distance"],
angular_position=gen_dict["angular_position"],
)
return obj
Loading

0 comments on commit a044a6d

Please sign in to comment.