export interface CflSliderProps { value: number; onChange: (v: number) => void; /** Largest stable step, when known, to show the resulting dt */ dtMax?: number; min?: number; max?: number; disabled?: boolean; } /** * The time step as a fraction of the stability limit. Past 1 the explicit * scheme amplifies its shortest waves every step, and the run blows up within * a few dozen steps; the slider colours that region so it is not a surprise. */ export function CflSlider({ value, onChange, dtMax, min = 0.5, max = 1.2, disabled, }: CflSliderProps) { const unstable = value > 1; const pct = ((1 - min) / (max - min)) * 100; return (
onChange(Number(e.target.value))} style={{ background: `linear-gradient(to right, #cfe0f5 0%, #cfe0f5 ${pct}%, #f5c6c6 ${pct}%, #f5c6c6 100%)`, }} aria-label="time step as a fraction of the stability limit" /> {value.toFixed(2)} dtmax
{dtMax !== undefined ? ( <> dt = {(value * dtMax * 1e6).toPrecision(3)} µs (limit {(dtMax * 1e6).toPrecision(3)}{" "} µs).{" "} ) : null} {unstable ? ( Above the limit: the run will diverge. ) : ( "Stable below 1." )}
); }