space

Define initial space grid.

class space.SpaceGrid(params, default_params, work_dir, logger)[source]

Bases: object

Store initial domain dimensions.

Variables:
  • default_params (dict) – Parameters used when not specified in user input.

  • geometry (str) – Domain geometry (‘planar’, ‘cylindrical’ or ‘spherical’).

  • work_dir (pathlib.Path) – Work directory.

  • logger (log_utils.CustomLogger) – Logger.

  • zmin (float) – Initial position of left-hand domain boundary (m).

  • zmax (float) – Initial position of right-hand domain boundary (m).

  • nz_init (int) – Number of steps in initial space grid.

  • z_init (1D array) – Initial node positions. Ranges from 0 to zmax, size nz. This is where fluxes are evaluated.

  • dz_init (1D array) – Initial space step, shape (nz - 1,).

  • zm_init (1D array) – Initial midpoint positions, shape (nz - 1,). This is where composition variables are evaluated.

__init__(params, default_params, work_dir, logger)[source]

Class constructor.

make_grid(params)[source]

Make initial space grid from input file or parameters.

If ‘file’ is given, the grid is read from work_dir/filename using np.genfromtxt, and zmin, zmax and nz are inferred from the grid. If not, see make_grid_from_dict().

Raises:

utils.UserInputError – If params contains both ‘file’ and space parameters.

make_grid_from_dict(params)[source]

Make grid from parameters.

The type of grid is specified via the optional parameter ‘grid_type’, which can be ‘linear’ or ‘geometric’ and defaults to ‘linear’ :

  • ‘linear’: linear grid from zmin to zmax with size nz.

  • ‘geometric’: geometric grid from zmin to zmax with size nz and common ratio q.

In both cases :

  • ‘zmax’ must be included in input

  • ‘zmin’ is optional and defaults to 0

  • ‘nz’ is optional and defaults to value in default_params (can be set in ‘user_data.toml’).

  • ‘q’ is optional and defaults to value in default_params.

Raises:
space.geo_grid(zmin, zmax, nz, q)[source]

Make space grid according to geometric progression.

Parameters:
  • zmin (float) – Start position.

  • zmax (float) – End position.

  • nz (int) – Number of elements.

  • q (float) – Common ratio.

Returns:

Geometric grid.

Return type:

1D array