Skip to main content

parse_thrust

Function parse_thrust 

Source
pub fn parse_thrust(
    id: &str,
    name: &str,
    text: &str,
    burn_time_s: Option<f64>,
    reshape: Option<(f64, f64)>,
) -> Result<(Vec<(f64, f64)>, f64), RealFlightError>
Expand description

A thrust file as RocketPy 1.13.0 reads it, with the example’s burn options.

  • An .eng file (Motor.import_eng, rocketpy/motors/motor.py:1130-1150): ; starts a comment, the first line left is the description, and each later one gives a time and a thrust; a (0, 0) point is put first. So a file whose first data line is 0 0 has that line read as its description.
  • A .csv file: every row a time and a thrust, nothing put first.
  • reshape (Motor.reshape_thrust_curve, motor.py:937-960): times scaled to the burn time and moved to start at zero, then thrusts scaled so the trapezoidal integral is the impulse.
  • The burn time (Motor.clip_thrust, motor.py:985-1024): at most the last time; the points strictly inside (0, burn time) kept, with the curve’s linear value added at each end.

hpr’s curve refuses a negative thrust, so any is read as zero, and the impulse this removes is returned with the curve.

§Errors

RealFlightError::Input for a file with no points, a line that doesn’t read, or times that decrease.