comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Force Field
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Force Field [message #45494 is a reply to message #45491] Tue, 13 September 2005 19:13 Go to previous messageGo to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <1126634205.227520.96190@f14g2000cwb.googlegroups.com>,
"Andres" <panblosky@gmail.com> wrote:

> Hi all,
>
> I have a potential field on a grid (it has periodic boundary
> conditions), and I want to calculate the acceleration (force field) of
> this, i.e., f=-grad(potential), I need the gradient of the potential .
> I wrote a procedure, but it has to many for loops in it. Does any body
> know a fast and smart way to do this?
> Thanks!!
>
> Andres

Assuming that you are happy with first-order, centered differences, you
want something like this

grad_x = (SHIFT(phi, -1, 0) - SHIFT(phi, 1, 0))/(2.0*dx)
grad_y = (SHIFT(phi, 0, -1) - SHIFT(phi, 0, 1))/(2.0*dy)

where phi is the potential It think this handles the periodic boundary
conditions properly, but check to make sure.

Cheers, Ken Bowman
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Poscript Component Selection
Next Topic: Replication question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:05:40 PDT 2025

Total time taken to generate the page: 1.35721 seconds