Exemplo n.º 1
0
    def test_change_variable_updated_bcs(self, tmp_path):
        p = utilities.yaml_from_dict(tmp_path, 'input.yaml')
        _delta = DeltaModel(input_file=p)

        # what is Qw0 before?
        assert _delta.Qw0 == 1250.0

        # change u0
        _delta.u0 = 2

        # nothing has happened to Qw0 yet
        assert _delta.u0 == 2
        assert _delta.Qw0 == 1250.0

        # now call to recreate, see what happened
        _delta.create_boundary_conditions()
        assert _delta.u0 == 2
        assert _delta.Qw0 == 2500.0
Exemplo n.º 2
0
    def test_setting_getting_influx_concentration(self, tmp_path):
        p = utilities.yaml_from_dict(tmp_path, 'input.yaml')
        _delta = DeltaModel(input_file=p)

        # mock the init methods
        _delta.create_boundary_conditions = mock.MagicMock()
        _delta.init_sediment_routers = mock.MagicMock()

        # check initials
        assert _delta.influx_sediment_concentration == 0.1

        # change and assert changed
        _delta.influx_sediment_concentration = 0.003
        assert _delta.C0_percent == 0.3

        # assert reinitializers called
        assert (_delta.create_boundary_conditions.called is True)
        assert (_delta.init_sediment_routers.called is True)
Exemplo n.º 3
0
    def test_setting_getting_flow_depth(self, tmp_path):
        p = utilities.yaml_from_dict(tmp_path, 'input.yaml')
        _delta = DeltaModel(input_file=p)

        # mock the init methods
        _delta.create_boundary_conditions = mock.MagicMock()
        _delta.init_sediment_routers = mock.MagicMock()

        # check initials
        assert _delta.channel_flow_depth == 5

        # change and assert changed
        _delta.channel_flow_depth = 2
        assert _delta.channel_flow_depth == 2
        assert _delta.channel_flow_depth == _delta.h0
        assert _delta.channel_flow_depth == _delta._h0

        # assert reinitializers called
        assert (_delta.create_boundary_conditions.called is True)
        assert (_delta.init_sediment_routers.called is True)
Exemplo n.º 4
0
    def test_setting_getting_channel_width(self, tmp_path):
        p = utilities.yaml_from_dict(tmp_path, 'input.yaml')
        _delta = DeltaModel(input_file=p)

        _delta.create_boundary_conditions = mock.MagicMock()
        _delta.init_sediment_routers = mock.MagicMock()

        # check initials
        assert _delta.channel_width == 250

        # change value
        #  the channel width is then changed internally with `N0`, according
        #  to the `create_boundary_conditions` so no change is actually made
        #  here.
        with pytest.warns(UserWarning):
            _delta.channel_width = 300
        assert _delta.channel_width == 250  # not changed!

        # assert reinitializers called
        assert (_delta.create_boundary_conditions.called is True)
        assert (_delta.init_sediment_routers.called is True)