mf6rtm package¶
Subpackages¶
Subpackages:
- mf6rtm.config package
- mf6rtm.io package
- Submodules
- mf6rtm.io.externalio module
RegeneratorRegenerator.add_m0_to_config()Regenerator.generate_equilibrium_phases_blocks()Regenerator.generate_exchange_phases_blocks()Regenerator.generate_kinetic_phases_blocks()Regenerator.generate_new_script()Regenerator.read_external_files()Regenerator.read_phinp()Regenerator.regenerate_from_external_files()Regenerator.update_yaml()Regenerator.validate_external_files()Regenerator.write_new_script()
SelectedOutput
- Module contents
- mf6rtm.mup3d package
- Submodules
- mf6rtm.mup3d.base module
BlockChemStressEquilibriumPhasesExchangePhasesGasPhaseKineticPhasesMup3dMup3d.nameMup3d.wdMup3d.charge_offsetMup3d.databaseMup3d.solutionsMup3d.init_tempMup3d.equilibrium_phasesMup3d.kinetic_phasesMup3d.exchange_phasesMup3d.surfaces_phasesMup3d.postfixMup3d.phreeqc_rmMup3d.init_conc_array_phreeqcMup3d.sconcMup3d.phinpMup3d.componentsMup3d.fixed_componentsMup3d.nlayMup3d.nrowMup3d.ncolMup3d.nxyzMup3d.grid_shapeMup3d.from_mf6()Mup3d.generate_phreeqc_script()Mup3d.get_componenth2o()Mup3d.get_config()Mup3d.initialize()Mup3d.initialize_chem_stress()Mup3d.load_mup3d()Mup3d.run()Mup3d.save_config()Mup3d.save_mup3d()Mup3d.set_charge_offset()Mup3d.set_chem_stress()Mup3d.set_componenth2o()Mup3d.set_config()Mup3d.set_database()Mup3d.set_diffusion_coeff()Mup3d.set_equilibrium_phases()Mup3d.set_exchange_phases()Mup3d.set_fixed_components()Mup3d.set_initial_temp()Mup3d.set_phases()Mup3d.set_postfix()Mup3d.set_reaction_temp()Mup3d.set_wd()Mup3d.write_external_files_layered()Mup3d.write_internal_parameters()Mup3d.write_simulation()
SolutionsSurfacesworking_dir()
- Module contents
Mup3dMup3d.nameMup3d.wdMup3d.charge_offsetMup3d.databaseMup3d.solutionsMup3d.init_tempMup3d.equilibrium_phasesMup3d.kinetic_phasesMup3d.exchange_phasesMup3d.surfaces_phasesMup3d.postfixMup3d.phreeqc_rmMup3d.init_conc_array_phreeqcMup3d.sconcMup3d.phinpMup3d.componentsMup3d.fixed_componentsMup3d.nlayMup3d.nrowMup3d.ncolMup3d.nxyzMup3d.grid_shapeMup3d.from_mf6()Mup3d.generate_phreeqc_script()Mup3d.get_componenth2o()Mup3d.get_config()Mup3d.initialize()Mup3d.initialize_chem_stress()Mup3d.load_mup3d()Mup3d.run()Mup3d.save_config()Mup3d.save_mup3d()Mup3d.set_charge_offset()Mup3d.set_chem_stress()Mup3d.set_componenth2o()Mup3d.set_config()Mup3d.set_database()Mup3d.set_diffusion_coeff()Mup3d.set_equilibrium_phases()Mup3d.set_exchange_phases()Mup3d.set_fixed_components()Mup3d.set_initial_temp()Mup3d.set_phases()Mup3d.set_postfix()Mup3d.set_reaction_temp()Mup3d.set_wd()Mup3d.write_external_files_layered()Mup3d.write_internal_parameters()Mup3d.write_simulation()
- mf6rtm.simulation package
- Submodules
- mf6rtm.simulation.discretization module
- mf6rtm.simulation.mf6api module
- mf6rtm.simulation.phreeqcbmi module
- mf6rtm.simulation.solver module
- Module contents
- mf6rtm.utils package
- Submodules
- mf6rtm.utils.utils module
add_charge_flag_to_species_in_solution()check_phreeqcrm_status()concentration_l_to_m3()concentration_m3_to_l()concentration_to_massrate()concentration_volbulk_to_volwater()fill_missing_minerals()flatten_list()generate_equ_phases_block()generate_exchange_block()generate_kinetics_block()generate_solution_block()generate_surface_block()get_compound_names()get_indices()handle_block()map_species_property_to_grid()parse_equilibriums_dataframe()parse_kinetics_dataframe()prep_bins()rearrange_copy_blocks()solution_csv_to_dict()solution_df_to_dict()surfaces_csv_to_dict()
- Module contents
Module contents¶
The MF6RTM (Modflow 6 Reactive Transport Model) package is a Python package for reactive transport modeling via the MODFLOW 6 and PhreeqcRM APIs.
- class mf6rtm.Mf6API(wd, dll)¶
Bases:
ModflowApiMODFLOW 6 API wrapper driving the flow and transport solve.
Extends
modflowapi.ModflowApito load the coupled simulation and run the per-timestep GWF/GWT solve loop thatMf6RTMalternates with the PhreeqcRM reaction step.- Parameters:
wd (os.PathLike) – Working directory containing the MODFLOW 6 simulation.
dll (os.PathLike) – Path to the MODFLOW 6 shared library (libmf6).
- property grid_type: str¶
Return the grid type of the MODFLOW 6 model.
- class mf6rtm.Mf6RTM(wd, mf6api, phreeqcbmi, output_format=None)¶
Bases:
objectReactive transport loop coupling MODFLOW 6 and PhreeqcRM.
Drives the sequential non-iterative (SNIA) operator-splitting loop: each time step MODFLOW 6 solves flow and conservative transport, the resulting concentrations are handed to PhreeqcRM to solve chemistry, and the reacted concentrations are written back to the transport models.
Instances are normally created via
prep_to_run()and run withsolve()rather than constructed directly. See__init__for the full list of parameters and attributes.- get_saturation_from_mf6()¶
Get the cell saturation array from MODFLOW 6.
Reads the saturation for the transport models and stores it on the PhreeqcRM interface (
sat_now).- Returns:
Saturation values for the grid; identical across all components.
- Return type:
dict[Any,ndarray]
- get_time_units_from_mf6()¶
Get the simulation time units from MODFLOW 6.
- Returns:
The MODFLOW 6 TDIS time units (e.g.
"days").- Return type:
str
- is_reactive_tstep()¶
Check whether the current timestep should be reactive.
- Returns:
True if the current timestep should be reactive, based on the run configuration; False otherwise.
- Return type:
bool
- print_warning_user_active()¶
Print 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_outputwith 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_datafrom 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()¶
Increment and return the coupling iteration counter.
Initializes
kiterto 0 on the first call, then increments it on each subsequent call.- Returns:
The current iteration counter.
- Return type:
int
- set_min_concentration(min_concentration)¶
Set the floor value for non-charge concentrations passed to PhreeqcRM.
- Parameters:
min_concentration (
float|None) – Any non-charge concentration below this value will be replaced with this value before calling SetConcentrations. Use a small positive number (e.g. 1e-30) to avoid PHREEQC divide-by-zero errors. Pass None to disable filtering entirely.- Return type:
None
- set_time_conversion()¶
Set the time conversion factor from the MODFLOW 6 time units.
- Return type:
None
- solve()¶
Run the coupled MODFLOW 6 / PhreeqcRM time-stepping loop.
- Returns:
True if the run finished and both interfaces were finalized successfully.
- Return type:
bool
- class mf6rtm.PhreeqcBMI(yaml='mf6rtm.yaml')¶
Bases:
BMIPhreeqcRMBasic Model Interface wrapper around PhreeqcRM.
Extends
phreeqcrm.BMIPhreeqcRMwith helpers used byMf6RTMto run the geochemical reaction step: scalar setters, selected-output handling and per-timestep solution updates.- Parameters:
yaml (str, optional) – Path to the PhreeqcRM YAML configuration file used to initialize the chemistry. Default is
"mf6rtm.yaml".
- get_grid_to_map()¶
Get the PhreeqcRM grid-to-map mapping.
- Returns:
The grid-to-map mapping returned by
GetGridToMap.- Return type:
array-like
- set_scalar(var_name, value)¶
Set a scalar PhreeqcRM BMI variable.
- Parameters:
var_name (str) – Name of the BMI variable to set.
value (Any) – Scalar value to assign; cast to the variable’s declared dtype.
- Raises:
ValueError – If
var_namedoes not refer to a scalar (dimension != 1).
- mf6rtm.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.solve(wd, reactive=None, nthread=1, libname=None, output_format=None, **mf6rtm_kwargs)¶
Prepare the coupled interfaces and run the reactive transport solve.
- Parameters:
wd (
PathLike) – Model working directory.reactive (
bool|None) – If given, override the reactive mode taken from the configuration. When it differs from the configured value the mode is switched (and selected output is left to MODFLOW 6 for conservative runs). Default is None.nthread (
int) – Number of threads for PhreeqcRM. Default is 1.libname (
Path|None) – Path to the MODFLOW 6 shared library. Default is None.output_format (
str) – Selected-output format (e.g."csv"or"hdf5"). Default is None.**mf6rtm_kwargs – Additional attributes to set on the
Mf6RTMinstance before solving; each key must be an existing attribute.
- Returns:
True if the simulation finished successfully.
- Return type:
bool- Raises:
AttributeError – If a keyword in
mf6rtm_kwargsis not an attribute ofMf6RTM.