71 #define USESJETLOGHOVERR 1
84 static FTYPE bp_npow,
bp_r1jet,
bp_njet1,
bp_njet,
bp_r0jet,
bp_rsjet,
bp_Qjet,
bp_ntheta,
bp_htheta,
bp_rsjet2,
bp_r0jet2,
bp_rsjet3,
bp_r0jet3,
bp_rs,
bp_r0,
bp_rsinner,
bp_r0inner,
bp_npow2,
bp_cpow2,
bp_rbr,
bp_x1br,
bp_h0;
105 static FTYPE th_npow,
th_r1jet,
th_njet1,
th_njet,
th_r0jet,
th_rsjet,
th_Qjet,
th_ntheta,
th_htheta,
th_rsjet2,
th_r0jet2,
th_rsjet3,
th_r0jet3,
th_rs,
th_r0,
th_npow2,
th_cpow2,
th_rbr,
th_x1br,
th_h0;
129 if(omp_in_parallel()){
130 dualfprintf(
fail_file,
"set_coord_parms_nodeps() called in parallel region\n");
150 else if (defcoordlocal ==
EQMIRROR) {
400 else if (defcoordlocal ==
BPTHIN1) {
463 #if(0)//HIGHRES // MAVARACHANGE I choose this because bp_ntheta 5 is less than the 0 used for the thin regime for the bp study. so, 5 note extreme enough.
469 #if(1) //MIDRES note that lowres doesn't use polefix code
484 #define JET5TOTALSIZE (256)
485 #define JET5RIN (1.2)
486 #define JET5ROUT (1.0E10)
490 dualfprintf(
fail_file,
"Current version of JET5COORDS requires totalsize[1]=256\n");
498 AAAA=1999999.0/10000000.0;
501 AAA=0.0413459589685779052930351140071389811117796472908765122327766247871075306910922595355681060060416677474341974954736231119642058094;
511 BBB=-11.730265173318042629015657514515818843547237290015385234914265620733433049284290050282184485;
521 DDD=0.055717934049496306640561701541245682756775321774122925900528950779091605796182691888079948813285317249415181430716632182425357598150;
609 else if (defcoordlocal ==
UNI2LOG) {
623 dualfprintf(
fail_file,
"Shouldn't reach end of set_coord_parms: You set defcoordlocal=%d\n",defcoordlocal);
635 if(omp_in_parallel()){
636 dualfprintf(
fail_file,
"set_coord_parms_deps() called in parallel region\n");
654 else if (defcoordlocal ==
EQMIRROR) {
736 #if(USESJETLOGHOVERR)
756 else if (defcoordlocal ==
BPTHIN1) {
797 else if (defcoordlocal ==
UNI2LOG) {
809 dualfprintf(
fail_file,
"If Nstar=0 then Rstar=Rin must be set\n");
817 dualfprintf(
fail_file,
"Shouldn't reach end of set_coord_parms: You set defcoordlocal=%d\n",defcoordlocal);
832 if(omp_in_parallel()){
833 dualfprintf(
fail_file,
"write_coord_parms_parms() called in parallel region\n");
840 if((out=fopen(
"coordparms.dat",
"wt"))==NULL){
841 dualfprintf(
fail_file,
"Couldn't write coordparms.dat file\n");
861 else if (defcoordlocal ==
EQMIRROR) {
874 fprintf(out,
"%26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g\n",
npow,
h0,
hf,
rh0,
myrout,
dmyhslope1dr,
dmyhslope2dx1,
x1in,
x1out);
883 fprintf(out,
"%26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g\n",
npow,
r1jet,
njet,
r0grid,
r0jet,
rjetend,
rsjet,
Qjet,
fracphi,
npow2,
cpow2,
rbr,
x1br,
fracdisk,
fracjet,
r0disk,
rdiskend,
torusrmax_loc,
jetnu,
x10,
x20);
886 fprintf(out,
"%26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g\n",
npow,
r1jet,
njet,
r0jet,
rsjet,
Qjet,
ntheta,
htheta,
rsjet2,
r0jet2,
rsjet3,
r0jet3,
rs,
r0,
npow2,
cpow2,
rbr,
x1br,
cpow3);
889 fprintf(out,
"%26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g %26.20g\n",th_npow,th_r1jet,th_njet,th_r0jet,th_rsjet,th_Qjet,th_ntheta,th_htheta,th_rsjet2,th_r0jet2,th_rsjet3,th_r0jet3,th_rs,th_r0,th_npow2,th_cpow2,th_rbr,th_x1br,th_rbr,th_h0,th_njet1);
891 else if (defcoordlocal ==
BPTHIN1) {
892 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 %21.15g %21.15g\n",
bp_npow,
bp_r1jet,
bp_njet,
bp_r0jet,
bp_rsjet,
bp_Qjet,
bp_ntheta,
bp_htheta,
bp_rsjet2,
bp_r0jet2,
bp_rsjet3,
bp_r0jet3,
bp_rs,
bp_r0,
bp_rsinner,
bp_r0inner,
bp_npow2,
bp_cpow2,
bp_rbr,
bp_x1br,
fracphi);
908 fprintf(out,
"%26.20g\n",
npow);
917 else if (defcoordlocal ==
UNI2LOG) {
921 dualfprintf(
fail_file,
"Shouldn't reach end of write_coord_parms: You set defcoordlocal=%d\n",defcoordlocal);
940 if(omp_in_parallel()){
941 dualfprintf(
fail_file,
"read_coord_parms_parms() called in parallel region\n");
947 in=fopen(
"coordparms.dat",
"rt");
949 dualfprintf(
fail_file,
"Couldn't read coordparms.dat file. I'll assume coded coordinates and let restart header overwrite any global restart parameters\n");
973 else if (defcoordlocal ==
EQMIRROR) {
985 fscanf(in,
HEADER9IN,&
npow,&
h0,&
hf,&
rh0,&
myrout,&
dmyhslope1dr,&
dmyhslope2dx1,&
x1in,&
x1out);
994 fscanf(in,
HEADER9IN,&
npow,&
r1jet,&
njet,&
r0grid,&
r0jet,&
rjetend,&
rsjet,&
Qjet,&
fracphi);
995 fscanf(in,
HEADER9IN,&
npow2,&
cpow2,&
rbr,&
x1br,&
fracdisk,&
fracjet,&
r0disk,&
rdiskend,&
torusrmax_loc);
999 fscanf(in,
HEADER19IN,&
npow,&
r1jet,&
njet,&
r0jet,&
rsjet,&
Qjet,&
ntheta,&
htheta,&
rsjet2,&
r0jet2,&
rsjet3,&
r0jet3,&
rs,&
r0,&
npow2,&
cpow2,&
rbr,&
x1br,&
cpow3);
1002 fscanf(in,
HEADER21IN,&th_npow,&th_r1jet,&th_njet,&th_r0jet,&th_rsjet,&th_Qjet,&th_ntheta,&th_htheta,&th_rsjet2,&th_r0jet2,&th_rsjet3,&th_r0jet3,&th_rs,&th_r0,&th_npow2,&th_cpow2,&th_rbr,&th_x1br,&th_rbr,&th_h0,&th_njet1);
1004 else if (defcoordlocal ==
BPTHIN1) {
1005 fscanf(in,
HEADER21IN,&
bp_npow,&
bp_r1jet,&
bp_njet,&
bp_r0jet,&
bp_rsjet,&
bp_Qjet,&
bp_ntheta,&
bp_htheta,&
bp_rsjet2,&
bp_r0jet2,&
bp_rsjet3,&
bp_r0jet3,&
bp_rs,&
bp_r0,&
bp_rsinner,&
bp_r0inner,&
bp_npow2,&
bp_cpow2,&
bp_rbr,&
bp_x1br,&
fracphi);
1029 else if (defcoordlocal ==
UNI2LOG) {
1030 fscanf(in,
"%d",&
Nstar);
1035 dualfprintf(
fail_file,
"Shouldn't reach end of read_coord_parms: You set defcoordlocal=%d\n",defcoordlocal);
1045 MPI_Bcast(&
R0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1046 MPI_Bcast(&
Rin, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1047 MPI_Bcast(&
Rout, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1048 MPI_Bcast(&
hslope, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1049 MPI_Bcast(&
dofull2pi, 1, MPI_INT, MPIid[0], MPI_COMM_GRMHD);
1053 extern void read_coord_parms_mpi_user(
int defcoordlocal);
1054 read_coord_parms_mpi_user(defcoordlocal);
1064 else if (defcoordlocal ==
EQMIRROR) {
1069 MPI_Bcast(&
x2trans, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1070 MPI_Bcast(&
thetatores, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1071 MPI_Bcast(&
m2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1072 MPI_Bcast(&
d2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1073 MPI_Bcast(&
c2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1074 MPI_Bcast(&
m3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1075 MPI_Bcast(&
b3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1079 DIMENLOOP(dimen) MPI_Bcast(&
Rin_array[dimen], 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1083 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1084 MPI_Bcast(&
h0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1085 MPI_Bcast(&
hf, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1086 MPI_Bcast(&
rh0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1087 MPI_Bcast(&
myrout, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1088 MPI_Bcast(&
dmyhslope1dr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1089 MPI_Bcast(&
dmyhslope2dx1, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1090 MPI_Bcast(&
x1in, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1091 MPI_Bcast(&
x1out, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1094 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1095 MPI_Bcast(&
r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1096 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1097 MPI_Bcast(&
rpjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1100 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1101 MPI_Bcast(&
r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1102 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1103 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1104 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1105 MPI_Bcast(&
Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1108 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1109 MPI_Bcast(&
r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1110 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1111 MPI_Bcast(&
r0grid, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1112 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1113 MPI_Bcast(&
rjetend, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1114 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1115 MPI_Bcast(&
Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1117 MPI_Bcast(&
fracphi, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1118 MPI_Bcast(&
npow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1119 MPI_Bcast(&
cpow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1120 MPI_Bcast(&
rbr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1121 MPI_Bcast(&
x1br, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1122 MPI_Bcast(&
fracdisk, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1123 MPI_Bcast(&
fracjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1124 MPI_Bcast(&
r0disk, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1125 MPI_Bcast(&
rdiskend, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1126 MPI_Bcast(&
torusrmax_loc, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1127 MPI_Bcast(&
jetnu, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1128 MPI_Bcast(&
x10, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1129 MPI_Bcast(&
x20, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1132 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1133 MPI_Bcast(&
r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1134 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1135 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1136 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1137 MPI_Bcast(&
Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1138 MPI_Bcast(&
ntheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1139 MPI_Bcast(&
htheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1140 MPI_Bcast(&
rsjet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1141 MPI_Bcast(&
r0jet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1142 MPI_Bcast(&
rsjet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1143 MPI_Bcast(&
r0jet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1144 MPI_Bcast(&
rs, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1145 MPI_Bcast(&
r0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1146 MPI_Bcast(&
npow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1147 MPI_Bcast(&
cpow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1148 MPI_Bcast(&
rbr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1149 MPI_Bcast(&
x1br, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1150 MPI_Bcast(&
cpow3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1153 MPI_Bcast(&th_npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1154 MPI_Bcast(&th_r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1155 MPI_Bcast(&th_njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1156 MPI_Bcast(&th_r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1157 MPI_Bcast(&th_rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1158 MPI_Bcast(&th_Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1159 MPI_Bcast(&th_ntheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1160 MPI_Bcast(&th_htheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1161 MPI_Bcast(&th_rsjet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1162 MPI_Bcast(&th_r0jet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1163 MPI_Bcast(&th_rsjet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1164 MPI_Bcast(&th_r0jet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1165 MPI_Bcast(&th_rs, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1166 MPI_Bcast(&th_r0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1167 MPI_Bcast(&th_npow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1168 MPI_Bcast(&th_cpow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1169 MPI_Bcast(&th_rbr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1170 MPI_Bcast(&th_x1br, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1171 MPI_Bcast(&th_rbr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1172 MPI_Bcast(&th_h0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1173 MPI_Bcast(&th_njet1, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1175 else if (defcoordlocal ==
BPTHIN1) {
1176 MPI_Bcast(&
bp_npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1177 MPI_Bcast(&
bp_r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1178 MPI_Bcast(&
bp_njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1179 MPI_Bcast(&
bp_r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1180 MPI_Bcast(&
bp_rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1181 MPI_Bcast(&
bp_Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1182 MPI_Bcast(&
bp_ntheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1183 MPI_Bcast(&
bp_htheta, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1184 MPI_Bcast(&
bp_rsjet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1185 MPI_Bcast(&
bp_r0jet2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1186 MPI_Bcast(&
bp_rsjet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1187 MPI_Bcast(&
bp_r0jet3, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1188 MPI_Bcast(&
bp_rs, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1189 MPI_Bcast(&
bp_r0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1190 MPI_Bcast(&
bp_rsinner, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1191 MPI_Bcast(&
bp_r0inner, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1192 MPI_Bcast(&
bp_npow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1193 MPI_Bcast(&
bp_cpow2, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1194 MPI_Bcast(&
bp_rbr, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1195 MPI_Bcast(&
bp_x1br, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1196 MPI_Bcast(&
fracphi, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1199 MPI_Bcast(&
AAAA, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1200 MPI_Bcast(&
AAA, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1201 MPI_Bcast(&
BBB, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1202 MPI_Bcast(&
DDD, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1203 MPI_Bcast(&
ii0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1204 MPI_Bcast(&
CCCC, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1205 MPI_Bcast(&
Rj, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1207 MPI_Bcast(&
r1jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1208 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1209 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1210 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1211 MPI_Bcast(&
Qjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1214 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1215 MPI_Bcast(&
hinner, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1216 MPI_Bcast(&
houter, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1217 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1218 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1222 DIMENLOOP(dimen) MPI_Bcast(&
Rin_array[dimen], 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1226 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1229 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1230 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1231 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1232 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1235 MPI_Bcast(&
npow, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1236 MPI_Bcast(&
rs, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1237 MPI_Bcast(&
r0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1238 MPI_Bcast(&
h0, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1239 MPI_Bcast(&
r0jet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1240 MPI_Bcast(&
njet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1241 MPI_Bcast(&
rsjet, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1243 else if (defcoordlocal ==
UNI2LOG) {
1244 MPI_Bcast(&
Nstar, 1, MPI_INT, MPIid[0], MPI_COMM_GRMHD);
1245 MPI_Bcast(&
Rstar, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1246 MPI_Bcast(&
Afactor, 1, MPI_FTYPE, MPIid[0], MPI_COMM_GRMHD);
1249 dualfprintf(
fail_file,
"Shouldn't reach end of read_coord_parms MPI stuff: You set defcoordlocal=%d\n",defcoordlocal);
1264 FTYPE mysign,ts1,fnstar,myNrat;
1266 FTYPE myhslope1,myhslope2,myhslope;
1268 FTYPE th0,th0toprint,th2,switch0,switch2,switchinner0,switchinner2,switchrad0,switchrad2,thetasign,x2temp;
1269 FTYPE r,dtheta2dx1,dtheta2dx2,dtheta0dx2,dtheta0dx1,dswitch0dr,dswitch2dr;
1274 FTYPE ii,logform,radialarctan,thetaarctan;
1276 FTYPE theexp,theexp1,theexp2;
1294 dualfprintf(
fail_file,
"With log grid and R0SING must have R0<0 instead of %26.20g\n",
R0);
1298 if(X[1]>X0) V[1] =
R0+exp(X[1]) ;
1299 else V[1] = -(
R0+
R0*
R0*exp(-X[1])) ;
1303 V[1] =
R0+exp(X[1]) ;
1308 V[1] =
R0+exp(X[1]) ;
1315 V[2] = M_PI * X[2] + ((1. -
hslope) / 2.) * mysin(2. * M_PI * X[2]);
1319 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. -
hslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
1328 V[1] =
R0+exp(X[1]) ;
1337 V[2]=(
hslope*((X[2]-0.5)/0.5) + (1-
hslope)*pow((X[2]-0.5)/0.5, 7.0)+1.)*M_PI/2.;
1345 ((-49. *
hslope + 60. * M_PI) * X[2]) / 12. +
1346 ((247. *
hslope - 240. * M_PI) * pow(X[2],2)) / 12. +
1347 ((-83. *
hslope + 80. * M_PI) * pow(X[2],3)) / 2. -
1348 (5. * (-25. *
hslope + 24. * M_PI) * pow(X[2], 4)) / 3. +
1349 (2. * (-25. *
hslope + 24. * M_PI) * pow(X[2], 5)) / 3.;
1355 V[2] = M_PI* X[2] + ((1. -
hslope) / 2.) * sin(2. * M_PI * X[2]);
1361 V[2] = M_PI* X[2] + ((1. -
hslope) / 2.) * sin(2. * M_PI * X[2]);
1367 V[1] =
R0+exp(X[1]) ;
1368 V[2] = M_PI * X[2] + ((1. -
hslope) / 2.) * sin(2. * M_PI * X[2]);
1373 V[1] =
R0+exp(X[1]) ;
1375 V[2] = (
der0*X[2]*(-32.*pow(-1. + X[2],3.)*pow(X[2],2.)*(-1. + 2.*X[2]) -
1376 Ri*(-1. + X[2])*pow(-1. + 2.*X[2],3.)*
1377 (-1. + 7.*(-1. + X[2])*X[2])) +
1378 M_PI*
Ri*pow(X[2],3.)*(70. +
1379 3.*X[2]*(-105. + 2.*X[2]*(91. + 10.*X[2]*(-7. + 2.*X[2])))))/
Ri;
1386 V[1] =
R0+exp(X[1]) ;
1389 if(X[2]<0.5){ myx2=X[2]; flip1=0.0; flip2=1.0;}
1390 else{ myx2=1.0-X[2]; flip1=M_PI; flip2=-1.0;}
1393 V[2] = flip1+flip2*(
d2*pow(myx2,3.0)+
c2*pow(myx2,2.0)+
m2*myx2);
1396 V[2] = flip1+flip2*(
m3*myx2+
b3);
1403 V[1] =
R0+exp(X[1]) ;
1408 V[1] =
R0+exp(pow(X[1],
npow)) ;
1413 myhslope=(myhslope1+myhslope2)*0.5;
1414 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * sin(2. * M_PI * X[2]);
1419 V[1] =
R0+exp(pow(X[1],
npow)) ;
1421 myhslope=2.0-pow(V[1]/
r1jet,
njet*(-1.0+exp(1.0)/exp(V[1]+
rpjet)));
1423 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * sin(2. * M_PI * X[2]);
1428 V[1] =
R0+exp(pow(X[1],
npow)) ;
1433 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
1436 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
1444 vofx_sjetcoords( X, V );
1448 vofx_cylindrified( X, vofx_sjetcoords, V );
1454 #if(0) // no change in exponentiation
1456 V[1] =
R0+exp(pow(X[1],
npow)) ;
1463 V[1] =
R0+exp(theexp);
1475 switch0 = 0.5+1.0/M_PI*atan((V[1]-
rbr)/r0rbr);
1480 V[1] = V1*(1.0-switch0) + V2*switch0;
1486 FTYPE theta1,theta2,arctan2;
1492 theta1 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
1505 FTYPE localrbrr0=100.0;
1507 switch0 = 0.5+1.0/M_PI*atan((V[1]-localrbr)/localrbrr0);
1508 switch2 = 1.0-switch0;
1513 myhslope = myhslope1*switch2 + myhslope2*switch0;
1516 if(X[2]>1.0) myx2=2.0-X[2];
1517 else if(X[2]<0.0) myx2=-X[2];
1520 th2 = 0.5*M_PI*(1.0 + atan(myhslope*(myx2-0.5))/atan(myhslope*0.5));
1522 if(X[2]>1.0) th2=2.0*M_PI-th2;
1523 else if(X[2]<0.0) th2=-th2;
1529 myhslope = myhslope1*switch2 + myhslope2*switch0;
1533 th0 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
1537 FTYPE xi=((1. - myhslope) * 0.5);
1538 th0 = M_PI * .5 * (myhslope*(2.0*X[2]-1.0) + (1.0-myhslope)*pow(2.0*X[2]-1.0,3.0)+1.);
1543 switch0 = 0.5+1.0/M_PI*atan((V[1]-
rs)/
r0);
1544 switch2 = 1.0-switch0;
1547 theta1 = th0*switch2 + th2*switch0;
1555 arctan2 = 0.5 + 1.0/M_PI*(atan( (V[1]-
rsjet2)/
r0jet2) );
1558 V[2] = theta2 + arctan2*(theta1-theta2);
1567 #if(0) // no change in exponentiation
1577 V[1] =
R0+exp(theexp);
1593 V[1] = (
R0+exp(theexp1))*switchrad2 + (
R0+exp(theexp2))*switchrad0;
1605 FTYPE theta1,theta2,arctan2;
1611 theta1 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
1623 if(X[2]>1.0) myx2=2.0-X[2];
1624 else if(X[2]<0.0) myx2=-X[2];
1627 th2 = M_PI*.5*(.2*(2.0*myx2-1.0) + (1.0-.2)*pow(2.0*myx2-1,3.0)+1.0);
1629 if(X[2]>1.0) th2=2.0*M_PI-th2;
1630 else if(X[2]<0.0) th2=-th2;
1640 FTYPE xi=((1. - myhslope) * 0.5);
1656 th0 = M_PI * .5 * (.11875*(1.+(
bp_rsinner/V[1]))*(2.0*X[2]-1.0) +(1.0-.11875*(1.+(
bp_rsinner/V[1])))*pow(2.0*X[2]-1.0,9.0)+1.) ;
1662 switch0 = 0.5+1.0/M_PI*atan((V[1]-
bp_rs)/
bp_r0);
1663 switch2 = 0.5-1.0/M_PI*atan((V[1]-
bp_rs)/
bp_r0);
1666 theta1 = th0*switch2 + th2*switch0;
1678 V[2] = theta2 + arctan2*(theta1-theta2);
1693 radialarctan=(1.0/2.0) + (1.0/M_PI)*atan((ii-
ii0)/
CCCC);
1698 logform =
AAA*ii + exp(
BBB+
DDD*ii)*radialarctan;
1701 V[1] =
AAAA+exp(logform);
1710 thetaarctan=(1.0/2.0) + (1.0/M_PI)*atan((V[1]-
rsjet)/
r0jet);
1717 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
1720 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
1731 #if(0) // no change in exponentiation
1733 V[1] =
R0+exp(pow(X[1],th_npow)) ;
1736 theexp = th_npow*X[1];
1737 if( X[1] > th_x1br ) {
1738 theexp += th_cpow2 * pow(X[1]-th_x1br,th_npow2);
1740 V[1] =
R0+exp(theexp);
1752 FTYPE theta1,theta2,arctan2;
1757 myhslope=2.0-th_Qjet*pow(V[1]/th_r1jet,-th_njet*(0.5+1.0/M_PI*atan(V[1]/th_r0jet-th_rsjet/th_r0jet)));
1758 theta1 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
1770 myhslope=th_h0 + pow( (V[1]-th_rsjet3)/th_r0jet3 , th_njet);
1772 else myhslope=th_h0 + pow( (th_rbr-th_rsjet3)/th_r0jet3 , th_njet);
1775 if(X[2]>1.0) myx2=2.0-X[2];
1776 else if(X[2]<0.0) myx2=-X[2];
1779 th2 = 0.5*M_PI*(1.0 + atan(myhslope*(myx2-0.5))/atan(myhslope*0.5));
1781 if(X[2]>1.0) th2=2.0*M_PI-th2;
1782 else if(X[2]<0.0) th2=-th2;
1787 myhslope=2.0-th_Qjet*pow(V[1]/th_r1jet,-th_njet*(0.5+1.0/M_PI*atan(V[1]/th_r0jet-th_rsjet/th_r0jet)));
1789 else myhslope=2.0-th_Qjet*pow(th_rbr/th_r1jet,-th_njet*(0.5+1.0/M_PI*atan(th_rbr/th_r0jet-th_rsjet/th_r0jet)));
1794 th0 = M_PI * X[2] + ((1. - myhslope) * 0.5) * mysin(2. * M_PI * X[2]);
1798 FTYPE xi=((1. - myhslope) * 0.5);
1799 th0 = M_PI * .5 * (myhslope*(2.0*X[2]-1.0) + (1.0-myhslope)*pow(2.0*X[2]-1.0,9.0)+1.);
1803 switch0 = 0.5+1.0/M_PI*atan((V[1]-th_rs)/th_r0);
1804 switch2 = 0.5-1.0/M_PI*atan((V[1]-th_rs)/th_r0);
1807 theta1 = th0*switch2 + th2*switch0;
1812 theta2 = M_PI*0.5*(th_htheta*(2.0*X[2]-1.0)+(1.0-
th_htheta)*pow(2.0*X[2]-1.0,th_ntheta)+1.0);
1815 arctan2 = 0.5 + 1.0/M_PI*(atan( (V[1]-th_rsjet2)/th_r0jet2) );
1818 V[2] = theta2 + arctan2*(theta1-theta2);
1831 radialarctan=(1.0/2.0) + (1.0/M_PI)*atan((ii-
ii0)/
CCCC);
1836 logform =
AAA*ii + exp(
BBB+
DDD*ii)*radialarctan;
1839 V[1] =
AAAA+exp(logform);
1848 thetaarctan=(1.0/2.0) + (1.0/M_PI)*atan((V[1]-
rsjet)/
r0jet);
1855 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
1858 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
1868 V[1] =
R0+exp(pow(X[1],
npow)) ;
1873 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
1876 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
1900 V[1] =
R0+exp(pow(X[1],
npow)) ;
1904 if(X[2]>1.0) myx2=2.0-X[2];
1905 else if(X[2]<0.0) myx2=-X[2];
1908 V[2] = 0.5*M_PI*(1.0 + atan(myhslope*(myx2-0.5))/atan(myhslope*0.5));
1910 if(X[2]>1.0) V[2]=2.0*M_PI-V[2];
1911 else if(X[2]<0.0) V[2]=-V[2];
1926 dualfprintf(
fail_file,
"With log grid and R0SING must have R0<0 instead of %26.20g\n",
R0);
1930 if(X[1]>X0) V[1] =
R0+exp(X[1]) ;
1931 else V[1] = -(
R0+
R0*
R0*exp(-X[1])) ;
1935 V[1] =
R0+exp(X[1]) ;
1940 V[1] =
R0+exp(pow(X[1],
npow)) ;
1948 if(X[2]>1.0) myx2=2.0-X[2];
1949 else if(X[2]<0.0) myx2=-X[2];
1952 th2 = 0.5*M_PI*(1.0 + atan(myhslope*(myx2-0.5))/atan(myhslope*0.5));
1954 if(X[2]>1.0) th2=2.0*M_PI-th2;
1955 else if(X[2]<0.0) th2=-th2;
1961 th0 = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
1964 th0 = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
1968 switch0 = 0.5+1.0/M_PI*atan((V[1]-
rs)/
r0);
1969 switch2 = 0.5-1.0/M_PI*atan((V[1]-
rs)/
r0);
1971 FTYPE theta1,theta2,arctan2;
1974 theta1 = th0*switch2 + th2*switch0;
1980 arctan2 = 0.5 + 1.0/M_PI*(atan( (V[1]-
rsjet2)/
r0jet2) );
1983 V[2] = theta2 + arctan2*(theta1-theta2);
2004 myNrat = ts1/(fnstar+
SMALL);
2007 if(
Nstar==0 || fabs(X[1])>=1.0/myNrat ){
2021 V[1] = mysign*(
Rstar + BB*(fabs(X[1])*myNrat-1.0) + CC*(fabs(X[1])*myNrat-1.0)*(fabs(X[1])*myNrat-1.0) );
2038 V[2] = M_PI * X[2] + ((1. -
hslope) / 2.) * mysin(2. * M_PI * X[2]);
2042 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. -
hslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
2053 dualfprintf(
fail_file,
"Shouldn't reach end of bl_coord: defcoord=%d\n",
defcoord);
2079 if(V[2]<0) V[2] = -V[2];
2080 if(V[2]>M_PI) V[2]=2.0*M_PI-V[2];
2082 if(V[3]<0) V[3] = -V[3];
2083 if(V[3]>2.0*M_PI) V[3]=4.0*M_PI-V[3];
2088 #if( COORDSINGFIXCYL ) //SUPERSASMARK fix the singularity for the cylinrical coordinates
2135 FTYPE fac, faker, ror0nu;
2136 FTYPE fakerdisk, fakerjet;
2137 FTYPE rbeforedisk, rinsidedisk, rinsidediskmax, rafterdisk;
2139 #define DOIMPROVEJETCOORDS 1
2140 #if(DOIMPROVEJETCOORDS)
2141 FTYPE ror0nudisk, ror0nujet, thetadisk, thetajet;
2151 V[1] =
R0+exp(theexp);
2153 #if(0) //JON's method
2157 V[2] = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
2160 V[2] = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
2168 #if(USESJETLOGHOVERR)
2175 rinsidediskmax = 1.;
2179 fakerdisk = rbeforedisk * rinsidedisk * rafterdisk;
2183 #if( DOIMPROVEJETCOORDS )
2186 thetadisk =
thetaofx2( X[2], ror0nudisk );
2187 thetajet =
thetaofx2( X[2], ror0nujet );
2188 V[2] = fac*thetajet + (1 - fac)*thetadisk;
2190 faker = fac*fakerjet + (1 - fac)*fakerdisk -
rsjet*
Rin;
2219 theta = 0 + atan( tan((x2+1)*
M_PI_2l)/ror0nu );
2221 else if( x2 > 0.5 ) {
2222 theta = M_PI + atan( tan((x2-1)*
M_PI_2l)/ror0nu );
2245 dxdxp_analytic(X,V,
dxdxp);
2263 if(X[2]<
startx[2] || X[2]>endx2){
2284 FTYPE myhslope1,myhslope2,myhslope;
2285 FTYPE dmyhslopedr,dmyhslopedx1;
2288 FTYPE th0,th2,switch0,switch2;
2289 FTYPE r,dtheta2dx1,dtheta2dx2,dtheta0dx2,dtheta0dx1,dswitch0dr,dswitch2dr;
2292 FTYPE ii,logform,radialarctan,thetaarctan;
2307 dxdxp[2][2] = M_PI + (1. -
hslope) * M_PI * mycos(2. * M_PI * X[2]);
2310 dxdxp[2][2] = M_PI + (1. -
hslope) * M_PI * mycos(2. * M_PI * (1.0-X[2]) );
2312 dxdxp[3][3] = 2.0*M_PI;
2316 dxdxp[2][2]=M_PI/2.*( (
hslope * X[2])/0.5 + (7. * (1-
hslope))/(pow(0.5, 7.)) *pow(X[2]-0.5, 6.)) ;
2324 dxdxp[3][3] = 0.5*M_PI;
2329 dxdxp[2][2] = (-49. *
hslope + 60. * M_PI) / 12. +
2330 ((247. *
hslope - 240. * M_PI) * X[2]) / 6. +
2331 (3. * (-83. *
hslope + 80. * M_PI) * pow(X[2], 2)) / 2. -
2332 (20. * (-25. *
hslope + 24. * M_PI) * pow(X[2], 3)) / 3. +
2333 (10. * (-25. *
hslope + 24. * M_PI) * pow(X[2], 4)) / 3.;
2335 dxdxp[3][3] = 2.0*M_PI;
2338 dxdxp[2][2] = (
totalsize[2]==1) ? (2.0) : (M_PI + (1. -
hslope) * M_PI * cos(2. * M_PI * X[2]));
2339 dxdxp[3][3] = 2.0*M_PI;
2343 dxdxp[2][2] = M_PI + (1. -
hslope) * M_PI * cos(2. * M_PI * X[2]);
2344 dxdxp[3][3] = 2.0*M_PI;
2348 dxdxp[2][2] = (210.*M_PI*
Ri*pow(1. - 2.*X[2],2.)*pow(-1. + X[2],2.)*
2349 pow(X[2],2.) +
der0*
2350 (-32.*pow(-1. + X[2],2.)*pow(X[2],2.)*
2351 (3. + 14.*(-1. + X[2])*X[2]) -
2352 Ri*pow(1. - 2.*X[2],2.)*
2353 (-1. + 2.*(-1. + X[2])*X[2]*(2. + 49.*(-1. + X[2])*X[2]))))/
Ri;
2354 dxdxp[3][3] = 2.0*M_PI;
2360 if(X[2]<0.5){ myx2=X[2]; flip1=0.0; flip2=1.0;}
2361 else{ myx2=1.0-X[2]; flip1=M_PI; flip2=-1.0;}
2364 dxdxp[2][2] = (3.0*
d2*pow(myx2,2.0)+2.0*
c2*pow(myx2,1.0)+
m2);
2371 dxdxp[3][3] = 2.0*M_PI;
2389 myhslope=0.5*(myhslope1+myhslope2);
2391 dxdxp[2][2] = M_PI + (1. - myhslope) * M_PI * cos(2. * M_PI * X[2]);
2394 dxdxp[2][1] = -0.5*dmyhslopedx1* sin(2. * M_PI * X[2]);
2396 dxdxp[3][3] = 2.0*M_PI;
2403 myhslope=2.0-pow(V[1]/
r1jet,
njet*(-1.0+exp(1.0)/exp(V[1]+
rpjet)));
2405 dmyhslopedr=-((pow(exp(1.0),-V[1] -
rpjet)*myhslope*
njet*(-exp(1.0) + pow(exp(1.0),V[1] +
rpjet) + exp(1.0)*V[1]*log(V[1]/
r1jet)))/V[1]);
2406 dmyhslopedx1=dmyhslopedr*
dxdxp[1][1];
2408 dxdxp[2][2] = M_PI + (1. - myhslope) * M_PI * cos(2. * M_PI * X[2]);
2409 dxdxp[2][1] = -0.5*dmyhslopedx1* sin(2. * M_PI * X[2]);
2410 dxdxp[3][3] = 2.0*M_PI;
2421 dmyhslopedx1=dmyhslopedr*
dxdxp[1][1];
2424 dxdxp[2][2] = M_PI + (1. - myhslope) * M_PI * mycos(2. * M_PI * X[2]);
2425 dxdxp[2][1] = -0.5*dmyhslopedx1* mysin(2. * M_PI * X[2]);
2428 dxdxp[2][2] = M_PI + (1. - myhslope) * M_PI * mycos(2. * M_PI * (1.0-X[2]));
2429 dxdxp[2][1] = -0.5*dmyhslopedx1* (-mysin(2. * M_PI * (1.0-X[2])));
2433 dxdxp[3][3] = 2.0*M_PI;
2439 dualfprintf(
fail_file,
"Should not be computing JET6COORDS analytically\n");
2441 dxdxp[3][3] = 2.0*M_PI;
2444 dualfprintf(
fail_file,
"Should not be computing JET6COORDSTHIN analytically\n");
2446 dxdxp[3][3] = 2.0*M_PI;
2449 dualfprintf(
fail_file,
"Should not be computing BPTHIN1 analytically\n");
2451 dxdxp[3][3] = 2.0*M_PI;
2454 dualfprintf(
fail_file,
"Should not be computing JET5COORDS analytically\n");
2456 dxdxp[3][3] = 2.0*M_PI;
2460 dxdxp[1][1] =
npow*(V[1]-
R0)*pow(X[1],
npow-1.0);
2464 dmyhslopedx1=dmyhslopedr*dxdxp[1][1];
2466 dxdxp[2][2] = M_PI + (1. - myhslope) * M_PI * cos(2. * M_PI * X[2]);
2467 dxdxp[2][1] = -0.5*dmyhslopedx1* sin(2. * M_PI * X[2]);
2471 dxdxp[3][3] = 2.0*M_PI;
2497 dxdxp[1][1] =
npow*(V[1]-
R0)*pow(X[1],
npow-1.0);
2504 if(!finite(dmyhslopedr)){
2505 dualfprintf(
fail_file,
"Problem with dmyhslopedr=%g\n",dmyhslopedr);
2511 dmyhslopedx1=dmyhslopedr*dxdxp[1][1];
2514 if(X[2]>1.0) myx2=2.0-X[2];
2515 else if(X[2]<0.0) myx2=-X[2];
2522 dxdxp[2][2] = (2.0*M_PI*myhslope)/(atan(myhslope*0.5)*(4.0 + pow(1.0 - 2.0*myx2,2.0)*pow(myhslope,2.0)));
2533 dxdxp[2][1] = (M_PI*dmyhslopedx1*(
2534 (-4.0*atan((-0.5 + myx2)*myhslope))/(4. + pow(myhslope,2.)) +
2535 (4.*(-1. + 2.*myx2)*atan(myhslope/2.))/(4. + pow(1. - 2.*myx2,2.)*pow(myhslope,2.))
2537 )/(4.*pow(atan(myhslope/2.),2.));
2540 if(X[2]>1.0) dxdxp[2][1]*=-1.0;
2541 if(X[2]<0.0) dxdxp[2][1]*=-1.0;
2544 dxdxp[3][3] = 2.0*M_PI;
2559 if(X[2]>1.0) myx2=2.0-X[2];
2560 else if(X[2]<0.0) myx2=-X[2];
2563 th2 = 0.5*M_PI*(1.0 + atan(myhslope*(myx2-0.5))/atan(myhslope*0.5));
2565 if(X[2]>1.0) th2=2.0*M_PI-th2;
2566 else if(X[2]<0.0) th2=-th2;
2574 th0 = M_PI * X[2] + ((1. - myhslope) / 2.) * mysin(2. * M_PI * X[2]);
2577 th0 = M_PI - (M_PI * (1.0-X[2])) + ((1. - myhslope) / 2.) * (-mysin(2. * M_PI * (1.0-X[2])));
2581 switch0 = 0.5+1.0/M_PI*atan((V[1]-
rs)/
r0);
2582 switch2 = 0.5-1.0/M_PI*atan((V[1]-
rs)/
r0);
2588 dxdxp[1][1] =
npow*(V[1]-
R0)*pow(X[1],
npow-1.0);
2598 dtheta0dx2 = M_PI + (1. -
hslope) * M_PI * mycos(2. * M_PI * X[2]);
2601 dtheta0dx2 = M_PI + (1. -
hslope) * M_PI * mycos(2. * M_PI * (1.0-X[2]) );
2615 if(!finite(dmyhslopedr)){
2616 dualfprintf(
fail_file,
"Problem with dmyhslopedr=%g\n",dmyhslopedr);
2622 dmyhslopedx1=dmyhslopedr*dxdxp[1][1];
2625 if(X[2]>1.0) myx2=2.0-X[2];
2626 else if(X[2]<0.0) myx2=-X[2];
2631 dtheta2dx2 = (2.0*M_PI*myhslope)/(atan(myhslope*0.5)*(4.0 + pow(1.0 - 2.0*myx2,2.0)*pow(myhslope,2.0)));
2634 dtheta2dx1 = (M_PI*dmyhslopedx1*(
2635 (-4.0*atan((-0.5 + myx2)*myhslope))/(4. + pow(myhslope,2.)) +
2636 (4.*(-1. + 2.*myx2)*atan(myhslope/2.))/(4. + pow(1. - 2.*myx2,2.)*pow(myhslope,2.))
2638 )/(4.*pow(atan(myhslope/2.),2.));
2640 if(X[2]>1.0) dtheta2dx1*=-1.0;
2641 if(X[2]<0.0) dtheta2dx1*=-1.0;
2645 dswitch0dr=1.0/(M_PI*
r0*(1.0 + (r -
rs)*(r -
rs)/(
r0*
r0)));
2646 dswitch2dr=-dswitch0dr;
2649 dxdxp[2][2] = dtheta0dx2*switch2 + dtheta2dx2*switch0;
2652 dxdxp[2][1] = dtheta0dx1*switch2 + th0*dswitch2dr*dxdxp[1][1] + dtheta2dx1*switch0+th2*dswitch0dr*dxdxp[1][1] ;
2659 dxdxp[3][3] = 2.0*M_PI;
2677 #define GAMMIEDERIVATIVE 0
2678 #define NUMREC 1 // at present this is too slow since dxdxp is called many times. Could setup permenant memory space, but kinda stupid
2687 #define DXDERTYPE DIFFGAMMIE
2690 #if((REALTYPE==DOUBLETYPE)||(REALTYPE==FLOATTYPE))
2691 #define DXDELTA (MY1EM5)
2693 #elif(REALTYPE==LONGDOUBLETYPE)
2694 #define DXDELTA (MY1EM6)
2702 #define GENDXDELTA(k) (DXDELTA*Diffx[k])
2712 void donothing(
FTYPE *temp);
2732 failreturn=dfridr(blcoordsimple,ptrgeom,X,0,j,k,&(dxdxp[j][k]));
2752 for(l=0;l<
NDIM;l++){
2759 dxmachine[l] = temp-X[l];
2773 dxdxp[
j][k] = (Vh[
j] - Vl[
j]) / (Xh[k] - Xl[k]);
2784 dualfprintf(
fail_file,
"dxdxp[%d][%d]=%g is too small. Ensure SINGSMALL=%g < %g\n",j,k,dxdxp[j][k],
SINGSMALL,(Xh[k] - Xl[k]));
2793 void donothing(
FTYPE *temp)
2832 FTYPE x1max0, x1max,dxmax;
2835 const int ITERMAX = 100;
2842 extern void set_points_user(
void);
2952 for( iter = 0; iter < ITERMAX; iter++ ) {
2953 if( fabs((x1max - x1max0)/x1max) < RELACC ) {
2960 FTYPE dampingfactor=0.5;
2961 x1max = x1max0 + dampingfactor*dxmax;
2964 if( iter == ITERMAX ) {
2965 trifprintf(
"Error: iteration procedure for finding x1max has not converged: x1max = %g, dx1max/x1max = %g, iter = %d\n",
2966 x1max, (x1max-x1max0)/x1max, iter );
2970 trifprintf(
"x1max = %g (dx1max/x1max = %g, itno = %d)\n", x1max, (x1max-x1max0)/x1max, iter );
2991 trifprintf(
"ITERATIVE dx1: Rout=%26.20g R0=%26.20g npow=%26.20g cpow2=%26.20g cpow3=%26.20g npow2=%26.20g x1br=%26.20g rbr=%26.20g\n",
Rout,R0,
npow,
cpow2,
cpow3,
npow2,
x1br,
rbr);
3001 for( iter = 0; iter < ITERMAX; iter++ ) {
3005 if( fabs((x1max - x1max0)/x1max) < RELACC ) {
3019 dxmax=(
Rout-V0)/dVdx1;
3021 dualfprintf(
fail_file,
"dVdx1=%g V0=%g dxmax=%g x1max=%g x1max0=%g\n",dVdx1,V0,dxmax,x1max,x1max0);
3025 FTYPE dampingfactor=0.5;
3026 x1max = x1max0 + dampingfactor*dxmax;
3031 if( iter == ITERMAX ) {
3032 trifprintf(
"Error: iteration procedure for finding x1max has not converged: x1max = %g, dx1max/x1max = %g, iter = %d\n",
3033 x1max, (x1max-x1max0)/x1max, iter );
3037 trifprintf(
"x1max = %g (dx1max/x1max = %g, itno = %d)\n", x1max, (x1max-x1max0)/x1max, iter );
3047 startx[1] = pow(log(
Rin-R0),1.0/th_npow);
3057 trifprintf(
"ITERATIVE dx1: Rout=%26.20g R0=%26.20g npow=%26.20g cpow2=%26.20g npow2=%26.20g x1br=%26.20g rbr=%26.20g\n",
Rout,R0,th_npow,th_cpow2,th_npow2,th_x1br,th_rbr);
3059 if(
Rout < th_rbr ) {
3067 for( iter = 0; iter < ITERMAX; iter++ ) {
3071 if( fabs((x1max - x1max0)/x1max) < RELACC ) {
3075 dxmax= (pow( (log(
Rout-R0) - th_npow*x1max0)/th_cpow2, 1./th_npow2 ) +
th_x1br) - x1max0;
3078 FTYPE dampingfactor=0.5;
3079 x1max = x1max0 + dampingfactor*dxmax;
3083 if( iter == ITERMAX ) {
3084 trifprintf(
"Error: iteration procedure for finding x1max has not converged: x1max = %g, dx1max/x1max = %g, iter = %d\n",
3085 x1max, (x1max-x1max0)/x1max, iter );
3089 trifprintf(
"x1max = %g (dx1max/x1max = %g, itno = %d)\n", x1max, (x1max-x1max0)/x1max, iter );
3119 for( iter = 0; iter < ITERMAX; iter++ ) {
3123 if( fabs((x1max - x1max0)/x1max) < RELACC ) {
3130 FTYPE dampingfactor=0.5;
3131 x1max = x1max0 + dampingfactor*dxmax;
3135 if( iter == ITERMAX ) {
3136 trifprintf(
"Error: iteration procedure for finding x1max has not converged: x1max = %g, dx1max/x1max = %g, iter = %d\n",
3137 x1max, (x1max-x1max0)/x1max, iter );
3141 trifprintf(
"x1max = %g (dx1max/x1max = %g, itno = %d)\n", x1max, (x1max-x1max0)/x1max, iter );
3226 dualfprintf(
fail_file,
"Shouldn't reach end of set_points: defcoord=%d\n",
defcoord);
3255 #define MAXIHOR MAXBND
3256 #define FRACN1 (0.1)
3257 #define ADJUSTFRACT (0.25)
3289 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3293 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3297 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3301 return((
Rhor-ftemp*
Rout)/(1.0-ftemp));
3305 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3309 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3313 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3317 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3322 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3332 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3343 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3346 dualfprintf(
fail_file,
"ihoradjust=%26.20g totalsize[1]=%d Rhor=%26.20g R0=%26.20g npow=%26.20g Rout=%26.20g\n",ihoradjust,
totalsize[1],
Rhor,R0,
npow,
Rout);
3351 dualfprintf(
fail_file,
"setRin(): not implemented for SJETCOORDS\n" );
3358 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3364 dualfprintf(
fail_file,
"ihoradjust=%26.20g totalsize[1]=%d Rhor=%26.20g R0=%26.20g npow=%26.20g Rout=%26.20g\n",ihoradjust,
totalsize[1],
Rhor,R0,
npow,
Rout);
3372 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3374 else if(th_npow2>0){
3378 dualfprintf(
fail_file,
"ihoradjust=%26.20g totalsize[1]=%d Rhor=%26.20g R0=%26.20g npow=%26.20g Rout=%26.20g\n",ihoradjust,
totalsize[1],
Rhor,R0,th_npow,
Rout);
3379 return(R0+exp( pow((
totalsize[1]*pow(log(
Rhor-R0),1.0/th_npow) - ihoradjust*pow(log(
Rout-R0),1.0/th_npow))/(
totalsize[1]-ihoradjust),th_npow)));
3386 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3392 dualfprintf(
fail_file,
"ihoradjust=%21.15g totalsize[1]=%d Rhor=%21.15g R0=%21.15g bp_npow=%21.15g Rout=%21.15g\n",ihoradjust,
totalsize[1],
Rhor,R0,
bp_npow,
Rout);
3402 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3417 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3427 return(R0+pow((
Rhor-R0)/pow(
Rout-R0,ftemp),1.0/(1.0-ftemp)));
3435 dualfprintf(
fail_file,
"This grid's setRin is not setup defcoord=%d\n",
defcoord);
3464 else if (loc ==
FACE1) {
3474 else if (loc ==
FACE2) {
3485 else if (loc ==
FACE3) {
3495 else if (loc ==
CORN1) {
3509 else if (loc ==
CORN2) {
3524 else if (loc ==
CORN3) {
3538 else if (loc ==
CORNT) {
3586 else if (loc ==
FACE1) {
3591 else if (loc ==
FACE2) {
3596 else if (loc ==
FACE3) {
3601 else if (loc ==
CORN1) {
3606 else if (loc ==
CORN2) {
3611 else if (loc ==
CORN3) {
3616 else if (loc ==
CORNT) {
3649 else if (loc ==
FACE1) {
3659 else if (loc ==
FACE2) {
3670 else if (loc ==
FACE3) {
3680 else if (loc ==
CORN1) {
3694 else if (loc ==
CORN2) {
3709 else if (loc ==
CORN3) {
3723 else if (loc ==
CORNT) {
3755 void icoord(
FTYPE *X,
int loc,
int *i,
int *j,
int *k)
3758 *i = (int)((X[1]-
startx[1])/dx[1] - 0.5) ;
3759 *j = (int)((X[2]-
startx[2])/dx[2] - 0.5) ;
3760 *k = (int)((X[3]-
startx[3])/dx[3] - 0.5) ;
3773 #define INCLUDEROUND 0 // default
3777 #define INCLUDEROUND 1
3781 #if(REALTYPE==LONGDOUBLETYPE)
3783 #define INCLUDEROUND 1
3794 if(fabs(x-xfloor)>fabs(x-xceil))
return(xceil);
3795 else return(xfloor);
3801 return((
long int)
round(x));
3811 #if(REALTYPE==FLOATTYPE)
3813 #elif(REALTYPE==DOUBLETYPE || REALTYPE==LONGDOUBLETYPE)
3826 #if(REALTYPE==FLOATTYPE)
3828 #elif(REALTYPE==DOUBLETYPE)
3830 #elif(REALTYPE==LONGDOUBLETYPE)
3835 #define myround2int(x) (ROUND2INT(x))
3839 void icoord_round(
FTYPE *X,
int loc,
int *i,
int *j,
int *k)
3885 (
startpos[dimen]+ijk[dimen]<0 && dirsign==-1)
3947 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
3953 bl_coord_ijk_2(i, j, k, loc, X, V);
3957 dualfprintf(
fail_file,
"dxdxprim_ijk(): No X to compute V or dxdxp ijk=%d %d %d loc=%d\n",i,j,k,loc);
3987 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
3993 bl_coord_ijk_2(i, j, k, loc, X, V);
4030 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
4036 bl_coord_ijk_2(i, j, k, loc, X, V);
4041 dualfprintf(
fail_file,
"idxdxprim_ijk(): No X, V, or dxdxp to compute idxdxp\n");
4071 bl_coord_ijk_2(ptrgeom->i,ptrgeom->j,ptrgeom->k,ptrgeom->p,X,V);
4075 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
4082 bl_coord_ijk_2(ptrgeom->i,ptrgeom->j,ptrgeom->k,ptrgeom->p,X,V);
4113 if(i<-N1BND-SHIFT1 || i>
N1-1+
SHIFT1*2+N1BND || j<-N2BND-SHIFT2 || j>
N2-1+
SHIFT2*2+N2BND || k<-N3BND-SHIFT3 || k>
N3-1+
SHIFT3*2+N3BND){
4114 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
4121 coord(i, j, k, loc, X);
4125 dualfprintf(
fail_file,
"bl_coord_ijk(): No X to compute V : ijk=%d %d %d loc=%d\n",i,j,k,loc);
4135 void bl_coord_ijk_2(
int i,
int j,
int k,
int loc,
FTYPE *X,
FTYPE *V)
4153 if(i<-N1BND-SHIFT1 || i>
N1-1+
SHIFT1*2+N1BND || j<-N2BND-SHIFT2 || j>
N2-1+
SHIFT2*2+N2BND || k<-N3BND-SHIFT3 || k>
N3-1+
SHIFT3*2+N3BND){
4154 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
4200 if(i<-N1BND-SHIFT1 || i>
N1-1+
SHIFT1*2+N1BND || j<-N2BND-SHIFT2 || j>
N2-1+
SHIFT2*2+N2BND || k<-N3BND-SHIFT3 || k>
N3-1+
SHIFT3*2+N3BND){
4201 dualfprintf(
fail_file,
"Beyond stored location: %d %d %d\n",i,j,k);
4210 coord(i, j, k, loc, X);
4213 dualfprintf(
fail_file,
"coord_ijk() NOWHERE: Can't use loc=%d to compute X\n",loc);
4235 res = (64 + cos(5*M_PI*x) + 70*sin((M_PI*(-1 + 2*x))/2.) + 5*sin((3*M_PI*(-1 + 2*x))/2.))/128.;
4246 res = (x*ya)/xa + (-((x*ya)/xa) + ((x - xb)*(1 - yb))/(1 - xb) + yb)*
Ftr((x - xa)/(-xa + xb));
4256 res = ya + (yb-ya)*
Ftr( (x-xa)/(xb-xa) );
4272 res = (1 + x + (-140*sin((M_PI*(1 + x))/2.) + (10*sin((3*M_PI*(1 + x))/2.))/3. + (2*sin((5*M_PI*(1 + x))/2.))/5.)/(64.*M_PI))/2.;
4282 return( y0 - dxx *
Fangle(-(x-x0)/dxx) );
4288 return( y0 + dxx *
Fangle((x-x0)/dxx) );
4294 return(
limlin(f1, f2, df, f2) );
4300 return( -
mins(-f1, -f2, df) );
4311 return(
maxs(f1, f2, df) );
4314 return(
mins(f1, f2, df) );
4333 DLOOPA(dim) Xout[dim] = Xin[dim];
4336 ntimes = floor( (Xin[2]+2.0)/4.0 );
4338 Xout[2] -= 4 * ntimes;
4342 if( Xout[2] > 0. ) {
4344 *ismirrored = 1-*ismirrored;
4348 if( Xout[2] < -1. ) {
4349 Xout[2] = -2. - Xout[2];
4350 *ismirrored = 1-*ismirrored;
4363 DLOOPA(dim) Xc0[dim] = X[dim];
4370 return( V0[1] * sin(V0[2]) / Vc0[1] );
4383 DLOOPA(dim) X0c[dim] = X0[dim];
4390 return( V0[1] * sin(V0c[2]) / V[1] );
4407 DLOOPA(dim) Xc0[dim] = X[dim];
4411 DLOOPA(dim) Xcmid[dim] = X[dim];
4413 vofx( Xcmid, Vcmid );
4418 th0 = asin(
sinth0(X0, X, vofx) );
4420 res = (V[2] - Vc0[2])/(Vcmid[2] - Vc0[2]) * (Vcmid[2]-th0) + th0;
4440 int dim, ismirrored;
4457 DLOOPA(dim) Xtr[dim] = X[dim];
4458 Xtr[1] = log( 0.5*( exp(X0[1])+exp(
startx[1]) ) );
4461 f1 =
func1( X0, X, vofx );
4462 f2 =
func2( X0, X, vofx );
4463 dftr =
func2( X0, Xtr, vofx ) -
func1( X0, Xtr, vofx );
4466 sinth =
maxs( V[1]*f1, V[1]*f2, Vtr[1]*fabs(dftr)+
SMALL ) / V[1];
4471 DLOOPA(dim) Vout[dim] = Vin[dim];
4474 if( 0 == ismirrored ) {
4475 Vout[2] = Vin[2] + (th - V[2]);
4479 Vout[2] = Vin[2] - (th - V[2]);
4490 return( sin(V[2]) );
4500 FTYPE sth1in, sth2in, sth1inaxis, sth2inaxis;
4503 DLOOPA(dim) Xca[dim] = X[dim];
4509 sth2in = sin(
th2in(X0, X, vofx) );
4511 sth1inaxis =
sinth1in( X0, Xca, vofx );
4512 sth2inaxis = sin(
th2in(X0, Xca, vofx) );
4514 func2 =
minmaxs( sth1in, sth2in, fabs(sth2inaxis-sth1inaxis)+
SMALL, X[1] - X0[1] );