Skip to content

Commit

Permalink
Working version of alternative clog
Browse files Browse the repository at this point in the history
  • Loading branch information
miekkasarki committed Sep 20, 2024
1 parent 9422488 commit 4383822
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
10 changes: 7 additions & 3 deletions src/libascot.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,19 +827,23 @@ void libascot_eval_collcoefs(
real mufun[3] = {0., 0., 0.};

/* Evaluate rho as it is needed to evaluate plasma parameters */
real psi, rho[2];
real psi, rho[2], B[3];
if( B_field_eval_psi(&psi, R[k], phi[k], z[k], t[k], &sim.B_data) ) {
continue;
}
if( B_field_eval_rho(rho, psi, &sim.B_data) ) {
continue;
}
if( B_field_eval_B(B, R[k], phi[k], z[k], t[k], &sim.B_data) ) {
continue;
}

real nb[MAX_SPECIES], Tb[MAX_SPECIES];
if( plasma_eval_densandtemp(nb, Tb, rho[0], R[k], phi[k], z[k], t[k],
&sim.plasma_data) ) {
continue;
}
real Bnorm = math_norm(B);

/* Evaluate coefficients for different velocities */
for(int iv=0; iv<Nv; iv++) {
Expand All @@ -849,8 +853,8 @@ void libascot_eval_collcoefs(

/* Coulomb logarithm */
real clogab[MAX_SPECIES];
mccc_coefs_clog(clogab, ma, qa, va[iv], n_species, mb, qb,
nb, Tb);
mccc_coefs_clog(
clogab, ma, qa, va[iv], Bnorm, n_species, mb, qb, nb, Tb);

/* Special functions */
real vb = sqrt( 2 * Tb[ib] / mb[ib] );
Expand Down
15 changes: 8 additions & 7 deletions src/simulate/mccc/mccc_coefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,19 @@
* @param nb plasma species densities [m^-3]
* @param Tb plasma species temperatures [J]
*/
#pragma omp declare simd uniform(nspec, mb, qb, nb, Tb)
inline static void mccc_coefs_clog(real* clogab, real ma, real qa, real va,
int nspec, const real* mb, const real* qb,
const real* nb, const real* Tb) {
#pragma omp declare simd uniform(nspec, mb, qb, nb, Tb, B)
inline static void mccc_coefs_clog(
real* clogab, real ma, real qa, real va, real B, int nspec, const real* mb,
const real* qb, const real* nb, const real* Tb) {

/* Evaluate Debye length */
real sum = 0;
for(int i = 0; i < nspec; i++){
sum += (nb[i] * qb[i] * qb[i] / (mb[i]*CONST_E0) + qa*5.3/ma) / (Tb[i]/mb[i] + va * va);
//sum += nb[i] * qb[i] * qb[i] / Tb[i];
sum += ( nb[i] * qb[i] * qb[i] / ( mb[i] * CONST_E0 )
+ qb[i] * qb[i] * B * B / ( mb[i] * mb[i] ) )
/ ( Tb[i] / mb[i] + va * va );
}
real debyeLength = sqrt(sum);//sqrt(CONST_E0/sum);
real debyeLength = 1.0/sqrt(sum);

/* Evaluate classical and quantum mechanical impact parameter. The one *
* that is larger is used to evaluate Coulomb logarithm. */
Expand Down
3 changes: 2 additions & 1 deletion src/simulate/mccc/mccc_fo_euler.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void mccc_fo_euler(particle_simd_fo* p, real* h, plasma_data* pdata,

/* Coulomb logarithm */
real clogab[MAX_SPECIES];
mccc_coefs_clog(clogab, p->mass[i], p->charge[i], vin,
real B = math_normc(p->B_r[i], p->B_phi[i], p->B_z[i]);
mccc_coefs_clog(clogab, p->mass[i], p->charge[i], vin, B,
n_species, mb, qb, nb, Tb);

/* Evaluate collision coefficients and sum them for each *
Expand Down
2 changes: 1 addition & 1 deletion src/simulate/mccc/mccc_gc_euler.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void mccc_gc_euler(particle_simd_gc* p, real* h, B_field_data* Bdata,

/* Coulomb logarithm */
real clogab[MAX_SPECIES];
mccc_coefs_clog(clogab, p->mass[i], p->charge[i], vin,
mccc_coefs_clog(clogab, p->mass[i], p->charge[i], vin, Bnorm,
n_species, mb, qb, nb, Tb);

/* Evaluate collision coefficients and sum them for each *
Expand Down
2 changes: 1 addition & 1 deletion src/simulate/mccc/mccc_gc_milstein.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void mccc_gc_milstein(particle_simd_gc* p, real* hin, real* hout, real tol,

/* Coulomb logarithm */
real clogab[MAX_SPECIES];
mccc_coefs_clog(clogab, p->mass[i], p->charge[i], vin,
mccc_coefs_clog(clogab, p->mass[i], p->charge[i], vin, Bnorm,
n_species, mb, qb, nb, Tb);

/* Evaluate collision coefficients and sum them for each *
Expand Down

0 comments on commit 4383822

Please sign in to comment.