Skip to content

Commit

Permalink
Mflab added to workspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
Olsthoorn committed Dec 10, 2023
1 parent 28ad6bc commit 86d1526
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 32 deletions.
2 changes: 2 additions & 0 deletions fdm/mf6_face_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ def get_struct_flows(flowjas, grb_file=None, verbose=False):
"""
ja_ptr, grb = get_indices_to_pick_fxf(grb_file=grb_file)

flowjas = [flowja.flatten() for flowja in flowjas[0]]

dtype = np.dtype([('frf', (float, grb.shape)),
('fff', (float, grb.shape)),
Expand Down
3 changes: 2 additions & 1 deletion mflab/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
./mfiles
**/mfiles
**/_pychache_
10 changes: 8 additions & 2 deletions mflab/mf_paramtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ class Dirs():
.. # Other runnable code like Zonebudget
cases # folder collecting all cases for this projec
<case_name1> # First case <..> denote dedicated name.
mf6_files
flow
mfsim.lst
..
<case_name1>.lst
<case_name1>.dis
..
transport
mfsim.lst
..
<case_name1>.lst
<case_name1>.dis
..
photos
__init__.py
mf_adapt.py
Expand Down Expand Up @@ -137,7 +143,7 @@ def add_case(self, case_name):

# Add subdirs 'mf6_files, Photos, Images'

for subd in ['mf6_files', 'Photos', 'Images']:
for subd in ['SIM', 'GWF', 'GWT', 'Photos', 'Images']:
subdir = os.path.join(self.case, subd)
exec("self.{} = '{}'".format(subd, subdir))
if not os.path.isdir(subdir):
Expand Down
85 changes: 56 additions & 29 deletions mflab/mf_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,43 +88,47 @@ def mf_setup():

### sim =====================
logging.info("sim")
model_dict['Simsim'].update(sim_name=mf_adapt.sim_name, sim_ws=mf_adapt.dirs.mf6_files)
model_dict['Simsim'].update(sim_name=mf_adapt.sim_name, sim_ws=mf_adapt.dirs.SIM)
sim = flopy.mf6.MFSimulation(**model_dict['Simsim'])
fp_packages['Simsim'] = sim

### tdis ====================
logging.info("Simtdis")
model_dict['Simtdis'].update(nper=mf_adapt.nper, perioddata=mf_adapt.period_data,
start_date_time=mf_adapt.start_date_time)
start_date_time=mf_adapt.start_date_time,
time_units=mf_adapt.TIME_UNITS)

fp_packages['Simtdis'] = flopy.mf6.ModflowTdis(sim, **model_dict['Simtdis'])

### ims =====================
if True: # Solver, geneally use defaults from workbook.
model_dict['Simims'].update()
logging.info("Simims")
fp_packages['Simims'] = flopy.mf6.ModflowIms(sim, **model_dict['Simims'])



### ======== F L O W ================================================

if 'Gwf' in use_models:
### Gwf =====================
if True: # Groundwater flow model, use name from 'sim').
logging.info("Gwf")
model_dict['Gwfgwf'].update(modelname=sim.name,
model_rel_path=mf_adapt.dirs.mf6_files,
Gwf_model_name = sim.name + 'Gwf'
model_dict['Gwfgwf'].update(modelname=Gwf_model_name,
model_rel_path=mf_adapt.dirs.GWF,
exe_name=sim.exe_name,
)
gwf = flopy.mf6.ModflowGwf(sim, **model_dict['Gwfgwf'])
fp_packages['Gwfgwf'] = gwf

### Ims =====================
model_dict['Gwfims'].update()
logging.info("Gwfims")
Gwfims = flopy.mf6.ModflowIms(sim, **model_dict['Gwfims'])
fp_packages['Gwfims'] = Gwfims
sim.register_ims_package(Gwfims, [Gwf_model_name])


### Gwfdis ==================
if 'Gwfdis' in use_packages:
logging.info('Gwfdis')
model_dict['Gwfdis'].update(nlay=gr.nlay, nrow=gr.nrow, ncol=gr.ncol,
delr=gr.dx, delc=gr.dy,
top=gr.Z[0], botm=gr.Z[1:],
length_units = mf_adapt.LENGTH_UNITS,
idomain=mf_adapt.IDOMAIN,
)
fp_packages['Gwfdis'] = flopy.mf6.ModflowGwfdis(gwf, **model_dict['Gwfdis'])
Expand Down Expand Up @@ -233,9 +237,7 @@ def mf_setup():
### Gwfoc ==================
if 'Gwfoc' in use_packages:
logging.info('Gwfoc')
model_dict['Gwfoc'].update(head_filerecord="{}.hds".format(sim.name),
budget_filerecord="{}.cbc".format(sim.name),
saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")])
model_dict['Gwfoc'].update(**mf_adapt.Gwfoc)
fp_packages['Gwfoc'] = flopy.mf6.ModflowGwfoc(gwf, **model_dict['Gwfoc'])

### Gwfrch ==================
Expand Down Expand Up @@ -286,18 +288,31 @@ def mf_setup():
if 'Gwt' in use_models:
### Gwt ===============================
if True: # Groundwater transport model, use name from 'sim').
logging.info("Gwt")
model_dict['Gwt'].update(modelname=sim.name,
model_rel_path=mf_adapt.dirs.mf6,
logging.info("Gwtgwt")
Gwt_model_name = sim.name + 'Gwt'
model_dict['Gwtgwt'].update(modelname=Gwt_model_name,
model_rel_path=mf_adapt.dirs.GWT,
exe_name=sim.exe_name,
)
gwt = flopy.mf6.ModflowGwt(sim, **model_dict['Gwtgwt'])
fp_packages['Gwtgwt'] = gwt

### ims =====================
model_dict['Gwtims'].update(complexity='MODERATE') # SIMPLE | MODERATE | COMPLEX
logging.info("Gwtims")
Gwtims = flopy.mf6.ModflowIms(sim, **model_dict['Gwtims'])
fp_packages['Gwtims'] = Gwtims
sim.register_ims_package(Gwtims, [Gwt_model_name])

### Gwtdis ==================
if 'Gwtdis' in use_packages:
logging.info('Gwtdis')
model_dict['Gwtdis'].update()
model_dict['Gwtdis'].update(nlay=gr.nlay, nrow=gr.nrow, ncol=gr.ncol,
delr=gr.dx, delc=gr.dy,
top=gr.Z[0], botm=gr.Z[1:],
length_units=mf_adapt.LENGTH_UNITS,
idomain=mf_adapt.IDOMAIN,
)
fp_packages['Gwtdis'] = flopy.mf6.ModflowGwtdis(gwt, **model_dict['Gwtdis'])

### Gwtdisu ==================
Expand All @@ -311,37 +326,36 @@ def mf_setup():
logging.info('Gwtdisv')
model_dict['Gwtdisv'].update()
fp_packages['Gwtdisv'] = flopy.mf6.ModflowGwtdisv(gwt, **model_dict['Gwtdisv'])




### Gwtadv ==================
if 'Gwtadv' in use_packages:
logging.info('Gwtadv')
model_dict['Gwtadv'].update()
model_dict['Gwtadv'].update(scheme=mf_adapt.SCHEME)
fp_packages['Gwtadv'] = flopy.mf6.ModflowGwtadv(gwt, **model_dict['Gwtadv'])

### Gwtcnc ==================
if 'Gwtcnc' in use_packages:
logging.info('Gwtcnc')
model_dict['Gwtcnc'].update()
model_dict['Gwtcnc'].update(stress_period_data=mf_adapt.CONSTCONC,
maxbound = len(mf_adapt.CONSTCONC))
fp_packages['Gwtcnc'] = flopy.mf6.ModflowGwtcnc(gwt, **model_dict['Gwtcnc'])

### Gwtdsp ==================
if 'Gwtdsp' in use_packages:
logging.info('Gwtdsp')
model_dict['Gwtdsp'].update()
model_dict['Gwtdsp'].update(**mf_adapt.DISPERSIVITIES)
fp_packages['Gwtdsp'] = flopy.mf6.ModflowGwtdsp(gwt, **model_dict['Gwtdsp'])

### Gwtfmi ==================
if 'Gwtfmi' in use_packages:
logging.info('Gwtfmi')
model_dict['Gwtfmi'].update()
model_dict['Gwtfmi'].update(**mf_adapt.Gwtfmi)
fp_packages['Gwtfmi'] = flopy.mf6.ModflowGwtfmi(gwt, **model_dict['Gwtfmi'])

### Gwtic ==================
if 'Gwtic' in use_packages:
logging.info('Gwtic')
model_dict['Gwtic'].update()
model_dict['Gwtic'].update(strt=mf_adapt.STRTC)
fp_packages['Gwtic'] = flopy.mf6.ModflowGwtic(gwt, **model_dict['Gwtic'])

### Gwtist ==================
Expand All @@ -359,7 +373,7 @@ def mf_setup():
### Gwtmst ==================
if 'Gwtmst' in use_packages:
logging.info('Gwtmst')
model_dict['Gwtmst'].update()
model_dict['Gwtmst'].update(**mf_adapt.Gwtmst)
fp_packages['Gwtmst'] = flopy.mf6.ModflowGwtmst(gwt, **model_dict['Gwtmst'])

### Gwtmvt ==================
Expand All @@ -383,7 +397,7 @@ def mf_setup():
### Gwtoc ==================
if 'Gwtoc' in use_packages:
logging.info('Gwtoc')
model_dict['Gwtoc'].update()
model_dict['Gwtoc'].update(**mf_adapt.GWTOC)
fp_packages['Gwtoc'] = flopy.mf6.ModflowGwtoc(gwt, **model_dict['Gwtoc'])

### Gwtsft ==================
Expand All @@ -410,6 +424,19 @@ def mf_setup():
model_dict['Gwtuzt'].update()
fp_packages['Gwtuzt'] = flopy.mf6.ModflowGwtuzt(gwt, **model_dict['Gwtuzt'])



### ==== Dynamic exchange ===========================================

if 'Gwf' in use_models and 'Gwt' in use_models:
logging.info("Dynamic exchange GWF-GWT active")
model_dict['Gwfexc'].update(exgtype='GWF6-GWT6',
exgmnamea=model_dict['Gwfgwf']['modelname'],
exgmnameb=model_dict['Gwtgwt']['modelname'])
exchange = flopy.mf6.ModflowGwfgwt(sim, **model_dict['Gwfexc'])
fp_packages['Gwfexc'] = exchange


return fp_packages, model_dict, use_models, use_packages


Expand Down

0 comments on commit 86d1526

Please sign in to comment.