Skip to main content

Module sim

Module sim 

Source
Expand description

Running several domains at once.

A domain is a piece of physics that can be stepped: heat in a block of glass, a rigid body under contact, light through a train of surfaces. Each one knows its own equations and nothing about the others. This module is how they share a clock and a budget without knowing about each other.

§The timescale problem, which is the real one

Domains do not agree on how big a step is. An explicit FDTD electromagnetic solver on a nanometre grid is stable to about 10⁻¹⁷ s; heat conduction to about 10⁻⁹ s; rigid contact to 10⁻⁴ s; and a thermal drift that defocuses an instrument plays out over seconds. Stepping all of them at the smallest limit integrates the slow ones ten billion times for nothing.

Two mechanisms deal with that, and they are the reason this module is not just a for loop over domains:

  • Kind::QuasiStatic — a domain with no state to roll forward, which is re-solved on demand instead of stepped. Light crosses an instrument in nanoseconds; against a thermal timescale that is zero, so optics is not integrated at all. This is the largest single saving available, and it is what the closed-form Motion and the instantaneous SurfaceOptics were already doing before there was a scheduler to notice.
  • Schedule::Multirate — each evolving domain takes as many equal substeps of the shared window as its own stability limit requires, so the slow domain is not dragged down to the fast one’s step.

§Coupling, and why it goes through a bus

Domains never touch each other. They publish to and consume from an Exchange, which is a set of named channels carrying SI amounts. That is not only a borrow-checker convenience: it is what makes the transfer auditable. Each domain conserves energy internally, but the interface between two discretisations of the same surface — ray hits on one side, mesh nodes on the other — is exactly where interpolation quietly loses or invents some. The bus compares what was published against what was consumed and refuses to let the difference pass silently.

§What the schedules cost

Schedule::OneWay is unconditionally stable and embarrassingly parallel, because nothing feeds back. Schedule::Staggered costs one exchange per step and is stable only while the coupling is weak — and not fixable by shrinking dt, since some strongly coupled systems (the standard example is fluid-structure interaction at comparable densities, the added-mass effect) become more unstable as the step shrinks. That is what Schedule::Iterative is for, and why it is worth its cost.

Structs§

Exchange
The channel between domains: named quantities, in SI base units.
Report
What one Simulation::advance actually did.
Simulation
A set of domains sharing a clock.

Enums§

Kind
Whether a domain has state to roll forward.
Schedule
How the domains are interleaved.

Traits§

Domain
One piece of physics.