From: Bruce S. <Bru...@nc...> - 2009-08-12 21:54:20
|
I'll comment that one just gets a standard error message, not a segfault, on Ubuntu, Windows, and Mac. Bruce Sherwood Sanjoy Mahajan wrote: > On Debian GNU/Linux (i386, 'unstable' distribution), I get a segfault > with the following vpython script. I'm using v5.11 as packaged in > Debian, with Python 2.5.4 from Debian. > > Does anyone see the same problem? > > I eventually figured out one problem with the script: the "F -= > ball.m*g" line needs a vector on the right-hand side. But I don't think > it should segfault even with that mistake. > > By the way, valgrind is not very happy with the script, and also gives > something of a backtrace for the segfault. I've included the end of the > output of "valgrind --leak-check=full python /tmp/script.py" > > -Sanjoy > > > from visual import * > > cd = 0.5 # drag coefficient for a sphere > ball = sphere(pos=(0,0,0), # in m > color=color.red, > radius=0.05) # in m > ball.v = vector(10,0,10) # in m/s > ball.m = 0.5 > g = 10 > endpoint = sphere(pos=(20,0,0)) > startpoint = sphere(pos=(0,0,0)) > scene.autoscale = 0 > > trail = curve() > dt = 0.0001 > area = pi * ball.radius**2 # cross-sectional area of ball > while 1: > rate(int(1/dt)) > ball.pos += ball.v*dt # use updated velocity to update position > trail.append(pos=ball.pos) > F = -0.5 * cd * area * ball.v * ball.v.mag > F -= ball.m*g > ball.v += F/ball.m*dt # force changes the velocity > > > And here is the valgrind output: > > > > |