Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdsharpe committed Dec 18, 2023
1 parent 321b590 commit c4270be
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 67 deletions.
3 changes: 2 additions & 1 deletion aerosandbox/atmosphere/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __init__(self,
altitude: Flight altitude, in meters. This is assumed to be a geopotential altitude above MSL.
method: Method of atmosphere modeling to use. Either:
* "differentiable" - a C1-continuous fit to the International Standard Atmosphere; useful for optimization
* "differentiable" - a C1-continuous fit to the International Standard Atmosphere; useful for optimization.
Mean absolute error of pressure relative to the ISA is 0.02% over 0-100 km altitude range.
* "isa" - the International Standard Atmosphere, exactly reproduced
temperature_deviation: A deviation from the temperature model, in Kelvin (or equivalently, Celsius). This is useful for modeling
Expand Down
43 changes: 32 additions & 11 deletions aerosandbox/dynamics/point_mass/common_point_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def draw(self,
import aerosandbox.tools.pretty_plots as p

if vehicle_model is None:
default_vehicle_stl = _asb_root / "dynamics/visualization/default_assets/yf23.stl"
default_vehicle_stl = _asb_root / "dynamics/visualization/default_assets/talon.stl"
vehicle_model = pv.read(str(default_vehicle_stl))
elif isinstance(vehicle_model, pv.PolyData):
pass
Expand Down Expand Up @@ -478,13 +478,34 @@ def draw(self,
plotter.add_axes()
plotter.show_grid(color='gray')

### Set up interpolators for dynamics instances
from scipy import interpolate
state_interpolators = {
k: interpolate.InterpolatedUnivariateSpline(
x=np.arange(len(self)),
y=v * np.ones(len(self)),
check_finite=True,
)
for k, v in self.state.items()
}
control_interpolators = {
k: interpolate.InterpolatedUnivariateSpline(
x=np.arange(len(self)),
y=v * np.ones(len(self)),
check_finite=True,
)
for k, v in self.control_variables.items()
}

### Draw the vehicle
for i in np.unique(
np.round(
np.linspace(0, len(self) - 1, n_vehicles_to_draw)
)
).astype(np.int64):
dyn = self[i]
for i in np.linspace(0, len(self) - 1, n_vehicles_to_draw):
dyn = self.get_new_instance_with_state({
k: float(v(i))
for k, v in state_interpolators.items()
})
for k, v in control_interpolators.items():
setattr(dyn, k, float(v(i)))

try:
phi = dyn.phi
except AttributeError:
Expand All @@ -499,7 +520,7 @@ def draw(self,
psi = dyn.track

x_cg_b, y_cg_b, z_cg_b = dyn.convert_axes(
dyn.mass_props.x_cg,
dyn.mass_props.x_cg, # TODO fix this and make this per-point
dyn.mass_props.y_cg,
dyn.mass_props.z_cg,
from_axes=cg_axes,
Expand All @@ -508,9 +529,9 @@ def draw(self,

this_vehicle = copy.deepcopy(vehicle_model)
this_vehicle.translate([
-x_cg_b,
-y_cg_b,
-z_cg_b,
-np.mean(x_cg_b),
-np.mean(y_cg_b),
-np.mean(z_cg_b),
], inplace=True)
this_vehicle.points *= scale_vehicle_model
this_vehicle.rotate_x(np.degrees(phi), inplace=True)
Expand Down
7 changes: 5 additions & 2 deletions aerosandbox/numpy/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,13 @@ def reshape(a, newshape, order='C'):
if isinstance(newshape, int):
newshape = (newshape, 1)

if len(newshape) == 1:
elif len(newshape) == 1:
newshape = (newshape[0], 1)

if len(newshape) > 2:
elif len(newshape) == 2:
newshape = tuple(newshape)

elif len(newshape) > 2:
raise ValueError("CasADi data types are limited to no more than 2 dimensions.")

return _cas.reshape(a.T, newshape[::-1]).T
Expand Down

Large diffs are not rendered by default.

0 comments on commit c4270be

Please sign in to comment.