def test_run_event(): """"trivial case of an event. An event with depth 2 fills the top 2 bins when bins have unit depth and can be filled 100% with water. Recharge is calculated on a 'floor' basis.""" sm = SchenkVadoseModel( num_bins=5, available_relative_saturation=1.0, porosity=1.0, ) sm.run_event(2.0) assert_equal(sm.sat_profile, [1.0, 1.0, 0.0, 0.0, 0.0]) assert_equal(sm.recharge_at_depth, [1.0, 0.0, 0.0, 0.0, 0.0])
def test_run_interevent_2(): """Edge case where interevent PET exceeds available saturation. In this case, the remaining saturation is drained.""" sm = SchenkVadoseModel( num_bins=5, available_relative_saturation=1.0, porosity=1.0, potential_evapotranspiration_rate=1.0, ) sm.sat_profile[:] = np.array([0.0, 0.0, 0.0, 0.0, 1.0]) sm.run_interevent(2.0) assert_equal(sm.sat_profile, [0.0, 0.0, 0.0, 0.0, 0.0])
def test_run_event_2(): """Slightly less trivial example of an event where there is already some inital nonuniform saturation. Ensure that the topmost available bins are filled.""" sm = SchenkVadoseModel( num_bins=5, available_relative_saturation=1.0, porosity=1.0, ) sm.sat_profile[:] = np.array([0.0, 1.0, 0.0, 0.0, 1.0]) sm.run_event(2.0) assert_equal(sm.sat_profile, [1.0, 1.0, 1.0, 0.0, 1.0]) assert_equal(sm.recharge_at_depth, [1.0, 1.0, 0.0, 0.0, 0.0])
def test_run_interevent(): """ Trivial case of an interevent. With unit PET rate, the top two bins are drained after 2 units of time when bins have unit depth and can be filled 100% with water. Note recharge_at_depth is not reset.""" sm = SchenkVadoseModel( num_bins=5, available_relative_saturation=1.0, porosity=1.0, potential_evapotranspiration_rate=1.0, ) sm.sat_profile[:] = np.array([1.0, 1.0, 1.0, 0.0, 0.0]) sm.run_interevent(2.0) assert_equal(sm.sat_profile, [0.0, 0.0, 1.0, 0.0, 0.0])
def test_run_event_3(): """Edge case where event depth is added to a profile that is already saturated. In this case, the profile should stay saturated, but the recharge should reflect the total amount. That is, a water table at any depth will recieve recharge.""" sm = SchenkVadoseModel( num_bins=5, available_relative_saturation=1.0, porosity=1.0, ) sm.sat_profile[:] = np.array([1.0, 1.0, 1.0, 1.0, 1.0]) sm.run_event(2.0) assert_equal(sm.sat_profile, [1.0, 1.0, 1.0, 1.0, 1.0]) assert_equal(sm.recharge_at_depth, [2.0, 2.0, 2.0, 2.0, 2.0])
def test_init_depth_profile(): """"Check depths and bin capacity. Depths correspond to the bottom of each bin. Bin capacity is porosity * bin depth * difference in relative sat.""" sm = SchenkVadoseModel(num_bins=5) assert_equal(sm.depths, [1.0, 2.0, 3.0, 4.0, 5.0]) assert_almost_equal(sm.bin_capacity, 0.02)
def test_generate_storm(): """Make sure seed is set when generating a storm event.""" sm1 = SchenkVadoseModel(random_seed=5) sm1.generate_storm() dr, tr, tb = sm1.Dr, sm1.Tr, sm1.Tb sm2 = SchenkVadoseModel(random_seed=5) sm2.generate_storm() assert_equal([dr, tr, tb], [sm2.Dr, sm2.Tr, sm2.Tb])
porosity=n, hydraulic_conductivity=ks, recharge_rate=0.0, vn_coefficient=0.5, courant_coefficient=0.5, ) pdr = PrecipitationDistribution(grid, mean_storm_duration=tr, mean_interstorm_duration=tb, mean_storm_depth=ds, total_t=Nt*(tr+tb)) pdr.seed_generator(seedval=1235) svm = SchenkVadoseModel( potential_evapotranspiration_rate=pet, available_relative_saturation=Srange, profile_depth=b, porosity=n, num_bins=Nz, ) hm = HydrologyEventVadoseStreamPower( grid, precip_generator=pdr, groundwater_model=gdp, vadose_model=svm, ) #print("components initialized") # run once to spin up model hm.run_step() #print("Spinup completed")