particula.optics.gpu.shortwave
Batched scalar shortwave transfer on a caller-selected Warp device.
The azimuthal quadrature and static BRDFs are prepared once. Device kernels recompute layer scattering, adding/doubling, and interface fluxes as optical properties change. See Hansen & Travis (1974), doi:10.1007/BF00168069.
Classes
| Name | Description |
|---|---|
ShortwaveWorkspace | Retained inputs, launch commands and latest results on one stream. |
Functions
| Name | Description |
|---|---|
_angles | No description. |
_column_layout | No description. |
_device_stream | No description. |
_integration | No description. |
_moments | No description. |
_quadrature | No description. |
_reference_indices | No description. |
_sequence | No description. |
_tile_size | No description. |
_upload_boundary | No description. |
prepare_shortwave | Prepare independent column/wavelength solves with reusable scratch. |
ShortwaveWorkspaceclassdataclass#
class ShortwaveWorkspace(layers: LayerData, flux: wp.array, broadband: wp.array | None, broadband_delta: wp.array | None, radiance: wp.array | None, band_radiance: wp.array | None, status: wp.array, _commands: tuple, _resources: tuple, _columns: tuple, _suns: tuple, _surfaces: tuple, _view: tuple | None, _stream: wp.Stream | None, _ready: bool = False)Retained inputs, launch commands and latest results on one stream.
Attributes
| Name | Type | Description |
|---|---|---|
layers | LayerData | Writable dimensionless depth, albedo (case, layer, wavelength) and normalized moments with an additional Legendre degree axis. |
flux | wp.array | (case, interface, wavelength) vec3d of physical direct down, diffuse down and upwelling densities in W m⁻² m⁻¹. |
broadband | wp.array | None | (case, interface) vec3d of those fluxes in W m⁻². None for a single wavelength without quadrature widths. |
broadband_delta | wp.array | None | Optional (case, interface) vec3d of broadband case minus reference fluxes in W m⁻², in broadband field order. |
radiance | wp.array | None | (case, wavelength) emergent W m⁻² sr⁻¹ m⁻¹ if a view was requested. Defined after enqueue and a successful check. |
band_radiance | wp.array | None | Optional (case,) response mean in W m⁻² sr⁻¹ m⁻¹. |
status | wp.array | (case, wavelength) integers. Zero means success, one invalid layer data, two a nonfinite result, negative an incomplete angular solve. Check before consuming device outputs. |
_columnsattributeinstance attribute#
_columns: tuple_commandsattributeinstance attribute#
_commands: tuple_readyattributeclass attributeinstance attribute#
_ready: bool = False_resourcesattributeinstance attribute#
_resources: tuple_streamattributeinstance attribute#
_stream: wp.Stream | None_sunsattributeinstance attribute#
_suns: tuple_surfacesattributeinstance attribute#
_surfaces: tuple_viewattributeinstance attribute#
_view: tuple | Noneband_radianceattributeinstance attribute#
band_radiance: wp.array | Nonebroadbandattributeinstance attribute#
broadband: wp.array | Nonebroadband_deltaattributeinstance attribute#
broadband_delta: wp.array | Nonefluxattributeinstance attribute#
flux: wp.arraylayersattributeinstance attribute#
layers: LayerDataradianceattributeinstance attribute#
radiance: wp.array | Nonestatusattributeinstance attribute#
status: wp.array__init__method#
def __init__(layers: LayerData, flux: wp.array, broadband: wp.array | None, broadband_delta: wp.array | None, radiance: wp.array | None, band_radiance: wp.array | None, status: wp.array, _commands: tuple, _resources: tuple, _columns: tuple, _suns: tuple, _surfaces: tuple, _view: tuple | None, _stream: wp.Stream | None, _ready: bool = False) -> Nonecheckmethod#
def check()Synchronize and raise RuntimeError on missing or failed results.
downloadmethod#
def download()Download spectral results in case order.
Returns
tuple[ShortwaveFlux, ...]- Detached CPU results for each case.
Raises
RuntimeError- If no solve has run or a device result failed.
enqueuemethod#
def enqueue()Queue transport on the prepared stream, overwriting prior results.
_anglesfunction#
def _angles(streams, fourier_order, relative_azimuth_deg, view_zenith_deg)_column_layoutfunction#
def _column_layout(columns, sun, surface)_device_streamfunction#
def _device_stream(device, stream)_integrationfunction#
def _integration(suns, sensor_response, has_view)_momentsfunction#
def _moments(cols, nl, nw, streams, delta_m)_quadraturefunction#
def _quadrature(sun)_reference_indicesfunction#
def _reference_indices(columns, suns, indices)_sequencefunction#
def _sequence(values, cls, count)_tile_sizefunction#
def _tile_size(case_tile, lanes, n, nl)_upload_boundaryfunction#
def _upload_boundary(suns, surfaces, mu, weight, modes, limit, device)prepare_shortwavefunction#
def prepare_shortwave(columns, sun, surface, *, device, stream=None, streams=8, view_zenith_deg=None, relative_azimuth_deg=0.0, fourier_order=None, delta_m=True, case_tile=None, reference_cases=None, sensor_response=None)Prepare independent column/wavelength solves with reusable scratch.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
columns | SpectralColumn | Sequence[SpectralColumn] | required | One SpectralColumn or a sequence with equal wavelength grids and layer counts. Interface heights may vary between columns. |
sun | SolarInput | Sequence[SolarInput] | required | SolarInput shared by all columns or one per column. |
surface | Surface | Sequence[Surface] | required | Shared surface or a sequence of spectral surface boundaries. |
device | str | warp.Device | required | Explicit Warp CPU or CUDA device. No automatic fallback. |
stream | warp.Stream | None | None | Optional CUDA stream on device. Input updates and consumers must use this stream or explicit inter-stream ordering. |
streams | int | 8 | Gauss–Legendre ordinates per hemisphere, 2 through 16. |
view_zenith_deg | float | None | None | Optional outgoing zenith angle [0, 90) in degrees. |
relative_azimuth_deg | float | 0.0 | Surface Sun–observer azimuth difference [deg]. |
fourier_order | int | None | None | Maximum azimuthal harmonic, default 2 * streams - 1. |
delta_m | bool | True | Apply delta-M if a next phase moment is available. |
case_tile | int | None | None | Maximum concurrent column/wavelength lanes. The default targets 32 MiB of layer scratch and up to 4096 lanes. |
reference_cases | ArrayLike | None | None | Optional integer reference index for each case. Paired cases need matching heights and integration coordinates. |
sensor_response | ArrayLike | None | None | Optional nonnegative energy response on the grid. Requires a view and wavelength integration widths. |
Returns
ShortwaveWorkspace- Retained layer and boundary data. Use enqueue() after updating inputs. Use download() for detached CPU results.
Raises
ValueError- If shapes, geometry, stream, or quadrature are invalid.