Esempio n. 1
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. 2
0
 def __init__(self, model, nlay=1, nrow=2, ncol=2, nper=1, delr=1.0, delc=1.0, laycbd=1, top=1, botm=0, perlen=1, nstp=1, tsmult=1, steady=True, itmuni=4, lenuni=2, extension='dis', unitnumber=11):
     Package.__init__(self, model, extension, 'DIS', unitnumber) # Call ancestor's init to set self.parent, extension, name and unit number
     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 = self.assignarray((self.nlay,), np.int, laycbd, name='laycbd')
     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])    
     #if (not self.checklayerthickness()):
     #    if self.parent.silent == 0: print 'Warning: Cells with zero-layer thickness encountered!'
     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. 3
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='vka')
     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,hk,name='hani',locat=self.unit_number[0])
     self.vka = util_3d(model,(nlay,nrow,ncol),np.float32,hk,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)
Esempio n. 4
0
 def thickness(self):
     #self.__thickness = np.empty((self.botm.shape))
     # First model layer
     #self.__thickness[0] = self.top - self.botm[0]
     # All other layers
     #for l in range(1, self.nlay):
     #    self.__thickness[l] = self.botm[l-1] - self.botm[l]
     thk = []
     thk.append(self.top - self.botm[0])
     for k in range(1,self.nlay):
         thk.append(self.botm[k-1] - self.botm[k])
     self.__thickness = util_3d(self.parent,(self.nlay,self.nrow,self.ncol),np.float32,thk,name='thickness')
     return self.__thickness
Esempio n. 5
0
    def __init__(self,
                 model,
                 ibound=1,
                 strt=1.0,
                 ixsec=False,
                 ichflg=False,
                 hnoflo=-999.99,
                 extension='bas',
                 unitnumber=13):
        Package.__init__(
            self, model, extension, 'BAS6', unitnumber
        )  # Call ancestor's init to set self.parent, extension, name and unit number
        self.url = 'bas6.htm'
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        # First create arrays so that they have the correct size
        self.__ibound = np.empty((nrow, ncol, nlay),
                                 dtype='int32')  # IBOUND array
        self.strt = np.empty((nrow, ncol, nlay))  # Starting heads
        # Set values of all parameters

        #self.__ibound = self.assignarray((nlay,nrow,ncol), np.int, ibound, name='ibound', load=True)
        self.__ibound = util_3d(model, (nlay, nrow, ncol),
                                np.int,
                                ibound,
                                name='ibound',
                                locat=self.unit_number[0])
        #self.strt = self.assignarray((nlay,nrow,ncol), np.float, strt, name='strt', load=model.load)
        self.strt = util_3d(model, (nlay, nrow, ncol),
                            np.float32,
                            strt,
                            name='strt',
                            locat=self.unit_number[0])
        self.heading = '# Basic package file for MODFLOW, generated by Flopy.'
        self.options = ''  # Can be either or a combination of XSECTION, CHTOCH or FREE
        self.ixsec = ixsec  # Flag for use of cross-section option
        self.ichflg = ichflg  # Flag for calculation of flow between constant head cells
        self.ifrefm = True  # Free format specifier is set to True, as other packages depend on that
        self.hnoflo = hnoflo  # Head in no-flow cells
        self.parent.add_package(self)
Esempio n. 6
0
 def thickness(self):
     #self.__thickness = np.empty((self.botm.shape))
     # First model layer
     #self.__thickness[0] = self.top - self.botm[0]
     # All other layers
     #for l in range(1, self.nlay):
     #    self.__thickness[l] = self.botm[l-1] - self.botm[l]
     thk = []
     thk.append(self.top - self.botm[0])
     for k in range(1, self.nlay):
         thk.append(self.botm[k - 1] - self.botm[k])
     self.__thickness = util_3d(self.parent,
                                (self.nlay, self.nrow, self.ncol),
                                np.float32,
                                thk,
                                name='thickness')
     return self.__thickness
Esempio n. 7
0
    def __init__(self,
                 model,
                 nlay=1,
                 nrow=2,
                 ncol=2,
                 nper=1,
                 delr=1.0,
                 delc=1.0,
                 laycbd=1,
                 top=1,
                 botm=0,
                 perlen=1,
                 nstp=1,
                 tsmult=1,
                 steady=True,
                 itmuni=4,
                 lenuni=2,
                 extension='dis',
                 unitnumber=11):
        Package.__init__(
            self, model, extension, 'DIS', unitnumber
        )  # Call ancestor's init to set self.parent, extension, name and unit number
        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 = self.assignarray((self.nlay,), np.int, laycbd, name='laycbd')
        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])
        #if (not self.checklayerthickness()):
        #    if self.parent.silent == 0: print 'Warning: Cells with zero-layer thickness encountered!'
        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. 8
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.get_value(),\
         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:10f}{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. 9
0
 def setibound(self, value):
     self.__ibound = util_3d(model, (nlay, nrow, ncol),
                             np.int,
                             ibound,
                             name='ibound',
                             locat=self.unit_number[0])
Esempio n. 10
0
#print k_layer1_2d.get_file_entry()

#--to access the array which in this case loads the array stored in 'my_perfect_k.dat'
#print k_layer1_2d.array

#--to access the string,  returns the string representation of the array that was just loaded
#print k_layer1_2d.string

#----------------------------------------------------------------------------------------------
#--util_3d - just a wrapper around util_2d

#--just a scalar assigns the same value to all layers
#--internal (constants)
model_instance.external_path = None
k_3d = util_3d(model_instance, (nlay, nrow, ncol),
               np.float32,
               some_k_scalar,
               name='k')
#print k_3d.get_file_entry()

#--external arrays
model_instance.external_path = '.\\'
k_3d = util_3d(model_instance, (nlay, nrow, ncol),
               np.float32,
               some_k_scalar,
               name='k')
#print k_3d.get_file_entry()

#--a mix of nlay items - internal
model_instance.external_path = None
some_k_list = [50.0, 'my_perfect_k.dat', np.zeros((nrow, ncol)) + 50.0]
k_3d = util_3d(model_instance, (nlay, nrow, ncol),