T05: Scientific and aerospace-related computing
On this page
- A. Prerequisites and observable goals
- B. The central question: what exactly does this simulation claim to represent?
- C. Units and nondimensionalization reduce hidden mistakes
- D. Derive conservation laws before testing them
- E. Velocity Verlet uses acceleration at both ends
- F. Interpret the measured validation rather than a pretty curve
- G. Independent practice
- H. Complete solutions: T05
- I. Retention and readiness
A. Prerequisites and observable goals#
Calculus I–III motion and vector fields; A05 numerical error; A06 ODE integration; A01 vectors; C14 reproducibility.
Construct a nondimensional motion model, derive conserved quantities, validate a numerical orbit against an analytic solution, and distinguish model error from discretization and roundoff error.
Level: Advanced-entry track. A bounded idealized orbit, not mission design, flight software, or a validated aerospace tool.
B. The central question: what exactly does this simulation claim to represent?#
A scientific simulation begins with a model, its assumptions, inputs, units, numerical method, and validation target. A visually plausible trajectory is not enough. A game may deliberately sacrifice physical fidelity for responsiveness; a scientific calculation must state which physical quantities and accuracy requirements it aims to preserve. Neither purpose is inherently wrong, but their evidence standards differ.
Consider a point particle moving under a fixed central inverse-square attraction in a plane. Let position be , velocity , and parameter . The model is
It ignores extended bodies, collisions, atmospheric drag, propulsion, relativistic effects, and perturbations from other bodies. The origin is singular. A numerical step approaching it needs careful handling; the small circular example intentionally stays far away. We do not insert real planetary constants or claim ephemeris accuracy.
C. Units and nondimensionalization reduce hidden mistakes#
If position has units of length and time has units of time, then has units length/time, so acceleration has length/time. Choose a reference length and time scale . Writing and gives
The nondimensional model has parameter one. This does not change the physics of the specified idealization; it changes units and often improves numerical scale. Record the conversion back to physical quantities rather than mixing nondimensional coordinates with seconds or meters later.
For , initial position and velocity have exact circular solution , and period . Differentiate twice to verify the acceleration is , and note that radius remains one. This analytic solution supplies a stronger validation target than a plotted loop that merely appears closed.
D. Derive conservation laws before testing them#
Specific mechanical energy is
Since , differentiating energy gives
The planar specific angular momentum is . Its derivative is , because the two velocity-product terms cancel. Central acceleration is parallel to , so this cross product is zero. For the unit circular initial state, and .
A conserved quantity is a diagnostic, not a complete solution oracle. A method could maintain nearly constant energy while accumulating phase error. Therefore check position error against the known circle, energy variation, angular momentum variation, and convergence under step refinement. Each catches a different failure mode.
E. Velocity Verlet uses acceleration at both ends#
For acceleration depending on position, velocity Verlet advances
The position update uses a second-order local Taylor idea. The velocity update averages endpoint accelerations. For smooth conservative mechanical systems with fixed steps, this method has useful geometric properties and second-order global accuracy under the usual regularity conditions. It does not exactly conserve the original energy for every finite step or make singular trajectories safe.
Compare it with forward Euler on an oscillator, which can systematically increase energy. A higher-order method can reduce error, but method selection also considers long-time qualitative behavior, stability, cost, and event handling. Adaptive step sizes and close encounters require additional analysis rather than simply changing whenever a plotted curve looks bad.
The companion records every state together with energy and angular momentum, rejects the singular initial origin, and uses synthetic nondimensional inputs. It is a small reference implementation for reasoning and validation, not a general orbital propagator.
F. Interpret the measured validation rather than a pretty curve#
The reference experiment used and 1000 steps, one nominal circular period. It recorded final position approximately , position error , maximum absolute energy deviation , and maximum absolute angular-momentum deviation in this environment. Tiny energy variation coexists with a larger phase-related position error, illustrating why one invariant is not enough.
Separate three errors. Modeling error comes from omitted or inaccurate physical assumptions. Discretization error comes from replacing continuous evolution with finite steps. Roundoff error comes from bounded arithmetic. Step refinement can diagnose discretization behavior but cannot fix a wrong force law or units. Agreement between two implementations of the same wrong equation is not physical validation.
For reproducibility, preserve source revision, units, parameters, initial conditions, step policy, final time, tolerances, environment, and raw diagnostics. A scientific report should explain whether comparisons use analytic truth, a higher-accuracy numerical reference, or observational data, because those are different evidence sources. Safety-critical use requires domain-specific verification, validation, and organizational processes far beyond this exercise.
G. Independent practice#
F foundation C standard course work T transfer S optional stretch L runnable lab or project. Attempt the complete set before opening its solutions.
Verify directly that satisfies the nondimensional central-force equation for all real . Compute its energy and angular momentum.
Starting from with , write the velocity-Verlet position after one step of size . Then express the next acceleration and velocity update without replacing them by Euler’s update.
A simulation has energy error below but misses the expected final position by . Is that logically inconsistent? Explain what additional diagnostic is needed and identify one mistake that reducing the time step cannot repair.
A method is in a regime with global error approximately . If an error is at step , predict the error at and explain why observing that ratio on one pair of runs is evidence, not a proof of the order for all problems.
Implement starters/orbit_lab.py: central acceleration, energy and angular momentum diagnostics, and velocity-Verlet integration. Validate the unit circular case over a nominal period, compare two step sizes, and report all three error measures. Keep the model nondimensional and reject the singular origin.
Optional small hints
For T05.01, radius is exactly one. For T05.02, the new acceleration must be evaluated at the new position. For T05.03, conservation and phase accuracy are different properties.
H. Complete solutions: T05#
Compare the first step where your work differs. A corrected answer is not yet an independent success.
T05.01Show solution
Substitute into the original differential equation
and , so . Velocity is with squared speed one. Energy is . Angular momentum is . The radius never vanishes, so the equation’s domain condition holds. This verifies the full trajectory, not merely its initial state.
Back to T05.01T05.02Show solution
Use both endpoint accelerations
Initial acceleration is . Thus . Let . Then and
Using only the initial acceleration for velocity would give a different method. The expression preserves the distinction between a position update and a velocity update, and the denominator is nonzero for real because the two position components cannot both vanish.
Back to T05.02T05.03Show solution
A conserved scalar does not locate the state uniquely
There is no contradiction. Many positions and velocities can share the same energy; even a nearly circular trajectory can be shifted in phase. Compare position and velocity against an analytic or independently justified reference at the same times, and inspect phase or period error. A wrong unit conversion, initial condition, or force model cannot be repaired merely by smaller steps: the method may converge accurately to the wrong modeled problem.
Back to T05.03T05.04Show solution
A second-order prediction has a restricted meaning
Halving predicts one quarter the error, , if the leading term dominates and other assumptions remain comparable. A single ratio can be affected by cancellation, roundoff, a special initial condition, or a reference error. Test several refinements and verify regularity, stability, and a common final time. Theoretical order is a mathematical statement under hypotheses; a convergence experiment is evidence that the implementation behaves accordingly in the tested regime.
Back to T05.04T05.05Show solution
Complete validated idealized orbit
The reference computes new acceleration only after obtaining the new position, then averages old and new accelerations for velocity. Diagnostics are stored from the initial state onward. The tests compare selected circular cases and refinement behavior; this does not validate omitted physical forces or arbitrary close approaches to the singularity.
"""T05.05: nondimensional two-body orbit with velocity Verlet."""
import math
def acceleration(position, mu=1.0):
x, y = position
r = math.hypot(x, y)
if not math.isfinite(r) or r == 0 or not math.isfinite(mu) or mu <= 0:
raise ValueError("finite nonzero radius and positive mu required")
return (-mu * x / r**3, -mu * y / r**3)
def diagnostics(position, velocity, mu=1.0):
x, y = position
vx, vy = velocity
r = math.hypot(x, y)
if r == 0: raise ValueError("singular origin")
return (0.5 * (vx*vx + vy*vy) - mu / r, x*vy - y*vx)
def orbit(dt=0.01, steps=1000, mu=1.0, position=(1., 0.), velocity=(0., 1.)):
if type(steps) is not int or steps < 1 or not math.isfinite(dt) or dt <= 0:
raise ValueError("positive finite step and integer step count required")
if any(not math.isfinite(x) for x in (*position, *velocity)):
raise ValueError("finite initial state required")
p, v = tuple(position), tuple(velocity)
out = [(0., p, v, *diagnostics(p, v, mu))]
for i in range(steps):
a = acceleration(p, mu)
next_p = tuple(p[j] + dt*v[j] + 0.5*dt*dt*a[j] for j in range(2))
next_a = acceleration(next_p, mu)
v = tuple(v[j] + 0.5*dt*(a[j] + next_a[j]) for j in range(2))
p = next_p
out.append(((i + 1)*dt, p, v, *diagnostics(p, v, mu)))
return out
if __name__ == "__main__":
data = orbit(dt=2*math.pi/1000, steps=1000)
print("one nominal circular period:", data[-1])I. Retention and readiness#
Retrieve vector derivatives, units, numerical stability, and the distinction between invariants and full correctness. Readiness requires reproducing an analytic case and defending an error budget. Continue with deeper ODEs, numerical analysis, mechanics, uncertainty quantification, and domain-specific scientific validation before using a simulation for consequential aerospace decisions.