Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nmm_2020_site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
nmm_2020_site
Commits
e5d7ddd3
Commit
e5d7ddd3
authored
5 years ago
by
Erik Strand
Browse files
Options
Downloads
Patches
Plain Diff
Start pset 6
parent
72893da0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
_code/pset_06/scripts/waves.py
+30
-0
30 additions, 0 deletions
_code/pset_06/scripts/waves.py
_psets/06.md
+193
-0
193 additions, 0 deletions
_psets/06.md
with
223 additions
and
0 deletions
_code/pset_06/scripts/waves.py
0 → 100644
+
30
−
0
View file @
e5d7ddd3
from
sympy
import
*
from
sympy.assumptions.assume
import
global_assumptions
x
=
Symbol
(
"
x
"
,
real
=
True
)
h
=
Symbol
(
"
h
"
,
real
=
True
,
positive
=
True
)
# not sure why I did this
def
linear_hats
():
n
=
5
A
=
zeros
(
5
,
5
)
for
i
in
range
(
0
,
n
):
if
i
-
1
>=
0
:
A
[
i
,
i
-
1
]
=
h
/
6
A
[
i
,
i
]
=
2
*
h
/
3
if
i
+
1
<
n
:
A
[
i
,
i
+
1
]
=
h
/
6
print
(
latex
(
A
))
B
=
zeros
(
5
,
5
)
for
i
in
range
(
0
,
n
):
if
i
-
1
>=
0
:
B
[
i
,
i
-
1
]
=
1
/
h
B
[
i
,
i
]
=
-
2
/
h
if
i
+
1
<
n
:
B
[
i
,
i
+
1
]
=
1
/
h
print
(
latex
(
B
))
if
__name__
==
"
__main__
"
:
linear_hats
()
This diff is collapsed.
Click to expand it.
_psets/06.md
0 → 100644
+
193
−
0
View file @
e5d7ddd3
---
title
:
Problem Set 5 (FEM)
---
## 1
{:.question}
Consider the damped wave equation
$$
\f
rac{
\p
artial^2 u}{
\p
artial t^2}
= v^2
\f
rac{
\p
artial^2 u}{
\p
artial x^2}
+
\g
amma
\f
rac{
\p
artial}{
\p
artial t}
\f
rac{
\p
artial^2 u}{
\p
artial x^2}
$$
{:.question}
Take the solution domain to be the interval [0, 1].
### (a)
{:.question}
Use the Galerkin method to find an approximating system of differential equations.
We will search for an approximate solution of the form
$$
u(x, t) =
\s
um_{i=1}^n a_i(t)
\v
arphi_i(x)
$$
(where $$n$$ is yet to be determined). From here on out I will just write $$a_i$$ and $$
\v
arphi_i$$; it
is understood that these are functions of time and space, respectively. Thus the damped wave
equation becomes
$$
\s
um_{i=1}^n
\l
eft(
\f
rac{d^2 a_i}{d t^2}
\v
arphi_i
-
v^2 a_i
\f
rac{d^2
\v
arphi_i}{d x^2}
-
\g
amma
\f
rac{d a_i}{d t}
\f
rac{d^2
\v
arphi_i}{d x^2}
\r
ight)
= 0
$$
For each basis function $$
\v
arphi_i$$, we construct a Galerkin constraint
$$
\b
egin{aligned}
0 &=
\i
nt_0^1
\s
um_{j=1}^n
\l
eft(
\f
rac{d^2 a_j}{d t^2}
\v
arphi_j
-
v^2 a_j
\f
rac{d^2
\v
arphi_j}{d x^2}
-
\g
amma
\f
rac{d a_j}{d t}
\f
rac{d^2
\v
arphi_j}{d x^2}
\r
ight)
\v
arphi_i dx
\\
&=
\s
um_{j=1}^n
\l
eft(
\f
rac{d^2 a_j}{d t^2}
\i
nt_0^1
\v
arphi_j
\v
arphi_i dx
-
\l
eft(v^2 a_j +
\g
amma
\f
rac{d a_j}{d t}
\r
ight)
\i
nt_0^1
\f
rac{d^2
\v
arphi_j}{d x^2}
\v
arphi_i dx
\r
ight)
\\
\e
nd{aligned}
$$
This may be written as
$$
\b
old{A}
\f
rac{d^2
\o
verrightharpoon{a}}{d t^2}
-
\g
amma
\b
old{B}
\f
rac{d
\o
verrightharpoon{a}}{d t}
-
v^2
\b
old{B}
\o
verrightharpoon{a}
= 0
$$
where
$$
\b
egin{aligned}
\b
old{A}_{i, j} &=
\i
nt_0^1
\v
arphi_i
\v
arphi_j dx
\\
\b
old{B}_{i, j} &=
\i
nt_0^1
\v
arphi_i
\f
rac{d^2
\v
arphi_j}{d x^2} dx
\\
&=
\l
eft[
\v
arphi_i
\f
rac{d
\v
arphi_j}{d x}
\r
ight]_ {0}^1
-
\i
nt_0^1
\f
rac{d
\v
arphi_i}{dx}
\f
rac{d
\v
arphi_j}{dx} dx
\\
\e
nd{aligned}
$$
This gives a system of second order linear homogeneous ODEs. Note that I integrated $$
\b
old{B}$$ by
parts in order to reduce the order of the highest order derivative of $$
\v
arphi_j$$ that appears.
This lets us use lower order basis functions.
### (b)
{:.question}
Evaluate the matrix coefficients for linear hat basis functions, using elements with a fixed size of
h.
I will assume both boundaries are fixed at zero. Thus it's fine if all hat functions are zero at
each boundary. So I will place $$n$$ hat functions evenly spaced at $$1/h,
\l
dots, n/h$$, where $$h
= 1/(n + 1)$$. Each hat ranges linearly from 0 to 1, then back down to zero. So for $$1
\l
eq i
\l
eq
n$$,
$$
\b
egin{aligned}
\v
arphi_i(x) &=
\b
egin{cases}
\L
arge{
\f
rac{x - (i - 1)h}{h}} &
\t
ext{ for } (i - 1)h < x
\l
eq ih
\\
\L
arge{
\f
rac{(i + 1)h - x}{h}} &
\t
ext{ for } ih < x < (i + 1)h
\\
0 &
\t
ext{ otherwise}
\e
nd{cases}
\\
\f
rac{d
\v
arphi_i(x)}{dx} &=
\b
egin{cases}
\L
arge{
\f
rac{1}{h}} &
\t
ext{ for } (i - 1)h < x
\l
eq ih
\\
\L
arge{
\f
rac{-1}{h}} &
\t
ext{ for } ih < x < (i + 1)h
\\
0 &
\t
ext{ otherwise}
\e
nd{cases}
\e
nd{aligned}
$$
First, let's compute $$
\b
old{A}$$. Since the hat functions only overlap their immediate neighbors,
the only nonzero elements will be those on the diagonal, and one off it.
First let's compute the diagonal elements. The dependence on $$i$$ drops out after a change of
variables.
$$
\b
egin{aligned}
\b
old{A}_{i, i} &=
\i
nt_{(i - 1)h}^{(i + 1)h}
\v
arphi_i(x)^2 dx
\\
&=
\i
nt_{(i - 1)h}^{ih}
\l
eft(
\f
rac{x - (i - 1)h}{h}
\r
ight)^2 dx
+
\i
nt_{ih}^{(i + 1)h}
\l
eft(
\f
rac{(i + 1)h - x}{h}
\r
ight)^2 dx
\\
&=
\i
nt_{0}^{h}
\l
eft(
\f
rac{x}{h}
\r
ight)^2 dx
+
\i
nt_{-h}^{0}
\l
eft(
\f
rac{-x}{h}
\r
ight)^2 dx
\\
&=
\f
rac{2}{h^2}
\i
nt_{0}^{h} x^2 dx
\\
&=
\f
rac{2h}{3}
\e
nd{aligned}
$$
Now we compute the off diagonal elements.
$$
\b
egin{aligned}
\b
old{A}_{i, i+1} &=
\i
nt_{ih}^{(i + 1)h}
\v
arphi_i(x)
\v
arphi_{i+1}(x) dx
\\
&=
\i
nt_{ih}^{(i + 1)h}
\l
eft(
\f
rac{(i + 1)h - x}{h}
\r
ight)
\l
eft(
\f
rac{x - ih}{h}
\r
ight) dx
\\
&=
\i
nt_{0}^{h}
\l
eft(
\f
rac{h - x}{h}
\r
ight)
\l
eft(
\f
rac{x}{h}
\r
ight) dx
\\
&=
\f
rac{1}{h^2}
\i
nt_{0}^{h}
\l
eft( hx - x^2
\r
ight) dx
\\
&=
\f
rac{1}{h^2}
\l
eft(
\f
rac{h^3}{2} -
\f
rac{h^3}{3}
\r
ight) dx
\\
&=
\f
rac{h}{6}
\e
nd{aligned}
$$
By symmetry, $$
\b
old{A}_{i, i+1} =
\b
old{A}_{i, i-1}$$. All other elements are zero.
Now we compute the diagonal elements of $$
\b
old{B}$$. The boundary term drops out since all
$$
\v
arphi_i$$ are zero at 0 and 1.
$$
\b
egin{aligned}
\b
old{B}_{i, i}
&=
\l
eft[
\v
arphi_i(x)
\f
rac{d
\v
arphi_i(x)}{d x}
\r
ight]_ {0}^1
-
\i
nt_0^1
\l
eft(
\f
rac{d
\v
arphi_i(x)}{dx}
\r
ight)^2 dx
\\
&= -
\i
nt_{(i-1)h}^{ih}
\l
eft(
\f
rac{1}{h}
\r
ight)^2 dx
-
\i
nt_{ih}^{(i+1)h}
\l
eft(
\f
rac{-1}{h}
\r
ight)^2 dx
\\
&= -
\f
rac{2}{h^2}
\i
nt_{0}^{h} dx
\\
&=
\f
rac{-2}{h}
\e
nd{aligned}
$$
Finally, the off diagonal elements.
$$
\b
egin{aligned}
\b
old{B}_{i, i + 1}
&=
\l
eft[
\v
arphi_i(x)
\f
rac{d
\v
arphi_i(x)}{d x}
\r
ight]_ {0}^1
-
\i
nt_0^1
\f
rac{d
\v
arphi_i(x)}{dx}
\f
rac{d
\v
arphi_{i + 1}(x)}{dx} dx
\\
&= -
\i
nt_{ih}^{(i+1)h}
\l
eft(
\f
rac{-1}{h}
\r
ight)
\l
eft(
\f
rac{1}{h}
\r
ight) dx
\\
&=
\f
rac{1}{h^2}
\i
nt_{0}^{h} dx
\\
&=
\f
rac{1}{h}
\e
nd{aligned}
$$
All other elements are zero.
### (c)
{:.question}
Now find the matrix coefficients for Hermite polynomial interpolation basis functions, once again
using elements with a fixed size of h. A symbolic math environment is useful for this problem.
## 2
{:.question}
Model the bending of a beam (equation 9.29) under an applied load. Use Hermite polynomial
interpolation, and boundary conditions fixing the displacement and slope at one end, and applying a
force at the other end.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment