qimpy.transport.geometry.Patch

class Patch(*, transformation, grid_size_tot, grid_start, grid_stop, is_reflective, has_apertures, aperture_circles, contact_circles, contact_params, material, cent_diff_deriv, checkpoint_in=(None, ''))

Bases: object

Quad-patch with real-space advection on an arbitrary transformation.

Parameters:
  • transformation (Callable[[torch.Tensor], torch.Tensor])

  • grid_size_tot (tuple[int, ...])

  • grid_start (tuple[int, ...])

  • grid_stop (tuple[int, ...])

  • is_reflective (np.ndarray)

  • has_apertures (np.ndarray)

  • aperture_circles (torch.Tensor)

  • contact_circles (torch.Tensor)

  • contact_params (list[dict])

  • material (Material)

  • cent_diff_deriv (bool)

  • checkpoint_in (CheckpointPath)

__init__(*, transformation, grid_size_tot, grid_start, grid_stop, is_reflective, has_apertures, aperture_circles, contact_circles, contact_params, material, cent_diff_deriv, checkpoint_in=(None, ''))
Parameters:
  • transformation (Callable[[Tensor], Tensor])

  • grid_size_tot (tuple[int, ...])

  • grid_start (tuple[int, ...])

  • grid_stop (tuple[int, ...])

  • is_reflective (ndarray)

  • has_apertures (ndarray)

  • aperture_circles (Tensor)

  • contact_circles (Tensor)

  • contact_params (list[dict])

  • material (Material)

  • cent_diff_deriv (bool)

  • checkpoint_in (CheckpointPath)

Return type:

None

Methods

__init__

rho_dot

Compute g*rho_dot, given current g*rho.

save_checkpoint

Save observables, and optionally density matrix, to checkpoint.

Attributes

q

Nx x Ny x 2 Cartesian coordinates

g

Nx x Ny x 1 sqrt(metric), with extra dimensipm for broadcasting

V

Nx x Ny x Nkbb x 2 mesh-coordinate velocities

Vedges

Relevant velocity component along each edge

Vpadded

Padded mesh-coordinate velocities

riemann_masks

Cached riemann selection masks

dt_max

Maximum stable time step

wk

Integration weight for the flattened density matrix dimensions

rho_offset

Offset of density matrix data within that of quad

rho_shape

Shape of density matrix on patch

rho

current density matrix on this patch

advect

Underlying advection logic

cent_diff_deriv

material

aperture_selections

Aperture indices for each edge

reflectors

Material-dependent reflector for each edge that needs one

contacts

Contact calculators (multiple possibly) by edge

edge_masks

Masks for zeroing edge flux by axis

rho_dot(grho)

Compute g*rho_dot, given current g*rho. The input is ghost-padded, while the output contains the contributions within the domain and the edge contributions that must be reflected/passed-through.

Parameters:

grho (Tensor)

Return type:

tuple[Tensor, list[Tensor]]

save_checkpoint(cp_path, observables, save_rho)

Save observables, and optionally density matrix, to checkpoint.

Parameters:
Return type:

None

V: Tensor

Nx x Ny x Nkbb x 2 mesh-coordinate velocities

Vedges: list[Tensor]

Relevant velocity component along each edge

Vpadded: tuple[Tensor, Tensor]

Padded mesh-coordinate velocities

advect: ScriptModule

Underlying advection logic

aperture_selections: list[Tensor | None]

Aperture indices for each edge

contacts: list[list[Contact]]

Contact calculators (multiple possibly) by edge

dt_max: float

Maximum stable time step

edge_masks: tuple[list[bool | Tensor], list[bool | Tensor]]

Masks for zeroing edge flux by axis

g: Tensor

Nx x Ny x 1 sqrt(metric), with extra dimensipm for broadcasting

q: Tensor

Nx x Ny x 2 Cartesian coordinates

reflectors: list[Callable[[Tensor], Tensor] | None]

Material-dependent reflector for each edge that needs one

rho: Tensor

current density matrix on this patch

rho_offset: tuple[int, ...]

Offset of density matrix data within that of quad

rho_shape: tuple[int, ...]

Shape of density matrix on patch

riemann_masks: tuple[Tensor, Tensor]

Cached riemann selection masks

wk: float

Integration weight for the flattened density matrix dimensions