qimpy.transport.geometry.PatchSet

class PatchSet(*, material, svg_file, svg_unit=1.0, grid_spacing, contacts, grid_size_max=0, save_rho=False, cent_diff_deriv=False, process_grid, checkpoint_in=(None, ''))

Bases: Geometry

Spatial transport starting from a SVG cubic spline specification.

Parameters:
  • material (Material)

  • svg_file (str)

  • svg_unit (float)

  • grid_spacing (float)

  • contacts (dict[str, dict | None])

  • grid_size_max (int)

  • save_rho (bool)

  • cent_diff_deriv (bool)

  • process_grid (ProcessGrid)

  • checkpoint_in (CheckpointPath)

__init__(*, material, svg_file, svg_unit=1.0, grid_spacing, contacts, grid_size_max=0, save_rho=False, cent_diff_deriv=False, process_grid, checkpoint_in=(None, ''))

Initialize PatchSet parameters.

Parameters:
  • svg_file (str) – :yaml:`Path to an SVG file containing the input geometry.

  • svg_unit (float) – [Input file] Real length corresponding to one unit of distance in SVG.

  • grid_spacing (float) – [Input file] Maximum spacing between grid points anywhere in the geometry. This is used to select the number of grid points in each domain.

  • contacts (dict[str, dict | None]) – [Input file] Dictionary of contact names to parameters. The available contact parameters depend on the contact models implemented in the corresponding material. If None, the contact is treated like a regular boundary, but stored in the checkpoint, enabling consistent plotting of ‘floating’ contacts.

  • grid_size_max (int) – [Input file] Maximum grid points per dimension after quad subdvision. If 0, will be determined automatically from number of processes. Note that this only affects parallelization and performance by changing how data is divided into patches, and does not affect the accuracy of format of the output.

  • save_rho (bool) – [Input file] Whether to write the full density matrices to the checkpoint file. If not (default), only observables are written to the checkpoint file.

  • cent_diff_deriv (bool) – [Input file] Whether to use the simple central-difference derivative operator. The default is choosing from the backward, central or forward derivative.

  • material (Material)

  • process_grid (ProcessGrid)

  • checkpoint_in (CheckpointPath)

Methods

__init__

Initialize PatchSet parameters.

add_child

Construct child object self.`attr_name` of type cls.

add_child_one_of

Invoke add_child on one of several child options in args.

boundaries_post

Accumulate edge contributions of grho_dot into appropriate domain points.

boundaries_pre

Apply all boundary conditions to rho at time t and produce ghost-padded, g=sqrt(metric)-multipled version suitable for advection.

edge_exchange

Exchange data across edges based on patch adjacency, handling communication between patches on different processes, as necessary.

rho_dot

Return list of drho/dt corresponding to each rho at time t.

save_checkpoint

Save self and all children in hierarchy to cp_path.

update_padded_velocities

Update padded velocities and riemann masks in each patch.

update_stash

Stash results for current step for a future save_checkpoint call.

Attributes

rho

Get current values of density matrices.

comm

Communicator for real-space split over patches

material

Corresponding material

grid_spacing

Grid spacing used for discretization

contacts

SVG contact names to material parameters

quad_set

Original geometry specification from SVG

sub_quad_set

Division into smaller quads for tuning parallelization

patches

Advection for each quad patch local to this process

patch_division

Division of patches over comm

stash

Saved results for collating into fewer checkpoints

dt_max

Maximum stable time step

save_rho

whether to write rho to checkpoint file

cent_diff_deriv

child_names

Names of attributes with child objects.

variant_name

Version of children having variants (if any)

boundaries_post(grho_dot_list)

Accumulate edge contributions of grho_dot into appropriate domain points. This is necessary for exact norm conservation in reflection and pass-throughs, when velocities don’t map exactly across the boundary.

Parameters:

grho_dot_list (list[tuple[Tensor, list[Tensor]]])

Return type:

None

boundaries_pre(rho_list, t)

Apply all boundary conditions to rho at time t and produce ghost-padded, g=sqrt(metric)-multipled version suitable for advection. The list contains the data for each patch.

Parameters:
Return type:

list[Tensor]

edge_exchange(edge_list_in, velocity_mode=False)

Exchange data across edges based on patch adjacency, handling communication between patches on different processes, as necessary. If velocity_mode is True, the edge data is vectorial along the short axis of the edges, as used for communication of velocities, and hence changes sign when the short axis is flipped across a pass-through edge.

Parameters:
  • edge_list_in (list[list[Tensor]])

  • velocity_mode (bool)

Return type:

list[list[Tensor | None]]

rho_dot(rho, t)

Return list of drho/dt corresponding to each rho at time t.

Parameters:
Return type:

TensorList

update_padded_velocities()

Update padded velocities and riemann masks in each patch.