mf6adj.pm module

class mf6adj.pm.PerfMeas(pm_name, pm_entries, logging_level='INFO', logger=None)[source]

Bases: object

Performance-measure container and adjoint-solve helper.

Parameters:
  • pm_name (str) – Name of the performance measure.

  • pm_entries (list[PerfMeasRecord]) – Performance-measure entries.

  • logging_level (str or int, optional) – Logging level.

  • logger (logging.Logger, optional) – Logger instance. If omitted, a new logger is created.

solve_adjoint(hdf5_forward_solution_fname, hdf5_adjoint_solution_fname=None, skip_solve=False, csv_summary=False, linear_solver=None, linear_solver_kwargs=None, use_precon=True, jacobi_preconditioner=None, precon_kwargs=None, singular_test=False, tikhonov=0.0, dvclose=1e-06, rclose=0.001, dvscale=False)[source]

Solve for the adjoint state for the performance measure.

This method writes an adjoint-solution HDF5 file and, when requested, writes a CSV summary file.

Parameters:
  • hdf5_forward_solution_fname (PathLike) – HDF5 file created by Mf6Adj.solve_forward_model() containing the forward-solution information needed for the adjoint solve.

  • hdf5_adjoint_solution_fname (PathLike, optional) – HDF5 file to write the adjoint solution. If omitted, a default name based on the performance-measure name is used. If the target file already exists, it is removed before writing.

  • skip_solve (bool, optional) – Skip the adjoint solve for time steps with no performance-measure entries.

  • csv_summary (bool, optional) – Write a CSV summary of the sensitivity information beside the adjoint HDF5 output file.

  • linear_solver (str or callable, optional) – Sparse linear solver to use. Supported string values are "direct", "bicgstab", "cg", "gmres", "lgmres", and "lsqr".

  • linear_solver_kwargs (dict, optional) – Keyword arguments passed to the configured linear solver callable.

  • use_precon (bool, optional) – Use a preconditioner with the iterative linear solver.

  • jacobi_preconditioner (str, optional) – Use a Jacobi preconditioner with the iterative linear solver. If None, the ILU preconditioner is used. Supported string values are "point" and "block".

  • precon_kwargs (dict, optional) – Keyword arguments passed to the preconditioner setup. For the default ILU preconditioner, these are passed to spilu. When jacobi_preconditioner="block", the block_size key sets the block size.

  • singular_test (bool, optional) – Test for a singular matrix and apply Tikhonov regularization when needed.

  • tikhonov (float, optional) – Tikhonov regularization value.

  • dvclose (float, optional) – Custom convergence criterion based on the maximum absolute change between consecutive iterates.

  • rclose (float, optional) – Custom convergence criterion based on the maximum absolute residual.

  • dvscale (bool, optional) – Scale lambda and the right-hand side to improve iterative solver convergence for large lambda values.

Returns:

Summary of composite sensitivity information.

Return type:

DataFrame

class mf6adj.pm.PerfMeasRecord(kper, kstp, inode, pm_type, pm_form, weight, obsval, k=None, i=None, j=None)[source]

Bases: object

Single record from a performance-measure block.

Parameters:
  • kper (int) – Zero-based stress period.

  • kstp (int) – Zero-based time step.

  • inode (int) – Zero-based node number.

  • pm_type (str) – Either head or a boundary package name from the GWF name file.

  • pm_form (str) – Either direct or residual.

  • weight (float) – Weight value.

  • obsval (float) – Observed counterpart; used only for residual form.

  • k (int, optional) – Zero-based layer index for structured-grid reporting.

  • i (int, optional) – Zero-based row index for structured-grid reporting.

  • j (int, optional) – Zero-based column index for structured-grid reporting.