def test_mixed_bed(self): models = [KarthausModel, FluxBasedModel] flss = [dummy_constant_bed(), dummy_mixed_bed()] lens = [] surface_h = [] volume = [] widths = [] yrs = np.arange(1, 700, 2) # yrs = np.arange(1, 100, 2) for model, fls in zip(models, flss): mb = LinearMassBalance(2800.) model = model(fls, mb_model=mb, fs=self.fs_old, glen_a=self.aglen_old, fixed_dt=14 * 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(volume[0][-1], volume[1][-1], atol=2e-2) if do_plot: # pragma: no cover plt.plot(lens[0], 'r', label='normal') plt.plot(lens[1], 'b', label='mixed') plt.legend() plt.show() plt.plot(volume[0], 'r', label='normal') plt.plot(volume[1], 'b', label='mixed') plt.legend() plt.show() plt.plot(fls[-1].bed_h, 'k') plt.plot(surface_h[0], 'r', label='normal') plt.plot(surface_h[1], 'b', label='mixed') plt.legend() plt.show() plt.plot(widths[0], 'r', label='normal') plt.plot(widths[1], 'b', label='mixed') plt.legend() plt.show()
def test_mixed_bed(self): models = [KarthausModel, FluxBasedModel] flss = [dummy_constant_bed(), dummy_mixed_bed()] lens = [] surface_h = [] volume = [] widths = [] yrs = np.arange(1, 700, 2) # yrs = np.arange(1, 100, 2) for model, fls in zip(models, flss): mb = LinearMassBalance(2800.) model = model(fls, mb_model=mb, fs=self.fs_old, glen_a=self.aglen_old, fixed_dt=14 * 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(volume[0][-1], volume[1][-1], atol=2e-2) if do_plot: # pragma: no cover plt.plot(lens[0], 'r', label='normal') plt.plot(lens[1], 'b', label='mixed') plt.legend() plt.show() plt.plot(volume[0], 'r', label='normal') plt.plot(volume[1], 'b', label='mixed') plt.legend() plt.show() plt.plot(fls[-1].bed_h, 'k') plt.plot(surface_h[0], 'r', label='normal') plt.plot(surface_h[1], 'b', label='mixed') plt.legend() plt.show() plt.plot(widths[0], 'r', label='normal') plt.plot(widths[1], 'b', label='mixed') plt.legend() plt.show()
def test_simple_flux_gate(self): mb = ScalarMassBalance() model = FluxBasedModel(dummy_constant_bed(), mb_model=mb, flux_gate_thickness=150, flux_gate_build_up=50) model.run_until(1000) assert_allclose(model.volume_m3, model.flux_gate_m3_since_y0) model = FluxBasedModel(dummy_mixed_bed(), mb_model=mb, flux_gate_thickness=150, flux_gate_build_up=50) model.run_until(1000) assert_allclose(model.volume_m3, model.flux_gate_m3_since_y0) # Make sure that we cover the types of beds beds = np.unique(model.fls[0].shape_str[model.fls[0].thick > 0]) assert len(beds) == 2 if do_plot: # pragma: no cover plt.plot(model.fls[-1].bed_h, 'k') plt.plot(model.fls[-1].surface_h, 'b') plt.show()