|
6 | 6 | "source": [ |
7 | 7 | "# STEMMUS_SCOPE & MODFLOW 6 BMI coupling\n", |
8 | 8 | "\n", |
9 | | - "This Python notebook shows a simple example of BMI coupling between the STEMMUS_SCOPE model and the MODFLOW 6 model. The example is prepared for one of the PLUMBER2 dataset (https://researchdata.edu.au/plumber2-forcing-evaluation-surface-models/1656048): the LooBos site, the Netherlands (NL-Loo). To run this notebook, the following are required:\n", |
| 9 | + "This Python notebook shows a simple example of BMI coupling between the STEMMUS_SCOPE model and the MODFLOW 6 model, based on research carried by \"M. Daoud\", as a part of [EcoExtreML](https://research-software-directory.org/projects/ecoextreml) project, for more info see [this reference](https://research.utwente.nl/en/publications/investigating-the-role-of-groundwater-in-mitigating-vegetation-wa). The example is prepared for one of the PLUMBER2 dataset (https://researchdata.edu.au/plumber2-forcing-evaluation-surface-models/1656048): the LooBos site, the Netherlands (NL-Loo). To run this notebook, the following are required:\n", |
10 | 10 | "- Install the related packages:\n", |
11 | 11 | " - pyStemmusScope package (https://pystemmusscope.readthedocs.io/en/latest/).\n", |
12 | 12 | " - modflowapi Python package (https://github.com/MODFLOW-USGS/modflowapi?tab=readme-ov-file#installation).\n", |
|
124 | 124 | } |
125 | 125 | ], |
126 | 126 | "source": [ |
127 | | - "# Add the matlab runtime compiler locations: \n", |
| 127 | + "# Add the matlab runtime compiler locations:\n", |
128 | 128 | "matlab_version = 'R2023a'\n", |
129 | | - "matlab_path = '/opt/matlab/MATLAB_Runtime/' + matlab_version \n", |
130 | | - " \n", |
131 | | - "os.environ['LD_LIBRARY_PATH'] = ( \n", |
| 129 | + "matlab_path = '/opt/matlab/MATLAB_Runtime/' + matlab_version\n", |
| 130 | + "\n", |
| 131 | + "os.environ['LD_LIBRARY_PATH'] = (\n", |
132 | 132 | " f\"{matlab_path}/runtime/glnxa64:\"\n", |
133 | 133 | " f\"{matlab_path}/bin/glnxa64:\"\n", |
134 | 134 | " f\"{matlab_path}/sys/os/glnxa64:\"\n", |
|
262 | 262 | ], |
263 | 263 | "source": [ |
264 | 264 | "sim = ApiSimulation.load(modflow)\n", |
265 | | - "gwf_name = sim.model_names[0] # groundwater flow model \n", |
| 265 | + "gwf_name = sim.model_names[0] # groundwater flow model\n", |
266 | 266 | "gwe_name = sim.model_names[1] # groundwater energy (heat) model\n", |
267 | 267 | "gwf_name, gwe_name" |
268 | 268 | ] |
|
399 | 399 | "source": [ |
400 | 400 | "stemmus_scope.set_value(\"groundwater_elevation_top_aquifer\", top_elev)\n", |
401 | 401 | "stemmus_scope.set_value(\"groundwater_head_bottom_layer\", gwhead_init)\n", |
402 | | - "stemmus_scope.set_value(\"groundwater_temperature\", gwtemp_init) " |
| 402 | + "stemmus_scope.set_value(\"groundwater_temperature\", gwtemp_init)" |
403 | 403 | ] |
404 | 404 | }, |
405 | 405 | { |
|
6650 | 6650 | ], |
6651 | 6651 | "source": [ |
6652 | 6652 | "while modflow.get_current_time() < modflow.get_end_time():\n", |
6653 | | - " while stemmus_scope.get_current_time() < stemmus_scope.get_end_time(): \n", |
6654 | | - " \n", |
6655 | | - " # Get STEMMUS_SCOPE variables (soil moisture, soil temperature, groundwater recharge) \n", |
| 6653 | + " while stemmus_scope.get_current_time() < stemmus_scope.get_end_time():\n", |
| 6654 | + "\n", |
| 6655 | + " # Get STEMMUS_SCOPE variables (soil moisture, soil temperature, groundwater recharge)\n", |
6656 | 6656 | " stemmus_scope.get_value(\"soil_moisture\", soil_moisture[i])\n", |
6657 | 6657 | " stemmus_scope.get_value(\"soil_temperature\", soil_temperature[i])\n", |
6658 | 6658 | " stemmus_scope.get_value(\"groundwater_recharge\", gw_recharge)\n", |
|
6669 | 6669 | " # Set STEMMUS_SCOPE variables (groundwater head, groundwater temperature)\n", |
6670 | 6670 | " stemmus_scope.set_value(\"groundwater_head_bottom_layer\", gwhead)\n", |
6671 | 6671 | " stemmus_scope.set_value(\"groundwater_temperature\", gwtemp)\n", |
6672 | | - " \n", |
| 6672 | + "\n", |
6673 | 6673 | " # Set MODFLOW 6 variables (groundwater recharge)\n", |
6674 | | - " kstp, kper = sim.kstp, sim.kper \n", |
| 6674 | + " kstp, kper = sim.kstp, sim.kper\n", |
6675 | 6675 | " if kstp == nstp - 1:\n", |
6676 | | - " # groundwater recharge per stress period = sum of groundwater recharge per time step \n", |
| 6676 | + " # groundwater recharge per stress period = sum of groundwater recharge per time step\n", |
6677 | 6677 | " gw_recharge_nper = np.array([-1 * np.sum(gw_recharge_nstp) / 100]) # multiply by -1 due to different signs of both models\n", |
6678 | 6678 | " modflow.set_value(rch_tag, gw_recharge_nper)\n", |
6679 | | - " gw_recharge_nstp = np.array([]) \n", |
6680 | | - " \n", |
6681 | | - " # Track the simulation time of MODFLOW 6 \n", |
| 6679 | + " gw_recharge_nstp = np.array([])\n", |
| 6680 | + "\n", |
| 6681 | + " # Track the simulation time of MODFLOW 6\n", |
6682 | 6682 | " print('Updating MODFLOW Stress period ' + str(kper + 1) + ', time step ' + str(kstp + 1))\n", |
6683 | 6683 | " # print(kper + 1, kstp + 1, gwhead, gwtemp)\n", |
6684 | | - " \n", |
| 6684 | + "\n", |
6685 | 6685 | " # Update models\n", |
6686 | 6686 | " stemmus_scope.update()\n", |
6687 | 6687 | " modflow.update()" |
|
0 commit comments