Debian Codegraph @

raster/r.solute.transport/seguin_verify_well.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Shellscript to verify r.solute.transport calculation, this calculation is based on
3 # the example 2.1 and 2.2 at page 181 of the following book:
4 # title = "Str{\"o}mungs und Transportmodellierung",
5 # author = "Lege, T. and Kolditz, O. and Zielke W.",
6 # publisher = "Springer",
7 # edition = "2. Auflage",
8 # year = "1996",
9 # series = "Handbuch zur Erkundung des Untergrundes von Deponien und Altlasten"
10 #
11
12 import grass.script as gs
13
14 # Overwrite existing maps
15 gs.run_command("g.gisenv", set="OVERWRITE=1")
16
17 gs.message(_("Set the region"))
18
19 # The area is 2000m x 1000m with a cell size of 50m x 50m
20 gs.run_command("g.region", res=50, res3=50, t=25, b=0, n=1000, s=0, w=0, e=2000)
21
22 gs.message(_("Create all the input maps needed for groundwater flow computation"))
23
24 # Initial condition of the piezometric head, we have a huge gradient from 275m to 50m
25 # over a distance of 2000m
26 gs.run_command("r.mapcalc", expression="phead_1=if(col() == 1 , 275, 50)")
27 # Set the active cells and the dirichlet boundary condition
28 gs.run_command("r.mapcalc", expression="status_1=if(col() == 1 || col() == 40 , 2, 1)")
29 # We have a single well with a small influent pumping rate
30 gs.run_command(
31 "r.mapcalc", expression="well_1=if((row() == 10 && col() == 10), 0.000002818287, 0)"
32 )
33 # The hydraulic conductivity
34 gs.run_command("r.mapcalc", expression="hydcond_1=0.0001")
35 # The recharge, well we have no recharge at all
36 gs.run_command("r.mapcalc", expression="recharge_1=0")
37 # We have a confined aquifer with a height of 25m
38 gs.run_command("r.mapcalc", expression="top_conf_1=25")
39 # Bottom of the aquifer starts at 0m
40 gs.run_command("r.mapcalc", expression="bottom_1=0")
41 # This is the standard porosity of sand aquifer
42 gs.run_command("r.mapcalc", expression="poros_1=0.17")
43 # The specific yield of a confined aquifer
44 gs.run_command("r.mapcalc", expression="syield_1=0.0001")
45 gs.run_command("r.mapcalc", expression="null_1=0.0")
46
47 gs.message("First compute a steady state groundwater flow")
48
49 # Compute the steady state groundwater flow
50 gs.run_command(
51 "r.gwflow",
52 solver="cg",
53 top="top_conf_1",
54 bottom="bottom_1",
55 phead="phead_1",
56 status="status_1",
57 hc_x="hydcond_1",
58 hc_y="hydcond_1",
59 q="well_1",
60 s="syield_1",
61 recharge="recharge_1",
62 output="gwresult_conf_1",
63 dt=8640000000000,
64 type="confined",
65 )
66
67 gs.message(_("generate the transport data"))
68
69 # The initial concentration is zero
70 gs.run_command("r.mapcalc", expression="c_1=if(col() == 10 && row() == 10 , 0.0, 0.0)")
71 # No inner sources or sinks (result of chemical reaction)
72 gs.run_command("r.mapcalc", expression="cs_1=0.0")
73 # The pollution is inserted by a well
74 gs.run_command(
75 "r.mapcalc",
76 expression="cin_1=if(col() == 10 && row() == 10 ," + str(0.2 / 86400) + ", 0.0)",
77 )
78 # We have a transfer boundary condition
79 gs.run_command("r.mapcalc", expression="tstatus_1=if(col() == 1 || col() == 40 , 3, 1)")
80 # No diffusion coefficient known for the solution
81 gs.run_command("r.mapcalc", expression="diff_1=0.0")
82 # Normal retardation
83 gs.run_command("r.mapcalc", expression="R_1=1.0")
84
85 # Longitudinal and transversal dispersivity length
86 AL = 50
87 AT = 5
88
89 # Compute the solute transport using the above defined dispersivity coefficients
90 # for a timestep of 250d
91 gs.run_command(
92 "r.solute.transport",
93 "c",
94 error=0.000000000000001,
95 maxit=1000,
96 solver="bicgstab",
97 top="top_conf_1",
98 bottom="bottom_1",
99 phead="gwresult_conf_1",
100 status="tstatus_1",
101 hc_x="hydcond_1",
102 hc_y="hydcond_1",
103 rd="R_1",
104 cs="cs_1",
105 q="well_1",
106 nf="poros_1",
107 output="stresult_conf_1",
108 dt=21600000,
109 diff_x="diff_1",
110 diff_y="diff_1",
111 cin="cin_1",
112 c="c_1",
113 al=AL,
114 at=AT,
115 )
116
117 # Get the maximum concentration
118 range = gs.parse_command("r.info", "r", map="stresult_conf_1")
119 # Normalize the result
120 gs.run_command(
121 "r.mapcalc",
122 expression="stresult_conf_1_norm = stresult_conf_1/" + str(range["max"]),
123 )
124 # Create contour lines range from 0.7 to 0.1 in 0.1 steps
125 gs.run_command(
126 "r.contour",
127 input="stresult_conf_1_norm",
128 output="stresult_conf_1_norm",
129 minlevel=0.1,
130 maxlevel=0.7,
131 step=0.1,
132 )
133
134 # The second computation uses different dispersivity lengths
135 AL = 10
136 AT = 1
137
138 # Compute the solute transport using the above defined dispersivity coefficients
139 # for a timestep of 250d
140 gs.run_command(
141 "r.solute.transport",
142 "c",
143 error=0.000000000000001,
144 maxit=1000,
145 solver="bicgstab",
146 top="top_conf_1",
147 bottom="bottom_1",
148 phead="gwresult_conf_1",
149 status="tstatus_1",
150 hc_x="hydcond_1",
151 hc_y="hydcond_1",
152 rd="R_1",
153 cs="cs_1",
154 q="well_1",
155 nf="poros_1",
156 output="stresult_conf_2",
157 dt=21600000,
158 diff_x="diff_1",
159 diff_y="diff_1",
160 cin="cin_1",
161 c="c_1",
162 al=AL,
163 at=AT,
164 )
165
166
167 # Get the maximum concentration
168 range = gs.parse_command("r.info", "r", map="stresult_conf_2")
169 # Normalize the result
170 gs.run_command(
171 "r.mapcalc",
172 expression="stresult_conf_2_norm = stresult_conf_2/" + str(range["max"]),
173 )
174 # Create contour lines range from 0.7 to 0.1 in 0.1 steps
175 gs.run_command(
176 "r.contour",
177 input="stresult_conf_2_norm",
178 output="stresult_conf_2_norm",
179 minlevel=0.1,
180 maxlevel=0.7,
181 step=0.1,
182 )