0001 #include <complex.h>
0002 #include <math.h>
0003 #include "mex.h"
0004
0005
0006
0007
0008
0009 struct raymagnetic {
0010 double *rn;
0011 double *drndY;
0012 double *d2rndY2;
0013 double *xn;
0014 double *dxndY;
0015 double *d2xndY2;
0016 double *yn;
0017 double *dyndY;
0018 double *d2yndY2;
0019 double *Brhon;
0020 double *dBrhondY;
0021 double *d2BrhondY2;
0022 double *Bsn;
0023 double *dBsndY;
0024 double *d2BsndY2;
0025 double *Bzn;
0026 double *dBzndY;
0027 double *d2BzndY2;
0028 double *B;
0029 double *dBdY;
0030 double *d2BdY2;
0031 double *salpha;
0032 double *dsalphadY;
0033 double *d2salphadY2;
0034 double *calpha;
0035 double *dcalphadY;
0036 double *d2calphadY2;
0037 double *gradrhon;
0038 double *dgradrhondY;
0039 double *d2gradrhondY2;
0040 double *rhorip;
0041 double *drhoripdY;
0042 double *d2rhoripdY2;
0043 double *Upsilonn;
0044 double *dUpsilonndY;
0045 double *d2UpsilonndY2;
0046 };
0047
0048
0049
0050 struct susceptibilitytensor {
0051 double complex *Xxx;
0052 double complex *Xxy;
0053 double complex *Xxz;
0054 double complex *Xyy;
0055 double complex *Xyz;
0056 double complex *Xzz;
0057 double complex *dXxxdNperp;
0058 double complex *dXxydNperp;
0059 double complex *dXxzdNperp;
0060 double complex *dXyydNperp;
0061 double complex *dXyzdNperp;
0062 double complex *dXzzdNperp;
0063 double complex *dXxxdNpar;
0064 double complex *dXxydNpar;
0065 double complex *dXxzdNpar;
0066 double complex *dXyydNpar;
0067 double complex *dXyzdNpar;
0068 double complex *dXzzdNpar;
0069 double complex *dXxxdY;
0070 double complex *dXxydY;
0071 double complex *dXxzdY;
0072 double complex *dXyydY;
0073 double complex *dXyzdY;
0074 double complex *dXzzdY;
0075 };
0076
0077 typedef struct raymagnetic raymagnetic_format;
0078 typedef struct susceptibilitytensor susceptibilitytensor_format;
0079
0080
0081 #define MC 8
0082 #define MAXCYCLHARM 101
0083 #define PI 3.14159265358979
0084
0085 void buildXstruc();
0086 void vacuumtensor();
0087 void coldtensor();
0088 void calcY();
0089 void calcY1();
0090 void Zdisp();
0091 void ZFriedConte();
0092 void hottensor();
0093 void Gamma();
0094 void modBessel();
0095 void imagBessel();
0096 void dawson();
0097 void smith();
0098 void weakrelativistictensor();
0099 void Shka();
0100 void ImShka();
0101 void Fdnest();
0102 void ImFdnest();
0103 int sgn();
0104
0105
0106 void vacuumtensor(X)
0107 susceptibilitytensor_format X;
0108 {
0109 int i;
0110
0111 X.Xxx[0] = 0.0;
0112 X.Xxy[0] = 0.0;
0113 X.Xxz[0] = 0.0;
0114 X.Xyy[0] = 0.0;
0115 X.Xyz[0] = 0.0;
0116 X.Xzz[0] = 0.0;
0117
0118 for (i = 0;i < MC;i++) {
0119 X.dXxxdY[i] = 0.0;
0120 X.dXxydY[i] = 0.0;
0121 X.dXxzdY[i] = 0.0;
0122 X.dXyydY[i] = 0.0;
0123 X.dXyzdY[i] = 0.0;
0124 X.dXzzdY[i] = 0.0;
0125 }
0126 }
0127
0128 void coldtensor(X,Nperp,dNperpdY,ns,ncyclharm,raymagnetic,Npar,dNpardY,wcn,dwcndY,wpn2,dwpn2dY,betath,dbetathdY)
0129 susceptibilitytensor_format X;
0130 double complex Nperp,dNperpdY[];
0131 int ns;
0132 int ncyclharm;
0133 raymagnetic_format raymagnetic;
0134 double wcn[],wpn2[],betath[];
0135 double dwcndY[][MC],dwpn2dY[][MC],dbetathdY[][MC];
0136 double Npar,dNpardY[];
0137
0138 {
0139 double complex Xxx[ns+1],Xxy[ns+1],Xxz[ns+1],Xyy[ns+1],Xyz[ns+1],Xzz[ns+1];
0140 double complex dXxxdNperp[ns+1],dXxydNperp[ns+1],dXxzdNperp[ns+1],dXyydNperp[ns+1],dXyzdNperp[ns+1],dXzzdNperp[ns+1];
0141 double complex dXxxdNpar[ns+1],dXxydNpar[ns+1],dXxzdNpar[ns+1],dXyydNpar[ns+1],dXyzdNpar[ns+1],dXzzdNpar[ns+1];
0142 double complex dXxxdbetath[ns+1],dXxydbetath[ns+1],dXxzdbetath[ns+1],dXyydbetath[ns+1],dXyzdbetath[ns+1],dXzzdbetath[ns+1];
0143 double complex dXxxdwcn[ns+1],dXxydwcn[ns+1],dXxzdwcn[ns+1],dXyydwcn[ns+1],dXyzdwcn[ns+1],dXzzdwcn[ns+1];
0144 double complex dXxxdwpn2[ns+1],dXxydwpn2[ns+1],dXxzdwpn2[ns+1],dXyydwpn2[ns+1],dXyzdwpn2[ns+1],dXzzdwpn2[ns+1];
0145
0146 int is,i;
0147
0148 calcY1(Nperp,dNperpdY,ns,ncyclharm,Npar,dNpardY,wcn,dwcndY,wpn2,dwpn2dY,betath,dbetathdY);
0149
0150 for (is = 0;is < ns + 1;is++) {
0151
0152
0153
0154 Xxx[is] = - wpn2[is]/(1.0 - wcn[is]*wcn[is]);
0155 Xxy[is] = I*wpn2[is]*wcn[is]/(1.0 - wcn[is]*wcn[is]);
0156 Xxz[is] = 0.0;
0157 Xyy[is] = - wpn2[is]/(1.0 - wcn[is]*wcn[is]);
0158 Xyz[is] = 0.0;
0159 Xzz[is] = - wpn2[is];
0160
0161
0162
0163 dXxxdNperp[is] = 0.0;
0164 dXxydNperp[is] = 0.0;
0165 dXxzdNperp[is] = 0.0;
0166 dXyydNperp[is] = 0.0;
0167 dXyzdNperp[is] = 0.0;
0168 dXzzdNperp[is] = 0.0;
0169
0170 dXxxdNpar[is] = 0.0;
0171 dXxydNpar[is] = 0.0;
0172 dXxzdNpar[is] = 0.0;
0173 dXyydNpar[is] = 0.0;
0174 dXyzdNpar[is] = 0.0;
0175 dXzzdNpar[is] = 0.0;
0176
0177 dXxxdbetath[is] = 0.0;
0178 dXxydbetath[is] = 0.0;
0179 dXxzdbetath[is] = 0.0;
0180 dXyydbetath[is] = 0.0;
0181 dXyzdbetath[is] = 0.0;
0182 dXzzdbetath[is] = 0.0;
0183
0184 dXxxdwcn[is] = -2.0*wpn2[is]*wcn[is]/(1.0 - wcn[is]*wcn[is])/(1.0 - wcn[is]*wcn[is]);
0185 dXxydwcn[is] = I*(2.0*wpn2[is]*wcn[is]*wcn[is]/(1 - wcn[is]*wcn[is])/(1.0 - wcn[is]*wcn[is]) + wpn2[is]/(1.0 - wcn[is]*wcn[is]));
0186 dXxzdwcn[is] = 0.0;
0187 dXyydwcn[is] = -2.0*wpn2[is]*wcn[is]/(1.0 - wcn[is]*wcn[is])/(1.0 - wcn[is]*wcn[is]);
0188 dXyzdwcn[is] = 0.0;
0189 dXzzdwcn[is] = 0.0;
0190
0191 dXxxdwpn2[is] = -1.0/(1.0 - wcn[is]*wcn[is]);
0192 dXxydwpn2[is] = I*wcn[is]/(1.0 - wcn[is]*wcn[is]);
0193 dXxzdwpn2[is] = 0.0;
0194 dXyydwpn2[is] = -1.0/(1.0 - wcn[is]*wcn[is]);
0195 dXyzdwpn2[is] = 0.0;
0196 dXzzdwpn2[is] = -1.0;
0197
0198 }
0199
0200 buildXstruc(X,dNperpdY,Xxx,Xxy,Xxz,Xyy,Xyz,Xzz,dXxxdNperp,dXxydNperp,dXxzdNperp,dXyydNperp,dXyzdNperp,dXzzdNperp,dXxxdNpar,dXxydNpar,dXxzdNpar,dXyydNpar,dXyzdNpar,dXzzdNpar,dXxxdbetath,dXxydbetath,dXxzdbetath,dXyydbetath,dXyzdbetath,dXzzdbetath,dXxxdwcn,dXxydwcn,dXxzdwcn,dXyydwcn,dXyzdwcn,dXzzdwcn,dXxxdwpn2,dXxydwpn2,dXxzdwpn2,dXyydwpn2,dXyzdwpn2,dXzzdwpn2,ns,dNpardY,dwcndY,dwpn2dY,dbetathdY);
0201 }
0202
0203
0204
0205 void calcY1(Nperp,dNperpdY,ns,ncyclharm,Npar,dNpardY,wcn,dwcndY,wpn2,dwpn2dY,betath,dbetathdY)
0206 double complex Nperp,dNperpdY[MC];
0207 int ns;
0208 int ncyclharm;
0209 double Npar,dNpardY[MC];
0210 double wcn[],dwcndY[][MC],wpn2[],dwpn2dY[][MC],betath[],dbetathdY[][MC];
0211 {
0212
0213 }
0214
0215
0216 void hottensor(X,Nperp,dNperpdY,ns,ncyclharm,raymagnetic,Npar,dNpardY,wcn,dwcndY,wpn2,dwpn2dY,betath,dbetathdY)
0217 susceptibilitytensor_format X;
0218 double complex Nperp,dNperpdY[];
0219 int ns;
0220 int ncyclharm;
0221 raymagnetic_format raymagnetic;
0222 double wcn[],wpn2[],betath[];
0223 double dwcndY[][MC],dwpn2dY[][MC],dbetathdY[][MC];
0224 double Npar,dNpardY[];
0225
0226 {
0227 double complex Xxx[ns+1],Xxy[ns+1],Xxz[ns+1],Xyy[ns+1],Xyz[ns+1],Xzz[ns+1];
0228 double complex dXxxdNperp[ns+1],dXxydNperp[ns+1],dXxzdNperp[ns+1],dXyydNperp[ns+1],dXyzdNperp[ns+1],dXzzdNperp[ns+1];
0229 double complex dXxxdNpar[ns+1],dXxydNpar[ns+1],dXxzdNpar[ns+1],dXyydNpar[ns+1],dXyzdNpar[ns+1],dXzzdNpar[ns+1];
0230 double complex dXxxdbetath[ns+1],dXxydbetath[ns+1],dXxzdbetath[ns+1],dXyydbetath[ns+1],dXyzdbetath[ns+1],dXzzdbetath[ns+1];
0231 double complex dXxxdwcn[ns+1],dXxydwcn[ns+1],dXxzdwcn[ns+1],dXyydwcn[ns+1],dXyzdwcn[ns+1],dXzzdwcn[ns+1];
0232 double complex dXxxdwpn2[ns+1],dXxydwpn2[ns+1],dXxzdwpn2[ns+1],dXyydwpn2[ns+1],dXyzdwpn2[ns+1],dXzzdwpn2[ns+1];
0233
0234 double Yxx[ns+1][2*ncyclharm+1],Yxy[ns+1][2*ncyclharm+1],Yxz[ns+1][2*ncyclharm+1],Yyy[ns+1][2*ncyclharm+1],Yyz[ns+1][2*ncyclharm+1],Yzz[ns+1][2*ncyclharm+1];
0235 double dYxxdNperp[ns+1][2*ncyclharm+1],dYxydNperp[ns+1][2*ncyclharm+1],dYxzdNperp[ns+1][2*ncyclharm+1],dYyydNperp[ns+1][2*ncyclharm+1],dYyzdNperp[ns+1][2*ncyclharm+1],dYzzdNperp[ns+1][2*ncyclharm+1];
0236 double dYxxdNpar[ns+1][2*ncyclharm+1],dYxydNpar[ns+1][2*ncyclharm+1],dYxzdNpar[ns+1][2*ncyclharm+1],dYyydNpar[ns+1][2*ncyclharm+1],dYyzdNpar[ns+1][2*ncyclharm+1],dYzzdNpar[ns+1][2*ncyclharm+1];
0237 double dYxxdbetath[ns+1][2*ncyclharm+1],dYxydbetath[ns+1][2*ncyclharm+1],dYxzdbetath[ns+1][2*ncyclharm+1],dYyydbetath[ns+1][2*ncyclharm+1],dYyzdbetath[ns+1][2*ncyclharm+1],dYzzdbetath[ns+1][2*ncyclharm+1];
0238 double dYxxdwcn[ns+1][2*ncyclharm+1],dYxydwcn[ns+1][2*ncyclharm+1],dYxzdwcn[ns+1][2*ncyclharm+1],dYyydwcn[ns+1][2*ncyclharm+1],dYyzdwcn[ns+1][2*ncyclharm+1],dYzzdwcn[ns+1][2*ncyclharm+1];
0239 double dYxxdwpn2[ns+1][2*ncyclharm+1],dYxydwpn2[ns+1][2*ncyclharm+1],dYxzdwpn2[ns+1][2*ncyclharm+1],dYyydwpn2[ns+1][2*ncyclharm+1],dYyzdwpn2[ns+1][2*ncyclharm+1],dYzzdwpn2[ns+1][2*ncyclharm+1];
0240
0241 double zeta,dzetadNperp,dzetadNpar,dzetadbetath,dzetadwcn,dzetadwpn2;
0242
0243 int is,i;
0244
0245 calcY(Nperp,dNperpdY,Yxx,Yxy,Yxz,Yyy,Yyz,Yzz,dYxxdNperp,dYxydNperp,dYxzdNperp,dYyydNperp,dYyzdNperp,dYzzdNperp,dYxxdNpar,dYxydNpar,dYxzdNpar,dYyydNpar,dYyzdNpar,dYzzdNpar,dYxxdbetath,dYxydbetath,dYxzdbetath,dYyydbetath,dYyzdbetath,dYzzdbetath,dYxxdwcn,dYxydwcn,dYxzdwcn,dYyydwcn,dYyzdwcn,dYzzdwcn,dYxxdwpn2,dYxydwpn2,dYxzdwpn2,dYyydwpn2,dYyzdwpn2,dYzzdwpn2,ns,ncyclharm,Npar,dNpardY,wcn,dwcndY,wpn2,dwpn2dY,betath,dbetathdY);
0246
0247 for (is = 0;is < ns + 1;is++) {
0248 Xxx[is] = 0.0;
0249 Xxy[is] = 0.0;
0250 Xxz[is] = 0.0;
0251 Xyy[is] = 0.0;
0252 Xyz[is] = 0.0;
0253 Xzz[is] = 0.0;
0254
0255 dXxxdNperp[is] = 0.0;
0256 dXxydNperp[is] = 0.0;
0257 dXxzdNperp[is] = 0.0;
0258 dXyydNperp[is] = 0.0;
0259 dXyzdNperp[is] = 0.0;
0260 dXzzdNperp[is] = 0.0;
0261
0262 dXxxdNpar[is] = 0.0;
0263 dXxydNpar[is] = 0.0;
0264 dXxzdNpar[is] = 0.0;
0265 dXyydNpar[is] = 0.0;
0266 dXyzdNpar[is] = 0.0;
0267 dXzzdNpar[is] = 0.0;
0268
0269 dXxxdbetath[is] = 0.0;
0270 dXxydbetath[is] = 0.0;
0271 dXxzdbetath[is] = 0.0;
0272 dXyydbetath[is] = 0.0;
0273 dXyzdbetath[is] = 0.0;
0274 dXzzdbetath[is] = 0.0;
0275
0276 dXxxdwcn[is] = 0.0;
0277 dXxydwcn[is] = 0.0;
0278 dXxzdwcn[is] = 0.0;
0279 dXyydwcn[is] = 0.0;
0280 dXyzdwcn[is] = 0.0;
0281 dXzzdwcn[is] = 0.0;
0282
0283 dXxxdwpn2[is] = 0.0;
0284 dXxydwpn2[is] = 0.0;
0285 dXxzdwpn2[is] = 0.0;
0286 dXyydwpn2[is] = 0.0;
0287 dXyzdwpn2[is] = 0.0;
0288 dXzzdwpn2[is] = 0.0;
0289 }
0290
0291 for (is = 0;is < ns + 1;is++) {
0292 for (i = -ncyclharm;i <= ncyclharm; i++) {
0293
0294 zeta = (1.0 - i*wcn[is])/fabs(Npar)*betath[is];
0295 dzetadNperp = 0.0;
0296 dzetadNpar = -sgn(Npar)*zeta/Npar;
0297 dzetadbetath = -zeta/betath[is];
0298 dzetadwcn = - i/fabs(Npar)*betath[is];
0299 dzetadwpn2 = 0.0;
0300
0301
0302
0303 Xxx[is] = Xxx[is] + wpn2[is]*zeta*Yxx[is][i];
0304 Xxy[is] = Xxy[is] + wpn2[is]*zeta*Yxy[is][i];
0305 Xxz[is] = Xxz[is] + wpn2[is]*zeta*Yxz[is][i];
0306 Xyy[is] = Xyy[is] + wpn2[is]*zeta*Yyy[is][i];
0307 Xyz[is] = Xyz[is] + wpn2[is]*zeta*Yyz[is][i];
0308 Xzz[is] = Xzz[is] + wpn2[is]*zeta*Yzz[is][i];
0309
0310
0311
0312 dXxxdNperp[is] = dXxxdNperp[is] + wpn2[is]*dzetadNperp*Yxx[is][i] + wpn2[is]*zeta*dYxxdNperp[is][i];
0313 dXxydNperp[is] = dXxydNperp[is] + wpn2[is]*dzetadNperp*Yxy[is][i] + wpn2[is]*zeta*dYxydNperp[is][i];
0314 dXxzdNperp[is] = dXxzdNperp[is] + wpn2[is]*dzetadNperp*Yxz[is][i] + wpn2[is]*zeta*dYxzdNperp[is][i];
0315 dXyydNperp[is] = dXyydNperp[is] + wpn2[is]*dzetadNperp*Yyy[is][i] + wpn2[is]*zeta*dYyydNperp[is][i];
0316 dXyzdNperp[is] = dXyzdNperp[is] + wpn2[is]*dzetadNperp*Yyz[is][i] + wpn2[is]*zeta*dYyzdNperp[is][i];
0317 dXzzdNperp[is] = dXzzdNperp[is] + wpn2[is]*dzetadNperp*Yzz[is][i] + wpn2[is]*zeta*dYzzdNperp[is][i];
0318
0319 dXxxdNpar[is] = dXxxdNpar[is] + wpn2[is]*dzetadNpar*Yxx[is][i] + wpn2[is]*zeta*dYxxdNpar[is][i];
0320 dXxydNpar[is] = dXxydNpar[is] + wpn2[is]*dzetadNpar*Yxy[is][i] + wpn2[is]*zeta*dYxydNpar[is][i];
0321 dXxzdNpar[is] = dXxzdNpar[is] + wpn2[is]*dzetadNpar*Yxz[is][i] + wpn2[is]*zeta*dYxzdNpar[is][i];
0322 dXyydNpar[is] = dXyydNpar[is] + wpn2[is]*dzetadNpar*Yyy[is][i] + wpn2[is]*zeta*dYyydNpar[is][i];
0323 dXyzdNpar[is] = dXyzdNpar[is] + wpn2[is]*dzetadNpar*Yyz[is][i] + wpn2[is]*zeta*dYyzdNpar[is][i];
0324 dXzzdNpar[is] = dXzzdNpar[is] + wpn2[is]*dzetadNpar*Yzz[is][i] + wpn2[is]*zeta*dYzzdNpar[is][i];
0325
0326 dXxxdbetath[is] = dXxxdbetath[is] + wpn2[is]*dzetadbetath*Yxx[is][i] + wpn2[is]*zeta*dYxxdbetath[is][i];
0327 dXxydbetath[is] = dXxydbetath[is] + wpn2[is]*dzetadbetath*Yxy[is][i] + wpn2[is]*zeta*dYxydbetath[is][i];
0328 dXxzdbetath[is] = dXxzdbetath[is] + wpn2[is]*dzetadbetath*Yxz[is][i] + wpn2[is]*zeta*dYxzdbetath[is][i];
0329 dXyydbetath[is] = dXyydbetath[is] + wpn2[is]*dzetadbetath*Yyy[is][i] + wpn2[is]*zeta*dYyydbetath[is][i];
0330 dXyzdbetath[is] = dXyzdbetath[is] + wpn2[is]*dzetadbetath*Yyz[is][i] + wpn2[is]*zeta*dYyzdbetath[is][i];
0331 dXzzdbetath[is] = dXzzdbetath[is] + wpn2[is]*dzetadbetath*Yzz[is][i] + wpn2[is]*zeta*dYzzdbetath[is][i];
0332
0333 dXxxdwcn[is] = dXxxdwcn[is] + wpn2[is]*dzetadwcn*Yxx[is][i] + wpn2[is]*zeta*dYxxdwcn[is][i];
0334 dXxydwcn[is] = dXxydwcn[is] + wpn2[is]*dzetadwcn*Yxy[is][i] + wpn2[is]*zeta*dYxydwcn[is][i];
0335 dXxzdwcn[is] = dXxzdwcn[is] + wpn2[is]*dzetadwcn*Yxz[is][i] + wpn2[is]*zeta*dYxzdwcn[is][i];
0336 dXyydwcn[is] = dXyydwcn[is] + wpn2[is]*dzetadwcn*Yyy[is][i] + wpn2[is]*zeta*dYyydwcn[is][i];
0337 dXyzdwcn[is] = dXyzdwcn[is] + wpn2[is]*dzetadwcn*Yyz[is][i] + wpn2[is]*zeta*dYyzdwcn[is][i];
0338 dXzzdwcn[is] = dXzzdwcn[is] + wpn2[is]*dzetadwcn*Yzz[is][i] + wpn2[is]*zeta*dYzzdwcn[is][i];
0339
0340 dXxxdwpn2[is] = dXxxdwpn2[is] + zeta*Yxx[is][i] + wpn2[is]*dzetadwpn2*Yxx[is][i] + wpn2[is]*zeta*dYxxdwpn2[is][i];
0341 dXxydwpn2[is] = dXxydwpn2[is] + zeta*Yxy[is][i] + wpn2[is]*dzetadwpn2*Yxy[is][i] + wpn2[is]*zeta*dYxydwpn2[is][i];
0342 dXxzdwpn2[is] = dXxzdwpn2[is] + zeta*Yxz[is][i] + wpn2[is]*dzetadwpn2*Yxz[is][i] + wpn2[is]*zeta*dYxzdwpn2[is][i];
0343 dXyydwpn2[is] = dXyydwpn2[is] + zeta*Yyy[is][i] + wpn2[is]*dzetadwpn2*Yyy[is][i] + wpn2[is]*zeta*dYyydwpn2[is][i];
0344 dXyzdwpn2[is] = dXyzdwpn2[is] + zeta*Yyz[is][i] + wpn2[is]*dzetadwpn2*Yyz[is][i] + wpn2[is]*zeta*dYyzdwpn2[is][i];
0345 dXzzdwpn2[is] = dXzzdwpn2[is] + zeta*Yzz[is][i] + wpn2[is]*dzetadwpn2*Yzz[is][i] + wpn2[is]*zeta*dYzzdwpn2[is][i];
0346 }
0347 }
0348
0349 buildXstruc(X,dNperpdY,Xxx,Xxy,Xxz,Xyy,Xyz,Xzz,dXxxdNperp,dXxydNperp,dXxzdNperp,dXyydNperp,dXyzdNperp,dXzzdNperp,dXxxdNpar,dXxydNpar,dXxzdNpar,dXyydNpar,dXyzdNpar,dXzzdNpar,dXxxdbetath,dXxydbetath,dXxzdbetath,dXyydbetath,dXyzdbetath,dXzzdbetath,dXxxdwcn,dXxydwcn,dXxzdwcn,dXyydwcn,dXyzdwcn,dXzzdwcn,dXxxdwpn2,dXxydwpn2,dXxzdwpn2,dXyydwpn2,dXyzdwpn2,dXzzdwpn2,ns,dNpardY,dwcndY,dwpn2dY,dbetathdY);
0350 }
0351
0352
0353 void calcY(Nperp,dNperpdY,Yxx,Yxy,Yxz,Yyy,Yyz,Yzz,dYxxdNperp,dYxydNperp,dYxzdNperp,dYyydNperp,dYyzdNperp,dYzzdNperp,dYxxdNpar,dYxydNpar,dYxzdNpar,dYyydNpar,dYyzdNpar,dYzzdNpar,dYxxdbetath,dYxydbetath,dYxzdbetath,dYyydbetath,dYyzdbetath,dYzzdbetath,dYxxdwcn,dYxydwcn,dYxzdwcn,dYyydwcn,dYyzdwcn,dYzzdwcn,dYxxdwpn2,dYxydwpn2,dYxzdwpn2,dYyydwpn2,dYyzdwpn2,dYzzdwpn2,ns,ncyclharm,Npar,dNpardY,wcn,dwcndY,wpn2,dwpn2dY,betath,dbetathdY)
0354 double complex Nperp,dNperpdY[MC];
0355 double complex Yxx[][MAXCYCLHARM],Yxy[][MAXCYCLHARM],Yxz[][MAXCYCLHARM],Yyy[][MAXCYCLHARM],Yyz[][MAXCYCLHARM],Yzz[][MAXCYCLHARM];
0356 double complex dYxxdNperp[][MAXCYCLHARM],dYxydNperp[][MAXCYCLHARM],dYxzdNperp[][MAXCYCLHARM],dYyydNperp[][MAXCYCLHARM],dYyzdNperp[][MAXCYCLHARM],dYzzdNperp[][MAXCYCLHARM];
0357 double complex dYxxdNpar[][MAXCYCLHARM],dYxydNpar[][MAXCYCLHARM],dYxzdNpar[][MAXCYCLHARM],dYyydNpar[][MAXCYCLHARM],dYyzdNpar[][MAXCYCLHARM],dYzzdNpar[][MAXCYCLHARM];
0358 double complex dYxxdbetath[][MAXCYCLHARM],dYxydbetath[][MAXCYCLHARM],dYxzdbetath[][MAXCYCLHARM],dYyydbetath[][MAXCYCLHARM],dYyzdbetath[][MAXCYCLHARM],dYzzdbetath[][MAXCYCLHARM];
0359 double complex dYxxdwcn[][MAXCYCLHARM],dYxydwcn[][MAXCYCLHARM],dYxzdwcn[][MAXCYCLHARM],dYyydwcn[][MAXCYCLHARM],dYyzdwcn[][MAXCYCLHARM],dYzzdwcn[][MAXCYCLHARM];
0360 double complex dYxxdwpn2[][MAXCYCLHARM],dYxydwpn2[][MAXCYCLHARM],dYxzdwpn2[][MAXCYCLHARM],dYyydwpn2[][MAXCYCLHARM],dYyzdwpn2[][MAXCYCLHARM],dYzzdwpn2[][MAXCYCLHARM];
0361 int ns;
0362 int ncyclharm;
0363 double Npar,dNpardY[MC];
0364 double wcn[],dwcndY[][MC],wpn2[],dwpn2dY[][MC],betath[],dbetathdY[][MC];
0365 {
0366 double zeta,dzetadNperp,dzetadNpar,dzetadbetath,dzetadwcn,dzetadwpn2;
0367 double complex lambda,dlambdadNperp,dlambdadNpar,dlambdadbetath,dlambdadwcn,dlambdadwpn2;
0368 double complex Z,Zp,Zpp,G,Gp,Gpp;
0369 double sigmas;
0370
0371 int is,i;
0372
0373 if (2*ncyclharm+1 > MAXCYCLHARM) {mexPrintf("******** WARNING: the code is limited to 50 cylotron harmonics only ! ********");}
0374
0375 for (is = 0;is < ns + 1;is++) {
0376
0377 sigmas = sgn(-1.0+2.0*is);
0378
0379 for (i = -ncyclharm;i <= ncyclharm; i++) {
0380
0381 zeta = (1.0 - i*wcn[is])/fabs(Npar)*betath[is];
0382 dzetadNperp = 0.0;
0383 dzetadNpar = -sgn(Npar)*zeta/Npar;
0384 dzetadbetath = -zeta/betath[is];
0385 dzetadwcn = - i/fabs(Npar)*betath[is];
0386 dzetadwpn2 = 0.0;
0387
0388 lambda = Nperp*betath[is]/wcn[is];
0389 dlambdadNperp = betath[is]/wcn[is];
0390 dlambdadNpar = 0.0;
0391 dlambdadbetath = Nperp/wcn[is];
0392 dlambdadwcn = - lambda/wcn[is];
0393 dlambdadwpn2 = 0.0;
0394
0395 Zdisp((double complex)zeta,&Z,&Zp,&Zpp);
0396 Gamma(lambda,&G,&Gp,&Gpp,(double)i);
0397
0398
0399
0400 Yxx[is][i] = i*i*G*Z/lambda;
0401 Yxy[is][i] = I*sigmas*i*Gp*Z;
0402 Yxz[is][i] = -sgn(Npar)*i*G*Zp/sqrt(2.0*lambda);
0403 Yyy[is][i] = (i*i*G/lambda - 2.0*lambda*Gp)*Z;
0404 Yyz[is][i] = I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gp*Zp;
0405 Yzz[is][i] = -G*zeta*Zp;
0406
0407
0408
0409 dYxxdNperp[is][i] = i*i*Gp*dlambdadNperp*Z/lambda + i*i*G*Zp*dzetadNperp - i*i*G*Z*dlambdadNperp/lambda/lambda;
0410 dYxydNperp[is][i] = I*sigmas*i*Gpp*dlambdadNperp*Z + I*sigmas*i*Gp*Zp*dzetadNperp;
0411 dYxzdNperp[is][i] = -sgn(Npar)*i*Gp*dlambdadNperp*Zp/sqrt(2.0*lambda) - sgn(Npar)*i*G*Zpp*dzetadNperp/sqrt(2.0*lambda) + sgn(Npar)*i*G*Zp*dlambdadNperp/sqrt(2.0*lambda)/(2.0*lambda);
0412 dYyydNperp[is][i] = (i*i*Gp*dlambdadNperp/lambda - i*i*G*dlambdadNperp/lambda/lambda - 2.0*dlambdadNperp*Gp - 2.0*lambda*dlambdadNperp*Gpp)*Z + (i*i*G/lambda - 2.0*lambda*Gp)*Zp*dzetadNperp;
0413 dYyzdNperp[is][i] = I*sigmas*sgn(Npar)*dlambdadNperp*Gp*Zp/sqrt(lambda/2.0)/4.0 + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gpp*dlambdadNperp*Zp + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gp*Zpp*dzetadNperp;
0414 dYzzdNperp[is][i] = -Gp*dlambdadNperp*zeta*Zp - G*dzetadNperp*Zp - G*zeta*Zpp*dzetadNperp;
0415
0416 dYxxdNpar[is][i] = i*i*Gp*dlambdadNpar*Z/lambda + i*i*G*Zp*dzetadNpar - i*i*G*Z*dlambdadNpar/lambda/lambda;
0417 dYxydNpar[is][i] = I*sigmas*i*Gpp*dlambdadNpar*Z + I*sigmas*i*Gp*Zp*dzetadNpar;
0418 dYxzdNpar[is][i] = -sgn(Npar)*i*Gp*dlambdadNpar*Zp/sqrt(2.0*lambda) - sgn(Npar)*i*G*Zpp*dzetadNpar/sqrt(2.0*lambda) + sgn(Npar)*i*G*Zp*dlambdadNpar/sqrt(2.0*lambda)/(2.0*lambda);
0419 dYyydNpar[is][i] = (i*i*Gp*dlambdadNpar/lambda - i*i*G*dlambdadNpar/lambda/lambda - 2.0*dlambdadNpar*Gp - 2.0*lambda*dlambdadNpar*Gpp)*Z + (i*i*G/lambda - 2.0*lambda*Gp)*Zp*dzetadNpar;
0420 dYyzdNpar[is][i] = I*sigmas*sgn(Npar)*dlambdadNpar*Gp*Zp/sqrt(lambda/2.0)/4.0 + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gpp*dlambdadNpar*Zp + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gp*Zpp*dzetadNpar;
0421 dYzzdNpar[is][i] = -Gp*dlambdadNpar*zeta*Zp - G*dzetadNpar*Zp - G*zeta*Zpp*dzetadNpar;
0422
0423 dYxxdbetath[is][i] = i*i*Gp*dlambdadbetath*Z/lambda + i*i*G*Zp*dzetadbetath - i*i*G*Z*dlambdadbetath/lambda/lambda;
0424 dYxydbetath[is][i] = I*sigmas*i*Gpp*dlambdadbetath*Z + I*sigmas*i*Gp*Zp*dzetadbetath;
0425 dYxzdbetath[is][i] = -sgn(Npar)*i*Gp*dlambdadbetath*Zp/sqrt(2.0*lambda) - sgn(Npar)*i*G*Zpp*dzetadbetath/sqrt(2.0*lambda) + sgn(Npar)*i*G*Zp*dlambdadbetath/sqrt(2.0*lambda)/(2.0*lambda);
0426 dYyydbetath[is][i] = (i*i*Gp*dlambdadbetath/lambda - i*i*G*dlambdadbetath/lambda/lambda - 2.0*dlambdadbetath*Gp - 2.0*lambda*dlambdadbetath*Gpp)*Z + (i*i*G/lambda - 2.0*lambda*Gp)*Zp*dzetadbetath;
0427 dYyzdbetath[is][i] = I*sigmas*sgn(Npar)*dlambdadbetath*Gp*Zp/sqrt(lambda/2.0)/4.0 + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gpp*dlambdadbetath*Zp + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gp*Zpp*dzetadbetath;
0428 dYzzdbetath[is][i] = -Gp*dlambdadbetath*zeta*Zp - G*dzetadbetath*Zp - G*zeta*Zpp*dzetadbetath;
0429
0430 dYxxdwcn[is][i] = i*i*Gp*dlambdadwcn*Z/lambda + i*i*G*Zp*dzetadwcn - i*i*G*Z*dlambdadwcn/lambda/lambda;
0431 dYxydwcn[is][i] = I*sigmas*i*Gpp*dlambdadwcn*Z + I*sigmas*i*Gp*Zp*dzetadwcn;
0432 dYxzdwcn[is][i] = -sgn(Npar)*i*Gp*dlambdadwcn*Zp/sqrt(2.0*lambda) - sgn(Npar)*i*G*Zpp*dzetadwcn/sqrt(2.0*lambda) + sgn(Npar)*i*G*Zp*dlambdadwcn/sqrt(2.0*lambda)/(2.0*lambda);
0433 dYyydwcn[is][i] = (i*i*Gp*dlambdadwcn/lambda - i*i*G*dlambdadwcn/lambda/lambda - 2.0*dlambdadwcn*Gp - 2.0*lambda*dlambdadwcn*Gpp)*Z + (i*i*G/lambda - 2.0*lambda*Gp)*Zp*dzetadwcn;
0434 dYyzdwcn[is][i] = I*sigmas*sgn(Npar)*dlambdadwcn*Gp*Zp/sqrt(lambda/2.0)/4.0 + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gpp*dlambdadwcn*Zp + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gp*Zpp*dzetadwcn;
0435 dYzzdwcn[is][i] = -Gp*dlambdadwcn*zeta*Zp - G*dzetadwcn*Zp - G*zeta*Zpp*dzetadwcn;
0436
0437 dYxxdwpn2[is][i] = i*i*Gp*dlambdadwpn2*Z/lambda + i*i*G*Zp*dzetadwpn2 - i*i*G*Z*dlambdadwpn2/lambda/lambda;
0438 dYxydwpn2[is][i] = I*sigmas*i*Gpp*dlambdadwpn2*Z + I*sigmas*i*Gp*Zp*dzetadwpn2;
0439 dYxzdwpn2[is][i] = -sgn(Npar)*i*Gp*dlambdadwpn2*Zp/sqrt(2.0*lambda) - sgn(Npar)*i*G*Zpp*dzetadwpn2/sqrt(2.0*lambda) + sgn(Npar)*i*G*Zp*dlambdadwpn2/sqrt(2.0*lambda)/(2.0*lambda);
0440 dYyydwpn2[is][i] = (i*i*Gp*dlambdadwpn2/lambda - i*i*G*dlambdadwpn2/lambda/lambda - 2.0*dlambdadwpn2*Gp - 2.0*lambda*dlambdadwpn2*Gpp)*Z + (i*i*G/lambda - 2.0*lambda*Gp)*Zp*dzetadwpn2;
0441 dYyzdwpn2[is][i] = I*sigmas*sgn(Npar)*dlambdadwpn2*Gp*Zp/sqrt(lambda/2.0)/4.0 + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gpp*dlambdadwpn2*Zp + I*sigmas*sgn(Npar)*sqrt(lambda/2.0)*Gp*Zpp*dzetadwpn2;
0442 dYzzdwpn2[is][i] = -Gp*dlambdadwpn2*zeta*Zp - G*dzetadwpn2*Zp - G*zeta*Zpp*dzetadwpn2;
0443 }
0444 }
0445 }
0446
0447 void Gamma(z,g,gp,gpp,nhu)
0448 double complex z,*g,*gp,*gpp;
0449 int nhu;
0450 {
0451 double complex mBn,mBnp,mBnpp;
0452
0453 modBessel(z,&mBn,&mBnp,&mBnpp,nhu);
0454
0455 g[0] = cexp(-z)*mBn;
0456 gp[0] = -g[0] + cexp(-z)*mBnp;
0457 gpp[0] = g[0] - cexp(-z)*(2.0*mBnp - mBnpp);
0458
0459 }
0460
0461
0462 void Zdisp(z,Z,Zp,Zpp)
0463 double complex z;
0464 double complex *Z,*Zp,*Zpp;
0465 {
0466
0467 ZFriedConte(z,Z);
0468
0469 Zp[0] = -2.0*(1.0 + z*Z[0]);
0470 Zpp[0] = 4.0*z + Z[0]*(4*z*z - 2.0);
0471 }
0472
0473 void ZFriedConte(z,Z)
0474 double complex z;
0475 double complex *Z;
0476 {
0477 double daw,x,y;
0478 if (cimag(z) == 0.0) {
0479 x = creal(z);
0480 dawson(x,&daw);
0481 Z[0]=-2.0*daw+I*sqrt(PI)*exp(x*x);
0482 } else if (creal(z) == 0.0) {
0483 y = cimag(z);
0484 Z[0] = I*sqrt(PI)*exp(y*y)*erfc(-y);
0485 } else {
0486 smith(z,Z);
0487 }
0488 }
0489
0490
0491 void modBessel(z,mBn,mBnp,mBnpp,nhu)
0492 double complex z,*mBn,*mBnp,*mBnpp;
0493 double nhu;
0494 {
0495 double complex iBn,iBnp,iBnpp;
0496
0497 imagBessel(I*z,&iBn,&iBnp,&iBnpp,nhu);
0498
0499 mBn[0] = cpow(-I,nhu)*iBn;
0500 mBnp[0] = -cpow(-I,nhu+1.0)*iBnp;
0501 mBnpp[0] = -cpow(-I,nhu)*iBnpp;
0502
0503
0504
0505 }
0506
0507
0508
0509 void imagBessel(z,iBn,iBnp,iBnpp,nhu)
0510 double complex z,*iBn,*iBnp,*iBnpp;
0511 double nhu;
0512
0513 {
0514 mxArray *rhs[3], *lhs[1];
0515
0516 double *pr,*pi;
0517 double complex Besseln,Besselnm1,Besselnm2;
0518 double *Bessel_r,*Bessel_i;
0519
0520 rhs[0] = mxCreateString("J");
0521 rhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
0522 rhs[2] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);
0523
0524 pr = mxGetPr(rhs[2]);
0525 pr[0] = creal(z);
0526 pi = mxGetPi(rhs[2]);
0527 pi[0] = cimag(z);
0528
0529 pr = mxGetPr(rhs[1]);
0530 pr[0] = nhu;
0531 mexCallMATLAB(1,lhs,3,rhs,"besselmx");
0532 Bessel_r = mxGetData(lhs[0]);
0533 Bessel_i = mxGetImagData(lhs[0]);
0534 Besseln = Bessel_r[0] + I*Bessel_i[0];
0535
0536
0537
0538 pr = mxGetPr(rhs[1]);
0539 pr[0] = nhu - 1.0;
0540 mexCallMATLAB(1,lhs,3,rhs,"besselmx");
0541 Bessel_r = mxGetData(lhs[0]);
0542 Bessel_i = mxGetImagData(lhs[0]);
0543 Besselnm1 = Bessel_r[0] + I*Bessel_i[0];
0544
0545
0546
0547
0548 pr = mxGetPr(rhs[1]);
0549 pr[0] = nhu - 2.0;
0550 mexCallMATLAB(1,lhs,3,rhs,"besselmx");
0551 Bessel_r = mxGetData(lhs[0]);
0552 Bessel_i = mxGetImagData(lhs[0]);
0553 Besselnm2 = Bessel_r[0] + I*Bessel_i[0];
0554
0555
0556
0557 iBn[0] = Besseln;
0558 iBnp[0] = Besselnm1 - nhu*Besseln/z;
0559 iBnpp[0] = Besselnm2 + (2.0*nhu - 1.0)*Besselnm1/z + nhu*(nhu + 1.0)*Besseln/z/z;
0560
0561
0562
0563 mxDestroyArray(rhs[0]);
0564 mxDestroyArray(rhs[1]);
0565 mxDestroyArray(rhs[2]);
0566 mxDestroyArray(lhs[0]);
0567 }
0568
0569
0570
0571 void smith(z,Z)
0572 double complex z, *Z;
0573 {
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591 double complex z2, z_2, som, ZZ;
0592 double rz,iz;
0593 double criterion, sigma;
0594 int nn;
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604 static double b=5.51;
0605 static double nmax1=75;
0606 static double nmax2=34;
0607 static double nmax3=27;
0608 static double complex czero = 0.0;
0609 static double complex cone = 1.0;
0610 static double complex isqrtpi = I*1.772453850905516;
0611
0612 z2 = z*z;
0613 som = czero;
0614 rz = fabs(creal(z));
0615 iz = fabs(cimag(z));
0616
0617
0618
0619 if ((rz <= b) & (iz <= 2.0-1.5*rz/b)) {
0620 for (nn = nmax1;nn > 0;nn--) {
0621 som = 1.0/nn*z2*1.0/(2.0*nn + 1.0 + som);
0622 }
0623 ZZ = cexp(-z2)*(isqrtpi - 2.0*z*(som + 1.0));
0624 }
0625
0626
0627
0628 if (((rz <= b) & (iz > 2.0-1.5*rz/b)) | ((rz > b) & (iz > 0.5))) {
0629
0630 z_2 = cone/z2;
0631 for (nn = nmax2;nn > 0;nn--) {
0632 som = -0.5*nn*z_2/(som + 1.0);
0633 }
0634 ZZ = -1.0/(z*(som + 1.0));
0635 if (cimag(z) < 0.0) {
0636 ZZ = ZZ + 2.0*isqrtpi*cexp(-z2);
0637 }
0638 }
0639
0640
0641 if ((rz > b) & (iz <= 0.5)) {
0642 z_2 = cone/z2;
0643 for (nn = nmax3;nn > 0;nn--) {
0644 som = (nn-0.5)*z_2*(som + 1.0);
0645 }
0646 ZZ = -(som + 1.0)/z;
0647 criterion = 0.7853981633974483331/rz;
0648 sigma = (cimag(z) < criterion) + (cimag(z) < -criterion);
0649 if (sigma > 0.0) {
0650 ZZ = ZZ + sigma*isqrtpi*cexp(-z2);
0651 }
0652 }
0653
0654 Z[0] = ZZ;
0655 }
0656
0657
0658
0659 void dawson(zeta,dwork)
0660 double zeta;
0661 double *dwork;
0662 {
0663
0664
0665
0666
0667
0668
0669
0670 static double half = 0.5;
0671 static double one = 1.0;
0672 static double two = 2.0;
0673 static double ten = 10.0;
0674
0675
0676
0677
0678
0679
0680
0681 static int nmax = 50;
0682
0683 static double tcoef [51]={2.3770636862073187, -0.2214259431356961, -0.0232524179380925, 0.1327809189298409, -0.1325824891002065,
0684 0.0825446940740374,-0.0337827509774703, 0.0070874724137126, 0.0009814185303952,-0.0010948499244205,
0685 0.0001341521888280, 0.0001204181702739,-0.0000351287219323,-0.0000146145750095, 0.0000062641524139,
0686 0.0000022709548584,-0.0000010280349044,-0.0000004487400975, 0.0000001532631036, 0.0000001005306690,
0687 -0.0000000166366048,-0.0000000226490692,-0.0000000006425396, 0.0000000046258504, 0.0000000011681305,
0688 -0.0000000007317958,-0.0000000004540732, 0.0000000000395128, 0.0000000001175806, 0.0000000000278655,
0689 -0.0000000000190620,-0.0000000000134858,-0.0000000000001751, 0.0000000000033395, 0.0000000000013606,
0690 -0.0000000000003122,-0.0000000000004896,-0.0000000000001295, 0.0000000000000741, 0.0000000000000694,
0691 0.0000000000000122,-0.0000000000000135,-0.0000000000000101,-0.0000000000000013, 0.0000000000000022,
0692 0.0000000000000016, 0.0000000000000002,-0.0000000000000004,-0.0000000000000003, 0.0000000000000000,
0693 0.0000000000000001};
0694 double zeta2,t,twot,tn,tnm1,tnm2;
0695 int ind;
0696
0697 zeta2 = zeta*zeta;
0698 t = (zeta2 - ten)/(zeta2 + ten);
0699 twot = two*t;
0700 tnm1 = one;
0701 tn = t;
0702 dwork[0] = half*tcoef[0]*tnm1 + tcoef[1]*tn;
0703 for (ind=2;ind <= nmax;ind++) {
0704 tnm2 = tnm1;
0705 tnm1 = tn;
0706 tn = twot*tnm1 - tnm2;
0707 dwork[0] += tcoef[ind]*tn;
0708 }
0709 dwork[0] *= zeta/(one + two*zeta2);
0710 }
0711
0712 void weakrelativistictensor(X,Nperp,dNperpdx,ns,ncyclharm,raymagnetic,Npar,dNpardx,wcn,dwcndx,wpn2,dwpn2dx,betath,dbetathdx)
0713 susceptibilitytensor_format X;
0714 double complex Nperp,dNperpdx[];
0715 int ns,ncyclharm;
0716 raymagnetic_format raymagnetic;
0717 double wcn[],wpn2[],betath[];
0718 double dwcndx[][MC],dwpn2dx[][MC],dbetathdx[][MC];
0719 double Npar,dNpardx[];
0720
0721 {
0722
0723 double complex Xxx[ns+1],Xxy[ns+1],Xxz[ns+1],Xyy[ns+1],Xyz[ns+1],Xzz[ns+1];
0724 double complex dXxxdNperp[ns+1],dXxydNperp[ns+1],dXxzdNperp[ns+1],dXyydNperp[ns+1],dXyzdNperp[ns+1],dXzzdNperp[ns+1];
0725 double complex dXxxdNpar[ns+1],dXxydNpar[ns+1],dXxzdNpar[ns+1],dXyydNpar[ns+1],dXyzdNpar[ns+1],dXzzdNpar[ns+1];
0726 double complex dXxxdbetath[ns+1],dXxydbetath[ns+1],dXxzdbetath[ns+1],dXyydbetath[ns+1],dXyzdbetath[ns+1],dXzzdbetath[ns+1];
0727 double complex dXxxdwcn[ns+1],dXxydwcn[ns+1],dXxzdwcn[ns+1],dXyydwcn[ns+1],dXyzdwcn[ns+1],dXzzdwcn[ns+1];
0728 double complex dXxxdwpn2[ns+1],dXxydwpn2[ns+1],dXxzdwpn2[ns+1],dXyydwpn2[ns+1],dXyzdwpn2[ns+1],dXzzdwpn2[ns+1];
0729
0730 int is,i;
0731
0732 double npar2, te, B, XX, Y_1, Y_2, mu, halfmu, mu2, delta1, delta2, delta3, mudelta1, mudelta2, mudelta3;
0733 double halfnpar2, psi2, twopsi2, pipo1;
0734 double F50, F70, F90, dF50dz, dF70dz, dF90dz, dF30da, dF50da, dF70da, dF90da, dF110da;
0735 double I50, I70, I90, dI50dz, dI70dz, dI90dz, dI30da, dI50da, dI70da, dI90da, dI110da;
0736 double F51, F71, F91, dF51dz, dF71dz, dF91dz, dF51da, dF71da, dF91da, dF111da;
0737 double I51, I71, I91, dI51dz, dI71dz, dI91dz, dI51da, dI71da, dI91da, dI111da;
0738 double F72, F92, dF72dz, dF92dz, dF72da, dF92da, dF112da;
0739 double I72, I92, dI72dz, dI92dz, dI72da, dI92da, dI112da;
0740 double F93, dF93dz, dF93da;
0741 double I93, dI93dz, dI93da;
0742
0743 double muF50, dmuF50dTe, dmuF50dnpar2, muI50, dmuI50dTe, dmuI50dnpar2;
0744 double dF70dTe, dF70dnpar2, dI70dTe, dI70dnpar2, dF90dTe, dF90dnpar2, dI90dTe, dI90dnpar2;
0745 double muF701, dmuF701dTe, dmuF701dnpar2, muI701, dmuI701dTe, dmuI701dnpar2;
0746 double F901, dF901dTe, dF901dnpar2, I901, dI901dTe, dI901dnpar2;
0747 double twopsi2muF702, dtwopsi2muF702dTe, dtwopsi2muF702dnpar2, twopsi2muI702, dtwopsi2muI702dTe, dtwopsi2muI702dnpar2;
0748 double twopsi2F902, dtwopsi2F902dTe, dtwopsi2F902dnpar2, twopsi2I902, dtwopsi2I902dTe, dtwopsi2I902dnpar2;
0749 double twopsi2F1102,dtwopsi2F1102dTe,dtwopsi2F1102dnpar2,twopsi2I1102,dtwopsi2I1102dTe,dtwopsi2I1102dnpar2;
0750 double muF51, dmuF51dY, dmuF51dTe, dmuF51dnpar2, muI51, dmuI51dY, dmuI51dTe, dmuI51dnpar2;
0751 double dF71dY, dF71dTe, dF71dnpar2, dI71dY, dI71dTe, dI71dnpar2;
0752 double dF91dY, dF91dTe, dF91dnpar2, dI91dY, dI91dTe, dI91dnpar2;
0753 double muF711, dmuF711dY, dmuF711dTe, dmuF711dnpar2, muI711, dmuI711dY, dmuI711dTe, dmuI711dnpar2;
0754 double F911, dF911dY, dF911dTe, dF911dnpar2, I911, dI911dY, dI911dTe, dI911dnpar2;
0755 double twopsi2F912, dtwopsi2F912dY, dtwopsi2F912dTe, dtwopsi2F912dnpar2;
0756 double twopsi2I912, dtwopsi2I912dY, dtwopsi2I912dTe, dtwopsi2I912dnpar2;
0757 double twopsi2F1112, dtwopsi2F1112dY, dtwopsi2F1112dTe, dtwopsi2F1112dnpar2;
0758 double twopsi2I1112, dtwopsi2I1112dY, dtwopsi2I1112dTe, dtwopsi2I1112dnpar2;
0759 double dF72dY, dF72dTe, dF72dnpar2, dI72dY, dI72dTe, dI72dnpar2;
0760 double dF92dY, dF92dTe, dF92dnpar2, dI92dY, dI92dTe, dI92dnpar2;
0761 double F921, dF921dY, dF921dTe, dF921dnpar2, I921, dI921dY, dI921dTe, dI921dnpar2;
0762 double twopsi2F1122, dtwopsi2F1122dY, dtwopsi2F1122dTe, dtwopsi2F1122dnpar2;
0763 double twopsi2I1122, dtwopsi2I1122dY, dtwopsi2I1122dTe, dtwopsi2I1122dnpar2;
0764 double dF93dY, dF93dTe, dF93dnpar2, dI93dY, dI93dTe, dI93dnpar2;
0765 double delta_1, delta_1_1, delta_1_2, delta_2, delta_2_1, delta_2_2, delta_3, delta_3_1;
0766 double F5_1, dF5_1dz, muF5_1, dmuF5_1dY, dmuF5_1dTe, dmuF5_1dnpar2;
0767 double F7_1, dF7_1dz, dF7_1dY, dF7_1dTe, dF7_1dnpar2;
0768 double F9_1, dF9_1dz, dF9_1dY, dF9_1dTe, dF9_1dnpar2;
0769 double muF7_11, dmuF7_11dY, dmuF7_11dTe, dmuF7_11dnpar2;
0770 double F9_11, dF9_11dY, dF9_11dTe, dF9_11dnpar2;
0771 double twopsi2F9_12, dtwopsi2F9_12dY, dtwopsi2F9_12dTe, dtwopsi2F9_12dnpar2;
0772 double twopsi2F11_12, dtwopsi2F11_12dY, dtwopsi2F11_12dTe, dtwopsi2F11_12dnpar2;
0773 double F7_2, dF7_2dz, dF7_2dY, dF7_2dTe, dF7_2dnpar2;
0774 double F9_2, dF9_2dz, dF9_2dY, dF9_2dTe, dF9_2dnpar2;
0775 double F9_21, dF9_21dY, dF9_21dTe, dF9_21dnpar2;
0776 double twopsi2F11_22, dtwopsi2F11_22dY, dtwopsi2F11_22dTe, dtwopsi2F11_22dnpar2;
0777 double F9_3, dF9_3dz, dF9_3dY, dF9_3dTe, dF9_3dnpar2;
0778 double coeff1, coeff2, coeff3, coeff4, coeff5, coeff6, coeff7, coeff8;
0779
0780 double complex R0, dR0dX, dR0dY, dR0dTe, dR0dnpar2;
0781 double complex R1, dR1dX, dR1dY, dR1dTe, dR1dnpar2;
0782 double complex R2, dR2dX, dR2dY, dR2dTe, dR2dnpar2;
0783 double complex RR, dRdX , dRdY , dRdTe , dRdnpar2;
0784 double complex L0, dL0dX, dL0dY, dL0dTe, dL0dnpar2;
0785 double complex L1, dL1dX, dL1dY, dL1dTe, dL1dnpar2;
0786 double complex L2, dL2dX, dL2dY, dL2dTe, dL2dnpar2;
0787 double complex L , dLdX , dLdY , dLdTe , dLdnpar2;
0788 double complex P0, dP0dX, dP0dY, dP0dTe, dP0dnpar2;
0789 double complex P1, dP1dX, dP1dY, dP1dTe, dP1dnpar2;
0790 double complex P2, dP2dX, dP2dY, dP2dTe, dP2dnpar2;
0791 double complex P , dPdX , dPdY , dPdTe , dPdnpar2;
0792 double complex T1, dT1dX, dT1dY, dT1dTe, dT1dnpar2;
0793 double complex T2, dT2dX, dT2dY, dT2dTe, dT2dnpar2;
0794 double complex T, dTdX, dTdY, dTdTe, dTdnpar2;
0795 double complex M0, dM0dX, dM0dY, dM0dTe, dM0dnpar2;
0796 double complex M1, dM1dX, dM1dY, dM1dTe, dM1dnpar2;
0797 double complex M, dMdX, dMdY, dMdTe, dMdnpar2;
0798 double complex N0, dN0dX, dN0dY, dN0dTe, dN0dnpar2;
0799 double complex N1, dN1dX, dN1dY, dN1dTe, dN1dnpar2;
0800 double complex N, dNdX, dNdY, dNdTe, dNdnpar2;
0801 double complex S0, S1, S2, S;
0802 double complex Nperp2;
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813 npar2 = Npar*Npar;
0814 te = betath[0]*betath[0];
0815 B = wcn[0];
0816 XX = wpn2[0];
0817 Y_1 = 1.0/B;
0818 Y_2 = Y_1*Y_1;
0819 mu = 1.0/te;
0820 halfmu = 0.5*mu;
0821 mu2 = mu*mu;
0822 delta1 = 1.0-B;
0823 delta2 = delta1-B;
0824 delta3 = delta2-B;
0825 halfnpar2 = 0.5*npar2;
0826 psi2 = mu*halfnpar2;
0827 twopsi2 = 2.0*psi2;
0828
0829
0830
0831
0832
0833
0834
0835
0836 Shka(mu,psi2,&F50,&F70,&F90,&dF50dz,&dF70dz,&dF90dz,&dF30da,&dF50da,&dF70da,&dF90da,&dF110da);
0837
0838 muF50 = mu*F50;
0839 dmuF50dTe = -mu2*(mu*(dF50dz+halfnpar2*dF50da)+F50);
0840 dmuF50dnpar2 = mu*halfmu*dF50da;
0841
0842 dF70dTe = -mu2*(dF70dz+halfnpar2*dF70da);
0843 dF70dnpar2 = halfmu*dF70da;
0844 dF90dTe = -mu2*(dF90dz+halfnpar2*dF90da);
0845 dF90dnpar2 = halfmu*dF90da;
0846
0847 muF701 = mu*dF70dz;
0848 dmuF701dTe = -mu2*(mu*(dF50da+halfnpar2*(dF70da-dF50da))+dF70dz);
0849 dmuF701dnpar2 = mu*halfmu*(dF70da-dF50da);
0850
0851 F901 = dF90dz;
0852 dF901dTe = -mu2*(dF70da+halfnpar2*(dF90da-dF70da));
0853 dF901dnpar2 = halfmu*(dF90da-dF70da);
0854
0855 twopsi2muF702 = mu*twopsi2*dF50da;
0856 dtwopsi2muF702dTe = -mu2*mu*twopsi2*(dF50da-dF30da+halfnpar2*(dF70da-2.0*dF50da+dF30da)) - 2.0*mu*twopsi2muF702;
0857 dtwopsi2muF702dnpar2 = mu*twopsi2*halfmu*(dF70da-2.0*dF50da+dF30da)+mu2*dF50da;
0858
0859 twopsi2F902 = twopsi2*dF70da;
0860 dtwopsi2F902dTe = -mu2*twopsi2*(dF70da-dF50da+halfnpar2*(dF90da-2.0*dF70da+dF50da)) - mu*twopsi2F902;
0861 dtwopsi2F902dnpar2 = twopsi2*halfmu*(dF90da-2.0*dF70da+dF50da)+mu*dF70da;
0862
0863 twopsi2F1102 = twopsi2*dF90da;
0864 dtwopsi2F1102dTe = -mu2*twopsi2*(dF90da-dF70da+halfnpar2*(dF110da-2.0*dF90da+dF70da)) - mu*twopsi2F1102;
0865 dtwopsi2F1102dnpar2=twopsi2*halfmu*(dF110da-2.0*dF90da+dF70da)+mu*dF90da;
0866
0867 if (mu < psi2) {
0868 ImShka(mu,psi2,&I50,&I70,&I90,&dI50dz,&dI70dz,&dI90dz,&dI30da,&dI50da,&dI70da,&dI90da,&dI110da);
0869 muI50 = mu*I50;
0870 dmuI50dTe = -mu2*(mu*(dI50dz+halfnpar2*dI50da)+I50);
0871 dmuI50dnpar2 = mu*halfmu*dI50da;
0872 dI70dTe = -mu2*(dI70dz+halfnpar2*dI70da);
0873 dI70dnpar2 = halfmu*dI70da;
0874 dI90dTe = -mu2*(dI90dz+halfnpar2*dI90da);
0875 dI90dnpar2 = halfmu*dI90da;
0876 muI701 = mu*dI70dz;
0877 dmuI701dTe = -mu2*(mu*(dI50da+halfnpar2*(dI70da-dI50da))+dI70dz);
0878 dmuI701dnpar2 = mu*halfmu*(dI70da-dI50da);
0879 I901 = dI90dz;
0880 dI901dTe = -mu2*(dI70da+halfnpar2*(dI90da-dI70da));
0881 dI901dnpar2 = halfmu*(dI90da-dI70da);
0882 twopsi2muI702 = mu*twopsi2*dI50da;
0883 dtwopsi2muI702dTe = -mu2*mu*twopsi2*(dI50da-dI30da+halfnpar2*(dI70da-2.0*dI50da+dI30da)) - 2.0*mu*twopsi2muI702;
0884 dtwopsi2muI702dnpar2 = mu*twopsi2*halfmu*(dI70da-2.0*dI50da+dI30da)+mu2*dI50da;
0885 twopsi2I902 = twopsi2*dI70da;
0886 dtwopsi2I902dTe = -mu2*twopsi2*(dI70da-dI50da+halfnpar2*(dI90da-2.0*dI70da+dI50da)) - mu*twopsi2I902;
0887 dtwopsi2I902dnpar2 = twopsi2*halfmu*(dI90da-2.0*dI70da+dI50da)+mu*dI70da;
0888 twopsi2I1102 = twopsi2*dI90da;
0889 dtwopsi2I1102dTe = -mu2*twopsi2*(dI90da-dI70da+halfnpar2*(dI110da-2.0*dI90da+dI70da)) - mu*twopsi2I1102;
0890 dtwopsi2I1102dnpar2 = twopsi2*halfmu*(dI110da-2.0*dI90da+dI70da)+mu*dI90da;
0891 } else {
0892 I50 = 0.0;I70 = 0.0; I90 = 0.0; dI50dz = 0.0; dI70dz = 0.0; dI90dz = 0.0;
0893 dI30da = 0.0; dI50da = 0.0; dI70da = 0.0; dI90da = 0.0; dI110da = 0.0;
0894 muI50 = 0.0; dmuI50dTe = 0.0; dmuI50dnpar2 = 0.0;
0895 dI70dTe = 0.0; dI70dnpar2 = 0.0;
0896 dI90dTe = 0.0; dI90dnpar2 = 0.0;
0897 muI701 = 0.0; dmuI701dTe = 0.0; dmuI701dnpar2 = 0.0;
0898 I901 = 0.0; dI901dTe = 0.0; dI901dnpar2 = 0.0;
0899 twopsi2muI702 = 0.0; dtwopsi2muI702dTe = 0.0; dtwopsi2muI702dnpar2 = 0.0;
0900 twopsi2I902 = 0.0; dtwopsi2I902dTe = 0.0; dtwopsi2I902dnpar2 = 0.0;
0901 twopsi2I1102 = 0.0; dtwopsi2I1102dTe = 0.0; dtwopsi2I1102dnpar2 = 0.0;
0902 }
0903
0904
0905 Shka(mu*delta1,psi2,&F51,&F71,&F91,&dF51dz,&dF71dz,&dF91dz,&pipo1,&dF51da,&dF71da,&dF91da,&dF111da);
0906
0907 muF51 = mu*F51;
0908 dmuF51dY = -mu2*dF51dz;
0909 dmuF51dTe = -mu2*(mu*(delta1*dF51dz + halfnpar2*dF51da)+F51);
0910 dmuF51dnpar2 = mu*halfmu*dF51da;
0911
0912 dF71dY = -mu*dF71dz;
0913 dF71dTe = -mu2*(delta1*dF71dz + halfnpar2*dF71da);
0914 dF71dnpar2 = halfmu*dF71da;
0915
0916 dF91dY = -mu*dF91dz;
0917 dF91dTe = -mu2*(delta1*dF91dz + halfnpar2*dF91da);
0918 dF91dnpar2 = halfmu*dF91da;
0919
0920 muF711 = mu*dF71dz;
0921 dmuF711dY = -mu2*dF51da;
0922 dmuF711dTe = -mu2*(mu*(delta1*dF51da+halfnpar2*(dF71da-dF51da))+dF71dz);
0923 dmuF711dnpar2 = mu*halfmu*(dF71da-dF51da);
0924
0925 F911 = dF91dz;
0926 dF911dY = -mu*dF71da;
0927 dF911dTe = -mu2*(delta1*dF71da+halfnpar2*(dF91da-dF71da));
0928 dF911dnpar2 = halfmu*(dF91da-dF71da);
0929
0930 twopsi2F912 = twopsi2*dF71da;
0931 dtwopsi2F912dY = -twopsi2*mu*(dF71da-dF51da);
0932 dtwopsi2F912dTe = -mu2*twopsi2*(delta1*(dF71da-dF51da) + halfnpar2*(dF91da-2.0*dF71da+dF51da)) - mu*twopsi2F912;
0933 dtwopsi2F912dnpar2 = twopsi2*halfmu*(dF91da-2.0*dF71da+dF51da)+mu*dF71da;
0934
0935 twopsi2F1112 = twopsi2*dF91da;
0936 dtwopsi2F1112dY = -twopsi2*mu*(dF91da-dF71da);
0937 dtwopsi2F1112dTe = -mu2*twopsi2*(delta1*(dF91da-dF71da) + halfnpar2*(dF111da-2.0*dF91da+dF71da)) - mu*twopsi2F1112;
0938 dtwopsi2F1112dnpar2 = twopsi2*halfmu*(dF111da-2.0*dF91da+dF71da)+mu*dF91da;
0939
0940 if (mu*delta1else {
0969 I51 = 0.0;
0970 I71 = 0.0;
0971 I91 = 0.0;
0972 dI51dz = 0.0;
0973 dI71dz = 0.0;
0974 dI91dz = 0.0;
0975 dI51da = 0.0;
0976 dI71da = 0.0;
0977 dI91da = 0.0;
0978 dI111da = 0.0;
0979 muI51 = 0.0;
0980 dmuI51dY = 0.0;
0981 dmuI51dTe = 0.0;
0982 dmuI51dnpar2 = 0.0;
0983 dI71dY = 0.0;
0984 dI71dTe = 0.0;
0985 dI71dnpar2 = 0.0;
0986 dI91dY = 0.0;
0987 dI91dTe = 0.0;
0988 dI91dnpar2 = 0.0;
0989 muI711 = 0.0;
0990 dmuI711dY = 0.0;
0991 dmuI711dTe = 0.0;
0992 dmuI711dnpar2 = 0.0;
0993 I911 = 0.0;
0994 dI911dY = 0.0;
0995 dI911dTe = 0.0;
0996 dI911dnpar2 = 0.0;
0997 twopsi2I912 = 0.0;
0998 dtwopsi2I912dY = 0.0;
0999 dtwopsi2I912dTe = 0.0;
1000 dtwopsi2I912dnpar2 = 0.0;
1001 twopsi2I1112 = 0.0;
1002 dtwopsi2I1112dY = 0.0;
1003 dtwopsi2I1112dTe = 0.0;
1004 dtwopsi2I1112dnpar2 = 0.0;
1005 }
1006
1007
1008 Shka(mu*delta2,psi2,&pipo1,&F72,&F92,&pipo1,&dF72dz,&dF92dz,&pipo1,&pipo1,&dF72da,&dF92da,&dF112da);
1009
1010 dF72dY = -2.0*mu*dF72dz;
1011 dF72dTe = -mu2*(delta2*dF72dz+halfnpar2*dF72da);
1012 dF72dnpar2 = halfmu*dF72da;
1013
1014 dF92dY = -2.0*mu*dF92dz;
1015 dF92dTe = -mu2*(delta2*dF92dz+halfnpar2*dF92da);
1016 dF92dnpar2 = halfmu*dF92da;
1017
1018 F921 = dF92dz;
1019 dF921dY = -2.0*mu*dF72da;
1020 dF921dTe = -mu2*(delta2*dF72da+halfnpar2*(dF92da-dF72da));
1021 dF921dnpar2 = halfmu*(dF92da-dF72da);
1022
1023 twopsi2F1122 = twopsi2*dF92da;
1024 dtwopsi2F1122dY = -2.0*twopsi2*mu*(dF92da-dF72da);
1025 dtwopsi2F1122dTe = -mu2*twopsi2*(delta2*(dF92da-dF72da) + halfnpar2*(dF112da-2.0*dF92da+dF72da)) - mu*twopsi2F1122;
1026 dtwopsi2F1122dnpar2 = twopsi2*halfmu*(dF112da-2.0*dF92da+dF72da)+mu*dF92da;
1027
1028 if (mu*delta2else {
1046 I72 = 0.0;
1047 I92 = 0.0;
1048 dI72dz = 0.0;
1049 dI92dz = 0.0;
1050 dI72da = 0.0;
1051 dI92da = 0.0;
1052 dI112da = 0.0;
1053 dI72dY = 0.0;
1054 dI72dTe = 0.0;
1055 dI72dnpar2 = 0.0;
1056 dI92dY = 0.0;
1057 dI92dTe = 0.0;
1058 dI92dnpar2 = 0.0;
1059 I921 = 0.0;
1060 dI921dY = 0.0;
1061 dI921dTe = 0.0;
1062 dI921dnpar2 = 0.0;
1063 twopsi2I1122 = 0.0;
1064 dtwopsi2I1122dY = 0.0;
1065 dtwopsi2I1122dTe = 0.0;
1066 dtwopsi2I1122dnpar2 = 0.0;
1067 }
1068
1069
1070
1071 Shka(mu*delta3,psi2,&pipo1,&pipo1,&F93,&pipo1,&pipo1,&dF93dz,&pipo1,&pipo1,&pipo1,&dF93da,&pipo1);
1072
1073 dF93dY = -3.0*mu*dF93dz;
1074 dF93dTe = -mu2*(delta3*dF93dz+halfnpar2*dF93da);
1075 dF93dnpar2 = halfmu*dF93da;
1076
1077 if (mu*delta3else {
1084 I93 = 0.0; dI93dz = 0.0;
1085 dI93da = 0.0;
1086 dI93dY = 0.0;
1087 dI93dTe = 0.0;
1088 dI93dnpar2 = 0.0;
1089 }
1090
1091
1092
1093
1094 delta_1 = 1.0+B;
1095 delta_2 = delta_1+B;
1096 delta_3 = delta_2+B;
1097 delta_1_1 = 1.0/delta_1;
1098 delta_1_2 = delta_1_1*delta_1_1;
1099 delta_2_1 = 1.0/delta_2;
1100 delta_2_2 = delta_2_1*delta_2_1;
1101 delta_3_1 = 1.0/delta_3;
1102
1103 muF5_1 = delta_1_1;
1104 dmuF5_1dY = -delta_1_2;
1105 dmuF5_1dTe = 0.0;
1106 dmuF5_1dnpar2 = 0.0;
1107
1108 F7_1 = te*delta_1_1;
1109 dF7_1dY = -te*delta_1_2;
1110 dF7_1dTe = delta_1_1;
1111 dF7_1dnpar2 = 0.0;
1112
1113 F9_1 = F7_1; dF9_1dY = dF7_1dY; dF9_1dTe = dF7_1dTe; dF9_1dnpar2 = 0.0;
1114
1115 muF7_11 = -te*delta_1_2;
1116 dmuF7_11dY = -2.0*muF7_11*delta_1_1;
1117 dmuF7_11dTe = mu*muF7_11;
1118 dmuF7_11dnpar2 = 0.0;
1119
1120 F9_11 = -te*te*delta_1_2;
1121 dF9_11dY = -2.0*F9_11*delta_1_1;
1122 dF9_11dTe = 2.0*mu*F9_11;
1123 dF9_11dnpar2 = 0.0;
1124
1125 dtwopsi2F9_12dnpar2 = 2.0*te*te*delta_1_2*delta_1_1;
1126 twopsi2F9_12 = npar2*dtwopsi2F9_12dnpar2;
1127 dtwopsi2F9_12dY = -3.0*delta_1_1*twopsi2F9_12;
1128 dtwopsi2F9_12dTe = 2.0*mu*twopsi2F9_12;
1129
1130 twopsi2F11_12 = twopsi2F9_12; dtwopsi2F11_12dY = dtwopsi2F9_12dY;
1131 dtwopsi2F11_12dTe = dtwopsi2F9_12dTe; dtwopsi2F11_12dnpar2 = dtwopsi2F9_12dnpar2;
1132
1133 F7_2 = te*delta_2_1;
1134 dF7_2dY = -2.0*te*delta_2_2;
1135 dF7_2dTe = delta_2_1;
1136 dF7_2dnpar2 = 0.0;
1137
1138 F9_2 = F7_2; dF9_2dY = dF7_2dY; dF9_2dTe = dF7_2dTe; dF9_2dnpar2 = 0.0;
1139
1140 F9_21 = -te*te*delta_2_2;
1141 dF9_21dY = -4.0*F9_21*delta_2_1;
1142 dF9_21dTe = 2.0*mu*F9_21;
1143 dF9_21dnpar2 = 0.0;
1144
1145 dtwopsi2F11_22dnpar2 = 2.0*te*te*delta_2_2*delta_2_1;
1146 twopsi2F11_22 = npar2*dtwopsi2F11_22dnpar2;
1147 dtwopsi2F11_22dY = -6.0*delta_2_1*twopsi2F11_22;
1148 dtwopsi2F11_22dTe = 2.0*mu*twopsi2F11_22;
1149
1150 F9_3 = te*delta_3_1;
1151 dF9_3dY = -3.0*F9_3*delta_3_1;
1152 dF9_3dTe = delta_3_1;
1153 dF9_3dnpar2 = 0.0;
1154
1155
1156
1157
1158
1159
1160
1161 coeff1 = 0.5*Y_2;
1162 coeff2 = XX*coeff1;
1163 coeff4 = XX*Y_1;
1164 coeff3 = mu*coeff4;
1165 coeff5 = 0.5*te*coeff1*coeff1;
1166 coeff6 = XX*coeff5;
1167 coeff7 = 0.25*Y_2*Y_1;
1168 coeff8 = XX*coeff7;
1169
1170 dR0dX = -muF51-I*muI51;
1171 R0 = XX*dR0dX;
1172 dR0dY = -XX*(dmuF51dY+I*dmuI51dY);
1173 dR0dTe = -XX*(dmuF51dTe+I*dmuI51dTe);
1174 dR0dnpar2 = -XX*(dmuF51dnpar2+I*dmuI51dnpar2);
1175
1176 dR1dX = coeff1*((3.0*F71-F7_1-2.0*F72)+I*(3.0*I71 - 2.0*I72));
1177 R1 = XX*dR1dX;
1178 dR1dY = -2.0*R1*Y_1+coeff2*((3.0*dF71dY-dF7_1dY-2.0*dF72dY) + I*(3.0*dI71dY-2.0*dI72dY));
1179 dR1dTe = coeff2*((3.0*dF71dTe - dF7_1dTe - 2.0*dF72dTe) + I*(3.0*dI71dTe - 2.0*dI72dTe));
1180 dR1dnpar2 = coeff2*((3.0*dF71dTe-dF7_1dTe-2.0*dF72dTe)+I*(3.0*dI71dTe-2.0*dI72dTe));
1181 dR2dX = coeff5*((5.0*F9_1-10.0*F91-2.0*F9_2-3.0*F93) + I*(-10.0*I91-3.0*I93));
1182 R2 = XX*dR2dX;
1183 dR2dY = -4.0*R2*Y_1+coeff6*((5.0*dF9_1dY-10.0*dF91dY-2.0*dF9_2dY-3.0*dF93dY) + I*(-10.0*dI91dY-3.0*dI93dY));
1184 dR2dTe = mu*R2+coeff6*((5.0*dF9_1dTe-10.0*dF91dTe-2.0*dF9_2dTe-3.0*dF93dTe) + I*(-10.0*dI91dTe-3.0*dI93dTe));
1185 dR2dnpar2 = coeff6*((5.0*dF9_1dnpar2-10.0*dF91dnpar2-2.0*dF9_2dnpar2-3.0*dF93dnpar2) + I*(-10.0*dI91dnpar2-3.0*dI93dnpar2));
1186
1187 dL0dX = -muF5_1;
1188 L0 = -XX*muF5_1;
1189 dL0dY = -XX*dmuF5_1dY;
1190 dL0dTe = -XX*dmuF5_1dTe;
1191 dL0dnpar2 = -XX*dmuF5_1dnpar2;
1192
1193 dL1dX = coeff1*((3.0*F7_1-F71-2.0*F7_2) + I*(-I71));
1194 L1 = XX*dL1dX;
1195 dL1dY = -2.0*L1*Y_1+coeff2*((3.0*dF7_1dY-dF71dY-2.0*dF7_2dY) + I*(-dI71dY));
1196 dL1dTe = coeff2*((3.0*dF7_1dTe-dF71dTe-2.0*dF7_2dTe) +I*(-dI71dTe));
1197 dL1dnpar2 = coeff2*((3.0*dF7_1dnpar2-dF71dnpar2-2.0*dF7_2dnpar2) + I*(-dI71dnpar2));
1198
1199 dL2dX = coeff5*((5.0*F91-10.0*F9_1-2.0*F92-3.0*F9_3) + I*(5.0*I91-2.0*I92));
1200 L2 = XX*dL2dX;
1201 dL2dY = -4.0*L2*Y_1+coeff6*((5.0*dF91dY-10.0*dF9_1dY-2.0*dF92dY-3.0*dF9_3dY) + I*(5.0*dI91dY-2.0*dI92dY));
1202 dL2dTe = mu*L2+coeff6*((5.0*dF91dTe-10.0*dF9_1dTe-2.0*dF92dTe-3.0*dF9_3dTe) + I*(5.0*dI91dTe-2.0*dI92dTe));
1203 dL2dnpar2 = coeff6*((5.0*dF91dnpar2-10.0*dF9_1dnpar2 -2.0*dF92dnpar2-3.0*dF9_3dnpar2) + I*(5.0*dI91dnpar2-2.0*dI92dnpar2));
1204
1205 dP0dX = (-muF50-twopsi2muF702)+I*(-muI50-twopsi2muI702);
1206 P0 = XX*dP0dX;
1207 dP0dY = 0.0;
1208 dP0dTe = -XX*((dmuF50dTe+dtwopsi2muF702dTe) + I*(dmuI50dTe+dtwopsi2muI702dTe));
1209 dP0dnpar2 = -XX*((dmuF50dnpar2 +dtwopsi2muF702dnpar2) + I*(dmuI50dnpar2 +dtwopsi2muI702dnpar2));
1210
1211 dP1dX = coeff1*((2.0*(F70+twopsi2F902)-(F71+twopsi2F912)-(F7_1+twopsi2F9_12)) + I*(2.0*(I70+twopsi2I902)-(I71+twopsi2I912)));
1212 P1 = XX*dP1dX;
1213 dP1dY = -2.0*coeff4*dP1dX-coeff2*((dF71dY+dtwopsi2F912dY+dF7_1dY+dtwopsi2F9_12dY) + I*(dI71dY+dtwopsi2I912dY));
1214 dP1dTe = coeff2*((2.0*(dF70dTe+dtwopsi2F902dTe)-(dF71dTe+dtwopsi2F912dTe)-(dF7_1dTe+dtwopsi2F9_12dTe)) + I*(2.0*(dI70dTe+dtwopsi2I902dTe)-(dI71dTe+dtwopsi2I912dTe)));
1215 dP1dnpar2 = coeff2*((2.0*(dF70dnpar2+dtwopsi2F902dnpar2)-(dF71dnpar2+dtwopsi2F912dnpar2)-(dF7_1dnpar2+dtwopsi2F9_12dnpar2)) + I*(2.0*(dI70dnpar2+dtwopsi2I902dnpar2)-(dI71dnpar2+dtwopsi2I912dnpar2) ));
1216
1217 dP2dX = coeff5*((-6.0*(F90+twopsi2F1102)+4.0*(F91+twopsi2F1112+F9_1+twopsi2F11_12)-(F92+twopsi2F1122+F9_2+twopsi2F11_22)) +I*(-6.0*(I90+twopsi2I1102)+4.0*(I91+twopsi2I1112)-(I92+twopsi2I1122 )));
1218 P2 = XX*dP2dX;
1219 dP2dY = -4.0*P2*Y_1+coeff6*((+4.0*(dF91dY+dtwopsi2F1112dY+dF9_1dY+dtwopsi2F11_12dY) - (dF92dY+dtwopsi2F1122dY+dF9_2dY+dtwopsi2F11_22dY)) + I*(+4.0*(dI91dY+dtwopsi2I1112dY) - (dI92dY+dtwopsi2I1122dY )));
1220 dP2dTe = mu*P2+coeff6*((-6.0*(dF90dTe+dtwopsi2F1102dTe)+4.0*(dF91dTe+dtwopsi2F1112dTe+dF9_1dTe+dtwopsi2F11_12dTe)-(dF92dTe+dtwopsi2F1122dTe+dF9_2dTe+dtwopsi2F11_22dTe))+I*(-6.0*(dI90dTe+dtwopsi2I1102dTe)+4.0*(dI91dTe+dtwopsi2I1112dTe)-(dI92dTe+dtwopsi2I1122dTe)));
1221 dP2dnpar2 = coeff6*((-6.0*(dF90dnpar2+dtwopsi2F1102dnpar2)+4.0*(dF91dnpar2+dtwopsi2F1112dnpar2+dF9_1dnpar2+dtwopsi2F11_12dnpar2)-(dF92dnpar2+dtwopsi2F1122dnpar2+dF9_2dnpar2+dtwopsi2F11_22dnpar2))+I*(-6.0*(dI90dnpar2+dtwopsi2I1102dnpar2)+4.0*(dI91dnpar2+dtwopsi2I1112dnpar2)-(dI92dnpar2+dtwopsi2I1122dnpar2)));
1222
1223 dT1dX = coeff1*((2.0*F70-F71-F7_1)+I*(2.0*I70-I71));
1224 T1 = XX*dT1dX;
1225 dT1dY = -2.0*coeff4*dT1dX-coeff2*((dF71dY+dF7_1dY) + I*(dI71dY));
1226 dT1dTe = coeff2*((2.0*dF70dTe-dF71dTe-dF7_1dTe)+I*(2.0*dI70dTe-dI71dTe));
1227 dT1dnpar2 = coeff2*((2.0*dF70dnpar2 -dF71dnpar2-dF7_1dnpar2)+I*(2.0*dI70dnpar2-dI71dnpar2));
1228
1229 dT2dX = coeff5*((16.0*(F91+F9_1)+4.0*(F92+F9_2)-12.0*F90)+I*(16.0*(I91)+4.0*(I92)-12.0*I90));
1230 T2 = XX*dT2dX;
1231 dT2dY = -4.0*Y_1*T2+coeff6*((16.0*(dF91dY+dF9_1dY)+4.0*(dF92dY+dF9_2dY)) +I*(16.0* dI91dY+4.0* dI92dY));
1232 dT2dTe = mu*T2+coeff6*((16.0*(dF91dTe+dF9_1dTe)+4.0*(dF92dTe+dF9_2dTe)-12.0*dF90dTe) +I*(16.0* dI91dTe+4.0* dI92dTe) -12.0*dI90dTe);
1233 dT2dnpar2 = coeff6*((16.0*(dF91dnpar2+dF9_1dnpar2)+4.0*(dF92dnpar2+dF9_2dnpar2)-12.0*dF90dnpar2)+I*(16.0* dI91dnpar2+4.0* dI92dnpar2-12.0*dI90dnpar2));
1234
1235
1236
1237
1238
1239 dM0dX = Y_1*(-muF7_11+muF701+I*muI701);
1240 M0 = XX*dM0dX;
1241 dM0dY = coeff4*(-dmuF7_11dY-dM0dX);
1242 dM0dTe = coeff4*(-dmuF7_11dTe+dmuF701dTe+I*dmuI701dTe);
1243 dM0dnpar2 = coeff4*(-dmuF7_11dnpar2+dmuF701dnpar2+I*dmuI701dnpar2);
1244
1245
1246
1247
1248 dM1dX = coeff7*((2.0*F911+6.0*F9_11+2.0*F9_21-3.0*F901)+I*(2.0*I911-3.0*I901));
1249 M1 = XX*dM1dX;
1250 dM1dY = -3.0*M1*Y_1+coeff8*((2.0*dF911dY+6.0*dF9_11dY+2.0*dF9_21dY)+I*(2.0*dI911dY));
1251 dM1dTe = coeff8*((2.0*dF911dTe+6.0*dF9_11dTe+2.0*dF9_21dTe -3.0*dF901dTe)+I*(2.0*dI911dTe-3.0*dI901dTe));
1252 dM1dnpar2 = coeff8*((2.0*dF911dnpar2+6.0*dF9_11dnpar2+2.0*dF9_21dnpar2-3.0*dF901dnpar2)+I*(2.0*dI911dnpar2-3.0*dI901dnpar2));
1253
1254
1255
1256
1257
1258 dN0dX = Y_1*((muF711-muF701)+I*(muI711-muI701));
1259 N0 = XX*dN0dX;
1260 dN0dY = coeff4*(dmuF711dY-dN0dX+I*dmuI711dY);
1261 dN0dTe = coeff4*((dmuF711dTe-dmuF701dTe)+I*(dmuI711dTe-dmuI701dTe));
1262 dN0dnpar2 = coeff4*(dmuF711dnpar2-dmuF701dnpar2) + I*(dmuI711dnpar2-dmuI701dnpar2);
1263
1264
1265
1266
1267 dN1dX = coeff7*((-2.0*F9_11-6.0*F911-2.0*F921+3.0*F901)+I*(-6.0*I911-2.0*I921+3.0*I901));
1268 N1 = XX*dN1dX;
1269 dN1dY = -3.0*N1*Y_1+coeff8*((-2.0*dF9_11dY-6.0*dF911dY-2.0*dF921dY) +I*(-6.0*dI911dY-2.0*dI921dY));
1270 dN1dTe = coeff8*((-2.0*dF9_11dTe-6.0*dF911dTe-2.0*dF921dTe+3.0*dF901dTe) +I*(-6.0*dI911dTe-2.0*dI921dTe+3.0*dI901dTe));
1271 dN1dnpar2 = coeff8*((-2.0*dF9_11dnpar2-6.0*dF911dnpar2-2.0*dF921dnpar2+3.0*dF901dnpar2)+I*(-6.0*dI911dnpar2-2.0*dI921dnpar2+3.0*dI901dnpar2));
1272
1273
1274 Nperp2 = Nperp*Nperp;
1275 RR = R0+Nperp2*(R1+Nperp2*R2);
1276 L = L0+Nperp2*(L1+Nperp2*L2);
1277 S = 0.5*(RR+L);
1278 P = P0+Nperp2*(P1+Nperp2*P2);
1279 T = Nperp2*(T1+Nperp2*T2);
1280 M = M0+Nperp2*M1;
1281 N = N0+Nperp2*N1;
1282
1283 dRdX = dR0dX+Nperp2*(dR1dX+Nperp2*dR2dX);
1284 dLdX = dL0dX+Nperp2*(dL1dX+Nperp2*dL2dX);
1285 dPdX = dP0dX+Nperp2*(dP1dX+Nperp2*dP2dX);
1286 dTdX = Nperp2*(dT1dX+Nperp2*dT2dX);
1287 dMdX = dM0dX+Nperp2*dM1dX;
1288 dNdX = dN0dX+Nperp2*dN1dX;
1289
1290 dRdY = dR0dY+Nperp2*(dR1dY+Nperp2*dR2dY);
1291 dLdY = dL0dY+Nperp2*(dL1dY+Nperp2*dL2dY);
1292 dPdY = dP0dY+Nperp2*(dP1dY+Nperp2*dP2dY);
1293 dTdY = Nperp2*(dT1dY+Nperp2*dT2dY);
1294 dMdY = dM0dY+Nperp2*dM1dY;
1295 dNdY = dN0dY+Nperp2*dN1dY;
1296
1297 dRdTe = dR0dTe+Nperp2*(dR1dTe+Nperp2*dR2dTe);
1298 dLdTe = dL0dTe+Nperp2*(dL1dTe+Nperp2*dL2dTe);
1299 dPdTe = dP0dTe+Nperp2*(dP1dTe+Nperp2*dP2dTe);
1300 dTdTe = Nperp2*(dT1dTe+Nperp2*dT2dTe);
1301 dMdTe = dM0dTe+Nperp2*dM1dTe;
1302 dNdTe = dN0dTe+Nperp2*dN1dTe;
1303
1304 dRdnpar2 = dR0dnpar2+Nperp2*(dR1dnpar2+Nperp2*dR2dnpar2);
1305 dLdnpar2 = dL0dnpar2+Nperp2*(dL1dnpar2+Nperp2*dL2dnpar2);
1306 dPdnpar2 = dP0dnpar2+Nperp2*(dP1dnpar2+Nperp2*dP2dnpar2);
1307 dTdnpar2 = Nperp2*(dT1dnpar2+Nperp2*dT2dnpar2);
1308 dMdnpar2 = dM0dnpar2+Nperp2*dM1dnpar2;
1309 dNdnpar2 = dN0dnpar2+Nperp2*dN1dnpar2;
1310
1311
1312
1313
1314
1315
1316 Xxx[0] = S;
1317 Xxy[0] = 0.5*I*(L-RR);
1318 Xxz[0] = 0.5*Npar*Nperp*(M+N);
1319 Xyy[0] = S-2.0*T;
1320 Xyz[0] = 0.5*I*Npar*Nperp*(M-N);
1321 Xzz[0] = P;
1322
1323
1324
1325 for (is = 1;is < ns + 1;is++) {
1326 Xxx[is] = 0.0;
1327 Xxy[is] = 0.0;
1328 Xxz[is] = 0.0;
1329 Xyy[is] = 0.0;
1330 Xyz[is] = 0.0;
1331 Xzz[is] = 0.0;
1332 }
1333
1334
1335
1336 dXxxdNperp[0] = Nperp*(R1+L1+2.0*Nperp2*(R2+L2));
1337 dXxydNperp[0] = I*Nperp*(L1-R1+2.0*Nperp2*(L2-R2));
1338 dXxzdNperp[0] = Npar*(0.5*(M+N)+Nperp2*(M1+N1));
1339 dXyydNperp[0] = dXxxdNperp[0]-4.0*Nperp*(T1+2.0*Nperp2*T2);
1340 dXyzdNperp[0] = I*Npar*(0.5*(M-N)+Nperp2*(M1-N1));
1341 dXzzdNperp[0] = 2.0*Nperp*(P1+2.0*Nperp2*P2);
1342
1343 dXxxdNpar[0] = Npar*(dRdnpar2+dLdnpar2);
1344 dXxydNpar[0] = Npar*I*(dLdnpar2-dRdnpar2);
1345 dXxzdNpar[0] = npar2*Nperp*(dMdnpar2+dNdnpar2)+0.5*Nperp*(M+N);
1346 dXyydNpar[0] = dXxxdNpar[0]-4.0*Npar*dTdnpar2;
1347 dXyzdNpar[0] = I*npar2*Nperp*(dMdnpar2-dNdnpar2)+0.5*I*Nperp*(M-N);;
1348 dXzzdNpar[0] = 2.0*Npar*dPdnpar2;
1349
1350 dXxxdbetath[0] = betath[0]*(dRdTe+dLdTe);
1351 dXxydbetath[0] = betath[0]*I*(dLdTe-dRdTe);
1352 dXxzdbetath[0] = betath[0]*Npar*Nperp*(dMdTe+dNdTe);
1353 dXyydbetath[0] = 2.0*betath[0]*(0.5*(dRdTe+dLdTe)-2.0*dTdTe);
1354 dXyzdbetath[0] = betath[0]*I*Npar*Nperp*(dMdTe-dNdTe);
1355 dXzzdbetath[0] = 2.0*betath[0]*dPdTe;
1356
1357 dXxxdwcn[0] = 0.5*(dRdY+dLdY);
1358 dXxydwcn[0] = 0.5*I*(dLdY-dRdY);
1359 dXxzdwcn[0] = 0.5*Npar*Nperp*(dMdY+dNdY);
1360 dXyydwcn[0] = 0.5*(dRdY+dLdY)-2.0*dTdY;
1361 dXyzdwcn[0] = 0.5*I*Npar*Nperp*(dMdY-dNdY);
1362 dXzzdwcn[0] = dPdY;
1363
1364 dXxxdwpn2[0] = 0.5*(dRdX+dLdX);
1365 dXxydwpn2[0] = 0.5*I*(dLdX-dRdX);
1366 dXxzdwpn2[0] = 0.5*Npar*Nperp*(dMdX+dNdX);
1367 dXyydwpn2[0] = 0.5*(dRdX+dLdX)-2.0*dTdX;
1368 dXyzdwpn2[0] = 0.5*I*Npar*Nperp*(dMdX-dNdX);
1369 dXzzdwpn2[0] = dPdX;
1370
1371
1372
1373 for (is = 1;is < ns + 1; is++) {
1374 dXxxdNperp[is] = 0.0;
1375 dXxydNperp[is] = 0.0;
1376 dXxzdNperp[is] = 0.0;
1377 dXyydNperp[is] = 0.0;
1378 dXyzdNperp[is] = 0.0;
1379 dXzzdNperp[is] = 0.0;
1380 dXxxdNpar[is] = 0.0;
1381 dXxydNpar[is] = 0.0;
1382 dXxzdNpar[is] = 0.0;
1383 dXyydNpar[is] = 0.0;
1384 dXyzdNpar[is] = 0.0;
1385 dXzzdNpar[is] = 0.0;
1386 dXxxdbetath[is] = 0.0;
1387 dXxydbetath[is] = 0.0;
1388 dXxzdbetath[is] = 0.0;
1389 dXyydbetath[is] = 0.0;
1390 dXyzdbetath[is] = 0.0;
1391 dXzzdbetath[is] = 0.0;
1392 dXxxdwcn[is] = 0.0;
1393 dXxydwcn[is] = 0.0;
1394 dXxzdwcn[is] = 0.0;
1395 dXyydwcn[is] = 0.0;
1396 dXyzdwcn[is] = 0.0;
1397 dXzzdwcn[is] = 0.0;
1398 dXxxdwpn2[is] = 0.0;
1399 dXxydwpn2[is] = 0.0;
1400 dXxzdwpn2[is] = 0.0;
1401 dXyydwpn2[is] =0.0;
1402 dXyzdwpn2[is] = 0.0;
1403 dXzzdwpn2[is] = 0.0;
1404 }
1405 buildXstruc(X,dNperpdx,Xxx,Xxy,Xxz,Xyy,Xyz,Xzz,dXxxdNperp,dXxydNperp,dXxzdNperp,dXyydNperp,dXyzdNperp,dXzzdNperp,dXxxdNpar,dXxydNpar,dXxzdNpar,dXyydNpar,dXyzdNpar,dXzzdNpar,dXxxdbetath,dXxydbetath,dXxzdbetath,dXyydbetath,dXyzdbetath,dXzzdbetath,dXxxdwcn,dXxydwcn,dXxzdwcn,dXyydwcn,dXyzdwcn,dXzzdwcn,dXxxdwpn2,dXxydwpn2,dXxzdwpn2,dXyydwpn2,dXyzdwpn2,dXzzdwpn2,ns,dNpardx,dwcndx,dwpn2dx,dbetathdx);
1406 }
1407
1408
1409
1410 void Shka(z,a,RF5,RF7,RF9,dRF5dz,dRF7dz,dRF9dz,dRF3da,dRF5da,dRF7da,dRF9da,dRF11da)
1411 double z,a;
1412 double *RF5,*RF7,*RF9,*dRF5dz,*dRF7dz,*dRF9dz,*dRF3da,*dRF5da,*dRF7da,*dRF9da,*dRF11da;
1413 {
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423 double S0, S1, S2, S3, S4, S5, S6;
1424 double dS1dz, dS2dz, dS3dz, dS4dz, dS5dz, dS6dz;
1425 double dS1da, dS2da, dS3da, dS4da, dS5da;
1426 double F1, F2, F3, F4, F5, F6, dF1, dF2, dF3, dF4, dF5, dF6;
1427 double d2F1, d2F2, d2F3, d2F4, d2F5;
1428 double qmax, limit, expo, oldcoeff, az1, terme, terme1, nmax, z_a, coeff;
1429 double phi2, phi, psi, rZ1, rZ2;
1430 double Cqj[1000];
1431 double daw;
1432
1433 int nb, n, compteur;
1434 static double sqrttwoe_6 = 1.414e-6;
1435
1436 double complex Z1, Z2;
1437
1438
1439
1440
1441
1442
1443
1444
1445 qmax = 6.0;
1446 limit = 10*sqrt(a*a+qmax*qmax);
1447 nb = (int) limit;
1448 nb = ((nb) > (1000) ? (1000) : (nb));
1449
1450 if ((fabs(z-a)>10.0*limit)&(a>sqrttwoe_6)) {
1451 for (n = 0;n