| 1 | """Test to verify r.gwflow calculation, this calculation is based on
|
|---|
| 2 | the example at page 133 of the following book:
|
|---|
| 3 | author = "Kinzelbach, W. and Rausch, R.",
|
|---|
| 4 | title = "Grundwassermodellierung",
|
|---|
| 5 | publisher = "Gebr{\"u}der Borntraeger (Berlin, Stuttgart)",
|
|---|
| 6 | year = "1995"
|
|---|
| 7 |
|
|---|
| 8 | @author Soeren Gebbert
|
|---|
| 9 | """
|
|---|
| 10 | from grass.gunittest.case import TestCase
|
|---|
| 11 |
|
|---|
| 12 | class Validation7x7Grid(TestCase):
|
|---|
| 13 |
|
|---|
| 14 | @classmethod
|
|---|
| 15 | def setUpClass(cls):
|
|---|
| 16 | """Use temporary region settings"""
|
|---|
| 17 | cls.use_temp_region()
|
|---|
| 18 | cls.runModule("g.region", res=100, n=700, s=0, w=0, e=700)
|
|---|
| 19 |
|
|---|
| 20 | @classmethod
|
|---|
| 21 | def tearDownClass(cls):
|
|---|
| 22 | """!Remove the temporary region
|
|---|
| 23 | """
|
|---|
| 24 | cls.del_temp_region()
|
|---|
| 25 |
|
|---|
| 26 | def setUp(self):
|
|---|
| 27 | """Create input data for transient groundwater flow computation
|
|---|
| 28 | """
|
|---|
| 29 | self.runModule("r.mapcalc", expression="phead=50")
|
|---|
| 30 | self.runModule("r.mapcalc", expression="status=if(col() == 1 || col() == 7 , 2, 1)")
|
|---|
| 31 | self.runModule("r.mapcalc", expression="well=if((row() == 4 && col() == 4), -0.1, 0)")
|
|---|
| 32 | self.runModule("r.mapcalc", expression="hydcond=0.0005")
|
|---|
| 33 | self.runModule("r.mapcalc", expression="recharge=0")
|
|---|
| 34 | self.runModule("r.mapcalc", expression="top_conf=20")
|
|---|
| 35 | self.runModule("r.mapcalc", expression="bottom=0")
|
|---|
| 36 | self.runModule("r.mapcalc", expression="s=0.0001")
|
|---|
| 37 | self.runModule("r.mapcalc", expression="null=0.0")
|
|---|
| 38 |
|
|---|
| 39 | def test_transient(self):
|
|---|
| 40 | #First compute the groundwater flow after 500 seconds to have initial conditions
|
|---|
| 41 | self.assertModule("r.gwflow", flags="f", solver="cholesky", top="top_conf", bottom="bottom", phead="phead",\
|
|---|
| 42 | status="status", hc_x="hydcond", hc_y="hydcond", q="well", s="s",\
|
|---|
| 43 | recharge="recharge", output="gwresult_conf", dtime=500, type="confined", budget="water_budget", overwrite=True)
|
|---|
| 44 |
|
|---|
| 45 | # loop over the timesteps each 500 seconds
|
|---|
| 46 | for i in range(20):
|
|---|
| 47 | self.assertModule("r.gwflow", flags="f", solver="cholesky", top="top_conf", bottom="bottom", phead="gwresult_conf",\
|
|---|
| 48 | status="status", hc_x="hydcond", hc_y="hydcond", q="well", s="s",\
|
|---|
| 49 | recharge="recharge", output="gwresult_conf", dtime=500, type="confined", budget="water_budget", overwrite=True)
|
|---|
| 50 |
|
|---|
| 51 | # Output of r.univar
|
|---|
| 52 | univar_string="""n=49
|
|---|
| 53 | null_cells=0
|
|---|
| 54 | cells=49
|
|---|
| 55 | min=45.1219899394172
|
|---|
| 56 | max=50
|
|---|
| 57 | range=4.8780100605828
|
|---|
| 58 | mean=49.081632669812
|
|---|
| 59 | mean_of_abs=49.081632669812
|
|---|
| 60 | stddev=0.908558909200636
|
|---|
| 61 | variance=0.825479291487849
|
|---|
| 62 | coeff_var=1.85111794326975
|
|---|
| 63 | sum=2405.00000082079"""
|
|---|
| 64 |
|
|---|
| 65 | # Output of r.info, only a subset of the output is needed
|
|---|
| 66 | info_string="""north=700
|
|---|
| 67 | south=0
|
|---|
| 68 | east=700
|
|---|
| 69 | west=0
|
|---|
| 70 | nsres=100
|
|---|
| 71 | ewres=100
|
|---|
| 72 | rows=7
|
|---|
| 73 | cols=7
|
|---|
| 74 | cells=49
|
|---|
| 75 | datatype=DCELL
|
|---|
| 76 | ncats=0
|
|---|
| 77 | min=45.1219899394172
|
|---|
| 78 | max=50
|
|---|
| 79 | map=gwresult_conf"""
|
|---|
| 80 |
|
|---|
| 81 | self.assertRasterFitsUnivar(raster="gwresult_conf", reference=univar_string, precision=3)
|
|---|
| 82 | self.assertRasterFitsInfo(raster="gwresult_conf", reference=info_string, precision=3)
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | if __name__ == '__main__':
|
|---|
| 86 | from grass.gunittest.main import test
|
|---|
| 87 | test()
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|