From 2dcd98076db0ef059a0b6c7fa09b232924585fe0 Mon Sep 17 00:00:00 2001 From: GabrielBarberini Date: Sun, 13 Oct 2024 19:34:28 -0300 Subject: [PATCH] adapts API to recent rocketpy changes --- lib/models/aerosurfaces.py | 17 ++- lib/models/environment.py | 6 +- lib/models/flight.py | 27 +++- lib/models/motor.py | 10 +- lib/models/rocket.py | 10 +- lib/services/flight.py | 10 +- lib/services/motor.py | 6 +- lib/services/rocket.py | 76 +++++----- lib/views/environment.py | 85 +++++------ lib/views/flight.py | 287 ++++++++++++++++++------------------- lib/views/motor.py | 126 ++++++++-------- lib/views/rocket.py | 61 ++++---- 12 files changed, 377 insertions(+), 344 deletions(-) diff --git a/lib/models/aerosurfaces.py b/lib/models/aerosurfaces.py index f356601..53ae8c8 100644 --- a/lib/models/aerosurfaces.py +++ b/lib/models/aerosurfaces.py @@ -4,7 +4,7 @@ class RailButtons(BaseModel): - name: str + name: str = "RailButtons" upper_button_position: float lower_button_position: float angular_position: float @@ -34,13 +34,24 @@ class Fins(BaseModel): name: str n: int root_chord: float - tip_chord: Optional[float] = None span: float position: float + + # Optional parameters + tip_chord: Optional[float] = None cant_angle: Optional[float] = None - radius: Optional[float] = None + rocket_radius: Optional[float] = None airfoil: Optional[Tuple[List[Tuple[float, float]], AngleUnit]] = None + def get_additional_parameters(self): + return { + key: value + for key, value in self.dict().items() + if value is not None + and key + not in ["fins_kind", "name", "n", "root_chord", "span", "position"] + } + # TODO: implement airbrakes class AirBrakes(BaseModel): diff --git a/lib/models/environment.py b/lib/models/environment.py index ce5e352..3b62940 100644 --- a/lib/models/environment.py +++ b/lib/models/environment.py @@ -16,10 +16,12 @@ class AtmosphericModelTypes(str, Enum): class Env(BaseModel): latitude: float longitude: float - elevation: Optional[int] = 0 + elevation: Optional[int] = 1 # Optional parameters - atmospheric_model_type: Optional[AtmosphericModelTypes] = None + atmospheric_model_type: AtmosphericModelTypes = ( + AtmosphericModelTypes.STANDARD_ATMOSPHERE + ) atmospheric_model_file: Optional[str] = None date: Optional[datetime.datetime] = ( datetime.datetime.today() + datetime.timedelta(days=1) diff --git a/lib/models/flight.py b/lib/models/flight.py index c92be47..7616475 100644 --- a/lib/models/flight.py +++ b/lib/models/flight.py @@ -14,16 +14,35 @@ class Flight(BaseModel): name: str = "Flight" environment: Env rocket: Rocket - rail_length: float + rail_length: float = 1 + time_overshoot: bool = True + terminate_on_apogee: bool = True + equations_of_motion: EquationsOfMotion = EquationsOfMotion.STANDARD + + # Optional parameters inclination: Optional[int] = None heading: Optional[int] = None # TODO: implement initial_solution - terminate_on_apogee: Optional[bool] = None max_time: Optional[int] = None max_time_step: Optional[float] = None min_time_step: Optional[int] = None rtol: Optional[float] = None atol: Optional[float] = None - time_overshoot: Optional[bool] = None verbose: Optional[bool] = None - equations_of_motion: Optional[EquationsOfMotion] = None + + def get_additional_parameters(self): + return { + key: value + for key, value in self.dict().items() + if value is not None + and key + not in [ + "name", + "environment", + "rocket", + "rail_length", + "time_overshoot", + "terminate_on_apogee", + "equations_of_motion", + ] + } diff --git a/lib/models/motor.py b/lib/models/motor.py index 1ef5bff..302dfc9 100644 --- a/lib/models/motor.py +++ b/lib/models/motor.py @@ -76,7 +76,7 @@ class Motor(BaseModel): burn_time: float nozzle_radius: float dry_mass: float - dry_inertia: Tuple[float, float, float] + dry_inertia: Tuple[float, float, float] = (0, 0, 0) center_of_dry_mass_position: float # Generic motor parameters @@ -102,9 +102,11 @@ class Motor(BaseModel): throat_radius: Optional[float] = None # Optional parameters - interpolation_method: Optional[InterpolationMethods] = None - coordinate_system_orientation: Optional[CoordinateSystemOrientation] = None - reshape_thrust_curve: Optional[Union[bool, tuple]] = None + interpolation_method: InterpolationMethods = InterpolationMethods.LINEAR + coordinate_system_orientation: CoordinateSystemOrientation = ( + CoordinateSystemOrientation.NOZZLE_TO_COMBUSTION_CHAMBER + ) + reshape_thrust_curve: Union[bool, tuple] = False # Computed parameters _motor_kind: MotorKinds = PrivateAttr(default=MotorKinds.SOLID) diff --git a/lib/models/rocket.py b/lib/models/rocket.py index 593f889..2b6b1a9 100644 --- a/lib/models/rocket.py +++ b/lib/models/rocket.py @@ -34,9 +34,12 @@ class Rocket(BaseModel): inertia: Union[ Tuple[float, float, float], Tuple[float, float, float, float, float, float], - ] - power_off_drag: List[Tuple[float, float]] - power_on_drag: List[Tuple[float, float]] + ] = (0, 0, 0) + power_off_drag: List[Tuple[float, float]] = [(0, 0)] + power_on_drag: List[Tuple[float, float]] = [(0, 0)] + coordinate_system_orientation: CoordinateSystemOrientation = ( + CoordinateSystemOrientation.TAIL_TO_NOSE + ) # Optional parameters parachutes: Optional[List[Parachute]] = None @@ -44,4 +47,3 @@ class Rocket(BaseModel): nose: Optional[NoseCone] = None fins: Optional[List[Fins]] = None tail: Optional[Tail] = None - coordinate_system_orientation: Optional[CoordinateSystemOrientation] = None diff --git a/lib/services/flight.py b/lib/services/flight.py index 8dba4df..3130205 100644 --- a/lib/services/flight.py +++ b/lib/services/flight.py @@ -31,20 +31,12 @@ def from_flight_model(cls, flight: Flight) -> Self: rocketpy_rocket = RocketService.from_rocket_model(flight.rocket).rocket rocketpy_flight = RocketPyFlight( rocket=rocketpy_rocket, - inclination=flight.inclination, - heading=flight.heading, environment=rocketpy_env, rail_length=flight.rail_length, - # initial_solution=flight.initial_solution, terminate_on_apogee=flight.terminate_on_apogee, - max_time=flight.max_time, - max_time_step=flight.max_time_step, - min_time_step=flight.min_time_step, - rtol=flight.rtol, - atol=flight.atol, time_overshoot=flight.time_overshoot, - verbose=flight.verbose, equations_of_motion=flight.equations_of_motion.value.lower(), + **flight.get_additional_parameters(), ) return cls(flight=rocketpy_flight) diff --git a/lib/services/motor.py b/lib/services/motor.py index 20cce13..c83d424 100644 --- a/lib/services/motor.py +++ b/lib/services/motor.py @@ -41,11 +41,7 @@ def from_motor_model(cls, motor: Motor) -> Self: "dry_mass": motor.dry_mass, "dry_inertia": motor.dry_inertia, "center_of_dry_mass_position": motor.center_of_dry_mass_position, - "coordinate_system_orientation": ( - motor.coordinate_system_orientation.value.lower() - if motor.coordinate_system_orientation - else None - ), + "coordinate_system_orientation": motor.coordinate_system_orientation.value.lower(), "interpolation_method": motor.interpolation_method.value.lower(), "reshape_thrust_curve": False or motor.reshape_thrust_curve, } diff --git a/lib/services/rocket.py b/lib/services/rocket.py index c6b6722..f3b4f47 100644 --- a/lib/services/rocket.py +++ b/lib/services/rocket.py @@ -47,46 +47,53 @@ def from_rocket_model(cls, rocket: Rocket) -> Self: ) # RailButtons - rocketpy_rocket.set_rail_buttons( - upper_button_position=rocket.rail_buttons.upper_button_position, - lower_button_position=rocket.rail_buttons.lower_button_position, - angular_position=rocket.rail_buttons.angular_position, - ) - rocketpy_rocket.add_motor( - MotorService.from_motor_model(rocket.motor).motor, - rocket.motor_position, - ) + if rocket.rail_buttons: + rocketpy_rocket.set_rail_buttons( + upper_button_position=rocket.rail_buttons.upper_button_position, + lower_button_position=rocket.rail_buttons.lower_button_position, + angular_position=rocket.rail_buttons.angular_position, + ) + rocketpy_rocket.add_motor( + MotorService.from_motor_model(rocket.motor).motor, + rocket.motor_position, + ) # NoseCone - nose = cls.get_rocketpy_nose(rocket.nose) - rocketpy_rocket.aerodynamic_surfaces.add(nose, nose.position) - rocketpy_rocket.evaluate_static_margin() + if rocket.nose: + nose = cls.get_rocketpy_nose(rocket.nose) + rocketpy_rocket.aerodynamic_surfaces.add(nose, nose.position) + rocketpy_rocket.evaluate_static_margin() # FinSet - rocketpy_finset_list = cls.get_rocketpy_finset_list_from_fins_list( - rocket.fins - ) - for finset in rocketpy_finset_list: - rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position) - rocketpy_rocket.evaluate_static_margin() + if rocket.fins: + rocketpy_finset_list = cls.get_rocketpy_finset_list_from_fins_list( + rocket.fins + ) + for finset in rocketpy_finset_list: + rocketpy_rocket.aerodynamic_surfaces.add( + finset, finset.position + ) + rocketpy_rocket.evaluate_static_margin() # Tail - tail = cls.get_rocketpy_tail(rocket.tail) - rocketpy_rocket.aerodynamic_surfaces.add(tail, tail.position) - rocketpy_rocket.evaluate_static_margin() + if rocket.tail: + tail = cls.get_rocketpy_tail(rocket.tail) + rocketpy_rocket.aerodynamic_surfaces.add(tail, tail.position) + rocketpy_rocket.evaluate_static_margin() # Air Brakes # Parachutes - for parachute in rocket.parachutes: - if cls.check_parachute_trigger(parachute.trigger): - rocketpy_parachute = cls.get_rocketpy_parachute(parachute) - rocketpy_rocket.parachutes.append(rocketpy_parachute) - else: - logger.warning( - "Parachute trigger not valid. Skipping parachute." - ) - continue + if rocket.parachutes: + for parachute in rocket.parachutes: + if cls.check_parachute_trigger(parachute.trigger): + rocketpy_parachute = cls.get_rocketpy_parachute(parachute) + rocketpy_rocket.parachutes.append(rocketpy_parachute) + else: + logger.warning( + "Parachute trigger not valid. Skipping parachute." + ) + continue return cls(rocket=rocketpy_rocket) @@ -160,11 +167,8 @@ def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins: n=fins.n, name=fins.name, root_chord=fins.root_chord, - tip_chord=fins.tip_chord, span=fins.span, - cant_angle=fins.cant_angle, - rocket_radius=fins.radius, - airfoil=fins.airfoil, + **fins.get_additional_parameters(), ) case "ELLIPTICAL": rocketpy_finset = RocketPyEllipticalFins( @@ -172,9 +176,7 @@ def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins: name=fins.name, root_chord=fins.root_chord, span=fins.span, - cant_angle=fins.cant_angle, - rocket_radius=fins.radius, - airfoil=fins.airfoil, + **fins.get_additional_parameters(), ) case _: raise ValueError(f"Invalid fins kind: {kind}") diff --git a/lib/views/environment.py b/lib/views/environment.py index bbde25d..a7478f5 100644 --- a/lib/views/environment.py +++ b/lib/views/environment.py @@ -1,50 +1,53 @@ from typing import Optional, Any -from datetime import datetime +from datetime import datetime, timedelta from pydantic import BaseModel +from lib.models.environment import AtmosphericModelTypes from lib.utils import to_python_primitive class EnvSummary(BaseModel): - latitude: Optional[float] - longitude: Optional[float] - elevation: Optional[float] - atmospheric_model_type: Optional[str] - air_gas_constant: Optional[float] - standard_g: Optional[float] - earth_radius: Optional[float] - datum: Optional[str] - timezone: Optional[str] - initial_utm_zone: Optional[int] - initial_utm_letter: Optional[str] - initial_north: Optional[float] - initial_east: Optional[float] - initial_hemisphere: Optional[str] - initial_ew: Optional[str] - max_expected_height: Optional[int] - date: Optional[datetime] - local_date: Optional[datetime] - datetime_date: Optional[datetime] - ellipsoid: Optional[Any] - barometric_height: Optional[Any] - barometric_height_ISA: Optional[Any] - pressure: Optional[Any] - pressure_ISA: Optional[Any] - temperature: Optional[Any] - temperature_ISA: Optional[Any] - density: Optional[Any] - speed_of_sound: Optional[Any] - dynamic_viscosity: Optional[Any] - gravity: Optional[Any] - somigliana_gravity: Optional[Any] - wind_speed: Optional[Any] - wind_direction: Optional[Any] - wind_heading: Optional[Any] - wind_velocity_x: Optional[Any] - wind_velocity_y: Optional[Any] - calculate_earth_radius: Optional[Any] - decimal_degrees_to_arc_seconds: Optional[Any] - geodesic_to_utm: Optional[Any] - utm_to_geodesic: Optional[Any] + latitude: Optional[float] = None + longitude: Optional[float] = None + elevation: Optional[float] = 1 + atmospheric_model_type: Optional[str] = ( + AtmosphericModelTypes.STANDARD_ATMOSPHERE.value + ) + air_gas_constant: Optional[float] = None + standard_g: Optional[float] = None + earth_radius: Optional[float] = None + datum: Optional[str] = None + timezone: Optional[str] = None + initial_utm_zone: Optional[int] = None + initial_utm_letter: Optional[str] = None + initial_north: Optional[float] = None + initial_east: Optional[float] = None + initial_hemisphere: Optional[str] = None + initial_ew: Optional[str] = None + max_expected_height: Optional[int] = None + date: Optional[datetime] = datetime.today() + timedelta(days=1) + local_date: Optional[datetime] = datetime.today() + timedelta(days=1) + datetime_date: Optional[datetime] = datetime.today() + timedelta(days=1) + ellipsoid: Optional[Any] = None + barometric_height: Optional[Any] = None + barometric_height_ISA: Optional[Any] = None + pressure: Optional[Any] = None + pressure_ISA: Optional[Any] = None + temperature: Optional[Any] = None + temperature_ISA: Optional[Any] = None + density: Optional[Any] = None + speed_of_sound: Optional[Any] = None + dynamic_viscosity: Optional[Any] = None + gravity: Optional[Any] = None + somigliana_gravity: Optional[Any] = None + wind_speed: Optional[Any] = None + wind_direction: Optional[Any] = None + wind_heading: Optional[Any] = None + wind_velocity_x: Optional[Any] = None + wind_velocity_y: Optional[Any] = None + calculate_earth_radius: Optional[Any] = None + decimal_degrees_to_arc_seconds: Optional[Any] = None + geodesic_to_utm: Optional[Any] = None + utm_to_geodesic: Optional[Any] = None class Config: json_encoders = {Any: to_python_primitive} diff --git a/lib/views/flight.py b/lib/views/flight.py index 5dc8133..00ad4f4 100644 --- a/lib/views/flight.py +++ b/lib/views/flight.py @@ -7,150 +7,149 @@ class FlightSummary(RocketSummary, EnvSummary): - # TODO: implement {flight_id}/summary/motor; {flight_id}/summary/rocket; {flight_id}/summary/environment - name: Optional[str] - max_time: Optional[int] - min_time_step: Optional[int] - max_time_step: Optional[Any] - equations_of_motion: Optional[str] - heading: Optional[int] - inclination: Optional[int] - initial_solution: Optional[list] - effective_1rl: Optional[float] - effective_2rl: Optional[float] - out_of_rail_time: Optional[float] - out_of_rail_time_index: Optional[int] - parachute_cd_s: Optional[float] - rail_length: Optional[float] - rtol: Optional[float] - t: Optional[float] - t_final: Optional[float] - t_initial: Optional[int] - terminate_on_apogee: Optional[bool] - time_overshoot: Optional[bool] - latitude: Optional[Any] - longitude: Optional[Any] - M1: Optional[Any] - M2: Optional[Any] - M3: Optional[Any] - R1: Optional[Any] - R2: Optional[Any] - R3: Optional[Any] - acceleration: Optional[Any] - aerodynamic_bending_moment: Optional[Any] - aerodynamic_drag: Optional[Any] - aerodynamic_lift: Optional[Any] - aerodynamic_spin_moment: Optional[Any] - alpha1: Optional[Any] - alpha2: Optional[Any] - alpha3: Optional[Any] - altitude: Optional[Any] - angle_of_attack: Optional[Any] - apogee: Optional[Any] - apogee_freestream_speed: Optional[Any] - apogee_state: Optional[Any] - apogee_time: Optional[Any] - apogee_x: Optional[Any] - apogee_y: Optional[Any] - atol: Optional[Any] - attitude_angle: Optional[Any] - attitude_frequency_response: Optional[Any] - attitude_vector_x: Optional[Any] - attitude_vector_y: Optional[Any] - attitude_vector_z: Optional[Any] - ax: Optional[Any] - ay: Optional[Any] - az: Optional[Any] - bearing: Optional[Any] - drag_power: Optional[Any] - drift: Optional[Any] - dynamic_pressure: Optional[Any] - e0: Optional[Any] - e1: Optional[Any] - e2: Optional[Any] - e3: Optional[Any] - free_stream_speed: Optional[Any] - frontal_surface_wind: Optional[Any] - function_evaluations: Optional[Any] - function_evaluations_per_time_step: Optional[Any] - horizontal_speed: Optional[Any] - impact_state: Optional[Any] - impact_velocity: Optional[Any] - initial_stability_margin: Optional[Any] - kinetic_energy: Optional[Any] - lateral_attitude_angle: Optional[Any] - lateral_surface_wind: Optional[Any] - mach_number: Optional[Any] - max_acceleration: Optional[Any] - max_acceleration_power_off: Optional[Any] - max_acceleration_power_off_time: Optional[Any] - max_acceleration_power_on: Optional[Any] - max_acceleration_power_on_time: Optional[Any] - max_acceleration_time: Optional[Any] - max_dynamic_pressure: Optional[Any] - max_dynamic_pressure_time: Optional[Any] - max_mach_number: Optional[Any] - max_mach_number_time: Optional[Any] - max_rail_button1_normal_force: Optional[Any] - max_rail_button1_shear_force: Optional[Any] - max_rail_button2_normal_force: Optional[Any] - max_rail_button2_shear_force: Optional[Any] - max_reynolds_number: Optional[Any] - max_reynolds_number_time: Optional[Any] - max_speed: Optional[Any] - max_speed_time: Optional[Any] - max_stability_margin: Optional[Any] - max_stability_margin_time: Optional[Any] - max_total_pressure: Optional[Any] - max_total_pressure_time: Optional[Any] - min_stability_margin: Optional[Any] - min_stability_margin_time: Optional[Any] - omega1_frequency_response: Optional[Any] - omega2_frequency_response: Optional[Any] - omega3_frequency_response: Optional[Any] - out_of_rail_stability_margin: Optional[Any] - out_of_rail_state: Optional[Any] - out_of_rail_velocity: Optional[Any] - parachute_events: Optional[Any] - path_angle: Optional[Any] - phi: Optional[Any] - potential_energy: Optional[Any] - psi: Optional[Any] - rail_button1_normal_force: Optional[Any] - rail_button1_shear_force: Optional[Any] - rail_button2_normal_force: Optional[Any] - rail_button2_shear_force: Optional[Any] - reynolds_number: Optional[Any] - rotational_energy: Optional[Any] - solution: Optional[Any] - solution_array: Optional[Any] - speed: Optional[Any] - stability_margin: Optional[Any] - static_margin: Optional[Any] - stream_velocity_x: Optional[Any] - stream_velocity_y: Optional[Any] - stream_velocity_z: Optional[Any] - theta: Optional[Any] - thrust_power: Optional[Any] - time: Optional[Any] - time_steps: Optional[Any] - total_energy: Optional[Any] - total_pressure: Optional[Any] - translational_energy: Optional[Any] - vx: Optional[Any] - vy: Optional[Any] - vz: Optional[Any] - w1: Optional[Any] - w2: Optional[Any] - w3: Optional[Any] - x: Optional[Any] - x_impact: Optional[Any] - y: Optional[Any] - y_impact: Optional[Any] - y_sol: Optional[Any] - z: Optional[Any] - z_impact: Optional[Any] - flight_phases: Optional[Any] + name: Optional[str] = None + max_time: Optional[int] = None + min_time_step: Optional[int] = None + max_time_step: Optional[Any] = None + equations_of_motion: Optional[str] = None + heading: Optional[int] = None + inclination: Optional[int] = None + initial_solution: Optional[list] = None + effective_1rl: Optional[float] = None + effective_2rl: Optional[float] = None + out_of_rail_time: Optional[float] = None + out_of_rail_time_index: Optional[int] = None + parachute_cd_s: Optional[float] = None + rail_length: Optional[float] = None + rtol: Optional[float] = None + t: Optional[float] = None + t_final: Optional[float] = None + t_initial: Optional[int] = None + terminate_on_apogee: Optional[bool] = None + time_overshoot: Optional[bool] = None + latitude: Optional[Any] = None + longitude: Optional[Any] = None + M1: Optional[Any] = None + M2: Optional[Any] = None + M3: Optional[Any] = None + R1: Optional[Any] = None + R2: Optional[Any] = None + R3: Optional[Any] = None + acceleration: Optional[Any] = None + aerodynamic_bending_moment: Optional[Any] = None + aerodynamic_drag: Optional[Any] = None + aerodynamic_lift: Optional[Any] = None + aerodynamic_spin_moment: Optional[Any] = None + alpha1: Optional[Any] = None + alpha2: Optional[Any] = None + alpha3: Optional[Any] = None + altitude: Optional[Any] = None + angle_of_attack: Optional[Any] = None + apogee: Optional[Any] = None + apogee_freestream_speed: Optional[Any] = None + apogee_state: Optional[Any] = None + apogee_time: Optional[Any] = None + apogee_x: Optional[Any] = None + apogee_y: Optional[Any] = None + atol: Optional[Any] = None + attitude_angle: Optional[Any] = None + attitude_frequency_response: Optional[Any] = None + attitude_vector_x: Optional[Any] = None + attitude_vector_y: Optional[Any] = None + attitude_vector_z: Optional[Any] = None + ax: Optional[Any] = None + ay: Optional[Any] = None + az: Optional[Any] = None + bearing: Optional[Any] = None + drag_power: Optional[Any] = None + drift: Optional[Any] = None + dynamic_pressure: Optional[Any] = None + e0: Optional[Any] = None + e1: Optional[Any] = None + e2: Optional[Any] = None + e3: Optional[Any] = None + free_stream_speed: Optional[Any] = None + frontal_surface_wind: Optional[Any] = None + function_evaluations: Optional[Any] = None + function_evaluations_per_time_step: Optional[Any] = None + horizontal_speed: Optional[Any] = None + impact_state: Optional[Any] = None + impact_velocity: Optional[Any] = None + initial_stability_margin: Optional[Any] = None + kinetic_energy: Optional[Any] = None + lateral_attitude_angle: Optional[Any] = None + lateral_surface_wind: Optional[Any] = None + mach_number: Optional[Any] = None + max_acceleration: Optional[Any] = None + max_acceleration_power_off: Optional[Any] = None + max_acceleration_power_off_time: Optional[Any] = None + max_acceleration_power_on: Optional[Any] = None + max_acceleration_power_on_time: Optional[Any] = None + max_acceleration_time: Optional[Any] = None + max_dynamic_pressure: Optional[Any] = None + max_dynamic_pressure_time: Optional[Any] = None + max_mach_number: Optional[Any] = None + max_mach_number_time: Optional[Any] = None + max_rail_button1_normal_force: Optional[Any] = None + max_rail_button1_shear_force: Optional[Any] = None + max_rail_button2_normal_force: Optional[Any] = None + max_rail_button2_shear_force: Optional[Any] = None + max_reynolds_number: Optional[Any] = None + max_reynolds_number_time: Optional[Any] = None + max_speed: Optional[Any] = None + max_speed_time: Optional[Any] = None + max_stability_margin: Optional[Any] = None + max_stability_margin_time: Optional[Any] = None + max_total_pressure: Optional[Any] = None + max_total_pressure_time: Optional[Any] = None + min_stability_margin: Optional[Any] = None + min_stability_margin_time: Optional[Any] = None + omega1_frequency_response: Optional[Any] = None + omega2_frequency_response: Optional[Any] = None + omega3_frequency_response: Optional[Any] = None + out_of_rail_stability_margin: Optional[Any] = None + out_of_rail_state: Optional[Any] = None + out_of_rail_velocity: Optional[Any] = None + parachute_events: Optional[Any] = None + path_angle: Optional[Any] = None + phi: Optional[Any] = None + potential_energy: Optional[Any] = None + psi: Optional[Any] = None + rail_button1_normal_force: Optional[Any] = None + rail_button1_shear_force: Optional[Any] = None + rail_button2_normal_force: Optional[Any] = None + rail_button2_shear_force: Optional[Any] = None + reynolds_number: Optional[Any] = None + rotational_energy: Optional[Any] = None + solution: Optional[Any] = None + solution_array: Optional[Any] = None + speed: Optional[Any] = None + stability_margin: Optional[Any] = None + static_margin: Optional[Any] = None + stream_velocity_x: Optional[Any] = None + stream_velocity_y: Optional[Any] = None + stream_velocity_z: Optional[Any] = None + theta: Optional[Any] = None + thrust_power: Optional[Any] = None + time: Optional[Any] = None + time_steps: Optional[Any] = None + total_energy: Optional[Any] = None + total_pressure: Optional[Any] = None + translational_energy: Optional[Any] = None + vx: Optional[Any] = None + vy: Optional[Any] = None + vz: Optional[Any] = None + w1: Optional[Any] = None + w2: Optional[Any] = None + w3: Optional[Any] = None + x: Optional[Any] = None + x_impact: Optional[Any] = None + y: Optional[Any] = None + y_impact: Optional[Any] = None + y_sol: Optional[Any] = None + z: Optional[Any] = None + z_impact: Optional[Any] = None + flight_phases: Optional[Any] = None class Config: json_encoders = {Any: to_python_primitive} diff --git a/lib/views/motor.py b/lib/views/motor.py index 67a9c2c..6424096 100644 --- a/lib/views/motor.py +++ b/lib/views/motor.py @@ -1,71 +1,73 @@ from typing import List, Any, Optional from pydantic import BaseModel -from lib.models.motor import Motor, MotorKinds +from lib.models.motor import Motor, MotorKinds, CoordinateSystemOrientation from lib.utils import to_python_primitive class MotorSummary(BaseModel): - average_thrust: Optional[float] - burn_duration: Optional[float] - burn_out_time: Optional[float] - burn_start_time: Optional[float] - center_of_dry_mass_position: Optional[float] - coordinate_system_orientation: Optional[str] - dry_I_11: Optional[float] - dry_I_12: Optional[float] - dry_I_13: Optional[float] - dry_I_22: Optional[float] - dry_I_23: Optional[float] - dry_I_33: Optional[float] - dry_mass: Optional[float] - grain_burn_out: Optional[float] - grain_density: Optional[float] - grain_initial_height: Optional[float] - grain_initial_inner_radius: Optional[float] - grain_initial_mass: Optional[float] - grain_initial_volume: Optional[float] - grain_number: Optional[int] - grain_outer_radius: Optional[float] - grain_separation: Optional[float] - grains_center_of_mass_position: Optional[float] - interpolate: Optional[str] - max_thrust: Optional[float] - max_thrust_time: Optional[float] - nozzle_position: Optional[float] - nozzle_radius: Optional[float] - propellant_initial_mass: Optional[float] - throat_area: Optional[float] - throat_radius: Optional[float] - thrust_source: Optional[List[List[float]]] - total_impulse: Optional[float] - Kn: Optional[Any] - I_11: Optional[Any] - I_12: Optional[Any] - I_13: Optional[Any] - I_22: Optional[Any] - I_23: Optional[Any] - I_33: Optional[Any] - burn_area: Optional[Any] - burn_rate: Optional[Any] - burn_time: Optional[Any] - center_of_mass: Optional[Any] - center_of_propellant_mass: Optional[Any] - exhaust_velocity: Optional[Any] - grain_height: Optional[Any] - grain_volume: Optional[Any] - grain_inner_radius: Optional[Any] - mass_flow_rate: Optional[Any] - propellant_I_11: Optional[Any] - propellant_I_12: Optional[Any] - propellant_I_13: Optional[Any] - propellant_I_22: Optional[Any] - propellant_I_23: Optional[Any] - propellant_I_33: Optional[Any] - propellant_mass: Optional[Any] - reshape_thrust_curve: Optional[Any] - total_mass: Optional[Any] - total_mass_flow_rate: Optional[Any] - thrust: Optional[Any] + average_thrust: Optional[float] = None + burn_duration: Optional[float] = None + burn_out_time: Optional[float] = None + burn_start_time: Optional[float] = None + center_of_dry_mass_position: Optional[float] = None + coordinate_system_orientation: str = ( + CoordinateSystemOrientation.NOZZLE_TO_COMBUSTION_CHAMBER.value + ) + dry_I_11: Optional[float] = None + dry_I_12: Optional[float] = None + dry_I_13: Optional[float] = None + dry_I_22: Optional[float] = None + dry_I_23: Optional[float] = None + dry_I_33: Optional[float] = None + dry_mass: Optional[float] = None + grain_burn_out: Optional[float] = None + grain_density: Optional[float] = None + grain_initial_height: Optional[float] = None + grain_initial_inner_radius: Optional[float] = None + grain_initial_mass: Optional[float] = None + grain_initial_volume: Optional[float] = None + grain_number: Optional[int] = None + grain_outer_radius: Optional[float] = None + grain_separation: Optional[float] = None + grains_center_of_mass_position: Optional[float] = None + interpolate: Optional[str] = None + max_thrust: Optional[float] = None + max_thrust_time: Optional[float] = None + nozzle_position: Optional[float] = None + nozzle_radius: Optional[float] = None + propellant_initial_mass: Optional[float] = None + throat_area: Optional[float] = None + throat_radius: Optional[float] = None + thrust_source: Optional[List[List[float]]] = None + total_impulse: Optional[float] = None + Kn: Optional[Any] = None + I_11: Optional[Any] = None + I_12: Optional[Any] = None + I_13: Optional[Any] = None + I_22: Optional[Any] = None + I_23: Optional[Any] = None + I_33: Optional[Any] = None + burn_area: Optional[Any] = None + burn_rate: Optional[Any] = None + burn_time: Optional[Any] = None + center_of_mass: Optional[Any] = None + center_of_propellant_mass: Optional[Any] = None + exhaust_velocity: Optional[Any] = None + grain_height: Optional[Any] = None + grain_volume: Optional[Any] = None + grain_inner_radius: Optional[Any] = None + mass_flow_rate: Optional[Any] = None + propellant_I_11: Optional[Any] = None + propellant_I_12: Optional[Any] = None + propellant_I_13: Optional[Any] = None + propellant_I_22: Optional[Any] = None + propellant_I_23: Optional[Any] = None + propellant_I_33: Optional[Any] = None + propellant_mass: Optional[Any] = None + reshape_thrust_curve: Optional[Any] = None + total_mass: Optional[Any] = None + total_mass_flow_rate: Optional[Any] = None + thrust: Optional[Any] = None class Config: json_encoders = {Any: to_python_primitive} diff --git a/lib/views/rocket.py b/lib/views/rocket.py index 5733440..691ae97 100644 --- a/lib/views/rocket.py +++ b/lib/views/rocket.py @@ -1,39 +1,42 @@ from typing import Any, Optional from pydantic import BaseModel -from lib.models.rocket import Rocket +from lib.models.rocket import Rocket, CoordinateSystemOrientation from lib.views.motor import MotorView, MotorSummary from lib.utils import to_python_primitive class RocketSummary(MotorSummary): - area: Optional[float] - center_of_mass_without_motor: Optional[float] - motor_center_of_dry_mass_position: Optional[float] - motor_position: Optional[float] - nozzle_position: Optional[float] - nozzle_to_cdm: Optional[float] - cp_eccentricity_x: Optional[float] - cp_eccentricity_y: Optional[float] - thrust_eccentricity_x: Optional[float] - thrust_eccentricity_y: Optional[float] - I_11_without_motor: Optional[Any] - I_12_without_motor: Optional[Any] - I_13_without_motor: Optional[Any] - I_22_without_motor: Optional[Any] - I_23_without_motor: Optional[Any] - I_33_without_motor: Optional[Any] - check_parachute_trigger: Optional[Any] - com_to_cdm_function: Optional[Any] - cp_position: Optional[Any] - motor_center_of_mass_position: Optional[Any] - nozzle_gyration_tensor: Optional[Any] - power_off_drag: Optional[Any] - power_on_drag: Optional[Any] - reduced_mass: Optional[Any] - stability_margin: Optional[Any] - static_margin: Optional[Any] - thrust_to_weight: Optional[Any] - total_lift_coeff_der: Optional[Any] + area: Optional[float] = None + coordinate_system_orientation: str = ( + CoordinateSystemOrientation.TAIL_TO_NOSE.value + ) + center_of_mass_without_motor: Optional[float] = None + motor_center_of_dry_mass_position: Optional[float] = None + motor_position: Optional[float] = None + nozzle_position: Optional[float] = None + nozzle_to_cdm: Optional[float] = None + cp_eccentricity_x: Optional[float] = None + cp_eccentricity_y: Optional[float] = None + thrust_eccentricity_x: Optional[float] = None + thrust_eccentricity_y: Optional[float] = None + I_11_without_motor: Optional[Any] = None + I_12_without_motor: Optional[Any] = None + I_13_without_motor: Optional[Any] = None + I_22_without_motor: Optional[Any] = None + I_23_without_motor: Optional[Any] = None + I_33_without_motor: Optional[Any] = None + check_parachute_trigger: Optional[Any] = None + com_to_cdm_function: Optional[Any] = None + cp_position: Optional[Any] = None + motor_center_of_mass_position: Optional[Any] = None + nozzle_gyration_tensor: Optional[Any] = None + power_off_drag: Optional[Any] = None + power_on_drag: Optional[Any] = None + reduced_mass: Optional[Any] = None + stability_margin: Optional[Any] = None + static_margin: Optional[Any] = None + thrust_to_weight: Optional[Any] = None + total_lift_coeff_der: Optional[Any] = None class Config: json_encoders = {Any: to_python_primitive}