valid_calc_7x7.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. # Python script to verify r.gwflow calculation, this calculation is based on
  3. # the example at page 133 of the following book:
  4. # author = "Kinzelbach, W. and Rausch, R.",
  5. # title = "Grundwassermodellierung",
  6. # publisher = "Gebr{\"u}der Borntraeger (Berlin, Stuttgart)",
  7. # year = "1995"
  8. #
  9. import sys
  10. import os
  11. import grass.script as grass
  12. # Overwrite existing maps
  13. grass.run_command("g.gisenv", set="OVERWRITE=1")
  14. grass.message(_("Set the region"))
  15. # The area is 2000m x 1000m with a cell size of 25m x 25m
  16. grass.run_command("g.region", res=100, n=700, s=0, w=0, e=700)
  17. grass.run_command("r.mapcalc", expression="phead=50")
  18. grass.run_command("r.mapcalc", expression="status=if(col() == 1 || col() == 7 , 2, 1)")
  19. grass.run_command("r.mapcalc", expression="well=if((row() == 4 && col() == 4), -0.1, 0)")
  20. grass.run_command("r.mapcalc", expression="hydcond=0.0005")
  21. grass.run_command("r.mapcalc", expression="recharge=0")
  22. grass.run_command("r.mapcalc", expression="top_conf=20")
  23. grass.run_command("r.mapcalc", expression="bottom=0")
  24. grass.run_command("r.mapcalc", expression="s=0.0001")
  25. grass.run_command("r.mapcalc", expression="null=0.0")
  26. #First compute the groundwater flow
  27. grass.run_command("r.gwflow", "f", solver="cholesky", top="top_conf", bottom="bottom", phead="phead",\
  28. status="status", hc_x="hydcond", hc_y="hydcond", q="well", s="s",\
  29. recharge="recharge", output="gwresult_conf", dt=500, type="confined", budget="water_budget")
  30. count=500
  31. # loop over the timesteps
  32. for i in range(20):
  33. grass.run_command("r.gwflow", "f", solver="cholesky", top="top_conf", bottom="bottom", phead="gwresult_conf",\
  34. status="status", hc_x="hydcond", hc_y="hydcond", q="well", s="s",\
  35. recharge="recharge", output="gwresult_conf", dt=500, type="confined", budget="water_budget")
  36. count += 500