qimpy.grid.FieldG
- class FieldG(grid, *, shape_batch=(), data=None)
-
Complex fields in (full) reciprocal space.
- 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 (Tensor | None) – Initial data if provided; initialize to zero otherwise
- Return type:
None
Methods
Initialize to zeros or specified data.
add_Add in-place with optional scale factor (Mirroring torch.Tensor.add_).
cloneCreate field with cloned data (deep copy).
convolveConvolve scalar field by reciprocal-space kernel_tilde.
divergenceDivergence of field.
dotCompute broadcasted inner product \(\int a^\dagger b\).
Data type for the Field type
get_origin_indexReturn 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.
gradientGradient of field.
integralCompute integral over unit cell, retaining batch dimensions in output.
laplacianLaplacian of field.
normNorm of a field, defined by \(\sqrt{\int |a|^2}\).
Offset of local grid dimensions into global grid for Field type
randomizeInitialize to MPI-reproducible standard-normal numbers, based on seed.
readRead field from cp_path.
requires_grad_Set whether gradient with respect to this object is needed.
Global grid shape for the Field type
Local grid shape (last 3 data dimensions) for the Field type
Switch field to another grid with possibly different shape.
vdotVector-space dot product of data summed over all dimensions.
writeWrite field to cp_path.
zeros_likeCreate zero Field with same grid and batch dimensions.
Attributes
Whether this represents a complex scalar field.
Whether this field is in reciprocal space.
oSlice of data corresponding to
get_origin_index().requires_gradReturn whether gradient with respect to this object is needed.
gridAssociated grid that determines dimensions of field
dataUnderlying data, with last three dimensions on grid
gradoptional gradient (of energy) with respect to this object.
- 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, …]
- to(grid)
Switch field to another grid with possibly different shape. This routine will perform Fourier resampling and MPI rearrangements, as necessary.
- 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’.)