A collaborative educational initiative in computational science and engineering.
mesnardo on master
Minor changes * [Module 2, Les… (compare)
labarba on format
# 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
Hi, I have a little question about the third question of module 1 (Array trigonometry), according to my calculations the answer is:
In [23]: p
Out[23]: 7
In [24]: r
Out[24]: array([ 11.2, 4.7, 6.6])
In [25]: numpy.power((numpy.sin(p/r)),3)
Out[25]: array([ 0.20030151, 0.99009101, 0.66454238])
ans: 0.9900
Is there something wrong? Because I can't check the answer. Thanks in advance...