forked from numerical-mooc/numerical-mooc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge solutions to master - phugoid 1 and 2
- Loading branch information
Showing
13 changed files
with
1,869 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
|
||
lessons/phugoid/.ipynb_checkpoints/01_01_Pendulum-checkpoint.ipynb | ||
lessons/phugoid/.ipynb_checkpoints/*checkpoint.ipynb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.ipynb_checkpoints |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Script to plot the flight path of the phugoid using Lanchester's model. | ||
# It uses the sign convention and formulae provided by Lanchester (1909). | ||
|
||
import numpy | ||
import matplotlib.pyplot as plt | ||
|
||
def radius_of_curvature(y, yt, C): | ||
"""Returns the radius of curvature of the flight path at any point. | ||
Parameters | ||
--------- | ||
y : float | ||
current depth below the reference horizontal line. | ||
yt : float | ||
initial depth below the reference horizontal line. | ||
C : float | ||
constant of integration. | ||
Returns | ||
------- | ||
radius : float | ||
radius of curvature. | ||
""" | ||
#return 2./(C*(1./y)**1.5 - 2./3./yt) | ||
return -1*yt / (1./3 - C/2.*(yt/y)**1.5) | ||
|
||
def rotate(x, y, xCenter, yCenter, angle): | ||
"""Returns the new position of the point. | ||
Parameters | ||
--------- | ||
x : float | ||
previous x-position of the point | ||
y : float | ||
previous y-position of the point. | ||
xCenter : float | ||
x-location of the center of rotation. | ||
yCenter : float | ||
y-location of the center of rotation. | ||
angle : float | ||
angle of rotation | ||
Returns | ||
------- | ||
xCenter_new : float | ||
new x-location of the center of rotation. | ||
yCenter_new : float | ||
new y-location of the center of rotation. | ||
""" | ||
dx = x - xCenter | ||
dy = y - yCenter | ||
xNew = dx*numpy.cos(angle) - dy*numpy.sin(angle) | ||
yNew = dx*numpy.sin(angle) + dy*numpy.cos(angle) | ||
return xCenter + xNew, yCenter + yNew | ||
|
||
def plot_flight_path(yt, y0, theta0): | ||
"""Plots the flight path. | ||
Parameters | ||
--------- | ||
yt : float | ||
trim height of the glider. | ||
y0 : float | ||
initial height of the glider. | ||
theta0 : float | ||
initial orientation of the glider. | ||
Returns | ||
------- | ||
None : None | ||
""" | ||
# arrays to store the coordinates of the flight path | ||
N = 1000 | ||
y = numpy.zeros(N) | ||
x = numpy.zeros(N) | ||
|
||
# set initial conditions | ||
y[0] = y0 | ||
x[0] = 0. | ||
theta = theta0 | ||
|
||
# calculate the constant C | ||
#C = numpy.sqrt(y[0])*(numpy.cos(theta) - y[0]/yt/3.) | ||
C = (numpy.cos(theta) - 1./3*y[0]/yt)*(y[0]/yt)**.5 | ||
|
||
# incremental distance along the flight path | ||
ds = 1 | ||
|
||
#obtain the curve coordinates | ||
for i in range(1,N): | ||
normal = numpy.array([numpy.cos(theta+numpy.pi/2.), numpy.sin(theta+numpy.pi/2.)]) | ||
R = radius_of_curvature(y[i-1], yt, C) | ||
center = numpy.array([x[i-1]+normal[0]*R, y[i-1]+normal[1]*R]) | ||
dtheta = ds/R | ||
x[i], y[i] = rotate(x[i-1], y[i-1], center[0], center[1], dtheta) | ||
theta = theta + dtheta | ||
|
||
# generate a plot | ||
plt.figure(figsize=(10,6)) | ||
plt.plot(x, -y, color = 'k', ls='-', lw=2.0, label="$z_t=\ %.1f,\\,z_1=\ %.1f,\\,\\theta_1=\ %.2f$" % (yt, y[0], theta0)) | ||
plt.axis('equal') | ||
plt.title("Flight path for $C$ = %.3f" % C, fontsize=18) | ||
plt.xlabel("$x$", fontsize=18) | ||
plt.ylabel("$z$", fontsize=18) | ||
plt.legend() | ||
plt.show() | ||
|
||
# End of File |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'> | ||
<link href='http://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'> | ||
<link href='http://fonts.googleapis.com/css?family=PT+Mono' rel='stylesheet' type='text/css'> | ||
<link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'> | ||
<link href='http://fonts.googleapis.com/css?family=Nixie+One' rel='stylesheet' type='text/css'> | ||
<style> | ||
|
||
@font-face { | ||
font-family: "Computer Modern"; | ||
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf'); | ||
} | ||
|
||
#notebook_panel { /* main background */ | ||
background: rgb(245,245,245); | ||
} | ||
|
||
div.cell { /* set cell width */ | ||
width: 750px; | ||
} | ||
|
||
div #notebook { /* centre the content */ | ||
background: #fff; /* white background for content */ | ||
width: 1000px; | ||
margin: auto; | ||
padding-left: 0em; | ||
} | ||
|
||
#notebook li { /* More space between bullet points */ | ||
margin-top:0.8em; | ||
} | ||
|
||
/* draw border around running cells */ | ||
div.cell.border-box-sizing.code_cell.running { | ||
border: 1px solid #111; | ||
} | ||
|
||
/* Put a solid color box around each cell and its output, visually linking them*/ | ||
div.cell.code_cell { | ||
background-color: rgb(256,256,256); | ||
border-radius: 0px; | ||
padding: 0.5em; | ||
margin-left:1em; | ||
margin-top: 1em; | ||
} | ||
|
||
div.text_cell_render{ | ||
font-family: 'Alegreya Sans' sans-serif; | ||
line-height: 140%; | ||
font-size: 125%; | ||
font-weight: 400; | ||
width:600px; | ||
margin-left:auto; | ||
margin-right:auto; | ||
} | ||
|
||
|
||
/* Formatting for header cells */ | ||
.text_cell_render h1 { | ||
font-family: 'Nixie One', serif; | ||
font-style:regular; | ||
font-weight: 400; | ||
font-size: 45pt; | ||
line-height: 100%; | ||
color: rgb(0,51,102); | ||
margin-bottom: 0.5em; | ||
margin-top: 0.5em; | ||
display: block; | ||
} | ||
.text_cell_render h2 { | ||
font-family: 'Nixie One', serif; | ||
font-weight: 400; | ||
font-size: 30pt; | ||
line-height: 100%; | ||
color: rgb(0,51,102); | ||
margin-bottom: 0.1em; | ||
margin-top: 0.3em; | ||
display: block; | ||
} | ||
|
||
.text_cell_render h3 { | ||
font-family: 'Nixie One', serif; | ||
margin-top:16px; | ||
font-size: 22pt; | ||
font-weight: 600; | ||
margin-bottom: 3px; | ||
font-style: regular; | ||
color: rgb(102,102,0); | ||
} | ||
|
||
.text_cell_render h4 { /*Use this for captions*/ | ||
font-family: 'Nixie One', serif; | ||
font-size: 14pt; | ||
text-align: center; | ||
margin-top: 0em; | ||
margin-bottom: 2em; | ||
font-style: regular; | ||
} | ||
|
||
.text_cell_render h5 { /*Use this for small titles*/ | ||
font-family: 'Nixie One', sans-serif; | ||
font-weight: 400; | ||
font-size: 16pt; | ||
color: rgb(163,0,0); | ||
font-style: italic; | ||
margin-bottom: .1em; | ||
margin-top: 0.8em; | ||
display: block; | ||
} | ||
|
||
.text_cell_render h6 { /*use this for copyright note*/ | ||
font-family: 'PT Mono', sans-serif; | ||
font-weight: 300; | ||
font-size: 9pt; | ||
line-height: 100%; | ||
color: grey; | ||
margin-bottom: 1px; | ||
margin-top: 1px; | ||
} | ||
|
||
.CodeMirror{ | ||
font-family: "PT Mono"; | ||
font-size: 90%; | ||
} | ||
|
||
</style> | ||
<script> | ||
MathJax.Hub.Config({ | ||
TeX: { | ||
extensions: ["AMSmath.js"], | ||
equationNumbers: { autoNumber: "AMS", useLabelIds: true} | ||
}, | ||
tex2jax: { | ||
inlineMath: [ ['$','$'], ["\\(","\\)"] ], | ||
displayMath: [ ['$$','$$'], ["\\[","\\]"] ] | ||
}, | ||
displayAlign: 'center', // Change this to 'center' to center equations. | ||
"HTML-CSS": { | ||
styles: {'.MathJax_Display': {"margin": 4}} | ||
} | ||
}); | ||
</script> |