0
# MODFLOW 6 Models and Packages
1
2
This module provides comprehensive support for MODFLOW 6 models including groundwater flow (GWF), transport (GWT), energy transport (GWE), and particle tracking (PRT) models with all standard packages and advanced features. MODFLOW 6 represents the latest generation of the MODFLOW groundwater modeling software with enhanced capabilities and modern input/output structure.
3
4
## Core Classes
5
6
### MFSimulation
7
8
The main container for MODFLOW 6 simulations that manages models, time discretization, and solution schemes.
9
10
```python { .api }
11
class MFSimulation:
12
"""MODFLOW 6 simulation container and execution manager"""
13
def __init__(
14
self,
15
sim_name: str = 'modflowtest',
16
version: str = 'mf6',
17
exe_name: str = 'mf6',
18
sim_ws: str = '.',
19
verbosity_level: int = 1,
20
write_headers: bool = True,
21
lazy_io: bool = False,
22
use_pandas: bool = True,
23
**kwargs
24
): ...
25
26
def write_simulation(
27
self,
28
silent: bool = False,
29
ext_file_action: ExtFileAction = ExtFileAction.copy_relative_paths
30
) -> None:
31
"""Write all simulation files to the workspace"""
32
...
33
34
def run_simulation(
35
self,
36
silent: bool = False,
37
pause: bool = False,
38
report: bool = False,
39
normal_msg: str = 'normal termination'
40
) -> tuple[bool, list[str]]:
41
"""Run the MODFLOW 6 simulation and return success status and output"""
42
...
43
44
def load_package(
45
self,
46
ftype: str,
47
fname: str,
48
pname: str,
49
**kwargs
50
) -> object:
51
"""Load a package from file"""
52
...
53
54
def register_ims_package(
55
self,
56
solution: object,
57
model_list: list[str]
58
) -> None:
59
"""Register iterative model solution for models"""
60
...
61
62
def get_model(self, model_name: str = None) -> object:
63
"""Get model by name"""
64
...
65
66
def remove_model(self, model_name: str) -> None:
67
"""Remove model from simulation"""
68
...
69
70
@property
71
def simulation_data(self) -> object:
72
"""Access to simulation data container"""
73
...
74
75
@property
76
def name_file(self) -> object:
77
"""Simulation name file object"""
78
...
79
```
80
81
### MFModel
82
83
Base class for all MODFLOW 6 models providing common functionality.
84
85
```python { .api }
86
class MFModel:
87
"""Base class for MODFLOW 6 models"""
88
def __init__(
89
self,
90
simulation: MFSimulation,
91
model_type: str,
92
modelname: str,
93
**kwargs
94
): ...
95
96
def load_package(
97
self,
98
ftype: str,
99
fname: str,
100
pname: str = None,
101
**kwargs
102
) -> object:
103
"""Load package from file"""
104
...
105
106
def remove_package(self, package_name: str) -> bool:
107
"""Remove package from model"""
108
...
109
110
def get_package(self, name: str = None) -> object:
111
"""Get package by name or file type"""
112
...
113
114
def set_model_relative_path(self, path: str) -> None:
115
"""Set relative path for model files"""
116
...
117
118
@property
119
def modelgrid(self) -> object:
120
"""Model grid object"""
121
...
122
123
@property
124
def packages(self) -> list[object]:
125
"""List of model packages"""
126
...
127
```
128
129
## Model Types
130
131
### ModflowGwf
132
133
Groundwater flow model for simulating saturated groundwater flow.
134
135
```python { .api }
136
class ModflowGwf(MFModel):
137
"""MODFLOW 6 groundwater flow model"""
138
def __init__(
139
self,
140
simulation: MFSimulation,
141
modelname: str = 'gwf',
142
model_nam_file: str = None,
143
version: str = 'mf6',
144
exe_name: str = 'mf6',
145
model_ws: str = None,
146
disfile: str = None,
147
grid_type: str = 'structured',
148
xll: float = None,
149
yll: float = None,
150
rotation: float = 0.0,
151
proj4_str: str = None,
152
**kwargs
153
): ...
154
155
def get_steadystate_list(self) -> list[bool]:
156
"""Get list of steady state periods"""
157
...
158
159
def get_package_list(self, ftype: str = None) -> list[str]:
160
"""Get list of packages by file type"""
161
...
162
```
163
164
### ModflowGwt
165
166
Groundwater transport model for simulating solute transport.
167
168
```python { .api }
169
class ModflowGwt(MFModel):
170
"""MODFLOW 6 groundwater transport model"""
171
def __init__(
172
self,
173
simulation: MFSimulation,
174
modelname: str = 'gwt',
175
model_nam_file: str = None,
176
version: str = 'mf6',
177
exe_name: str = 'mf6',
178
model_ws: str = None,
179
disfile: str = None,
180
**kwargs
181
): ...
182
```
183
184
### ModflowGwe
185
186
Groundwater energy transport model for simulating heat transport.
187
188
```python { .api }
189
class ModflowGwe(MFModel):
190
"""MODFLOW 6 groundwater energy transport model"""
191
def __init__(
192
self,
193
simulation: MFSimulation,
194
modelname: str = 'gwe',
195
model_nam_file: str = None,
196
version: str = 'mf6',
197
exe_name: str = 'mf6',
198
model_ws: str = None,
199
disfile: str = None,
200
**kwargs
201
): ...
202
```
203
204
### ModflowPrt
205
206
Particle tracking model for flow path analysis.
207
208
```python { .api }
209
class ModflowPrt(MFModel):
210
"""MODFLOW 6 particle tracking model"""
211
def __init__(
212
self,
213
simulation: MFSimulation,
214
modelname: str = 'prt',
215
model_nam_file: str = None,
216
version: str = 'mf6',
217
exe_name: str = 'mf6',
218
model_ws: str = None,
219
**kwargs
220
): ...
221
```
222
223
## Core Packages
224
225
### Time Discretization
226
227
#### ModflowTdis
228
229
Temporal discretization package that defines stress periods and time stepping.
230
231
```python { .api }
232
class ModflowTdis:
233
"""MODFLOW 6 time discretization package"""
234
def __init__(
235
self,
236
simulation: MFSimulation,
237
loading_package: bool = False,
238
time_units: str = 'DAYS',
239
start_date_time: str = None,
240
nper: int = 1,
241
perioddata: list[tuple] = None,
242
filename: str = None,
243
pname: str = None,
244
**kwargs
245
): ...
246
```
247
248
**Parameters:**
249
- `time_units` (str): Time units ('DAYS', 'HOURS', 'MINUTES', 'SECONDS', 'YEARS')
250
- `nper` (int): Number of stress periods
251
- `perioddata` (list[tuple]): List of (perlen, nstp, tsmult) tuples for each period
252
- `start_date_time` (str): Starting date and time in ISO format
253
254
### Solution Packages
255
256
#### ModflowIms
257
258
Iterative model solution package for solving linear equations.
259
260
```python { .api }
261
class ModflowIms:
262
"""MODFLOW 6 iterative model solution package"""
263
def __init__(
264
self,
265
simulation: MFSimulation,
266
loading_package: bool = False,
267
print_option: str = None,
268
complexity: str = 'SIMPLE',
269
csv_output_filerecord: str = None,
270
csv_outer_output_filerecord: str = None,
271
no_ptcrecord: str = None,
272
outer_dvclose: float = 1e-4,
273
outer_maximum: int = 100,
274
under_relaxation: str = None,
275
inner_maximum: int = 100,
276
inner_dvclose: float = 1e-4,
277
rcloserecord: list = None,
278
linear_acceleration: str = 'BICGSTAB',
279
scaling_method: str = None,
280
reordering_method: str = None,
281
relaxation_factor: float = 0.97,
282
preconditioner_levels: int = 7,
283
preconditioner_drop_tolerance: float = 0.0001,
284
number_orthogonalizations: int = 0,
285
filename: str = None,
286
pname: str = None,
287
**kwargs
288
): ...
289
```
290
291
## Discretization Packages
292
293
### ModflowGwfdis
294
295
Structured grid discretization package for regular rectangular grids.
296
297
```python { .api }
298
class ModflowGwfdis:
299
"""MODFLOW 6 structured grid discretization"""
300
def __init__(
301
self,
302
model: ModflowGwf,
303
loading_package: bool = False,
304
length_units: str = 'FEET',
305
nogrb: bool = None,
306
xorigin: float = None,
307
yorigin: float = None,
308
angrot: float = None,
309
nlay: int = 1,
310
nrow: int = 2,
311
ncol: int = 2,
312
delr: ArrayData = 1.0,
313
delc: ArrayData = 1.0,
314
top: ArrayData = 1.0,
315
botm: ArrayData = 0.0,
316
idomain: ArrayData = None,
317
filename: str = None,
318
pname: str = None,
319
**kwargs
320
): ...
321
```
322
323
### ModflowGwfdisu
324
325
Unstructured grid discretization package for flexible mesh geometries.
326
327
```python { .api }
328
class ModflowGwfdisu:
329
"""MODFLOW 6 unstructured grid discretization"""
330
def __init__(
331
self,
332
model: ModflowGwf,
333
loading_package: bool = False,
334
length_units: str = 'FEET',
335
nogrb: bool = None,
336
xorigin: float = None,
337
yorigin: float = None,
338
angrot: float = None,
339
nodes: int = None,
340
nja: int = None,
341
nvert: int = None,
342
top: ArrayData = None,
343
bot: ArrayData = None,
344
area: ArrayData = None,
345
idomain: ArrayData = None,
346
iac: ArrayData = None,
347
ja: ArrayData = None,
348
ihc: ArrayData = None,
349
cl12: ArrayData = None,
350
hwva: ArrayData = None,
351
angldegx: ArrayData = None,
352
vertices: list[tuple] = None,
353
cell2d: list[tuple] = None,
354
filename: str = None,
355
pname: str = None,
356
**kwargs
357
): ...
358
```
359
360
### ModflowGwfdisv
361
362
Vertex grid discretization package for flexible layered grids.
363
364
```python { .api }
365
class ModflowGwfdisv:
366
"""MODFLOW 6 vertex grid discretization"""
367
def __init__(
368
self,
369
model: ModflowGwf,
370
loading_package: bool = False,
371
length_units: str = 'FEET',
372
nogrb: bool = None,
373
xorigin: float = None,
374
yorigin: float = None,
375
angrot: float = None,
376
nlay: int = 1,
377
ncpl: int = None,
378
nvert: int = None,
379
top: ArrayData = None,
380
botm: ArrayData = None,
381
idomain: ArrayData = None,
382
vertices: list[tuple] = None,
383
cell2d: list[tuple] = None,
384
filename: str = None,
385
pname: str = None,
386
**kwargs
387
): ...
388
```
389
390
## Flow Packages
391
392
### ModflowGwfnpf
393
394
Node property flow package that defines hydraulic properties.
395
396
```python { .api }
397
class ModflowGwfnpf:
398
"""MODFLOW 6 node property flow package"""
399
def __init__(
400
self,
401
model: ModflowGwf,
402
loading_package: bool = False,
403
ipakcb: str = None,
404
cellavg: str = None,
405
thickstrt: bool = None,
406
cvoptions: str = None,
407
perched: bool = None,
408
rewet_record: str = None,
409
xt3doptions: str = None,
410
save_specific_discharge: bool = None,
411
save_saturation: bool = None,
412
k_filerecord: str = None,
413
k33_filerecord: str = None,
414
sat_filerecord: str = None,
415
icelltype: ArrayData = 0,
416
k: ArrayData = 1.0,
417
k22: ArrayData = None,
418
k33: ArrayData = None,
419
angle1: ArrayData = None,
420
angle2: ArrayData = None,
421
angle3: ArrayData = None,
422
wetdry: ArrayData = None,
423
filename: str = None,
424
pname: str = None,
425
**kwargs
426
): ...
427
```
428
429
### ModflowGwfic
430
431
Initial conditions package that sets starting heads.
432
433
```python { .api }
434
class ModflowGwfic:
435
"""MODFLOW 6 initial conditions package"""
436
def __init__(
437
self,
438
model: ModflowGwf,
439
loading_package: bool = False,
440
strt: ArrayData = 1.0,
441
filename: str = None,
442
pname: str = None,
443
**kwargs
444
): ...
445
```
446
447
### ModflowGwfsto
448
449
Storage package for transient simulations.
450
451
```python { .api }
452
class ModflowGwfsto:
453
"""MODFLOW 6 storage package"""
454
def __init__(
455
self,
456
model: ModflowGwf,
457
loading_package: bool = False,
458
save_flows: bool = None,
459
ipakcb: str = None,
460
storagecoefficient: bool = None,
461
ss_confined_only: bool = None,
462
tvs_filerecord: str = None,
463
iconvert: ArrayData = 0,
464
ss: ArrayData = 1e-5,
465
sy: ArrayData = 0.15,
466
steady_state: list[bool] = None,
467
transient: list[bool] = None,
468
filename: str = None,
469
pname: str = None,
470
**kwargs
471
): ...
472
```
473
474
## Boundary Condition Packages
475
476
### ModflowGwfchd
477
478
Constant head boundary package.
479
480
```python { .api }
481
class ModflowGwfchd:
482
"""MODFLOW 6 constant head boundary package"""
483
def __init__(
484
self,
485
model: ModflowGwf,
486
loading_package: bool = False,
487
auxiliary: list[str] = None,
488
auxmultname: str = None,
489
boundnames: bool = None,
490
print_input: bool = None,
491
print_flows: bool = None,
492
save_flows: bool = None,
493
observations: dict = None,
494
maxbound: int = None,
495
stress_period_data: StressPeriodData = None,
496
filename: str = None,
497
pname: str = None,
498
**kwargs
499
): ...
500
```
501
502
### ModflowGwfwel
503
504
Well package for pumping and injection wells.
505
506
```python { .api }
507
class ModflowGwfwel:
508
"""MODFLOW 6 well package"""
509
def __init__(
510
self,
511
model: ModflowGwf,
512
loading_package: bool = False,
513
auxiliary: list[str] = None,
514
auxmultname: str = None,
515
boundnames: bool = None,
516
print_input: bool = None,
517
print_flows: bool = None,
518
save_flows: bool = None,
519
auto_flow_reduce: float = None,
520
observations: dict = None,
521
mover: bool = None,
522
maxbound: int = None,
523
stress_period_data: StressPeriodData = None,
524
filename: str = None,
525
pname: str = None,
526
**kwargs
527
): ...
528
```
529
530
### ModflowGwfrch
531
532
Recharge package for distributed recharge.
533
534
```python { .api }
535
class ModflowGwfrch:
536
"""MODFLOW 6 recharge package"""
537
def __init__(
538
self,
539
model: ModflowGwf,
540
loading_package: bool = False,
541
auxiliary: list[str] = None,
542
auxmultname: str = None,
543
boundnames: bool = None,
544
print_input: bool = None,
545
print_flows: bool = None,
546
save_flows: bool = None,
547
readasarrays: bool = None,
548
fixed_cell: bool = None,
549
observations: dict = None,
550
mover: bool = None,
551
maxbound: int = None,
552
recharge: ArrayData = None,
553
stress_period_data: StressPeriodData = None,
554
filename: str = None,
555
pname: str = None,
556
**kwargs
557
): ...
558
```
559
560
### ModflowGwfevt
561
562
Evapotranspiration package.
563
564
```python { .api }
565
class ModflowGwfevt:
566
"""MODFLOW 6 evapotranspiration package"""
567
def __init__(
568
self,
569
model: ModflowGwf,
570
loading_package: bool = False,
571
auxiliary: list[str] = None,
572
auxmultname: str = None,
573
boundnames: bool = None,
574
print_input: bool = None,
575
print_flows: bool = None,
576
save_flows: bool = None,
577
readasarrays: bool = None,
578
fixed_cell: bool = None,
579
observations: dict = None,
580
mover: bool = None,
581
maxbound: int = None,
582
surface: ArrayData = None,
583
rate: ArrayData = None,
584
depth: ArrayData = None,
585
stress_period_data: StressPeriodData = None,
586
filename: str = None,
587
pname: str = None,
588
**kwargs
589
): ...
590
```
591
592
### ModflowGwfghb
593
594
General head boundary package.
595
596
```python { .api }
597
class ModflowGwfghb:
598
"""MODFLOW 6 general head boundary package"""
599
def __init__(
600
self,
601
model: ModflowGwf,
602
loading_package: bool = False,
603
auxiliary: list[str] = None,
604
auxmultname: str = None,
605
boundnames: bool = None,
606
print_input: bool = None,
607
print_flows: bool = None,
608
save_flows: bool = None,
609
observations: dict = None,
610
mover: bool = None,
611
maxbound: int = None,
612
stress_period_data: StressPeriodData = None,
613
filename: str = None,
614
pname: str = None,
615
**kwargs
616
): ...
617
```
618
619
### ModflowGwfriv
620
621
River package for river-aquifer interaction.
622
623
```python { .api }
624
class ModflowGwfriv:
625
"""MODFLOW 6 river package"""
626
def __init__(
627
self,
628
model: ModflowGwf,
629
loading_package: bool = False,
630
auxiliary: list[str] = None,
631
auxmultname: str = None,
632
boundnames: bool = None,
633
print_input: bool = None,
634
print_flows: bool = None,
635
save_flows: bool = None,
636
observations: dict = None,
637
mover: bool = None,
638
maxbound: int = None,
639
stress_period_data: StressPeriodData = None,
640
filename: str = None,
641
pname: str = None,
642
**kwargs
643
): ...
644
```
645
646
### ModflowGwfdrn
647
648
Drain package for drainage features.
649
650
```python { .api }
651
class ModflowGwfdrn:
652
"""MODFLOW 6 drain package"""
653
def __init__(
654
self,
655
model: ModflowGwf,
656
loading_package: bool = False,
657
auxiliary: list[str] = None,
658
auxmultname: str = None,
659
boundnames: bool = None,
660
print_input: bool = None,
661
print_flows: bool = None,
662
save_flows: bool = None,
663
observations: dict = None,
664
mover: bool = None,
665
maxbound: int = None,
666
stress_period_data: StressPeriodData = None,
667
filename: str = None,
668
pname: str = None,
669
**kwargs
670
): ...
671
```
672
673
## Advanced Packages
674
675
### ModflowGwflak
676
677
Lake package for lake-aquifer interaction.
678
679
```python { .api }
680
class ModflowGwflak:
681
"""MODFLOW 6 lake package"""
682
def __init__(
683
self,
684
model: ModflowGwf,
685
loading_package: bool = False,
686
auxiliary: list[str] = None,
687
boundnames: bool = None,
688
print_input: bool = None,
689
print_stage: bool = None,
690
print_flows: bool = None,
691
save_flows: bool = None,
692
stage_filerecord: str = None,
693
budget_filerecord: str = None,
694
budgetcsv_filerecord: str = None,
695
package_convergence_filerecord: str = None,
696
ts_filerecord: str = None,
697
observations: dict = None,
698
mover: bool = None,
699
surfdep: float = None,
700
time_conversion: float = None,
701
length_conversion: float = None,
702
nlakes: int = None,
703
noutlets: int = None,
704
ntables: int = None,
705
packagedata: list[tuple] = None,
706
connectiondata: list[tuple] = None,
707
tables: list[tuple] = None,
708
outlets: list[tuple] = None,
709
perioddata: StressPeriodData = None,
710
filename: str = None,
711
pname: str = None,
712
**kwargs
713
): ...
714
```
715
716
### ModflowGwfsfr
717
718
Streamflow routing package for stream networks.
719
720
```python { .api }
721
class ModflowGwfsfr:
722
"""MODFLOW 6 streamflow routing package"""
723
def __init__(
724
self,
725
model: ModflowGwf,
726
loading_package: bool = False,
727
auxiliary: list[str] = None,
728
boundnames: bool = None,
729
print_input: bool = None,
730
print_stage: bool = None,
731
print_flows: bool = None,
732
save_flows: bool = None,
733
stage_filerecord: str = None,
734
budget_filerecord: str = None,
735
budgetcsv_filerecord: str = None,
736
package_convergence_filerecord: str = None,
737
ts_filerecord: str = None,
738
observations: dict = None,
739
mover: bool = None,
740
maximum_depth_change: float = None,
741
maximum_picard_iterations: int = None,
742
length_conversion: float = None,
743
time_conversion: float = None,
744
nreaches: int = None,
745
packagedata: list[tuple] = None,
746
connectiondata: list[tuple] = None,
747
diversions: list[tuple] = None,
748
perioddata: StressPeriodData = None,
749
filename: str = None,
750
pname: str = None,
751
**kwargs
752
): ...
753
```
754
755
### ModflowGwfmaw
756
757
Multi-aquifer well package for complex wells.
758
759
```python { .api }
760
class ModflowGwfmaw:
761
"""MODFLOW 6 multi-aquifer well package"""
762
def __init__(
763
self,
764
model: ModflowGwf,
765
loading_package: bool = False,
766
auxiliary: list[str] = None,
767
boundnames: bool = None,
768
print_input: bool = None,
769
print_head: bool = None,
770
print_flows: bool = None,
771
save_flows: bool = None,
772
head_filerecord: str = None,
773
budget_filerecord: str = None,
774
budgetcsv_filerecord: str = None,
775
package_convergence_filerecord: str = None,
776
ts_filerecord: str = None,
777
observations: dict = None,
778
mover: bool = None,
779
flowing_wells: bool = None,
780
shutdown_theta: float = None,
781
shutdown_kappa: float = None,
782
nmawwells: int = None,
783
packagedata: list[tuple] = None,
784
connectiondata: list[tuple] = None,
785
perioddata: StressPeriodData = None,
786
filename: str = None,
787
pname: str = None,
788
**kwargs
789
): ...
790
```
791
792
### ModflowGwfuzf
793
794
Unsaturated zone flow package.
795
796
```python { .api }
797
class ModflowGwfuzf:
798
"""MODFLOW 6 unsaturated zone flow package"""
799
def __init__(
800
self,
801
model: ModflowGwf,
802
loading_package: bool = False,
803
auxiliary: list[str] = None,
804
auxmultname: str = None,
805
boundnames: bool = None,
806
print_input: bool = None,
807
print_flows: bool = None,
808
save_flows: bool = None,
809
wc_filerecord: str = None,
810
budget_filerecord: str = None,
811
budgetcsv_filerecord: str = None,
812
package_convergence_filerecord: str = None,
813
ts_filerecord: str = None,
814
observations: dict = None,
815
mover: bool = None,
816
simulate_et: bool = None,
817
linear_gwet: bool = None,
818
square_gwet: bool = None,
819
simulate_gwseep: bool = None,
820
unsat_etwc: bool = None,
821
unsat_etae: bool = None,
822
nuzfcells: int = None,
823
ntrailwaves: int = None,
824
nwavesets: int = None,
825
packagedata: list[tuple] = None,
826
perioddata: StressPeriodData = None,
827
filename: str = None,
828
pname: str = None,
829
**kwargs
830
): ...
831
```
832
833
## Output Control
834
835
### ModflowGwfoc
836
837
Output control package for managing model output.
838
839
```python { .api }
840
class ModflowGwfoc:
841
"""MODFLOW 6 output control package"""
842
def __init__(
843
self,
844
model: ModflowGwf,
845
loading_package: bool = False,
846
budget_filerecord: str = None,
847
head_filerecord: str = None,
848
headprintrecord: str = None,
849
saverecord: list[tuple] = None,
850
printrecord: list[tuple] = None,
851
filename: str = None,
852
pname: str = None,
853
**kwargs
854
): ...
855
```
856
857
## Usage Examples
858
859
### Basic Groundwater Flow Model
860
861
```python
862
import flopy
863
import numpy as np
864
865
# Create simulation
866
sim = flopy.mf6.MFSimulation(sim_name='basic_gwf', version='mf6', exe_name='mf6')
867
868
# Add time discretization
869
tdis = flopy.mf6.ModflowTdis(
870
sim,
871
time_units='DAYS',
872
nper=2,
873
perioddata=[(1.0, 1, 1.0), (365.0, 12, 1.2)]
874
)
875
876
# Create groundwater flow model
877
gwf = flopy.mf6.ModflowGwf(sim, modelname='gwf', save_flows=True)
878
879
# Add discretization
880
dis = flopy.mf6.ModflowGwfdis(
881
gwf,
882
nlay=3, nrow=50, ncol=50,
883
delr=100.0, delc=100.0,
884
top=100.0,
885
botm=[50.0, 0.0, -50.0]
886
)
887
888
# Add initial conditions
889
ic = flopy.mf6.ModflowGwfic(gwf, strt=75.0)
890
891
# Add node property flow
892
npf = flopy.mf6.ModflowGwfnpf(
893
gwf,
894
k=[10.0, 5.0, 1.0], # Different K for each layer
895
icelltype=1 # Convertible layers
896
)
897
898
# Add storage for transient simulation
899
sto = flopy.mf6.ModflowGwfsto(
900
gwf,
901
ss=1e-5,
902
sy=0.2,
903
iconvert=1,
904
steady_state={0: True}, # First period steady state
905
transient={1: True} # Second period transient
906
)
907
908
# Add constant head boundaries
909
chd_period_data = {
910
0: [[(0, 0, 0), 100.0], [(0, 49, 49), 80.0]],
911
1: [[(0, 0, 0), 95.0], [(0, 49, 49), 75.0]]
912
}
913
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chd_period_data)
914
915
# Add recharge
916
rch = flopy.mf6.ModflowGwfrch(gwf, recharge=0.001)
917
918
# Add output control
919
oc = flopy.mf6.ModflowGwfoc(
920
gwf,
921
head_filerecord='gwf.hds',
922
budget_filerecord='gwf.cbc',
923
saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')],
924
printrecord=[('HEAD', 'LAST'), ('BUDGET', 'ALL')]
925
)
926
927
# Add solver
928
ims = flopy.mf6.ModflowIms(sim, complexity='SIMPLE')
929
930
# Write and run
931
sim.write_simulation()
932
success, buff = sim.run_simulation()
933
```
934
935
### Advanced Lake-Stream Model
936
937
```python
938
import flopy
939
940
# Create simulation with multiple models
941
sim = flopy.mf6.MFSimulation(sim_name='lake_stream', exe_name='mf6')
942
943
# Time discretization for seasonal analysis
944
tdis = flopy.mf6.ModflowTdis(
945
sim,
946
time_units='DAYS',
947
nper=4, # Four seasons
948
perioddata=[(90, 30, 1.1) for _ in range(4)]
949
)
950
951
# Groundwater flow model
952
gwf = flopy.mf6.ModflowGwf(sim, modelname='gwf')
953
954
# Structured grid
955
dis = flopy.mf6.ModflowGwfdis(
956
gwf,
957
nlay=5, nrow=100, ncol=100,
958
delr=50.0, delc=50.0,
959
top=50.0,
960
botm=[40.0, 30.0, 20.0, 10.0, -10.0]
961
)
962
963
# Initial conditions
964
ic = flopy.mf6.ModflowGwfic(gwf, strt=45.0)
965
966
# Node property flow with varying K
967
k_values = np.array([20.0, 15.0, 10.0, 5.0, 1.0])
968
npf = flopy.mf6.ModflowGwfnpf(gwf, k=k_values)
969
970
# Lake package
971
lake_packagedata = [
972
[0, 42.0, 10, 'lake1'], # Lake ID, stage, connections, name
973
]
974
lake_connectiondata = [
975
[0, 0, (0, 50, 50), 'horizontal', 1.0, 0.5, 0.0, 100.0, 100.0],
976
]
977
lak = flopy.mf6.ModflowGwflak(
978
gwf,
979
nlakes=1,
980
packagedata=lake_packagedata,
981
connectiondata=lake_connectiondata
982
)
983
984
# Stream package
985
sfr_packagedata = [
986
[0, (0, 25, 10), 100.0, 1.0, 0.001, 0.0, 1.0, 0.035, 'reach1'],
987
[1, (0, 25, 11), 100.0, 1.0, 0.001, 0.0, 1.0, 0.035, 'reach2'],
988
]
989
sfr_connectiondata = [
990
[0, -1], # Reach 0 has no upstream connection
991
[1, 0], # Reach 1 connects to reach 0
992
]
993
sfr = flopy.mf6.ModflowGwfsfr(
994
gwf,
995
nreaches=2,
996
packagedata=sfr_packagedata,
997
connectiondata=sfr_connectiondata
998
)
999
1000
# Transport model
1001
gwt = flopy.mf6.ModflowGwt(sim, modelname='gwt')
1002
1003
# Transport solver
1004
ims_gwt = flopy.mf6.ModflowIms(
1005
sim,
1006
filename='gwt.ims',
1007
linear_acceleration='BICGSTAB'
1008
)
1009
sim.register_ims_package(ims_gwt, [gwt.name])
1010
1011
# Write and run
1012
sim.write_simulation()
1013
success, buff = sim.run_simulation()
1014
```
1015
1016
## Common Types
1017
1018
```python { .api }
1019
# MODFLOW 6 specific types
1020
ExtFileAction = Literal['copy_relative_paths', 'copy_all', 'copy_none']
1021
ArrayData = Union[int, float, np.ndarray, list, str]
1022
StressPeriodData = dict[int, list[list]]
1023
PackageData = list[tuple]
1024
ConnectionData = list[tuple]
1025
ObservationData = dict[str, list[tuple]]
1026
1027
# Time discretization
1028
PeriodData = list[tuple[float, int, float]] # (perlen, nstp, tsmult)
1029
1030
# Boundary condition data
1031
BoundaryData = list[list] # [cellid, *values]
1032
1033
# File record types
1034
FileRecord = str | list[str]
1035
```
1036
1037
This comprehensive documentation covers the complete MODFLOW 6 API including all major model types, packages, and their parameters. The examples demonstrate both basic and advanced usage patterns for groundwater flow, transport, and surface water interaction modeling.