qimpy.grid.FieldC
- class FieldC(grid, *, shape_batch=(), data=None)
-
Complex fields in real 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 (Optional[Tensor]) – 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_).
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\).
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 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.
Global grid shape for the Field type
Local grid shape (last 3 data dimensions) for the Field type
Switch field to another grid with same 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
Whether this represents a complex scalar field.
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, …]
- to(grid)
Switch field to another grid with same shape. The new grid can only differ in the MPI split.
- data: torch.Tensor
Underlying data, with last three dimensions on grid
- grad: GradientType
optional gradient (of energy) with respect to this object.
- 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’.)