def lithology(self,
                      damage_opt=None,
                      width=None,
                      ko=None,
                      km=None,
                      Do=None,
                      Dm=None):

            if width == None:
                width = self.fault_width  # set to the instantiated width

            if damage_opt == None:
                damage_func = lambda x: np.zeros(x.size)
                km = 0
                Dm = 0

            # 2D profiles
            if damage_opt == 'boxcar':
                damage_func = lambda x: np.heaviside(x-fault_pos-width,1) - \
                                        np.heaviside(x-fault_pos+width,1)

            if damage_opt == 'heaviside_up':
                damage_func = lambda x: np.abs(
                    np.heaviside(x - fault_pos, 1) - 1)

            if damage_opt == 'heaviside_down':
                damage_func = lambda x: np.heaviside(x - fault_pos, 1)

            if damage_opt == 'exp':
                damage_func = lambda x: (
                    width / (abs(x - fault_pos) + width)
                )  # NEED TO DEFINE BUFF -> similar to c value in aftershocks

            def mk_dict(rmg, damage_func, ao, am):
                lith_ary = ao + (am - ao) * damage_func(rmg.node_y)
                damage_dict = dict(zip(rmg.node_y, lith_ary))
                return damage_dict

            attrs = {
                'K_sp': mk_dict(self.rmg, damage_func, ko, km),
                'D': mk_dict(self.rmg, damage_func, Do, Dm)
            }

            lith = Lithology(
                self.rmg,
                self.rmg.ones().ravel().reshape(1, len(
                    self.rmg.node_y)),  # note that this is a dummy thickness
                self.rmg.node_y.reshape(1, len(self.rmg.node_y)),
                attrs,
                rock_id=self.rmg.node_y)

            self.rmg['node']['topographic__elevation'] += 1.
            lith.run_one_step()
            #imshow_grid(self.rmg, 'K_sp', cmap='viridis', vmin=ko, vmax=km)
            return lith
Ejemplo n.º 2
0
def test_run_one_step_erodes_all_raises_error():
    """Test that eroding all material with the run one step method raises an error."""
    mg = RasterModelGrid(3, 3)
    z = mg.add_zeros("node", "topographic__elevation")
    thicknesses = [1, 2, 4, 1, 5]
    ids = [1, 2, 1, 2, 1]
    attrs = {"K_sp": {1: 0.001, 2: 0.0001}}
    lith = Lithology(mg, thicknesses, ids, attrs)
    z -= 30
    with pytest.raises(ValueError):
        lith.run_one_step()
Ejemplo n.º 3
0
def test_run_one_step_deposit_no_id_raises_error():
    """Test that giving the run one step method a deposit with no id raises an error."""
    mg = RasterModelGrid(3, 3)
    z = mg.add_zeros("node", "topographic__elevation")
    thicknesses = [1, 2, 4, 1, 5]
    ids = [1, 2, 1, 2, 1]
    attrs = {"K_sp": {1: 0.001, 2: 0.0001}}
    lith = Lithology(mg, thicknesses, ids, attrs)
    z += 1
    with pytest.raises(ValueError):
        lith.run_one_step()
Ejemplo n.º 4
0
def test_run_one_step_erodes_all_raises_error():
    """Test that eroding all material with the run one step method raises an error."""
    mg = RasterModelGrid((3, 3))
    z = mg.add_zeros("node", "topographic__elevation")
    thicknesses = [1, 2, 4, 1, 5]
    ids = [1, 2, 1, 2, 1]
    attrs = {"K_sp": {1: 0.001, 2: 0.0001}}
    lith = Lithology(mg, thicknesses, ids, attrs)
    z -= 30
    with pytest.raises(ValueError):
        lith.run_one_step()
Ejemplo n.º 5
0
def test_run_one_step_deposit_no_id_raises_error():
    """Test that giving the run one step method a deposit with no id raises an error."""
    mg = RasterModelGrid((3, 3))
    z = mg.add_zeros("node", "topographic__elevation")
    thicknesses = [1, 2, 4, 1, 5]
    ids = [1, 2, 1, 2, 1]
    attrs = {"K_sp": {1: 0.001, 2: 0.0001}}
    lith = Lithology(mg, thicknesses, ids, attrs)
    z += 1
    with pytest.raises(ValueError):
        lith.run_one_step()
Ejemplo n.º 6
0
thickness = [1, 1]

# instantiate the Lithology component
lith = Lithology(rmg, thickness, [1, 2], attrs)

# put in the damage zone a third of the way in the model
spatially_variable_rock_id = rmg.ones('node')

# Comment/Uncomment below to introduce a damage zone kdc!
spatially_variable_rock_id[(rmg.y_of_node > 2 * ymax / 5)
                           & (rmg.y_of_node < 3 * ymax / 5)] = 2

# grow the topography up (this is clearly dumb)
z += 1.
dz_ad = 0.
lith.run_one_step(dz_advection=dz_ad, rock_id=spatially_variable_rock_id)
imshow_grid(rmg, 'rock_type__id', cmap='viridis', vmin=0, vmax=3)

#  since we will not update z after this, the erodability parameters of the rock should not change
#  ...at least that is the idea

################################################################################
## Third, we now set parameters to control and build our landscape ############
################################################################################

# Erosion variables #
#K = 0.08 # value for the "erodability" of the landscape bedrock [kyr^-1]
m = 0.5  # exponent on drainage area [non dimensional]
n = 1  # exponent on river slope [non dimensional]
#D = 0.02 # Hillslope linear diffusivity [meters sqared per kiloyear]