PLUTO
init.c File Reference

Disk-Planet interaction problem. More...

#include "pluto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define MIN_DENSITY   1e-8
 
#define g_OmegaZ   0.0
 

Functions

static void NormalizeDensity (const Data *d, Grid *g)
 
void Init (double *us, double x1, double x2, double x3)
 
void Analysis (const Data *d, Grid *grid)
 
void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

Disk-Planet interaction problem.

Simulate the interaction of a planet embedded in a disk as described in section 3.4 of Mignone et al., A&A (2012) 545, A152. This test is a nice benchmark for the FARGO module and the ROTATING_FRAME switch. For testing-purposes no viscosity is used here. The initial condition consists of a locally isothermal configuration with temperature profile $\propto T^{-1}$ yielding a disk vertical height to radius of 0.05. The gravitational potential due to the presence of the star and the planet is defined in BodyForcePotential() function.

The conventions used throught the implementation are the following:

  • r = spherical radius
  • R = cylindrical radius
  • z = cylindrical height
  • th = meridional angle

The test can be carried out in polar (2D or 3D) or spherical (3D) coordinates and the following parameters determine the initial configuration:

  1. g_inputParam[Mstar]: controls the star mass (in solar masses)
  2. g_inputParam[Mdisk]: controls the disk mass (in solar masses)
  3. g_inputParam[Mplanet]: sets the planet mass (in earth masses)
  4. g_inputParam[Viscosity]: sets the amount of viscosity

Computation can be carried in the rotating or in the observer's frame of reference (ROTATING_FRAME to YES or NO, respectively). In particular:

  • Configurations #01 and #02 are in 2D polar coordinates without and with FARGO, in the rotating frame.
  • Configurations #03, #04 and #05 are in spherical 3D coordinates with and without FARGO in the rotating frame
  • Configurations #06 and #07 are in 2D polar coordinates but in the observer's frame
  • Configuration #08 employs static AMR (grid levels are spatial dependent but not dependent on time) in the rotating frame.
hd_disk_planet.08.png
Density map for configuration #08 using AMR
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 16, 2012

References:

  • "A Conservative orbital advection scheme for simulations of magnetized shear flows with the PLUTO Code" Mignone et al, A&A (2012)

Definition in file init.c.

Macro Definition Documentation

#define g_OmegaZ   0.0

Definition at line 64 of file init.c.

#define MIN_DENSITY   1e-8

Definition at line 60 of file init.c.

Function Documentation

void Analysis ( const Data d,
Grid grid 
)

Perform runtime data analysis.

Parameters
[in]dthe PLUTO Data structure
[in]gridpointer to array of Grid structures

Definition at line 128 of file init.c.

133 {
134 
135 }
void Init ( double *  us,
double  x1,
double  x2,
double  x3 
)

The Init() function can be used to assign initial conditions as as a function of spatial position.

Parameters
[out]va pointer to a vector of primitive variables
[in]x1coordinate point in the 1st dimension
[in]x2coordinate point in the 2nd dimension
[in]x3coordinate point in the 3rdt dimension

The meaning of x1, x2 and x3 depends on the geometry:

\[ \begin{array}{cccl} x_1 & x_2 & x_3 & \mathrm{Geometry} \\ \noalign{\medskip} \hline x & y & z & \mathrm{Cartesian} \\ \noalign{\medskip} R & z & - & \mathrm{cylindrical} \\ \noalign{\medskip} R & \phi & z & \mathrm{polar} \\ \noalign{\medskip} r & \theta & \phi & \mathrm{spherical} \end{array} \]

Variable names are accessed by means of an index v[nv], where nv = RHO is density, nv = PRS is pressure, nv = (VX1, VX2, VX3) are the three components of velocity, and so forth.

Definition at line 68 of file init.c.

74 {
75  double r, th, R, z, H, OmegaK, cs;
76  double scrh;
77 
78  #if EOS == IDEAL
79  g_gamma = 1.01;
80  #endif
81 
82  #if ROTATING_FRAME == YES
84  g_OmegaZ *= 2.0*CONST_PI;
85  #endif
86 
87  #if GEOMETRY == POLAR
88  R = x1;
89  #if DIMENSIONS == 2
90  z = 0.0;
91  r = R;
92  th = 0.5*CONST_PI;
93  #else
94  z = x3;
95  r = sqrt(R*R + z*z);
96  th = atan2(R,z);
97  #endif
98  #elif GEOMETRY == SPHERICAL
99  r = x1;
100  th = x2;
101  R = r*sin(th);
102  z = r*cos(th);
103  #endif
104 
105  H = 0.05*R;
106  OmegaK = 2.0*CONST_PI/(R*sqrt(R));
107  cs = H*OmegaK;
108 
109  scrh = (0.5*CONST_PI - th)*r/H;
110  us[RHO] = 1.0/(R*sqrt(R))*exp(-0.5*scrh*scrh);
111  us[VX1] = us[VX2] = us[VX3] = 0.0;
112 
113  us[iVPHI] = R*(OmegaK - g_OmegaZ);
114  #if EOS == IDEAL
115  us[PRS] = us[RHO]*cs*cs;
116  #elif EOS == ISOTHERMAL
117 // g_isoSoundSpeed = cs;
118  g_isoSoundSpeed = CONST_PI*0.1;
119  #endif
120 
121 #if DUST == YES
122  us[RHO_D] = 1.e-4;
123  us[VX1_D] = us[VX2_D] = us[VX3_D] = 0.0;
124  us[VX2_D] = us[iVPHI];
125 #endif
126 }
double g_gamma
Definition: globals.h:112
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
tuple scrh
Definition: configure.py:200
#define iVPHI
Definition: mod_defs.h:67
#define g_OmegaZ
Definition: init.c:64
#define Mstar
#define VX1
Definition: mod_defs.h:28
#define CONST_Msun
Solar Mass.
Definition: pluto.h:265
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
#define CONST_Mearth
Earth Mass.
Definition: pluto.h:266
#define VX3
Definition: mod_defs.h:30
#define CONST_PI
.
Definition: pluto.h:269
#define Mplanet
void NormalizeDensity ( const Data d,
Grid g 
)
static

Definition at line 199 of file init.c.

207 {
208  int i, j, k;
209  double mc;
210 
211  mc = 0.5*g_inputParam[Mdisk]*CONST_Msun;
213  DOM_LOOP(k,j,i){
214  d->Vc[RHO][k][j][i] *= mc;
215  #if EOS == IDEAL
216  d->Vc[PRS][k][j][i] *= mc;
217  #endif
218  }
219 }
#define UNIT_DENSITY
Unit density in gr/cm^3.
Definition: pluto.h:369
DOM_LOOP(k, j, i)
Definition: analysis.c:22
#define RHO
Definition: mod_defs.h:19
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define CONST_Msun
Solar Mass.
Definition: pluto.h:265
#define UNIT_LENGTH
Unit Length in cm.
Definition: pluto.h:373
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
#define Mdisk

Here is the call graph for this function:

Here is the caller graph for this function:

void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Assign user-defined boundary conditions.

Parameters
[in,out]dpointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies the boundary side where ghost zones need to be filled. It can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Definition at line 137 of file init.c.

141 {
142  int i, j, k, nv;
143  double *x1, *x2, *x3, R, OmegaK, v[256];
144  static int do_once = 1;
145 
146  x1 = grid[IDIR].x;
147  x2 = grid[JDIR].x;
148  x3 = grid[KDIR].x;
149 
150  #if DIMENSIONS == 3
151  if (side == 0){
152  if (do_once){
153  NormalizeDensity(d, grid);
154  do_once = 0;
155  }
156  }
157  #endif
158 
159  if (side == X1_BEG){
160  X1_BEG_LOOP(k,j,i){
161  NVAR_LOOP(nv) d->Vc[nv][k][j][i] = d->Vc[nv][k][j][2*IBEG - i - 1];
162  d->Vc[VX1][k][j][i] *= -1.0;
163  #if GEOMETRY == POLAR
164  R = x1[i];
165  #elif GEOMETRY == SPHERICAL
166  R = x1[i]*sin(x2[j]);
167  #endif
168  OmegaK = 2.0*CONST_PI/(R*sqrt(R));
169  d->Vc[iVPHI][k][j][i] = R*(OmegaK - g_OmegaZ);
170 #if DUST == YES
171 // NDUST_LOOP(nv) d->Vc[nv][k][j][i] = 0.0;
172  d->Vc[VX2_D][k][j][i] = d->Vc[iVPHI][k][j][i];
173 #endif
174  }
175  }
176 
177  if (side == X1_END){
178  X1_END_LOOP(k,j,i){
179  NVAR_LOOP(nv) d->Vc[nv][k][j][i] = d->Vc[nv][k][j][IEND];
180  #if GEOMETRY == POLAR
181  R = x1[i];
182 // d->Vc[iVR][k][j][i] = 0.0;
183  #elif GEOMETRY == SPHERICAL
184  R = x1[i]*sin(x2[j]);
185  d->Vc[iVR][k][j][i] = 0.0;
186  d->Vc[iVTH][k][j][i] = 0.0;
187  #endif
188  OmegaK = 2.0*CONST_PI/(R*sqrt(R));
189  d->Vc[iVPHI][k][j][i] = R*(OmegaK - g_OmegaZ);
190 #if DUST == YES
191  d->Vc[VX2_D][k][j][i] = d->Vc[iVPHI][k][j][i];
192 #endif
193 
194  }
195  }
196 }
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
static void NormalizeDensity(const Data *d, Grid *g)
Definition: init.c:199
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define iVPHI
Definition: mod_defs.h:67
#define g_OmegaZ
Definition: init.c:64
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define VX1
Definition: mod_defs.h:28
#define KDIR
Definition: pluto.h:195
#define iVR
Definition: mod_defs.h:65
#define IDIR
Definition: pluto.h:193
#define NVAR_LOOP(n)
Definition: pluto.h:618
int j
Definition: analysis.c:2
#define iVTH
Definition: mod_defs.h:66
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:37
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
#define X1_END_LOOP(k, j, i)
Definition: macros.h:50
#define X1_BEG_LOOP(k, j, i)
Definition: macros.h:46
int i
Definition: analysis.c:2
#define CONST_PI
.
Definition: pluto.h:269
#define JDIR
Definition: pluto.h:194
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35

Here is the call graph for this function: