44import warnings
55from copy import deepcopy
66from functools import cached_property
7- from ..motors .pointmassmotor import PointMassMotor
8- from ..rocket import PointMassRocket
7+
98import numpy as np
109import simplekml
1110from scipy .integrate import BDF , DOP853 , LSODA , RK23 , RK45 , OdeSolver , Radau
1211
1312from ..mathutils .function import Function , funcify_method
1413from ..mathutils .vector_matrix import Matrix , Vector
14+ from ..motors .point_mass_motor import PointMassMotor
1515from ..plots .flight_plots import _FlightPlots
1616from ..prints .flight_prints import _FlightPrints
17+ from ..rocket import PointMassRocket
1718from ..tools import (
1819 calculate_cubic_hermite_coefficients ,
1920 euler313_to_quaternions ,
@@ -1195,14 +1196,17 @@ def __init_solver_monitors(self):
11951196 def __init_equations_of_motion (self ):
11961197 """Initialize equations of motion."""
11971198 # Determine if a point-mass model is used.
1198- is_point_mass = (
1199- isinstance (self .rocket , PointMassRocket )
1200- or ( self . rocket . _motors and isinstance (self .rocket ._motors [ 0 ] , PointMassMotor ) )
1199+ is_point_mass = isinstance ( self . rocket , PointMassRocket ) or (
1200+ hasattr (self .rocket , "motor" )
1201+ and isinstance (self .rocket .motor , PointMassMotor )
12011202 )
12021203 # Set simulation mode based on model type.
12031204 if is_point_mass :
12041205 if self .simulation_mode != "3 DOF" :
1205- warnings .warn ("A point-mass model was detected. Simulation mode should be '3 DOF'." , UserWarning )
1206+ warnings .warn (
1207+ "A point-mass model was detected. Simulation mode should be '3 DOF'." ,
1208+ UserWarning ,
1209+ )
12061210 self .simulation_mode = "3 DOF"
12071211 else :
12081212 self .simulation_mode = self .simulation_mode
@@ -1213,14 +1217,15 @@ def __init_equations_of_motion(self):
12131217 self .u_dot_generalized = self .u_dot_generalized_3dof
12141218 elif self .simulation_mode == "6 DOF" :
12151219 if self .equations_of_motion == "solid_propulsion" :
1216- self .u_dot_generalized = self .u_dot_6dof
1220+ self .u_dot_generalized = self .u_dot
12171221 else :
1218- self .u_dot_generalized = self .u_dot_generalized_6dof
1222+ self .u_dot_generalized = self .u_dot_generalized
12191223 else :
12201224 raise ValueError (
12211225 f"Invalid simulation_mode: { self .simulation_mode } . "
12221226 "Must be '3 DOF' or '6 DOF'."
12231227 )
1228+
12241229 def __init_controllers (self ):
12251230 """Initialize controllers and sensors"""
12261231 self ._controllers = self .rocket ._controllers [:]
@@ -1580,17 +1585,8 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals
15801585 R3 += Z
15811586 # Linear acceleration
15821587 L = [
1583- (
1584- R1
1585-
1586- )
1587- / total_mass_at_t ,
1588- (
1589- R2
1590-
1591- )
1592- / total_mass_at_t ,
1593-
1588+ (R1 ) / total_mass_at_t ,
1589+ (R2 ) / total_mass_at_t ,
15941590 (R3 - b * propellant_mass_at_t * (alpha2 - omega1 * omega3 ) + net_thrust )
15951591 / total_mass_at_t ,
15961592 ]
@@ -1622,7 +1618,6 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals
16221618
16231619 if post_processing :
16241620 self .__post_processed_variables .append (
1625-
16261621 [
16271622 t ,
16281623 ax ,
@@ -1700,11 +1695,7 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False):
17001695 air_brake .deployment_level , mach
17011696 )
17021697 ab_force = (
1703- - 0.5
1704- * rho
1705- * free_stream_speed ** 2
1706- * air_brake .reference_area
1707- * ab_cd
1698+ - 0.5 * rho * free_stream_speed ** 2 * air_brake .reference_area * ab_cd
17081699 )
17091700 if air_brake .override_rocket_drag :
17101701 R3 = ab_force
@@ -1759,7 +1750,6 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False):
17591750 if post_processing :
17601751 self .__post_processed_variables .append (
17611752 [t , * v_dot , * w_dot , R1 , R2 , R3 , 0 , 0 , 0 ]
1762-
17631753 )
17641754
17651755 return u_dot
@@ -1769,7 +1759,7 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too
17691759 rocket is flying in 6 DOF motion in space and significant mass variation
17701760 effects exist. Typical flight phases include powered ascent after launch
17711761 rail.
1772-
1762+
17731763 Parameters
17741764 ----------
17751765 t : float
0 commit comments