| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
import grass.script as gs |
| 13 |
|
| 14 |
|
| 15 |
gs.run_command("g.gisenv", set="OVERWRITE=1") |
| 16 |
|
| 17 |
gs.message(_("Set the region")) |
| 18 |
|
| 19 |
|
| 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 |
|
| 25 |
|
| 26 |
gs.run_command("r.mapcalc", expression="phead_1=if(col() == 1 , 275, 50)") |
| 27 |
|
| 28 |
gs.run_command("r.mapcalc", expression="status_1=if(col() == 1 || col() == 40 , 2, 1)") |
| 29 |
|
| 30 |
gs.run_command( |
| 31 |
"r.mapcalc", expression="well_1=if((row() == 10 && col() == 10), 0.000002818287, 0)" |
| 32 |
) |
| 33 |
|
| 34 |
gs.run_command("r.mapcalc", expression="hydcond_1=0.0001") |
| 35 |
|
| 36 |
gs.run_command("r.mapcalc", expression="recharge_1=0") |
| 37 |
|
| 38 |
gs.run_command("r.mapcalc", expression="top_conf_1=25") |
| 39 |
|
| 40 |
gs.run_command("r.mapcalc", expression="bottom_1=0") |
| 41 |
|
| 42 |
gs.run_command("r.mapcalc", expression="poros_1=0.17") |
| 43 |
|
| 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 |
|
| 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 |
|
| 70 |
gs.run_command("r.mapcalc", expression="c_1=if(col() == 10 && row() == 10 , 0.0, 0.0)") |
| 71 |
|
| 72 |
gs.run_command("r.mapcalc", expression="cs_1=0.0") |
| 73 |
|
| 74 |
gs.run_command( |
| 75 |
"r.mapcalc", |
| 76 |
expression="cin_1=if(col() == 10 && row() == 10 ," + str(0.2 / 86400) + ", 0.0)", |
| 77 |
) |
| 78 |
|
| 79 |
gs.run_command("r.mapcalc", expression="tstatus_1=if(col() == 1 || col() == 40 , 3, 1)") |
| 80 |
|
| 81 |
gs.run_command("r.mapcalc", expression="diff_1=0.0") |
| 82 |
|
| 83 |
gs.run_command("r.mapcalc", expression="R_1=1.0") |
| 84 |
|
| 85 |
|
| 86 |
AL = 50 |
| 87 |
AT = 5 |
| 88 |
|
| 89 |
|
| 90 |
|
| 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 |
|
| 118 |
range = gs.parse_command("r.info", "r", map="stresult_conf_1") |
| 119 |
|
| 120 |
gs.run_command( |
| 121 |
"r.mapcalc", |
| 122 |
expression="stresult_conf_1_norm = stresult_conf_1/" + str(range["max"]), |
| 123 |
) |
| 124 |
|
| 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 |
|
| 135 |
AL = 10 |
| 136 |
AT = 1 |
| 137 |
|
| 138 |
|
| 139 |
|
| 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 |
|
| 168 |
range = gs.parse_command("r.info", "r", map="stresult_conf_2") |
| 169 |
|
| 170 |
gs.run_command( |
| 171 |
"r.mapcalc", |
| 172 |
expression="stresult_conf_2_norm = stresult_conf_2/" + str(range["max"]), |
| 173 |
) |
| 174 |
|
| 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 |
) |