Skip to content

Commit abce321

Browse files
committed
Added another example to lots_of_loads
1 parent 4144583 commit abce321

4 files changed

Lines changed: 389 additions & 207 deletions

File tree

fault_scarp/landlab-fault-scarp-unexpanded.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"cell_type": "code",
38-
"execution_count": null,
38+
"execution_count": 1,
3939
"metadata": {
4040
"collapsed": false
4141
},
@@ -53,7 +53,7 @@
5353
},
5454
{
5555
"cell_type": "code",
56-
"execution_count": null,
56+
"execution_count": 2,
5757
"metadata": {
5858
"collapsed": false
5959
},

flexure/lots_of_loads.ipynb

Lines changed: 71 additions & 146 deletions
Large diffs are not rendered by default.

flexure/lots_of_loads.py

Lines changed: 100 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,146 @@
11

2-
# coding: utf-8
3-
4-
# <a href="http://landlab.github.io"><img style="float: left" src="https://raw.githubusercontent.com/landlab/tutorials/master/landlab_header.png"></a>
5-
#
6-
72
# # Using the Landlab flexure component
83
#
9-
# <hr>
10-
# <small> For instructions on how to run an interactive iPython notebook, click here: <a href="https://github.com/landlab/tutorials/blob/master/README.md">https://github.com/landlab/tutorials/blob/master/README.md</a></small><br>
11-
# <small>For the unexpanded version to download and run, click here: <a href="http://nbviewer.jupyter.org/github/landlab/tutorials/blob/master/flexure/lots_of_loads_unexpanded.ipynb">http://nbviewer.jupyter.org/github/landlab/tutorials/blob/master/flexure/lots_of_loads_unexpanded.ipynb</a></small><br>
12-
# <small>For more Landlab tutorials, click here: <a href="https://github.com/landlab/landlab/wiki/Tutorials">https://github.com/landlab/landlab/wiki/Tutorials</a></small>
13-
# <hr>
14-
#
4+
155
# In this example we will:
166
# * create a Landlab component that solves the flexure equation
17-
# * apply a point loads all over the place
7+
# * apply randomly distributed point loads
188
# * run the component
199
# * plot some output
2010

21-
# A bit of magic so that we can plot within this notebook.
22-
23-
# In[1]:
2411

25-
# get_ipython().magic(u'pylab inline')
12+
import numpy as np
2613

2714

28-
# ## Create the component
15+
# ## Create the grid
2916
#
30-
# We are going to build a uniform rectilinear grid with a node spacing of 10 km in each direction on which we will solve the flexure equation.
17+
# We are going to build a uniform rectilinear grid with a node spacing of 10 km in the *y*-direction and 20 km in the *x*-direction on which we will solve the flexure equation.
18+
#
19+
# First we nee to import *RasterModelGrid*. We also import the Landlab plotting function *imshow_grid* to view the grids.
20+
3121

32-
# In[2]:
22+
from landlab import RasterModelGrid
23+
from landlab.plot.imshow import imshow_grid
3324

34-
(n_rows, n_cols) = (200, 400)
35-
(dy, dx) = (10e3, 10e3)
3625

26+
# Create a rectilinear grid with a spacing of 10 km between rows and 20 km between columns. The numbers of rows and columms are provided as a `tuple` of `(n_rows, n_cols)`, in the same manner as similar numpy functions. The spacing is also a `tuple`, `(dy, dx)`.
3727

38-
# In[3]:
3928

40-
from landlab import RasterModelGrid
41-
grid = RasterModelGrid((n_rows, n_cols), dx)
29+
grid = RasterModelGrid((200, 400), spacing=(10e3, 20e3))
30+
31+
32+
33+
grid.dy, grid.dx
4234

4335

44-
# Now we create the flexure component and tell it to use our newly-created grid.
36+
# ## Create the component
37+
38+
# Now we create the flexure component and tell it to use our newly-created grid. First, though, we'll examine the Flexure component a bit.
39+
4540

46-
# In[4]:
4741

4842
from landlab.components.flexure import Flexure
43+
44+
45+
# The Flexure component, as with most landlab components, will require our grid to have some data that it will use. We can get the names of these data fields with the `intput_var_names` attribute of the component *class*.
46+
47+
48+
49+
Flexure.input_var_names
50+
51+
52+
# We see that flexure uses just 1 data field: the change in lithospheric loading. landlab component classes can provide additional information about each of these fields. For instance, to the the units for a field, use the `var_units` method.
53+
54+
55+
56+
Flexure.var_units('lithosphere__overlying_pressure_increment')
57+
58+
59+
# To print a more detailed description of a field, use `var_help`.
60+
61+
62+
63+
Flexure.var_help('lithosphere__overlying_pressure_increment')
64+
65+
66+
# What about the data that `Flexure` provides? Use the `output_var_names` attribute.
67+
68+
69+
70+
Flexure.output_var_names
71+
72+
73+
74+
75+
Flexure.var_help('lithosphere_surface__elevation_increment')
76+
77+
78+
# Now that we understand the component a little more, create it using our grid.
79+
80+
81+
4982
flex = Flexure(grid, method='flexure')
5083

5184

5285
# ## Add some loading
53-
# We will add some loading at the center of the grid. For this component, the name of the variable that hold the applied loads is call, `lithosphere__overlying_pressure`. We add loads of random magnitude at every node of the grid.
86+
# We will add loads to the grid. As we saw above, for this component, the name of the variable that hold the applied loads is call, `lithosphere__overlying_pressure`. We add loads of random magnitude at every node of the grid.
5487

55-
# In[5]:
88+
5689

57-
loads = np.random.normal(1e9, 1e12, grid.number_of_nodes)
58-
grid.at_node['lithosphere__overlying_pressure_increment'][:] = loads
90+
load = np.random.normal(0, 100 * 2650. * 9.81, grid.number_of_nodes)
91+
grid.at_node['lithosphere__overlying_pressure_increment'] = load
5992

6093

61-
# In[6]:
94+
6295

63-
grid.imshow('node', 'lithosphere__overlying_pressure_increment', symmetric_cbar=True,
64-
cmap='spectral', show=True, shrink=.75)
96+
imshow_grid(grid, 'lithosphere__overlying_pressure_increment', symmetric_cbar=True,
97+
cmap='spectral', show=True)
6598

6699

67100
# ## Update the component to solve for deflection
68101
# If you have more than one processor on your machine you may want to use several of them.
69102

70-
# In[7]:
103+
71104

72105
flex.update(n_procs=4)
73106

74107

108+
# As we saw above, the flexure component creates an output field (`lithosphere_surface__elevation_increment`) that contains surface deflections for the applied loads.
109+
75110
# # Plot the output
76-
# The name of the variable that holds elevations is called `lithosphere__elevation`.
77111

78-
# In[8]:
112+
# We now plot these deflections with the `imshow` method, which is available to all landlab components.
79113

80-
grid.imshow('node', 'lithosphere_surface__elevation_increment', symmetric_cbar=True,
81-
cmap='spectral', show=True, shrink=.75)
114+
115+
116+
imshow_grid(grid, 'lithosphere_surface__elevation_increment', symmetric_cbar=True,
117+
cmap='spectral', show=True)
118+
119+
120+
# Maintain the same loading distribution but double the effective elastic thickness.
121+
122+
123+
124+
flex.eet *= 2.
125+
flex.update(n_procs=4)
126+
imshow_grid(grid, 'lithosphere_surface__elevation_increment', symmetric_cbar=True,
127+
cmap='spectral', show=True)
128+
129+
130+
# Now let's add a vertical rectangular load to the middle of the grid. We plot the load grid first to make sure we did this correctly.
131+
132+
133+
134+
load[np.where(np.logical_and(grid.node_x>3000000, grid.node_x<5000000))]= load[np.where(np.logical_and(grid.node_x>3000000, grid.node_x<5000000))]+1e7
135+
imshow_grid(grid, 'lithosphere__overlying_pressure_increment', symmetric_cbar=True,
136+
cmap='spectral', show=True)
137+
138+
139+
140+
141+
flex.update(n_procs=4)
142+
imshow_grid(grid, 'lithosphere_surface__elevation_increment', symmetric_cbar=True,
143+
cmap='spectral', show=True)
82144

83145

84146
# ### Click here for more <a href="https://github.com/landlab/landlab/wiki/Tutorials">Landlab tutorials</a>

0 commit comments

Comments
 (0)