Skip to content

Upload of MIKE SHE Hot Start Run Script - #9

Open
acgr96 wants to merge 3 commits into
DHI:mainfrom
acgr96:main
Open

Upload of MIKE SHE Hot Start Run Script#9
acgr96 wants to merge 3 commits into
DHI:mainfrom
acgr96:main

Conversation

@acgr96

@acgr96 acgr96 commented Aug 17, 2025

Copy link
Copy Markdown

Uploading a run script to SimulationExecution that can allow for using 3D water content distribution from previous WM simulations as the starting condition for another WM simulation by overwriting water content for the first several timesteps.

acgr96 added 3 commits August 17, 2025 13:20
This script allows for using a previous simulation's 3D water content distribution as a hot start condition for another WM simulation by overwriting the water content in the new simulation over the first several timesteps.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The new script has a confirmed runtime-breaking issue in how the MShePy extension module is loaded, and also needs small structural/convention fixes to be safely usable from the repo.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds a new SimulationExecution helper script intended to “hot start” a MIKE SHE WM simulation by reading 3D unsaturated-zone water content from a previous run and overwriting initial timesteps before continuing the run.

Changes:

  • Introduces MSHE_HotStart.py to read UZ water content from a dfs3 result and apply it as initial conditions for several timesteps.
  • Initializes and advances the MIKE SHE WM engine programmatically, then runs to the simulation end time.
File summaries
File Description
SimulationExecution/MSHE_HotStart.py New hot-start execution script that reads prior-run UZ water content and overwrites UZ_WC for the first N timesteps.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 4
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +7 to +10
import importlib.util
spec = importlib.util.spec_from_file_location('MShePy311', r'C:\Program Files (x86)\DHI\MIKE Zero\2025\bin\x64\MShePy311.pyd')
MShePy = importlib.util.module_from_spec(spec)

Comment on lines +15 to +33
# Load DFS3 Result File of Unsat Zone and get Water Content Array
print('Importing Water Content Data From Previous Model Run...')
uz_data = mikeio.read(r'D:\Projects\MIKESHE_Hotstart\TestModel\TestModel_3DUZ.dfs3')
wc_arr = uz_data['water content in unsaturated zone']
wc_arr_finalts = wc_arr[-1,:,:,:].values # Access array of 3D water content values at final timestep
#Transpose Z dimensions from first dim of array to last to align with MShePy dataset structure
wc_arr_finalts = np.transpose(wc_arr_finalts, (1, 2, 0))

# Initiate MIKE SHE Model
print('Initializing MIKESHE Model...')
model = r'D:\Projects\MIKESHE_Hotstart\TestModel\TestModel.she'
MShePy.wm.initialize(model)
MShePy

simperiod = MShePy.wm.simPeriod()
start_time = simperiod[0]
end_time = simperiod[-1]
assign_timesteps = 10 # Number of timesteps to execute water content overwrite

Comment on lines +34 to +39
for ts in range(assign_timesteps):
print(ts)
(t0, t1, wc) = MShePy.wm.getValues(MShePy.paramTypes.UZ_WC)
wc[:] = wc_arr_finalts.tolist()
MShePy.wm.setValues(wc)
MShePy.wm.performTimeStep()
Comment on lines +5 to +6
print('Importing Required Libraries...')
# Import MIKESHE
@watermain
watermain self-requested a review July 30, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants