0

I have an existing MODFLOW2005 model that was created in Processing Modflow gui. I would like to import this model into flopy to be able to conduct a sensivitiy analysis on model parameters, something that I believe should be much quicker using flopy.

I can load the existing modflow model using:

ml = flopy.modflow.Modflow.load("modelnamw.nam", model_ws=model_ws,verbose=True,check=False)

And can re-name the model to create a new output using:

ml.name = 'New model'

ml.write_input()

Is there a way I can leave the entire model as is but just change the hydraulic conductivity (hy) parameter (leaving rest of bcf input as is)?

Thank you

Under2
  • 23
  • 3

1 Answers1

3

The easiest method is probably to create a copy of the model (by changing the model_ws or giving it a new name), and then create a new BCF package with the modified parameters. Be sure to pass all the parameters that are unchanged to the new BCF package.

# get the BCF package
bcf = ml.get_package("BCF6")  

# new hy
new_hy = 2.

# don't forget to pass all the unchanged parameters from the old BCF
new_bcf = flopy.modflow.ModflowBcf(ml, laycon=bcf.laycon, hy=new_hy, vcont=bcf.vcont) 

new_bcf.write_file()  # write file
ml.run_model()  # run model with new BCF

Changing only the parameter on the existing object is also possible. To do that replace the existing bcf.hy object with a new Util3d object. Note: in this case it's a Util3d but for other parameters it might be 1D or 2D.

# get the BCF package
bcf = ml.get_package("BCF6")

# create new util3d object
new_hy_util3d = flopy.utils.Util3d(ml, bcf.hy.array.shape, np.float32, new_hy, "hy")

# replace the old hy with the new object
bcf.hy= new_hy_util3d  

bcf.write_file()  # write file
ml.run_model()  # run model with new hy