# autogenerated file, do not modify

from os import PathLike, curdir
from typing import Union

from flopy.mf6.data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
from flopy.mf6.mfpackage import MFChildPackages, MFPackage


class ModflowPts(MFPackage):
    """
    ModflowPts defines a PTS package.

    Parameters
    ----------
    simulation
        Simulation that this package is a part of. Package is automatically
        added to simulation when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    print_option : string
        is a flag that controls printing of convergence information from the solver.
        none means print nothing. summary means print only the total number of
        iterations and nonlinear residual reduction summaries. all means print linear
        matrix solver convergence information to the solution listing file and model
        specific linear matrix solver convergence information to each model listing
        file in addition to summary information. none is default if print_option is not
        specified.
    complexity : string
        is an optional keyword that defines default non-linear and linear solver
        parameters.  simple - indicates that default solver input values will be
        defined that work well for nearly linear models. this would be used for models
        that do not include nonlinear stress packages and models that are either
        confined or consist of a single unconfined layer that is thick enough to
        contain the water table within a single layer. moderate - indicates that
        default solver input values will be defined that work well for moderately
        nonlinear models. this would be used for models that include nonlinear stress
        packages and models that consist of one or more unconfined layers. the moderate
        option should be used when the simple option does not result in successful
        convergence.  complex - indicates that default solver input values will be
        defined that work well for highly nonlinear models. this would be used for
        models that include nonlinear stress packages and models that consist of one or
        more unconfined layers representing complex geology and surface-
        water/groundwater interaction. the complex option should be used when the
        moderate option does not result in successful convergence.  non-linear and
        linear solver parameters assigned using a specified complexity can be modified
        in the nonlinear and linear blocks. if the complexity option is not specified,
        nonlinear and linear variables will be assigned the simple complexity values.
    csv_output_filerecord : (csvfile)
        * csvfile : string
                name of the ascii comma separated values output file to write solver
                convergence information. If PRINT_OPTION is NONE or SUMMARY, comma separated
                values output includes maximum head change convergence information at the end
                of each outer iteration for each time step. If PRINT_OPTION is ALL, comma
                separated values output includes maximum head change and maximum residual
                convergence information for the solution and each model (if the solution
                includes more than one model) and linear acceleration information for each
                inner iteration.

    csv_outer_output_filerecord : (outer_csvfile)
        * outer_csvfile : string
                name of the ascii comma separated values output file to write maximum
                dependent-variable (for example, head) change convergence information at the
                end of each outer iteration for each time step.

    csv_inner_output_filerecord : (inner_csvfile)
        * inner_csvfile : string
                name of the ascii comma separated values output file to write solver
                convergence information. Comma separated values output includes maximum
                dependent-variable (for example, head) change and maximum residual convergence
                information for the solution and each model (if the solution includes more than
                one model) and linear acceleration information for each inner iteration.

    no_ptcrecord : (no_ptc, no_ptc_option)
        * no_ptc : keyword
                is a flag that is used to disable pseudo-transient continuation (PTC). Option
                only applies to steady-state stress periods for models using the Newton-Raphson
                formulation. For many problems, PTC can significantly improve convergence
                behavior for steady-state simulations, and for this reason it is active by
                default.  In some cases, however, PTC can worsen the convergence behavior,
                especially when the initial conditions are similar to the solution.  When the
                initial conditions are similar to, or exactly the same as, the solution and
                convergence is slow, then the NO_PTC FIRST option should be used to deactivate
                PTC for the first stress period.  The NO_PTC ALL option should also be used in
                order to compare convergence behavior with other MODFLOW versions, as PTC is
                only available in MODFLOW 6.
        * no_ptc_option : string
                is an optional keyword that is used to define options for disabling pseudo-
                transient continuation (PTC). FIRST is an optional keyword to disable PTC for
                the first stress period, if steady-state and one or more model is using the
                Newton-Raphson formulation. ALL is an optional keyword to disable PTC for all
                steady-state stress periods for models using the Newton-Raphson formulation. If
                NO_PTC_OPTION is not specified, the NO_PTC ALL option is used.

    ats_outer_maximum_fraction : double precision
        real value defining the fraction of the maximum allowable outer iterations used
        with the adaptive time step (ats) capability if it is active.  if this value is
        set to zero by the user, then this solution will have no effect on ats
        behavior.  this value must be greater than or equal to zero and less than or
        equal to 0.5 or the program will terminate with an error.  if it is not
        specified by the user, then it is assigned a default value of one third.  when
        the number of outer iterations for this solution is less than the product of
        this value and the maximum allowable outer iterations, then ats will increase
        the time step length by a factor of dtadj in the ats input file.  when the
        number of outer iterations for this solution is greater than the maximum
        allowable outer iterations minus the product of this value and the maximum
        allowable outer iterations, then the ats (if active) will decrease the time
        step length by a factor of 1 / dtadj.
    outer_maximum : integer
        integer value defining the maximum number of outer (nonlinear) iterations --
        that is, calls to the solution routine. for a linear problem outer_maximum
        should be 1.

    filename : str or PathLike, optional
        Name or path of file where this package is stored.
    pname : str, optional
        Package name.
    **kwargs
        Extra keywords for :class:`flopy.mf6.mfpackage.MFPackage`.

    """

    csv_output_filerecord = ListTemplateGenerator(
        ("pts", "options", "csv_output_filerecord")
    )
    csv_outer_output_filerecord = ListTemplateGenerator(
        ("pts", "options", "csv_outer_output_filerecord")
    )
    csv_inner_output_filerecord = ListTemplateGenerator(
        ("pts", "options", "csv_inner_output_filerecord")
    )
    no_ptcrecord = ListTemplateGenerator(("pts", "options", "no_ptcrecord"))
    package_abbr = "pts"
    _package_type = "pts"
    dfn_file_name = "sln-pts.dfn"
    dfn = [
        ["header"],
        [
            "block options",
            "name print_option",
            "type string",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name complexity",
            "type string",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name csv_output_filerecord",
            "type record csv_output fileout csvfile",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "deprecated 6.1.1",
        ],
        [
            "block options",
            "name csv_output",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
            "deprecated 6.1.1",
        ],
        [
            "block options",
            "name csvfile",
            "type string",
            "preserve_case true",
            "shape",
            "in_record true",
            "reader urword",
            "tagged false",
            "optional false",
            "deprecated 6.1.1",
        ],
        [
            "block options",
            "name csv_outer_output_filerecord",
            "type record csv_outer_output fileout outer_csvfile",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
        ],
        [
            "block options",
            "name csv_outer_output",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name fileout",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name outer_csvfile",
            "type string",
            "preserve_case true",
            "shape",
            "in_record true",
            "reader urword",
            "tagged false",
            "optional false",
        ],
        [
            "block options",
            "name csv_inner_output_filerecord",
            "type record csv_inner_output fileout inner_csvfile",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
        ],
        [
            "block options",
            "name csv_inner_output",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name inner_csvfile",
            "type string",
            "preserve_case true",
            "shape",
            "in_record true",
            "reader urword",
            "tagged false",
            "optional false",
        ],
        [
            "block options",
            "name no_ptcrecord",
            "type record no_ptc no_ptc_option",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name no_ptc",
            "type keyword",
            "in_record true",
            "reader urword",
            "optional false",
            "tagged true",
        ],
        [
            "block options",
            "name no_ptc_option",
            "type string",
            "in_record true",
            "reader urword",
            "optional true",
            "tagged false",
        ],
        [
            "block options",
            "name ats_outer_maximum_fraction",
            "type double precision",
            "reader urword",
            "optional true",
        ],
        [
            "block nonlinear",
            "name outer_maximum",
            "type integer",
            "reader urword",
            "optional false",
        ],
    ]

    def __init__(
        self,
        simulation,
        loading_package=False,
        print_option=None,
        complexity=None,
        csv_output_filerecord=None,
        csv_outer_output_filerecord=None,
        csv_inner_output_filerecord=None,
        no_ptcrecord=None,
        ats_outer_maximum_fraction=None,
        outer_maximum=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowPts."""
        super().__init__(
            parent=simulation,
            package_type="pts",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.print_option = self.build_mfdata("print_option", print_option)
        self.complexity = self.build_mfdata("complexity", complexity)
        self.csv_output_filerecord = self.build_mfdata(
            "csv_output_filerecord", csv_output_filerecord
        )
        self.csv_outer_output_filerecord = self.build_mfdata(
            "csv_outer_output_filerecord", csv_outer_output_filerecord
        )
        self.csv_inner_output_filerecord = self.build_mfdata(
            "csv_inner_output_filerecord", csv_inner_output_filerecord
        )
        self.no_ptcrecord = self.build_mfdata("no_ptcrecord", no_ptcrecord)
        self.ats_outer_maximum_fraction = self.build_mfdata(
            "ats_outer_maximum_fraction", ats_outer_maximum_fraction
        )
        self.outer_maximum = self.build_mfdata("outer_maximum", outer_maximum)

        self._init_complete = True
