seguin_verify.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env python
  2. # Shellscript to verify r.solute.transport calculation, this calculation is based on
  3. # the example 1.1 and 1.2 at page 175 of the following book:
  4. # title = "Str{\"o}mungs und Transportmodellierung",
  5. # author = "Lege, T. and Kolditz, O. and Zielke W.",
  6. # publisher = "Springer (Berlin; Heidelberg; New York; Barcelona; Hongkong; London; Mailand; Paris; Singapur; Tokio)",
  7. # edition = "2. Auflage",
  8. # year = "1996",
  9. # series = "Handbuch zur Erkundung des Untergrundes von Deponien und Altlasten"
  10. #
  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 50m x 50m
  16. grass.run_command("g.region", res=50, res3=50, t=25, b=0, n=1000, s=0, w=0, e=2000)
  17. grass.message(_("Create all the input maps needed for groundwater flow computation"))
  18. # Initial condition of the piezometric head, we have a huge gradient from 275m to 50m
  19. # over a distance of 2000m
  20. grass.run_command("r.mapcalc", expression="phead_1=if(col() == 1 , 275, 50)")
  21. # Set the active cells and the dirichlet boundary condition, the first and the last cells a dirichlet
  22. grass.run_command("r.mapcalc", expression="status_1=if(col() == 1 || col() == 40 , 2, 1)")
  23. # We have a no wells
  24. grass.run_command("r.mapcalc", expression="well_1=0")
  25. # The hydraulic conductivity is 0.0001 m/s
  26. grass.run_command("r.mapcalc", expression="hydcond_1=0.0001")
  27. # The recharge, well we have no recharge at all
  28. grass.run_command("r.mapcalc", expression="recharge_1=0")
  29. # We have a confined aquifer with a height of 25m
  30. grass.run_command("r.mapcalc", expression="top_conf_1=25")
  31. # Bottom of the aquifer starts at 0m
  32. grass.run_command("r.mapcalc", expression="bottom_1=0")
  33. # This porosity of sand aquifer is 0.17 in example 1.1
  34. grass.run_command("r.mapcalc", expression="poros_1=0.17")
  35. # The specific yield of a confined aquifer
  36. grass.run_command("r.mapcalc", expression="syield_1=0.0001")
  37. grass.run_command("r.mapcalc", expression="null_1=0.0")
  38. grass.message("First compute a steady state groundwater flow with a mean velocity of 5.88 m/d or 6.8*10^5m/s")
  39. # Compute the steady state groundwater flow
  40. grass.run_command("r.gwflow", solver="cg", top="top_conf_1", bottom="bottom_1", phead="phead_1",\
  41. status="status_1", hc_x="hydcond_1", hc_y="hydcond_1", \
  42. q="well_1", s="syield_1", recharge="recharge_1", output="gwresult_conf_1",\
  43. dt=8640000000000, type="confined")
  44. grass.message(_("generate the transport data"))
  45. # The initial concentration is zero
  46. grass.run_command("r.mapcalc", expression="c_1=if(col() == 10 && row() == 10 , 0.0, 0.0)")
  47. # One inner sources (result of chemical reaction)
  48. grass.run_command("r.mapcalc", expression="cs_1=if(col() == 10 && row() == 10 , 0.0013888, 0.0)")
  49. # No pollution by well
  50. grass.run_command("r.mapcalc", expression="cin_1=0.0")
  51. # We have a transfer boundary condition
  52. grass.run_command("r.mapcalc", expression="tstatus_1=if(col() == 1 || col() == 40 , 3, 1)")
  53. # No diffusion coefficient known for the solution
  54. grass.run_command("r.mapcalc", expression="diff_1=0.0")
  55. # Normal retardation
  56. grass.run_command("r.mapcalc", expression="R_1=1.0")
  57. # Longitudinal and transversal dispersivity length al = 100m, at = 10m
  58. AL=100
  59. AT=10
  60. # Compute the solute transport using the above defined dispersivity coefficients for a timestep of 1000d
  61. grass.run_command("r.solute.transport", "c", error=0.000000000000001, maxit=1000, solver="bicgstab",\
  62. top="top_conf_1", bottom="bottom_1", phead="gwresult_conf_1", status="tstatus_1", hc_x="hydcond_1",\
  63. hc_y="hydcond_1", rd="R_1", cs="cs_1", q="well_1", nf="poros_1", output="stresult_conf_1", dt=86400000,\
  64. diff_x="diff_1", diff_y="diff_1", cin="cin_1", c="c_1", al=AL, at=AT, vx="stresult_conf_vel_1_x", vy="stresult_conf_vel_1_y")
  65. # Get the maximum concentration
  66. range = grass.parse_command("r.info", "r", map="stresult_conf_1")
  67. # Normalize the result
  68. grass.run_command("r.mapcalc", expression="stresult_conf_1_norm = stresult_conf_1/" + str(range["max"]))
  69. #Create contour lines range from 0.7 to 0.1 in 0.1 steps
  70. grass.run_command("r.contour", input="stresult_conf_1_norm", output="stresult_conf_1_norm", minlevel=0.1, maxlevel=0.7, step=0.1)
  71. # The second computation uses different porosity for higher groundwater velocity
  72. # Used to compute a lower velocity, so the mean velocity is about 1 m/d or 1.15*10^-5 m/s
  73. grass.run_command("r.mapcalc", expression="poros_2=1")
  74. # Compute the solute transport using the above defined dispersivity coefficients for a timestep of 1000d
  75. grass.run_command("r.solute.transport", "c", error=0.000000000000001, maxit=1000, solver="bicgstab",\
  76. top="top_conf_1", bottom="bottom_1", phead="gwresult_conf_1", status="tstatus_1", hc_x="hydcond_1",\
  77. hc_y="hydcond_1", rd="R_1", cs="cs_1", q="well_1", nf="poros_2", output="stresult_conf_2", dt=86400000,\
  78. diff_x="diff_1", diff_y="diff_1", cin="cin_1", c="c_1", al=AL, at=AT, vx="stresult_conf_vel_2_x", vy="stresult_conf_vel_2_y")
  79. # Get the maximum concentration
  80. range = grass.parse_command("r.info", "r", map="stresult_conf_2")
  81. # Normalize the result
  82. grass.run_command("r.mapcalc", expression="stresult_conf_2_norm = stresult_conf_2/" + str(range["max"]))
  83. #Create contour lines range from 0.7 to 0.1 in 0.1 steps
  84. grass.run_command("r.contour", input="stresult_conf_2_norm", output="stresult_conf_2_norm", minlevel=0.1, maxlevel=0.7, step=0.1)