Skip to content

particula.execution.multivapor_parcel

CUDA conditional-graph solver for the finite multivapor parcel.

The resident coordinates are pressure, temperature and analytical material masses. Each RHS reconstructs its finite gas inventories by conservation. This formulation and embedded solvers are independent of the Radau oracle, which integrates the gas reservoirs explicitly.

Classes

NameDescription
ParcelReplayCheckpointAccepted SI restart boundary with finite reservoirs and counters.
ResidentMultiVaporParcelPrepare one isolated device workspace for a constant-updraft parcel.

Functions

NameDescription
run_multivapor_cudaRun resident RK23 or ROS3 with observations at the requested times.

ParcelReplayCheckpointclassdataclass#

class ParcelReplayCheckpoint(identity: dict, time: float, height: float, pressure: float, temperature: float, masses: np.ndarray, vapor: np.ndarray, coordinates: np.ndarray, next_step: float, counters: tuple[int, ...], completed_segments: int)

Accepted SI restart boundary with finite reservoirs and counters.

completed_segmentsattributeinstance attribute#

completed_segments: int

coordinatesattributeinstance attribute#

coordinates: np.ndarray

countersattributeinstance attribute#

counters: tuple[int, ...]

heightattributeinstance attribute#

height: float

identityattributeinstance attribute#

identity: dict

massesattributeinstance attribute#

masses: np.ndarray

next_stepattributeinstance attribute#

next_step: float

pressureattributeinstance attribute#

pressure: float

temperatureattributeinstance attribute#

temperature: float

timeattributeinstance attribute#

time: float

vaporattributeinstance attribute#

vapor: np.ndarray

__init__method#

def __init__(identity: dict, time: float, height: float, pressure: float, temperature: float, masses: np.ndarray, vapor: np.ndarray, coordinates: np.ndarray, next_step: float, counters: tuple[int, ...], completed_segments: int) -> None

loadmethodclassmethod#

def load(path)

Read detached numeric arrays without initializing a device.

savemethod#

def save(path)

Save an accepted parcel to an atomic numeric restart archive.

ResidentMultiVaporParcelclass#

class ResidentMultiVaporParcel(initial, *, device, adaptive, timestep, updraft, phase_exchange=True)

Prepare one isolated device workspace for a constant-updraft parcel.

_arraysattributeinstance attribute#

_arrays = []

_countsattributeinstance attribute#

_counts = upload(initial.number.reshape(1, -1))

_densityattributeinstance attribute#

_density = upload(initial.density)

_lanesattributeinstance attribute#

_lanes = upload(self.lanes, wp.int32)

_m0attributeinstance attribute#

_m0 = upload(initial.masses)

_propsattributeinstance attribute#

_props = upload(
  np.column_stack(
    (
      self.rhs.gas_r,
      self.rhs.latent,
      self.rhs.p0,
      self.rhs.t0,
      self.rhs.diffusivity * self.rhs.enabled
    )
  )
)

_q0attributeinstance attribute#

_q0 = upload(initial.vapor)

_scaleattributeinstance attribute#

_scale = upload(self.scale)

bindingattributeinstance attribute#

binding = initial.activity_strategy.bind_device((1, nclass, nmat), self.lanes, self.device)

boundary_readbacksattributeinstance attribute#

boundary_readbacks = 0

clockattributeinstance attribute#

clock = upload([0.0, self.timestep, self.timestep, self.timestep])

condattributeinstance attribute#

cond = zeros(1, wp.int32)

controlsattributeinstance attribute#

controls = adaptive

countersattributeinstance attribute#

counters = zeros(5, wp.int32)

deltaattributeinstance attribute#

delta = zeros(1)

deviceattributeinstance attribute#

device = wp.get_device(device)

graphattributeinstance attribute#

graph = capture.graph

initialattributeinstance attribute#

initial = initial

initial_yattributeinstance attribute#

initial_y = np.r_[1.0, 1.0, initial.masses[:, self.lanes] / self.scale.ravel()]

invalidattributeinstance attribute#

invalid = zeros(1, wp.int32)

jacattributeinstance attribute#

jac = zeros((self.n, self.n))

jac_baseattributeinstance attribute#

jac_base = zeros(self.n) if getattr(self.binding, 'hybrid', False) else self.f0

lanesattributeinstance attribute#

lanes = self.rhs.targets

massesattributeinstance attribute#

masses = zeros((1, nclass, nmat))

nattributeinstance attribute#

n = 2 + nclass * nv

nclassattributeinstance attribute#

nclass = nclass

phase_exchangeattributeinstance attribute#

phase_exchange = bool(phase_exchange)

pivotsattributeinstance attribute#

pivots = zeros(self.n, wp.int32)

replay_secondsattributeinstance attribute#

replay_seconds = 0.0

rhsattributeinstance attribute#

rhs = ParcelTendencies(initial, updraft, phase_exchange)

rosattributeinstance attribute#

ros = isinstance(adaptive, ParcelROS3)

scaleattributeinstance attribute#

scale = np.maximum(
  initial.masses[:, self.lanes],
  np.maximum(initial.masses.sum(axis=1, keepdims=True) * 1e-06, 1e-30)
)

scratch_bytesattributeinstance attribute#

scratch_bytes = sum((a.size * wp.types.type_size_in_bytes(a.dtype) for a in self._arrays))

segmentsattributeinstance attribute#

segments = 0

timeattributeinstance attribute#

time = 0.0

timestepattributeinstance attribute#

timestep = float(timestep)

updraftattributeinstance attribute#

updraft = float(updraft)

vaporattributeinstance attribute#

vapor = zeros(nv)

yattributeinstance attribute#

y = upload(self.initial_y)

__init__method#

def __init__(initial, *, device, adaptive, timestep, updraft, phase_exchange=True)

Allocate bounded scratch and capture the non-advancing trial.

_decodemethod#

def _decode(y)

_fluxesmethod#

def _fluxes()

_iterationmethod#

def _iteration()

_launchmethod#

def _launch(kernel, n, *inputs)

_ratemethod#

def _rate(state, out, stage, *, linearize=False)

_trialmethod#

def _trial()

_unpackmethod#

def _unpack(state, stage)

advancemethod#

def advance(stop)

Replay to an absolute time, then read observation and status.

checkpointmethod#

def checkpoint()

Copy an accepted boundary and next step for recapture.

identitymethod#

def identity()

Record the material, thermophysical, solver and device identities.

restoremethod#

def restore(checkpoint)

Validate restart coordinates and identity before device writes.

run_multivapor_cudafunction#

def run_multivapor_cuda(initial, time, updraft, phase_exchange, device, adaptive)

Run resident RK23 or ROS3 with observations at the requested times.