# 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 ModflowGwfvsc(MFPackage):
    """
    ModflowGwfvsc defines a VSC package.

    Parameters
    ----------
    model
        Model that this package is a part of. Package is automatically
        added to model when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    viscref : double precision
        fluid reference viscosity used in the equation of state.  this value is set to
        1.0 if not specified as an option.
    temperature_species_name : string
        string used to identify the auxspeciesname in packagedata that corresponds to
        the temperature species.  there can be only one occurrence of this temperature
        species name in the packagedata block or the program will terminate with an
        error.  this value has no effect if viscosity does not depend on temperature.
    thermal_formulation : string
        may be used for specifying which viscosity formulation to use for the
        temperature species. can be either linear or nonlinear. the linear viscosity
        formulation is the default.
    thermal_a2 : double precision
        is an empirical parameter specified by the user for calculating viscosity using
        a nonlinear formulation.  if a2 is not specified, a default value of 10.0 is
        assigned (voss, 1984).
    thermal_a3 : double precision
        is an empirical parameter specified by the user for calculating viscosity using
        a nonlinear formulation.  if a3 is not specified, a default value of 248.37 is
        assigned (voss, 1984).
    thermal_a4 : double precision
        is an empirical parameter specified by the user for calculating viscosity using
        a nonlinear formulation.  if a4 is not specified, a default value of 133.15 is
        assigned (voss, 1984).
    viscosity_filerecord : (viscosityfile)
        * viscosityfile : string
                name of the binary output file to write viscosity information.  The viscosity
                file has the same format as the head file.  Viscosity values will be written to
                the viscosity file whenever heads are written to the binary head file.  The
                settings for controlling head output are contained in the Output Control
                option.

    nviscspecies : integer
        number of species used in the viscosity equation of state.  if either
        concentrations or temperature (or both) are used to update viscosity then
        nviscspecies needs to be at least one.
    packagedata : [(iviscspec, dviscdc, cviscref, modelname, auxspeciesname)]
        * iviscspec : integer
                integer value that defines the species number associated with the specified
                PACKAGEDATA data entered on each line. IVISCSPECIES must be greater than zero
                and less than or equal to NVISCSPECIES. Information must be specified for each
                of the NVISCSPECIES species or the program will terminate with an error.  The
                program will also terminate with an error if information for a species is
                specified more than once.
        * dviscdc : double precision
                real value that defines the slope of the line defining the linear relationship
                between viscosity and temperature or between viscosity and concentration,
                depending on the type of species entered on each line.  If the value of
                AUXSPECIESNAME entered on a line corresponds to TEMPERATURE_SPECIES_NAME (in
                the OPTIONS block), this value will be used when VISCOSITY_FUNC is equal to
                LINEAR (the default) in the OPTIONS block.  When VISCOSITY_FUNC is set to
                NONLINEAR, a value for DVISCDC must be specified though it is not used.
        * cviscref : double precision
                real value that defines the reference temperature or reference concentration
                value used for this species in the viscosity equation of state.  If
                AUXSPECIESNAME entered on a line corresponds to TEMPERATURE_SPECIES_NAME (in
                the OPTIONS block), then CVISCREF refers to a reference temperature, otherwise
                it refers to a reference concentration.
        * modelname : string
                name of a GWT or GWE model used to simulate a species that will be used in the
                viscosity equation of state.  This name will have no effect if the simulation
                does not include a GWT or GWE model that corresponds to this GWF model.
        * auxspeciesname : string
                name of an auxiliary variable in a GWF stress package that will be used for
                this species to calculate the viscosity values.  If a viscosity value is needed
                by the Viscosity Package then it will use the temperature or concentration
                values associated with this AUXSPECIESNAME in the viscosity equation of state.
                For advanced stress packages (LAK, SFR, MAW, and UZF) that have an associated
                advanced transport package (LKT, SFT, MWT, and UZT), the
                FLOW_PACKAGE_AUXILIARY_NAME option in the advanced transport package can be
                used to transfer simulated temperature or concentration(s) into the flow
                package auxiliary variable.  In this manner, the Viscosity Package can
                calculate viscosity values for lakes, streams, multi-aquifer wells, and
                unsaturated zone flow cells using simulated concentrations.


    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`.

    """

    viscosity_filerecord = ListTemplateGenerator(
        ("gwf6", "vsc", "options", "viscosity_filerecord")
    )
    packagedata = ListTemplateGenerator(("gwf6", "vsc", "packagedata", "packagedata"))
    package_abbr = "gwfvsc"
    _package_type = "vsc"
    dfn_file_name = "gwf-vsc.dfn"
    dfn = [
        ["header"],
        [
            "block options",
            "name viscref",
            "type double precision",
            "reader urword",
            "optional true",
            "default 1.0",
        ],
        [
            "block options",
            "name temperature_species_name",
            "type string",
            "shape",
            "reader urword",
            "optional true",
            "mf6internal temp_specname",
        ],
        [
            "block options",
            "name thermal_formulation",
            "type string",
            "shape",
            "reader urword",
            "optional true",
            "valid linear nonlinear",
            "mf6internal thermal_form",
        ],
        [
            "block options",
            "name thermal_a2",
            "type double precision",
            "reader urword",
            "optional true",
            "default 10.",
        ],
        [
            "block options",
            "name thermal_a3",
            "type double precision",
            "reader urword",
            "optional true",
            "default 248.37",
        ],
        [
            "block options",
            "name thermal_a4",
            "type double precision",
            "reader urword",
            "optional true",
            "default 133.15",
        ],
        [
            "block options",
            "name viscosity_filerecord",
            "type record viscosity fileout viscosityfile",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "mf6internal viscosity_fr",
        ],
        [
            "block options",
            "name viscosity",
            "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 viscosityfile",
            "type string",
            "preserve_case true",
            "shape",
            "in_record true",
            "reader urword",
            "tagged false",
            "optional false",
        ],
        [
            "block dimensions",
            "name nviscspecies",
            "type integer",
            "reader urword",
            "optional false",
        ],
        [
            "block packagedata",
            "name packagedata",
            "type recarray iviscspec dviscdc cviscref modelname auxspeciesname",
            "shape (nviscspecies)",
            "reader urword",
        ],
        [
            "block packagedata",
            "name iviscspec",
            "type integer",
            "shape",
            "tagged false",
            "in_record true",
            "reader urword",
            "numeric_index true",
        ],
        [
            "block packagedata",
            "name dviscdc",
            "type double precision",
            "shape",
            "tagged false",
            "in_record true",
            "reader urword",
        ],
        [
            "block packagedata",
            "name cviscref",
            "type double precision",
            "shape",
            "tagged false",
            "in_record true",
            "reader urword",
        ],
        [
            "block packagedata",
            "name modelname",
            "type string",
            "in_record true",
            "tagged false",
            "shape",
            "reader urword",
        ],
        [
            "block packagedata",
            "name auxspeciesname",
            "type string",
            "in_record true",
            "tagged false",
            "shape",
            "reader urword",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        viscref=1.0,
        temperature_species_name=None,
        thermal_formulation=None,
        thermal_a2=10.0,
        thermal_a3=248.37,
        thermal_a4=133.15,
        viscosity_filerecord=None,
        nviscspecies=None,
        packagedata=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwfvsc."""
        super().__init__(
            parent=model,
            package_type="vsc",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.viscref = self.build_mfdata("viscref", viscref)
        self.temperature_species_name = self.build_mfdata(
            "temperature_species_name", temperature_species_name
        )
        self.thermal_formulation = self.build_mfdata(
            "thermal_formulation", thermal_formulation
        )
        self.thermal_a2 = self.build_mfdata("thermal_a2", thermal_a2)
        self.thermal_a3 = self.build_mfdata("thermal_a3", thermal_a3)
        self.thermal_a4 = self.build_mfdata("thermal_a4", thermal_a4)
        self.viscosity_filerecord = self.build_mfdata(
            "viscosity_filerecord", viscosity_filerecord
        )
        self.nviscspecies = self.build_mfdata("nviscspecies", nviscspecies)
        self.packagedata = self.build_mfdata("packagedata", packagedata)

        self._init_complete = True
