A collaborative educational initiative in computational science and engineering.
mesnardo on master
Minor changes * [Module 2, Lesâ€¦ (compare)
labarba on format
Corrections to module 01_02:
In cell 91, there is no need to use an array slice on u.
In cell 92, z_exact is not an input parameter and should not be listed in the docstring.
In cell 95, you reference a temporary variable, z, which I don't think you mean to. Cell should read:
error_values = numpy.empty_like(dt_values)
for i, dt in enumerate(dt_values):
### call the function get_error() ###
error_values[i] = get_error(z_values[i], dt)
I can create a pull request or merge file if you like.
# obtain the curve coordinates
for i in range(1,N):
x[i] = x[i-1] + numpy.cos(theta) * ds
y[i] = y[i-1] + numpy.sin(theta) * ds
R = radius_of_curvature(y[i-1], yt, C)
dtheta = ds/R
theta = theta + dtheta
Messed up my previous post. Here's the missing explanation for the code. I think the algorithm in phugiod.py can be simplified. Currently phugoid.py advances the point (the plane) by computing the radius of curvature, and by rotating the point by an angle dtheta along the osculating circle. Instead of that you could also advance the point by a distance ds in the direction (cos(theta), sin(theta)). The difference between the two is of order (ds)^2, i.e. they are equally accurate. The simplification of the code consists in two parts
I tried it and managed to upload the modified phugoid.py to my forked numerical-moocs repo (yay! my first commit!)
N = int(T/dt)
followed by t = numpy.linspace(0.0, T, N)
. Don't you want to set N = int(T/dt)+1
? As it is, the values in the t
array have values like 0.010001, 0.020002, 0.030003 ...
.
t = numpy.linspace(0.0, T, N+1)
In a local group discussion today, we found another correction to module 01_02. The Euler's method loop. Currently, the loop reads:
z[0]=z0
# time-loop using Euler's method
for n in range(N):
u = u + dt*numpy.array([u[1], g*(1-u[0]/zt)])
z[n] = u[0]
But this overwrites z[0] with non-initial data.
Loop should read
z[0]=z0
# time-loop using Euler's method
for n in range(1,N):
u = u + dt*numpy.array([u[1], g*(1-u[0]/zt)])
z[n] = u[0]
I will create another pull request. Thanks for all your hard work!
looked up a video online that said to "pull request" but that didn't quite work
would really appreciate the help
thank you in advance