pub trait DragModel:
Debug
+ Send
+ Sync {
// Required method
fn zero_lift_drag(&self, query: &DragQuery<'_>) -> Result<f64, AeroError>;
}Expand description
A rocket’s zero-lift drag, given by a program in place of hpr’s drag buildup.
Implement DragModel::zero_lift_drag and hand the model to AeroModel::with_drag_model
or hpr_sim::Simulation::with_drag_model. The flight asks it at every evaluation of the
equations of motion, several times a step, so it should be quick and give the same answer to
the same question: a flight’s determinism is only as good as its model’s. The integrator’s
trial evaluations can reach a little past the speeds the flight itself reaches, so a model
that refuses past the end of its data wants some margin beyond the top speed.
A model is shared, not copied: it is kept behind an Arc, so a model that holds a large
table costs nothing to fly many times. AeroModel::with_shared_drag_model takes an
Arc<dyn DragModel> that is already shared.
A model must not ask for the drag of an AeroModel that holds it, which would ask the model
again, without end; DragQuery::buildup is hpr’s own drag without the model.
Required Methods§
Sourcefn zero_lift_drag(&self, query: &DragQuery<'_>) -> Result<f64, AeroError>
fn zero_lift_drag(&self, query: &DragQuery<'_>) -> Result<f64, AeroError>
The whole rocket’s zero-lift drag coefficient C_D0 at query’s flow, on the rocket’s
reference area (DragQuery::reference_area_m2). From hpr’s buildup that is
Drag::zero_lift_coefficient, not Drag::axial_coefficient, which is already scaled
for the angle of attack.
§Errors
Whatever the model can’t answer, such as a Mach number past its data. The flight wraps
the error in AeroError::DragModel, so it says where it came from; an error from
DragQuery::buildup can be passed on as it is.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".