def test_parabolic_bed(self): models = [KarthausModel, FluxBasedModel] flss = [dummy_constant_bed(), dummy_parabolic_bed()] lens = [] surface_h = [] volume = [] widths = [] yrs = np.arange(1, 700, 2) for model, fls in zip(models, flss): mb = LinearMassBalance(2800.) model = model(fls, mb_model=mb, glen_a=self.glen_a, fixed_dt=10 * SEC_IN_DAY) length = yrs * 0. vol = yrs * 0. for i, y in enumerate(yrs): model.run_until(y) assert model.yr == y length[i] = fls[-1].length_m vol[i] = fls[-1].volume_km3 lens.append(length) volume.append(vol) widths.append(fls[-1].widths_m.copy()) surface_h.append(fls[-1].surface_h.copy()) np.testing.assert_allclose(lens[0][-1], lens[1][-1], atol=1300) np.testing.assert_allclose(volume[0][-1], volume[1][-1], atol=1e-2) if do_plot: # pragma: no cover plt.plot(lens[0], 'r') plt.plot(lens[1], 'b') plt.show() plt.plot(volume[0], 'r') plt.plot(volume[1], 'b') plt.show() plt.plot(fls[-1].bed_h, 'k') plt.plot(surface_h[0], 'r') plt.plot(surface_h[1], 'b') plt.show() plt.plot(widths[0], 'r') plt.plot(widths[1], 'b') plt.show()
def test_parabolic_bed(self): models = [KarthausModel, FluxBasedModel] flss = [dummy_constant_bed(), dummy_parabolic_bed()] lens = [] surface_h = [] volume = [] widths = [] yrs = np.arange(1, 700, 2) for model, fls in zip(models, flss): mb = LinearMassBalance(2800.) model = model(fls, mb_model=mb, glen_a=self.glen_a, fixed_dt=10 * SEC_IN_DAY) length = yrs * 0. vol = yrs * 0. for i, y in enumerate(yrs): model.run_until(y) length[i] = fls[-1].length_m vol[i] = fls[-1].volume_km3 lens.append(length) volume.append(vol) widths.append(fls[-1].widths_m.copy()) surface_h.append(fls[-1].surface_h.copy()) np.testing.assert_allclose(lens[0][-1], lens[1][-1], atol=1300) np.testing.assert_allclose(volume[0][-1], volume[1][-1], atol=1e-2) if do_plot: # pragma: no cover plt.plot(lens[0], 'r') plt.plot(lens[1], 'b') plt.show() plt.plot(volume[0], 'r') plt.plot(volume[1], 'b') plt.show() plt.plot(fls[-1].bed_h, 'k') plt.plot(surface_h[0], 'r') plt.plot(surface_h[1], 'b') plt.show() plt.plot(widths[0], 'r') plt.plot(widths[1], 'b') plt.show()