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,BCsMixin- 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.Fieldobject. 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
fieldis a Field object.
- Returns
Assembled global array on rank 0; returns
Noneon 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.Fieldon 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
Noneon 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.Fileobject 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
SolverFIT3Dinstance 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.Fileis returned for caller-managed operations.
- Returns
Open file object when
closeis False, otherwise None.- Return type
h5py.File or None
- update_logger(attrs)[source]ο
Copy selected solver attributes into the internal
Loggerobject.- 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,imuorsigmaare modified this routine reconstructs the corresponding sparse diagonal matrices and the composite operator products used in the update equations. Use thetensorargument 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.