Repository navigation
BUG: Prevent center-of-mass derivative spikes at ignition and burnout - #1214
zakariyaghazzol wants to merge 4 commits into
Conversation
Gui-FernandesBR
left a comment
There was a problem hiding this comment.
Two blocking points (a ValueError on near-equal knots and the Pylint step) and five smaller ones, each as an inline comment.
The three Pytest (*, 3.14) failures are test_set_elevation_open_elevation (Open-Elevation API), which this diff does not touch. The 3.10 jobs were still running when I checked.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1214 +/- ##
===========================================
+ Coverage 86.87% 87.00% +0.13%
===========================================
Files 131 131
Lines 18326 18419 +93
===========================================
+ Hits 15920 16026 +106
+ Misses 2406 2393 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@Gui-FernandesBR, I went through your comments and pushed the revision. The offset paths use one helper now, motors report their own time knots, and the sampled |
@zakariyaghazzol , could you kindly mark each comment as "resolved" please? |
@Gui-FernandesBR Done |
MateusStano
left a comment
There was a problem hiding this comment.
Thank you for working on this! I think there's a much simpler fix here though.
We could just discretize com_to_cdm_function with:
self.com_to_cdm_function.set_discrete(start, end, 1000, "linear", "constant")This should be inside evaluate_com_to_cdm_function.
These would be very few lines, and no new public methods. I believe it would not affect simulation results and might even make it faster... it would be nice to see some numbers though
Use the existing discretization method and include known mass and tank time ranges. See RocketPy-Team#1185.
Addresses #1185.
Current behavior
For a callable CM offset, taking a second difference across ignition or
burnout can produce an acceleration spike that grows as the difference
step gets smaller.
New behavior
Use the existing
set_discrete(start, end, 1000, "linear", "constant")inside
evaluate_com_to_cdm_function. The range includes the motor burninterval, available mass/position sample ranges, and declared tank-flux
intervals. This avoids freezing the offset while a tank continues flowing
after thrust ends.
The current diff changes one production method and adds no public methods.
The earlier derivative helpers and Motor APIs are no longer part of the
diff against develop. Their commits are kept in the branch history.
The public offset uses a 1,000-point uniform grid, so its
.sourceand.x_arraycan have different sample times from the inputs. Linearinterpolation gives zero second derivative between points. This removes
the divergence, but does not preserve the smooth curvature of the original
mass-fraction expression or model an impulse at a slope change.
Comparison
Native Windows 11, Python 3.14.3. Seven sequential runs per version after
warm-up, with rotating order and single-thread BLAS settings. All three
use develop
b389b43cas common code; the previous-approach column usesthe production changes from
4e79d51c.Inputs and solver settings match across versions:
rtol=1e-6,atol=1e-3, no maximum step-size limit, and termination atapogee. Imports and result analysis are excluded from timing.
Apogee above ground, metres
Median setup plus flight time, milliseconds
This includes rocket/environment construction and the sampling cost, not
just the Flight calculation.
For the delayed-ignition fixture, a fixed airborne-state check at the
ignition instant gave vertical accelerations of -32525.592,
-9.847 and -9.843 m/s² respectively. At burnout they were
3807.149, -9.901 and -9.901 m/s². These are numerical
endpoint probes at the same state, not on-rail launch accelerations.
These are local measurements, not a guarantee of identical trajectories
or a speedup for every rocket. Sampling bounds matter when tank flow
extends beyond the burn interval.
Testing
On the published revision
428881df:66 skipped. Three rendering tests were separated from this run.
2 skipped.
Windows Application Control. The same import fails on unchanged develop.
Rendering coverage is not verified locally.
The tests include airborne ignition/burnout with near-equal tank/motor
times, bounds extending beyond burnout, empty/solid/liquid/hybrid motors,
and a common-time offset comparison retaining the existing 1 mm tolerance.
The roll-report test retains an exact-zero simulator check and allows
roundoff only in the interpolated report.
The new hosted checks require maintainer approval and have started zero
jobs. No hosted result is claimed for this revision yet.