From: cchuang <cc...@ma...> - 2005-06-21 01:58:41
|
Hi, I had released a booklet about VPython and Pygame. All are written within TeXmacs with its Python plugin and shell plugin. In this booklet, there are some vpython examples including: 1. a 3D reflected Brownian partitle travels within a box, (Neuman condition). As the RBM particle hits one of the walls, the hitting sound will be rendering by pygame.sound. 2. Runge-Kutta method for ODE.s. Model the projectile of baseball and Rutherford Scattering Experiment. The file can be downloaded from: ftp://math.cgu.edu.tw/pub/KNOPPIX/game4.pdf In this file server, we also apply some variant KNOPPIX bootable DVD image file, based on knoppix-3.8. Python Environment is also included, for example, visual, scipy etc. User can easily extend his/her need with the help of unionfs in KNOPPIX. In other words, users can read, write even install the packages on the DVD-linux. Hope this really help to you! |
From: Gary <pa...@in...> - 2005-06-22 17:53:57
|
I've been wondering if there would be a programming, accuracy, or performance benefit to using a fancy ode solver with vpython rather than the canonical v = v + F/m * dt especially as the number of objects grows. My thinking was that I could call the solver once per "frame" (say, 1/30 sec), solve for all of the variables all at once, and perhaps have better accuracy, and perhaps get more objects into the simulation. I began to experiment with scipy's odeint, and got some demos working. I ran across some instabilites that I tracked down, but before going any further I thought I'd ask: Does this seem worth the effort? Is there something I haven't considered that dooms this idea? Has someone already done this? The instablilty I found is related to in the way odeint (LSODA??) manages the independent variable. I'd like to look at other solvers. Any suggestions? In particular I'd like to look at a 4th order Runge-Kutta solver, but the only RK4s that I've found are written in python. Does anyone know where there's a python-wrapped C or Fortran RK solver? Thanks, Gary |
From: Eric A. <Ay...@ma...> - 2005-06-22 23:15:22
|
I've been using Python (occasionally with vpython) for an undergrad- level computational physics course, and have had excellent results with an RK4 routine. Here's a sample program: http:// phys.csuchico.edu/ayars/250/code/spring-pendulum.shtml (Ignore the "error processing directive" messages on the webpage -- the page is not up to date at the moment but the code shown is good.) As you suggest, I solve all variables at once: in this example I use the array y[] as a container. I've found that for displaying things on-screen in vpython, a python- based RK4 routine is not the speed-limiting factor. If you need to go with a c routine, though, you might consider writing your own and then using SWIG (http://www.swig.org/) as a way of making a python wrapper for it. I'm new to SWIG (as of this week, actually) but it is working very well for me so far. Hope this helps. -EA ----------------------------------------------------------------- Dr. Eric Ayars Assistant Professor of Physics California State University, Chico ay...@ma... On Jun 22, 2005, at 10:53 AM, Gary wrote: > I've been wondering if there would be a programming, accuracy, or > performance benefit to using a fancy ode solver with vpython rather > than the canonical v = v + F/m * dt especially as the number of > objects grows. My thinking was that I could call the solver once > per "frame" (say, 1/30 sec), solve for all of the variables all at > once, and perhaps have better accuracy, and perhaps get more > objects into the simulation. > > I began to experiment with scipy's odeint, and got some demos > working. I ran across some instabilites that I tracked down, but > before going any further I thought I'd ask: > > Does this seem worth the effort? > > Is there something I haven't considered that dooms this idea? > > Has someone already done this? > > The instablilty I found is related to in the way odeint (LSODA??) > manages the independent variable. I'd like to look at other > solvers. Any suggestions? In particular I'd like to look at a 4th > order Runge-Kutta solver, but the only RK4s that I've found are > written in python. Does anyone know where there's a python-wrapped > C or Fortran RK solver? > > Thanks, > Gary > > |
From: Hans F. <H.F...@so...> - 2005-06-27 19:55:41
|
Hi Gary, > I've been wondering if there would be a programming, accuracy, or > performance benefit to using a fancy ode solver with vpython rather than > the canonical v = v + F/m * dt especially as the number of objects > grows. My thinking was that I could call the solver once per "frame" > (say, 1/30 sec), solve for all of the variables all at once, and perhaps > have better accuracy, and perhaps get more objects into the simulation. > > I began to experiment with scipy's odeint, and got some demos working. > I ran across some instabilites that I tracked down, but before going any > further I thought I'd ask: > > Does this seem worth the effort? We used scipy.integrate.odeint quite successfully (in a teaching context). > Is there something I haven't considered that dooms this idea? Not sure. What doesn't work? > Has someone already done this? > > The instablilty I found is related to in the way odeint (LSODA??) > manages the independent variable. I'd like to look at other solvers. Are saying, it takes too large steps? > Any suggestions? In particular I'd like to look at a 4th order > Runge-Kutta solver, but the only RK4s that I've found are written in > python. Does anyone know where there's a python-wrapped C or Fortran RK > solver? My feeling is that the solver in odeint is far more sophisticated than a RK4 solver. However, I would need more information as to what is 'instable' and what you have tried to overcome this. Cheers, Hans |