Skip to content

Commit

Permalink
fix Beta and Bp_R, Bp_Z grid outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarnier committed May 8, 2024
1 parent 3fa0b66 commit b83fc9a
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions sources/HDF5Output.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ typedef float float32;
#define PI 3.14159265358979323
#define MU0 1.25663706e-06
#define TWOPI 6.283185307


#define ITER_IJ(ix, iz, nmin, nmax) \
for (int iz = nmin; iz <= nmax; iz++) /* slowest */ \
for (int ix = nmin; ix <= nmax; ix++) /* fastest */ \


/*
** ScaleArray
**
**
*/
static void ScaleArray(double *a, double **ad, int nmax, double multiplier)
{
int ix, iz;

for (iz = 0; iz <= nmax; iz++) /* slowest */
for (ix = 0; ix <= nmax; ix++) /* fastest */
*a++ = ad[ix][iz] * multiplier;
ITER_IJ(ix, iz, 0, nmax) *a++ = ad[ix][iz] * multiplier;
}

/*
Expand Down Expand Up @@ -266,18 +267,13 @@ void HDFPlasma(PLASMA * pl, PSIGRID * pg, char *Oname)
/* Bp_x */
MULTI;
ap = a;
for (int ix = 0; ix <= nmax; ix++)
for (int iz = 0; iz <= nmax; iz++)
*ap++ = pl->GradPsiZ[ix][iz] / TWOPI / pg->X[ix];

ITER_IJ(ix, iz, 0, nmax) *ap++ = pl->GradPsiZ[ix][iz] / TWOPI / pg->X[ix];
HDFWrite2D(a, BpX_NAME, "T", g2d, dsp2d, dsc1, dsc2);

/* Bp_z */
MULTI;
ap = a;
for (int ix = 0; ix <= nmax; ix++)
for (int iz = 0; iz <= nmax; iz++)
*ap++ = -pl->GradPsiX[ix][iz] / TWOPI / pg->X[ix];
ITER_IJ(ix, iz, 0, nmax) *ap++ = -pl->GradPsiX[ix][iz] / TWOPI / pg->X[ix];

HDFWrite2D(a, BpZ_NAME, "T", g2d, dsp2d, dsc1, dsc2);

Expand Down Expand Up @@ -309,9 +305,7 @@ void HDFPlasma(PLASMA * pl, PSIGRID * pg, char *Oname)
switch (pl->ModelType) {
default :
ap = a;
for (int ix = 1; ix <= nmax; ix++)
for (int iz = 1; iz <= nmax; iz++)
*ap++ = 2*pl->Piso[ix][iz]/pl->B2[ix][iz];
ITER_IJ(ix, iz, 0, nmax) *ap++ = 2*pl->Piso[ix][iz]/pl->B2[ix][iz];
HDFWrite2D(a, BETA_NAME, "", g2d, dsp2d, dsc1, dsc2);
break;
case Plasma_IsoFlow:
Expand Down

0 comments on commit b83fc9a

Please sign in to comment.