最简单的方法可能是创建模型的副本(通过更改 model_ws 或给它一个新名称),然后使用修改后的参数创建一个新的 BCF 包。确保将所有未更改的参数传递给新的 BCF 包。
# 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
也可以仅更改现有对象的参数。为此,将现有bcf.hy
对象替换为新Util3d
对象。注意:在这种情况下,它是 Util3d,但对于其他参数,它可能是 1D 或 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