HASEonGPU.Simulation
- class HASEonGPU.Simulation(gainMedium, pump, phiASE, timeIntegrationSolver, timeStep, crossSections=None, endTime=None, constants=<factory>, enableAse=True, prePump=False)
Bases:
objectHigh-level pump, ASE, fluorescence, and time-integration loop.
Register
onInitorbeforeStepcallbacks when a function needs the liveSimulationobject and may inspect or mutate it. RegisteronStepcallbacks when a function needs the completedTimeStepStatesnapshot produced by each step.- Parameters:
gainMedium (GainMedium)
pump (PumpProperties)
phiASE (PhiASE)
timeIntegrationSolver (TimeIntegrationSolver)
timeStep (float)
crossSections (CrossSectionData | None)
endTime (float | None)
constants (Constants)
enableAse (bool)
prePump (bool)
- gainMedium: GainMedium
Geometry, material data, and current beta arrays.
- pump: PumpProperties
Pump model that adds population to
betaCells.
- timeIntegrationSolver: TimeIntegrationSolver
Solver object that advances
betaCellsusingd beta / dt.
- timeStep: float
Physical time increment per step, in seconds.
- crossSections: CrossSectionData | None = None
Shared spectra used by pump and ASE when not set on either object.
- endTime: float | None = None
Optional target physical time for
runUntil().
- enableAse: bool = True
Whether each derivative evaluation runs ASE depletion through
PhiASE.
- prePump: bool = False
When true, the first time step advances without ASE so pump can seed beta.
- onStep(callback, *args, **kwargs)
Register a post-step callback.
The callback signature is
callback(state, *args, **kwargs).Simulationalways supplies the completedTimeStepStateas the first argument, then appends the positional and keyword arguments passed toonStep. For example,simulation.onStep(write_vtk, output_dir, scale=5.5)callswrite_vtk(state, output_dir, scale=5.5)after every completed step.Use this hook for logging, writing VTK files, explicit state storage, or other work that should consume the immutable step snapshot. Callback return values are ignored. The method returns
selfso registrations can be chained.
- onInit(callback, *args, **kwargs)
Register a one-time initialization callback.
The callback signature is
callback(simulation, *args, **kwargs).Simulationsupplies the live simulation object as the first argument, then appends the user arguments passed toonInit. The hook runs once, immediately before the first step is evaluated.Use this hook to initialize or normalize mutable simulation inputs such as
gainMedium,pump,phiASE, ortimeStep. Callback return values are ignored. The method returnsselffor chaining.
- beforeStep(callback, *args, **kwargs)
Register a pre-step callback.
The callback signature is
callback(simulation, *args, **kwargs).Simulationsupplies the live simulation object as the first argument, then appends the user arguments passed tobeforeStep. The hook runs before every step, after one-timeonInitcallbacks.Use this hook for controlled changes that must happen before derivative evaluation, such as time-dependent pump settings. Callback return values are ignored. The method returns
selffor chaining.
- runUntil(endtime=None, endTime=None, *, openpmdSession=None)
Advance steps until the configured or supplied end time is reached.
- runSteps(steps, pumpSteps=None, *, openpmdSession=None)
Run exactly
stepscalls tostep()and returnself.pumpStepsoptionally limits the pump contribution to the firstpumpStepscalls in this run. When omitted,PumpPropertiesmay provide apumpStepscustom property. If neither is set, the pump is active for every step, matching the historicalrunSteps(steps)behavior.PumpProperties.pumpSubstepsis separate: it controls the internal pump integration resolution inside one pumped simulation step.
- step(*, openpmdSession=None)
Advance one time step and return the completed
TimeStepState.
- getLastState()
Return the most recent completed
TimeStepStatesnapshot.
- getResults()
Return the most recent completed
TimeStepStatesnapshot.Simulationdoes not retain a full time-step history. Register anonStepcallback to write or store per-step state explicitly.
- property lastState
Most recent completed
TimeStepStatesnapshot.
- property time
Current physical simulation time in seconds.
- property stepIndex
Number of completed time steps.