Esempio n. 1
0
    def __init__(self, model, nrchop=3, irchcb=0, rech=1e-3, irch=1,
                 extension ='rch', unitnumber=19):
        """
        Package constructor.

        """
        # Call parent init to set self.parent, extension, name and unit number
        Package.__init__(self, model, extension, 'RCH', unitnumber)
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        self.heading = '# RCH for MODFLOW, generated by Flopy.'
        self.url = 'rch.htm'
        self.nrchop = nrchop
        self.irchcb = irchcb
        self.rech = []
        self.irch = []
        if (not isinstance(rech, list)):
            rech = [rech]
        for i,a in enumerate(rech):
            r = util_2d(model,(nrow,ncol),np.float32,a,name='rech_'+str(i+1))
            self.rech = self.rech + [r]
        if (not isinstance(irch, list)):
            irch = [irch]
        for i,a in enumerate(irch):
            ir = util_2d(model,(nrow,ncol),np.int,a,name='irech_'+str(i+1))
            self.irch = self.irch + [ir]
        self.np = 0
        self.parent.add_package(self)
Esempio n. 2
0
    def __init__(self, model, laytyp=0, layavg=0, chani=1.0, layvka=0, laywet=0, iupwcb = 53, hdry=-1E+30, iphdry = 0,\
                 hk=1.0, hani=1.0, vka=1.0, ss=1e-5, sy=0.15, vkcb=0.0, noparcheck=False,        \
                 extension='upw', unitnumber = 31):
        Package.__init__(self, model, extension, 'UPW', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
        self.heading = '# UPW for MODFLOW-NWT, generated by Flopy.'
        self.url = 'upw_upstream_weighting_package.htm'
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        # item 1
        self.iupwcb = iupwcb # Unit number for file with cell-by-cell flow terms
        self.hdry = hdry # Head in cells that are converted to dry during a simulation
        self.npupw = 0 # number of UPW parameters
        self.iphdry = iphdry
        self.laytyp = util_2d(model,(nlay,),np.int,laytyp,name='laytyp')
        self.layavg = util_2d(model,(nlay,),np.int,layavg,name='layavg')
        self.chani = util_2d(model,(nlay,),np.int,chani,name='chani')
        self.layvka = util_2d(model,(nlay,),np.int,layvka,name='vka')
        self.laywet = util_2d(model,(nlay,),np.int,laywet,name='laywet')

        self.options = ' '
        if noparcheck: self.options = self.options + 'NOPARCHECK  '

        self.hk = util_3d(model,(nlay,nrow,ncol),np.float32,hk,name='hk',locat=self.unit_number[0])
        self.hani = util_3d(model,(nlay,nrow,ncol),np.float32,hani,name='hani',locat=self.unit_number[0])
        self.vka = util_3d(model,(nlay,nrow,ncol),np.float32,vka,name='vka',locat=self.unit_number[0])
        self.ss = util_3d(model,(nlay,nrow,ncol),np.float32,ss,name='ss',locat=self.unit_number[0])
        self.sy = util_3d(model,(nlay,nrow,ncol),np.float32,sy,name='sy',locat=self.unit_number[0])
        self.vkcb = util_3d(model,(nlay,nrow,ncol),np.float32,vkcb,name='vkcb',locat=self.unit_number[0])
        self.parent.add_package(self)
Esempio n. 3
0
File: mfupw.py Progetto: ksl0/flopy
    def __init__(self, model, laytyp=0, layavg=0, chani=1.0, layvka=0, laywet=0, iupwcb = 53, hdry=-1E+30, iphdry = 0,\
                 hk=1.0, hani=1.0, vka=1.0, ss=1e-5, sy=0.15, vkcb=0.0, noparcheck=False,        \
                 extension='upw', unitnumber = 31):
        Package.__init__(self, model, extension, 'UPW', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
        self.heading = '# UPW for MODFLOW-NWT, generated by Flopy.'
        self.url = 'upw_upstream_weighting_package.htm'
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        # item 1
        self.iupwcb = iupwcb # Unit number for file with cell-by-cell flow terms
        self.hdry = hdry # Head in cells that are converted to dry during a simulation
        self.npupw = 0 # number of UPW parameters
        self.iphdry = iphdry
        self.laytyp = util_2d(model,(nlay,),np.int,laytyp,name='laytyp')
        self.layavg = util_2d(model,(nlay,),np.int,layavg,name='layavg')
        self.chani = util_2d(model,(nlay,),np.int,chani,name='chani')
        self.layvka = util_2d(model,(nlay,),np.int,layvka,name='vka')
        self.laywet = util_2d(model,(nlay,),np.int,laywet,name='laywet')

        self.options = ' '
        if noparcheck: self.options = self.options + 'NOPARCHECK  '

        self.hk = util_3d(model,(nlay,nrow,ncol),np.float32,hk,name='hk',locat=self.unit_number[0])
        self.hani = util_3d(model,(nlay,nrow,ncol),np.float32,hani,name='hani',locat=self.unit_number[0])
        self.vka = util_3d(model,(nlay,nrow,ncol),np.float32,vka,name='vka',locat=self.unit_number[0])
        self.ss = util_3d(model,(nlay,nrow,ncol),np.float32,ss,name='ss',locat=self.unit_number[0])
        self.sy = util_3d(model,(nlay,nrow,ncol),np.float32,sy,name='sy',locat=self.unit_number[0])
        self.vkcb = util_3d(model,(nlay,nrow,ncol),np.float32,vkcb,name='vkcb',locat=self.unit_number[0])
        self.parent.add_package(self)
Esempio n. 4
0
    def __setattr__(self, key, value):
        var_dict = vars(self)
        if key in var_dict.keys():
            old_value = var_dict[key]
            if isinstance(old_value, utils.util_2d):
                value = utils.util_2d(self.parent,
                                      old_value.shape,
                                      old_value.dtype,
                                      value,
                                      name=old_value.name,
                                      fmtin=old_value.fmtin,
                                      locat=old_value.locat)
            elif isinstance(old_value, utils.util_3d):
                value = utils.util_3d(self.parent,
                                      old_value.shape,
                                      old_value.dtype,
                                      value,
                                      name=old_value.name_base,
                                      fmtin=old_value.fmtin,
                                      locat=old_value.locat)
            elif isinstance(old_value, utils.transient_2d):
                value = utils.transient_2d(self.parent,
                                           old_value.shape,
                                           old_value.dtype,
                                           value,
                                           name=old_value.name_base,
                                           fmtin=old_value.fmtin,
                                           locat=old_value.locat)
            elif isinstance(old_value, utils.mflist):
                value = utils.mflist(self.parent, old_value.dtype, data=value)
            elif isinstance(old_value, list):
                if isinstance(old_value[0], utils.util_3d):
                    new_list = []
                    for vo, v in zip(old_value, value):
                        new_list.append(
                            utils.util_3d(self.parent,
                                          vo.shape,
                                          vo.dtype,
                                          v,
                                          name=vo.name_base,
                                          fmtin=vo.fmtin,
                                          locat=vo.locat))
                    value = new_list
                elif isinstance(old_value[0], utils.util_2d):
                    new_list = []
                    for vo, v in zip(old_value, value):
                        new_list.append(
                            utils.util_2d(self.parent,
                                          vo.shape,
                                          vo.dtype,
                                          v,
                                          name=vo.name,
                                          fmtin=vo.fmtin,
                                          locat=vo.locat))
                    value = new_list

        super(Package, self).__setattr__(key, value)
Esempio n. 5
0
File: mbase.py Progetto: ksl0/flopy
    def __setattr__(self, key, value):
        var_dict = vars(self)
        if key in list(var_dict.keys()):
            old_value = var_dict[key]
            if isinstance(old_value, utils.util_2d):
                value = utils.util_2d(
                    self.parent,
                    old_value.shape,
                    old_value.dtype,
                    value,
                    name=old_value.name,
                    fmtin=old_value.fmtin,
                    locat=old_value.locat,
                )
            elif isinstance(old_value, utils.util_3d):
                value = utils.util_3d(
                    self.parent,
                    old_value.shape,
                    old_value.dtype,
                    value,
                    name=old_value.name_base,
                    fmtin=old_value.fmtin,
                    locat=old_value.locat,
                )
            elif isinstance(old_value, utils.transient_2d):
                value = utils.transient_2d(
                    self.parent,
                    old_value.shape,
                    old_value.dtype,
                    value,
                    name=old_value.name_base,
                    fmtin=old_value.fmtin,
                    locat=old_value.locat,
                )
            elif isinstance(old_value, utils.mflist):
                value = utils.mflist(self.parent, old_value.dtype, data=value)
            elif isinstance(old_value, list):
                if isinstance(old_value[0], utils.util_3d):
                    new_list = []
                    for vo, v in zip(old_value, value):
                        new_list.append(
                            utils.util_3d(
                                self.parent, vo.shape, vo.dtype, v, name=vo.name_base, fmtin=vo.fmtin, locat=vo.locat
                            )
                        )
                    value = new_list
                elif isinstance(old_value[0], utils.util_2d):
                    new_list = []
                    for vo, v in zip(old_value, value):
                        new_list.append(
                            utils.util_2d(
                                self.parent, vo.shape, vo.dtype, v, name=vo.name, fmtin=vo.fmtin, locat=vo.locat
                            )
                        )
                    value = new_list

        super(Package, self).__setattr__(key, value)
Esempio n. 6
0
File: mtdsp.py Progetto: ksl0/flopy
 def __init__(self, model, al=0.01, trpt=0.1, trpv=0.01, dmcoef=1e-9, 
              extension='dsp', multiDiff=False,**kwargs):
     '''
     if dmcoef is passed as a list of (nlay, nrow, ncol) arrays,
     then the multicomponent diffusion is activated
     '''
     # Call ancestor's init to set self.parent, extension, name and 
     #unit number
     Package.__init__(self, model, extension, 'DSP', 33) 
     nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
     ncomp = self.parent.get_ncomp()        
     # if multiDiff:
     #     assert isinstance(dmcoef,list),('using multicomponent diffusion '
     #                                     'requires dmcoef is list of '
     #                                     'length ncomp')
     #     if len(dmcoef) != ncomp:
     #         raise TypeError,('using multicomponent diffusion requires '
     #                          'dmcoef is list of length ncomp')
     self.multiDiff = multiDiff                                    
     #self.al = self.assignarray((nlay, nrow, ncol), np.float, al, 
     #                           name='al', load=model.load )
     self.al = util_3d(model,(nlay,nrow,ncol),np.float32,al,name='al',
                       locat=self.unit_number[0])
     #self.trpt = self.assignarray((nlay,), np.float, trpt, name='trpt', 
     #                             load=model.load)
     self.trpt = util_2d(model,(nlay,),np.float32,trpt,name='trpt',
                         locat=self.unit_number[0])
     #self.trpv = self.assignarray((nlay,), np.float, trpv, name='trpv', 
     #                             load=model.load)
     self.trpv = util_2d(model,(nlay,),np.float32,trpt,name='trpv',
                         locat=self.unit_number[0])
     self.dmcoef = []
     a = util_3d(model, (nlay, nrow, ncol), np.float32, dmcoef,
                 name='dmcoef1', locat=self.unit_number[0])
     self.dmcoef.append(a)
     if self.multiDiff:
         for icomp in range(2, ncomp+1):
             name = "dmcoef" + str(icomp)
             val = 0.0
             if name in list(kwargs.keys()):
                 val = kwargs[name]
                 kwargs.pop(name)
             else:
                 print("DSP: setting dmcoef for component " +\
                       str(icomp) + " to zero, kwarg name " +\
                       name)
             a = util_3d(model, (nlay, nrow, ncol), np.float32, val,
                         name=name, locat=self.unit_number[0])
             self.dmcoef.append(a)
     if len(list(kwargs.keys())) > 0:
         raise Exception("DSP error: unrecognized kwargs: " +
                         ' '.join(list(kwargs.keys())))
     self.parent.add_package(self)
     return
Esempio n. 7
0
File: mfbcf.py Progetto: ksl0/flopy
 def __init__(
     self,
     model,
     ibcfcb=53,
     intercellt=0,
     laycon=3,
     trpy=1.0,
     hdry=-1e30,
     iwdflg=0,
     wetfct=0.1,
     iwetit=1,
     ihdwet=0,
     tran=1.0,
     hy=1.0,
     vcont=1.0,
     sf1=1e-5,
     sf2=0.15,
     wetdry=-0.01,
     extension="bcf",
     unitnumber=15,
 ):
     Package.__init__(self, model, extension, "BCF6", unitnumber)
     self.url = "bcf.htm"
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     # Set values of all parameters
     self.intercellt = util_2d(model, (nlay,), np.int, intercellt, name="laycon", locat=self.unit_number[0])
     self.laycon = util_2d(model, (nlay,), np.int, laycon, name="laycon", locat=self.unit_number[0])
     self.trpy = util_2d(model, (nlay,), np.int, trpy, name="Anisotropy factor", locat=self.unit_number[0])
     self.ibcfcb = ibcfcb
     self.hdry = hdry
     self.iwdflg = iwdflg
     self.wetfct = wetfct
     self.iwetit = iwetit
     self.ihdwet = ihdwet
     self.tran = util_3d(model, (nlay, nrow, ncol), np.float32, tran, "Transmissivity", locat=self.unit_number[0])
     self.hy = util_3d(
         model, (nlay, nrow, ncol), np.float32, hy, "Horizontal Hydraulic Conductivity", locat=self.unit_number[0]
     )
     self.vcont = util_3d(
         model, (nlay - 1, nrow, ncol), np.float32, vcont, "Vertical Conductance", locat=self.unit_number[0]
     )
     self.sf1 = util_3d(
         model, (nlay, nrow, ncol), np.float32, sf1, "Primary Storage Coefficient", locat=self.unit_number[0]
     )
     self.sf2 = util_3d(
         model, (nlay, nrow, ncol), np.float32, sf2, "Secondary Storage Coefficient", locat=self.unit_number[0]
     )
     self.wetdry = util_3d(model, (nlay, nrow, ncol), np.float32, wetdry, "WETDRY", locat=self.unit_number[0])
     self.parent.add_package(self)
Esempio n. 8
0
    def write_file(self):
        """
        Write the package input file.

        """
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        ModflowDis = self.parent.mf.get_package('DIS')
        # Open file for writing
        f_bas = open(self.fn_path, 'w')
        f_bas.write('#{0:s}\n#{1:s}\n'.format(self.heading1,self.heading2))
        f_bas.write('{0:16.6f} {1:16.6f}\n'\
                    .format(self.hnoflo, self.hdry))
        f_bas.write('{0:4d}\n'\
                    .format(self.def_face_ct))
        if self.def_face_ct > 0:
            for i in range(self.def_face_ct):
                f_bas.write('{0:20s}\n'.format(self.bud_label[i]))
                f_bas.write('{0:2d}\n'.format(self.def_iface[i]))
        #f_bas.write('\n')
  
        flow_package = self.parent.mf.get_package('BCF6')
        if (flow_package != None):
            lc = util_2d(self.parent,(nlay,),np.int,\
                         flow_package.laycon.get_value(),name='bas - laytype',\
                         locat=self.unit_number[0])
        else:
            flow_package = self.parent.mf.get_package('LPF')
            if (flow_package != None):
                lc = util_2d(self.parent,(nlay,),\
                             np.int,flow_package.laytyp.get_value(),\
                             name='bas - laytype',locat=self.unit_number[0])
            else:
                flow_package = self.parent.mf.get_package('UPW')
                if (flow_package != None):
                    lc = util_2d(self.parent,(nlay,),\
                                 np.int,flow_package.laytyp.get_value(),\
                                 name='bas - laytype', locat=self.unit_number[0])
        # need to reset lc fmtin
        lc.set_fmtin('(40I2)')
        f_bas.write(lc.string)
        # from modpath bas--uses keyword array types
        f_bas.write(self.__ibound.get_file_entry())
        # from MT3D bas--uses integer array types
        #f_bas.write(self.ibound.get_file_entry())
        f_bas.write(self.prsity.get_file_entry())
        f_bas.write(self.prsityCB.get_file_entry())
        
        f_bas.close() 
Esempio n. 9
0
    def write_file(self):
        """
        Write the package input file.

        """
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        ModflowDis = self.parent.mf.get_package('DIS')
        # Open file for writing
        f_bas = open(self.fn_path, 'w')
        f_bas.write('#{0:s}\n#{1:s}\n'.format(self.heading1, self.heading2))
        f_bas.write('{0:16.6f} {1:16.6f}\n'\
                    .format(self.hnoflo, self.hdry))
        f_bas.write('{0:4d}\n'\
                    .format(self.def_face_ct))
        if self.def_face_ct > 0:
            for i in range(self.def_face_ct):
                f_bas.write('{0:20s}\n'.format(self.bud_label[i]))
                f_bas.write('{0:2d}\n'.format(self.def_iface[i]))
        #f_bas.write('\n')

        flow_package = self.parent.mf.get_package('BCF6')
        if (flow_package != None):
            lc = util_2d(self.parent,(nlay,),np.int,\
                         flow_package.laycon.get_value(),name='bas - laytype',\
                         locat=self.unit_number[0])
        else:
            flow_package = self.parent.mf.get_package('LPF')
            if (flow_package != None):
                lc = util_2d(self.parent,(nlay,),\
                             np.int,flow_package.laytyp.get_value(),\
                             name='bas - laytype',locat=self.unit_number[0])
            else:
                flow_package = self.parent.mf.get_package('UPW')
                if (flow_package != None):
                    lc = util_2d(self.parent,(nlay,),\
                                 np.int,flow_package.laytyp.get_value(),\
                                 name='bas - laytype', locat=self.unit_number[0])
        #--need to reset lc fmtin
        lc.set_fmtin('(40I2)')
        f_bas.write(lc.string)
        # from modpath bas--uses keyword array types
        f_bas.write(self.__ibound.get_file_entry())
        # from MT3D bas--uses integer array types
        #f_bas.write(self.ibound.get_file_entry())
        f_bas.write(self.prsity.get_file_entry())
        f_bas.write(self.prsityCB.get_file_entry())

        f_bas.close()
Esempio n. 10
0
    def __init__(self, model, npln=1, istrat=1, iswizt=53, nprn=1, toeslope=0.05, tipslope=0.05, \
                 zetamin=0.005, delzeta=0.05, nu=0.025, zeta=[], ssz=[], isource=0, extension='swi', fname_output='swi.zta'):
        """
        Package constructor.

        """
        Package.__init__(self, model) # Call ancestor's init to set self.parent
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        self.unit_number = [29,53]
        self.extension = extension
        self.file_name = [ self.parent.name + '.' + self.extension, fname_output ]
        self.name = [ 'SWI', 'DATA(BINARY)' ]
        self.heading = '# Salt Water Intrusion package file for MODFLOW-2000, generated by Flopy.'
        self.npln = npln
        self.istrat = istrat
        self.iswizt = iswizt
        self.nprn = nprn
        self.toeslope = toeslope
        self.tipslope = tipslope
        self.zetamin = zetamin
        self.delzeta = delzeta
        # Create arrays so that they have the correct size
        if self.istrat == 1:
            #self.nu = empty( self.npln+1 )
            self.nu = util_2d(model,(self.npln+1,),np.float32,nu,name='nu')
        else:
            #self.nu = empty( self.npln+2 )
            self.nu = util_2d(model,(self.npln+2,),np.float32,nu,name='nu')
        self.zeta = []
        for i in range(nlay):
            #self.zeta.append( empty((nrow, ncol, self.npln)) )
            self.zeta
        #self.ssz = empty((nrow, ncol, nlay))
        #self.isource = empty((nrow, ncol, nlay),dtype='int32')
        # Set values of arrays
        #self.assignarray_old( self.nu, nu )
        #for i in range(nlay):
        #    self.assignarray_old( self.zeta[i], zeta[i] )
        #self.assignarray_old( self.ssz, ssz )
        #self.assignarray_old( self.isource, isource )
        for i in range(nlay):           
            self.zeta.append(util_2d(model,(self.npln,nrow,ncol),np.float32,zeta[i],name='zeta_'+str(i+1)))        
        self.ssz = util_3d(model,(nlay,nrow,ncol),np.float32,ssz,name='ssz')        
        self.isource = util_3d(model,(nlay,nrow,ncol),np.int,isource,name='isource')
        self.parent.add_package(self)
Esempio n. 11
0
 def __init__(self, model, laytyp=0, layavg=0, chani=1.0, layvka=0,
              laywet=0, ilpfcb = 53, hdry=-1E+30, iwdflg=0, wetfct=0.1,
              iwetit=1, ihdwet=0, hk=1.0, hani=1.0, vka=1.0, ss=1e-5,
              sy=0.15, vkcb=0.0, wetdry=-0.01, storagecoefficient=False,
              constantcv=False, thickstrt=False, nocvcorrection=False,
              novfc=False, extension='lpf', unitnumber=15):
     Package.__init__(self, model, extension, 'LPF', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
     self.heading = '# LPF for MODFLOW, generated by Flopy.'
     self.url = 'lpf.htm'
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     # item 1
     self.ilpfcb = ilpfcb # Unit number for file with cell-by-cell flow terms
     self.hdry = hdry # Head in cells that are converted to dry during a simulation
     self.nplpf = 0 # number of LPF parameters
     self.laytyp = util_2d(model,(nlay,),np.int,laytyp,name='laytyp')
     self.layavg = util_2d(model,(nlay,),np.int,layavg,name='layavg')
     self.chani = util_2d(model,(nlay,),np.float32,chani,name='chani')
     self.layvka = util_2d(model,(nlay,),np.int,layvka,name='layvka')
     self.laywet = util_2d(model,(nlay,),np.int,laywet,name='laywet')
     self.wetfct = wetfct # Factor that is included in the calculation of the head when a cell is converted from dry to wet
     self.iwetit = iwetit # Iteration interval for attempting to wet cells
     self.ihdwet = ihdwet # Flag that determines which equation is used to define the initial head at cells that become wet
     self.options = ' '
     if storagecoefficient:
         self.options = self.options + 'STORAGECOEFFICIENT '
     if constantcv: self.options = self.options + 'CONSTANTCV '
     if thickstrt: self.options = self.options + 'THICKSTRT '
     if nocvcorrection: self.options = self.options + 'NOCVCORRECTION '
     if novfc: self.options = self.options + 'NOVFC '
     self.hk = util_3d(model, (nlay,nrow,ncol), np.float32, hk, name='hk',
                       locat=self.unit_number[0])
     self.hani = util_3d(model, (nlay,nrow,ncol), np.float32, hani,
                         name='hani', locat=self.unit_number[0])
     self.vka = util_3d(model, (nlay,nrow,ncol), np.float32, vka,
                        name='vka', locat=self.unit_number[0])
     self.ss = util_3d(model, (nlay,nrow,ncol), np.float32, ss, name='ss',
                       locat=self.unit_number[0])
     self.sy = util_3d(model, (nlay,nrow,ncol), np.float32, sy, name='sy',
                       locat=self.unit_number[0])
     self.vkcb = util_3d(model, (nlay,nrow,ncol), np.float32, vkcb,
                         name='vkcb', locat=self.unit_number[0])
     self.wetdry = util_3d(model, (nlay,nrow,ncol), np.float32, wetdry,
                           name='wetdry', locat=self.unit_number[0])
     self.parent.add_package(self)
     return
Esempio n. 12
0
 def __init__(self, model, nevtop=3, ievtcb=0, surf=0., evtr=1e-3, exdp=1., ievt=1, 
              extension ='evt', unitnumber=22, external=True):
     '''
     external flag is used to control writing external arrays of constant value
     since this package has the potential to create a lot of external arrays
     '''
     Package.__init__(self, model, extension, 'EVT', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     self.heading = '# EVT for MODFLOW, generated by Flopy.'
     self.url = 'evt.htm'
     self.nevtop = nevtop
     self.ievtcb = ievtcb
     self.surf = []
     self.evtr = []
     self.exdp = []
     self.ievt = []        
     self.external = external
     if self.external is False:
         load = True
     else:
         load = model.load            
     if (not isinstance(surf, list)):
         surf = [surf]
     for i,a in enumerate(surf):
         s = util_2d(model,(nrow,ncol),np.float32,a,name='surf_'+str(i+1))
         self.surf = self.surf + [s]
     if (not isinstance(evtr, list)):
         evtr = [evtr]
     for i,a in enumerate(evtr):
         e = util_2d(model,(nrow,ncol),np.float32,a,name='etvr_'+str(i+1))
         self.evtr = self.evtr + [e]
     if (not isinstance(exdp, list)):
         exdp = [exdp]
     for i,a in enumerate(exdp):
         e = util_2d(model,(nrow,ncol),np.float32,a,name='exdp_'+str(i+1))
         self.exdp = self.exdp + [e]
     if (not isinstance(ievt, list)):
         ievt = [ievt]
     for i,a in enumerate(ievt):
         iv = util_2d(model,(nrow,ncol),np.int,a,name='ievt_'+str(i+1))
         self.ievt = self.ievt + [iv]
     self.np = 0
     self.parent.add_package(self)
Esempio n. 13
0
    def __init__(self, model, ibcfcb = 0, intercellt=0,laycon=3, trpy=1.0, hdry=-1E+30, iwdflg=0, wetfct=0.1, iwetit=1, ihdwet=0, \
                 tran=1.0, hy=1.0, vcont=1.0, sf1=1e-5, sf2=0.15, wetdry=-0.01, extension='bcf', unitnumber=15):
        Package.__init__(self, model, extension, 'BCF6', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
        self.url = 'bcf.htm'
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
#        # Set values of all parameters
#        self.intercellt = self.assignarray((nlay,), np.int, intercellt, name='intercellt') # Specifies how to compute intercell conductance
#        self.laycon = self.assignarray((nlay,), np.int, laycon, name='laycon') # Specifies the layer type (LAYCON)
#        self.trpy = self.assignarray((nlay,), np.float, trpy, name='trpy') # Horizontal anisotropy factor for each layer
#        self.ibcfcb = ibcfcb # Unit number for file with cell-by-cell flow terms
#        self.hdry = hdry # Head in cells that are converted to dry during a simulation
#        self.iwdflg = iwdflg # Flag that determines if the wetting capability is active
#        self.wetfct = wetfct # Factor that is included in the calculation of the head when a cell is converted from dry to wet
#        self.iwetit = iwetit # Iteration interval for attempting to wet cells
#        self.ihdwet = ihdwet # Flag that determines which equation is used to define the initial head at cells that become wet     
#        self.tran = self.assignarray((nlay,nrow,ncol), np.float, tran, name='tran', load=True)
#        self.hy = self.assignarray((nlay,nrow,ncol), np.float, hy, name='hy', load=True)
#        self.vcont = self.assignarray((nlay-1,nrow,ncol), np.float, vcont, name='vcont', load=True)
#        self.sf1 = self.assignarray((nlay,nrow,ncol), np.float, sf1, name='sf1', load=True)
#        self.sf2 = self.assignarray((nlay,nrow,ncol), np.float, sf2, name='sf2', load=True)
#        self.wetdry = self.assignarray((nlay,nrow,ncol), np.float, wetdry, name='wetdry', load=True)
        # Set values of all parameters
        #self.intercellt = self.assignarray((nlay,), np.int, intercellt, name='intercellt') # Specifies how to compute intercell conductance
        #self.laycon = self.assignarray((nlay,), np.int, laycon, name='laycon') # Specifies the layer type (LAYCON)
        self.intercellt = util_2d(model,(nlay,),np.int,intercellt,name='laycon',locat=self.unit_number[0])
        self.laycon = util_2d(model,(nlay,),np.int,laycon,name='laycon',locat=self.unit_number[0])
        self.trpy = util_2d(model,(nlay,),np.int,trpy,name='Anisotropy factor',locat=self.unit_number[0])
        self.ibcfcb = ibcfcb # Unit number for file with cell-by-cell flow terms
        self.hdry = hdry # Head in cells that are converted to dry during a simulation
        self.iwdflg = iwdflg # Flag that determines if the wetting capability is active
        self.wetfct = wetfct # Factor that is included in the calculation of the head when a cell is converted from dry to wet
        self.iwetit = iwetit # Iteration interval for attempting to wet cells
        self.ihdwet = ihdwet # Flag that determines which equation is used to define the initial head at cells that become wet     
        self.tran = util_3d(model,(nlay,nrow,ncol),np.float32,tran,'Transmissivity',locat=self.unit_number[0])    
        self.hy = util_3d(model,(nlay,nrow,ncol),np.float32,hy,'Horizontal Hydraulic Conductivity',locat=self.unit_number[0])    
        self.vcont = util_3d(model,(nlay-1,nrow,ncol),np.float32,vcont,'Vertical Conductance',locat=self.unit_number[0])    
        self.sf1 = util_3d(model,(nlay,nrow,ncol),np.float32,sf1,'Primary Storage Coefficient',locat=self.unit_number[0])    
        self.sf2 = util_3d(model,(nlay,nrow,ncol),np.float32,sf2,'Secondary Storage Coefficient',locat=self.unit_number[0])    
        self.wetdry = util_3d(model,(nlay,nrow,ncol),np.float32,wetdry,'WETDRY',locat=self.unit_number[0])
        
        self.parent.add_package(self)
Esempio n. 14
0
 def __init__(self, model, ibcfcb = 0, intercellt=0,laycon=3, trpy=1.0, hdry=-1E+30, iwdflg=0, wetfct=0.1, iwetit=1, ihdwet=0, \
              tran=1.0, hy=1.0, vcont=1.0, sf1=1e-5, sf2=0.15, wetdry=-0.01, extension='bcf', unitnumber=15):
     Package.__init__(self, model, extension, 'BCF6', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
     self.url = 'bcf.htm'
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     # Set values of all parameters
     self.intercellt = util_2d(model,(nlay,),np.int,intercellt,name='laycon',locat=self.unit_number[0])
     self.laycon = util_2d(model,(nlay,),np.int,laycon,name='laycon',locat=self.unit_number[0])
     self.trpy = util_2d(model,(nlay,),np.int,trpy,name='Anisotropy factor',locat=self.unit_number[0])
     self.ibcfcb = ibcfcb # Unit number for file with cell-by-cell flow terms
     self.hdry = hdry # Head in cells that are converted to dry during a simulation
     self.iwdflg = iwdflg # Flag that determines if the wetting capability is active
     self.wetfct = wetfct # Factor that is included in the calculation of the head when a cell is converted from dry to wet
     self.iwetit = iwetit # Iteration interval for attempting to wet cells
     self.ihdwet = ihdwet # Flag that determines which equation is used to define the initial head at cells that become wet     
     self.tran = util_3d(model,(nlay,nrow,ncol),np.float32,tran,'Transmissivity',locat=self.unit_number[0])    
     self.hy = util_3d(model,(nlay,nrow,ncol),np.float32,hy,'Horizontal Hydraulic Conductivity',locat=self.unit_number[0])    
     self.vcont = util_3d(model,(nlay-1,nrow,ncol),np.float32,vcont,'Vertical Conductance',locat=self.unit_number[0])    
     self.sf1 = util_3d(model,(nlay,nrow,ncol),np.float32,sf1,'Primary Storage Coefficient',locat=self.unit_number[0])    
     self.sf2 = util_3d(model,(nlay,nrow,ncol),np.float32,sf2,'Secondary Storage Coefficient',locat=self.unit_number[0])    
     self.wetdry = util_3d(model,(nlay,nrow,ncol),np.float32,wetdry,'WETDRY',locat=self.unit_number[0])       
     self.parent.add_package(self)
Esempio n. 15
0
 def __init__(self, model, ibcfcb=53, intercellt=0,laycon=3, trpy=1.0,
              hdry=-1E+30, iwdflg=0, wetfct=0.1, iwetit=1, ihdwet=0,
              tran=1.0, hy=1.0, vcont=1.0, sf1=1e-5, sf2=0.15, wetdry=-0.01,
              extension='bcf', unitnumber=15):
     Package.__init__(self, model, extension, 'BCF6', unitnumber)
     self.url = 'bcf.htm'
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     # Set values of all parameters
     self.intercellt = util_2d(model, (nlay,), np.int,intercellt,
                               name='laycon',locat=self.unit_number[0])
     self.laycon = util_2d(model, (nlay,), np.int,laycon, name='laycon',
                           locat=self.unit_number[0])
     self.trpy = util_2d(model, (nlay,), np.int, trpy,
                         name='Anisotropy factor',locat=self.unit_number[0])
     self.ibcfcb = ibcfcb
     self.hdry = hdry
     self.iwdflg = iwdflg
     self.wetfct = wetfct
     self.iwetit = iwetit
     self.ihdwet = ihdwet
     self.tran = util_3d(model, (nlay,nrow,ncol), np.float32, tran,
                         'Transmissivity', locat=self.unit_number[0])
     self.hy = util_3d(model, (nlay,nrow,ncol), np.float32, hy,
                       'Horizontal Hydraulic Conductivity',
                       locat=self.unit_number[0])
     self.vcont = util_3d(model, (nlay-1,nrow,ncol), np.float32, vcont,
                          'Vertical Conductance', locat=self.unit_number[0])
     self.sf1 = util_3d(model, (nlay,nrow,ncol), np.float32, sf1,
                        'Primary Storage Coefficient',
                        locat=self.unit_number[0])
     self.sf2 = util_3d(model, (nlay,nrow,ncol), np.float32, sf2,
                        'Secondary Storage Coefficient',
                        locat=self.unit_number[0])
     self.wetdry = util_3d(model, (nlay,nrow,ncol), np.float32, wetdry,
                           'WETDRY', locat=self.unit_number[0])
     self.parent.add_package(self)
Esempio n. 16
0
    def __init__(self, model, nlay=1, nrow=2, ncol=2, nper=1, delr=1.0,
                 delc=1.0, laycbd=0, top=1, botm=0, perlen=1, nstp=1,
                 tsmult=1, steady=True, itmuni=4, lenuni=2, extension='dis',
                 unitnumber=11, xul=None, yul=None, rotation=0.0):

        # Call ancestor's init to set self.parent, extension, name and unit
        # number
        Package.__init__(self, model, extension, 'DIS', unitnumber)
        self.url = 'dis.htm'
        self.nrow = nrow
        self.ncol = ncol
        self.nlay = nlay
        self.nper = nper

        # Set values of all parameters
        self.heading = '# Discretization file for MODFLOW, generated by Flopy.'
        self.laycbd = util_2d(model, (self.nlay,), np.int, laycbd,
                              name='laycbd')
        self.laycbd[-1] = 0  # bottom layer must be zero
        self.delr = util_2d(model, (self.ncol,), np.float32, delr, name='delr',
                            locat=self.unit_number[0])
        self.delc = util_2d(model,(self.nrow,), np.float32, delc, name='delc',
                            locat=self.unit_number[0])
        self.top = util_2d(model, (self.nrow,self.ncol), np.float32,
                           top,name='model_top', locat=self.unit_number[0])
        self.botm = util_3d(model, (self.nlay+sum(self.laycbd),
                                    self.nrow,self.ncol), np.float32, botm,
                                    'botm', locat=self.unit_number[0])
        self.perlen = util_2d(model, (self.nper,), np.float32, perlen,
                              name='perlen')
        self.nstp = util_2d(model, (self.nper,), np.int, nstp, name='nstp')
        self.tsmult = util_2d(model, (self.nper,), np.float32, tsmult,
                              name='tsmult')
        self.steady = util_2d(model, (self.nper,), np.bool,
                              steady,name='steady')
        self.itmuni = int(itmuni)
        self.lenuni = int(lenuni)
        self.parent.add_package(self)
        self.itmuni_dict = {0: "undefined", 1: "seconds", 2: "minutes",
                            3: "hours", 4: "days", 5: "years"}

        self.sr = reference.SpatialReference(self.delr.array, self.delc.array, self.lenuni, xul=xul,
                                             yul=yul, rotation=rotation)
Esempio n. 17
0
    def __init__(self, model, nlay=1, nrow=2, ncol=2, nper=1, delr=1.0,
                 delc=1.0, laycbd=0, top=1, botm=0, perlen=1, nstp=1,
                 tsmult=1, steady=True, itmuni=4, lenuni=2, extension='dis',
                 unitnumber=11):

        # Call ancestor's init to set self.parent, extension, name and unit
        # number
        Package.__init__(self, model, extension, 'DIS', unitnumber)
        self.url = 'dis.htm'
        self.nrow = nrow
        self.ncol = ncol
        self.nlay = nlay
        self.nper = nper
        
        # Set values of all parameters
        self.heading = '# Discretization file for MODFLOW, generated by Flopy.'
        self.laycbd = util_2d(model, (self.nlay,), np.int, laycbd,
                              name='laycbd')
        self.laycbd[-1] = 0  # bottom layer must be zero
        self.delr = util_2d(model, (self.ncol,), np.float32, delr, name='delr',
                            locat=self.unit_number[0])
        self.delc = util_2d(model,(self.nrow,), np.float32, delc, name='delc',
                            locat=self.unit_number[0])
        self.top = util_2d(model, (self.nrow,self.ncol), np.float32,
                           top,name='model_top', locat=self.unit_number[0])
        self.botm = util_3d(model, (self.nlay+sum(self.laycbd),
                                    self.nrow,self.ncol), np.float32, botm,
                                    'botm', locat=self.unit_number[0])
        self.perlen = util_2d(model, (self.nper,), np.float32, perlen,
                              name='perlen')
        self.nstp = util_2d(model, (self.nper,), np.int, nstp, name='nstp')
        self.tsmult = util_2d(model, (self.nper,), np.float32,tsmult,
                              name='tsmult')
        self.steady = util_2d(model, (self.nper,), np.bool,
                              steady,name='steady')
        self.itmuni = itmuni
        self.lenuni = lenuni
        self.parent.add_package(self)
Esempio n. 18
0
File: mfuzf1.py Progetto: ksl0/flopy
 def __init__(self, model, \
 nuztop = 1, iuzfopt = 0, irunflg = 0, ietflg = 0, iuzfcb1 = 57, iuzfcb2 = 0, ntrail2 = 10, nsets = 20, nuzgag = 0, surfdep = 1.0, \
 iuzfbnd = 1, irunbnd = 0, vks = 1.0E-6, eps = 3.5, thts = 0.35, thtr = 0.15, thti = 0.20, row_col_iftunit_iuzopt = [], \
 specifythtr = 0, specifythti = 0, nosurfleak = 0, \
 finf = 1.0E-8, pet = 5.0E-8, extdp = 15.0, extwc = 0.1, \
 uzfbud_ext = [], extension ='uzf', unitnumber = 19):
     Package.__init__(self, model, extension, ['UZF'], unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
     if self.parent.get_package('RCH') != None or self.parent.get_package('EVT') != None:
         print('WARNING!\n The RCH and EVT packages should not be active when the UZF1 package is active!')
     if self.parent.version == 'mf2000':
         print('WARNING!\nThe UZF1 package is only compatible with MODFLOW-2005 and MODFLOW-NWT!')
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     self.heading = '# UZF1 for MODFLOW, generated by Flopy.'
     self.url = 'uzf_unsaturated_zone_flow_pack.htm'
     # Data Set 1a
     self.specifythtr = specifythtr
     self.specifythti = specifythti
     self.nosurfleak  = nosurfleak
     # Data Set 1b
     # NUZTOP IUZFOPT IRUNFLG IETFLG IUZFCB1 IUZFCB2 [NTRAIL2 NSETS2] NUZGAG SURFDEP
     self.nuztop = nuztop
     self.iuzfopt = iuzfopt
     self.irunflg = irunflg
     self.ietflg = ietflg
     self.iuzfcb1 = iuzfcb1
     self.iuzfcb2 = iuzfcb2
     class_nam = ['UZF']
     if (not isinstance(unitnumber, list)):
         unitnumber = [unitnumber]
     if (not isinstance(extension, list)):
         extension = [extension]
     if iuzfcb1 > 0 and iuzfcb2 < 1:
         unitnumber.append(iuzfcb1)
         extension.append(extension[0]+'bt1')
         class_nam += ['DATA(BINARY)']
     elif iuzfcb1 < 1 and iuzfcb2 > 0:
         unitnumber.append(iuzfcb2)
         extension.append(extension[0]+'bt2')
         class_nam += ['DATA(BINARY)']
     elif iuzfcb1 > 0 and iuzfcb2 > 0:
         unitnumber.append(iuzfcb1)
         extension.append(extension[0]+'bt1')
         unitnumber.append(iuzfcb2)
         extension.append(extension[0]+'bt2')
         class_nam += ['DATA(BINARY)','DATA(BINARY)']
     if iuzfopt > 0:
         self.ntrail2 = ntrail2
         self.nsets = nsets
     self.nuzgag = nuzgag
     self.surfdep = surfdep
     #Data Set 2
     #IUZFBND (NCOL, NROW) -- U2DINT            
     self.iuzfbnd = util_2d(model,(nrow,ncol),np.int,iuzfbnd,name='iuzfbnd')
     #If IRUNFLG > 0: Read item 3
     #Data Set 3
     #[IRUNBND (NCOL, NROW)] -- U2DINT
     if irunflg > 0:            
         self.irunbnd = util_2d(model,(nrow,ncol),np.int,irunbnd,name='irunbnd')
     #IF the absolute value of IUZFOPT = 1: Read item 4.
     #Data Set 4
     #[VKS (NCOL, NROW)] -- U2DREL
     if abs(iuzfopt) == 1:            
         self.vks = util_2d(model,(nrow,ncol),np.float32,vks,name='vks')
     if iuzfopt > 0:
         #Data Set 5
         #EPS (NCOL, NROW) -- U2DREL            
         self.eps = util_2d(model,(nrow,ncol),np.float32,eps,name='eps')
         #Data Set 6a
         #THTS (NCOL, NROW) -- U2DREL            
         self.thts = util_2d(model,(nrow,ncol),np.float32,thts,name='thts')
         #Data Set 6b
         #THTS (NCOL, NROW) -- U2DREL
         if self.specifythtr > 0:                
             self.thtr = util_2d(model,(nrow,ncol),np.float32,thtr,name='thtr')
         #Data Set 7
         #[THTI (NCOL, NROW)] -- U2DREL            
         self.thti = util_2d(model,(nrow,ncol),np.float32,thti,name='thti')
     #Data Set 8
     #[IUZROW] [IUZCOL] IFTUNIT [IUZOPT]
     if len(row_col_iftunit_iuzopt) != nuzgag:
         print("WARNING!\nItem 8 doesn't correspond with NUZGAG.\nNUZGAG set to 0")
         self.nuzgag = 0
         self.row_col_iftunit_iuzopt = []
     else:
         self.row_col_iftunit_iuzopt = row_col_iftunit_iuzopt
         i = 0
         for l in row_col_iftunit_iuzopt:
             unitnumber.append(abs(l[0][2]))
             if uzfbud_ext ==[]:
                 extension.append(extension[0] + 'b' + str(i))
             else:
                 extension.append(uzfbud_ext[i])
             i += 1
         Package.__init__(self,model,extension,class_nam+nuzgag*['DATA'],unit_number=unitnumber)
     #Dataset 9, 11, 13 and 15 will be written automatically in the write_file function
     #Data Set 10
     #[FINF (NCOL, NROW)] – U2DREL
     self.finf = []
     if (not isinstance(finf, list)):
         finf = [finf]
     for i,a in enumerate(finf):          
         b = util_2d(model,(nrow,ncol),np.float32,a,name='finf_'+str(i+1))
         self.finf = self.finf + [b]
     if ietflg > 0:
         #Data Set 12
         #[PET (NCOL, NROW)] – U2DREL
         self.pet = []
         if (not isinstance(pet, list)):
             pet = [pet]
         for i,a in enumerate(pet):               
             b = util_2d(model,(nrow,ncol),np.float32,a,name='pet_'+str(i+1))
             self.pet = self.pet + [b]
         #Data Set 14
         #[EXTDP (NCOL, NROW)] – U2DREL
         self.extdp = []
         if (not isinstance(extdp, list)):
             extdp = [extdp]
         for i,a in enumerate(extdp):               
             b = util_2d(model,(nrow,ncol),np.float32,a,name='extdp_'+str(i+1))
             self.extdp = self.extdp + [b]
         #Data Set 16
         #[EXTWC (NCOL, NROW)] – U2DREL
         if iuzfopt> 0:
             self.extwc = []
             if (not isinstance(extwc, list)):
                 extwc = [extwc]
             for i,a in enumerate(extwc):                   
                 b = util_2d(model,(nrow,ncol),np.float32,a,name='extwc_'+str(i+1))
                 self.extwc = self.extwc + [b]
     self.parent.add_package(self)
Esempio n. 19
0
 def __init__(self,
              model,
              laytyp=0,
              layavg=0,
              chani=1.0,
              layvka=0,
              laywet=0,
              ilpfcb=53,
              hdry=-1E+30,
              iwdflg=0,
              wetfct=0.1,
              iwetit=1,
              ihdwet=0,
              hk=1.0,
              hani=1.0,
              vka=1.0,
              ss=1e-5,
              sy=0.15,
              vkcb=0.0,
              wetdry=-0.01,
              storagecoefficient=False,
              constantcv=False,
              thickstrt=False,
              nocvcorrection=False,
              novfc=False,
              extension='lpf',
              unitnumber=15):
     Package.__init__(
         self, model, extension, 'LPF', unitnumber
     )  # Call ancestor's init to set self.parent, extension, name and unit number
     self.heading = '# LPF for MODFLOW, generated by Flopy.'
     self.url = 'lpf.htm'
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     # item 1
     self.ilpfcb = ilpfcb  # Unit number for file with cell-by-cell flow terms
     self.hdry = hdry  # Head in cells that are converted to dry during a simulation
     self.nplpf = 0  # number of LPF parameters
     self.laytyp = util_2d(model, (nlay, ), np.int, laytyp, name='laytyp')
     self.layavg = util_2d(model, (nlay, ), np.int, layavg, name='layavg')
     self.chani = util_2d(model, (nlay, ), np.int, chani, name='chani')
     self.layvka = util_2d(model, (nlay, ), np.int, layvka, name='layvka')
     self.laywet = util_2d(model, (nlay, ), np.int, laywet, name='laywet')
     self.wetfct = wetfct  # Factor that is included in the calculation of the head when a cell is converted from dry to wet
     self.iwetit = iwetit  # Iteration interval for attempting to wet cells
     self.ihdwet = ihdwet  # Flag that determines which equation is used to define the initial head at cells that become wet
     self.options = ' '
     if storagecoefficient:
         self.options = self.options + 'STORAGECOEFFICIENT '
     if constantcv: self.options = self.options + 'CONSTANTCV '
     if thickstrt: self.options = self.options + 'THICKSTRT '
     if nocvcorrection: self.options = self.options + 'NOCVCORRECTION '
     if novfc: self.options = self.options + 'NOVFC '
     self.hk = util_3d(model, (nlay, nrow, ncol),
                       np.float32,
                       hk,
                       name='hk',
                       locat=self.unit_number[0])
     self.hani = util_3d(model, (nlay, nrow, ncol),
                         np.float32,
                         hani,
                         name='hani',
                         locat=self.unit_number[0])
     self.vka = util_3d(model, (nlay, nrow, ncol),
                        np.float32,
                        vka,
                        name='vka',
                        locat=self.unit_number[0])
     self.ss = util_3d(model, (nlay, nrow, ncol),
                       np.float32,
                       ss,
                       name='ss',
                       locat=self.unit_number[0])
     self.sy = util_3d(model, (nlay, nrow, ncol),
                       np.float32,
                       sy,
                       name='sy',
                       locat=self.unit_number[0])
     self.vkcb = util_3d(model, (nlay, nrow, ncol),
                         np.float32,
                         vkcb,
                         name='vkcb',
                         locat=self.unit_number[0])
     self.wetdry = util_3d(model, (nlay, nrow, ncol),
                           np.float32,
                           wetdry,
                           name='wetdry',
                           locat=self.unit_number[0])
     self.parent.add_package(self)
     return
Esempio n. 20
0
 def __init__(self,
              model,
              al=0.01,
              trpt=0.1,
              trpv=0.01,
              dmcoef=1e-9,
              extension='dsp',
              multiDiff=False,
              **kwargs):
     '''
     if dmcoef is passed as a list of (nlay, nrow, ncol) arrays,
     then the multicomponent diffusion is activated
     '''
     # Call ancestor's init to set self.parent, extension, name and
     #unit number
     Package.__init__(self, model, extension, 'DSP', 33)
     nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
     ncomp = self.parent.get_ncomp()
     # if multiDiff:
     #     assert isinstance(dmcoef,list),('using multicomponent diffusion '
     #                                     'requires dmcoef is list of '
     #                                     'length ncomp')
     #     if len(dmcoef) != ncomp:
     #         raise TypeError,('using multicomponent diffusion requires '
     #                          'dmcoef is list of length ncomp')
     self.multiDiff = multiDiff
     #self.al = self.assignarray((nlay, nrow, ncol), np.float, al,
     #                           name='al', load=model.load )
     self.al = util_3d(model, (nlay, nrow, ncol),
                       np.float32,
                       al,
                       name='al',
                       locat=self.unit_number[0])
     #self.trpt = self.assignarray((nlay,), np.float, trpt, name='trpt',
     #                             load=model.load)
     self.trpt = util_2d(model, (nlay, ),
                         np.float32,
                         trpt,
                         name='trpt',
                         locat=self.unit_number[0])
     #self.trpv = self.assignarray((nlay,), np.float, trpv, name='trpv',
     #                             load=model.load)
     self.trpv = util_2d(model, (nlay, ),
                         np.float32,
                         trpt,
                         name='trpv',
                         locat=self.unit_number[0])
     self.dmcoef = []
     a = util_3d(model, (nlay, nrow, ncol),
                 np.float32,
                 dmcoef,
                 name='dmcoef1',
                 locat=self.unit_number[0])
     self.dmcoef.append(a)
     if self.multiDiff:
         for icomp in range(2, ncomp + 1):
             name = "dmcoef" + str(icomp)
             val = 0.0
             if name in kwargs.keys():
                 val = kwargs[name]
                 kwargs.pop(name)
             else:
                 print "DSP: setting dmcoef for component " +\
                       str(icomp) + " to zero, kwarg name " +\
                       name
             a = util_3d(model, (nlay, nrow, ncol),
                         np.float32,
                         val,
                         name=name,
                         locat=self.unit_number[0])
             self.dmcoef.append(a)
     if len(kwargs.keys()) > 0:
         raise Exception("DSP error: unrecognized kwargs: " +
                         ' '.join(kwargs.keys()))
     self.parent.add_package(self)
     return
Esempio n. 21
0
    def write_file(self):
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        ModflowDis = self.parent.mf.get_package('DIS')
        # Open file for writing
        f_btn = open(self.fn_path, 'w')
        f_btn.write('#{0:s}\n#{1:s}\n'.format(self.heading1,self.heading2))
        f_btn.write('{0:10d}{1:10d}{2:10d}{3:10d}{4:10d}{5:10d}\n'
            .format(nlay, nrow, ncol, nper, self.ncomp, self.mcomp))
        f_btn.write('{0:4s}{1:4s}{2:4s}\n'\
            .format(self.tunit, self.lunit, self.munit))
        if (self.parent.adv != None):         
            f_btn.write('{0:2s}'.format('T'))
        else:            
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.dsp != None):
            f_btn.write('{0:2s}'.format('T'))
        else:           
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.ssm != None):            
            f_btn.write('{0:2s}'.format('T'))
        else:
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.rct != None):            
            f_btn.write('{0:2s}'.format('T'))
        else:           
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.gcg != None):            
            f_btn.write('{0:2s}'.format('T'))
        else:            
            f_btn.write('{0:2s}'.format('F'))
        f_btn.write('\n')
        flow_package = self.parent.mf.get_package('BCF6')
        if (flow_package != None):
            lc = util_2d(self.parent, (nlay,), np.int,
                         flow_package.laycon.get_value(),
                         name='btn - laytype',
                         locat=self.unit_number[0])
        else:
            flow_package = self.parent.mf.get_package('LPF')
            if (flow_package != None):
                lc = util_2d(self.parent, (nlay,),
                             np.int, flow_package.laytyp.get_value(),
                             name='btn - laytype', locat=self.unit_number[0])
        #--need to reset lc fmtin
        lc.set_fmtin('(40I2)')
        f_btn.write(lc.string)        
        delr = util_2d(self.parent, (ncol,),
                       np.float32, ModflowDis.delr.get_value(),
                       name='delr', locat=self.unit_number[0])
        f_btn.write(delr.get_file_entry())
        
        delc = util_2d(self.parent, (nrow,), np.float32,
                       ModflowDis.delc.get_value(), name='delc',
                       locat=self.unit_number[0])
        f_btn.write(delc.get_file_entry())

        top = util_2d(self.parent, (nrow,ncol),
                      np.float32, ModflowDis.top.array,
                      name='top', locat=self.unit_number[0])
        f_btn.write(top.get_file_entry())
        
        thickness = util_3d(self.parent, (nlay, nrow, ncol),
                            np.float32, ModflowDis.thickness.get_value(),
                            name='thickness', locat=self.unit_number[0])
        f_btn.write(thickness.get_file_entry())
                
        f_btn.write(self.prsity.get_file_entry())
        
        f_btn.write(self.__icbund.get_file_entry())
              
        # Starting concentrations
        for s in range(len(self.sconc)):            
            f_btn.write(self.sconc[s].get_file_entry())
               
        f_btn.write('{0:10.0E}{1:10.4f}\n'\
            .format(self.cinact,self.thkmin))
               
        f_btn.write('{0:10d}{1:10d}{2:10d}{3:10d}'\
            .format(self.ifmtcn, self.ifmtnp, self.ifmtrf, self.ifmtdp))
        if (self.savucn == True):
            ss = 'T'
        else:
            ss = 'F'        
        f_btn.write('{0:>10s}\n'.format(ss))
        
        # NPRS
        if (self.timprs == None):            
            f_btn.write('{0:10d}\n'.format(self.nprs))
        else:            
            f_btn.write('{0:10d}\n'.format(len(self.timprs)))        
            timprs = util_2d(self.parent, (len(self.timprs),),
                             np.int, self.timprs, name='timprs',
                             fmtin='(8F10.0)')
            f_btn.write(timprs.string)
        # OBS
        if (self.obs == None):            
            f_btn.write('{0:10d}{1:10d}\n'.format(0, self.nprobs))
        else:
            nobs = self.obs.shape[0]            
            f_btn.write('{0:10d}{1:10d}\n'.format(nobs, self.nprobs))
            for r in range(nobs):                
                f_btn.write('{0:10d}{1:10d}{2:10d}\n'\
                    .format(self.obs[r, 0], self.obs[r, 1], self.obs[r, 2]))
        # CHKMAS, NPRMAS
        if (self.chkmas == True):
            ss = 'T'
        else:
            ss = 'F'        
        f_btn.write('{0:>10s}{1:10d}\n'.format(ss, self.nprmas))
        # PERLEN, NSTP, TSMULT
        for t in range(nper):            
            f_btn.write('{0:10.4G}{1:10d}{2:10.4G}\n'
                        .format(ModflowDis.perlen[t], ModflowDis.nstp[t],
                        ModflowDis.tsmult[t]))
            f_btn.write('{0:10.4G}{1:10d}{2:10.4G}{3:10.4G}\n'
                        .format(self.dt0[t], self.mxstrn[t],
                        self.ttsmult[t], self.ttsmax[t]))
        f_btn.close() 
Esempio n. 22
0
    def __init__(
        self,
        model,
        nsrf=1,
        istrat=1,
        nobs=0,
        iswizt=55,
        iswibd=56,
        iswiobs=0,
        options=None,
        nsolver=1,
        iprsol=0,
        mutsol=3,
        solver2params={
            "mxiter": 100,
            "iter1": 20,
            "npcond": 1,
            "zclose": 1e-3,
            "rclose": 1e-4,
            "relax": 1.0,
            "nbpol": 2,
            "damp": 1.0,
            "dampt": 1.0,
        },
        toeslope=0.05,
        tipslope=0.05,
        alpha=None,
        beta=0.1,
        nadptmx=1,
        nadptmn=1,
        adptfct=1.0,
        nu=0.025,
        zeta=0.0,
        ssz=0.25,
        isource=0,
        obsnam=[],
        obslrc=[],
        extension=["swi2", "zta", "swb"],
        unit_number=29,
        npln=None,
    ):
        """
        Package constructor.

        """
        name = ["SWI2", "DATA(BINARY)", "DATA(BINARY)"]
        units = [unit_number, iswizt, iswibd]
        extra = ["", "REPLACE", "REPLACE"]
        if nobs > 0:
            extension.append("zobs")
            name.append("DATA")
            units.append(iswiobs)
            extra.append("REPLACE")

        Package.__init__(
            self, model, extension=extension, name=name, unit_number=units, extra=extra
        )  # Call ancestor's init to set self.parent, extension, name and unit number

        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        self.heading = "# Salt Water Intrusion (SWI2) package file for MODFLOW-2005, generated by Flopy."

        # options
        self.fsssopt, self.adaptive = False, False
        if isinstance(options, list):
            if len(options) < 1:
                self.options = None
            else:
                self.options = options
                for o in self.options:
                    if o.lower() == "fsssopt":
                        self.fsssopt = True
                    elif o.lower() == "adaptive":
                        self.adaptive = True
        else:
            self.options = None

        if npln is not None:
            print("npln keyword is deprecated. use the nsrf keyword")
            nsrf = npln

        self.nsrf, self.istrat, self.nobs, self.iswizt, self.iswibd, self.iswiobs = (
            nsrf,
            istrat,
            nobs,
            iswizt,
            iswibd,
            iswiobs,
        )
        #
        self.nsolver, self.iprsol, self.mutsol = nsolver, iprsol, mutsol
        #
        self.solver2params = solver2params
        #
        self.toeslope, self.tipslope, self.alpha, self.beta = toeslope, tipslope, alpha, beta
        self.nadptmx, self.nadptmn, self.adptfct = nadptmx, nadptmn, adptfct
        # Create arrays so that they have the correct size
        if self.istrat == 1:
            self.nu = util_2d(model, (self.nsrf + 1,), np.float32, nu, name="nu")
        else:
            self.nu = util_2d(model, (self.nsrf + 2,), np.float32, nu, name="nu")
        self.zeta = []
        for i in range(self.nsrf):
            self.zeta.append(util_3d(model, (nlay, nrow, ncol), np.float32, zeta[i], name="zeta_" + str(i + 1)))
        self.ssz = util_3d(model, (nlay, nrow, ncol), np.float32, ssz, name="ssz")
        self.isource = util_3d(model, (nlay, nrow, ncol), np.int, isource, name="isource")
        #
        self.obsnam = obsnam
        if isinstance(obslrc, list):
            obslrc = np.array(obslrc, dtype=np.int)
        self.obslrc = obslrc
        #
        self.parent.add_package(self)
Esempio n. 23
0
 def __init__(self, model, nsrf=1, istrat=1, nobs=0, iswizt=55, iswibd=56, iswiobs=0, fsssopt=False, adaptive=False, \
              nsolver=1, iprsol=0, mutsol=3, \
              solver2params = {'mxiter':100, 'iter1':20, 'npcond':1, 'zclose':1e-3, 'rclose':1e-4, 'relax':1.0, 'nbpol':2, 'damp':1.0, 'dampt':1.0}, \
              toeslope=0.05, tipslope=0.05, alpha=None, beta=0.1, nadptmx=1, nadptmn=1, adptfct=1.0, \
              nu=0.025, zeta=[], ssz=[], isource=0, \
              obsnam=[], obslrc=[],
              extension=['swi2','zta','swb'], unit_number=29, \
              npln=None):
     name = ['SWI2', 'DATA(BINARY)', 'DATA(BINARY)']
     units = [unit_number,iswizt,iswibd]
     extra = ['','REPLACE','REPLACE']
     if nobs > 0:
         extension = name.append('zobs')
         name = name.append('DATA')
         units = units.append(iswiobs)
         extra = extra.append('')
     #Package.__init__(self, model, ) # Call ancestor's init to set self.parent
     #Package.__init__(self, model, extension, ['SWI', 'DATA(BINARY)', 'DATA(BINARY)'], [unit_number,iswizt,iswibd], extra=['','REPLACE','REPLACE']) # Call ancestor's init to set self.parent, extension, name and unit number
     Package.__init__(self, model, extension=extension, name=name, unit_number=units, extra=extra) # Call ancestor's init to set self.parent, extension, name and unit number
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     self.heading = '# Salt Water Intrusion (SWI2) package file for MODFLOW-2005, generated by Flopy.'
     #
     self.fsssopt, self.adaptive = fsssopt, adaptive
     #
     if npln is not None:
         print 'npln keyword is deprecated. use the nsrf keyword'
         nsrf = npln
     self.nsrf, self.istrat, self.nobs, self.iswizt, self.iswibd, self.iswiobs = nsrf, istrat, nobs, iswizt, iswibd, iswiobs
     #
     self.nsolver, self.iprsol, self.mutsol = nsolver, iprsol, mutsol
     #
     self.solver2params = solver2params
     #        
     self.toeslope, self.tipslope, self.alpha, self.beta = toeslope, tipslope, alpha, beta
     self.nadptmx, self.nadptmn, self.adptfct = nadptmx, nadptmn, adptfct
     # Create arrays so that they have the correct size
     if self.istrat == 1:
         #self.nu = empty( self.nsrf+1 )
         self.nu = util_2d(model,(self.nsrf+1,),np.float32,nu,name='nu')
     else:
         #self.nu = empty( self.nsrf+2 )
         self.nu = util_2d(model,(self.nsrf+2,),np.float32,nu,name='nu')
     self.zeta = []
     #for i in range(nlay):
     #    self.zeta.append( empty((nrow, ncol, self.nsrf)) )
     #self.ssz = empty((nrow, ncol, nlay))
     #self.isource = empty((nrow, ncol, nlay),dtype='int32')
     # Set values of arrays
     #self.assignarray_old( self.nu, nu )
     for i in range(self.nsrf):
         #self.assignarray_old( self.zeta[i], zeta[i] )
         self.zeta.append(util_3d(model,(nlay,nrow,ncol),np.float32,zeta[i],name='zeta_'+str(i+1)))
     #self.assignarray_old( self.ssz, ssz )
     self.ssz = util_3d(model,(nlay,nrow,ncol),np.float32,ssz,name='ssz')
     #self.assignarray_old( self.isource, isource )
     self.isource = util_3d(model,(nlay,nrow,ncol),np.int,isource,name='isource')
     #
     self.obsnam = obsnam
     self.obslrc = obslrc
     #
     self.parent.add_package(self)
Esempio n. 24
0
    def write_file(self):
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        ModflowDis = self.parent.mf.get_package("DIS")
        # Open file for writing
        f_btn = open(self.fn_path, "w")
        f_btn.write("#{0:s}\n#{1:s}\n".format(self.heading1, self.heading2))
        f_btn.write(
            "{0:10d}{1:10d}{2:10d}{3:10d}{4:10d}{5:10d}\n".format(nlay, nrow, ncol, nper, self.ncomp, self.mcomp)
        )
        f_btn.write("{0:4s}{1:4s}{2:4s}\n".format(self.tunit, self.lunit, self.munit))
        if self.parent.adv != None:
            f_btn.write("{0:2s}".format("T"))
        else:
            f_btn.write("{0:2s}".format("F"))
        if self.parent.dsp != None:
            f_btn.write("{0:2s}".format("T"))
        else:
            f_btn.write("{0:2s}".format("F"))
        if self.parent.ssm != None:
            f_btn.write("{0:2s}".format("T"))
        else:
            f_btn.write("{0:2s}".format("F"))
        if self.parent.rct != None:
            f_btn.write("{0:2s}".format("T"))
        else:
            f_btn.write("{0:2s}".format("F"))
        if self.parent.gcg != None:
            f_btn.write("{0:2s}".format("T"))
        else:
            f_btn.write("{0:2s}".format("F"))
        f_btn.write("\n")
        flow_package = self.parent.mf.get_package("BCF6")
        if flow_package != None:
            lc = util_2d(
                self.parent,
                (nlay,),
                np.int,
                flow_package.laycon.get_value(),
                name="btn - laytype",
                locat=self.unit_number[0],
            )
        else:
            flow_package = self.parent.mf.get_package("LPF")
            if flow_package != None:
                lc = util_2d(
                    self.parent,
                    (nlay,),
                    np.int,
                    flow_package.laytyp.get_value(),
                    name="btn - laytype",
                    locat=self.unit_number[0],
                )
        # --need to reset lc fmtin
        lc.set_fmtin("(40I2)")
        f_btn.write(lc.string)
        delr = util_2d(
            self.parent, (ncol,), np.float32, ModflowDis.delr.get_value(), name="delr", locat=self.unit_number[0]
        )
        f_btn.write(delr.get_file_entry())

        delc = util_2d(
            self.parent, (nrow,), np.float32, ModflowDis.delc.get_value(), name="delc", locat=self.unit_number[0]
        )
        f_btn.write(delc.get_file_entry())

        top = util_2d(
            self.parent, (nrow, ncol), np.float32, ModflowDis.top.array, name="top", locat=self.unit_number[0]
        )
        f_btn.write(top.get_file_entry())

        thickness = util_3d(
            self.parent,
            (nlay, nrow, ncol),
            np.float32,
            ModflowDis.thickness.get_value(),
            name="thickness",
            locat=self.unit_number[0],
        )
        f_btn.write(thickness.get_file_entry())

        f_btn.write(self.prsity.get_file_entry())

        f_btn.write(self.icbund.get_file_entry())

        # Starting concentrations
        for s in range(len(self.sconc)):
            f_btn.write(self.sconc[s].get_file_entry())

        f_btn.write("{0:10.0E}{1:10.4f}\n".format(self.cinact, self.thkmin))

        f_btn.write("{0:10d}{1:10d}{2:10d}{3:10d}".format(self.ifmtcn, self.ifmtnp, self.ifmtrf, self.ifmtdp))
        if self.savucn == True:
            ss = "T"
        else:
            ss = "F"
        f_btn.write("{0:>10s}\n".format(ss))

        # NPRS
        if self.timprs == None:
            f_btn.write("{0:10d}\n".format(self.nprs))
        else:
            f_btn.write("{0:10d}\n".format(len(self.timprs)))
            timprs = util_2d(self.parent, (len(self.timprs),), np.int, self.timprs, name="timprs", fmtin="(8F10.0)")
            f_btn.write(timprs.string)
        # OBS
        if self.obs == None:
            f_btn.write("{0:10d}{1:10d}\n".format(0, self.nprobs))
        else:
            nobs = self.obs.shape[0]
            f_btn.write("{0:10d}{1:10d}\n".format(nobs, self.nprobs))
            for r in range(nobs):
                f_btn.write("{0:10d}{1:10d}{2:10d}\n".format(self.obs[r, 0], self.obs[r, 1], self.obs[r, 2]))
        # CHKMAS, NPRMAS
        if self.chkmas == True:
            ss = "T"
        else:
            ss = "F"
        f_btn.write("{0:>10s}{1:10d}\n".format(ss, self.nprmas))
        # PERLEN, NSTP, TSMULT
        for t in range(nper):
            f_btn.write(
                "{0:10.4g}{1:10d}{2:10f}\n".format(ModflowDis.perlen[t], ModflowDis.nstp[t], ModflowDis.tsmult[t])
            )
            f_btn.write(
                "{0:10.4g}{1:10d}{2:10f}{3:10f}\n".format(self.dt0[t], self.mxstrn[t], self.ttsmult[t], self.ttsmax[t])
            )
        f_btn.close()
Esempio n. 25
0
    def __init__(self,
                 model,
                 nlay=1,
                 nrow=2,
                 ncol=2,
                 nper=1,
                 delr=1.0,
                 delc=1.0,
                 laycbd=0,
                 top=1,
                 botm=0,
                 perlen=1,
                 nstp=1,
                 tsmult=1,
                 steady=True,
                 itmuni=4,
                 lenuni=2,
                 extension='dis',
                 unitnumber=11):

        # Call ancestor's init to set self.parent, extension, name and unit
        # number
        Package.__init__(self, model, extension, 'DIS', unitnumber)
        self.url = 'dis.htm'
        self.nrow = nrow
        self.ncol = ncol
        self.nlay = nlay
        self.nper = nper

        # Set values of all parameters
        self.heading = '# Discretization file for MODFLOW, generated by Flopy.'
        self.laycbd = util_2d(model, (self.nlay, ),
                              np.int,
                              laycbd,
                              name='laycbd')
        self.laycbd[-1] = 0  # bottom layer must be zero
        self.delr = util_2d(model, (self.ncol, ),
                            np.float32,
                            delr,
                            name='delr',
                            locat=self.unit_number[0])
        self.delc = util_2d(model, (self.nrow, ),
                            np.float32,
                            delc,
                            name='delc',
                            locat=self.unit_number[0])
        self.top = util_2d(model, (self.nrow, self.ncol),
                           np.float32,
                           top,
                           name='model_top',
                           locat=self.unit_number[0])
        self.botm = util_3d(
            model, (self.nlay + sum(self.laycbd), self.nrow, self.ncol),
            np.float32,
            botm,
            'botm',
            locat=self.unit_number[0])
        self.perlen = util_2d(model, (self.nper, ),
                              np.float32,
                              perlen,
                              name='perlen')
        self.nstp = util_2d(model, (self.nper, ), np.int, nstp, name='nstp')
        self.tsmult = util_2d(model, (self.nper, ),
                              np.float32,
                              tsmult,
                              name='tsmult')
        self.steady = util_2d(model, (self.nper, ),
                              np.bool,
                              steady,
                              name='steady')
        self.itmuni = itmuni
        self.lenuni = lenuni
        self.parent.add_package(self)
        self.itmuni_dict = {
            0: "undefined",
            1: "seconds",
            2: "minutes",
            3: "hours",
            4: "days",
            5: "years"
        }
Esempio n. 26
0
    def read_from_cnf(self, cnf_file_name, n_per_line = 0):
        """
        Read discretization informatio from an MT3D configuration file.

        """

        def getn(ii, jj):
            if (jj == 0):
                n = 1
            else:
                n = int(ii / jj)
                if (ii % jj != 0):
                    n = n + 1

            return n

        try:
            f_cnf = open(cnf_file_name, 'r')

            # nlay, nrow, ncol
            line = f_cnf.readline()
            s = line.split()
            cnf_nlay = int(s[0])
            cnf_nrow = int(s[1])
            cnf_ncol = int(s[2])

            # ncol column widths delr[c]
            line = ''
            for dummy in range(getn(cnf_ncol, n_per_line)):
                line = line + f_cnf.readline()
            cnf_delr = [float(s) for s in line.split()]

            # nrow row widths delc[r]
            line = ''
            for dummy in range(getn(cnf_nrow, n_per_line)):
                line = line + f_cnf.readline()
            cnf_delc = [float(s) for s in line.split()]

            # nrow * ncol htop[r, c]
            line = ''
            for dummy in range(getn(cnf_nrow * cnf_ncol, n_per_line)):
                line = line + f_cnf.readline()
            cnf_top = [float(s) for s in line.split()]
            cnf_top = np.reshape(cnf_top, (cnf_nrow, cnf_ncol))

            # nlay * nrow * ncol layer thickness dz[l, r, c]
            line = ''
            for dummy in range(getn(cnf_nlay * cnf_nrow * cnf_ncol, n_per_line)):
                line = line + f_cnf.readline()
            cnf_dz = [float(s) for s in line.split()]
            cnf_dz = np.reshape(cnf_dz, (cnf_nlay, cnf_nrow, cnf_ncol))

            # cinact, cdry, not used here so commented
            '''line = f_cnf.readline()
            s = line.split()
            cinact = float(s[0])
            cdry = float(s[1])'''

            f_cnf.close()
        finally:
            self.nlay = cnf_nlay
            self.nrow = cnf_nrow
            self.ncol = cnf_ncol

            self.delr = util_2d(model, (self.ncol,), np.float32, cnf_delr, 
                                name='delr', locat=self.unit_number[0])
            self.delc = util_2d(model, (self.nrow,), np.float32, cnf_delc, 
                                name='delc', locat=self.unit_number[0])
            self.top = util_2d(model, (self.nrow,self.ncol), np.float32,
                                       cnf_top, name='model_top', 
                                       locat = self.unit_number[0])

            cnf_botm = np.empty((self.nlay + sum(self.laycbd),self.nrow, 
                                 self.ncol))

            # First model layer
            cnf_botm[0:, :, :] = cnf_top - cnf_dz[0, :, :]
            # All other layers
            for l in range(1, self.nlay):
                cnf_botm[l, :, :] = cnf_botm[l - 1, :, :] - cnf_dz[l, :, :]

            self.botm = util_3d(model, (self.nlay + sum(self.laycbd),
                                        self.nrow, self.ncol), np.float32,
                                        cnf_botm, 'botm', 
                                        locat = self.unit_number[0])
Esempio n. 27
0
    def __init__(self, model, criv=0.0, cghb = 0.0,cibd = 0.0, cchd=0.0,
                 crch=0.0, cpbc=1.0, cwel = 0.0, cevt = 0.0, itype_dict=None,
                 extension='ssm'):
        #Call ancestor's init to set self.parent, extension, name and 
        #unit number
        Package.__init__(self, model, extension, 'SSM', 34) 
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper

        #Check for modflow packages suppported by ssm
        mfbas = self.parent.mf.get_package('BAS6')
        mfchd = self.parent.mf.get_package('CHD')
        mfrch = self.parent.mf.get_package('RCH')
        mfevt = self.parent.mf.get_package('EVT')
        mfpbc = self.parent.mf.get_package('PBC')
        mfwel = self.parent.mf.get_package('WEL')
        mfghb = self.parent.mf.get_package('GHB')
        mfriv = self.parent.mf.get_package('RIV')

        #Check if the IBOUND array has any fixed heads
        self.ssmibound = np.empty((0, 3), dtype=np.int32)
        for r in range(nrow):
            for c in range(ncol):
                for l in range(nlay):
                    if (mfbas.ibound[l, r, c] < 0):
                        self.ssmibound = np.vstack((self.ssmibound,
                                         np.array([l + 1, r + 1, c + 1])))
        if (self.ssmibound.shape[0] > 0):
            self.cibd = []
            if (not isinstance(cibd, list)):
                cibd = [cibd]
            for a in cibd:
                a = np.atleast_2d(a)
                b = np.empty((self.ssmibound.shape[0], a.shape[1]))
                for c in range(b.shape[0]):
                    if c < a.shape[0]:
                        b[c, :] = a[c, :]
                    else:
                        b[c, :] = a[-1, :]
                self.cibd = self.cibd + [b]

        # The assignments below do not yet check if the dimensions 
        #     of crch, cpbc, ..., etc. are
        # compatible with their corresponding MODFLOW structures! Better to fix...

        #CHD
        if (mfchd != None):
            self.cchd = []
            if (not isinstance(cchd, list)):
                cchd = [cchd]
            for i,a in enumerate(cchd):
                #b = np.empty((mfchd.layer_row_column_shead_ehead[0].shape[0]))
                #self.assignarray_old(b , a )
                b = util_2d(model,(mfchd.layer_row_column_shead_ehead[0].shape[0],),np.float32,a,name='ssm_chd_'+str(i+1))
                self.cchd = self.cchd + [b]

        #GHB
        if (mfghb != None):
            self.cghb = []
            if (not isinstance(cghb, list)):
                cghb = [cghb]
            for i,a in enumerate(cghb):
                #b = np.empty((mfghb.layer_row_column_head_cond[0].shape[0]))
                #self.assignarray_old(b , a )
                b = util_2d(model,(mfghb.layer_row_column_head_cond[0].shape[0],),np.float32,a,name='ssm_ghb_'+str(i+1))
                self.cghb = self.cghb + [b]

        #RIV
        if (mfriv != None):
            self.criv = []
            if (not isinstance(criv, list)):
                criv = [criv]
            for i,a in enumerate(criv):
                #b = np.empty((mfriv.layer_row_column_Q[0].shape[0]))                
                #self.assignarray_old(b , a )                
                b = util_2d(model,(mfriv.layer_row_column_data[0].shape[0],),np.float32,a,name='ssm_riv_'+str(i+1))
                self.criv = self.criv + [b]                        
               
        #RCH
        if (mfrch != None):
            self.crch = []
            if (not isinstance(crch, list)):
                crch = [crch]
            i = 1
            for a in crch:
                crch_t = []
                if (not isinstance(a, list)):
                    a = [a]
                for b in a:
                    #c = np.empty((nrow, ncol))
                    #self.assignarray_old(c , b )
                    c = util_2d(model,(nrow,ncol),np.float32,b,name='ssm_rch_'+str(i))
                    crch_t.append(c)
                    i += 1
                self.crch.append(crch_t)

        #EVT
        if (mfevt != None):
            self.cevt = []
            if (not isinstance(cevt, list)):
                cevt = [cevt]
            i = 1
            for a in cevt:
                cevt_t = []
                if (not isinstance(a, list)):
                    a = [a]
                for b in a:
                    #c = np.empty((nrow, ncol))
                    #self.assignarray_old(c , b )
                    c = util_2d(model,(nrow,ncol),np.float32,b,name='ssm_evt_'+str(i))
                    cevt_t.append(c)
                    i += 1
                self.cevt.append(cevt_t)
        
        #PBC
        if (mfpbc != None):
            self.cpbc = []
            if (not isinstance(cpbc, list)):
                cpbc = [cpbc]
            for i,a in enumerate(cpbc):
                #b = np.empty((mfpbc.layer_row_column_shead_ehead[0].shape[0]))
                #self.assignarray_old(b , a )
                b = util_2d(model,(nrow,ncol),np.float32,a,name='ssm_pbc_'+str(i+1))
                self.cpbc = self.cpbc + [b]
        
        #WEL
        if (mfwel != None):
            self.cwel = []
            if (not isinstance(cwel, list)): cwel = [cwel]
            for a in cwel:
                a = np.atleast_2d(a)
                b = np.empty((mfwel.layer_row_column_Q[0].shape[0], a.shape[1]))  # allows for multiple species
                for c in range(b.shape[0]):
                    if c < a.shape[0]:
                        b[c, :] = a[c, :]
                    else:
                        b[c, :] = a[-1, :]
                self.cwel = self.cwel + [b]
        
        #SPECIFIED
        if itype_dict is not None:
            self.itype_max = 0
            for itype,data in itype_dict.items():
                if (not isinstance(data,list)):
                    data = [data]
                itype_max = 0
                for i,a in enumerate(data):
                    if a.shape[0] > itype_max:
                        itype_max = a.shape[0]
                    for aa in a:
                        assert len(aa) == 4
                    itype_dict[itype][i] = np.array(itype_dict[itype][i])                    
                self.itype_max += itype_max
            self.itype_dict = itype_dict                                                                                                           
        else:
            self.itype_dict = None
            self.itype_max = 0
        
        #Add self to parent and return
        self.parent.add_package(self)
        return
Esempio n. 28
0
    def __init__(
            self,
            model,
            nsrf=1,
            istrat=1,
            nobs=0,
            iswizt=55,
            iswibd=56,
            iswiobs=0,
            options=None,
            nsolver=1,
            iprsol=0,
            mutsol=3,
            solver2params={
                'mxiter': 100,
                'iter1': 20,
                'npcond': 1,
                'zclose': 1e-3,
                'rclose': 1e-4,
                'relax': 1.0,
                'nbpol': 2,
                'damp': 1.0,
                'dampt': 1.0
            },
            toeslope=0.05,
            tipslope=0.05,
            alpha=None,
            beta=0.1,
            nadptmx=1,
            nadptmn=1,
            adptfct=1.0,
            nu=0.025,
            zeta=0.0,
            ssz=0.25,
            isource=0,
            obsnam=[],
            obslrc=[],
            extension=['swi2', 'zta', 'swb'],
            unit_number=29,
            npln=None):
        """
        Package constructor.

        """
        name = ['SWI2', 'DATA(BINARY)', 'DATA(BINARY)']
        units = [unit_number, iswizt, iswibd]
        extra = ['', 'REPLACE', 'REPLACE']
        if nobs > 0:
            extension.append('zobs')
            name.append('DATA')
            units.append(iswiobs)
            extra.append('REPLACE')

        Package.__init__(
            self,
            model,
            extension=extension,
            name=name,
            unit_number=units,
            extra=extra
        )  # Call ancestor's init to set self.parent, extension, name and unit number

        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        self.heading = '# Salt Water Intrusion (SWI2) package file for MODFLOW-2005, generated by Flopy.'

        #--options
        self.fsssopt, self.adaptive = False, False
        if isinstance(options, list):
            if len(options) < 1:
                self.options = None
            else:
                self.options = options
                for o in self.options:
                    if o.lower() == 'fsssopt':
                        self.fsssopt = True
                    elif o.lower() == 'adaptive':
                        self.adaptive = True
        else:
            self.options = None

        if npln is not None:
            print 'npln keyword is deprecated. use the nsrf keyword'
            nsrf = npln

        self.nsrf, self.istrat, self.nobs, self.iswizt, self.iswibd, self.iswiobs = nsrf, istrat, nobs, \
                                                                                    iswizt, iswibd, iswiobs
        #
        self.nsolver, self.iprsol, self.mutsol = nsolver, iprsol, mutsol
        #
        self.solver2params = solver2params
        #
        self.toeslope, self.tipslope, self.alpha, self.beta = toeslope, tipslope, alpha, beta
        self.nadptmx, self.nadptmn, self.adptfct = nadptmx, nadptmn, adptfct
        # Create arrays so that they have the correct size
        if self.istrat == 1:
            self.nu = util_2d(model, (self.nsrf + 1, ),
                              np.float32,
                              nu,
                              name='nu')
        else:
            self.nu = util_2d(model, (self.nsrf + 2, ),
                              np.float32,
                              nu,
                              name='nu')
        self.zeta = []
        for i in range(self.nsrf):
            self.zeta.append(
                util_3d(model, (nlay, nrow, ncol),
                        np.float32,
                        zeta[i],
                        name='zeta_' + str(i + 1)))
        self.ssz = util_3d(model, (nlay, nrow, ncol),
                           np.float32,
                           ssz,
                           name='ssz')
        self.isource = util_3d(model, (nlay, nrow, ncol),
                               np.int,
                               isource,
                               name='isource')
        #
        self.obsnam = obsnam
        if isinstance(obslrc, list):
            obslrc = np.array(obslrc, dtype=np.int)
        self.obslrc = obslrc
        #
        self.parent.add_package(self)
Esempio n. 29
0
    def __init__(self,
                 model,
                 ncomp=1,
                 mcomp=1,
                 tunit='D',
                 lunit='M',
                 munit='KG',
                 prsity=0.30,
                 icbund=1,
                 sconc=0.0,
                 cinact=1e30,
                 thkmin=0.01,
                 ifmtcn=0,
                 ifmtnp=0,
                 ifmtrf=0,
                 ifmtdp=0,
                 savucn=True,
                 nprs=0,
                 timprs=None,
                 obs=None,
                 nprobs=1,
                 chkmas=True,
                 nprmas=1,
                 dt0=0,
                 mxstrn=50000,
                 ttsmult=1.0,
                 ttsmax=0,
                 species_names=[],
                 extension='btn',
                 **kwargs):
        Package.__init__(self, model, extension, 'BTN', 31)
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        self.heading1 = '# BTN for MT3DMS, generated by Flopy.'
        self.heading2 = '#'
        self.mcomp = mcomp
        self.tunit = tunit
        self.lunit = lunit
        self.munit = munit
        self.cinact = cinact
        self.thkmin = thkmin
        self.ifmtcn = ifmtcn
        self.ifmtnp = ifmtnp
        self.ifmtrf = ifmtrf
        self.ifmtdp = ifmtdp
        self.savucn = savucn
        self.nprs = nprs
        self.timprs = timprs
        self.obs = obs
        self.nprobs = nprobs
        self.chkmas = chkmas
        self.nprmas = nprmas
        self.species_names = species_names
        self.prsity = util_3d(model, (nlay, nrow, ncol),
                              np.float32,
                              prsity,
                              name='prsity',
                              locat=self.unit_number[0])
        self.__icbund = util_3d(model, (nlay, nrow, ncol),
                                np.int,
                                icbund,
                                name='icbund',
                                locat=self.unit_number[0])
        # Starting concentrations
        # some defense
        #
        self.ncomp = ncomp
        self.sconc = []
        u3d = util_3d(model, (nlay, nrow, ncol),
                      np.float32,
                      sconc,
                      name='sconc1',
                      locat=self.unit_number[0])
        self.sconc.append(u3d)
        if ncomp > 1:
            for icomp in range(2, ncomp + 1):
                name = "sconc" + str(icomp)
                val = 0.0
                if name in list(kwargs.keys()):
                    val = kwargs[name]
                    kwargs.pop(name)
                else:
                    print("BTN: setting sconc for component " +\
                          str(icomp) + " to zero, kwarg name " +\
                          name)

                u3d = util_3d(model, (nlay, nrow, ncol),
                              np.float32,
                              val,
                              name=name,
                              locat=self.unit_number[0])
                self.sconc.append(u3d)
        if len(list(kwargs.keys())) > 0:
            raise Exception("BTN error: unrecognized kwargs: " +
                            ' '.join(list(kwargs.keys())))
        self.dt0 = util_2d(model, (nper, ), np.float32, dt0, name='dt0')
        self.mxstrn = util_2d(model, (nper, ), np.int, mxstrn, name='mxstrn')
        self.ttsmult = util_2d(model, (nper, ),
                               np.float32,
                               ttsmult,
                               name='ttmult')
        self.ttsmax = util_2d(model, (nper, ),
                              np.float32,
                              ttsmax,
                              name='ttsmax')
        self.parent.add_package(self)
Esempio n. 30
0
 def __init__(
     self,
     model,
     ncomp=None,
     mcomp=1,
     tunit="D",
     lunit="M",
     munit="KG",
     prsity=0.30,
     icbund=1,
     sconc=0.0,
     cinact=1e30,
     thkmin=0.01,
     ifmtcn=0,
     ifmtnp=0,
     ifmtrf=0,
     ifmtdp=0,
     savucn=True,
     nprs=0,
     timprs=None,
     obs=None,
     nprobs=1,
     chkmas=True,
     nprmas=1,
     dt0=0,
     mxstrn=50000,
     ttsmult=1.0,
     ttsmax=0,
     species_names=[],
     extension="btn",
 ):
     Package.__init__(self, model, extension, "BTN", 31)
     nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
     self.heading1 = "# BTN for MT3DMS, generated by Flopy."
     self.heading2 = "#"
     self.mcomp = mcomp
     self.tunit = tunit
     self.lunit = lunit
     self.munit = munit
     self.cinact = cinact
     self.thkmin = thkmin
     self.ifmtcn = ifmtcn
     self.ifmtnp = ifmtnp
     self.ifmtrf = ifmtrf
     self.ifmtdp = ifmtdp
     self.savucn = savucn
     self.nprs = nprs
     self.timprs = timprs
     self.obs = obs
     self.nprobs = nprobs
     self.chkmas = chkmas
     self.nprmas = nprmas
     self.species_names = species_names
     self.prsity = util_3d(model, (nlay, nrow, ncol), np.float32, prsity, name="prsity", locat=self.unit_number[0])
     self.icbund = util_3d(model, (nlay, nrow, ncol), np.int, icbund, name="icbund", locat=self.unit_number[0])
     # Starting concentrations
     # --some defense
     if np.isscalar(sconc) and ncomp is None:
         # print 'setting ncomp == 1 and tiling scalar-valued sconc to nlay'
         sconc = [sconc]
         ncomp = 1
     elif ncomp != len(sconc):
         raise Exception("BTN input error - ncomp not equal to len(sconc)")
     self.ncomp = ncomp
     self.sconc = []
     for i in range(ncomp):
         u3d = util_3d(
             model, (nlay, nrow, ncol), np.float32, sconc[i], name="sconc" + str(i + 1), locat=self.unit_number[0]
         )
         self.sconc.append(u3d)
     self.dt0 = util_2d(model, (nper,), np.float32, dt0, name="dt0")
     self.mxstrn = util_2d(model, (nper,), np.int, mxstrn, name="mxstrn")
     self.ttsmult = util_2d(model, (nper,), np.float32, ttsmult, name="ttmult")
     self.ttsmax = util_2d(model, (nper,), np.float32, ttsmax, name="ttsmax")
     self.parent.add_package(self)
Esempio n. 31
0
 def __init__(self, model, \
 nuztop = 1, iuzfopt = 0, irunflg = 0, ietflg = 0, iuzfcb1 = 57, iuzfcb2 = 0, ntrail2 = 10, nsets = 20, nuzgag = 0, surfdep = 1.0, \
 iuzfbnd = 1, irunbnd = 0, vks = 1.0E-6, eps = 3.5, thts = 0.35, thtr = 0.15, thti = 0.20, row_col_iftunit_iuzopt = [], \
 specifythtr = 0, specifythti = 0, nosurfleak = 0, \
 finf = 1.0E-8, pet = 5.0E-8, extdp = 15.0, extwc = 0.1, \
 uzfbud_ext = [], extension ='uzf', unitnumber = 19):
     Package.__init__(
         self, model, extension, ['UZF'], unitnumber
     )  # Call ancestor's init to set self.parent, extension, name and unit number
     if self.parent.get_package('RCH') != None or self.parent.get_package(
             'EVT') != None:
         print(
             'WARNING!\n The RCH and EVT packages should not be active when the UZF1 package is active!'
         )
     if self.parent.version == 'mf2000':
         print(
             'WARNING!\nThe UZF1 package is only compatible with MODFLOW-2005 and MODFLOW-NWT!'
         )
     nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
     self.heading = '# UZF1 for MODFLOW, generated by Flopy.'
     self.url = 'uzf_unsaturated_zone_flow_pack.htm'
     # Data Set 1a
     self.specifythtr = specifythtr
     self.specifythti = specifythti
     self.nosurfleak = nosurfleak
     # Data Set 1b
     # NUZTOP IUZFOPT IRUNFLG IETFLG IUZFCB1 IUZFCB2 [NTRAIL2 NSETS2] NUZGAG SURFDEP
     self.nuztop = nuztop
     self.iuzfopt = iuzfopt
     self.irunflg = irunflg
     self.ietflg = ietflg
     self.iuzfcb1 = iuzfcb1
     self.iuzfcb2 = iuzfcb2
     class_nam = ['UZF']
     if (not isinstance(unitnumber, list)):
         unitnumber = [unitnumber]
     if (not isinstance(extension, list)):
         extension = [extension]
     if iuzfcb1 > 0 and iuzfcb2 < 1:
         unitnumber.append(iuzfcb1)
         extension.append(extension[0] + 'bt1')
         class_nam += ['DATA(BINARY)']
     elif iuzfcb1 < 1 and iuzfcb2 > 0:
         unitnumber.append(iuzfcb2)
         extension.append(extension[0] + 'bt2')
         class_nam += ['DATA(BINARY)']
     elif iuzfcb1 > 0 and iuzfcb2 > 0:
         unitnumber.append(iuzfcb1)
         extension.append(extension[0] + 'bt1')
         unitnumber.append(iuzfcb2)
         extension.append(extension[0] + 'bt2')
         class_nam += ['DATA(BINARY)', 'DATA(BINARY)']
     if iuzfopt > 0:
         self.ntrail2 = ntrail2
         self.nsets = nsets
     self.nuzgag = nuzgag
     self.surfdep = surfdep
     #Data Set 2
     #IUZFBND (NCOL, NROW) -- U2DINT
     self.iuzfbnd = util_2d(model, (nrow, ncol),
                            np.int,
                            iuzfbnd,
                            name='iuzfbnd')
     #If IRUNFLG > 0: Read item 3
     #Data Set 3
     #[IRUNBND (NCOL, NROW)] -- U2DINT
     if irunflg > 0:
         self.irunbnd = util_2d(model, (nrow, ncol),
                                np.int,
                                irunbnd,
                                name='irunbnd')
     #IF the absolute value of IUZFOPT = 1: Read item 4.
     #Data Set 4
     #[VKS (NCOL, NROW)] -- U2DREL
     if abs(iuzfopt) == 1:
         self.vks = util_2d(model, (nrow, ncol),
                            np.float32,
                            vks,
                            name='vks')
     if iuzfopt > 0:
         #Data Set 5
         #EPS (NCOL, NROW) -- U2DREL
         self.eps = util_2d(model, (nrow, ncol),
                            np.float32,
                            eps,
                            name='eps')
         #Data Set 6a
         #THTS (NCOL, NROW) -- U2DREL
         self.thts = util_2d(model, (nrow, ncol),
                             np.float32,
                             thts,
                             name='thts')
         #Data Set 6b
         #THTS (NCOL, NROW) -- U2DREL
         if self.specifythtr > 0:
             self.thtr = util_2d(model, (nrow, ncol),
                                 np.float32,
                                 thtr,
                                 name='thtr')
         #Data Set 7
         #[THTI (NCOL, NROW)] -- U2DREL
         self.thti = util_2d(model, (nrow, ncol),
                             np.float32,
                             thti,
                             name='thti')
     #Data Set 8
     #[IUZROW] [IUZCOL] IFTUNIT [IUZOPT]
     if len(row_col_iftunit_iuzopt) != nuzgag:
         print(
             "WARNING!\nItem 8 doesn't correspond with NUZGAG.\nNUZGAG set to 0"
         )
         self.nuzgag = 0
         self.row_col_iftunit_iuzopt = []
     else:
         self.row_col_iftunit_iuzopt = row_col_iftunit_iuzopt
         i = 0
         for l in row_col_iftunit_iuzopt:
             unitnumber.append(abs(l[0][2]))
             if uzfbud_ext == []:
                 extension.append(extension[0] + 'b' + str(i))
             else:
                 extension.append(uzfbud_ext[i])
             i += 1
         Package.__init__(self,
                          model,
                          extension,
                          class_nam + nuzgag * ['DATA'],
                          unit_number=unitnumber)
     #Dataset 9, 11, 13 and 15 will be written automatically in the write_file function
     #Data Set 10
     #[FINF (NCOL, NROW)] – U2DREL
     self.finf = []
     if (not isinstance(finf, list)):
         finf = [finf]
     for i, a in enumerate(finf):
         b = util_2d(model, (nrow, ncol),
                     np.float32,
                     a,
                     name='finf_' + str(i + 1))
         self.finf = self.finf + [b]
     if ietflg > 0:
         #Data Set 12
         #[PET (NCOL, NROW)] – U2DREL
         self.pet = []
         if (not isinstance(pet, list)):
             pet = [pet]
         for i, a in enumerate(pet):
             b = util_2d(model, (nrow, ncol),
                         np.float32,
                         a,
                         name='pet_' + str(i + 1))
             self.pet = self.pet + [b]
         #Data Set 14
         #[EXTDP (NCOL, NROW)] – U2DREL
         self.extdp = []
         if (not isinstance(extdp, list)):
             extdp = [extdp]
         for i, a in enumerate(extdp):
             b = util_2d(model, (nrow, ncol),
                         np.float32,
                         a,
                         name='extdp_' + str(i + 1))
             self.extdp = self.extdp + [b]
         #Data Set 16
         #[EXTWC (NCOL, NROW)] – U2DREL
         if iuzfopt > 0:
             self.extwc = []
             if (not isinstance(extwc, list)):
                 extwc = [extwc]
             for i, a in enumerate(extwc):
                 b = util_2d(model, (nrow, ncol),
                             np.float32,
                             a,
                             name='extwc_' + str(i + 1))
                 self.extwc = self.extwc + [b]
     self.parent.add_package(self)
Esempio n. 32
0
    def __init__(self, model, nsrf=1, istrat=1, nobs=0, iswizt=55, iswibd=56, iswiobs=0, options=None,
                 nsolver=1, iprsol=0, mutsol=3, 
                 solver2params={'mxiter': 100, 'iter1': 20, 'npcond': 1, 'zclose': 1e-3, 'rclose': 1e-4, 'relax': 1.0,
                                'nbpol': 2, 'damp': 1.0, 'dampt': 1.0},
                 toeslope=0.05, tipslope=0.05, alpha=None, beta=0.1, nadptmx=1, nadptmn=1, adptfct=1.0,
                 nu=0.025, zeta=0.0, ssz=0.25, isource=0,
                 obsnam=[], obslrc=[],
                 extension=['swi2', 'zta', 'swb'], unit_number=29,
                 npln=None):
        """
        Package constructor.

        """
        name = ['SWI2', 'DATA(BINARY)', 'DATA(BINARY)']
        units = [unit_number, iswizt, iswibd]
        extra = ['', 'REPLACE', 'REPLACE']
        if nobs > 0:
            extension.append('zobs')
            name.append('DATA')
            units.append(iswiobs)
            extra.append('REPLACE')

        Package.__init__(self, model, extension=extension, name=name, unit_number=units,
                         extra=extra)  # Call ancestor's init to set self.parent, extension, name and unit number

        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        self.heading = '# Salt Water Intrusion (SWI2) package file for MODFLOW-2005, generated by Flopy.'
        
        #--options
        self.fsssopt, self.adaptive = False, False
        if isinstance(options, list):
            if len(options) < 1:
                self.options = None
            else:
                self.options = options
                for o in self.options:
                    if o.lower() == 'fsssopt':
                        self.fsssopt = True
                    elif o.lower() == 'adaptive':
                        self.adaptive = True
        else:
            self.options = None

        if npln is not None:
            print 'npln keyword is deprecated. use the nsrf keyword'
            nsrf = npln

        self.nsrf, self.istrat, self.nobs, self.iswizt, self.iswibd, self.iswiobs = nsrf, istrat, nobs, \
                                                                                    iswizt, iswibd, iswiobs
        #
        self.nsolver, self.iprsol, self.mutsol = nsolver, iprsol, mutsol
        #
        self.solver2params = solver2params
        #
        self.toeslope, self.tipslope, self.alpha, self.beta = toeslope, tipslope, alpha, beta
        self.nadptmx, self.nadptmn, self.adptfct = nadptmx, nadptmn, adptfct
        # Create arrays so that they have the correct size
        if self.istrat == 1:
            self.nu = util_2d(model, (self.nsrf + 1,), np.float32, nu, name='nu')
        else:
            self.nu = util_2d(model, (self.nsrf + 2,), np.float32, nu, name='nu')
        self.zeta = []
        for i in range(self.nsrf):
            self.zeta.append(util_3d(model, (nlay, nrow, ncol), np.float32, zeta[i], name='zeta_' + str(i + 1)))
        self.ssz = util_3d(model, (nlay, nrow, ncol), np.float32, ssz, name='ssz')
        self.isource = util_3d(model, (nlay, nrow, ncol), np.int, isource, name='isource')
        #
        self.obsnam = obsnam
        if isinstance(obslrc, list):
            obslrc = np.array(obslrc, dtype=np.int)
        self.obslrc = obslrc
        #
        self.parent.add_package(self)
Esempio n. 33
0
    def write_file(self):
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        ModflowDis = self.parent.mf.get_package('DIS')
        # Open file for writing
        f_btn = open(self.fn_path, 'w')
        f_btn.write('#{0:s}\n#{1:s}\n'.format(self.heading1, self.heading2))
        f_btn.write('{0:10d}{1:10d}{2:10d}{3:10d}{4:10d}{5:10d}\n'.format(
            nlay, nrow, ncol, nper, self.ncomp, self.mcomp))
        f_btn.write('{0:4s}{1:4s}{2:4s}\n'\
            .format(self.tunit, self.lunit, self.munit))
        if (self.parent.adv != None):
            f_btn.write('{0:2s}'.format('T'))
        else:
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.dsp != None):
            f_btn.write('{0:2s}'.format('T'))
        else:
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.ssm != None):
            f_btn.write('{0:2s}'.format('T'))
        else:
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.rct != None):
            f_btn.write('{0:2s}'.format('T'))
        else:
            f_btn.write('{0:2s}'.format('F'))
        if (self.parent.gcg != None):
            f_btn.write('{0:2s}'.format('T'))
        else:
            f_btn.write('{0:2s}'.format('F'))
        f_btn.write('\n')
        flow_package = self.parent.mf.get_package('BCF6')
        if (flow_package != None):
            lc = util_2d(self.parent, (nlay, ),
                         np.int,
                         flow_package.laycon.get_value(),
                         name='btn - laytype',
                         locat=self.unit_number[0])
        else:
            flow_package = self.parent.mf.get_package('LPF')
            if (flow_package != None):
                lc = util_2d(self.parent, (nlay, ),
                             np.int,
                             flow_package.laytyp.get_value(),
                             name='btn - laytype',
                             locat=self.unit_number[0])
        # need to reset lc fmtin
        lc.set_fmtin('(40I2)')
        f_btn.write(lc.string)
        delr = util_2d(self.parent, (ncol, ),
                       np.float32,
                       ModflowDis.delr.get_value(),
                       name='delr',
                       locat=self.unit_number[0])
        f_btn.write(delr.get_file_entry())

        delc = util_2d(self.parent, (nrow, ),
                       np.float32,
                       ModflowDis.delc.get_value(),
                       name='delc',
                       locat=self.unit_number[0])
        f_btn.write(delc.get_file_entry())

        top = util_2d(self.parent, (nrow, ncol),
                      np.float32,
                      ModflowDis.top.array,
                      name='top',
                      locat=self.unit_number[0])
        f_btn.write(top.get_file_entry())

        thickness = util_3d(self.parent, (nlay, nrow, ncol),
                            np.float32,
                            ModflowDis.thickness.get_value(),
                            name='thickness',
                            locat=self.unit_number[0])
        f_btn.write(thickness.get_file_entry())

        f_btn.write(self.prsity.get_file_entry())

        f_btn.write(self.__icbund.get_file_entry())

        # Starting concentrations
        for s in range(len(self.sconc)):
            f_btn.write(self.sconc[s].get_file_entry())

        f_btn.write('{0:10.0E}{1:10.4f}\n'\
            .format(self.cinact,self.thkmin))

        f_btn.write('{0:10d}{1:10d}{2:10d}{3:10d}'\
            .format(self.ifmtcn, self.ifmtnp, self.ifmtrf, self.ifmtdp))
        if (self.savucn == True):
            ss = 'T'
        else:
            ss = 'F'
        f_btn.write('{0:>10s}\n'.format(ss))

        # NPRS
        if (self.timprs == None):
            f_btn.write('{0:10d}\n'.format(self.nprs))
        else:
            f_btn.write('{0:10d}\n'.format(len(self.timprs)))
            timprs = util_2d(self.parent, (len(self.timprs), ),
                             np.float32,
                             self.timprs,
                             name='timprs',
                             fmtin='(8G10.4)')
            f_btn.write(timprs.string)
        # OBS
        if (self.obs == None):
            f_btn.write('{0:10d}{1:10d}\n'.format(0, self.nprobs))
        else:
            nobs = self.obs.shape[0]
            f_btn.write('{0:10d}{1:10d}\n'.format(nobs, self.nprobs))
            for r in range(nobs):
                f_btn.write('{0:10d}{1:10d}{2:10d}\n'\
                    .format(self.obs[r, 0], self.obs[r, 1], self.obs[r, 2]))
        # CHKMAS, NPRMAS
        if (self.chkmas == True):
            ss = 'T'
        else:
            ss = 'F'
        f_btn.write('{0:>10s}{1:10d}\n'.format(ss, self.nprmas))
        # PERLEN, NSTP, TSMULT
        for t in range(nper):
            f_btn.write('{0:10.4G}{1:10d}{2:10.4G}\n'.format(
                ModflowDis.perlen[t], ModflowDis.nstp[t],
                ModflowDis.tsmult[t]))
            f_btn.write('{0:10.4G}{1:10d}{2:10.4G}{3:10.4G}\n'.format(
                self.dt0[t], self.mxstrn[t], self.ttsmult[t], self.ttsmax[t]))
        f_btn.close()
Esempio n. 34
0
    def __init__(self, model, npln=1, istrat=1, iswizt=53, nprn=1, toeslope=0.05, tipslope=0.05, \
                 zetamin=0.005, delzeta=0.05, nu=0.025, zeta=[], ssz=[], isource=0, extension='swi', fname_output='swi.zta'):
        """
        Package constructor.

        """
        Package.__init__(self,
                         model)  # Call ancestor's init to set self.parent
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        self.unit_number = [29, 53]
        self.extension = extension
        self.file_name = [
            self.parent.name + '.' + self.extension, fname_output
        ]
        self.name = ['SWI', 'DATA(BINARY)']
        self.heading = '# Salt Water Intrusion package file for MODFLOW-2000, generated by Flopy.'
        self.npln = npln
        self.istrat = istrat
        self.iswizt = iswizt
        self.nprn = nprn
        self.toeslope = toeslope
        self.tipslope = tipslope
        self.zetamin = zetamin
        self.delzeta = delzeta
        # Create arrays so that they have the correct size
        if self.istrat == 1:
            #self.nu = empty( self.npln+1 )
            self.nu = util_2d(model, (self.npln + 1, ),
                              np.float32,
                              nu,
                              name='nu')
        else:
            #self.nu = empty( self.npln+2 )
            self.nu = util_2d(model, (self.npln + 2, ),
                              np.float32,
                              nu,
                              name='nu')
        self.zeta = []
        for i in range(nlay):
            #self.zeta.append( empty((nrow, ncol, self.npln)) )
            self.zeta
        #self.ssz = empty((nrow, ncol, nlay))
        #self.isource = empty((nrow, ncol, nlay),dtype='int32')
        # Set values of arrays
        #self.assignarray_old( self.nu, nu )
        #for i in range(nlay):
        #    self.assignarray_old( self.zeta[i], zeta[i] )
        #self.assignarray_old( self.ssz, ssz )
        #self.assignarray_old( self.isource, isource )
        for i in range(nlay):
            self.zeta.append(
                util_2d(model, (self.npln, nrow, ncol),
                        np.float32,
                        zeta[i],
                        name='zeta_' + str(i + 1)))
        self.ssz = util_3d(model, (nlay, nrow, ncol),
                           np.float32,
                           ssz,
                           name='ssz')
        self.isource = util_3d(model, (nlay, nrow, ncol),
                               np.int,
                               isource,
                               name='isource')
        self.parent.add_package(self)
Esempio n. 35
0
    def __init__(self, model, ncomp=1, mcomp=1, tunit='D', lunit='M',
                 munit='KG', prsity=0.30, icbund=1, sconc=0.0,
                 cinact=1e30, thkmin=0.01, ifmtcn=0, ifmtnp=0, 
                 ifmtrf=0, ifmtdp=0, savucn=True, nprs=0, timprs=None,
                 obs=None, nprobs=1, chkmas=True, nprmas=1, dt0=0,
                 mxstrn=50000, ttsmult=1.0, ttsmax=0, 
                 species_names=[], extension='btn',**kwargs):
        Package.__init__(self, model, extension, 'BTN', 31) 
        nrow, ncol, nlay, nper = self.parent.mf.nrow_ncol_nlay_nper
        self.heading1 = '# BTN for MT3DMS, generated by Flopy.'
        self.heading2 = '#'
        self.mcomp = mcomp
        self.tunit = tunit
        self.lunit = lunit
        self.munit = munit
        self.cinact = cinact
        self.thkmin = thkmin
        self.ifmtcn = ifmtcn
        self.ifmtnp = ifmtnp
        self.ifmtrf = ifmtrf
        self.ifmtdp = ifmtdp
        self.savucn = savucn
        self.nprs = nprs
        self.timprs = timprs
        self.obs = obs
        self.nprobs = nprobs
        self.chkmas = chkmas
        self.nprmas = nprmas
        self.species_names = species_names        
        self.prsity = util_3d(model, (nlay, nrow, ncol), np.float32,
            prsity, name='prsity', locat=self.unit_number[0])
        self.__icbund = util_3d(model, (nlay, nrow, ncol), np.int,
                                icbund, name='icbund',
                                locat=self.unit_number[0])
        # Starting concentrations
        #--some defense
        #
        self.ncomp = ncomp
        self.sconc = []
        u3d = util_3d(model, (nlay, nrow, ncol), np.float32, sconc,
                name='sconc1', locat=self.unit_number[0])
        self.sconc.append(u3d)
        if ncomp > 1:
            for icomp in xrange(2,ncomp+1):
                name = "sconc"+str(icomp)
                val = 0.0
                if name in kwargs.keys():
                    val = kwargs[name]
                    kwargs.pop(name)
                else:
                    print "BTN: setting sconc for component " +\
                          str(icomp) + " to zero, kwarg name " +\
                          name

                u3d = util_3d(model, (nlay, nrow, ncol), np.float32,
                              val, name=name,
                              locat=self.unit_number[0])
                self.sconc.append(u3d)
        if len(kwargs.keys()) > 0:
            raise Exception("BTN error: unrecognized kwargs: " +
                            ' '.join(kwargs.keys()))
        self.dt0 = util_2d(model, (nper,), np.float32, dt0, name='dt0')
        self.mxstrn = util_2d(model, (nper,), np.int, mxstrn, name='mxstrn')
        self.ttsmult = util_2d(model, (nper,), np.float32, ttsmult,
                               name='ttmult')
        self.ttsmax = util_2d(model, (nper,), np.float32, ttsmax, name='ttsmax')
        self.parent.add_package(self)