Skip to main content

Module custom

Module custom 

Source
Expand description

Drag models of your own, flown in place of hpr’s drag buildup.

A DragModel gives the whole rocket’s zero-lift drag coefficient C_D0, its drag with the air along its axis over the dynamic pressure and the reference area, at a flow. AeroModel::with_drag_model puts one in place of hpr’s drag buildup (its sum of friction, pressure, base and parasitic drag, part by part) and of any drag table (crate::table); a flight takes one through hpr_sim::Simulation::with_drag_model.

The model replaces the zero-lift drag only, as a drag table does. The rest stays hpr’s:

The coefficient is on the rocket’s reference area (DragQuery::reference_area_m2), which is the design’s: by default a circle of the largest body diameter. Unlike a drag table, which can carry the diameter it was measured on, a model’s number is not rescaled: a curve measured on another area S is multiplied by S over the reference area before it is returned.

A model is asked a DragQuery: the flow (Mach number and angles), the drag conditions (Reynolds number per meter, whether a motor is thrusting) and hpr’s own buildup at that flow, so a model can adjust hpr’s number instead of replacing it.

How far to trust it: as far as the model, and no further than hpr’s other models, which still fly the rest of the rocket. hpr refuses a coefficient that is negative or not finite; it can’t know whether the number is right.

use hpr_aero::{AeroError, AeroModel, DragConditions, DragModel, DragQuery, Flow};

/// hpr's own drag, 10% higher: a rougher finish than the design says, say.
#[derive(Debug)]
struct TenPercentMore;

impl DragModel for TenPercentMore {
    fn zero_lift_drag(&self, query: &DragQuery<'_>) -> Result<f64, AeroError> {
        Ok(1.1 * query.buildup()?.zero_lift_coefficient)
    }
}

let rocket: hpr_design::Rocket = serde_json::from_str(include_str!(
    "../../../validation/designs/rocketpy-calisto-tests-motor-at-minus-1.373.json"
))?;
let hpr = AeroModel::new(&rocket.layout()?)?;
let custom = hpr.clone().with_drag_model(TenPercentMore);

let (flow, conditions) = (Flow::axial(0.3), DragConditions::coasting(6.0e6));
let own = hpr.drag(&flow, &conditions)?.zero_lift_coefficient;
let more = custom.drag(&flow, &conditions)?.zero_lift_coefficient;
assert!((more - 1.1 * own).abs() < 1e-15);

Structs§

DragQuery
What a DragModel is asked: the flow and the drag conditions, with the rocket’s reference area, its length and hpr’s own drag buildup at hand. Made by AeroModel::drag; to try a model on its own, give it to an AeroModel and ask that for its drag.

Traits§

DragModel
A rocket’s zero-lift drag, given by a program in place of hpr’s drag buildup.