Computational Physics Workflows
Start with an equation and an independent physical check. These nine examples include editable assumptions, admitted input ranges, labeled plots with smoothing disabled, and numerical…
Computational physics workflows
Start with an equation and an independent physical check. These nine examples include editable assumptions, admitted input ranges, labeled plots with smoothing disabled, and numerical comparisons. Their variables are dimensionless except where a plot or formula states a unit. They are small teaching investigations, not general-purpose validation of a physical model.
Open Docs → Examples, search for physics-, and open an example as a model.
Named outputs appear in I/O even when the model has few worksheet cells. The
library's output count uses explicit output declarations when available.
| Starter | Change | Check before interpreting the result |
|---|---|---|
| Damped oscillator | Damping from 0.1 to 0.4 | Compare every sampled displacement and the first falling zero with the analytical solution. Damping 0–0.8 and frequency 1–4 keep this example underdamped. |
| Kepler orbit | Eccentricity from 0.6 to 0.3 | Check orbit closure, specific energy and angular momentum over one period; GM and semimajor axis are one. |
| Heat diffusion | End time from 0.1 to 0.05 | Compare 21/41/81 spatial nodes, the continuum sine solution, and the discrete mode. Tighten time integration separately from spatial refinement. |
| Quantum square well | Well width from 1 to 1.5 | Check negative off-diagonals, a small eigenvector residual and unit absolute overlap with the discrete sine mode. Energies use a fixed scale with ℏ²/(2m)=1, so they vary as inverse width squared. |
| Blackbody radiation | Upper cutoff from 40 to 20 | Compare the integral with π⁴/15 and the omitted-tail bound. The peak is for radiance per frequency; radiance per wavelength has a different peak. |
| Stiff relaxation | End time from 1 to 0.5 | Inspect actual method, work and controls. Compare terminal states with the exact solution and a tighter solve. |
| Decay inference | Synthetic noise scale from 1 to 1.5 | Inspect residuals, Jacobian rank and conditional local uncertainty. The synthetic perturbation is fixed; the example does not draw a new random sample on each edit. |
| Spectral aliasing | Sample rate from 128 to 32 Hz | The 20 Hz tone aliases to 12 Hz. Check total integrated power 2.125. Only these two bin-centered sample rates are admitted. |
| Localized quadrature | Peak width from 0.0001 to 0.0002 | Compare an unsplit integral, an integral restricted to the known peak, and width × √π. A terminated unsplit solve can miss the peak entirely. |
Complete an oscillator investigation
- Open the oscillator and inspect
MaximumTrajectoryErrorandFirstZero - ExactFirstZero. The starter already plots the numerical and analytical curves with straight segments between samples. - In I/O, save the current assumptions as an input scenario named Baseline.
Set
Dampingto 0.4. Observe the changed trajectory and compare its errors. An out-of-range value is rejected with an explanation. - Select
Comparisonand choose Plot selection to create another plot. Choose the first column for time and the second for numerical displacement. Add the third column as a reference series in the chart editor if desired. This uses the existing numeric array directly and preserves its global name. - Preview the Baseline scenario, inspect the proposed input changes, and restore it. Scenarios preserve input overrides and require matching authored source and package versions; they do not rewind execution history or external systems.
- Save a
.gridocarchive and reopen it. The archive carries the source, inputs, chart configuration and saved scenario assets. Recheck the same physical outputs after reopening.
Read reports and recover from failures
Fit and ODE records have compact summaries in the grid and I/O. Select a result and use its inspector for the complete explanation and full-precision copy. Opening the report displays the existing value; it does not request another numerical solve. A compact summary does not certify convergence or accuracy. Rank deficiency and unavailable uncertainty remain visible. Unsupported report schemas receive a neutral summary and retain the complete value for inspection.
ODE_REPORT(..., {format: "record"}) exposes named method, termination, controls,
state and work fields. Omitting format retains the established numeric row.
The stiff starter explicitly requests the record. Completion means the requested
interval ended; local tolerances are not a bound on global trajectory error.
ODE failures retain their error codes and explain the cause. Budget exhaustion reports the stopping time, requested method and configured limit, and states that the interval was not completed. Inspect scaling, stiffness, domains and controls before deliberately changing a budget. Grid does not silently alter your method or tolerances. Cancellation keeps its existing cancellation signal.
For general real-matrix eigenvalues, use EIGEN.VALUES.COMPLEX; each result
has real and imaginary components. SVD computes singular values and vectors,
which answer a different question. This does not promise general eigenvectors.
Source warnings are distinct from errors in the inspector. A negative-power
warning offers explicit alternatives: -(x^2) negates the square, while
(-x)^2 squares the negative value. Choose deliberately; no formula is rewritten
automatically. If a scientific name resembles a spreadsheet address, follow the
diagnostic's underscore suggestion, such as Spectrum_20.
Accuracy is an authored investigation
Keep three quantities separate: requested local tolerance, error relative to an independently justified reference, and change under refinement. The diffusion and stiff examples compute all three explicitly. A small estimated integration error cannot detect structure that was never sampled. Use known subintervals or a justified restricted domain for a localized integrand, and account for omitted tails. These comparisons run because the model author requested them.