20 real RRoche, Rplanet, distance, dx, dy, deltaM, angle, temp;
21 int i_min,i_max, j_min, j_max, i, j, l, jf, ns, nr, lip, ljp, k;
23 real facc, facc1, facc2, frac1, frac2;
24 real *dens, *abs, *ord, *vrad, *vtheta;
25 real PxPlanet, PyPlanet, vrcell, vtcell, vxcell, vycell, xc, yc;
26 real dPxPlanet, dPyPlanet, dMplanet;
33 vtheta = Vtheta->
Field;
34 for (k=0; k < sys->
nb; k++) {
35 if (sys->
acc[k] > 1e-10) {
36 dMplanet = dPxPlanet = dPyPlanet = 0.0;
38 facc = dt*(sys->
acc[k]);
46 VXplanet = sys->
vx[k];
47 VYplanet = sys->
vy[k];
48 Mplanet = sys->
mass[k];
49 Rplanet = sqrt(Xplanet*Xplanet+Yplanet*Yplanet);
50 RRoche = pow((1.0/3.0*Mplanet),(1.0/3.0))*Rplanet;
53 while ((
Rsup[i_min] < Rplanet-RRoche) && (i_min < nr)) i_min++;
54 while ((
Rinf[i_max] > Rplanet+RRoche) && (i_max > 0)) i_max--;
55 angle = atan2 (Yplanet, Xplanet);
56 j_min =(int)((
real)ns/2.0/
PI*(angle - 2.0*RRoche/Rplanet));
57 j_max =(int)((
real)ns/2.0/
PI*(angle + 2.0*RRoche/Rplanet));
61 #pragma omp parallel for private(j,jf,vrcell,vtcell,vxcell,vycell,l,lip,ljp,xc,yc,dx,dy,distance,deltaM) reduction(+ : dPxPlanet, dPyPlanet, dMplanet)
62 for (i = i_min; i <= i_max; i++) {
63 for (j = j_min; j <= j_max; j++) {
65 while (jf < 0) jf += ns;
66 while (jf >= ns) jf -= ns;
70 if (jf == ns-1) ljp = i*ns;
75 distance = sqrt(dx*dx+dy*dy);
77 vrcell=0.5*(vrad[l]+vrad[lip]);
78 vxcell=(vrcell*xc-vtcell*yc)/
Rmed[i];
79 vycell=(vrcell*yc+vtcell*xc)/
Rmed[i];
80 if (distance < frac1*RRoche) {
81 deltaM = facc1*dens[l]*
Surf[i];
84 dens[l] *= (1.0 - facc1);
85 dPxPlanet += deltaM*vxcell;
86 dPyPlanet += deltaM*vycell;
89 if (distance < frac2*RRoche) {
90 deltaM = facc2*dens[l]*
Surf[i];
93 dens[l] *= (1.0 - facc2);
94 dPxPlanet += deltaM*vxcell;
95 dPyPlanet += deltaM*vycell;
106 PxPlanet += dPxPlanet;
107 PyPlanet += dPyPlanet;
110 sys->
vx[k] = PxPlanet/Mplanet;
111 sys->
vy[k] = PyPlanet/Mplanet;
113 sys->
mass[k] = Mplanet;
123 real Ax, Ay, e, d, h,
a, E, M, V;
128 sprintf (name,
"%sorbit%d.dat",
OUTPUTDIR, n);
129 output =
fopenp (name,
"a");
132 Ax = x*vy*vy-y*vx*vy-
G*m*x/d;
133 Ay = y*vx*vx-x*vx*vy-
G*m*y/d;
134 e = sqrt(Ax*Ax+Ay*Ay)/
G/m;
137 E = acos((1.0-d/a)/e);
141 if ((x*y*(vy*vy-vx*vx)+vx*vy*(x*x-y*y)) < 0) E= -E;
144 V = acos ((a*(1.0-e*e)/d-1.0)/e);
150 PerihelionPA=atan2(Ay,Ax);
152 PerihelionPA=atan2(y,x);
154 fprintf (output,
"%.12g\t%.12g\t%.12g\t%.12g\t%.12g\t%.12g\n",
PhysicalTime, e, a, M, V,\
double real
Definition of the type 'real' used throughout the code.
void FindOrbitalElements(real x, real y, real vx, real vy, real m, int n)
boolean * FeelDisk
For each planet tells if it feels the disk (ie migrates)
real * x
x-coordinate of the planets
real * y
y-coordinate of the planets
A structure used to store any scalar fied on the computational domain.
FILE * fopenp(char *string, char *mode)
real * vx
x-coordinate of the planets'velocities
real * mass
Masses of the planets.
int Nrad
Radial size of the grid, in number of zones.
Contains all the information about a planetary system at a given instant in time. ...
void AccreteOntoPlanets(PolarGrid *Rho, PolarGrid *Vrad, PolarGrid *Vtheta, real dt, PlanetarySystem *sys)
real * acc
The planets' accretion times^-1.
void MPI_Allreduce(void *ptr, void *ptr2, int count, int type, int foo3, int foo4)
real * vy
y-coordinate of the planets'velocities
Contains all the include directives requested by the code.
int Nsec
Azimuthal size of the grid, in number of zones.