11from os import PathLike
2- from pathlib import Path
32from warnings import warn
43
54from flopy .discretization .modeltime import ModelTime
65from modflow_devtools .misc import cd , run_cmd
76from xattree import xattree
87
9- from flopy4 .mf6 .component import Component
8+ from flopy4 .mf6 .context import Context
109from flopy4 .mf6 .exchange import Exchange
1110from flopy4 .mf6 .model import Model
1211from flopy4 .mf6 .solution import Solution
@@ -23,30 +22,21 @@ def convert_time(value):
2322
2423
2524@xattree
26- class Simulation (Component ):
25+ class Simulation (Context ):
2726 models : dict [str , Model ] = field ()
2827 exchanges : dict [str , Exchange ] = field ()
2928 solutions : dict [str , Solution ] = field ()
3029 tdis : Tdis = field (converter = convert_time )
31- workspace : Path = field (default = None )
32- filename : str = field (default = "mfsim.nam" )
30+ filename : str = field (default = "mfsim.nam" , init = False )
3331
3432 def __attrs_post_init__ (self ):
35- super ().__attrs_post_init__ ()
3633 if self .filename != "mfsim.nam" :
3734 warn (
3835 "Simulation filename must be 'mfsim.nam'." ,
3936 UserWarning ,
4037 )
4138 self .filename = "mfsim.nam"
4239
43- @property
44- def path (self ) -> Path :
45- """Return the path to the simulation namefile."""
46- if self .workspace is None :
47- raise ValueError ("Simulation has no workspace path." )
48- return Path (self .workspace ).expanduser ().resolve () / self .filename
49-
5040 @property
5141 def time (self ) -> ModelTime :
5242 """Return the simulation time discretization."""
@@ -66,10 +56,8 @@ def run(self, exe: str | PathLike = "mf6", verbose: bool = False) -> None:
6656
6757 def load (self , format = "ascii" ):
6858 """Load the simulation in the specified format."""
69- with cd (self .workspace ):
70- super ().load (format )
59+ super ().load (format )
7160
7261 def write (self , format = "ascii" ):
7362 """Write the simulation in the specified format."""
74- with cd (self .workspace ):
75- super ().write (format )
63+ super ().write (format )
0 commit comments