Welcome to WEAP's Website WEAP
WEAP is an initiative of the Stockholm Environment Institute.


About WEAP

Home
Why WEAP?
Features
What's New?
Sample Screens
Demonstration
Publications
History and Credits

Using WEAP
Download
Licensing
User Guide
Tutorial
Videos (YouTube)

User Forum
Discussions
Members List
Edit Profile

Additional Support
Training
University Courses
Collaboration

About Us
SEI-US Water Resources Program
Please Contact Us

LEAP
Interested in Energy?
Read about LEAP: SEI's software for energy planning.

Link WEAP and LEAP for combined Water-Energy planning.
Watch a video demo!
   

User Forum

All Topics | Topic "MODFLOW - WEAP LINKAGE"
Log in to post new messages or reply to existing messages.
 
Author Message
Mrs. Resmy K

Subject: MODFLOW - WEAP LINKAGE   
Posted: 5/18/2021 Viewed: 479 times
Can we stop MODFLOW in between simulation, and update the input recharge file through WEAP?
Mr. Markus Huber

Subject: Re: MODFLOW - WEAP LINKAGE   
Posted: 6/7/2021 Viewed: 169 times
Dear Resmy,

yes, there is a pretty workaround calling a vb-script at the right interupt-event. I've developed exactly what you are asking for shortly and it works like a charm.

1. Use the event-manager (Advanced -> Scripting -> Edit Events) and enter "Call( ExchangeRCHFile.vbs )" in the textbox besides "Before MODFLOW". This event fires AFTER Weap has produced its own set of MODFLOW files, but hasn't yet started MODFLOW. This is the right moment to replace the recharge file with your own.

2. Go to Advanced -> Scripting -> Edit Scripts and paste the lines below into a new document and save as ExchangeRCHFile.vbs. You will need to replace the words in brackets [] with what fits to your setup!

3. The script requires:
- that you have a folder containing all recharge files under the Area Directory
- that there is one folder for each scenario underneath
- the RCH-files are named "YYYY_MM.rch"
- the formats of the RCH-files match with the formats of the files produced by WEAP

Good luck and all the best
Markus



'---- Script:----

Option Explicit

Dim sCCRechFolder, sCCRechFile, sDestRechFile, sMFModelname, sMFFolder
Dim sScen, iScen, iYear, iMonth
Dim fso

sMFModelName = "[ENTER THE NAME OF YOUR MODFLOW MODEL HERE]"
sMFFolder = WEAP.ActiveArea.Directory & "MODFLOW\"
sCCRechFolder = WEAP.ActiveArea.Directory & "[ENTER THE FOLDERNAME WHERE THE RECHARGE FILES ARE]\"

'--- Generate FileNames based on current Scenario and Timestep'
sScen = WEAP.ActiveScenario.Name
iScen = Weap.ActiveScenario.ID
if len(iScen)<2 then iScen = "0" & iScen

iYear = CalcYear
iMonth = CalcTS
if len(iMonth)<2 then iMonth = "0" & iMonth


sCCRechFile = sCCRechFolder & "\" & sScen & "\" & iYear & "_" & iMonth & ".rch" 'you either need to follow this pattern in your file system, or you change the code here accordingly


sDestRechFile = sMFFolder & "!MF!" & sMFModelName & "_S" & iScen & "_" & iYear & "_" & iMonth & ".rch"


set fso=CreateObject("Scripting.FileSystemObject")

fso.deletefile sDestRechFile
fso.copyfile sCCRechFile, sDestRechFile


set fso = nothing


'---- end script ----
Topic "MODFLOW - WEAP LINKAGE"