Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged two PRs and added make_html.py #71

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3d38504
separated out code to compute trajectories and use to plot red/blue s…
rjleveque Apr 23, 2017
ddd8257
fix exact_solvers/traffic_LWR.py to use new trajectories code.
rjleveque Apr 24, 2017
bb9b10d
Initial effort at compiling book.
ketch Apr 24, 2017
863239d
Use report template and update script name.
ketch Apr 24, 2017
ac60084
Add 5 more chapters to book.
ketch Apr 24, 2017
a718c89
Merge branch 'master' into bookform
ketch Apr 24, 2017
ef59ba4
Remove stray comma from merge.
ketch Apr 24, 2017
0729c6b
Run pdflatex one more time for citations.
ketch Apr 24, 2017
660ed53
New Introduction.ipynb from old Prologue notebooks, with SW stripe ex…
rjleveque Apr 24, 2017
b4b0a19
Minor cleanup of stripe plotting code.
ketch Apr 25, 2017
decc0ef
Add acoustics phase plane demo.
ketch Apr 25, 2017
65f9b99
no reload in Python 3
ketch Apr 25, 2017
4e62f82
Use t=0.2 instead of t=0 for static widget output.
ketch Apr 25, 2017
eadfc63
Improved presentation in Shallow_water.ipynb.
ketch Apr 27, 2017
8bd584f
Add Preface and fix some issues with bookbook.
ketch Apr 30, 2017
b7ea741
Merge branch 'master' into bookform
ketch Apr 30, 2017
0d30c94
Apply SIAM book formatting to pdf.
ketch Apr 30, 2017
e63f58d
change 'time' to 't' and initialize to 0 in Introduction
rjleveque May 1, 2017
345c798
First pass at utils/jsanimate_widgets.py, illustrated in Introduction
rjleveque May 1, 2017
547bfd8
rjleveque version for debugging bookbook
rjleveque May 4, 2017
56d97f8
Add a bit to Introduction
rjleveque May 6, 2017
078387d
Merge branch 'master' into plot_red_blue_stripes
rjleveque May 6, 2017
442fde2
Add shallow water javascript to Introduction
rjleveque May 6, 2017
66a614d
first pass at script to convert all notebooks to html for a webpage
rjleveque May 6, 2017
9b22312
fix import statements for interact
rjleveque May 6, 2017
4368d3a
Merge branch 'bookform' into make_html_test and fixed conflicting cha…
rjleveque May 6, 2017
e5c1a08
add Introduction to make_chapters.py
rjleveque May 6, 2017
f135c16
revert change needed only by rjleveque due to python3 path issue
rjleveque May 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Advection.ipynb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Advection"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
Expand Down
34 changes: 28 additions & 6 deletions Euler_approximate_solvers.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Approximate solvers for the Euler equations of gas dynamics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Note: this notebook is currently a placeholder for Part II of the book, in which the concepts behind approximate solvers will be introduced in a methodical way. The present notebook is here simply to show the facility with which different solvers may be compared and understood using the tools available in this book.*"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -15,28 +29,36 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In the [Part I](Euler_equations.ipynb) we studied the Riemann problem for Euler equations of inviscid, compressible fluid flow . As we saw, the exact solution of the Riemann problem is computationally expensive, since it requires solving a set of nonlinear algebraic equations. In the context of finite volume methods, the detailed structure of the Riemann solution is almost immediately discarded -- only its impact on the neighboring cell averages is used. So it makes sense to consider whether we can approximate the solution with less computation. In this chapter, we investigate approximate solvers for the Euler equations."
"In [Part I](Euler_equations.ipynb) we studied the Riemann problem for Euler equations of inviscid, compressible fluid flow . As we saw, the exact solution of the Riemann problem is computationally expensive, since it requires solving a set of nonlinear algebraic equations. In the context of finite volume methods, the detailed structure of the Riemann solution is almost immediately discarded -- only its impact on the neighboring cell averages is used. So it makes sense to consider whether we can approximate the solution with less computation. In this chapter, we investigate approximate solvers for the Euler equations."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"tags": [
"hide"
]
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_format = 'svg'\n",
"import matplotlib as mpl\n",
"mpl.rcParams['font.size'] = 8\n",
"figsize =(8,4)\n",
"mpl.rcParams['figure.figsize'] = figsize\n",
"\n",
"import numpy as np\n",
"from exact_solvers import Euler\n",
"from clawpack import riemann\n",
"from utils import riemann_tools\n",
"import matplotlib.pyplot as plt\n",
"from collections import namedtuple\n",
"from ipywidgets import interact\n",
"from ipywidgets import widgets\n",
"from ipywidgets import interact # for interactive widgets\n",
"import matplotlib\n",
"matplotlib.rcParams.update({'font.size': 12})\n",
"Primitive_State = namedtuple('State', Euler.primitive_variables)\n",
"gamma = 1.4\n",
"problem_data = {}\n",
Expand Down Expand Up @@ -74,7 +96,7 @@
"print(\"HLL solver solution to Euler equations:\")\n",
"states_hll, s_hll, hll_eval = riemann_tools.riemann_solution(solver,left_state,right_state,\n",
" problem_data=problem_data,verbose=True)\n",
"fig, ax = plt.subplots(1,3,figsize=(16,4))\n",
"fig, ax = plt.subplots(1,3,figsize=figsize)\n",
"riemann_tools.plot_phase(states_hll,0,1,ax[0])\n",
"riemann_tools.plot_phase(states_hll,0,2,ax[1])\n",
"riemann_tools.plot_phase(states_hll,1,2,ax[2])\n",
Expand Down Expand Up @@ -122,7 +144,7 @@
"print(\"Roe solver solution to Euler equations:\")\n",
"states, s, roe_eval = riemann_tools.riemann_solution(solver,left_state,right_state,\n",
" problem_data=problem_data,verbose=True)\n",
"fig, ax = plt.subplots(1,2,figsize=(10,4))\n",
"fig, ax = plt.subplots(1,2,figsize=figsize)\n",
"riemann_tools.plot_phase(states,0,1,ax[0])\n",
"riemann_tools.plot_phase(states,0,2,ax[1])\n",
"riemann_tools.plot_phase_3d(states)"
Expand Down
180 changes: 163 additions & 17 deletions Euler_equations_TammannEOS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,20 @@
"middle state pressure $p_*$ that ensures that the velocity $u_*$ across the contact discontinuity is consistent. Since we know that the left state velocity $u_l$ should be connected by a rarefaction or shock to $u_*$, we write $u_*=u_l + [u]_1$, where $[u]_1$ is the jump of the velocity across the 1-wave. In a similar manner, we also \n",
"know the 3-wave should be a shock or rarefaction, so we write $u_*= u_r - [u]_3$. Therefore, it is useful to define\n",
"\n",
"\n",
"\\begin{align}\n",
" \\phi_l(p_*) = u_* = u_l - \\mathcal{F}_l(p_*), \\label{CDvel-1} \\\\\n",
" \\phi_r(p_*) = u_* = u_r + \\mathcal{F}_r(p_*). \\label{CDvel-2} \n",
"\\end{align}\n",
"\n",
"\n",
"where the value of $\\mathcal{F}_{l,r}(p_*) = -[u]_{1,3}$ depends on whether the wave in question is a shock or a rarefaction (signs were \n",
"chosen for notation consistency). As we expect these two equations yield the same contact discontinuity \n",
"velocity $u_*$, we have \n",
"\n",
"\n",
"\\begin{align}\n",
" \\Phi(p_*)= \\phi_r(p_*) - \\phi_l(p_*) = 0.\n",
" \\label{Phi} \n",
"\\end{align}\n",
"\n",
"\n",
"This nonlinear equation will yield the pressure $p_*$ that provides consistency between the type of waves (rarefactions or shocks), their speeds and the contact discontinuity velocity $u_*$. As we mentioned before, the shape of $\\phi_k(p_*)$ will depend on whether the states are connected by a shock wave or rarefaction. Once \n",
"the $p_*$ has been found, the contact discontinuity velocity can be found from the expressions just derived. However, it is not yet clear how to calculate the density or the speeds of the 1-wave \n",
"and 3-wave. It will become obvious how to obtain these quantities once we write the explicit equations for our system further below.\n",
Expand Down Expand Up @@ -220,7 +216,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"### Riemann invariants for rarefaction waves\n",
"\n",
"Riemann invariants are variables that remain constant through simple waves such as rarefactions. The Riemann invariants across \n",
Expand Down Expand Up @@ -298,13 +293,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"tags": [
"hide"
]
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"from ipywidgets import widgets\n",
"from ipywidgets import interact\n",
"from ipywidgets import widgets\n",
"import matplotlib.pyplot as plt\n",
"from exact_solvers import euler_tammann, interactive_pplanes\n",
"from utils import riemann_tools"
Expand All @@ -313,9 +310,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# Initial states [density, velocity, pressure]\n",
Expand All @@ -340,7 +335,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"nbdime-conflicts": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like some nbdime merge conflict stuff got included in this commit.

"local_diff": [
{
"key": "collapsed",
"op": "add",
"value": false
}
],
"remote_diff": [
{
"key": "collapsed",
"op": "add",
"value": true
}
]
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -375,7 +386,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"nbdime-conflicts": {
"local_diff": [
{
"key": "collapsed",
"op": "add",
"value": false
}
],
"remote_diff": [
{
"key": "collapsed",
"op": "add",
"value": true
}
]
}
},
"outputs": [],
"source": [
Expand All @@ -390,7 +417,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"nbdime-conflicts": {
"local_diff": [
{
"key": "collapsed",
"op": "add",
"value": false
}
],
"remote_diff": [
{
"key": "collapsed",
"op": "add",
"value": true
}
]
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -421,7 +464,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"nbdime-conflicts": {
"local_diff": [
{
"key": "collapsed",
"op": "add",
"value": false
}
],
"remote_diff": [
{
"key": "collapsed",
"op": "add",
"value": true
}
]
}
},
"outputs": [],
"source": [
Expand All @@ -445,7 +504,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"nbdime-conflicts": {
"local_diff": [
{
"key": "collapsed",
"op": "add",
"value": false
}
],
"remote_diff": [
{
"key": "collapsed",
"op": "add",
"value": true
}
]
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -473,7 +548,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"nbdime-conflicts": {
"local_diff": [
{
"key": "collapsed",
"op": "add",
"value": false
}
],
"remote_diff": [
{
"key": "collapsed",
"op": "add",
"value": true
}
]
}
},
"outputs": [],
"source": [
Expand All @@ -497,7 +588,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### *Test: Interactive pplane for ideal gas Euler eqs. "
"### Full solution\n",
"In order to get the full solution, we still need a couple more quantities. Equations (\\ref{RH-phis}) will yield the contact discontinuity speed $s_2=u_*$ in terms of $p_*$. We can also calculate $F_l$ and $F_r$ from (\\ref{Qk-f}), and we can substitute in (\\ref{RH-speeds}) to obtain the corresponding wave speeds. With this, we now provide the full solution of the Riemann problem. "
]
},
{
Expand All @@ -507,6 +599,60 @@
"collapsed": false
},
"outputs": [],
"source": [
"# %load exact_solvers/euler_tammann.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ql = [1.0, -3.0, 1.0]\n",
"qr = [1.0, 3.0, 1.0]\n",
"gamma = [1.4, 1.4]\n",
"pinf = [0.0, 0.0]\n",
"ex_states, ex_speeds, reval, wave_types, varsout = euler_tammann.exact_riemann_solution(ql ,qr, gamma, pinf, \n",
" varin = 'primitive', varout = 'conservative')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plot_function = riemann_tools.make_plot_function(ex_states, ex_speeds, reval, wave_types,\n",
" layout='vertical', variable_names=varsout)\n",
"interact(plot_function, t=widgets.FloatSlider(value=0.0,min=0,max=1.0));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### to be modified\n",
"Now we need to iterate this function using a Newton method, to find which value of $p_*$ yields $\\Phi(p_*)=0$\n",
"We just obtained the pressure and velocity middle states $p_*$ and $u_*$ that are continuous across the contact disconitnuity and the middle states for the density $\\rho_{*l}$ and $\\rho_{*r}$ have also been obtained from the function and saved as global variables. We also know the speed the left and right waves are traveling. We can now plot the solution to the Riemann problem. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### *Test: Interactive pplane for ideal gas Euler eqs. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Initial states [density, velocity, pressure]\n",
"ql = [1.0, -10.0, 100.0]\n",
Expand Down
Loading