@@ -145,8 +145,6 @@ class Flight:
145
145
Current integration state vector u.
146
146
Flight.postProcessed : bool
147
147
Defines if solution data has been post processed.
148
- Flight.retrievedAcceleration: bool
149
- Defines if acceleration data has been retrieved from the integration scheme.
150
148
Flight.retrievedTemporaryValues: bool
151
149
Defines if temporary values have been retrieved from the integration scheme.
152
150
Flight.calculatedRailButtonForces: bool
@@ -639,7 +637,6 @@ def __init__(
639
637
self .impactState = np .array ([0 ])
640
638
self .parachuteEvents = []
641
639
self .postProcessed = False
642
- self .retrievedAcceleration = False
643
640
self .retrievedTemporaryValues = False
644
641
self .calculatedRailButtonForces = False
645
642
self .calculatedGeodesicCoordinates = False
@@ -1128,18 +1125,18 @@ def __init_post_process_variables(self):
1128
1125
"""Initialize post-process variables."""
1129
1126
# Initialize all variables created during Flight.postProcess()
1130
1127
# Important to do so that MATLAB® can access them
1131
- self .windVelocityX = Function (0 )
1132
- self .windVelocityY = Function (0 )
1133
- self .density = Function (0 )
1134
- self .pressure = Function (0 )
1135
- self .dynamicViscosity = Function (0 )
1136
- self .speedOfSound = Function (0 )
1137
- self .ax = Function (0 )
1138
- self .ay = Function (0 )
1139
- self .az = Function (0 )
1140
- self .alpha1 = Function (0 )
1141
- self .alpha2 = Function (0 )
1142
- self .alpha3 = Function (0 )
1128
+ self ._windVelocityX = Function (0 )
1129
+ self ._windVelocityY = Function (0 )
1130
+ self ._density = Function (0 )
1131
+ self ._pressure = Function (0 )
1132
+ self ._dynamicViscosity = Function (0 )
1133
+ self ._speedOfSound = Function (0 )
1134
+ self ._ax = Function (0 )
1135
+ self ._ay = Function (0 )
1136
+ self ._az = Function (0 )
1137
+ self ._alpha1 = Function (0 )
1138
+ self ._alpha2 = Function (0 )
1139
+ self ._alpha3 = Function (0 )
1143
1140
self ._speed = Function (0 )
1144
1141
self ._maxSpeed = 0
1145
1142
self ._maxSpeedTime = 0
@@ -1156,12 +1153,12 @@ def __init_post_process_variables(self):
1156
1153
self ._phi = Function (0 )
1157
1154
self ._theta = Function (0 )
1158
1155
self ._psi = Function (0 )
1159
- self .R1 = Function (0 )
1160
- self .R2 = Function (0 )
1161
- self .R3 = Function (0 )
1162
- self .M1 = Function (0 )
1163
- self .M2 = Function (0 )
1164
- self .M3 = Function (0 )
1156
+ self ._R1 = Function (0 )
1157
+ self ._R2 = Function (0 )
1158
+ self ._R3 = Function (0 )
1159
+ self ._M1 = Function (0 )
1160
+ self ._M2 = Function (0 )
1161
+ self ._M3 = Function (0 )
1165
1162
self ._aerodynamicLift = Function (0 )
1166
1163
self ._aerodynamicDrag = Function (0 )
1167
1164
self ._aerodynamicBendingMoment = Function (0 )
@@ -1744,6 +1741,49 @@ def w3(self):
1744
1741
extrapolation = "natural" ,
1745
1742
)
1746
1743
1744
+ # Process second type of outputs - accelerations components
1745
+ @cached_property
1746
+ def ax (self ):
1747
+ ax , ay , az , alpha1 , alpha2 , alpha3 = self .__retrieved_acceleration_arrays ()
1748
+ # Convert accelerations to functions
1749
+ ax = Function (ax , "Time (s)" , "Ax (m/s2)" )
1750
+ return ax
1751
+
1752
+ @cached_property
1753
+ def ay (self ):
1754
+ ax , ay , az , alpha1 , alpha2 , alpha3 = self .__retrieved_acceleration_arrays ()
1755
+ # Convert accelerations to functions
1756
+ ay = Function (ay , "Time (s)" , "Ay (m/s2)" )
1757
+ return ay
1758
+
1759
+ @cached_property
1760
+ def az (self ):
1761
+ ax , ay , az , alpha1 , alpha2 , alpha3 = self .__retrieved_acceleration_arrays ()
1762
+ # Convert accelerations to functions
1763
+ az = Function (az , "Time (s)" , "Az (m/s2)" )
1764
+ return az
1765
+
1766
+ @cached_property
1767
+ def alpha1 (self ):
1768
+ ax , ay , az , alpha1 , alpha2 , alpha3 = self .__retrieved_acceleration_arrays ()
1769
+ # Convert accelerations to functions
1770
+ alpha1 = Function (alpha1 , "Time (s)" , "α1 (rad/s2)" )
1771
+ return alpha1
1772
+
1773
+ @cached_property
1774
+ def alpha2 (self ):
1775
+ ax , ay , az , alpha1 , alpha2 , alpha3 = self .__retrieved_acceleration_arrays ()
1776
+ # Convert accelerations to functions
1777
+ alpha2 = Function (alpha2 , "Time (s)" , "α2 (rad/s2)" )
1778
+ return alpha2
1779
+
1780
+ @cached_property
1781
+ def alpha3 (self ):
1782
+ ax , ay , az , alpha1 , alpha2 , alpha3 = self .__retrieved_acceleration_arrays ()
1783
+ # Convert accelerations to functions
1784
+ alpha3 = Function (alpha3 , "Time (s)" , "α3 (rad/s2)" )
1785
+ return alpha3
1786
+
1747
1787
# Process fourth type of output - values calculated from previous outputs
1748
1788
1749
1789
# Kinematics functions and values
@@ -1766,8 +1806,6 @@ def maxSpeed(self):
1766
1806
# Accelerations
1767
1807
@cached_property
1768
1808
def acceleration (self ):
1769
- if self .retrievedAcceleration is not True :
1770
- self .__retrieve_acceleration_array
1771
1809
acceleration = (self .ax ** 2 + self .ay ** 2 + self .az ** 2 ) ** 0.5
1772
1810
acceleration .setOutputs ("Acceleration Magnitude (m/s²)" )
1773
1811
return acceleration
@@ -2230,27 +2268,33 @@ def attitudeFrequencyResponse(self):
2230
2268
def staticMargin (self ):
2231
2269
return self .rocket .staticMargin
2232
2270
2233
- # Define initialization functions for post process variables
2271
+ # Define initialization functions for post process variables
2234
2272
2235
- def __retrieve_acceleration_array (
2236
- self , interpolation = "spline" , extrapolation = "natural"
2237
- ):
2238
- """Retrieve acceleration array from the integration scheme
2273
+ @cached_property
2274
+ def __retrieved_acceleration_arrays (self ):
2275
+ """Retrieve acceleration arrays from the integration scheme
2239
2276
2240
2277
Parameters
2241
2278
----------
2242
- interpolation : str, optional
2243
- Selected model for interpolation, by default "spline"
2244
- extrapolation : str, optional
2245
- Selected model for extrapolation, by default "natural"
2246
2279
2247
2280
Returns
2248
2281
-------
2249
- None
2282
+ ax: list
2283
+ acceleration in x direction
2284
+ ay: list
2285
+ acceleration in y direction
2286
+ az: list
2287
+ acceleration in z direction
2288
+ alpha1: list
2289
+ angular acceleration in x direction
2290
+ alpha2: list
2291
+ angular acceleration in y direction
2292
+ alpha3: list
2293
+ angular acceleration in z direction
2250
2294
"""
2251
2295
# Initialize acceleration arrays
2252
- self . ax , self . ay , self . az = [], [], []
2253
- self . alpha1 , self . alpha2 , self . alpha3 = [], [], []
2296
+ ax , ay , az = [], [], []
2297
+ alpha1 , alpha2 , alpha3 = [], [], []
2254
2298
# Go through each time step and calculate accelerations
2255
2299
# Get flight phases
2256
2300
for phase_index , phase in self .timeIterator (self .flightPhases ):
@@ -2266,27 +2310,17 @@ def __retrieve_acceleration_array(
2266
2310
# Get derivatives
2267
2311
uDot = currentDerivative (step [0 ], step [1 :])
2268
2312
# Get accelerations
2269
- ax , ay , az = uDot [3 :6 ]
2270
- alpha1 , alpha2 , alpha3 = uDot [10 :]
2313
+ ax_value , ay_value , az_value = uDot [3 :6 ]
2314
+ alpha1_value , alpha2_value , alpha3_value = uDot [10 :]
2271
2315
# Save accelerations
2272
- self .ax .append ([step [0 ], ax ])
2273
- self .ay .append ([step [0 ], ay ])
2274
- self .az .append ([step [0 ], az ])
2275
- self .alpha1 .append ([step [0 ], alpha1 ])
2276
- self .alpha2 .append ([step [0 ], alpha2 ])
2277
- self .alpha3 .append ([step [0 ], alpha3 ])
2278
-
2279
- # Convert accelerations to functions
2280
- self .ax = Function (self .ax , "Time (s)" , "Ax (m/s2)" , interpolation )
2281
- self .ay = Function (self .ay , "Time (s)" , "Ay (m/s2)" , interpolation )
2282
- self .az = Function (self .az , "Time (s)" , "Az (m/s2)" , interpolation )
2283
- self .alpha1 = Function (self .alpha1 , "Time (s)" , "α1 (rad/s2)" , interpolation )
2284
- self .alpha2 = Function (self .alpha2 , "Time (s)" , "α2 (rad/s2)" , interpolation )
2285
- self .alpha3 = Function (self .alpha3 , "Time (s)" , "α3 (rad/s2)" , interpolation )
2316
+ ax .append ([step [0 ], ax_value ])
2317
+ ay .append ([step [0 ], ay_value ])
2318
+ az .append ([step [0 ], az_value ])
2319
+ alpha1 .append ([step [0 ], alpha1_value ])
2320
+ alpha2 .append ([step [0 ], alpha2_value ])
2321
+ alpha3 .append ([step [0 ], alpha3_value ])
2286
2322
2287
- self .retrievedAcceleration = True
2288
-
2289
- return None
2323
+ return ax , ay , az , alpha1 , alpha2 , alpha3
2290
2324
2291
2325
def __retrieve_temporary_values_arrays (
2292
2326
self , interpolation = "spline" , extrapolation = "natural"
@@ -2607,10 +2641,6 @@ def postProcess(self, interpolation="spline", extrapolation="natural"):
2607
2641
None
2608
2642
"""
2609
2643
2610
- # Process second type of outputs - accelerations
2611
- if self .retrievedAcceleration is not True :
2612
- self .__retrieve_acceleration_array ()
2613
-
2614
2644
# Process third type of outputs - temporary values calculated during integration
2615
2645
if self .retrievedTemporaryValues is not True :
2616
2646
self .__retrieve_temporary_values_arrays ()
0 commit comments