Input/output#

Setup modules#

struphy.io.setup.import_parameters_py(params_path: str) ModuleType[source]#

Import a .py parameter file under the module name ‘parameters’ and return it.

struphy.io.setup.setup_folders(path_out: str, restart: bool, verbose: bool = False)[source]#

Setup output folders.

struphy.io.setup.setup_derham(grid: TensorProductGrid, options: DerhamOptions, comm: Intracomm | None = None, domain: Domain | None = None, verbose=False)[source]#

Creates the 3d derham sequence for given grid parameters.

Parameters:
  • grid (TensorProductGrid) – The FEEC grid.

  • comm (Intracomm) – MPI communicator (sub_comm if clones are used).

  • domain (Domain, optional) – The Struphy domain object for evaluating the mapping F : [0, 1]^3 –> R^3 and the corresponding metric coefficients.

  • verbose (bool) – Show info on screen.

Returns:

derham – Discrete de Rham sequence on the logical unit cube.

Return type:

struphy.feec.psydac_derham.Derham

struphy.io.setup.descend_options_dict(d: dict, out: list | dict, *, d_default: dict | None = None, d_opts: dict | None = None, keys: list | None = None, depth: int = 0, pop_again: bool = False, verbose: bool = False)[source]#

Create all possible parameter dicts from a model options dict, by looping through options.

If d_default=None, will return the default parameter dict of a model (takes first list entries of options dict).

Otherwise, will go through all sub-dicts of the options dict recursively and check whether a value is a list (i.e. different options are available). If True, creates one parameter dict for each value in the list, with all other parameters set to their defaults.

Parameters:
  • d (dict) – The (sub)-dict to investigate.

  • out (list or dict) – The ouptut, must be passed as empty list. During recursion, if list: Holds one parameter dict for each option. If dict: the default parameters.

  • d_default (dict) – The default parameter dict of the model. If passed as None, the default parameter dict will be returned.

  • d_opts (dict) – A copy of “d” created at first call (when d_opts is None).

  • keys (list) – The keys to the options in the options dict. The last entry is the lowest-level key. This list is filled automatically during recursion.

  • depth (int) – The length of d from the previous recursion.

  • pop_again (bool) – Whether to pop one more time from keys; this is automatically set to True when depth is reached during recursion.

  • verbose (bool) – Show some output on screen.

Data modules#

class struphy.io.output_handling.DataContainer(path_out, file_name=None, comm=None)[source]#

Creates/opens a hdf5 file for data ouput (each process locally).

Parameters:
  • path_out (str) – Path to hdf5 data files.

  • file_name (str, optional) – Name of hdf5 file.

  • comm (MPI communicator)

property file_name#

The hdf5 file name.

property file#

The hdf5 file.

property dset_dict#

Dictionary with dataset keys and object IDs.

add_data(data_dict)[source]#

Add data object to be saved during simulation.

Parameters:

data_dict (dict) – Name-object pairs to save during time stepping, e.g. {key : val}. key must be a string and val must be a xp.array of fixed shape. Scalar values (floats) must therefore be passed as 1d arrays of size 1.

save_data(keys=None)[source]#

Save data objects to hdf5 file.

Parameters:

keys (list) – Keys to the data objects specified when using “add_data”. Default saves all specified data objects.

info()[source]#

Print info of data sets to screen.