Esempio n. 1
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. 2
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. 3
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. 4
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. 5
0
 def __init__(self,
              model,
              nrchop=3,
              irchcb=0,
              rech=1e-3,
              irch=1,
              extension='rch',
              unitnumber=19,
              bin=False):
     '''
    
     '''
     Package.__init__(
         self, model, extension, 'RCH', 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 = '# 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),
                     bin=bin)
         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. 6
0
 def __init__(self, model, nrchop=3, irchcb=0, rech=1e-3, irch=1, extension ='rch', unitnumber=19,bin=False):
     '''
    
     '''
     Package.__init__(self, model, extension, 'RCH', 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 = '# 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),bin=bin)
         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. 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
print ul[0]
print ul[-1]
sys.exit()

#--------------------------------------------------------------------
#--util_2d

#--no external path...
model_instance = Modflow(modelname='my_perfect_model', external_path=None)
#--I'm experimenting with this one, so it isn't committed yet, but so far, can really speed things up
#--if the arrays haven't changed since the last run
setattr(model_instance, 'use_existing', False)
some_k_scalar = 50.0
k_layer1_2d = util_2d(model_instance, (nrow, ncol),
                      np.float32,
                      some_k_scalar,
                      name='k_in_layer_1',
                      locat=10)
#--this returns a constant control record
#print k_layer1_2d.get_file_entry()

#--using the slice operators forces the array to be created
k_layer1_2d[1:-1] = 25.0
#--now the file entry is the control record followed by the array string
#print k_layer1_2d.get_file_entry()

#--set external path to force external array writing
model_instance.external_path = '.\\'
some_k_scalar = 50.0
k_layer1_2d = util_2d(model_instance, (nrow, ncol),
                      np.float32,
Esempio n. 10
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)