qimpy.grid.FieldH

class FieldH(grid, *, shape_batch=(), data=None)

Bases: Field[FieldH]

Real fields in (half) reciprocal space. Note that the underlying data is complex in reciprocal space, but reduced to one half of reciprocal space using Hermitian symmetry.

Parameters
  • grid (Grid) –

  • shape_batch (Sequence[int]) –

  • data (Optional[torch.Tensor]) –

__init__(grid, *, shape_batch=(), data=None)

Initialize to zeros or specified data.

Parameters
  • grid (Grid) – Associated grid, which determines last three dimensions of data

  • shape_batch (Sequence[int]) – Optional preceding batch dimensions for vector fields, arrays of scalar fields etc. Not used if data is provided.

  • data (Optional[Tensor]) – Initial data if provided; initialize to zero otherwise

Return type

None

Methods

__init__

Initialize to zeros or specified data.

add_

Add in-place with optional scale factor (Mirroring torch.Tensor.add_).

clone

Create field with cloned data (deep copy).

convolve

Convolve scalar field by reciprocal-space kernel_tilde.

divergence

Divergence of field.

dot

Compute broadcasted inner product \(\int a^\dagger b\).

dtype

Data type for the Field type

get_origin_index

Return index into local data of the spatial index = 0 component(s), which corresponds to r = 0 for real-space fields and to the G = 0 component for reciprocal-space fields.

gradient

Gradient of field.

integral

Compute integral over unit cell, retaining batch dimensions in output.

laplacian

Laplacian of field.

norm

Norm of a field, defined by \(\sqrt{\int |a|^2}\).

offset_grid_mine

Offset of local grid dimensions into global grid for Field type

read

Read field from cp_path.

requires_grad_

Set whether gradient with respect to this object is needed.

shape_grid

Global grid shape for the Field type

shape_grid_mine

Local grid shape (last 3 data dimensions) for the Field type

symmetrize

Symmetrize field in-place.

to

Switch field to another grid with possibly different shape.

vdot

Vector-space dot product of data summed over all dimensions.

write

Write field to cp_path.

zeros_like

Create zero Field with same grid and batch dimensions.

Attributes

is_complex

Whether this represents a complex scalar field.

is_tilde

Whether this field is in reciprocal space.

o

Slice of data corresponding to get_origin_index().

requires_grad

Return whether gradient with respect to this object is needed.

dtype()

Data type for the Field type

Return type

dtype

offset_grid_mine()

Offset of local grid dimensions into global grid for Field type

Return type

tuple[int, …]

shape_grid()

Global grid shape for the Field type

Return type

tuple[int, …]

shape_grid_mine()

Local grid shape (last 3 data dimensions) for the Field type

Return type

tuple[int, …]

symmetrize()

Symmetrize field in-place.

Return type

None

to(grid)

Switch field to another grid with possibly different shape. This routine will perform Fourier resampling and MPI rearrangements, as necessary.

Parameters

grid (Grid) –

Return type

FieldH

data: torch.Tensor

Underlying data, with last three dimensions on grid

grad: GradientType

optional gradient (of energy) with respect to this object.

grid: Grid

Associated grid that determines dimensions of field

property is_complex: bool

Whether this represents a complex scalar field. Note that a real scalar field has complex Fourier transform coefficients, but would still be considered real here (i.e. this is False for FieldH).

property is_tilde: bool

Whether this field is in reciprocal space. (Corresponding variable names are typically suffixed by ‘_tilde’.)