42 int i,j,l,nr,ns,k,npl;
44 real xpl, ypl, zpl, mpl, dpl, invdpl3, smoothing;
46 real d2, d, H, H2, zmax, deltaz;
47 real rsm[
MAXPLANETS], rsm2[
MAXPLANETS], sigma, znode, znode2, denom, ax, ay, ar, at, axindir, ayindir;
49 real integstar, sum, tmp, tmpbuf;
50 real cs_avr, integstar_avr, sigma_avr, H_avr;
51 real tau_avr=0.0, p_H_avr=0.0, p_integstar_avr=0.0, p_integstar=0.0, pax=0.0, pay=0.0, pH=0.0, Hcorr=0.0;
52 Pair IndirectTermFromPlanets;
53 boolean IntegrateWithPlanet[
MAXPLANETS], IntegrateLocally;
54 real axstar, aystar, hillcut[
MAXPLANETS]={1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, mcell;
56 real tmparray[
MAXPLANETS]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}, axpl[
MAXPLANETS]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}, aypl[
MAXPLANETS]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
57 real *agr, *agt, *pagr, *pagt, *rho, *tau, *cs, *abs, *ord, *tqwk;
73 #pragma omp parallel for
74 for (i = 0; i < (nr+1)*ns; i++) {
85 for (k = 0; k < npl; k++) {
92 dpl = sqrt(xpl*xpl+ypl*ypl+zpl*zpl);
93 rhill[k] = dpl*pow((1.0/3.0*mpl),1.0/3.0);
96 smoothing2[k] = smoothing*smoothing;
99 rst3[k] = rst2[k]*rst;
100 rst4[k] = rst3[k]*rst;
101 rsm[k] = 0.05*rhill[k];
102 rsm2[k] = rsm[k]*rsm[k];
103 rmorevert2[k] = 2.0*rhill[k];
104 rmorevert2[k] *= rmorevert2[k];
106 invdpl3 = 1.0/(dpl*dpl*dpl);
108 axstar += mpl*invdpl3*xpl;
109 aystar += mpl*invdpl3*ypl;
112 IndirectTermFromPlanets.
x = - axstar;
113 IndirectTermFromPlanets.
y = - aystar;
116 #pragma omp parallel for \
117 firstprivate (tau_avr,p_H_avr,p_integstar_avr,p_integstar,pax,pay,pH,Hcorr) \
118 private (omegainv, r2, Nvert, cs_avr, H_avr, \
119 H2, zmax, deltaz, sigma_avr, integstar_avr, znode, znode2, sum, \
120 d2, d, denom, IntegrateLocally, ax, ay, x, y, mcell, H, \
121 xpl, ypl, zpl, s2, r2chk_1, r2chk_2, IntegrateWithPlanet, integpl, p_integpl, hillcut, \
122 sigma, integstar, taper, tmp, ar, mpl, at, \
124 reduction (+ : axstar,aystar)
127 for (i = 0; i<nr; i++) {
134 for (j = 0; j<ns; j++) {
137 if (
Pebbles) tau_avr += tau[l];
144 p_integstar_avr = 0.0;
148 deltaz = zmax/(
real)Nvert;
151 for (m=1; m<=Nvert; m++) {
152 znode = ((
real)m-0.5)*deltaz;
153 znode2 = znode*znode;
154 sum = exp(-(0.5*znode2/H2));
159 integstar_avr += sum/denom;
165 p_integstar_avr += sum/denom;
172 for (j = 0; j<ns; j++) {
173 IntegrateLocally =
NO;
184 mcell = rho[l]*
Surf[i];
188 if (fabs(H-H_avr)/H_avr > 0.05) IntegrateLocally =
YES;
192 if (fabs(pH-p_H_avr)/p_H_avr > 0.05) IntegrateLocally =
YES;
198 for (k = 0; k < npl; k++) {
202 s2[k] = (x-xpl)*(x-xpl) + (y-ypl)*(y-ypl);
203 r2chk_1 = 10.0*Hpl[k];
205 r2chk_2 = 5.0*rhill[k];
207 if (
MassTaper == 1.0 && (s2[k] < r2chk_1 || s2[k] < r2chk_2)) {
208 IntegrateLocally =
YES;
209 IntegrateWithPlanet[k] =
YES;
211 if (
Pebbles) p_integpl[k] = 0.0;
212 d2 = s2[k] + zpl*zpl;
214 hillcut[k] = 1.0/(exp(-(sqrt(d2)/rhill[k]-
HILLCUT)/
HILLCUT*10.0)+1.0);
217 IntegrateWithPlanet[k] =
NO;
219 if (s2[k] < rmorevert2[k]) Nvert = 30;
223 if (IntegrateLocally) {
225 deltaz = zmax/(
real)Nvert;
228 if (
Pebbles) p_integstar = 0.0;
229 for (m=1; m<=Nvert; m++) {
230 znode = ((
real)m-0.5)*deltaz;
231 znode2 = znode*znode;
232 sum = exp(-(0.5*znode2/H2));
237 integstar += sum/denom;
239 d2 = r2 + znode2*Hcorr*Hcorr;
242 p_integstar += sum/denom;
244 for (k = 0; k < npl; k++) {
245 if (IntegrateWithPlanet[k]==
YES) {
247 d2 = s2[k] + (znode-zpl)*(znode-zpl);
250 taper = -3.0*d2*d2/rst4[k] + 4.0*d*d2/rst3[k];
257 integpl[k] += sum/denom*taper;
258 if (zpl < - 0.05*H || zpl > 0.05*H) {
259 d2 = s2[k] + (-znode-zpl)*(-znode-zpl);
262 taper = -3.0*d2*d2/rst4[k] + 4.0*d*d2/rst3[k];
269 integpl[k] += sum/denom*taper;
272 d2 = s2[k] + (znode*Hcorr-zpl)*(znode*Hcorr-zpl);
275 taper = -3.0*d2*d2/rst4[k] + 4.0*d*d2/rst3[k];
282 p_integpl[k] += sum/denom*taper;
283 if (zpl < - 0.05*pH || zpl > 0.05*pH) {
284 d2 = s2[k] + (-znode*Hcorr-zpl)*(-znode*Hcorr-zpl);
287 taper = -3.0*d2*d2/rst4[k] + 4.0*d*d2/rst3[k];
294 p_integpl[k] += sum/denom*taper;
302 integstar = integstar_avr;
303 if (
Pebbles) p_integstar = p_integstar_avr;
306 tmp = integstar/sigma;
310 axstar += mcell*tmp*x;
311 aystar += mcell*tmp*y;
314 tmp = p_integstar/sigma;
320 for (k = 0; k < npl; k++) {
325 if (IntegrateWithPlanet[k]==
YES) {
326 if (zpl < - 0.05*H || zpl > 0.05*H) {
327 tmp = (x-xpl)*integpl[k]/(2.0*sigma);
329 tmp = (x-xpl)*integpl[k]/sigma;
335 axpl[k] += mcell*tmp;
338 if (zpl < - 0.05*H || zpl > 0.05*H) {
339 tmp = (y-ypl)*integpl[k]/(2.0*sigma);
341 tmp = (y-ypl)*integpl[k]/sigma;
347 aypl[k] += mcell*tmp;
351 if (zpl < - 0.05*pH || zpl > 0.05*pH) {
352 tmp = (x-xpl)*p_integpl[k]/(2.0*sigma);
354 tmp = (x-xpl)*p_integpl[k]/sigma;
357 if (zpl < - 0.05*pH || zpl > 0.05*pH) {
358 tmp = (y-ypl)*p_integpl[k]/(2.0*sigma);
360 tmp = (y-ypl)*p_integpl[k]/sigma;
366 d2 = s2[k] + zpl*zpl + smoothing2[k];
374 axpl[k] += mcell*tmp;
382 aypl[k] += mcell*tmp;
386 d2 += - smoothing2[k] + smoothing2[k]*Hcorr*Hcorr;
402 ar = (x*pax + y*pay)*
InvRmed[i];
403 at = (x*pay - y*pax)*
InvRmed[i];
411 IndirectTerm.
x = -tmpbuf;
413 IndirectTerm.
y = -tmpbuf;
415 for (k=0; k<npl; k++) {
416 sys->
ax[k] = tmparray[k];
419 for (k=0; k<npl; k++) {
420 sys->
ay[k] = tmparray[k];
423 axindir = IndirectTerm.
x;
424 ayindir = IndirectTerm.
y;
426 axindir += IndirectTermFromPlanets.
x;
427 ayindir += IndirectTermFromPlanets.
y;
429 for (i=0; i<nr; i++) {
430 for (j=0; j<ns; j++) {
434 ar = (x*axindir + y*ayindir)*
InvRmed[i];
435 at = (x*ayindir - y*axindir)*
InvRmed[i];
454 real x,y,z,m,vz,damp;
467 sprintf (command,
"cd %s; cat gastorque%d.dat.%05d >> gastorque%d.dat",\
475 for (k = 0; k < npl; k++) {
476 if (sys->FeelDisk[k] ==
YES) {
483 sys->vx[k] += dt * sys->ax[k];
484 sys->vy[k] += dt * sys->ay[k];
485 sys->vz[k] += dt * (sys->az[k] + damp);
486 sys->vx[k] += dt * IndirectTerm.
x;
487 sys->vy[k] += dt * IndirectTerm.
y;
499 real r, ang, Omega, cs4inv, damp=0.0, rhoavr=0.0, csavr=0.0, tmp;
509 if (ang < 0.0) ang += 2.0*
PI;
511 while (
Rsup[i] < r) i++;
512 for (j=0; j<ns; j++) {
519 cs4inv = pow(csavr, -4.0);
520 Omega = pow(r, -1.5);
521 damp =
VERTICALDAMPING*m*rhoavr*Omega*cs4inv*(-2.176*vz - 0.871*z*Omega);
535 for (i = 1; i < n; i++)
536 u[i] = 2.0*v[i]-u[i-1];
537 for (i = 1; i < n-1; i++) {
538 lapl += fabs(u[i+1]+u[i-1]-2.0*u[i]);
553 for (i=0; i<nr; i++) {
554 for (j=0; j<ns; j++) {
559 energy = Energy->Field;
560 for (i=0; i<nr; i++) {
561 for (j=0; j<ns; j++) {
572 real *vr, *vt, *pres, *cs;
573 real r, rg, omega, ri;
574 real viscosity, t1, t2, r1, r2;
608 t1 = t1-r1/(r2-r1)*(t2-t1);
619 for (i = 0; i <= nr; i++) {
629 for (j = 0; j < ns; j++) {
632 omega = sqrt(
G*1.0/rg/rg/rg);
639 vt[l] = omega*r*sqrt(1.0-cs[l]*cs[l]*r/
ADIABIND);
656 for (j = 0; j < ns; j++)
657 vr[j] = vr[j+ns*nr] = 0.0;
double real
Definition of the type 'real' used throughout the code.
static real vt_cent[MAX1D]
real * z
z-coordinate of the planets
PolarGrid * PebbleGravAccelTheta
real * x
x-coordinate of the planets
real ThicknessSmoothing(real x, real y)
Computes the local thickness from the sound speed and applies the thickness smoothing parameter...
real * y
y-coordinate of the planets
A structure used to store any scalar fied on the computational domain.
real * mass
Masses of the planets.
Contains all the information about a planetary system at a given instant in time. ...
void InitGasVelocity(PolarGrid *Vr, PolarGrid *Vt)
real DampingTW04(PolarGrid *Rho, real m, real x, real y, real z, real vz)
Artificial vertical force to damp the orbital inclinations using the Tanaka & Ward (2004) prescriptio...
static real vt_int[MAX1D]
boolean DumpTorqueDensNow
boolean CentrifugalBalance
PolarGrid * PebbleGravAccelRad
void MPI_Allreduce(void *ptr, void *ptr2, int count, int type, int foo3, int foo4)
void FillForcesArrays(PolarGrid *Rho, PlanetarySystem *sys)
Using the vertical averaging procedure of Muller & Kley (2012), calculates the acceleration in planet...
real ConstructSequence(real *u, real *v, int n)
void InitGasDensityEnergy(PolarGrid *Rho, PolarGrid *Energy)
Part of the initialisation.
real * ay
ay-coordinate of the planets' acceleration from the disk
PolarGrid * GravAccelTheta
Contains all the include directives requested by the code.
real * ax
ax-coordinate of the planets' acceleration from the disk
void AdvanceSystemFromDisk(PolarGrid *Rho, PlanetarySystem *sys, real dt)
Updates the planet velocities due to disk forces.
void UpdateLog(PolarGrid *Rho, PlanetarySystem *psys)
Calculates and writes the disk torques (both specific and normalized) acting on the planets...
boolean ParametricCooling
void WriteDiskPolar(PolarGrid *array, int number)
void mpi_make1Dprofile(real *gridfield, real *axifield)