solverFIT3D module

class wakis.solverFIT3D.SolverFIT3D(grid, wake=None, cfln=0.5, dt=None, bc_low=['Periodic', 'Periodic', 'Periodic'], bc_high=['Periodic', 'Periodic', 'Periodic'], use_stl=False, use_conductors=False, use_gpu=False, use_mpi=False, dtype=np.float64, n_pml=10, bg=[1.0, 1.0], verbose=1)[source]

Bases: PlotMixin, RoutinesMixin

get_abc()[source]

Save boundary field snapshots needed by the Absorbing Boundary Condition (ABC) update.

Extracts the necessary boundary layers for electric and magnetic fields for those faces configured with ABC and returns two dictionaries holding the saved arrays. Those dictionaries are later consumed by update_abc to restore boundary values.

load_state(filename='solver_state.h5')[source]

Load dynamic solver state (H, E, J) from an HDF5 file and restore them.

Parameters

filename (str, optional) – Input HDF5 filename. Default is β€œsolver_state.h5”.

Notes

Currently performs a simple load from a single-file state. MPI-aware redistribution of loaded arrays to worker ranks is TODO.

mpi_gather(field, x=None, y=None, z=None, component=None)[source]

Gather a component or slice of a distributed Field from all MPI ranks.

Assumes the field is split along the z-axis among ranks. The function collects local buffers, removes ghost cells and concatenates rank contributions to build a global NumPy array on the root rank (rank 0).

Parameters
  • field (str or wakis.Field) – Field identifier (β€˜E’,’H’,’J’) optionally with a component suffix (e.g. β€˜Ex’), or a wakis.Field object. If no component is given the β€˜z’ component is used by default.

  • x (int or slice, optional) – Index or slice for each axis to gather. Defaults to the full range.

  • y (int or slice, optional) – Index or slice for each axis to gather. Defaults to the full range.

  • z (int or slice, optional) – Index or slice for each axis to gather. Defaults to the full range.

  • component ({'x','y','z'} or slice, optional) – Component to gather when field is a Field object.

Returns

Assembled global array on rank 0; returns None on non-root ranks.

Return type

numpy.ndarray or None

mpi_gather_asField(field)[source]

Gather distributed field data from MPI ranks and return a global Field.

Collects the full 3-component field (E, H or J) from each rank and reconstructs a single wakis.Field on the root rank. Ghost cells are removed when reassembling the per-rank buffers.

Parameters

field (str or wakis.Field) – Identifier (β€˜E’,’H’,’J’) or a Field-like object to gather.

Returns

Global Field object assembled on rank 0. Returns None on other ranks.

Return type

wakis.Field or None

read_state(filename='solver_state.h5')[source]

Open an HDF5 file for read-only access without loading its contents.

Returns an open h5py.File object that the caller must close when finished. This is useful for inspecting saved state without restoring it into the solver.

Parameters

filename (str, optional) – Input HDF5 filename. Default is β€œsolver_state.h5”.

Returns

Open HDF5 file object in read mode.

Return type

h5py.File

reset_fields()[source]

Reset dynamic field arrays (E, H, J) to zero across the simulation.

Useful when reusing a SolverFIT3D instance for a new run without reconstructing the entire object.

save_state(filename='solver_state.h5', close=True)[source]

Save dynamic solver state (H, E, J) to an HDF5 file.

Writes the core dynamic fields to filename. When running under MPI the distributed fields are gathered to the root rank before saving.

Parameters
  • filename (str, optional) – Output HDF5 filename. Default is β€œsolver_state.h5”.

  • close (bool, optional) – If True (default) the file is closed before returning. If False an open h5py.File is returned for caller-managed operations.

Returns

Open file object when close is False, otherwise None.

Return type

h5py.File or None

update_abc(E_abc, H_abc)[source]

Apply the Absorbing Boundary Condition (ABC) using previously saved snapshots.

Parameters
  • E_abc (dict) – Dictionaries produced by get_abc that contain boundary-layer field arrays. Each dictionary maps face indices to arrays used to overwrite the exterior cell values after a timestep.

  • H_abc (dict) – Dictionaries produced by get_abc that contain boundary-layer field arrays. Each dictionary maps face indices to arrays used to overwrite the exterior cell values after a timestep.

update_logger(attrs)[source]

Copy selected solver attributes into the internal Logger object.

Parameters

attrs (iterable of str) – Names of attributes to copy to self.logger.solver. Special case β€˜grid’ copies the grid logger reference instead of a value.

update_tensors(tensor='all')[source]

Update tensor matrices after material Field changes and precompute combined operators used for time-stepping.

When ieps, imu or sigma are modified this routine reconstructs the corresponding sparse diagonal matrices and the composite operator products used in the update equations. Use the tensor argument to restrict work to a single tensor for efficiency.

Parameters

tensor ({'ieps','imu','sigma','all'}, optional) – Which tensor to update. Default is β€˜all’ which recomputes every tensor and refreshes the precomputed time-stepping matrices.