Re: implementing a static potential

From: Volker Springel <volker_at_MPA-Garching.MPG.DE>
Date: Thu, 16 Oct 2008 07:34:46 +0200

Jose Ariel Keselman wrote:
> Hi,
>
> I'm trying to implement a static potential to a galaxy-satellite
> collision simulation -so far without success. Maybe you can
> advise me how to make it work right... The potential is very simple,
> just a point mass, its force given by F=M/R^2.
>
> What I've done is the following - at the the end of function
> "force_treeevaluate_shortrange()", before the comment
>
> /* store result at the proper place */
>
> I've added the following lines:
>
> double my_r = sqrt(pos_x*pos_x+pos_y*pos_y+pos_z*pos_z);
> acc_x += -M*pos_x/my_r/my_r/my_r;
>
> and the same for acc_y and acc_z.
>

Hi Ariel,

That's the wrong place I'm afraid. First of all, this routine would only be
active in TreePM mode, but more importantly, in case you use multiple processors
you will add the forces multiple times for certain particles.

You can add your force at the end of gravity_tree(), with a loop of the form

  for(i = 0; i < NumPart; i++)
    if(P[i].Ti_endstep == All.Ti_Current)
      {
         P[i].GravAccel[0] += ...
         P[i].GravAccel[1] += ...
         ...
      }
        
Volker


> Thanks in advance,
> Ariel.
>
> -----------------------------
> Jose Ariel Keselman
> kari_at_tx.technion.ac.il
> +972 4829 5558
> Physics department
> Technion
>
>
>
>
> -----------------------------------------------------------
>
> If you wish to unsubscribe from this mailing, send mail to
> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe gadget-list
> A web-archive of this mailing list is available here:
> http://www.mpa-garching.mpg.de/gadget/gadget-list
Received on 2008-10-16 07:34:47

This archive was generated by hypermail 2.3.0 : 2022-09-01 14:03:42 CEST