Running Flopy/Modflow in Google Colab

566 views
Skip to first unread message

Chris Russoniello

unread,
Oct 9, 2020, 1:20:17 AM10/9/20
to MODFLOW Users Group
Folks,

I was wondering if anyone is using Google Colab to run FloPy/Modflow? If so, I was hoping you could share a sample Colab with me so I can see how you write input files, run Modflow, and read output files (I assume this would all need to be local?).

I would like to use this combo as a teaching tool, and love the flexibility of the CoLab environment for other teaching applications but cannot figure out how to mesh it all together.

Thanks,

Chris

Nguyễn Thái Vinh Trường

unread,
Oct 9, 2020, 1:55:55 AM10/9/20
to MODFLOW Users Group
I use

!pip install flopy
import flopy

And it shows:
flopy is installed in /usr/local/lib/python3.6/dist-packages/flopy


Hope it help! 

Vào lúc 13:20:17 UTC+8 ngày Thứ Sáu, 9 tháng 10, 2020, cjru...@gmail.com đã viết:

Chris Russoniello

unread,
Oct 12, 2020, 12:47:24 AM10/12/20
to MODFLOW Users Group
Thanks Vinhtru,

That makes sense. I get how to install/import floppy in Colab. I'm, but I'm more wondering about whether folks are able to use Colab/FloPy to run Modflow by:
1) Some solution to make it all run from the cloud (Colab for Flopy, store all files in Google Drive, and run the mf.exe through the cloud somehow), 
2) Store all inputs/outputs on the cloud and only use local resources for the actual mf2k05.exe (for this I guess you'd just mount your GDrive and then somehow call the mf.exe to call the input files from your Google Stream 'G: Drive'?), or even
3) Store input files locally, run mf2k05.exe locally, and store output files locally prior to rereading them into Colab?

Thanks!

Saul Montoya

unread,
Oct 12, 2020, 5:56:54 AM10/12/20
to mod...@googlegroups.com
I propose a work around:
Get a fix ip
Set your jupyter notebook accesible to remote access
Use the compiled versions of modflow for linux

You will get more resources, more control, more independence

Saul Montoya M.Sc.
Director

Dir: Caminos del Inca 288 dpto 302, Surco, Lima 33  |  Tel.: (511) 4491922  | Cel: Nuevo! (51) 984 115 861  |  Web: gidahatari.com



--
You received this message because you are subscribed to the Google Groups "MODFLOW Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modflow+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modflow/7547c463-43e3-4baa-99f2-9563448f96fen%40googlegroups.com.

Chris Russoniello

unread,
Oct 20, 2020, 12:18:55 AM10/20/20
to MODFLOW Users Group
Thanks Saul,

It's not surprising that you would have useful ideas. I've been enjoying your online workflows.

This might be a useful alternate workaround, but I'll need to see if I can figure this out with our network firewalls and such. My goal is to develop a workflow that students can easily run without installing much (preferably with no local install) on their local machines.

-Chris

Saul Montoya

unread,
Oct 23, 2020, 12:56:14 AM10/23/20
to mod...@googlegroups.com
Hi Chris

You can setup a Jupyterhub server:

The project is quite amazing, however it needs some special configuration for users and urls. It might be that I not smart enough but I have spent like 5 hours and I still cant make it work on Docker.

Saul

Saul Montoya M.Sc.
Director

Dir: Caminos del Inca 288 dpto 302, Surco, Lima 33  |  Tel.: (511) 4491922  | Cel: Nuevo! (51) 984 115 861  |  Web: gidahatari.com


Mattijn van Hoek

unread,
Nov 26, 2020, 11:36:39 PM11/26/20
to MODFLOW Users Group
Dear Chris and others,

I succeed in doing this! See the following Colab Notebook with compilation of MF2005, MT3D-USGS and running both through FloPy all within a Colab Notebook:

Regards,
Mattijn

Chris Russoniello

unread,
Dec 9, 2020, 12:33:46 AM12/9/20
to MODFLOW Users Group
Mattjin,

This is awesome! Kudos! I will be leaning on this for my next modeling course.

Thanks for sharing!

-Chris

Ed Rhodes

unread,
Sep 7, 2022, 11:36:58 PM9/7/22
to MODFLOW Users Group
Mattijn,

This is really cool! Thank you for sharing. I am new to Python (been learning over the summer). It looks like that script is pulling the modflow version straight from the USGS website. do you know if there is anyone to run it on a local file? I am using a modified version of NWT and would like to be able to use it in Colab.

Cheers!

-Ed

jonghyun....@gmail.com

unread,
Oct 7, 2022, 12:08:06 AM10/7/22
to MODFLOW Users Group
Below is an example for mf6 and you can simply replace pymake.build_apps('mf6') with pymake.build_apps('mfnwt') for modflow-mwt. 


If you need to modify the original code, compile first with pymake.build_apps('mfnwt', clean=False), which will keep the downloaded/unzipped source code, and copy all compiling commands from the screen (e.g..,, gfortran -O2 ...). Once the original code compilation is completed, you check the source code directory (./temp/modflow-nwt/src/), modify the code, and compile again with the copied compiling commands. 

Best,
Harry 

Jonghyun Harry Lee, Ph.D.
Associate Professor
Department of Civil and Environmental Engineering 
Water Resources Research Center 
University of Hawai‘i at Mānoa

Ed Rhodes

unread,
Oct 7, 2022, 11:12:42 AM10/7/22
to MODFLOW Users Group
Dr Lee, 

Amazing, thank you so much!

Cheers,

-Ed

Reply all
Reply to author
Forward
0 new messages