mf6rtm.simulation package

Submodules

mf6rtm.simulation.discretization module

This module contains the Discretization functions for various ModFlow grid types.

mf6rtm.simulation.discretization.grid_dimensions(modflow_api)
Return type:

tuple[int, ...]

mf6rtm.simulation.discretization.total_cells_in_grid(modflow_api)
Return type:

int

mf6rtm.simulation.mf6api module

class mf6rtm.simulation.mf6api.Mf6API(wd, dll)

Bases: ModflowApi

property grid_type: str

Grid type of the ModFlow6 model

mf6rtm.simulation.phreeqcbmi module

class mf6rtm.simulation.phreeqcbmi.PhreeqcBMI(yaml='mf6rtm.yaml')

Bases: BMIPhreeqcRM

get_grid_to_map()

Function to get grid to map

set_scalar(var_name, value)

mf6rtm.simulation.solver module

The solver module provides the Mf6RTM class that couples modflowapi and phreeqcrm, along with functions to run the coupled simulations.

class mf6rtm.simulation.solver.Mf6RTM(wd, mf6api, phreeqcbmi)

Bases: object

get_saturation_from_mf6()

Get the saturation

Parameters:

(modflowapi) (mf6)

Returns:

array

Return type:

dict[Any, ndarray]

get_time_units_from_mf6()

Function to get the time units from mf6

Return type:

str

is_reactive_tstep()

Check if the current timestep should be reactive based on configuration.

Returns:

True if current timestep should be reactive, False otherwise

Return type:

bool

print_warning_user_active()

Prints a warning if reaction timing is set to ‘user’.

set_emulator_output_add_variables()

Add emulator target and feature variables to the output.

Updates selected_output with variables defined in the configuration. Defaults to empty lists if not provided.

selected_output.target_var

Target variables for emulator training.

Type:

list of str

selected_output.feat_var

Feature variables for emulator training.

Type:

list of str

Return type:

None

set_emulator_training()

Configure emulator training output.

Reads emulator_training_data from the configuration. If enabled, sets up emulator output variables; otherwise disables training data.

ml_output

Whether emulator training data output is enabled.

Type:

bool

Return type:

None

set_kiter()
Return type:

int

set_time_conversion()

Function to set the time conversion factor

Return type:

None

solve()

Solve the model

Return type:

bool

mf6rtm.simulation.solver.check_config_file(wd)
Return type:

tuple[PathLike, PathLike]

mf6rtm.simulation.solver.check_nam_files(wd)

Check if the nam files are present in the model directory

Return type:

tuple[PathLike, PathLike]

mf6rtm.simulation.solver.get_conc_change_mask(ci, ck, ncomp, nxyz, treshold=1e-10)

Function to get the active-inactive cell mask for concentration change to inform phreeqc which cells to update

Return type:

ndarray[float64]

mf6rtm.simulation.solver.get_inactive_idx(arr, val=1e+30)

Function to get the index of all occurrences of <0 in an array

mf6rtm.simulation.solver.get_less_than_zero_idx(arr)

Function to get the index of all occurrences of <0 in an array

mf6rtm.simulation.solver.initialize_interfaces(wd, nthread=1, libname=None)

Function to initialize the interfaces for modflowapi and phreeqcrm and returns the mf6rtm object

Return type:

Mf6API

mf6rtm.simulation.solver.longest_common_substring(strings)

Function to find the longest common substring of a list of strings Used here to find the common “stem” of the GWT model names for matching with PhreeqcRM components.

mf6rtm.simulation.solver.mrbeaker()

ASCII art of Mr. Beaker

Return type:

str

mf6rtm.simulation.solver.prep_to_run(wd, libname=None)

Prepares the model to run by checking if the model directory (wd) contains the necessary files and returns the path to the yaml file (phreeqcrm) and the dll file (mf6 api)

Parameters:

wd (PathLike) – The path to the working directory of model directory

Returns:

The path to the phreeqcrm model file (yaml) and the path to the MODFLOW 6 dll (associated with mf6api).

Return type:

tuple[PathLike, PathLike]

mf6rtm.simulation.solver.run_cmd(cwd=None)

Console entrypoint compatibility wrapper.

When used as a console script the entrypoint calls mf6rtm:run_cmd with no arguments. Allow cwd to be optional and default to the current working directory.

Return type:

None

mf6rtm.simulation.solver.set_nthread_yaml(yamlfile, nthread=1)

Function to set the number of threads in the yaml file

Return type:

None

mf6rtm.simulation.solver.solve(wd, reactive=None, nthread=1, libname=None)

Wrapper to prepare and call solve functions

Return type:

bool

Module contents

Main module to manage the APIs PHREEQCRM and MODFLOW6 API, and solve the reactive transport loop

class mf6rtm.simulation.Mf6API(wd, dll)

Bases: ModflowApi

property grid_type: str

Grid type of the ModFlow6 model

class mf6rtm.simulation.Mf6RTM(wd, mf6api, phreeqcbmi)

Bases: object

get_saturation_from_mf6()

Get the saturation

Parameters:

(modflowapi) (mf6)

Returns:

array

Return type:

dict[Any, ndarray]

get_time_units_from_mf6()

Function to get the time units from mf6

Return type:

str

is_reactive_tstep()

Check if the current timestep should be reactive based on configuration.

Returns:

True if current timestep should be reactive, False otherwise

Return type:

bool

print_warning_user_active()

Prints a warning if reaction timing is set to ‘user’.

set_emulator_output_add_variables()

Add emulator target and feature variables to the output.

Updates selected_output with variables defined in the configuration. Defaults to empty lists if not provided.

selected_output.target_var

Target variables for emulator training.

Type:

list of str

selected_output.feat_var

Feature variables for emulator training.

Type:

list of str

Return type:

None

set_emulator_training()

Configure emulator training output.

Reads emulator_training_data from the configuration. If enabled, sets up emulator output variables; otherwise disables training data.

ml_output

Whether emulator training data output is enabled.

Type:

bool

Return type:

None

set_kiter()
Return type:

int

set_time_conversion()

Function to set the time conversion factor

Return type:

None

solve()

Solve the model

Return type:

bool

class mf6rtm.simulation.PhreeqcBMI(yaml='mf6rtm.yaml')

Bases: BMIPhreeqcRM

get_grid_to_map()

Function to get grid to map

set_scalar(var_name, value)
mf6rtm.simulation.run_cmd(cwd=None)

Console entrypoint compatibility wrapper.

When used as a console script the entrypoint calls mf6rtm:run_cmd with no arguments. Allow cwd to be optional and default to the current working directory.

Return type:

None

mf6rtm.simulation.solve(wd, reactive=None, nthread=1, libname=None)

Wrapper to prepare and call solve functions

Return type:

bool