Skip to content

Commit

Permalink
Updates tests to Landlab's new version
Browse files Browse the repository at this point in the history
Updates Landlab and check all tests.
  • Loading branch information
angelmons committed Sep 6, 2024
1 parent 056b2cd commit 284dde8
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 208 deletions.
139 changes: 69 additions & 70 deletions landlab/components/river_bed_dynamics/RiverBedDynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class property.
>>> qb_gsd_l15 = rbd._sed_transp__bedload_gsd_link[15]
>>> np.round(qb_gsd_l15, decimals=3)
array([ 0.475, 0.525])
array([0.475, 0.525])
Which in cummulative percentage is equivalent to
Expand All @@ -212,46 +212,46 @@ class property.
>>> qb_gsd_l = rbd._sed_transp__bedload_gsd_link
>>> np.round(qb_gsd_l, decimals=3)
array([[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0.475, 0.525],
[ 0.475, 0.525],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0.282, 0.718],
[ 0.475, 0.525],
[ 0.282, 0.718],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0.282, 0.718],
[ 0.282, 0.718],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0.282, 0.718],
[ 0.282, 0.718],
[ 0.282, 0.718],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0.282, 0.718],
[ 0.282, 0.718],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ],
[ 0. , 0. ]])
array([[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0.475, 0.525],
[0.475, 0.525],
[0. , 0. ],
[0. , 0. ],
[0.282, 0.718],
[0.475, 0.525],
[0.282, 0.718],
[0. , 0. ],
[0. , 0. ],
[0.282, 0.718],
[0.282, 0.718],
[0. , 0. ],
[0. , 0. ],
[0.282, 0.718],
[0.282, 0.718],
[0.282, 0.718],
[0. , 0. ],
[0. , 0. ],
[0.282, 0.718],
[0.282, 0.718],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ],
[0. , 0. ]])
Zeros indicate that there is no sediment transport of that grain size
at that location.
Expand All @@ -261,11 +261,11 @@ class property.
>>> z = grid.at_node["topographic__elevation"].reshape(grid.shape)
>>> np.round(z, decimals=3)
array([[ 1.07 , 1.06 , 1.007, 1.06 , 1.07 ],
[ 1.08 , 1.068, 1.037, 1.068, 1.08 ],
[ 1.09 , 1.08 , 1.068, 1.08 , 1.09 ],
[ 1.09 , 1.09 , 1.08 , 1.09 , 1.09 ],
[ 1.09 , 1.09 , 1.09 , 1.09 , 1.09 ]])
array([[1.07 , 1.06 , 1.007, 1.06 , 1.07 ],
[1.08 , 1.068, 1.037, 1.068, 1.08 ],
[1.09 , 1.08 , 1.068, 1.08 , 1.09 ],
[1.09 , 1.09 , 1.08 , 1.09 , 1.09 ],
[1.09 , 1.09 , 1.09 , 1.09 , 1.09 ]])
Let's take a look at bed load transport rate when we use the different bedload equations.
First, let's recover the original topography.
Expand Down Expand Up @@ -372,9 +372,9 @@ class property.
>>> qb_imposed = np.array([1, 2])
>>> rbd = RiverBedDynamics(grid, sed_transp__bedload_rate_fix_link=qb_imposed)
>>> rbd._sed_transp__bedload_rate_fix_link
array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0.])
>>> gsd_loc = np.array([1, 2])
>>> rbd = RiverBedDynamics(grid, bed_surf__gsd_loc_node=gsd_loc)
Expand Down Expand Up @@ -406,21 +406,20 @@ class property.
>>> vel_n_1 = np.array([1, 2])
>>> rbd = RiverBedDynamics(grid, surface_water__velocity_prev_time_link=vel_n_1)
>>> rbd._surface_water__velocity_prev_time_link
array([ 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25])
array([0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25])
For sed_transp__bedload_gsd_fix_link, for simplicity, we only show
links 0, 5, and 10
>>> qb_gsd_imposed = np.array([1, 2])
>>> rbd = RiverBedDynamics(grid, sed_transp__bedload_gsd_fix_link=qb_gsd_imposed)
>>> rbd._sed_transp__bedload_gsd_fix_link[[0, 5, 10], :]
array([[ 0., 0.],
[ 0., 0.],
[ 0., 0.]])
array([[0., 0.],
[0., 0.],
[0., 0.]])
In summary, in all these cases the wrong given value is override by default values.
But, if the size of the array is correct the specified condition is used.
Expand All @@ -429,7 +428,7 @@ class property.
>>> qb_imposed = np.full(grid.number_of_links, 1)
>>> rbd = RiverBedDynamics(grid, sed_transp__bedload_rate_fix_link=qb_imposed)
>>> rbd._sed_transp__bedload_rate_fix_link[[0, 5, 10]]
array([ 1., 1., 1.])
array([1., 1., 1.])
>>> gsd_loc = np.full(grid.number_of_nodes, 1)
>>> rbd = RiverBedDynamics(grid, bed_surf__gsd_loc_node=gsd_loc)
Expand Down Expand Up @@ -461,14 +460,14 @@ class property.
>>> vel_n_1 = np.full(grid.number_of_links, 1)
>>> rbd = RiverBedDynamics(grid, surface_water__velocity_prev_time_link=vel_n_1)
>>> rbd._surface_water__velocity_prev_time_link[[0, 5, 10]]
array([ 1., 1., 1.])
array([1., 1., 1.])
>>> qb_gsd_imposed = np.ones((grid.number_of_links, 2)) # 2 comes from gsd.shape[0]-1
>>> rbd = RiverBedDynamics(grid, sed_transp__bedload_gsd_fix_link=qb_gsd_imposed)
>>> rbd._sed_transp__bedload_gsd_fix_link[[0, 5, 10]]
array([[ 1., 1.],
[ 1., 1.],
[ 1., 1.]])
array([[1., 1.],
[1., 1.],
[1., 1.]])
Using the hydraulics radius is also possible. Let's compare the shear stress with and
without that option. First, without including the hydraulics radius.
Expand All @@ -490,6 +489,7 @@ class property.
So, there is an important difference between the two ways of calculating it.
"""

import numpy as np
import scipy.constants

Expand All @@ -508,7 +508,6 @@ class property.


class RiverBedDynamics(Component):

"""Predicts the evolution of a river bed.
Landlab component that predicts the evolution of a river bed
Expand Down Expand Up @@ -830,10 +829,10 @@ def __init__(
self._num_cycles_to_process_strat = num_cycles_to_process_strat

# Makes a copy of the original bed surface elevation and maps into links
self._grid["link"][
"topographic__elevation"
] = self._grid.map_mean_of_link_nodes_to_link(
self._grid["node"]["topographic__elevation"]
self._grid["link"]["topographic__elevation"] = (
self._grid.map_mean_of_link_nodes_to_link(
self._grid["node"]["topographic__elevation"]
)
)
self._topogr__elev_orig_node = self._grid["node"][
"topographic__elevation"
Expand Down Expand Up @@ -1175,9 +1174,9 @@ def update_bed_elevation(self):
z[self._out_id] = z0[self._out_id] + dz_outlet

# Now we map data into links to update Bed GSD
self._grid["link"][
"topographic__elevation"
] = self._grid.map_mean_of_link_nodes_to_link(z)
self._grid["link"]["topographic__elevation"] = (
self._grid.map_mean_of_link_nodes_to_link(z)
)
self._grid["node"]["topographic__elevation"] = z

def update_bed_surf_gsd(self):
Expand Down
20 changes: 10 additions & 10 deletions landlab/components/river_bed_dynamics/_bedload_eq_Parker_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,30 +131,30 @@ def strain_functions(phi_sgo):
>>> phi_sgo = np.array([0.1, 0.2, 0.3, 0.7639])
>>> (omega0, sigma0) = Parker1990.strain_functions(phi_sgo)
>>> omega0
array([ 1.011, 1.011, 1.011, 1.011])
array([1.011, 1.011, 1.011, 1.011])
>>> sigma0
array([ 0.8157, 0.8157, 0.8157, 0.8157])
array([0.8157, 0.8157, 0.8157, 0.8157])
range 2: (phi_sgo > 0.7639) & (phi_sgo < 231.2)
>>> phi_sgo = np.array([0.7639, 1, 100, 231.1])
>>> (omega0, sigma0) = Parker1990.strain_functions(phi_sgo)
>>> omega0
array([ 1.011 , 0.9997 , 0.45601387, 0.45409851])
>>> np.round(omega0,3)
array([1.011, 1. , 0.456, 0.454])
>>> sigma0
array([ 0.8157 , 0.8439 , 1.49812569, 1.49900013])
>>> np.round(sigma0,3)
array([0.816, 0.844, 1.498, 1.499])
range 3: phi_sgo >= 231.2
>>> phi_sgo = np.array([231.1, 1000, 2000, 2320])
>>> (omega0, sigma0) = Parker1990.strain_functions(phi_sgo)
>>> omega0
array([ 0.45409851, 0.45358472, 0.45291448, 0.4527 ])
>>> np.round(omega0,3)
array([0.454, 0.454, 0.453, 0.453])
>>> sigma0
array([ 1.49900013, 1.49936806, 1.4998468 , 1.5 ])
>>> np.round(sigma0,3)
array([1.499, 1.499, 1.5 , 1.5 ])
"""

Expand Down
Loading

0 comments on commit 284dde8

Please sign in to comment.