1 #define JET6LIKEUSERCOORD 0
2 #define UNIHALFUSERCOORD 1
4 #define WHICHUSERCOORD JET6LIKEUSERCOORD
8 static FTYPE npow,
r1jet,
njet1,
njet,
r0jet,
rsjet,
Qjet,
ntheta,
htheta,
rsjet2,
r0jet2,
rsjet3,
r0jet3,
rs,
r0,
npow2,
cpow2,
rbr,
x1br,
h0,
cpow3;
106 fprintf(out,
"%21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g %21.15g\n",
npow,
r1jet,
njet,
r0jet,
rsjet,
Qjet,
ntheta,
htheta,
rsjet2,
r0jet2,
rsjet3,
r0jet3,
rs,
r0,
npow2,
cpow2,
rbr,
x1br,
cpow3);
114 fscanf(in,
HEADER19IN,&
npow,&
r1jet,&
njet,&
r0jet,&
rsjet,&
Qjet,&
ntheta,&
htheta,&
rsjet2,&
r0jet2,&
rsjet3,&
r0jet3,&
rs,&
r0,&
npow2,&
cpow2,&
rbr,&
x1br,&
cpow3);
119 void read_coord_parms_mpi_user(
int defcoordlocal)
123 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
124 MPI_Bcast(&
r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
125 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
126 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
127 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
128 MPI_Bcast(&
Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
129 MPI_Bcast(&
ntheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
130 MPI_Bcast(&
htheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
131 MPI_Bcast(&
rsjet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
132 MPI_Bcast(&
r0jet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
133 MPI_Bcast(&
rsjet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
134 MPI_Bcast(&
r0jet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
135 MPI_Bcast(&
rs, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
136 MPI_Bcast(&
r0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
137 MPI_Bcast(&
npow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
138 MPI_Bcast(&
cpow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
139 MPI_Bcast(&
rbr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
140 MPI_Bcast(&
x1br, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
141 MPI_Bcast(&
cpow3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
154 #if(0) // no change in exponentiation
156 V[1] =
R0+exp(pow(X[1],
npow)) ;
157 #elif(WHICHUSERCOORD==UNIHALFUSERCOORD)
163 FTYPE gconst2=gconst1*.000001;
164 V[1] =
R0 + gconst1*X[1] + gconst2*exp(theexp);
167 #elif(WHICHUSERCOORD==JET6LIKEUSERCOORD)
173 V[1] =
R0+exp(theexp);
185 FTYPE switch0 = 0.5+1.0/M_PI*atan((V[1]-
rbr)/r0rbr);
190 V[1] = V1*(1.0-switch0) + V2*switch0;
196 FTYPE theta1,theta2,arctan2;
202 theta1 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
215 FTYPE localrbrr0=100.0;
217 FTYPE switch0 = 0.5+1.0/M_PI*atan((V[1]-localrbr)/localrbrr0);
218 FTYPE switch2 = 1.0-switch0;
224 FTYPE myhslope = myhslope1*switch2 + myhslope2*switch0;
232 if(X[2]>1.0) myx2=2.0-X[2];
233 else if(X[2]<0.0) myx2=-X[2];
236 FTYPE th2 = 0.5*M_PI*(1.0 + atan(myhslope*(myx2-0.5))/atan(myhslope*0.5));
238 if(X[2]>1.0) th2=2.0*M_PI-th2;
239 else if(X[2]<0.0) th2=-th2;
245 myhslope = myhslope1*switch2 + myhslope2*switch0;
247 FTYPE th0 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
251 switch0 = 0.5+1.0/M_PI*atan((V[1]-
rs)/
r0);
252 switch2 = 1.0-switch0;
255 theta1 = th0*switch2 + th2*switch0;
266 arctan2 = 0.5 + 1.0/M_PI*(atan( (V[1]-
rsjet2)/
r0jet2) );
269 V[2] = theta2 + arctan2*(theta1-theta2);
277 FTYPE fracpole=(1.0-fraceq)/2.0;
278 FTYPE x2p1=0.0+fracpole;
279 FTYPE x2p2=1.0-fracpole;
287 FTYPE switchh0 = 0.5+0.5*tanh((X[2]-x2p1)/swide);
288 FTYPE switchh2 = 0.5+0.5*tanh((X[2]-x2p2)/swide);
291 FTYPE theq = M_PI * X[2] + ((1. - eqh) * 0.5) * mysin(2. * M_PI * X[2]);
293 FTYPE thup=switchh0*theq + (1.0-switchh0)*theta1;
295 V[2]=switchh2*theta1 + (1.0-switchh2)*thup;
303 FTYPE transwidth=0.06;
305 FTYPE transR=0.5*(1.0-tanh(+(X[2] - xcent)/transwidth));
306 FTYPE transL=0.5*(1.0-tanh(-(X[2] - xcent)/transwidth));
315 V[2] = line1*transR + line2*transL;
325 #define cr(x) (exp(-1.0/(x)))
326 #define tr(x) (cr(x)/(cr(x) + cr(1.0-(x))))
327 #define trans(x,L,R) ((x)<=(L) ? 0.0 : ((x)>=(R) ? 1.0 : tr(((x)-(L))/((R)-(L)))) )
328 #define transR(x,center,width) ( 0.5*(1.0-tanh(+((x)-(center))/(width))))
329 #define transL(x,center,width) ( 0.5*(1.0-tanh(-((x)-(center))/(width))))
330 #define transM(x,center,width) ( exp(-pow(((x)-(center))/((width)*0.5),2.0) ) )
331 #define line1(x,w) ((x)*(w))
332 #define line2(x,w) ((x)*(w)+M_PI-(w))
333 #define line3(x,w) ((x)*(w))
336 #define wparsam(x,r) (h0 + pow(0.15 + ((r)-0.0)/10.0 , -njet))
337 #define thetasam(x,r,w,xp1,xp2) (line1(x,w)*(1.0-trans(x,xp1,xp2)) + line2(x,w)*trans(x,xp1,xp2))
351 #define plateau(x,L,R,W) (trans(x,(L)-0.5*(W),(L)+0.5*(W))*(1.0-trans(x,(R)-0.5*(W),(R)+0.5*(W))))
352 #define lineeq(x,w) ((x)*(w)+(0.5*M_PI)-(0.5*w))
353 #define linepole(x,w) (line1(x,w))
354 #define thetaL(x,wp,weq,xp1,xp2) ( linepole(x,wp)*(1.0-trans(x,xp1,xp2)) + lineeq(x,weq)*trans(x,xp1,xp2) )
355 #define thetasam2(x,wp,weq,xp1,xp2) ( x<0.5 ? thetaL(x,wp,weq,xp1,xp2) : -thetaL(1.0-x,wp,weq,xp1,xp2)+M_PI )
362 V[2] =
thetasam2(X[2], poleslope, eqslope, xpole, xeq);
379 dualfprintf(
fail_file,
"Should not be computing USERCOORDS analytically\n");
381 dxdxp[3][3] = 2.0*M_PI;
384 void set_points_user(
void)
389 startx[1] = 0.3999985081775278946780799743777598329673;
393 FTYPE endx1=21.40529883372801383045167738115556702610;
410 trifprintf(
"ITERATIVE dx1: Rout=%21.15g R0=%21.15g npow=%21.15g cpow2=%21.15g cpow3=%21.15g npow2=%21.15g x1br=%21.15g rbr=%21.15g\n",
Rout,
R0,
npow,
cpow2,
cpow3,
npow2,
x1br,
rbr);
412 FTYPE x1max0, x1max,dxmax;
415 const int ITERMAX = 100;
426 for( iter = 0; iter < ITERMAX; iter++ ) {
430 if( fabs((x1max - x1max0)/x1max) < RELACC ) {
444 dxmax=(
Rout-V0)/dVdx1;
446 dualfprintf(
fail_file,
"dVdx1=%g V0=%g dxmax=%g x1max=%g x1max0=%g\n",dVdx1,V0,dxmax,x1max,x1max0);
450 FTYPE dampingfactor=0.5;
451 x1max = x1max0 + dampingfactor*dxmax;
456 if( iter == ITERMAX ) {
457 trifprintf(
"Error: iteration procedure for finding x1max has not converged: x1max = %g, dx1max/x1max = %g, iter = %d\n",
458 x1max, (x1max-x1max0)/x1max, iter );
462 trifprintf(
"x1max = %g (dx1max/x1max = %g, itno = %d)\n", x1max, (x1max-x1max0)/x1max, iter );