diff --git a/core/zero/gkyl_array_average.h b/core/zero/gkyl_array_average.h index 6bd407ae94..867d4da668 100644 --- a/core/zero/gkyl_array_average.h +++ b/core/zero/gkyl_array_average.h @@ -19,7 +19,7 @@ typedef struct gkyl_array_average_inp gkyl_array_average_inp; * @param local Full range of the input array, covering all dimensions of the total basis. * @param local_avg Reduced range of the output array, covering only the non-averaged dimensions. * @param local_avg_ext Extended reduced range of the output array, used only to define the integrated weight. - * @param weight Pointer to the array containing weight for the averaging process. (set it to NULL for integral) + * @param weight Pointer to the array containing weight for the averaging process. * @param avg_dim Flag array to set which dimension is averaged * @param use_gpu Boolean flag indicating whether the computation should be performed on a GPU. */ @@ -78,7 +78,7 @@ gkyl_array_average_inew(const struct gkyl_array_average_inp *inp); * @param local Full range of the input array, covering all dimensions of the total basis. * @param local_avg Reduced range of the output array, covering only the non-averaged dimensions. * @param local_avg_ext Extended reduced range of the output array, used only to define the integrated weight. - * @param weight Pointer to the array containing weight for the averaging process. (set it to NULL for integral) + * @param weight Pointer to the array containing weight for the averaging process. * @param avg_dim Flag array to set which dimension is averaged * @param use_gpu Boolean flag indicating whether the computation should be performed on a GPU. */ diff --git a/gyrokinetic/apps/gk_field_1x.c b/gyrokinetic/apps/gk_field_1x.c index 2d91e55a4e..c510a10075 100644 --- a/gyrokinetic/apps/gk_field_1x.c +++ b/gyrokinetic/apps/gk_field_1x.c @@ -82,6 +82,7 @@ gk_field_fem_new_1x(struct gkyl_gyrokinetic_app *app, struct gk_field *f) polarization_weight += s->info.polarization_density*s->info.mass/pow(polarization_bmag,2); } // Need to set weight to kperpsq*polarizationWeight for use in potential smoothing. + assert(f->info.kperpSq > 0.0); gkyl_array_copy(f->epsilon, app->gk_geom->geo_int.jacobgeo); gkyl_array_scale(f->epsilon, polarization_weight); gkyl_array_scale(f->epsilon, f->info.kperpSq); diff --git a/gyrokinetic/apps/gk_species.c b/gyrokinetic/apps/gk_species.c index 2b93be63cf..b46c4bb2c4 100644 --- a/gyrokinetic/apps/gk_species.c +++ b/gyrokinetic/apps/gk_species.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -197,7 +198,7 @@ gk_species_rhs_implicit_static(gkyl_gyrokinetic_app *app, struct gk_species *spe } static void -gk_species_apply_bc_dynamic(gkyl_gyrokinetic_app *app, const struct gk_species *species, struct gkyl_array *f) +gk_species_apply_bc_dynamic(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gkyl_array *f) { struct timespec wst = gkyl_wall_clock(); @@ -209,9 +210,18 @@ gk_species_apply_bc_dynamic(gkyl_gyrokinetic_app *app, const struct gk_species * if (species->bc_is_np[d]) { switch (species->lower_bc[d].type) { - case GKYL_BC_GK_SPECIES_SHEATH: + case GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING: gkyl_bc_sheath_gyrokinetic_advance(species->bc_sheath_lo, app->field->phi_smooth, - app->field->phi_wall_lo, f, &app->local); + app->field->phi_wall_lo, NULL, NULL, NULL, NULL, f, &app->local); + break; + case GKYL_BC_GK_SPECIES_SHEATH_SURROGATE: + gk_species_moment_calc(&species->sheath_moms, species->local, app->local, f); + gk_species_moment_diag_jacobgeo_div(app, &species->sheath_moms, species->sheath_moms.marr, species->sheath_moms.marr); + gkyl_array_set_offset_range(species->dens_sheath, 1.0, species->sheath_moms.marr, 0, &app->local); + gkyl_array_set_offset_range(species->temp_sheath, species->info.mass, species->sheath_moms.marr, 2*app->basis.num_basis, &app->local); + gkyl_bc_sheath_gyrokinetic_advance(species->bc_sheath_lo, app->field->phi_smooth, + app->field->phi_wall_lo, species->dens_sheath, species->temp_sheath, + app->gk_geom->geo_int.bmag, app->gk_geom->geo_surf[d].bimpactangle, f, &app->local); break; case GKYL_BC_GK_SPECIES_TWISTSHIFT: gkyl_bc_twistshift_advance(species->bc_ts_lo, f, f); @@ -231,9 +241,18 @@ gk_species_apply_bc_dynamic(gkyl_gyrokinetic_app *app, const struct gk_species * } switch (species->upper_bc[d].type) { - case GKYL_BC_GK_SPECIES_SHEATH: + case GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING: gkyl_bc_sheath_gyrokinetic_advance(species->bc_sheath_up, app->field->phi_smooth, - app->field->phi_wall_up, f, &app->local); + app->field->phi_wall_up, NULL, NULL, NULL, NULL, f, &app->local); + break; + case GKYL_BC_GK_SPECIES_SHEATH_SURROGATE: + gk_species_moment_calc(&species->sheath_moms, species->local, app->local, f); + gk_species_moment_diag_jacobgeo_div(app, &species->sheath_moms, species->sheath_moms.marr, species->sheath_moms.marr); + gkyl_array_set_offset_range(species->dens_sheath, 1.0, species->sheath_moms.marr, 0, &app->local); + gkyl_array_set_offset_range(species->temp_sheath, species->info.mass, species->sheath_moms.marr, 2*app->basis.num_basis, &app->local); + gkyl_bc_sheath_gyrokinetic_advance(species->bc_sheath_up, app->field->phi_smooth, + app->field->phi_wall_up, species->dens_sheath, species->temp_sheath, + app->gk_geom->geo_int.bmag, app->gk_geom->geo_surf[d].bimpactangle, f, &app->local); break; case GKYL_BC_GK_SPECIES_TWISTSHIFT: gkyl_bc_twistshift_advance(species->bc_ts_up, f, f); @@ -266,7 +285,7 @@ gk_species_apply_bc_dynamic(gkyl_gyrokinetic_app *app, const struct gk_species * } static void -gk_species_apply_bc_static(gkyl_gyrokinetic_app *app, const struct gk_species *species, struct gkyl_array *f) +gk_species_apply_bc_static(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gkyl_array *f) { // do nothing } @@ -316,6 +335,39 @@ gk_species_copy_range_static(struct gkyl_array *out, // do nothing } +// Write out the sheath BC velocity cutoff (vcutsq) at one boundary. +static void +gk_species_write_vcutsq(gkyl_gyrokinetic_app* app, struct gk_species *gks, + struct gkyl_bc_sheath_gyrokinetic *bc_sheath, const char *dir_str, const char *edge_str, double tm, int frame) +{ + struct timespec wst = gkyl_wall_clock(); + + // Package metadata (time/frame + DG basis info). + gkyl_msgpack_map_elem_set_double(app->io_meta_dg_len, app->io_meta_dg, "time", tm); + gkyl_msgpack_map_elem_set_uint(app->io_meta_dg_len, app->io_meta_dg, "frame", frame); + struct gkyl_msgpack_map_elem mpe_vcutsq[] = { + { .key = "poly_order", .elem_type = GKYL_MP_UNSIGNED_INT, .uval = app->basis.poly_order }, + { .key = "basis_type", .elem_type = GKYL_MP_STRING, .cval = "serendipity" }, + { .key = "Description", .elem_type = GKYL_MP_STRING, + .cval = "Square of the velocity cutoff used in the gyrokinetic sheath BC." } + }; + int mpe_vcutsq_len = sizeof(mpe_vcutsq)/sizeof(mpe_vcutsq[0]); + int io_meta_len[] = {app->io_meta_dg_len, mpe_vcutsq_len}; + const struct gkyl_msgpack_map_elem* io_meta[] = {app->io_meta_dg, mpe_vcutsq}; + struct gkyl_msgpack_data *mt = gkyl_msgpack_create_union(sizeof(io_meta_len)/sizeof(int), io_meta_len, io_meta); + + const char *fmt = "%s-%s_bc_%s%s_vcutsq_%d.gkyl"; + int sz = gkyl_calc_strlen(fmt, app->name, gks->info.name, dir_str, edge_str, frame); + char fileNm[sz+1]; // ensures no buffer overflow + snprintf(fileNm, sizeof fileNm, fmt, app->name, gks->info.name, dir_str, edge_str, frame); + + gkyl_bc_sheath_gyrokinetic_write_vcutsq(bc_sheath, mt, fileNm); + + gkyl_msgpack_data_release(mt); + app->stat.species_diag_io_tm += gkyl_time_diff_now_sec(wst); + app->stat.n_diag_io += 1; +} + static void gk_species_write_dynamic(gkyl_gyrokinetic_app* app, struct gk_species *gks, double tm, int frame) { @@ -348,6 +400,13 @@ gk_species_write_dynamic(gkyl_gyrokinetic_app* app, struct gk_species *gks, doub app->stat.species_io_tm += gkyl_time_diff_now_sec(wst); app->stat.n_io += 1; + + // Write out the sheath BC velocity cutoff (vcutsq). + int par_dir = app->cdim-1; // Sheath BC acts in the parallel direction. + if (gks->lower_bc[par_dir].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE || gks->lower_bc[par_dir].type == GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING) + gk_species_write_vcutsq(app, gks, gks->bc_sheath_lo,"z","lower", tm, frame); + if (gks->upper_bc[par_dir].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE || gks->upper_bc[par_dir].type == GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING) + gk_species_write_vcutsq(app, gks, gks->bc_sheath_up, "z", "upper", tm, frame); } static void @@ -674,9 +733,14 @@ gk_species_release_dynamic(const gkyl_gyrokinetic_app* app, const struct gk_spec } // Copy BCs are allocated by default. Need to free. + bool release_surr_aux_var = false; for (int d=0; dcdim; ++d) { - if (s->lower_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH) { + if (s->lower_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING) { + gkyl_bc_sheath_gyrokinetic_release(s->bc_sheath_lo); + } + else if (s->lower_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { gkyl_bc_sheath_gyrokinetic_release(s->bc_sheath_lo); + release_surr_aux_var = true; } else if (s->lower_bc[d].type == GKYL_BC_GK_SPECIES_TWISTSHIFT) { gkyl_bc_twistshift_release(s->bc_ts_lo); @@ -688,9 +752,13 @@ gk_species_release_dynamic(const gkyl_gyrokinetic_app* app, const struct gk_spec gkyl_bc_basic_gyrokinetic_release(s->bc_lo[d]); } - if (s->upper_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH) { + if (s->upper_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING) { gkyl_bc_sheath_gyrokinetic_release(s->bc_sheath_up); } + else if (s->upper_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { + gkyl_bc_sheath_gyrokinetic_release(s->bc_sheath_up); + release_surr_aux_var = true; + } else if (s->upper_bc[d].type == GKYL_BC_GK_SPECIES_TWISTSHIFT) { gkyl_bc_twistshift_release(s->bc_ts_up); } @@ -700,6 +768,11 @@ gk_species_release_dynamic(const gkyl_gyrokinetic_app* app, const struct gk_spec (s->upper_bc[d].type == GKYL_BC_GK_SPECIES_FIXED_FUNC) ) { gkyl_bc_basic_gyrokinetic_release(s->bc_up[d]); } + if (release_surr_aux_var) { + gk_species_moment_release(app, &s->sheath_moms); + gkyl_array_release(s->dens_sheath); + gkyl_array_release(s->temp_sheath); + } } if (app->gk_geom->has_LCFS && app->cdim == 3) { @@ -872,11 +945,14 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app for (int d=0; dlower_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH) { + if (gks->lower_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING || + gks->lower_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { struct gkyl_range *sol_skin = gk_app_inp->geometry.has_LCFS? &gks->local_lower_skin_par_sol : &gks->local_lower_skin[d]; struct gkyl_range *sol_ghost = gk_app_inp->geometry.has_LCFS? &gks->local_lower_ghost_par_sol : &gks->local_lower_ghost[d]; - gks->bc_sheath_lo = gkyl_bc_sheath_gyrokinetic_new(d, GKYL_LOWER_EDGE, gks->basis_on_dev, - sol_skin, sol_ghost, gks->vel_map, cdim, 2.0*(gks->info.charge/gks->info.mass), app->use_gpu); + gks->bc_sheath_lo = gkyl_bc_sheath_gyrokinetic_new(d, GKYL_LOWER_EDGE, gks->basis_on_dev, + sol_skin, sol_ghost, gks->vel_map, cdim, 2.0*(gks->info.charge/gks->info.mass), + gks->lower_bc[d].type, gks->lower_bc[d].aux_str, + &gks->grid, &gks->local, gks->basis.poly_order, app->use_gpu); } else if (gks->lower_bc[d].type == GKYL_BC_GK_SPECIES_TWISTSHIFT) { assert(cdim == 3); @@ -932,11 +1008,14 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app } // Upper BC. - if (gks->upper_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH) { + if (gks->upper_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING || + gks->upper_bc[d].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { struct gkyl_range *sol_skin = gk_app_inp->geometry.has_LCFS? &gks->local_upper_skin_par_sol : &gks->local_upper_skin[d]; struct gkyl_range *sol_ghost = gk_app_inp->geometry.has_LCFS? &gks->local_upper_ghost_par_sol : &gks->local_upper_ghost[d]; - gks->bc_sheath_up = gkyl_bc_sheath_gyrokinetic_new(d, GKYL_UPPER_EDGE, gks->basis_on_dev, - sol_skin, sol_ghost, gks->vel_map, cdim, 2.0*(gks->info.charge/gks->info.mass), app->use_gpu); + gks->bc_sheath_up = gkyl_bc_sheath_gyrokinetic_new(d, GKYL_UPPER_EDGE, gks->basis_on_dev, + sol_skin, sol_ghost, gks->vel_map, cdim, 2.0*(gks->info.charge/gks->info.mass), + gks->upper_bc[d].type, gks->upper_bc[d].aux_str, + &gks->grid, &gks->local, gks->basis.poly_order, app->use_gpu); } else if (gks->upper_bc[d].type == GKYL_BC_GK_SPECIES_TWISTSHIFT) { assert(cdim == 3); @@ -983,7 +1062,7 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app gks->f->ncomp, app->cdim, app->use_gpu); gkyl_bc_basic_gyrokinetic_advance(gfss_bc_op, gks->bc_buffer_up_fixed, gks->f1); gkyl_bc_basic_gyrokinetic_release(gfss_bc_op); - // Copy ghost range into buffer. + // Copy ghost range into buffer. gkyl_bc_basic_gyrokinetic_buffer_fixed_func(gks->bc_up[d], gks->bc_buffer_up_fixed, gks->f1); gkyl_array_clear(gks->f1, 0.0); gk_species_projection_release(app, &gk_proj_bc_up); @@ -1034,6 +1113,16 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app gks->bc_ts_up = gkyl_bc_twistshift_new(&tsinp_up); } + bool alloc_surr_aux_var = false; + for (int d=0; d<2*app->cdim; ++d) + alloc_surr_aux_var = alloc_surr_aux_var || gks->info.bcs[d].type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE; + + if (alloc_surr_aux_var) { + gk_species_moment_init(app, gks, &gks->sheath_moms, GKYL_F_MOMENT_MAXWELLIAN, false); + gks->dens_sheath = mkarr(app->use_gpu, app->basis.num_basis, app->local_ext.volume); + gks->temp_sheath = mkarr(app->use_gpu, app->basis.num_basis, app->local_ext.volume); + } + // Set function pointers. gks->rhs_func = gk_species_rhs_dynamic; gks->rhs_implicit_func = gk_species_rhs_implicit_dynamic; @@ -1935,7 +2024,7 @@ gk_species_copy_range(struct gk_species *species, struct gkyl_array *out, } void -gk_species_apply_bc(gkyl_gyrokinetic_app *app, const struct gk_species *species, struct gkyl_array *f) +gk_species_apply_bc(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gkyl_array *f) { species->bc_func(app, species, f); } diff --git a/gyrokinetic/apps/gk_species_source.c b/gyrokinetic/apps/gk_species_source.c index 9a28277aa2..bb45b10e05 100644 --- a/gyrokinetic/apps/gk_species_source.c +++ b/gyrokinetic/apps/gk_species_source.c @@ -204,6 +204,7 @@ gk_species_source_write_integrated_mom_enabled(gkyl_gyrokinetic_app* app, struct } } gkyl_dynvec_clear(gks->src.integ_diag); + app->stat.n_diag_io += 1; if (gks->src.num_adapt_sources > 0) { if (rank == 0) { @@ -230,6 +231,7 @@ gk_species_source_write_integrated_mom_enabled(gkyl_gyrokinetic_app* app, struct } } gkyl_dynvec_clear(gks->src.part_diag); + app->stat.n_diag_io += 1; if (rank == 0) { // Write out temperature diagnostics for adaptive sources. @@ -255,11 +257,11 @@ gk_species_source_write_integrated_mom_enabled(gkyl_gyrokinetic_app* app, struct } } gkyl_dynvec_clear(gks->src.temp_diag); + app->stat.n_diag_io += 1; gks->src.is_first_integ_write_call_adapt = false; } app->stat.species_diag_io_tm += gkyl_time_diff_now_sec(wst); - app->stat.n_diag_io += 1; } diff --git a/gyrokinetic/apps/gkyl_gyrokinetic.h b/gyrokinetic/apps/gkyl_gyrokinetic.h index e04e1510ba..a5222a5a90 100644 --- a/gyrokinetic/apps/gkyl_gyrokinetic.h +++ b/gyrokinetic/apps/gkyl_gyrokinetic.h @@ -219,6 +219,7 @@ struct gkyl_gyrokinetic_bc { struct gkyl_gyrokinetic_emission_inp emission; bool write_diagnostics; // Whether to output diagnostics. int bidx; // Block index (for multiblock solver). + char aux_str[128]; // Auxiliary string (e.g. path to surrogate model for sheath BCs). }; struct gkyl_gyrokinetic_geometry { diff --git a/gyrokinetic/apps/gkyl_gyrokinetic_priv.h b/gyrokinetic/apps/gkyl_gyrokinetic_priv.h index 5615160973..2dfd747ee2 100644 --- a/gyrokinetic/apps/gkyl_gyrokinetic_priv.h +++ b/gyrokinetic/apps/gkyl_gyrokinetic_priv.h @@ -1039,7 +1039,11 @@ struct gk_species { struct gkyl_array *f_host; // Host copy for IO and initialization. struct gkyl_array *gyro_phi; // Gyroaveraged electrostatic potential. - + + struct gk_species_moment sheath_moms; // Maxwellian moment array to get temperature and density for sheath BCs. + struct gkyl_array *dens_sheath; // Zeroth maxwellian moment, at the sheath used for surrogate BCs. + struct gkyl_array *temp_sheath; // Third maxwellian moment times mass, at the sheath used for surrogate BCs. + struct gk_species_moment m0; // Computes charge density. struct gk_species_moment integ_moms; // Integrated moments. struct gk_species_moment *moms; // Diagnostic moments @@ -1126,7 +1130,7 @@ struct gk_species { const struct gkyl_array *fin, struct gkyl_array *rhs, struct gkyl_array **bflux_moms); double (*rhs_implicit_func)(gkyl_gyrokinetic_app *app, struct gk_species *species, const struct gkyl_array *fin, struct gkyl_array *rhs, struct gkyl_array **bflux_moms, double dt); - void (*bc_func)(gkyl_gyrokinetic_app *app, const struct gk_species *species, + void (*bc_func)(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gkyl_array *f); void (*release_func)(const gkyl_gyrokinetic_app* app, const struct gk_species *s); void (*step_f_func)(struct gkyl_array* out, double dt, const struct gkyl_array* inp); @@ -3246,7 +3250,7 @@ void gk_species_apply_pos_shift(gkyl_gyrokinetic_app* app, struct gk_species *gk * @param species Pointer to species. * @param f Field to apply BCs. */ -void gk_species_apply_bc(gkyl_gyrokinetic_app *app, const struct gk_species *species, struct gkyl_array *f); +void gk_species_apply_bc(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gkyl_array *f); /** * Fill stat object in app with collision timers. diff --git a/gyrokinetic/apps/gyrokinetic_lw.c b/gyrokinetic/apps/gyrokinetic_lw.c index 7a1a1500a7..ce0b0c901a 100644 --- a/gyrokinetic/apps/gyrokinetic_lw.c +++ b/gyrokinetic/apps/gyrokinetic_lw.c @@ -136,7 +136,8 @@ static const struct gkyl_str_int_pair gk_bcs[] = { { "speciesFunc", GKYL_BC_GK_SPECIES_FUNC }, // Fill ghost cell using a user-function. { "speciesFixedFunc", GKYL_BC_GK_SPECIES_FIXED_FUNC }, // Fixed function, time-independent. { "speciesZeroFlux", GKYL_BC_GK_SPECIES_ZERO_FLUX }, // Zero flux. - { "speciesSheath", GKYL_BC_GK_SPECIES_SHEATH }, // Sheath. + { "speciesSheathConducting", GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, // Sheath. + { "speciesSheathSurrogate", GKYL_BC_GK_SPECIES_SHEATH_SURROGATE }, // Sheath. { "speciesRecycle", GKYL_BC_GK_SPECIES_RECYCLE }, // Recycling. { "speciesPeriodic", GKYL_BC_GK_SPECIES_PERIODIC }, // Periodic. { "speciesTwistshift", GKYL_BC_GK_SPECIES_TWISTSHIFT }, // Twist-shift. diff --git a/gyrokinetic/creg/ignore_c_tests.lua b/gyrokinetic/creg/ignore_c_tests.lua index efb31ed08c..49e6493ae6 100644 --- a/gyrokinetic/creg/ignore_c_tests.lua +++ b/gyrokinetic/creg/ignore_c_tests.lua @@ -22,6 +22,11 @@ return { "rt_gk_bgk_periodic_sodshock_1x2v_p1", -- crashes compareFiles (C assertion in gkyl_aligned_free_) "rt_gk_bgk_im_periodic_sodshock_1x2v_p1", -- crashes compareFiles (C assertion in gkyl_aligned_free_) "rt_gk_wham_1xIC_2x2v_p1", -- crashes compareFiles (C assertion in gkyl_aligned_free_) + "rt_gk_multib_tcv_x21_3x2v_p1", -- Not ready yet. + "rt_gk_cbc_2x2v_p1", -- The setup is not ready yet. + "rt_gk_tcv_iwl_adapt_source_3x2v_p1", -- The shift function is too large and makes it crash. + "rt_gk_neut_step_2x3v_p1", + "rt_gk_multib_asdex_solonly_3x2v_p1", -- eqdisk reading problem. }, gpu = { }, diff --git a/gyrokinetic/creg/rt_gk_asdex_solonly_3x2v_p1.c b/gyrokinetic/creg/rt_gk_asdex_solonly_3x2v_p1.c index 4d14f4918c..0e0fe22467 100644 --- a/gyrokinetic/creg/rt_gk_asdex_solonly_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_asdex_solonly_3x2v_p1.c @@ -42,11 +42,11 @@ struct gk_app_ctx { double psi_sep; double Lx, Ly, Lz; double x_min, x_max, y_min, y_max, z_min, z_max, rho_min, rho_max; - int num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu; + int Nx, Ny, Nz, Nvpar, Nmu; int cells[GKYL_MAX_DIM], poly_order; double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; // Simulation control parameters - double final_time, write_phase_freq; + double t_end, write_phase_freq; int num_frames, int_diag_calc_num, num_failures_max; double dt_failure_tol; }; @@ -260,11 +260,11 @@ struct gk_app_ctx create_ctx(void) double temp_recycle_srcWALL = 4.0 * eV; // Grid parameters - int num_cell_x = 12; - int num_cell_y = 12; - int num_cell_z = 8; - int num_cell_vpar = 8; - int num_cell_mu = 4; + int Nx = 12; + int Ny = 12; + int Nz = 8; + int Nvpar = 8; + int Nmu = 4; int poly_order = 1; // Velocity box dimensions @@ -273,7 +273,7 @@ struct gk_app_ctx create_ctx(void) double vpar_max_ion = 6.*vti; double mu_max_ion = mi*pow(4*vti,2)/(2*B0); - double final_time = 1.0e-4; + double t_end = 1.0e-4; int num_frames = 100; double write_phase_freq = 0.01; int int_diag_calc_num = num_frames*100; @@ -314,17 +314,17 @@ struct gk_app_ctx create_ctx(void) .energy_srcWALL = energy_srcWALL, .particle_srcWALL = particle_srcWALL, .floor_srcWALL = floor_srcWALL, .temp_recycle_srcWALL = temp_recycle_srcWALL, - .num_cell_x = num_cell_x, - .num_cell_y = num_cell_y, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, @@ -470,8 +470,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 10, @@ -601,8 +601,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 10, @@ -688,7 +688,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/creg/rt_gk_bgk_asdex_2x2v_p1.c b/gyrokinetic/creg/rt_gk_bgk_asdex_2x2v_p1.c index 31769e444d..b2814a26bd 100644 --- a/gyrokinetic/creg/rt_gk_bgk_asdex_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_bgk_asdex_2x2v_p1.c @@ -419,8 +419,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 9, @@ -505,8 +505,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 9, diff --git a/gyrokinetic/creg/rt_gk_bgk_im_asdex_2x2v_p1.c b/gyrokinetic/creg/rt_gk_bgk_im_asdex_2x2v_p1.c index c020f35d70..06f0b372f1 100644 --- a/gyrokinetic/creg/rt_gk_bgk_im_asdex_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_bgk_im_asdex_2x2v_p1.c @@ -421,8 +421,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 9, @@ -508,8 +508,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 9, diff --git a/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c index b49d37b153..df3989d022 100644 --- a/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c @@ -63,15 +63,15 @@ struct gk_app_ctx { bool can_max; // Krook and buffer parameters. double nu_krook; - int num_cell_buff; + int Nbuff; // Grid parameters double Lx, Lz; double x_min, z_min, x_max, z_max; - int num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu; + int Nx, Nz, Nvpar, Nmu; int cells[GKYL_MAX_DIM], poly_order; double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; // Simulation control parameters - double final_time, write_phase_freq; + double t_end, write_phase_freq; int num_frames, int_diag_calc_num, num_failures_max; double dt_failure_tol; double max_run_time; // Maximum run time in seconds, 0 means no limit. @@ -326,14 +326,14 @@ void double_buffer_profile(double t, const double *xn, double *fout, void *ctx) { double x = xn[0]; struct gk_app_ctx *app = ctx; - int nx = app->num_cell_x; + int nx = app->Nx; double x_max = app->x_max; double x_min = app->x_min; double Lx = app->Lx; double Hbuff; // See Eq. 49 of V. Grandgirard et al. / Computer Physics Communications 207 (2016) 35–68 double Bs = 0.015; // Buffer transition width as a fraction of the domain size. - double Bl = app->num_cell_buff / (double)nx; // Buffer fraction. + double Bl = app->Nbuff / (double)nx; // Buffer fraction. Hbuff = 1 + 0.5 * (tanh((x - x_max + Bl*Lx)/(Bs*Lx)) - tanh((x - x_min - Bl*Lx)/(Bs*Lx))); fout[0] = Hbuff * app->nu_krook; } @@ -350,7 +350,7 @@ double tanh_profile(double x, double v0, double Lgrad, void *ctx) { struct gk_app_ctx *app = ctx; // Profile use in Gysela (see V. Grandgirard et al. / Computer Physics Communications 207 (2016) 35–68). - double buff_frac = (double)app->num_cell_buff / app->num_cell_x; + double buff_frac = (double)app->Nbuff / app->Nx; double delta = 0.5*(1-buff_frac) * app->Lx; double arg = x / (app->a_mid * delta); double prof_factor = (app->a_mid * delta) / Lgrad; @@ -575,15 +575,15 @@ struct gk_app_ctx create_ctx(void) double inv_asp_ratio = a_mid/R0; // Grid parameters - int num_cell_x = 4; - int num_cell_z = 4; - int num_cell_vpar = 4; - int num_cell_mu = 2; + int Nx = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 2; int poly_order = 1; // IC, Krook, buffer, and integration lookup tables (LUTs) parameters. double nu_krook = 1.0/1.0e-7; - int num_cell_buff = 2; // Number of cells in the buffer region on each side. + int Nbuff = 2; // Number of cells in the buffer region on each side. bool can_max = false; // Whether to use the canonical maxwellian formulation for the IC. int psi_lut_nfact = 100*(poly_order+1); // Resolution factor for the psi lookup table. @@ -592,7 +592,7 @@ struct gk_app_ctx create_ctx(void) double mu_max_elc = 7*Te0/B0; double vpar_max_ion = 4.*vti; double mu_max_ion = 7*Ti0/B0; - double final_time = 0.01*t_itg; + double t_end = 0.01*t_itg; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -609,7 +609,7 @@ struct gk_app_ctx create_ctx(void) // printf("R0/c_s = %1.2e [s]\n", t_unit); // printf("t_itg = %1.2e [s], t_gam = %1.2e [s]\n", t_itg, t_gam); // printf("t_itg c_s/R0 = %1.2e, t_gam c_s/R0 = %1.2e\n", t_itg/t_unit, t_gam/t_unit); - // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/num_cell_y)); + // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/Ny)); struct gk_app_ctx ctx = { .cdim = cdim, @@ -631,7 +631,7 @@ struct gk_app_ctx create_ctx(void) .LTi = LTi , .Lx = Lx , .Lz = Lz , - .num_cell_buff = num_cell_buff, + .Nbuff = Nbuff, .nu_krook = nu_krook, .can_max = can_max, .x_min = x_min, .x_max = x_max, @@ -640,20 +640,20 @@ struct gk_app_ctx create_ctx(void) .mi = mi, .qi = qi, .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, .nuFrac = nuFrac, - .num_cell_x = num_cell_x, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, - .psi_lut_size = psi_lut_nfact*num_cell_x, + .psi_lut_size = psi_lut_nfact*Nx, }; return ctx; } @@ -889,7 +889,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c index 2dcfcb6175..723c056803 100644 --- a/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c @@ -63,15 +63,15 @@ struct gk_app_ctx { bool can_max; // Krook and buffer parameters. double nu_krook; - int num_cell_buff; + int Nbuff; // Grid parameters double Lx, Ly, Lz; double x_min, y_min, z_min, x_max, y_max, z_max; - int num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu; + int Nx, Ny, Nz, Nvpar, Nmu; int cells[GKYL_MAX_DIM], poly_order; double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; // Simulation control parameters - double final_time, write_phase_freq; + double t_end, write_phase_freq; int num_frames, int_diag_calc_num, num_failures_max; double dt_failure_tol; double max_run_time; // Maximum run time in seconds, 0 means no limit. @@ -354,14 +354,14 @@ void double_buffer_profile(double t, const double *xn, double *fout, void *ctx) { double x = xn[0]; struct gk_app_ctx *app = ctx; - int nx = app->num_cell_x; + int nx = app->Nx; double x_max = app->x_max; double x_min = app->x_min; double Lx = app->Lx; double Hbuff; // See Eq. 49 of V. Grandgirard et al. / Computer Physics Communications 207 (2016) 35–68 double Bs = 0.015; // Buffer transition width as a fraction of the domain size. - double Bl = app->num_cell_buff / (double)nx; // Buffer fraction. + double Bl = app->Nbuff / (double)nx; // Buffer fraction. Hbuff = 1 + 0.5 * (tanh((x - x_max + Bl*Lx)/(Bs*Lx)) - tanh((x - x_min - Bl*Lx)/(Bs*Lx))); fout[0] = Hbuff * app->nu_krook; } @@ -370,7 +370,7 @@ double tanh_profile(double x, double v0, double Lgrad, void *ctx) { struct gk_app_ctx *app = ctx; // Profile use in Gysela (see V. Grandgirard et al. / Computer Physics Communications 207 (2016) 35–68). - double buff_frac = (double)app->num_cell_buff / app->num_cell_x; + double buff_frac = (double)app->Nbuff / app->Nx; double delta = 0.5*(1-buff_frac) * app->Lx; double arg = x / (app->a_mid * delta); double prof_factor = (app->a_mid * delta) / Lgrad; @@ -604,16 +604,16 @@ struct gk_app_ctx create_ctx(void) double inv_asp_ratio = a_mid/R0; // Grid parameters - int num_cell_x = 4; - int num_cell_y = 4; - int num_cell_z = 4; - int num_cell_vpar = 4; - int num_cell_mu = 2; + int Nx = 4; + int Ny = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 2; int poly_order = 1; // IC, Krook, buffer, and integration lookup tables (LUTs) parameters. double nu_krook = 1.0/1.0e-7; - int num_cell_buff = 2; // Number of cells in the buffer region on each side. + int Nbuff = 2; // Number of cells in the buffer region on each side. bool can_max = false; // Whether to use the canonical maxwellian formulation for the IC. int psi_lut_nfact = 100*(poly_order+1); // Resolution factor for the psi lookup table. @@ -622,7 +622,7 @@ struct gk_app_ctx create_ctx(void) double mu_max_elc = 7*Te0/B0; double vpar_max_ion = 4.*vti; double mu_max_ion = 7*Ti0/B0; - double final_time = 0.01*t_itg; + double t_end = 0.01*t_itg; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -639,7 +639,7 @@ struct gk_app_ctx create_ctx(void) // printf("R0/c_s = %1.2e [s]\n", t_unit); // printf("t_itg = %1.2e [s], t_gam = %1.2e [s]\n", t_itg, t_gam); // printf("t_itg c_s/R0 = %1.2e, t_gam c_s/R0 = %1.2e\n", t_itg/t_unit, t_gam/t_unit); - // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/num_cell_y)); + // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/Ny)); struct gk_app_ctx ctx = { .cdim = cdim, @@ -662,7 +662,7 @@ struct gk_app_ctx create_ctx(void) .Lx = Lx , .Ly = Ly , .Lz = Lz , - .num_cell_buff = num_cell_buff, + .Nbuff = Nbuff, .nu_krook = nu_krook, .can_max = can_max, .x_min = x_min, .x_max = x_max, @@ -672,21 +672,21 @@ struct gk_app_ctx create_ctx(void) .mi = mi, .qi = qi, .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, .nuFrac = nuFrac, - .num_cell_x = num_cell_x, - .num_cell_y = num_cell_y, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, - .psi_lut_size = psi_lut_nfact*num_cell_x, + .psi_lut_size = psi_lut_nfact*Nx, }; return ctx; } @@ -915,7 +915,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/creg/rt_gk_d3d_iwl_2x2v_p1.c b/gyrokinetic/creg/rt_gk_d3d_iwl_2x2v_p1.c index 22edb63f91..8c58a0ec5e 100644 --- a/gyrokinetic/creg/rt_gk_d3d_iwl_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_d3d_iwl_2x2v_p1.c @@ -632,8 +632,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 4, @@ -722,8 +722,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 4, diff --git a/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c b/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c index 5ac1995229..a08a8b2744 100644 --- a/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c @@ -714,8 +714,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 1, @@ -802,8 +802,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 1, diff --git a/gyrokinetic/creg/rt_gk_helical_3x2v_p1.c b/gyrokinetic/creg/rt_gk_helical_3x2v_p1.c new file mode 100644 index 0000000000..2884a8c498 --- /dev/null +++ b/gyrokinetic/creg/rt_gk_helical_3x2v_p1.c @@ -0,0 +1,656 @@ +/* + * This regression test is based on Section 5.2, "Helical SOL configuration + * including magnetic shear", Thesis of Noah Mandell, 2021. +*/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// Define the context of the simulation. This is basically all the globals +struct gk_app_ctx { + int cdim, vdim; // Dimensionality. + + // Geometry and magnetic field. + double R0; + double a0; + double B0; + double Bvx0; + double x0; + double H; + int n; // Exponent for vertical magnetic field profile. + + // Plasma parameters. + double me; double qe; + double mi; double qi; + double n0; double Te0; double Ti0; + + // Collisions. + double nu_frac; + + // Source parameters. + double Psrc; + double S0; + double xSource; + double lambdaSource; + + // Grid parameters. + double Lx; // Domain size in radial direction. + double Ly; // Domain size in binormal direction. + double Lz; // Domain size along magnetic field. + double x_min; double x_max; + double y_min; double y_max; + double z_min; double z_max; + int Nx; + int Ny; + int Nz; + int Nvpar; + int Nmu; + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + int poly_order; + double vpar_max_elc; double mu_max_elc; + double vpar_max_ion; double mu_max_ion; + + double t_end; // End time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. + double max_run_time; // Maximum run time in seconds, 0 means no limit. +}; + +double random0to1() +{ + return 1.0;//(double)rand() / (double)RAND_MAX; +} + +// Common source density profiles. +double sourceDensity(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], z = xn[2]; + double sourceFloor = 0.1; + + struct gk_app_ctx *app = ctx; + double S0 = app->S0; + double lambdaSource = app->lambdaSource; + double xSource = app->xSource; + double Lz = app->Lz; + + if (x < xSource) { + sourceFloor = 0.5; + } + if (fabs(z) < Lz/4) { + return 0.90625*S0*fmax(exp(-0.5*pow((x-xSource)/lambdaSource,2)),sourceFloor); + } else { + return 1e-10; + } +} + +// Common source temperature profile. +double sourceTemperature(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], z = xn[2]; + struct gk_app_ctx *app = ctx; + double xSource = app->xSource; + double lambdaSource = app->lambdaSource; + if (x < xSource + 3 * lambdaSource) { + return 80*GKYL_ELEMENTARY_CHARGE; + } else { + return 30*GKYL_ELEMENTARY_CHARGE; + } +} + +// Initial density. +double densityInit(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], y = xn[1], z = xn[2]; + struct gk_app_ctx *app = ctx; + double Ls = app->Lz/4; + double xSource[3] = {x, y, 0}; + double effectiveSource = sourceDensity(t, xSource, ctx); + double c_ss = sqrt(5/3*sourceTemperature(t, xSource, ctx)/app->mi); + double nPeak = 4*sqrt(5)/3/c_ss*Ls*effectiveSource/2; + double perturb = 1e-3*(random0to1() - 0.5)*2.0; + if (fabs(z) <= Ls) { + return nPeak * (1 + sqrt(1-pow(z/Ls,2)))/2 * (1+perturb); + } else { + return nPeak/2 * (1+perturb); + } +} + +// Initial temperature. +double temperatureInit(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], y = xn[1], z = xn[2]; + struct gk_app_ctx *app = ctx; + double xSource = app->xSource; + double lambdaSource = app->lambdaSource; + if (x < xSource + 3*lambdaSource) { + return 80*GKYL_ELEMENTARY_CHARGE; + } else { + return 20*GKYL_ELEMENTARY_CHARGE; + } +} + +// Initial ion drift speed. +double driftSpeed(const double * GKYL_RESTRICT xn, void *ctx){ + double x = xn[0], y = xn[1], z = xn[2]; + struct gk_app_ctx *app = ctx; + double xSource = app->xSource; + double lambdaSource = app->lambdaSource; + double Lz = app->Lz; + double mi = app->mi; + double Te; + if (x < xSource + 3*lambdaSource) { + Te = 50*GKYL_ELEMENTARY_CHARGE; + } else { + Te = 20*GKYL_ELEMENTARY_CHARGE; + } + double Ls = Lz/4; + if (fabs(z) <= Ls) { + return z/Ls*sqrt(Te/mi); + } else { + return (z > 0 ? 1.0 : -1.0)*sqrt(Te/mi); + } +} + +// Mapping +double Rx(const double *xc, void *ctx) +{ + return xc[0]; +} +double Zx(const double *xc, void *ctx) +{ + return xc[2]; +} + +// Magnetic field functions. +double Bphi(const double *xc, void *ctx) +{ + double x = xc[0]; + struct gk_app_ctx *app = ctx; + double B0 = app->B0; + double R0 = app->R0; + + double R = Rx(xc, ctx); + return B0*R0/R; +} + +double Bvert(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Bvx0 = app->Bvx0; + double x0 = app->x0; + int n = app->n; + double R = Rx(xc, ctx); + + return Bvx0 * pow(R, n); +} + +double Bmag(const double *xc, void *ctx) +{ + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + return Bv * sqrt(1 + pow(Bt/Bv,2)); +} + +// Toroidal angle coordinate. +double phix(const double *xc, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double R0 = app->R0; + double Lz = app->Lz; + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + return y/R0 + (Bt * z)/(Bv * x); +} + +double qprofile(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double H = app->H; + double R = Rx(xc, ctx); + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + + return (H * Bt)/(2*GKYL_PI*R*Bv); +} + +// Interface function calls. +void source_density(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = sourceDensity(t, xn, ctx); } +void source_temperature(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = sourceTemperature(t, xn, ctx); } +void density_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = densityInit(t, xn, ctx); } +void temp_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = temperatureInit(t, xn, ctx); } +void upar_ion_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = driftSpeed(xn, ctx); } +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + // Cartesian formulation of the magnetic field. + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + double phi = phix(xc, ctx); + fout[0] = -Bt*sin(phi); + fout[1] = Bt*cos(phi); + fout[2] = Bv; +} +void zero_func(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = 0.0; } + + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + // Map to cylindrical (R, Z, phi) coordinates. + double R = Rx(xc, ctx); + double Z = Zx(xc, ctx); + double phi = phix(xc, ctx); + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +struct gk_app_ctx +create_ctx(void) +{ + int cdim = 3, vdim = 2; // Dimensionality. + + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Plasma parameters. Chosen based on the value of a cubic sline + // between the last TS data inside the LCFS and the probe data in + // in the far SOL, near R=0.475 m. + double AMU = 2.01410177811; + double mi = mp*AMU; // Deuterium ions. + double Te0 = 40*eV; + double Ti0 = 40*eV; + double n0 = 7e19; // [1/m^3] (10 times NSTX ref.) + + // Geometry and magnetic field. + double B0 = 0.5; + double R0 = 0.85; + double a0 = 0.5; + double H = 2.4; // Poloidal length (used to get the field line pitch). + double Lcx0 = 8.0; // Connection length in the middle of the domain. + int shear = -2; + + double x0 = R0 + a0; + + const double vec0[3] = {x0, 0.0, 0.0}; + double Bc = Bphi(vec0, &(struct gk_app_ctx){.B0=B0, .R0=R0}); + double Bvx0 = H * Bc / Lcx0; + double n = shear + 2; + + // Source parameters. + // double P_SOL = 0.62*1e6; // Power crossing the separatrix, in Watts. + // double Psrc = P_SOL * Ly / (2*M_PI*Rc); + double S0 = 5.7691e23*10; // Taken from the input file. + double xSource = x0 - 0.05; + double lambdaSource = 0.005; + + // Collisions; + double nuFrac = 0.1; + + // Derived parameters. + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); // Sound speed. + double omega_ci = fabs(qi*B0/mi); // Ion cyclotron frequency. + double rho_s = c_s/omega_ci; // Ion sound gyroradius. + + // Box size. + double Lx = 56*rho_s; + double Ly = 100*rho_s*H/Lcx0; + double Lz = H; // [m] + + double x_min = x0 - Lx/2; + double x_max = x0 + Lx/2; + double y_min = -Ly/2; + double y_max = Ly/2; + double z_min = -Lz/2; + double z_max = Lz/2; + + // Grid parameters + int Nx = 8; + int Ny = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 2; + int poly_order = 1; + + double vpar_max_elc = 4.*vte; + double mu_max_elc = 12*me*pow(vte,2)/(2*B0); + double vpar_max_ion = 4.*vti; + double mu_max_ion = 12*mi*pow(vti,2)/(2*B0); + + double t_end = 1.e-6; // End time, should terminate in 43 steps. + int num_frames = 1; + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + + .B0 = B0, + .Bvx0 = Bvx0, + .R0 = R0, + .a0 = a0, + .H = H, + .x0 = x0, + .n = n, + + .Lx = Lx, + .Ly = Ly, + .Lz = Lz, + .x_min = x_min, .x_max = x_max, + .y_min = y_min, .y_max = y_max, + .z_min = z_min, .z_max = z_max, + + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + + .nu_frac = nuFrac, + + .S0 = S0, + .xSource = xSource, + .lambdaSource = lambdaSource, + + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, + + .t_end = t_end, .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + return ctx; +} + + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // Context for init functions. + + // Extract variables from command line arguments. + sscanf(app_args.opt_args, "max_run_time=%lf",&ctx.max_run_time); + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// Define the context of the simulation. This is basically all the globals +struct gk_app_ctx { + int cdim, vdim; // Dimensionality. + + // Geometry and magnetic field. + double B_axis; + double R0; + double Rc; + double Bv0; + double B0; + + // Plasma parameters. + double me; double qe; + double mi; double qi; + double n0; double Te0; double Ti0; + double kperp; + double Ntot; + double center_ic[1], sigma_ic[1]; + + // Collisions. + double nu_frac; + + // Source parameters. + double P_SOL; + double sourceFloor; + // Adaptive source parameters. + int num_sources; + bool adapt_energy_srcCORE, adapt_particle_srcCORE; + double center_srcCORE[1], sigma_srcCORE[1]; + double energy_srcCORE, particle_srcCORE; + double floor_srcCORE; + + // Grid parameters. + double Lx; // Domain size in radial direction. + double Ly; // Domain size in binormal direction. + double Lz; // Domain size along magnetic field. + double x; // Radial location + double z_min; double z_max; + int Nz; + int Nvpar; + int Nmu; + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + int poly_order; + double vpar_max_elc; double mu_max_elc; + double vpar_max_ion; double mu_max_ion; + + double t_end; // End time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. +}; + +// Radial coordinate mapping. +double Rx(const double *xc, void *ctx) +{ + return xc[0]; +} + +// Toroidal magnetic field. +double Bphi(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double B_axis = app->B_axis; + double R0 = app->R0; + double R = Rx(xc, ctx); + return B_axis*R0/R; +} + +// Vertical magnetic field. +double Bvert(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Bv0 = app->Bv0; + return Bv0; +} + +// Magnetic field magnitude. +double bmag(const double *xc, void *ctx) +{ + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + return sqrt(pow(Bt,2) + pow(Bv,2)); +} + +// Field line pitch. +double thetax(const double *xc, void *ctx) +{ + return asin(Bvert(xc, ctx)/bmag(xc, ctx)); +} + +// Parallel coordinate mapping. +double Zx(const double *xc, void *ctx) +{ + double theta = thetax(xc, ctx); + return xc[2]*sin(theta); +} + +double phix(const double *xc, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double Rc = app->Rc; + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + + // Helical sheared mapping. Passes right hand check and conserves particle. + double theta = thetax(xc, ctx); + return y/Rc + (Bt * z*sin(theta))/(Bv * x); +} + +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + // Cartesian formulation of the magnetic field. + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + double phi = phix(xc, ctx); + fout[0] = -Bt*sin(phi); + fout[1] = Bt*cos(phi); + fout[2] = Bv; +} + +void zero_func(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = 0.0; } + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + // Map to cylindrical (R, Z, phi) coordinates. + double R = Rx(xc, ctx); + double Z = Zx(xc, ctx); + double phi = phix(xc, ctx); + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +// Taken from rt gk d3d 3x2c, is this the non uniform v grid mapping? +void mapc2p_vel_elc(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_elc = app->vpar_max_elc; + double mu_max_elc = app->mu_max_elc; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_elc*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_elc*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_elc*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_elc*pow(cmu,2); +} + +void mapc2p_vel_ion(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_ion = app->vpar_max_ion; + double mu_max_ion = app->mu_max_ion; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_ion*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_ion*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_ion*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_ion*pow(cmu,2); +} + +struct gk_app_ctx +create_ctx(void) +{ + int cdim = 1, vdim = 2; // Dimensionality. + + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Plasma parameters. Chosen based on the value of a cubic sline + // between the last TS data inside the LCFS and the probe data in + // in the far SOL, near R=0.475 m. + double AMU = 2.01410177811; + double mi = mp*AMU; // Deuterium ions. + double Te0 = 20*eV; + double Ti0 = 20*eV; + double n0 = 7e19; // [1/m^3] (10 times NSTX ref.) + // Total number of particles in the simulation box. + double Ntot = 6.0e18 * 6 * 6; // The 6 x 6 factors come from scaling from 3x2v to 1x2v. + // Geometry and magnetic field. + double B_axis = 0.5; + double R0 = 0.85; + double a0 = 0.5; + double Lp = 2.4; // Poloidal length at x0. + double Lt = 8.0; // Toroidal length at x0. + double Rc = R0 + a0; + double B0 = B_axis*R0/Rc; + double kperpRhos = 0.15; + + double sintheta = Lp/Lt; + double Bv0 = B0*sintheta; + + // Source parameters. + double P_SOL = 8.1e5; // Power injected in the SOL [W]. + double sourceFloor = 1e-10; // [1/m^3], small but non-zero to avoid numerical issues with very low densities. + + // Collisions; + double nuFrac = 0.1; + + // Derived parameters. + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); // Sound speed. + double omega_ci = fabs(qi*B0/mi); // Ion cyclotron frequency. + double rho_s = c_s/omega_ci; // Ion sound gyroradius. + + // Box size. + double Lz = Lt; // [m] + + int num_sources = 1; + // Fixed source: + // - Injects energy only in the core region (0.25MW per species). + // - The particles injection is only the one that are lost through the inner radial boundary. + double energy_src = P_SOL; // What the source must inject in energy [W] + double particle_src = Ti0/P_SOL;// What the source must inject in particle [1/s] + double center_src[2] = {0.0}; // This is the position of the ion source, + double sigma_src[2] = {Lz/6}; // the electron source will be at +Lz/2. + + double x = Rc; + double z_min = -Lz/2; + double z_max = Lz/2; + double center_ic[1] = {0.0}; // Initial condition centered at z=0. + double sigma_ic[1] = {Lz}; // Initial condition width along z. + + // Grid parameters + int Nz = 16; + int Nvpar = 6; + int Nmu = 4; + int poly_order = 1; + + double vpar_max_elc = 4.*vte; + double mu_max_elc = 12*me*pow(vte,2)/(2*B0); + double vpar_max_ion = 4.*vti; + double mu_max_ion = 12*mi*pow(vti,2)/(2*B0); + + double t_end = 1.e-6; // End time, should terminate in 43 steps. + int num_frames = 1; + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .B_axis = B_axis, + .R0 = R0, + .Rc = Rc, + .Bv0 = Bv0, + .B0 = B0, + .x = x, + .Lz = Lz, + .z_min = z_min, .z_max = z_max, + .kperp = kperpRhos/rho_s, + + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + .Ntot = Ntot, + .center_ic = {center_ic[0]}, + .sigma_ic = {sigma_ic[0]}, + .nu_frac = nuFrac, + + .P_SOL = P_SOL, + .sourceFloor = sourceFloor, + + .num_sources = num_sources, + .adapt_energy_srcCORE = false, + .adapt_particle_srcCORE = false, + .center_srcCORE = {center_src[0]}, + .sigma_srcCORE = {sigma_src[0]}, + .energy_srcCORE = energy_src, + .particle_srcCORE = particle_src, + .floor_srcCORE = 1e-10, + + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, + + .t_end = t_end, .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + return ctx; +} + + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // Context for init functions. + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; dcomm but only invoked on the + // boundary-owning ranks. Request integrated diagnostics only (as TCV does). + .num_integrated_diag_moments = 1, + .integrated_diag_moments = { GKYL_F_MOMENT_HAMILTONIAN }, + }, + + .time_rate_diagnostics = true, + }; + + // ions + struct gkyl_gyrokinetic_species ion = { + .name = "ion", + .charge = ctx.qi, .mass = ctx.mi, + .vdim = ctx.vdim, + .cells = { cells_v[0], cells_v[1] }, + .polarization_density = ctx.n0, + + .lower = { -1.0/sqrt(2.0), 0.0}, + .upper = { 1.0/sqrt(2.0), 1.0}, + .mapc2p = { + .mapping = mapc2p_vel_ion, + .ctx = &ctx, + }, + + .projection = { + .proj_id = GKYL_PROJ_MAXWELLIAN_GAUSSIAN, + .gaussian_mean = {ctx.center_ic[0]}, + .gaussian_std_dev = {ctx.sigma_ic[0]}, + .total_num_particles = ctx.Ntot, + .total_kin_energy = ctx.Ti0 * ctx.Ntot, + .temp_max = 5.0*ctx.Ti0, + .temp_min = 0.1*ctx.Ti0, + .f_floor = 1e-10, + }, + + .collisionless = { + .type = GKYL_GK_COLLISIONLESS_ES, + }, + + .collisions = { + .collision_id = GKYL_LBO_COLLISIONS, + .num_cross_collisions = 1, + .collide_with = { "ion" }, + .den_ref = ctx.n0, + .temp_ref = ctx.Ti0, + .nu_frac = ctx.nu_frac, + }, + + .source = { + .source_id = GKYL_PROJ_SOURCE, + .num_sources = ctx.num_sources, + .num_adapt_sources = ctx.num_sources, + .projection[0] = proj_srcCORE_i, + .adapt[0] = adapt_srcCORE_i, + .diagnostics = { + .num_integrated_diag_moments = 1, + .integrated_diag_moments = { GKYL_F_MOMENT_HAMILTONIAN }, + }, + }, + + .bcs = { + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + }, + + .num_diag_moments = 9, + .diag_moments = {GKYL_F_MOMENT_HAMILTONIAN, GKYL_F_MOMENT_BIMAXWELLIAN, + GKYL_F_MOMENT_M0, GKYL_F_MOMENT_M1, GKYL_F_MOMENT_M2PAR, GKYL_F_MOMENT_M2PERP, + GKYL_F_MOMENT_M2, GKYL_F_MOMENT_M3PAR, GKYL_F_MOMENT_M3PERP}, + + .num_integrated_diag_moments = 1, + .integrated_diag_moments = { GKYL_F_MOMENT_HAMILTONIAN }, + + .boundary_flux_diagnostics = { + // NOTE: frame-based boundary-flux moment grids (.num_diag_moments / + // .diag_moments) deadlock under MPI for cdim=1: the 1x write in + // gk_species_bflux.c is collective over app->comm but only invoked on the + // boundary-owning ranks. Request integrated diagnostics only (as TCV does). + .num_integrated_diag_moments = 1, + .integrated_diag_moments = { GKYL_F_MOMENT_HAMILTONIAN }, + }, + + .time_rate_diagnostics = true, + }; + + // Field. + struct gkyl_gyrokinetic_field field = { + .kperpSq = ctx.kperp * ctx.kperp, + .polarization_bmag = ctx.B0, + .time_rate_diagnostics = true, + }; + + // GK app + struct gkyl_gk app_inp = { + + .cfl_frac_omegaH = 1.0, + .cfl_frac = 1.0, + + .cdim = ctx.cdim, + .lower = { ctx.z_min }, + .upper = { ctx.z_max }, + .cells = { cells_x[0] }, + .poly_order = ctx.poly_order, + .basis_type = app_args.basis_type, + + .geometry = { + .geometry_id = GKYL_GEOMETRY_MAPC2P, + .world = { ctx.Rc, 0.0}, + .mapc2p = mapc2p, // mapping of computational to physical space + .c2p_ctx = &ctx, + .bfield_func = bfield_func, // magnetic field + .bfield_ctx = &ctx, + }, + + .num_species = 2, + .species = { elc, ion }, + .field = field, + + .parallelism = { + .use_gpu = app_args.use_gpu, + .comm = comm, + .cuts = { app_args.cuts[0] }, + } + }; + + snprintf(app_inp.name, sizeof(app_inp.name), "%s", app_args.app_name); + struct gkyl_gyrokinetic_run_inp run_inp = { + .app_inp = app_inp, + .time_stepping = { + .t_end = ctx.t_end, + .num_frames = ctx.num_frames, + .write_phase_freq = ctx.write_phase_freq, + .int_diag_calc_num = ctx.int_diag_calc_num, + .dt_failure_tol = ctx.dt_failure_tol, + .num_failures_max = ctx.num_failures_max, + .is_restart = app_args.is_restart, + .restart_frame = app_args.restart_frame, + .num_steps = app_args.num_steps, + }, + .print_verbosity = { + .enabled = true, + .frequency = 0.01, + }, + }; + + gkyl_gyrokinetic_run_simulation(&run_inp); + + gkyl_gyrokinetic_comms_release(comm); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) + MPI_Finalize(); +#endif + + return 0; +} \ No newline at end of file diff --git a/gyrokinetic/creg/rt_gk_helical_zpar_2x2v_p1.c b/gyrokinetic/creg/rt_gk_helical_zpar_2x2v_p1.c new file mode 100644 index 0000000000..f2211475a0 --- /dev/null +++ b/gyrokinetic/creg/rt_gk_helical_zpar_2x2v_p1.c @@ -0,0 +1,647 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// Define the context of the simulation. This is basically all the globals +struct gk_app_ctx { + int cdim, vdim; // Dimensionality. + + // Geometry and magnetic field. + double B_axis; + double R0; + double Rc; + double Bv0; + + // Plasma parameters. + double me; double qe; + double mi; double qi; + double n0; double Te0; double Ti0; + + // Collisions. + double nu_frac; + + // Source parameters. + double P_SOL; + double S0; + double xSource; + double lambdaSource; + + // Grid parameters. + double Lx; // Domain size in radial direction. + double Ly; // Domain size in binormal direction. + double Lz; // Domain size along magnetic field. + double x_min; double x_max; + double z_min; double z_max; + int Nx; + int Nz; + int Nvpar; + int Nmu; + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + int poly_order; + double vpar_max_elc; double mu_max_elc; + double vpar_max_ion; double mu_max_ion; + + double t_end; // End time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. +}; + +// Common source density profiles. +double sourceDensity(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], z = xn[1]; + double sourceFloor = 0.1; + + struct gk_app_ctx *app = ctx; + double S0 = app->S0; + double lambdaSource = app->lambdaSource; + double xSource = app->xSource; + double Lz = app->Lz; + + if (x < xSource) { + sourceFloor = 0.5; + } + if (fabs(z) < Lz/4) { + return 0.90625*S0*fmax(exp(-0.5*pow((x-xSource)/lambdaSource,2)),sourceFloor); + } else { + return 1e-10; + } +} + +// Common source temperature profile. +double sourceTemperature(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], z = xn[1]; + struct gk_app_ctx *app = ctx; + double xSource = app->xSource; + double lambdaSource = app->lambdaSource; + if (x < xSource + 3 * lambdaSource) { + return 80*GKYL_ELEMENTARY_CHARGE; + } else { + return 30*GKYL_ELEMENTARY_CHARGE; + } +} + +// Initial density. +double densityInit(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], z = xn[1]; + struct gk_app_ctx *app = ctx; + double Ls = app->Lz/4; + double xSource[3] = {x, 0}; + double effectiveSource = sourceDensity(t, xSource, ctx); + double c_ss = sqrt(5/3*sourceTemperature(t, xSource, ctx)/app->mi); + double nPeak = 4*sqrt(5)/3/c_ss*Ls*effectiveSource/2; + pcg64_random_t rng = gkyl_pcg64_init(0); + double perturb = 1e-3*(gkyl_pcg64_rand_double(&rng) - 0.5)*2.0; + if (fabs(z) <= Ls) { + return nPeak * (1 + sqrt(1-pow(z/Ls,2)))/2 * (1+perturb); + } else { + return nPeak/2 * (1+perturb); + } +} + +// Initial temperature. +double temperatureInit(double t, const double * GKYL_RESTRICT xn, void *ctx) +{ + double x = xn[0], z = xn[1]; + struct gk_app_ctx *app = ctx; + double xSource = app->xSource; + double lambdaSource = app->lambdaSource; + if (x < xSource + 3*lambdaSource) { + return 80*GKYL_ELEMENTARY_CHARGE; + } else { + return 20*GKYL_ELEMENTARY_CHARGE; + } +} + +// Initial ion drift speed. +double driftSpeed(const double * GKYL_RESTRICT xn, void *ctx){ + double x = xn[0], z = xn[1]; + struct gk_app_ctx *app = ctx; + double xSource = app->xSource; + double lambdaSource = app->lambdaSource; + double Lz = app->Lz; + double mi = app->mi; + double Te; + if (x < xSource + 3*lambdaSource) { + Te = 50*GKYL_ELEMENTARY_CHARGE; + } else { + Te = 20*GKYL_ELEMENTARY_CHARGE; + } + double Ls = Lz/4; + if (fabs(z) <= Ls) { + return z/Ls*sqrt(Te/mi); + } else { + return (z > 0 ? 1.0 : -1.0)*sqrt(Te/mi); + } +} + +// Radial coordinate mapping. +double Rx(const double *xc, void *ctx) +{ + return xc[0]; +} + +// Toroidal magnetic field. +double Bphi(const double *xc, void *ctx) +{ + double x = xc[0]; + struct gk_app_ctx *app = ctx; + double B_axis = app->B_axis; + double R0 = app->R0; + double R = Rx(xc, ctx); + return B_axis*R0/R; +} + +// Vertical magnetic field. +double Bvert(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Bv0 = app->Bv0; + return Bv0; +} + +// Magnetic field magnitude. +double bmag(const double *xc, void *ctx) +{ + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + return sqrt(pow(Bt,2) + pow(Bv,2)); +} + +// Field line pitch. +double thetax(const double *xc, void *ctx) +{ + return asin(Bvert(xc, ctx)/bmag(xc, ctx)); +} + +// Parallel coordinate mapping. +double Zx(const double *xc, void *ctx) +{ + double theta = thetax(xc, ctx); + return xc[2]*sin(theta); +} + +double phix(const double *xc, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double Rc = app->Rc; + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + + // Original Shi mapping. This mapping does not pass the right hand check. + // double theta = asin(Lp/Lt); + // return (y/sin(theta) + z*cos(theta))/Rc; // O + + // This mapping passes right hand check but does not conserve particle! + // double theta = thetax(xc, ctx); + // return (y/sin(theta) + z*cos(theta))/x; + + // Helical sheared mapping. Passes right hand check and conserves particle. + double theta = thetax(xc, ctx); + return y/Rc + (Bt * z*sin(theta))/(Bv * x); +} + +// Interface function calls. +void source_density(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = sourceDensity(t, xn, ctx); } +void source_temperature(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = sourceTemperature(t, xn, ctx); } +void density_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = densityInit(t, xn, ctx); } +void temp_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = temperatureInit(t, xn, ctx); } +void upar_ion_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = driftSpeed(xn, ctx); } +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + // Cartesian formulation of the magnetic field. + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + double phi = phix(xc, ctx); + fout[0] = -Bt*sin(phi); + fout[1] = Bt*cos(phi); + fout[2] = Bv; +} +void zero_func(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = 0.0; } + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + + // Map to cylindrical (R, Z, phi) coordinates. + double R = Rx(xc, ctx); + double Z = Zx(xc, ctx); + double phi = phix(xc, ctx); + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +// Anomalous diffusion coefficient. +void diffusion_D_func(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + struct sheath_ctx *app = ctx; + + fout[0] = 0.5; // Diffusivity [m^2/s]. +} + +struct gk_app_ctx +create_ctx(void) +{ + int cdim = 2, vdim = 2; // Dimensionality. + + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Plasma parameters. Chosen based on the value of a cubic sline + // between the last TS data inside the LCFS and the probe data in + // in the far SOL, near R=0.475 m. + double AMU = 2.01410177811; + double mi = mp*AMU; // Deuterium ions. + double Te0 = 40*eV; + double Ti0 = 40*eV; + double n0 = 7e19; // [1/m^3] (10 times NSTX ref.) + + // Geometry and magnetic field. + double B_axis = 0.5; + double R0 = 0.85; + double a0 = 0.5; + double Lp = 2.4; // Poloidal length at x0. + double Lt = 8.0; // Toroidal length at x0. + double Rc = R0 + a0; + double B0 = B_axis*R0/Rc; + + double sintheta = Lp/Lt; + double Bv0 = B0*sintheta; + + // Source parameters. + double P_SOL = 8.1e5; + double S0 = 5.7691e23*10; // Multiplied by 10 to increase beta + double xSource = Rc - 0.05; + double lambdaSource = 0.005; + + // Collisions; + double nuFrac = 0.1; + + // Derived parameters. + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); // Sound speed. + double omega_ci = fabs(qi*B0/mi); // Ion cyclotron frequency. + double rho_s = c_s/omega_ci; // Ion sound gyroradius. + + // Box size. + double Lx = 50*rho_s; + double Lz = Lt; // [m] + + double x_min = Rc - Lx/2; + double x_max = Rc + Lx/2; + double z_min = -Lz/2; + double z_max = Lz/2; + + // Grid parameters + int Nx = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 4; + int poly_order = 1; + + double vpar_max_elc = 4.*vte; + double mu_max_elc = 12*me*pow(vte,2)/(2*B0); + double vpar_max_ion = 4.*vti; + double mu_max_ion = 12*mi*pow(vti,2)/(2*B0); + + double t_end = 1.e-6; // End time, should terminate in 43 steps. + int num_frames = 1; + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .B_axis = B_axis, + .R0 = R0, + .Rc = Rc, + .Bv0 = Bv0, + .Lx = Lx, + .Lz = Lz, + .x_min = x_min, .x_max = x_max, + .z_min = z_min, .z_max = z_max, + + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + + .nu_frac = nuFrac, + + .P_SOL = P_SOL, + .S0 = S0, + .xSource = xSource, + .lambdaSource = lambdaSource, + + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, + + .t_end = t_end, .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + return ctx; +} + + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // Context for init functions. + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// Define the context of the simulation. This is basically all the globals +struct gk_app_ctx { + int cdim, vdim; // Dimensionality. + + // Geometry and magnetic field. + double B_axis; + double R0; + double Rc; + double Bv0; + + // Plasma parameters. + double me; double qe; + double mi; double qi; + double n0; double Te0; double Ti0; + double Ntot; + double center_ic[2], sigma_ic[2]; + + // Collisions. + double nu_frac; + + // Adaptive source parameters. + double P_SOL; + int num_sources; + double center_srcCORE[2], sigma_srcCORE[2]; + double center_srcRECYlo[2], sigma_srcRECYlo[2]; + double center_srcRECYup[2], sigma_srcRECYup[2]; + double floor_src; + + // Grid parameters. + double Lx; // Domain size in radial direction. + double Lz; // Domain size along magnetic field. + double x_min; double x_max; + double z_min; double z_max; + int Nx; + int Nz; + int Nvpar; + int Nmu; + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + int poly_order; + double vpar_max_elc; double mu_max_elc; + double vpar_max_ion; double mu_max_ion; + + double t_end; // End time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. +}; + +// Radial coordinate mapping. +double Rx(const double *xc, void *ctx) +{ + return xc[0]; +} + +// Toroidal magnetic field. +double Bphi(const double *xc, void *ctx) +{ + double x = xc[0]; + struct gk_app_ctx *app = ctx; + double B_axis = app->B_axis; + double R0 = app->R0; + double R = Rx(xc, ctx); + return B_axis*R0/R; +} + +// Vertical magnetic field. +double Bvert(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Bv0 = app->Bv0; + return Bv0; +} + +// Magnetic field magnitude. +double bmag(const double *xc, void *ctx) +{ + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + return sqrt(pow(Bt,2) + pow(Bv,2)); +} + +// Field line pitch. +double thetax(const double *xc, void *ctx) +{ + return asin(Bvert(xc, ctx)/bmag(xc, ctx)); +} + +// Parallel coordinate mapping. +double Zx(const double *xc, void *ctx) +{ + double theta = thetax(xc, ctx); + return xc[2]*sin(theta); +} + +double phix(const double *xc, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double Rc = app->Rc; + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + + // Helical sheared mapping. Passes right hand check and conserves particle. + double theta = thetax(xc, ctx); + return y/Rc + (Bt * z*sin(theta))/(Bv * x); +} + +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + // Cartesian formulation of the magnetic field. + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + double phi = phix(xc, ctx); + fout[0] = -Bt*sin(phi); + fout[1] = Bt*cos(phi); + fout[2] = Bv; +} + +void zero_func(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = 0.0; } + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + + // Map to cylindrical (R, Z, phi) coordinates. + double R = Rx(xc, ctx); + double Z = Zx(xc, ctx); + double phi = phix(xc, ctx); + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +// Taken from rt gk d3d 3x2c, is this the non uniform v grid mapping? +void mapc2p_vel_elc(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_elc = app->vpar_max_elc; + double mu_max_elc = app->mu_max_elc; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_elc*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_elc*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_elc*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_elc*pow(cmu,2); +} + +void mapc2p_vel_ion(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_ion = app->vpar_max_ion; + double mu_max_ion = app->mu_max_ion; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_ion*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_ion*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_ion*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_ion*pow(cmu,2); +} + +// Anomalous diffusion coefficient. +void diffusion_D_func(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + struct sheath_ctx *app = ctx; + + fout[0] = 0.5; // Diffusivity [m^2/s]. +} + +struct gk_app_ctx +create_ctx(void) +{ + int cdim = 2, vdim = 2; // Dimensionality. + + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Plasma parameters. Chosen based on the value of a cubic sline + // between the last TS data inside the LCFS and the probe data in + // in the far SOL, near R=0.475 m. + double AMU = 2.01410177811; + double mi = mp*AMU; // Deuterium ions. + double Te0 = 40*eV; + double Ti0 = 40*eV; + double n0 = 7e19; // [1/m^3] (10 times NSTX ref.) + double Ntot = 6.0e18 * 6; // The factor 6 comes from 3x2v scaling. + + // Geometry and magnetic field. + double B_axis = 0.5; + double R0 = 0.85; + double a0 = 0.5; + double Lp = 2.4; // Poloidal length at x0. + double Lt = 8.0; // Toroidal length at x0. + double Rc = R0 + a0; + double B0 = B_axis*R0/Rc; + + double sintheta = Lp/Lt; + double Bv0 = B0*sintheta; + + // Collisions; + double nuFrac = 0.1; + + // Derived parameters. + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); // Sound speed. + double omega_ci = fabs(qi*B0/mi); // Ion cyclotron frequency. + double rho_s = c_s/omega_ci; // Ion sound gyroradius. + + // Box size. + double Lx = 50*rho_s; + double Lz = Lt; // [m] + + double x_min = Rc - Lx/2; + double x_max = Rc + Lx/2; + double z_min = -Lz/2; + double z_max = Lz/2; + double center_ic[2] = {x_min, 0.0}; // Initial condition centered at z=0. + double sigma_ic[2] = {Lx, Lz}; // Initial condition width along x and z. + + // 1+2 adaptive source setup: + // - CORE: at the left boundary (x=xmin), injects a fixed power P_SOL + // and compensate for energy loss through inner radial boundary. + // - RECY: neutral recycling model, put back particles lost through wall + // at 5 eV, no energy compensation. one for up, one for low. + double P_SOL = 8.1e5; // Power injected in the SOL [W]. + int num_sources = 3; + double center_srcCORE[2] = {x_min, 0.0}; // Source centered at x=xmin, z=0. + double sigma_srcCORE[2] = {Lx/16, Lz/8}; // Source width along x and z. + double center_srcRECYup[2] = {x_max, Lz/2}; // Source centered at x=xmax, z=Lz/2 (periodic). + double sigma_srcRECYup[2] = {Lx, Lz/16}; // Source width along x and z. + double center_srcRECYlo[2] = {x_max, -Lz/2}; // Source centered at x=xmax, z=-Lz/2 (periodic). + double sigma_srcRECYlo[2] = {Lx, Lz/16}; // Source width along x and z. + double floor_src = 1e-10; + + // Grid parameters + int Nx = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 4; + int poly_order = 1; + + double vpar_max_elc = 4.*vte; + double mu_max_elc = 12*me*pow(vte,2)/(2*B0); + double vpar_max_ion = 4.*vti; + double mu_max_ion = 12*mi*pow(vti,2)/(2*B0); + + double t_end = 1.e-6; // End time, should terminate in 43 steps. + int num_frames = 1; + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .B_axis = B_axis, + .R0 = R0, + .Rc = Rc, + .Bv0 = Bv0, + .Lx = Lx, + .Lz = Lz, + .x_min = x_min, .x_max = x_max, + .z_min = z_min, .z_max = z_max, + + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + .Ntot = Ntot, + .center_ic = {center_ic[0], center_ic[1]}, + .sigma_ic = {sigma_ic[0], sigma_ic[1]}, + + .nu_frac = nuFrac, + + .P_SOL = P_SOL, + .num_sources = num_sources, + .center_srcCORE = {center_srcCORE[0], center_srcCORE[1]}, + .sigma_srcCORE = {sigma_srcCORE[0], sigma_srcCORE[1]}, + .center_srcRECYlo = {center_srcRECYlo[0], center_srcRECYlo[1]}, + .sigma_srcRECYlo = {sigma_srcRECYlo[0], sigma_srcRECYlo[1]}, + .center_srcRECYup = {center_srcRECYup[0], center_srcRECYup[1]}, + .sigma_srcRECYup = {sigma_srcRECYup[0], sigma_srcRECYup[1]}, + .floor_src = floor_src, + + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, + + .t_end = t_end, .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + return ctx; +} + + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // Context for init functions. + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// Define the context of the simulation. This is basically all the globals +struct gk_app_ctx { + int cdim, vdim; // Dimensionality. + + // Geometry and magnetic field. + double B_axis; + double R0; + double Rc; + double Bv0; + + // Plasma parameters. + double me; double qe; + double mi; double qi; + double n0; double Te0; double Ti0; + double Ntot; + double center_ic[3], sigma_ic[3]; + + // Collisions. + double nu_frac; + + // Adaptive source parameters. + double P_SOL; + int num_sources; + double center_srcCORE[3], sigma_srcCORE[3]; + double center_srcRECYlo[3], sigma_srcRECYlo[3]; + double center_srcRECYup[3], sigma_srcRECYup[3]; + double floor_src; + + // Grid parameters. + double Lx; // Domain size in radial direction. + double Ly; // Domain size in binormal direction. + double Lz; // Domain size along magnetic field. + double x_min; double x_max; + double y_min; double y_max; + double z_min; double z_max; + int Nx; + int Ny; + int Nz; + int Nvpar; + int Nmu; + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + int poly_order; + double vpar_max_elc; double mu_max_elc; + double vpar_max_ion; double mu_max_ion; + + double t_end; // End time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. +}; + +// Radial coordinate mapping. +double Rx(const double *xc, void *ctx) +{ + return xc[0]; +} + +// Toroidal magnetic field. +double Bphi(const double *xc, void *ctx) +{ + double x = xc[0]; + struct gk_app_ctx *app = ctx; + double B_axis = app->B_axis; + double R0 = app->R0; + double R = Rx(xc, ctx); + return B_axis*R0/R; +} + +// Vertical magnetic field. +double Bvert(const double *xc, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Bv0 = app->Bv0; + return Bv0; +} + +// Magnetic field magnitude. +double bmag(const double *xc, void *ctx) +{ + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + return sqrt(pow(Bt,2) + pow(Bv,2)); +} + +// Field line pitch. +double thetax(const double *xc, void *ctx) +{ + return asin(Bvert(xc, ctx)/bmag(xc, ctx)); +} + +// Parallel coordinate mapping. +double Zx(const double *xc, void *ctx) +{ + double theta = thetax(xc, ctx); + return xc[2]*sin(theta); +} + +double phix(const double *xc, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double Rc = app->Rc; + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + + // Helical sheared mapping. Passes right hand check and conserves particle. + double theta = thetax(xc, ctx); + return y/Rc + (Bt * z*sin(theta))/(Bv * x); +} + +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + // Cartesian formulation of the magnetic field. + double Bt = Bphi(xc, ctx); + double Bv = Bvert(xc, ctx); + double phi = phix(xc, ctx); + fout[0] = -Bt*sin(phi); + fout[1] = Bt*cos(phi); + fout[2] = Bv; +} + +void zero_func(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ fout[0] = 0.0; } + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + + // Map to cylindrical (R, Z, phi) coordinates. + double R = Rx(xc, ctx); + double Z = Zx(xc, ctx); + double phi = phix(xc, ctx); + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +// Taken from rt gk d3d 3x2c, is this the non uniform v grid mapping? +void mapc2p_vel_elc(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_elc = app->vpar_max_elc; + double mu_max_elc = app->mu_max_elc; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_elc*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_elc*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_elc*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_elc*pow(cmu,2); +} + +void mapc2p_vel_ion(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_ion = app->vpar_max_ion; + double mu_max_ion = app->mu_max_ion; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_ion*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_ion*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_ion*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_ion*pow(cmu,2); +} + +struct gk_app_ctx +create_ctx(void) +{ + int cdim = 3, vdim = 2; // Dimensionality. + + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Plasma parameters. Chosen based on the value of a cubic sline + // between the last TS data inside the LCFS and the probe data in + // in the far SOL, near R=0.475 m. + double AMU = 2.01410177811; + double mi = mp*AMU; // Deuterium ions. + double Te0 = 40*eV; + double Ti0 = 40*eV; + double n0 = 7e19; // [1/m^3] (10 times NSTX ref.) + double Ntot = 6.0e18; // Total number of particles in the simulation box. + + // Geometry and magnetic field. + double B_axis = 0.5; + double R0 = 0.85; + double a0 = 0.5; + double Lp = 2.4; // Poloidal length at x0. + double Lt = 8.0; // Toroidal length at x0. + double Rc = R0 + a0; + double B0 = B_axis*R0/Rc; + + double sintheta = Lp/Lt; + double Bv0 = B0*sintheta; + + // Collisions; + double nuFrac = 0.1; + + // Derived parameters. + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); // Sound speed. + double omega_ci = fabs(qi*B0/mi); // Ion cyclotron frequency. + double rho_s = c_s/omega_ci; // Ion sound gyroradius. + + // Box size. + double Lx = 50*rho_s; + double Ly = 50*rho_s; + double Lz = Lt; // [m] + + double x_min = Rc - Lx/2; + double x_max = Rc + Lx/2; + double y_min = -Ly/2; + double y_max = Ly/2; + double z_min = -Lz/2; + double z_max = Lz/2; + double center_ic[3] = {x_min, 0.0, 0.0}; // Initial condition centered at z=0. + double sigma_ic[3] = {Lx, 0.0, Lz}; // Initial condition width along x and z. + + // 1+2 adaptive source setup: + // - CORE: at the left boundary (x=xmin), injects a fixed power P_SOL + // and compensate for energy loss through inner radial boundary. + // - RECY: neutral recycling model, put back particles lost through wall + // at 5 eV, no energy compensation. one for up, one for low. + double P_SOL = 8.1e5; // Power injected in the SOL [W]. + int num_sources = 3; + double center_srcCORE[3] = {x_min, 0.0, 0.0}; // Source centered at x=xmin, z=0. + double sigma_srcCORE[3] = {Lx/16, 0.0, Lz/8}; // Source width along x and z. + double center_srcRECYup[3] = {x_max, 0.0, Lz/2}; // Source centered at x=xmax, z=Lz/2 (periodic). + double sigma_srcRECYup[3] = {Lx, 0.0, Lz/16}; // Source width along x and z. + double center_srcRECYlo[3] = {x_max, 0.0, -Lz/2}; // Source centered at x=xmax, z=-Lz/2 (periodic). + double sigma_srcRECYlo[3] = {Lx, 0.0, Lz/16}; // Source width along x and z. + double floor_src = 1e-10; + + // Grid parameters + int Nx = 4; + int Ny = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 2; + int poly_order = 1; + + double vpar_max_elc = 4.*vte; + double mu_max_elc = 12*me*pow(vte,2)/(2*B0); + double vpar_max_ion = 4.*vti; + double mu_max_ion = 12*mi*pow(vti,2)/(2*B0); + + double t_end = 0.1e-6; // End time, should terminate in 43 steps. + int num_frames = 1; + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .B_axis = B_axis, + .R0 = R0, + .Rc = Rc, + .Bv0 = Bv0, + .Lx = Lx, + .Ly = Ly, + .Lz = Lz, + .x_min = x_min, .x_max = x_max, + .y_min = y_min, .y_max = y_max, + .z_min = z_min, .z_max = z_max, + + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + .Ntot = Ntot, + .center_ic = {center_ic[0], center_ic[1], center_ic[2]}, + .sigma_ic = {sigma_ic[0], sigma_ic[1], sigma_ic[2]}, + + .nu_frac = nuFrac, + + .P_SOL = P_SOL, + .num_sources = num_sources, + .center_srcCORE = {center_srcCORE[0], center_srcCORE[1], center_srcCORE[2]}, + .sigma_srcCORE = {sigma_srcCORE[0], sigma_srcCORE[1], sigma_srcCORE[2]}, + .center_srcRECYlo = {center_srcRECYlo[0], center_srcRECYlo[1], center_srcRECYlo[2]}, + .sigma_srcRECYlo = {sigma_srcRECYlo[0], sigma_srcRECYlo[1], sigma_srcRECYlo[2]}, + .center_srcRECYup = {center_srcRECYup[0], center_srcRECYup[1], center_srcRECYup[2]}, + .sigma_srcRECYup = {sigma_srcRECYup[0], sigma_srcRECYup[1], sigma_srcRECYup[2]}, + .floor_src = floor_src, + + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, + + .t_end = t_end, .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + return ctx; +} + + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // Context for init functions. + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// Define the context of the simulation. This stores global parameters. +struct gk_app_ctx { + int cdim, vdim; + // Geometry and magnetic field parameters + double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, Bref; + double kperp; + // Plasma parameters + double me, qe, mi, qi, n0, Te0, Ti0; + // Collision parameters + double nuFrac, nuElc, nuIon; + // Source parameters + int num_sources; + double center_src[2], sigma_src[2]; + double energy_src, particle_src; + double floor_src; + // Grid parameters + double x; + double Lz; + double z_min, z_max; + int Nz, Nvpar, Nmu; + int cells[GKYL_MAX_DIM], poly_order; + double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; + // Simulation control parameters + double t_end, write_phase_freq; + int num_frames, int_diag_calc_num, num_failures_max; + double dt_failure_tol; +}; + +// Geometry related functions +double r_x(double x, double a_mid) +{ + return x+a_mid; +} + +// cubic polynomial fit to TCV NT q profile (discharge #65130) +double qprofile(double R) { + double qfit[4] = { + 484.0615913225881, -1378.25993228584, 1309.3099150729233, -414.13270311478726 + }; + return qfit[0]*pow(R,3) + qfit[1]*pow(R,2) + qfit[2]*R + qfit[3]; +} + +double R_rtheta(double r, double theta, void *ctx) +{ + // Major radius as a function of minor radius r and poloidal angle theta. + struct gk_app_ctx *app = ctx; + double a_shift = app->a_shift; + double R_axis = app->R_axis; + double delta = app->delta; + return R_axis - a_shift*r*r/(2.*R_axis) + r*cos(theta + asin(delta)*sin(theta)); +} + +double Z_rtheta(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Z_axis = app->Z_axis; + double kappa = app->kappa; + return Z_axis + kappa*r*sin(theta); +} + +double dRdr(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double a_shift = app->a_shift; + double R_axis = app->R_axis; + double delta = app->delta; + return - a_shift*r/(R_axis) + cos(theta + asin(delta)*sin(theta)); +} + +double dRdtheta(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double delta = app->delta; + return -r*sin(theta + asin(delta)*sin(theta))*(1.+asin(delta)*cos(theta)); +} + +double dZdr(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double kappa = app->kappa; + return kappa*sin(theta); +} + +double dZdtheta(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double kappa = app->kappa; + return kappa*r*cos(theta); +} + +double Jr(double r, double theta, void *ctx) +{ + return R_rtheta(r,theta,ctx)*( dRdr(r,theta,ctx) * dZdtheta(r,theta,ctx) + -dRdtheta(r,theta,ctx) * dZdr(r,theta,ctx) ); +} + +struct integrand_ctx { + struct gk_app_ctx *app_ctx; + double r; +}; + +double integrand(double t, void *int_ctx) +{ + struct integrand_ctx *inctx = int_ctx; + double r = inctx->r; + struct gk_app_ctx *app = inctx->app_ctx; + return Jr(r,t,app) / pow(R_rtheta(r,t,app),2); +} + +double Bphi(double R, void *ctx) +{ + // Toroidal magnetic field. + struct gk_app_ctx *app = ctx; + double B0 = app->B0; + double R0 = app->R0; + return B0*R0/R; +} + +double dPsidr(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + struct integrand_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral; + integral = gkyl_dbl_exp(integrand, &tmp_ctx, 0., 2.*M_PI, 7, 1e-10); + + double R = R_rtheta(r,theta,ctx); + double Bt = Bphi(R,ctx); + double R_omp = R_rtheta(r,0.0,ctx); + return ( R*Bt/(2.*M_PI*qprofile(R_omp)))*integral.res; +} + +double alpha(double r, double theta, double phi, void *ctx) +{ + double twrap = theta; + while (twrap < -M_PI) twrap = twrap+2.*M_PI; + while (M_PI < twrap) twrap = twrap-2.*M_PI; + + struct gk_app_ctx *app = ctx; + struct integrand_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral; + if (0. < twrap) { + integral = gkyl_dbl_exp(integrand, &tmp_ctx, 0., twrap, 7, 1e-10); + } else { + integral = gkyl_dbl_exp(integrand, &tmp_ctx, twrap, 0., 7, 1e-10); + integral.res = -integral.res; + } + + double R = R_rtheta(r,theta,ctx); + double Bt = Bphi(R,ctx); + + return phi - R*Bt*integral.res/dPsidr(r,theta,ctx); +} + +double gradr(double r, double theta, void *ctx) +{ + return (R_rtheta(r,theta,ctx)/Jr(r,theta,ctx))*sqrt(pow(dRdtheta(r,theta,ctx),2) + pow(dZdtheta(r,theta,ctx),2)); +} + +void zero_func(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ + fout[0] = 0.0; +} + +// Density initial condition (like TCV exp profile) +void density_init(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ + double z = xn[0]; + struct gk_app_ctx *app = ctx; + fout[0] = app->n0 * exp(-pow(z/(app->Lz/4.),2)); +} + +// Electron temperature initial conditions +void temp_elc(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ + double z = xn[0]; + struct gk_app_ctx *app = ctx; + fout[0] = app->Te0; +} + +// Ion temperature initial conditions +void temp_ion(double t, const double * GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void *ctx) +{ + double z = xn[0]; + struct gk_app_ctx *app = ctx; + fout[0] = app->Ti0; +} + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double Cy = app->Cy; + double a_mid = app->a_mid; + double r = r_x(x,a_mid); + // Map to cylindrical (R, Z, phi) coordinates. + double R = R_rtheta(r, z, ctx); + double Z = Z_rtheta(r, z, ctx); + double phi = y/Cy + alpha(r, z, 0, ctx); + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +// Taken from rt gk d3d 3x2c, is this the non uniform v grid mapping? +void mapc2p_vel_elc(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_elc = app->vpar_max_elc; + double mu_max_elc = app->mu_max_elc; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_elc*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_elc*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_elc*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_elc*pow(cmu,2); +} + +void mapc2p_vel_ion(double t, const double *vc, double* GKYL_RESTRICT vp, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double vpar_max_ion = app->vpar_max_ion; + double mu_max_ion = app->mu_max_ion; + double cvpar = vc[0], cmu = vc[1]; + // Linear map up to vpar_max/2, then quadratic. + if (fabs(cvpar) <= 0.5) + vp[0] = vpar_max_ion*cvpar; + else if (cvpar < -0.5) + vp[0] = -vpar_max_ion*2.0*pow(cvpar,2); + else + vp[0] = vpar_max_ion*2.0*pow(cvpar,2); + // Quadratic map in mu. + vp[1] = mu_max_ion*pow(cmu,2); +} + +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double a_mid = app->a_mid; + double Cy = app->Cy; + double r = r_x(x,a_mid); + double Bt = Bphi(R_rtheta(r,z,ctx),ctx); + double Bp = dPsidr(r,z,ctx)/R_rtheta(r,z,ctx)*gradr(r,z,ctx); + + double drdtheta = dRdtheta(r,z,ctx); + double dzdtheta = dZdtheta(r,z,ctx); + double den = sqrt(pow(drdtheta,2) + pow(dzdtheta,2)); + double B_r = Bp*drdtheta/den; + double B_z = Bp*dzdtheta/den; + double phi = y/Cy + alpha(r, z, 0, ctx); + double R = R_rtheta(r, z, ctx); + + // xc are computational coords. + // Set Cartesian components of magnetic field. + fout[0] = B_r * cos(phi) + Bt * sin(phi); + fout[1] = B_r * sin(phi) - Bt * cos(phi); + fout[2] = B_z; +} + + +struct gk_app_ctx create_ctx(void) +{ + int cdim = 1, vdim = 2; // Dimensionality. + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Geometry and magnetic field. + double a_shift = 0.5; // Parameter in Shafranov shift. + double Z_axis = 0.1414361745; // Magnetic axis height [m]. + double R_axis = 0.8867856264; // Magnetic axis major radius [m]. + double B_axis = 1.4; // Magnetic field at the magnetic axis [T]. + double R_LCFSmid = 1.0870056099999; // Major radius of the LCFS at the outboard midplane [m + double x = 0.02; // Radial position, in terms of distance from the LCFS. + double Rmid_max = R_LCFSmid + x; // Maximum midplane major radius of simulation box [m]. + double R0 = Rmid_max; // Major radius of the simulation box [m]. + + // Perpendicular wavenumber (k_perp) times ion sound gyroradius (rho_s). + double kperpRhos = 0.15; + + // Minor radius at outboard midplane [m]. Redefine it with + // Shafranov shift, to ensure LCFS radial location. + double a_mid = fabs(a_shift)<1e-13? R_LCFSmid-R_axis : + R_axis/a_shift - sqrt(R_axis*(R_axis - 2*a_shift*R_LCFSmid + 2*a_shift*R_axis))/a_shift; + + double r0 = R0-R_axis; // Minor radius of the simulation box [m]. + double B0 = B_axis*(R_axis/R0); // Magnetic field magnitude in the simulation box [T]. + double kappa = 1.4; // Elongation (=1 for no elongation). + double delta = -0.38; // Triangularity (=0 for no triangularity). + + // Plasma parameters. Chosen based on the value of a cubic sline + // between the last TS data inside the LCFS and the probe data in + // in the far SOL, near R=0.475 m. + double AMU = 2.01410177811; + double mi = mp*AMU; // Deuterium ions. + double Te0 = 10*eV; + double Ti0 = 10*eV; + double n0 = 1.0e18; // [1/m^3] + double Bref = B0; // Reference magnetic field [T]. + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); + double omega_ci = fabs(qi*B0/mi); + double rho_s = c_s/omega_ci; + + // Configuration domain parameters + double q0 = qprofile(R0); // Safety factor in the center of domain. + double Cy = r0/q0; // Normalization in binormal coordinate. + + double Lz = 2.*M_PI; // Domain size along magnetic field. + double z_min = -Lz/2.; + double z_max = Lz/2.; + + // Collision frequencies + // We note that initial profile are unstable for the full collision frequency (nu=1.0). + // This factor can be increased once a saturated state is reached. + double nuFrac = 0.1; + // Electron-electron collision freq. + double logLambdaElc = 6.6 - 0.5 * log(n0/1e20) + 1.5 * log(Ti0/eV); + double nuElc = nuFrac * logLambdaElc * pow(eV, 4) * n0 / + (6*sqrt(2.) * pow(M_PI,3./2.) * pow(eps0,2) * sqrt(me) * pow(Te0,3./2.)); + // Ion-ion collision freq. + double logLambdaIon = 6.6 - 0.5 * log(n0/1e20) + 1.5 * log(Ti0/eV); + double nuIon = nuFrac * logLambdaIon * pow(eV, 4) * n0 / + (12 * pow(M_PI,3./2.) * pow(eps0,2) * sqrt(mi) * pow(Ti0,3./2.)); + + // Source parameters + int num_sources = 1; + double P_exp = 0.34e6; // P_sol measured [W] + // Fixed source: + // - Injects energy only in the core region (0.25MW per species). + // - The particles injection is only the one that are lost through the inner radial boundary. + double energy_src = P_exp; // What the source must inject in energy [W] + double particle_src = Ti0/P_exp;// What the source must inject in particle [1/s] + double center_src[2] = {0.0}; // This is the position of the ion source, + double sigma_src[2] = {Lz/6}; // the electron source will be at +Lz/2. + double floor_src = 1e-10; + + // Grid parameters + int Nz = 16; + int Nvpar = 8; + int Nmu = 8; + int poly_order = 1; + // Velocity box dimensions + double vpar_max_elc = 5.*vte; + double mu_max_elc = me*pow(4*vte,2)/(2*B0); + double vpar_max_ion = 5.*vti; + double mu_max_ion = mi*pow(4*vti,2)/(2*B0); + double t_end = 1.e-6; // Should take 8 time steps + int num_frames = 1; + double write_phase_freq = 1.0; + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-3; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .a_shift = a_shift, + .R_axis = R_axis, + .R0 = R0, + .a_mid = a_mid, + .r0 = r0, + .B0 = B0, + .kappa = kappa, + .delta = delta, + .q0 = q0, + .Cy = Cy, + .Lz = Lz, + .z_min = z_min, .z_max = z_max, + .kperp = kperpRhos/rho_s, + .Bref = Bref, + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + .nuFrac = nuFrac, .nuElc = nuElc, .nuIon = nuIon, + .num_sources = num_sources, + + .center_src = {center_src[0]}, + .sigma_src = {sigma_src[0]}, + .energy_src = energy_src, .particle_src = particle_src, + .floor_src = floor_src, + + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, + .write_phase_freq = write_phase_freq, + .t_end = t_end, .num_frames = num_frames, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + return ctx; +} + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) + MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // context for init functions + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d the resolution must be divisible by 3. - int num_cell_z = 8; - int num_cell_vpar = 8; - int num_cell_mu = 8; + int Nx = 9; // The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. + int Nz = 8; + int Nvpar = 8; + int Nmu = 8; int poly_order = 1; // Velocity box dimensions double vpar_max_elc = 5.*vte; double mu_max_elc = me*pow(4*vte,2)/(2*B0); double vpar_max_ion = 5.*vti; double mu_max_ion = mi*pow(4*vti,2)/(2*B0); - double final_time = 1.e-7; // Should take 8 time steps + double t_end = 1.e-7; // Should take 8 time steps int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -464,16 +464,16 @@ struct gk_app_ctx create_ctx(void) .energy_srcRECY = energy_srcRECY, .particle_srcRECY = particle_srcRECY, .floor_srcRECY = floor_srcRECY, - .num_cell_x = num_cell_x, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, @@ -651,8 +651,10 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_SURROGATE, + .aux_str = "gyrokinetic/data/nn_model/nn_model_sheath_bc_conv_MPE.kann" }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_SURROGATE, + .aux_str = "gyrokinetic/data/nn_model/nn_model_sheath_bc_conv_MPE.kann" }, }, .num_diag_moments = 9, @@ -732,8 +734,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 9, @@ -827,7 +829,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c b/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c index 1520d5cdde..ca6a6cc771 100644 --- a/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c @@ -35,11 +35,11 @@ struct gk_app_ctx { // Grid parameters double Lx, Ly, Lz; double x_min, x_max, y_min, y_max, z_min, z_max; - int num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu; + int Nx, Ny, Nz, Nvpar, Nmu; int cells[GKYL_MAX_DIM], poly_order; double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; // Simulation control parameters - double final_time, write_phase_freq; + double t_end, write_phase_freq; int num_frames, int_diag_calc_num, num_failures_max; double dt_failure_tol; }; @@ -439,18 +439,18 @@ struct gk_app_ctx create_ctx(void) double floor_srcRECY = 1e-10; // Grid parameters (reduced resolution for the regression test, minimal recommended values in comments) - int num_cell_x = 9; // (24) The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. - int num_cell_y = 4; // (16) - int num_cell_z = 8; // (12) - int num_cell_vpar = 8; // (12) - int num_cell_mu = 8; // (8) + int Nx = 9; // (24) The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. + int Ny = 4; // (16) + int Nz = 8; // (12) + int Nvpar = 8; // (12) + int Nmu = 8; // (8) int poly_order = 1; // Velocity box dimensions double vpar_max_elc = 5.*vte; double mu_max_elc = 1.*me*pow(4*vte,2)/(2*B0); double vpar_max_ion = 5.*vti; double mu_max_ion = 1.*mi*pow(4*vti,2)/(2*B0); - double final_time = 1.e-7; + double t_end = 1.e-7; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -497,17 +497,17 @@ struct gk_app_ctx create_ctx(void) .sigma_srcRECY = {sigma_srcRECY[0], sigma_srcRECY[1], sigma_srcRECY[2]}, .energy_srcRECY = energy_srcRECY, .particle_srcRECY = particle_srcRECY, .floor_srcRECY = floor_srcRECY, - .num_cell_x = num_cell_x, - .num_cell_y = num_cell_y, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, @@ -681,8 +681,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 9, @@ -766,8 +766,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 9, @@ -872,7 +872,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/creg/rt_gk_wham_1x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_1x2v_p1.c index ac4da07310..b17a0c9c30 100644 --- a/gyrokinetic/creg/rt_gk_wham_1x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_1x2v_p1.c @@ -639,8 +639,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .write_omega_cfl = true, @@ -728,8 +728,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .write_omega_cfl = true, diff --git a/gyrokinetic/creg/rt_gk_wham_1x2v_p1_static_field.c b/gyrokinetic/creg/rt_gk_wham_1x2v_p1_static_field.c index c20398b107..fc5d3cf09c 100644 --- a/gyrokinetic/creg/rt_gk_wham_1x2v_p1_static_field.c +++ b/gyrokinetic/creg/rt_gk_wham_1x2v_p1_static_field.c @@ -661,8 +661,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, @@ -728,8 +728,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_1xIC_2x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_1xIC_2x2v_p1.c index 253cc7887f..8e4b4dcb7d 100644 --- a/gyrokinetic/creg/rt_gk_wham_1xIC_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_1xIC_2x2v_p1.c @@ -860,8 +860,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ZERO_FLUX, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, @@ -925,8 +925,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ZERO_FLUX, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_2x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_2x2v_p1.c index 59b687ec1e..a432cffc36 100644 --- a/gyrokinetic/creg/rt_gk_wham_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_2x2v_p1.c @@ -703,8 +703,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, @@ -786,8 +786,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_2xIC_3x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_2xIC_3x2v_p1.c index cd895aeb45..92a8cc75a8 100644 --- a/gyrokinetic/creg/rt_gk_wham_2xIC_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_2xIC_3x2v_p1.c @@ -676,8 +676,8 @@ run_2x_sim(struct gk_mirror_ctx ctx, const struct gkyl_app_args app_args, .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, @@ -749,8 +749,8 @@ run_2x_sim(struct gk_mirror_ctx ctx, const struct gkyl_app_args app_args, .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, @@ -900,8 +900,8 @@ run_3x_sim(struct gk_mirror_ctx ctx, const struct gkyl_app_args app_args, .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, @@ -948,8 +948,8 @@ run_3x_sim(struct gk_mirror_ctx ctx, const struct gkyl_app_args app_args, .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_3x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_3x2v_p1.c index 33c4a2add7..db1b48f47c 100644 --- a/gyrokinetic/creg/rt_gk_wham_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_3x2v_p1.c @@ -697,8 +697,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, @@ -770,8 +770,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_boltz_elc_2x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_boltz_elc_2x2v_p1.c index 282f317b45..3449bc3b48 100644 --- a/gyrokinetic/creg/rt_gk_wham_boltz_elc_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_boltz_elc_2x2v_p1.c @@ -489,8 +489,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_boltz_elc_poa_1x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_boltz_elc_poa_1x2v_p1.c index cdb60a887f..2bb1a8e580 100644 --- a/gyrokinetic/creg/rt_gk_wham_boltz_elc_poa_1x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_boltz_elc_poa_1x2v_p1.c @@ -626,8 +626,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .write_omega_cfl = true, diff --git a/gyrokinetic/creg/rt_gk_wham_nonuniformx_1x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_nonuniformx_1x2v_p1.c index ab951609cd..8de97ae25a 100644 --- a/gyrokinetic/creg/rt_gk_wham_nonuniformx_1x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_nonuniformx_1x2v_p1.c @@ -660,8 +660,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, @@ -727,8 +727,8 @@ int main(int argc, char **argv) }, .bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_nonuniformx_2x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_nonuniformx_2x2v_p1.c index ae0e96a7b0..7ff7fa2859 100644 --- a/gyrokinetic/creg/rt_gk_wham_nonuniformx_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_nonuniformx_2x2v_p1.c @@ -693,8 +693,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, @@ -766,8 +766,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH }, + { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, + { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/creg/rt_gk_wham_nonuniformx_3x2v_p1.c b/gyrokinetic/creg/rt_gk_wham_nonuniformx_3x2v_p1.c index 84beff2d7f..591d23bae0 100644 --- a/gyrokinetic/creg/rt_gk_wham_nonuniformx_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_wham_nonuniformx_3x2v_p1.c @@ -697,8 +697,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = elc_ic, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, @@ -770,8 +770,8 @@ int main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_FIXED_FUNC, .projection = ion_ic, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, }, }, .num_diag_moments = 8, diff --git a/gyrokinetic/data/nn_model/README.md b/gyrokinetic/data/nn_model/README.md new file mode 100644 index 0000000000..a0854e4f4a --- /dev/null +++ b/gyrokinetic/data/nn_model/README.md @@ -0,0 +1,31 @@ +# Surrogate Models Overview + +### `nn_model_sheath_bc_conv_MPE.kann` + +A neural network model trained on simulation data from **GYRAZE**. It predicts the electron cutting velocity profile based on local plasma and magnetic parameters at the magnetic presheath entrance (MPE). + +#### Inputs + +* **`alpha`**: Angle between the magnetic field and the wall tangent. +* **`gamma`**: Ratio between the electron Larmor radius and the Debye length: + +$$\gamma = \frac{1}{B} \sqrt{\frac{n_e}{\varepsilon_0}}$$ + + +* **`phi`**: Normalized potential at the wall: + +$$\phi_{\text{norm}} = \frac{e \phi}{T_e}$$ + + + +#### Outputs + +The model outputs a vector of **40 values**: + +* **Indices 0–19**: Normalized electron cutting velocities $\hat v_i$ [$v_\text{th}$] +* **Indices 20–39**: Corresponding normalized magnetic moments $\hat \mu_i$ [$T_e/ B$] + +#### References & Documentation + +For full details on the architecture, training process, and C interface, visit the repository: +[Antoinehoff/gyraze_surrogate_c_interface](https://github.com/Antoinehoff/gyraze_surrogate_c_interface) \ No newline at end of file diff --git a/gyrokinetic/data/nn_model/nn_model_sheath_bc_conv_MPE.kann b/gyrokinetic/data/nn_model/nn_model_sheath_bc_conv_MPE.kann new file mode 100644 index 0000000000..6595804a77 Binary files /dev/null and b/gyrokinetic/data/nn_model/nn_model_sheath_bc_conv_MPE.kann differ diff --git a/gyrokinetic/ker/bc_sheath_gyrokinetic/bc_sheath_gyrokinetic_ser_p1.c b/gyrokinetic/ker/bc_sheath_gyrokinetic/bc_sheath_gyrokinetic_ser_p1.c index 998b64c168..ad23a14951 100644 --- a/gyrokinetic/ker/bc_sheath_gyrokinetic/bc_sheath_gyrokinetic_ser_p1.c +++ b/gyrokinetic/ker/bc_sheath_gyrokinetic/bc_sheath_gyrokinetic_ser_p1.c @@ -1,9 +1,8 @@ #include -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; double fReflSurf[3] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; @@ -12,19 +11,19 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; - vcutSq = -0.5*(2.449489742783178*phiWall[1]-2.449489742783178*phi[1]-1.414213562373095*phiWall[0]+1.414213562373095*phi[0])*q2Dm; + double vcutsq_n = vcutsq[0]; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) fReflSurf[0] = 0.0; fReflSurf[1] = 0.0; fReflSurf[2] = 0.0; - } else if (vcutSq > vparAbsSqUp) { // full reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - fReflSurf[0] = -0.7071067811865475*(1.732050807568877*f[1]-1.0*f[0]); - fReflSurf[1] = -0.7071067811865475*(1.732050807568877*f[3]-1.0*f[2]); - fReflSurf[2] = -0.1414213562373095*(8.660254037844387*f[5]-5.0*f[4]); + fReflSurf[0] = -(0.7071067811865475*(1.7320508075688772*f[1]-1.0*f[0])); + fReflSurf[1] = -(0.7071067811865475*(1.7320508075688772*f[3]-1.0*f[2])); + fReflSurf[2] = -(0.1414213562373095*(8.660254037844387*f[5]-5.0*f[4])); } else { // partial reflection @@ -35,29 +34,29 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurf[0] = -0.07905694150420944*((8.660254037844387*f[5]-5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]-3.872983346207417*f[2])*vcut_lR2+((-8.660254037844387*f[5])+5.0*f[4]+7.745966692414834*f[1]-4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]+3.872983346207417*f[2]+7.745966692414834*f[1]-4.47213595499958*f[0]); - fReflSurf[1] = -0.0441941738241592*((20.1246117974981*f[5]-11.61895003862225*f[4])*vcut_lR4+(13.85640646055102*f[3]-8.0*f[2])*vcut_lR3+((-13.41640786499874*f[5])+7.745966692414834*f[4]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[5]+3.872983346207417*f[4]+13.85640646055102*f[3]-8.0*f[2]-12.0*f[1]+6.928203230275509*f[0]); - fReflSurf[2] = -0.008838834764831839*((155.884572681199*f[5]-90.0*f[4])*vcut_lR5+(100.6230589874906*f[3]-58.09475019311126*f[2])*vcut_lR4+((-173.2050807568878*f[5])+100.0*f[4]+77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_lR3+(38.72983346207418*f[2]-67.0820393249937*f[3])*vcut_lR2+(86.60254037844389*f[5]-50.0*f[4]-77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_l+69.2820323027551*f[5]-40.0*f[4]-33.54101966249685*f[3]+19.36491673103709*f[2]); + fReflSurf[0] = -(0.07905694150420944*((8.660254037844387*f[5]-5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]-3.872983346207417*f[2])*vcut_lR2+(-(8.660254037844387*f[5])+5.0*f[4]+7.745966692414834*f[1]-4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]+3.872983346207417*f[2]+7.745966692414834*f[1]-4.47213595499958*f[0])); + fReflSurf[1] = -(0.044194173824159196*((20.124611797498105*f[5]-11.61895003862225*f[4])*vcut_lR4+(13.856406460551018*f[3]-8.0*f[2])*vcut_lR3+(-(13.416407864998737*f[5])+7.745966692414834*f[4]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[5]+3.872983346207417*f[4]+13.856406460551018*f[3]-8.0*f[2]-12.0*f[1]+6.928203230275509*f[0])); + fReflSurf[2] = -(0.008838834764831839*((155.88457268119896*f[5]-90.0*f[4])*vcut_lR5+(100.62305898749055*f[3]-58.09475019311126*f[2])*vcut_lR4+(-(173.20508075688778*f[5])+100.0*f[4]+77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_lR3+(38.729833462074176*f[2]-67.0820393249937*f[3])*vcut_lR2+(86.60254037844389*f[5]-50.0*f[4]-77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_l+69.2820323027551*f[5]-40.0*f[4]-33.54101966249685*f[3]+19.364916731037088*f[2])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurf[0] = 0.07905694150420944*((8.660254037844387*f[5]-5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]-3.872983346207417*f[2])*vcut_lR2+((-8.660254037844387*f[5])+5.0*f[4]+7.745966692414834*f[1]-4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]+3.872983346207417*f[2]-7.745966692414834*f[1]+4.47213595499958*f[0]); - fReflSurf[1] = 0.0441941738241592*((20.1246117974981*f[5]-11.61895003862225*f[4])*vcut_lR4+(13.85640646055102*f[3]-8.0*f[2])*vcut_lR3+((-13.41640786499874*f[5])+7.745966692414834*f[4]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[5]+3.872983346207417*f[4]-13.85640646055102*f[3]+8.0*f[2]-12.0*f[1]+6.928203230275509*f[0]); - fReflSurf[2] = 0.008838834764831839*((155.884572681199*f[5]-90.0*f[4])*vcut_lR5+(100.6230589874906*f[3]-58.09475019311126*f[2])*vcut_lR4+((-173.2050807568878*f[5])+100.0*f[4]+77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_lR3+(38.72983346207418*f[2]-67.0820393249937*f[3])*vcut_lR2+(86.60254037844389*f[5]-50.0*f[4]-77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_l-69.2820323027551*f[5]+40.0*f[4]-33.54101966249685*f[3]+19.36491673103709*f[2]); + fReflSurf[0] = 0.07905694150420944*((8.660254037844387*f[5]-5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]-3.872983346207417*f[2])*vcut_lR2+(-(8.660254037844387*f[5])+5.0*f[4]+7.745966692414834*f[1]-4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]+3.872983346207417*f[2]-7.745966692414834*f[1]+4.47213595499958*f[0]); + fReflSurf[1] = 0.044194173824159196*((20.124611797498105*f[5]-11.61895003862225*f[4])*vcut_lR4+(13.856406460551018*f[3]-8.0*f[2])*vcut_lR3+(-(13.416407864998737*f[5])+7.745966692414834*f[4]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[5]+3.872983346207417*f[4]-13.856406460551018*f[3]+8.0*f[2]-12.0*f[1]+6.928203230275509*f[0]); + fReflSurf[2] = 0.008838834764831839*((155.88457268119896*f[5]-90.0*f[4])*vcut_lR5+(100.62305898749055*f[3]-58.09475019311126*f[2])*vcut_lR4+(-(173.20508075688778*f[5])+100.0*f[4]+77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_lR3+(38.729833462074176*f[2]-67.0820393249937*f[3])*vcut_lR2+(86.60254037844389*f[5]-50.0*f[4]-77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_l-69.2820323027551*f[5]+40.0*f[4]-33.54101966249685*f[3]+19.364916731037088*f[2]); } @@ -77,17 +76,16 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double } - fRefl[0] = 1.414213562373095*fReflSurf[0]; + fRefl[0] = 1.4142135623730951*fReflSurf[0]; fRefl[1] = 0.0; - fRefl[2] = 1.414213562373095*fReflSurf[1]; + fRefl[2] = 1.4142135623730951*fReflSurf[1]; fRefl[3] = 0.0; - fRefl[4] = 1.414213562373095*fReflSurf[2]; + fRefl[4] = 1.4142135623730951*fReflSurf[2]; fRefl[5] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; double fReflSurf[3] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; @@ -96,18 +94,18 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; - vcutSq = 0.5*(2.449489742783178*phiWall[1]-2.449489742783178*phi[1]+1.414213562373095*phiWall[0]-1.414213562373095*phi[0])*q2Dm; + double vcutsq_n = vcutsq[0]; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) fReflSurf[0] = 0.0; fReflSurf[1] = 0.0; fReflSurf[2] = 0.0; - } else if (vcutSq > vparAbsSqUp) { // full reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - fReflSurf[0] = 0.7071067811865475*(1.732050807568877*f[1]+f[0]); - fReflSurf[1] = 0.7071067811865475*(1.732050807568877*f[3]+f[2]); + fReflSurf[0] = 0.7071067811865475*(1.7320508075688772*f[1]+f[0]); + fReflSurf[1] = 0.7071067811865475*(1.7320508075688772*f[3]+f[2]); fReflSurf[2] = 0.1414213562373095*(8.660254037844387*f[5]+5.0*f[4]); } else { // partial reflection @@ -119,29 +117,29 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurf[0] = 0.07905694150420944*((8.660254037844387*f[5]+5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]+3.872983346207417*f[2])*vcut_lR2+((-8.660254037844387*f[5])-5.0*f[4]+7.745966692414834*f[1]+4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]-3.872983346207417*f[2]+7.745966692414834*f[1]+4.47213595499958*f[0]); - fReflSurf[1] = 0.0441941738241592*((20.1246117974981*f[5]+11.61895003862225*f[4])*vcut_lR4+(13.85640646055102*f[3]+8.0*f[2])*vcut_lR3+((-13.41640786499874*f[5])-7.745966692414834*f[4]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[5]-3.872983346207417*f[4]+13.85640646055102*f[3]+8.0*f[2]-12.0*f[1]-6.928203230275509*f[0]); - fReflSurf[2] = 0.008838834764831839*((155.884572681199*f[5]+90.0*f[4])*vcut_lR5+(100.6230589874906*f[3]+58.09475019311126*f[2])*vcut_lR4+((-173.2050807568878*f[5])-100.0*f[4]+77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_lR3+((-67.0820393249937*f[3])-38.72983346207418*f[2])*vcut_lR2+(86.60254037844389*f[5]+50.0*f[4]-77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_l+69.2820323027551*f[5]+40.0*f[4]-33.54101966249685*f[3]-19.36491673103709*f[2]); + fReflSurf[0] = 0.07905694150420944*((8.660254037844387*f[5]+5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]+3.872983346207417*f[2])*vcut_lR2+(-(8.660254037844387*f[5])-5.0*f[4]+7.745966692414834*f[1]+4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]-3.872983346207417*f[2]+7.745966692414834*f[1]+4.47213595499958*f[0]); + fReflSurf[1] = 0.044194173824159196*((20.124611797498105*f[5]+11.61895003862225*f[4])*vcut_lR4+(13.856406460551018*f[3]+8.0*f[2])*vcut_lR3+(-(13.416407864998737*f[5])-7.745966692414834*f[4]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[5]-3.872983346207417*f[4]+13.856406460551018*f[3]+8.0*f[2]-12.0*f[1]-6.928203230275509*f[0]); + fReflSurf[2] = 0.008838834764831839*((155.88457268119896*f[5]+90.0*f[4])*vcut_lR5+(100.62305898749055*f[3]+58.09475019311126*f[2])*vcut_lR4+(-(173.20508075688778*f[5])-100.0*f[4]+77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_lR3+(-(67.0820393249937*f[3])-38.729833462074176*f[2])*vcut_lR2+(86.60254037844389*f[5]+50.0*f[4]-77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_l+69.2820323027551*f[5]+40.0*f[4]-33.54101966249685*f[3]-19.364916731037088*f[2]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurf[0] = -0.07905694150420944*((8.660254037844387*f[5]+5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]+3.872983346207417*f[2])*vcut_lR2+((-8.660254037844387*f[5])-5.0*f[4]+7.745966692414834*f[1]+4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]-3.872983346207417*f[2]-7.745966692414834*f[1]-4.47213595499958*f[0]); - fReflSurf[1] = -0.0441941738241592*((20.1246117974981*f[5]+11.61895003862225*f[4])*vcut_lR4+(13.85640646055102*f[3]+8.0*f[2])*vcut_lR3+((-13.41640786499874*f[5])-7.745966692414834*f[4]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[5]-3.872983346207417*f[4]-13.85640646055102*f[3]-8.0*f[2]-12.0*f[1]-6.928203230275509*f[0]); - fReflSurf[2] = -0.008838834764831839*((155.884572681199*f[5]+90.0*f[4])*vcut_lR5+(100.6230589874906*f[3]+58.09475019311126*f[2])*vcut_lR4+((-173.2050807568878*f[5])-100.0*f[4]+77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_lR3+((-67.0820393249937*f[3])-38.72983346207418*f[2])*vcut_lR2+(86.60254037844389*f[5]+50.0*f[4]-77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_l-69.2820323027551*f[5]-40.0*f[4]-33.54101966249685*f[3]-19.36491673103709*f[2]); + fReflSurf[0] = -(0.07905694150420944*((8.660254037844387*f[5]+5.0*f[4])*vcut_lR3+(6.708203932499369*f[3]+3.872983346207417*f[2])*vcut_lR2+(-(8.660254037844387*f[5])-5.0*f[4]+7.745966692414834*f[1]+4.47213595499958*f[0])*vcut_l-6.708203932499369*f[3]-3.872983346207417*f[2]-7.745966692414834*f[1]-4.47213595499958*f[0])); + fReflSurf[1] = -(0.044194173824159196*((20.124611797498105*f[5]+11.61895003862225*f[4])*vcut_lR4+(13.856406460551018*f[3]+8.0*f[2])*vcut_lR3+(-(13.416407864998737*f[5])-7.745966692414834*f[4]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[5]-3.872983346207417*f[4]-13.856406460551018*f[3]-8.0*f[2]-12.0*f[1]-6.928203230275509*f[0])); + fReflSurf[2] = -(0.008838834764831839*((155.88457268119896*f[5]+90.0*f[4])*vcut_lR5+(100.62305898749055*f[3]+58.09475019311126*f[2])*vcut_lR4+(-(173.20508075688778*f[5])-100.0*f[4]+77.45966692414835*f[1]+44.7213595499958*f[0])*vcut_lR3+(-(67.0820393249937*f[3])-38.729833462074176*f[2])*vcut_lR2+(86.60254037844389*f[5]+50.0*f[4]-77.45966692414835*f[1]-44.7213595499958*f[0])*vcut_l-69.2820323027551*f[5]-40.0*f[4]-33.54101966249685*f[3]-19.364916731037088*f[2])); } @@ -161,17 +159,17 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double } - fRefl[0] = 1.414213562373095*fReflSurf[0]; + fRefl[0] = 1.4142135623730951*fReflSurf[0]; fRefl[1] = 0.0; - fRefl[2] = 1.414213562373095*fReflSurf[1]; + fRefl[2] = 1.4142135623730951*fReflSurf[1]; fRefl[3] = 0.0; - fRefl[4] = 1.414213562373095*fReflSurf[2]; + fRefl[4] = 1.4142135623730951*fReflSurf[2]; fRefl[5] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; + double vcutsq_n; double fReflSurf[6] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; @@ -180,60 +178,54 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; - vcutSq = -0.5*(2.449489742783178*phiWall[1]-2.449489742783178*phi[1]-1.414213562373095*phiWall[0]+1.414213562373095*phi[0])*q2Dm; + double wv = 0.5*(vparUp+vparLo); + double dv = vparUp-1.0*vparLo; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + double xBar, xSqBar; + double fReflSurfMu[2][3] = {0.}; - fReflSurf[0] = 0.0; - fReflSurf[1] = 0.0; - fReflSurf[2] = 0.0; - fReflSurf[3] = 0.0; - fReflSurf[4] = 0.0; - fReflSurf[5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.5*(1.4142135623730951*vcutsq[1]-1.4142135623730951*vcutsq[0])); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurf[0] = -0.7071067811865475*(1.732050807568877*f[1]-1.0*f[0]); - fReflSurf[1] = -0.7071067811865475*(1.732050807568877*f[4]-1.0*f[2]); - fReflSurf[2] = -0.7071067811865475*(1.732050807568877*f[5]-1.0*f[3]); - fReflSurf[3] = -0.7071067811865475*(1.732050807568877*f[7]-1.0*f[6]); - fReflSurf[4] = -0.1414213562373095*(8.660254037844387*f[9]-5.0*f[8]); - fReflSurf[5] = -0.1414213562373095*(8.660254037844387*f[11]-5.0*f[10]); + fReflSurfMu[0][0] = 0.0; + fReflSurfMu[0][1] = 0.0; + fReflSurfMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfMu[0][0] = 0.5*(1.7320508075688772*f[5]-1.0*(f[3]+1.7320508075688772*f[1])+f[0]); + fReflSurfMu[0][1] = 0.5*(1.7320508075688772*f[7]-1.0*(f[6]+1.7320508075688772*f[4])+f[2]); + fReflSurfMu[0][2] = 0.03333333333333333*(1.7320508075688772*(15.0*f[11]-8.660254037844387*f[10])+3.0*(5.0*f[8]-8.660254037844387*f[9])); - double xBar, xSqBar; - double fReflSurfMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[0][0] = 0.01863389981249824*((25.98076211353316*f[11]-15.0*f[10]-25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]-20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])+15.0*f[10]+25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]-13.41640786499874*f[3]-23.2379000772445*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]+20.12461179749811*f[4]-13.41640786499874*f[3]-11.61895003862225*f[2]-23.2379000772445*f[1]+13.41640786499874*f[0]); - fReflSurfMu[0][1] = 0.03125*((20.12461179749811*f[11]-11.61895003862225*f[10]-20.1246117974981*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]-8.0*f[6]-13.85640646055102*f[4]+8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])+7.745966692414834*f[10]+13.41640786499874*f[9]-7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]-12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]+6.708203932499369*f[9]-3.872983346207417*f[8]+13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]-13.85640646055102*f[4]+6.928203230275509*f[3]+8.0*f[2]+12.0*f[1]-6.928203230275509*f[0]); - fReflSurfMu[0][2] = 0.002083333333333333*((467.6537180435967*f[11]-269.9999999999999*f[10]-467.6537180435969*f[9]+270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]-174.2842505793337*f[6]-301.8691769624717*f[4]+174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])+300.0000000000001*f[10]+519.6152422706633*f[9]-300.0*f[8]+232.379000772445*f[5]-134.1640786499874*f[3]-232.379000772445*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])+116.1895003862225*f[6]+201.2461179749811*f[4]-116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]-150.0*f[10]-259.8076211353317*f[9]+150.0*f[8]-232.379000772445*f[5]+134.1640786499874*f[3]+232.379000772445*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[11]-120.0*f[10]-207.8460969082653*f[9]+120.0*f[8]-100.6230589874906*f[7]+58.09475019311126*f[6]+100.6230589874906*f[4]-58.09475019311126*f[2]); + fReflSurfMu[0][0] = 0.018633899812498245*((25.980762113533157*f[11]-15.000000000000002*f[10]-25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]-20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])+15.000000000000002*f[10]+25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]-13.416407864998739*f[3]-23.2379000772445*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]+20.12461179749811*f[4]-13.416407864998739*f[3]-11.61895003862225*f[2]-23.2379000772445*f[1]+13.416407864998739*f[0]); + fReflSurfMu[0][1] = 0.03125*((20.12461179749811*f[11]-11.618950038622252*f[10]-20.124611797498105*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]-8.0*f[6]-13.856406460551018*f[4]+8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])+7.745966692414834*f[10]+13.416407864998737*f[9]-7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]-12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]+6.7082039324993685*f[9]-3.872983346207417*f[8]+13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]-13.856406460551018*f[4]+6.928203230275509*f[3]+8.0*f[2]+12.0*f[1]-6.928203230275509*f[0]); + fReflSurfMu[0][2] = 0.0020833333333333333*((467.65371804359665*f[11]-269.99999999999994*f[10]-467.65371804359694*f[9]+270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]-174.28425057933373*f[6]-301.86917696247167*f[4]+174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])+300.00000000000006*f[10]+519.6152422706633*f[9]-300.0*f[8]+232.37900077244504*f[5]-134.1640786499874*f[3]-232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])+116.18950038622252*f[6]+201.2461179749811*f[4]-116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]-150.00000000000003*f[10]-259.80762113533166*f[9]+150.0*f[8]-232.37900077244504*f[5]+134.1640786499874*f[3]+232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[11]-120.00000000000001*f[10]-207.84609690826528*f[9]+120.0*f[8]-100.62305898749055*f[7]+58.09475019311126*f[6]+100.62305898749055*f[4]-58.09475019311126*f[2]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[0][0] = -0.01863389981249824*((25.98076211353316*f[11]-15.0*f[10]-25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]-20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])+15.0*f[10]+25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]-13.41640786499874*f[3]-23.2379000772445*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]+20.12461179749811*f[4]+13.41640786499874*f[3]-11.61895003862225*f[2]+23.2379000772445*f[1]-13.41640786499874*f[0]); - fReflSurfMu[0][1] = -0.03125*((20.12461179749811*f[11]-11.61895003862225*f[10]-20.1246117974981*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]-8.0*f[6]-13.85640646055102*f[4]+8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])+7.745966692414834*f[10]+13.41640786499874*f[9]-7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]-12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]+6.708203932499369*f[9]-3.872983346207417*f[8]-13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]+13.85640646055102*f[4]+6.928203230275509*f[3]-8.0*f[2]+12.0*f[1]-6.928203230275509*f[0]); - fReflSurfMu[0][2] = -0.002083333333333333*((467.6537180435967*f[11]-269.9999999999999*f[10]-467.6537180435969*f[9]+270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]-174.2842505793337*f[6]-301.8691769624717*f[4]+174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])+300.0000000000001*f[10]+519.6152422706633*f[9]-300.0*f[8]+232.379000772445*f[5]-134.1640786499874*f[3]-232.379000772445*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])+116.1895003862225*f[6]+201.2461179749811*f[4]-116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]-150.0*f[10]-259.8076211353317*f[9]+150.0*f[8]-232.379000772445*f[5]+134.1640786499874*f[3]+232.379000772445*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[11]+120.0*f[10]+207.8460969082653*f[9]-120.0*f[8]-100.6230589874906*f[7]+58.09475019311126*f[6]+100.6230589874906*f[4]-58.09475019311126*f[2]); + fReflSurfMu[0][0] = -(0.018633899812498245*((25.980762113533157*f[11]-15.000000000000002*f[10]-25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]-20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])+15.000000000000002*f[10]+25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]-13.416407864998739*f[3]-23.2379000772445*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]+20.12461179749811*f[4]+13.416407864998739*f[3]-11.61895003862225*f[2]+23.2379000772445*f[1]-13.416407864998739*f[0])); + fReflSurfMu[0][1] = -(0.03125*((20.12461179749811*f[11]-11.618950038622252*f[10]-20.124611797498105*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]-8.0*f[6]-13.856406460551018*f[4]+8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])+7.745966692414834*f[10]+13.416407864998737*f[9]-7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]-12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]+6.7082039324993685*f[9]-3.872983346207417*f[8]-13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]+13.856406460551018*f[4]+6.928203230275509*f[3]-8.0*f[2]+12.0*f[1]-6.928203230275509*f[0])); + fReflSurfMu[0][2] = -(0.0020833333333333333*((467.65371804359665*f[11]-269.99999999999994*f[10]-467.65371804359694*f[9]+270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]-174.28425057933373*f[6]-301.86917696247167*f[4]+174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])+300.00000000000006*f[10]+519.6152422706633*f[9]-300.0*f[8]+232.37900077244504*f[5]-134.1640786499874*f[3]-232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])+116.18950038622252*f[6]+201.2461179749811*f[4]-116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]-150.00000000000003*f[10]-259.80762113533166*f[9]+150.0*f[8]-232.37900077244504*f[5]+134.1640786499874*f[3]+232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[11]+120.00000000000001*f[10]+207.84609690826528*f[9]-120.0*f[8]-100.62305898749055*f[7]+58.09475019311126*f[6]+100.62305898749055*f[4]-58.09475019311126*f[2])); } @@ -251,32 +243,50 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double fReflSurfMu[0][2] = 0.0; } - // node (mu)_1 + } + + // node (mu)_1 + vcutsq_n = 0.7071067811865476*(vcutsq[1]+vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfMu[1][0] = 0.0; + fReflSurfMu[1][1] = 0.0; + fReflSurfMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfMu[1][0] = -(0.5*(1.7320508075688772*f[5]-1.0*f[3]+1.7320508075688772*f[1]-1.0*f[0])); + fReflSurfMu[1][1] = -(0.5*(1.7320508075688772*f[7]-1.0*f[6]+1.7320508075688772*f[4]-1.0*f[2])); + fReflSurfMu[1][2] = -(0.03333333333333333*(1.7320508075688772*(15.0*f[11]-8.660254037844387*f[10])+3.0*(8.660254037844387*f[9]-5.0*f[8]))); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[1][0] = -0.01863389981249824*((25.98076211353316*f[11]-15.0*f[10]+25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]+20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])+15.0*f[10]-25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]-13.41640786499874*f[3]+23.2379000772445*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]-20.12461179749811*f[4]-13.41640786499874*f[3]+11.61895003862225*f[2]+23.2379000772445*f[1]-13.41640786499874*f[0]); - fReflSurfMu[1][1] = -0.03125*((20.12461179749811*f[11]-11.61895003862225*f[10]+20.1246117974981*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]-8.0*f[6]+13.85640646055102*f[4]-8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])+7.745966692414834*f[10]-13.41640786499874*f[9]+7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]-6.708203932499369*f[9]+3.872983346207417*f[8]+13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]+13.85640646055102*f[4]+6.928203230275509*f[3]-8.0*f[2]-12.0*f[1]+6.928203230275509*f[0]); - fReflSurfMu[1][2] = -0.002083333333333333*((467.6537180435967*f[11]-269.9999999999999*f[10]+467.6537180435969*f[9]-270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]-174.2842505793337*f[6]+301.8691769624717*f[4]-174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])+300.0000000000001*f[10]-519.6152422706633*f[9]+300.0*f[8]+232.379000772445*f[5]-134.1640786499874*f[3]+232.379000772445*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])+116.1895003862225*f[6]-201.2461179749811*f[4]+116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]-150.0*f[10]+259.8076211353317*f[9]-150.0*f[8]-232.379000772445*f[5]+134.1640786499874*f[3]-232.379000772445*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[11]-120.0*f[10]+207.8460969082653*f[9]-120.0*f[8]-100.6230589874906*f[7]+58.09475019311126*f[6]-100.6230589874906*f[4]+58.09475019311126*f[2]); + fReflSurfMu[1][0] = -(0.018633899812498245*((25.980762113533157*f[11]-15.000000000000002*f[10]+25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]+20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])+15.000000000000002*f[10]-25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]-13.416407864998739*f[3]+23.2379000772445*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]-20.12461179749811*f[4]-13.416407864998739*f[3]+11.61895003862225*f[2]+23.2379000772445*f[1]-13.416407864998739*f[0])); + fReflSurfMu[1][1] = -(0.03125*((20.12461179749811*f[11]-11.618950038622252*f[10]+20.124611797498105*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]-8.0*f[6]+13.856406460551018*f[4]-8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])+7.745966692414834*f[10]-13.416407864998737*f[9]+7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]-6.7082039324993685*f[9]+3.872983346207417*f[8]+13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]+13.856406460551018*f[4]+6.928203230275509*f[3]-8.0*f[2]-12.0*f[1]+6.928203230275509*f[0])); + fReflSurfMu[1][2] = -(0.0020833333333333333*((467.65371804359665*f[11]-269.99999999999994*f[10]+467.65371804359694*f[9]-270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]-174.28425057933373*f[6]+301.86917696247167*f[4]-174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])+300.00000000000006*f[10]-519.6152422706633*f[9]+300.0*f[8]+232.37900077244504*f[5]-134.1640786499874*f[3]+232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])+116.18950038622252*f[6]-201.2461179749811*f[4]+116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]-150.00000000000003*f[10]+259.80762113533166*f[9]-150.0*f[8]-232.37900077244504*f[5]+134.1640786499874*f[3]-232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[11]-120.00000000000001*f[10]+207.84609690826528*f[9]-120.0*f[8]-100.62305898749055*f[7]+58.09475019311126*f[6]-100.62305898749055*f[4]+58.09475019311126*f[2])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[1][0] = 0.01863389981249824*((25.98076211353316*f[11]-15.0*f[10]+25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]+20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])+15.0*f[10]-25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]-13.41640786499874*f[3]+23.2379000772445*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]-20.12461179749811*f[4]+13.41640786499874*f[3]+11.61895003862225*f[2]-23.2379000772445*f[1]+13.41640786499874*f[0]); - fReflSurfMu[1][1] = 0.03125*((20.12461179749811*f[11]-11.61895003862225*f[10]+20.1246117974981*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]-8.0*f[6]+13.85640646055102*f[4]-8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])+7.745966692414834*f[10]-13.41640786499874*f[9]+7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]-6.708203932499369*f[9]+3.872983346207417*f[8]-13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]-13.85640646055102*f[4]+6.928203230275509*f[3]+8.0*f[2]-12.0*f[1]+6.928203230275509*f[0]); - fReflSurfMu[1][2] = 0.002083333333333333*((467.6537180435967*f[11]-269.9999999999999*f[10]+467.6537180435969*f[9]-270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]-174.2842505793337*f[6]+301.8691769624717*f[4]-174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])+300.0000000000001*f[10]-519.6152422706633*f[9]+300.0*f[8]+232.379000772445*f[5]-134.1640786499874*f[3]+232.379000772445*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])+116.1895003862225*f[6]-201.2461179749811*f[4]+116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]-150.0*f[10]+259.8076211353317*f[9]-150.0*f[8]-232.379000772445*f[5]+134.1640786499874*f[3]-232.379000772445*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[11]+120.0*f[10]-207.8460969082653*f[9]+120.0*f[8]-100.6230589874906*f[7]+58.09475019311126*f[6]-100.6230589874906*f[4]+58.09475019311126*f[2]); + fReflSurfMu[1][0] = 0.018633899812498245*((25.980762113533157*f[11]-15.000000000000002*f[10]+25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]-11.61895003862225*f[6]+20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])+15.000000000000002*f[10]-25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]-13.416407864998739*f[3]+23.2379000772445*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]-20.12461179749811*f[4]+13.416407864998739*f[3]+11.61895003862225*f[2]-23.2379000772445*f[1]+13.416407864998739*f[0]); + fReflSurfMu[1][1] = 0.03125*((20.12461179749811*f[11]-11.618950038622252*f[10]+20.124611797498105*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]-8.0*f[6]+13.856406460551018*f[4]-8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])+7.745966692414834*f[10]-13.416407864998737*f[9]+7.745966692414834*f[8]+12.0*f[5]-6.928203230275509*f[3]+12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]+3.872983346207417*f[10]-6.7082039324993685*f[9]+3.872983346207417*f[8]-13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]-13.856406460551018*f[4]+6.928203230275509*f[3]+8.0*f[2]-12.0*f[1]+6.928203230275509*f[0]); + fReflSurfMu[1][2] = 0.0020833333333333333*((467.65371804359665*f[11]-269.99999999999994*f[10]+467.65371804359694*f[9]-270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]-174.28425057933373*f[6]+301.86917696247167*f[4]-174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])+300.00000000000006*f[10]-519.6152422706633*f[9]+300.0*f[8]+232.37900077244504*f[5]-134.1640786499874*f[3]+232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])+116.18950038622252*f[6]-201.2461179749811*f[4]+116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]-150.00000000000003*f[10]+259.80762113533166*f[9]-150.0*f[8]-232.37900077244504*f[5]+134.1640786499874*f[3]-232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[11]+120.00000000000001*f[10]-207.84609690826528*f[9]+120.0*f[8]-100.62305898749055*f[7]+58.09475019311126*f[6]-100.62305898749055*f[4]+58.09475019311126*f[2]); } @@ -294,6 +304,8 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double fReflSurfMu[1][2] = 0.0; } + } + fReflSurf[0] = 0.7071067811865475*(fReflSurfMu[1][0]+fReflSurfMu[0][0]); fReflSurf[1] = 0.7071067811865475*(fReflSurfMu[1][1]+fReflSurfMu[0][1]); fReflSurf[2] = 0.7071067811865475*(fReflSurfMu[1][0]-1.0*fReflSurfMu[0][0]); @@ -301,25 +313,23 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double fReflSurf[4] = 0.7071067811865475*(fReflSurfMu[1][2]+fReflSurfMu[0][2]); fReflSurf[5] = 0.7071067811865475*(fReflSurfMu[1][2]-1.0*fReflSurfMu[0][2]); - } - - fRefl[0] = 1.414213562373095*fReflSurf[0]; + fRefl[0] = 1.4142135623730951*fReflSurf[0]; fRefl[1] = 0.0; - fRefl[2] = 1.414213562373095*fReflSurf[1]; - fRefl[3] = 1.414213562373095*fReflSurf[2]; + fRefl[2] = 1.4142135623730951*fReflSurf[1]; + fRefl[3] = 1.4142135623730951*fReflSurf[2]; fRefl[4] = 0.0; fRefl[5] = 0.0; - fRefl[6] = 1.414213562373095*fReflSurf[3]; + fRefl[6] = 1.4142135623730951*fReflSurf[3]; fRefl[7] = 0.0; - fRefl[8] = 1.414213562373095*fReflSurf[4]; + fRefl[8] = 1.4142135623730951*fReflSurf[4]; fRefl[9] = 0.0; - fRefl[10] = 1.414213562373095*fReflSurf[5]; + fRefl[10] = 1.4142135623730951*fReflSurf[5]; fRefl[11] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; + double vcutsq_n; double fReflSurf[6] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; @@ -328,60 +338,54 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; - vcutSq = 0.5*(2.449489742783178*phiWall[1]-2.449489742783178*phi[1]+1.414213562373095*phiWall[0]-1.414213562373095*phi[0])*q2Dm; + double wv = 0.5*(vparUp+vparLo); + double dv = vparUp-1.0*vparLo; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + double xBar, xSqBar; + double fReflSurfMu[2][3] = {0.}; - fReflSurf[0] = 0.0; - fReflSurf[1] = 0.0; - fReflSurf[2] = 0.0; - fReflSurf[3] = 0.0; - fReflSurf[4] = 0.0; - fReflSurf[5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.5*(1.4142135623730951*vcutsq[1]-1.4142135623730951*vcutsq[0])); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurf[0] = 0.7071067811865475*(1.732050807568877*f[1]+f[0]); - fReflSurf[1] = 0.7071067811865475*(1.732050807568877*f[4]+f[2]); - fReflSurf[2] = 0.7071067811865475*(1.732050807568877*f[5]+f[3]); - fReflSurf[3] = 0.7071067811865475*(1.732050807568877*f[7]+f[6]); - fReflSurf[4] = 0.1414213562373095*(8.660254037844387*f[9]+5.0*f[8]); - fReflSurf[5] = 0.1414213562373095*(8.660254037844387*f[11]+5.0*f[10]); + fReflSurfMu[0][0] = 0.0; + fReflSurfMu[0][1] = 0.0; + fReflSurfMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfMu[0][0] = -(0.5*(1.7320508075688772*f[5]+f[3]-1.0*(1.7320508075688772*f[1]+f[0]))); + fReflSurfMu[0][1] = -(0.5*(1.7320508075688772*f[7]+f[6]-1.0*(1.7320508075688772*f[4]+f[2]))); + fReflSurfMu[0][2] = -(0.03333333333333333*(1.7320508075688772*(15.0*f[11]+8.660254037844387*f[10])-3.0*(8.660254037844387*f[9]+5.0*f[8]))); - double xBar, xSqBar; - double fReflSurfMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[0][0] = -0.01863389981249824*((25.98076211353316*f[11]+15.0*f[10]-25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]-20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])-15.0*f[10]+25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]+13.41640786499874*f[3]-23.2379000772445*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]+20.12461179749811*f[4]+13.41640786499874*f[3]+11.61895003862225*f[2]-23.2379000772445*f[1]-13.41640786499874*f[0]); - fReflSurfMu[0][1] = -0.03125*((20.12461179749811*f[11]+11.61895003862225*f[10]-20.1246117974981*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]+8.0*f[6]-13.85640646055102*f[4]-8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])-7.745966692414834*f[10]+13.41640786499874*f[9]+7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]-12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]+6.708203932499369*f[9]+3.872983346207417*f[8]+13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]-13.85640646055102*f[4]-6.928203230275509*f[3]-8.0*f[2]+12.0*f[1]+6.928203230275509*f[0]); - fReflSurfMu[0][2] = -0.002083333333333333*((467.6537180435967*f[11]+269.9999999999999*f[10]-467.6537180435969*f[9]-270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]+174.2842505793337*f[6]-301.8691769624717*f[4]-174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])-300.0000000000001*f[10]+519.6152422706633*f[9]+300.0*f[8]+232.379000772445*f[5]+134.1640786499874*f[3]-232.379000772445*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])-116.1895003862225*f[6]+201.2461179749811*f[4]+116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]+150.0*f[10]-259.8076211353317*f[9]-150.0*f[8]-232.379000772445*f[5]-134.1640786499874*f[3]+232.379000772445*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[11]+120.0*f[10]-207.8460969082653*f[9]-120.0*f[8]-100.6230589874906*f[7]-58.09475019311126*f[6]+100.6230589874906*f[4]+58.09475019311126*f[2]); + fReflSurfMu[0][0] = -(0.018633899812498245*((25.980762113533157*f[11]+15.000000000000002*f[10]-25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]-20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])-15.000000000000002*f[10]+25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]+13.416407864998739*f[3]-23.2379000772445*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]+20.12461179749811*f[4]+13.416407864998739*f[3]+11.61895003862225*f[2]-23.2379000772445*f[1]-13.416407864998739*f[0])); + fReflSurfMu[0][1] = -(0.03125*((20.12461179749811*f[11]+11.618950038622252*f[10]-20.124611797498105*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]+8.0*f[6]-13.856406460551018*f[4]-8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])-7.745966692414834*f[10]+13.416407864998737*f[9]+7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]-12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]+6.7082039324993685*f[9]+3.872983346207417*f[8]+13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]-13.856406460551018*f[4]-6.928203230275509*f[3]-8.0*f[2]+12.0*f[1]+6.928203230275509*f[0])); + fReflSurfMu[0][2] = -(0.0020833333333333333*((467.65371804359665*f[11]+269.99999999999994*f[10]-467.65371804359694*f[9]-270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]+174.28425057933373*f[6]-301.86917696247167*f[4]-174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])-300.00000000000006*f[10]+519.6152422706633*f[9]+300.0*f[8]+232.37900077244504*f[5]+134.1640786499874*f[3]-232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])-116.18950038622252*f[6]+201.2461179749811*f[4]+116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]+150.00000000000003*f[10]-259.80762113533166*f[9]-150.0*f[8]-232.37900077244504*f[5]-134.1640786499874*f[3]+232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[11]+120.00000000000001*f[10]-207.84609690826528*f[9]-120.0*f[8]-100.62305898749055*f[7]-58.09475019311126*f[6]+100.62305898749055*f[4]+58.09475019311126*f[2])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[0][0] = 0.01863389981249824*((25.98076211353316*f[11]+15.0*f[10]-25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]-20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])-15.0*f[10]+25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]+13.41640786499874*f[3]-23.2379000772445*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]+20.12461179749811*f[4]-13.41640786499874*f[3]+11.61895003862225*f[2]+23.2379000772445*f[1]+13.41640786499874*f[0]); - fReflSurfMu[0][1] = 0.03125*((20.12461179749811*f[11]+11.61895003862225*f[10]-20.1246117974981*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]+8.0*f[6]-13.85640646055102*f[4]-8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])-7.745966692414834*f[10]+13.41640786499874*f[9]+7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]-12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]+6.708203932499369*f[9]+3.872983346207417*f[8]-13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]+13.85640646055102*f[4]-6.928203230275509*f[3]+8.0*f[2]+12.0*f[1]+6.928203230275509*f[0]); - fReflSurfMu[0][2] = 0.002083333333333333*((467.6537180435967*f[11]+269.9999999999999*f[10]-467.6537180435969*f[9]-270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]+174.2842505793337*f[6]-301.8691769624717*f[4]-174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])-300.0000000000001*f[10]+519.6152422706633*f[9]+300.0*f[8]+232.379000772445*f[5]+134.1640786499874*f[3]-232.379000772445*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])-116.1895003862225*f[6]+201.2461179749811*f[4]+116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]+150.0*f[10]-259.8076211353317*f[9]-150.0*f[8]-232.379000772445*f[5]-134.1640786499874*f[3]+232.379000772445*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[11]-120.0*f[10]+207.8460969082653*f[9]+120.0*f[8]-100.6230589874906*f[7]-58.09475019311126*f[6]+100.6230589874906*f[4]+58.09475019311126*f[2]); + fReflSurfMu[0][0] = 0.018633899812498245*((25.980762113533157*f[11]+15.000000000000002*f[10]-25.98076211353316*f[9]-15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]-20.12461179749811*f[4]-11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])-15.000000000000002*f[10]+25.98076211353316*f[9]+15.0*f[8]+23.2379000772445*f[5]+13.416407864998739*f[3]-23.2379000772445*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]+20.12461179749811*f[4]-13.416407864998739*f[3]+11.61895003862225*f[2]+23.2379000772445*f[1]+13.416407864998739*f[0]); + fReflSurfMu[0][1] = 0.03125*((20.12461179749811*f[11]+11.618950038622252*f[10]-20.124611797498105*f[9]-11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]+8.0*f[6]-13.856406460551018*f[4]-8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])-7.745966692414834*f[10]+13.416407864998737*f[9]+7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]-12.0*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]+6.7082039324993685*f[9]+3.872983346207417*f[8]-13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]+13.856406460551018*f[4]-6.928203230275509*f[3]+8.0*f[2]+12.0*f[1]+6.928203230275509*f[0]); + fReflSurfMu[0][2] = 0.0020833333333333333*((467.65371804359665*f[11]+269.99999999999994*f[10]-467.65371804359694*f[9]-270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]+174.28425057933373*f[6]-301.86917696247167*f[4]-174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])-300.00000000000006*f[10]+519.6152422706633*f[9]+300.0*f[8]+232.37900077244504*f[5]+134.1640786499874*f[3]-232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])-116.18950038622252*f[6]+201.2461179749811*f[4]+116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]+150.00000000000003*f[10]-259.80762113533166*f[9]-150.0*f[8]-232.37900077244504*f[5]-134.1640786499874*f[3]+232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[11]-120.00000000000001*f[10]+207.84609690826528*f[9]+120.0*f[8]-100.62305898749055*f[7]-58.09475019311126*f[6]+100.62305898749055*f[4]+58.09475019311126*f[2]); } @@ -399,32 +403,50 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double fReflSurfMu[0][2] = 0.0; } - // node (mu)_1 + } + + // node (mu)_1 + vcutsq_n = 0.7071067811865476*(vcutsq[1]+vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfMu[1][0] = 0.0; + fReflSurfMu[1][1] = 0.0; + fReflSurfMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfMu[1][0] = 0.5*(1.7320508075688772*f[5]+f[3]+1.7320508075688772*f[1]+f[0]); + fReflSurfMu[1][1] = 0.5*(1.7320508075688772*f[7]+f[6]+1.7320508075688772*f[4]+f[2]); + fReflSurfMu[1][2] = 0.03333333333333333*(1.7320508075688772*(15.0*f[11]+8.660254037844387*f[10])+3.0*(8.660254037844387*f[9]+5.0*f[8])); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[1][0] = 0.01863389981249824*((25.98076211353316*f[11]+15.0*f[10]+25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]+20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])-15.0*f[10]-25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]+13.41640786499874*f[3]+23.2379000772445*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]-20.12461179749811*f[4]+13.41640786499874*f[3]-11.61895003862225*f[2]+23.2379000772445*f[1]+13.41640786499874*f[0]); - fReflSurfMu[1][1] = 0.03125*((20.12461179749811*f[11]+11.61895003862225*f[10]+20.1246117974981*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]+8.0*f[6]+13.85640646055102*f[4]+8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])-7.745966692414834*f[10]-13.41640786499874*f[9]-7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]-6.708203932499369*f[9]-3.872983346207417*f[8]+13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]+13.85640646055102*f[4]-6.928203230275509*f[3]+8.0*f[2]-12.0*f[1]-6.928203230275509*f[0]); - fReflSurfMu[1][2] = 0.002083333333333333*((467.6537180435967*f[11]+269.9999999999999*f[10]+467.6537180435969*f[9]+270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]+174.2842505793337*f[6]+301.8691769624717*f[4]+174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])-300.0000000000001*f[10]-519.6152422706633*f[9]-300.0*f[8]+232.379000772445*f[5]+134.1640786499874*f[3]+232.379000772445*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])-116.1895003862225*f[6]-201.2461179749811*f[4]-116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]+150.0*f[10]+259.8076211353317*f[9]+150.0*f[8]-232.379000772445*f[5]-134.1640786499874*f[3]-232.379000772445*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[11]+120.0*f[10]+207.8460969082653*f[9]+120.0*f[8]-100.6230589874906*f[7]-58.09475019311126*f[6]-100.6230589874906*f[4]-58.09475019311126*f[2]); + fReflSurfMu[1][0] = 0.018633899812498245*((25.980762113533157*f[11]+15.000000000000002*f[10]+25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]+20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])-15.000000000000002*f[10]-25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]+13.416407864998739*f[3]+23.2379000772445*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]-20.12461179749811*f[4]+13.416407864998739*f[3]-11.61895003862225*f[2]+23.2379000772445*f[1]+13.416407864998739*f[0]); + fReflSurfMu[1][1] = 0.03125*((20.12461179749811*f[11]+11.618950038622252*f[10]+20.124611797498105*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]+8.0*f[6]+13.856406460551018*f[4]+8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])-7.745966692414834*f[10]-13.416407864998737*f[9]-7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]-6.7082039324993685*f[9]-3.872983346207417*f[8]+13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]+13.856406460551018*f[4]-6.928203230275509*f[3]+8.0*f[2]-12.0*f[1]-6.928203230275509*f[0]); + fReflSurfMu[1][2] = 0.0020833333333333333*((467.65371804359665*f[11]+269.99999999999994*f[10]+467.65371804359694*f[9]+270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]+174.28425057933373*f[6]+301.86917696247167*f[4]+174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])-300.00000000000006*f[10]-519.6152422706633*f[9]-300.0*f[8]+232.37900077244504*f[5]+134.1640786499874*f[3]+232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])-116.18950038622252*f[6]-201.2461179749811*f[4]-116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]+150.00000000000003*f[10]+259.80762113533166*f[9]+150.0*f[8]-232.37900077244504*f[5]-134.1640786499874*f[3]-232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[11]+120.00000000000001*f[10]+207.84609690826528*f[9]+120.0*f[8]-100.62305898749055*f[7]-58.09475019311126*f[6]-100.62305898749055*f[4]-58.09475019311126*f[2]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfMu[1][0] = -0.01863389981249824*((25.98076211353316*f[11]+15.0*f[10]+25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]+20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+((-25.98076211353316*f[11])-15.0*f[10]-25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]+13.41640786499874*f[3]+23.2379000772445*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]-20.12461179749811*f[4]-13.41640786499874*f[3]-11.61895003862225*f[2]-23.2379000772445*f[1]-13.41640786499874*f[0]); - fReflSurfMu[1][1] = -0.03125*((20.12461179749811*f[11]+11.61895003862225*f[10]+20.1246117974981*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.85640646055102*f[7]+8.0*f[6]+13.85640646055102*f[4]+8.0*f[2])*vcut_lR3+((-13.41640786499874*f[11])-7.745966692414834*f[10]-13.41640786499874*f[9]-7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]-6.708203932499369*f[9]-3.872983346207417*f[8]-13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]-13.85640646055102*f[4]-6.928203230275509*f[3]-8.0*f[2]-12.0*f[1]-6.928203230275509*f[0]); - fReflSurfMu[1][2] = -0.002083333333333333*((467.6537180435967*f[11]+269.9999999999999*f[10]+467.6537180435969*f[9]+270.0*f[8])*vcut_lR5+(301.8691769624717*f[7]+174.2842505793337*f[6]+301.8691769624717*f[4]+174.2842505793337*f[2])*vcut_lR4+((-519.6152422706631*f[11])-300.0000000000001*f[10]-519.6152422706633*f[9]-300.0*f[8]+232.379000772445*f[5]+134.1640786499874*f[3]+232.379000772445*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[7])-116.1895003862225*f[6]-201.2461179749811*f[4]-116.1895003862225*f[2])*vcut_lR2+(259.8076211353315*f[11]+150.0*f[10]+259.8076211353317*f[9]+150.0*f[8]-232.379000772445*f[5]-134.1640786499874*f[3]-232.379000772445*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[11]-120.0*f[10]-207.8460969082653*f[9]-120.0*f[8]-100.6230589874906*f[7]-58.09475019311126*f[6]-100.6230589874906*f[4]-58.09475019311126*f[2]); + fReflSurfMu[1][0] = -(0.018633899812498245*((25.980762113533157*f[11]+15.000000000000002*f[10]+25.98076211353316*f[9]+15.0*f[8])*vcut_lR3+(20.12461179749811*f[7]+11.61895003862225*f[6]+20.12461179749811*f[4]+11.61895003862225*f[2])*vcut_lR2+(-(25.980762113533157*f[11])-15.000000000000002*f[10]-25.98076211353316*f[9]-15.0*f[8]+23.2379000772445*f[5]+13.416407864998739*f[3]+23.2379000772445*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]-20.12461179749811*f[4]-13.416407864998739*f[3]-11.61895003862225*f[2]-23.2379000772445*f[1]-13.416407864998739*f[0])); + fReflSurfMu[1][1] = -(0.03125*((20.12461179749811*f[11]+11.618950038622252*f[10]+20.124611797498105*f[9]+11.61895003862225*f[8])*vcut_lR4+(13.856406460551018*f[7]+8.0*f[6]+13.856406460551018*f[4]+8.0*f[2])*vcut_lR3+(-(13.416407864998739*f[11])-7.745966692414834*f[10]-13.416407864998737*f[9]-7.745966692414834*f[8]+12.0*f[5]+6.928203230275509*f[3]+12.0*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[11]-3.872983346207417*f[10]-6.7082039324993685*f[9]-3.872983346207417*f[8]-13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]-13.856406460551018*f[4]-6.928203230275509*f[3]-8.0*f[2]-12.0*f[1]-6.928203230275509*f[0])); + fReflSurfMu[1][2] = -(0.0020833333333333333*((467.65371804359665*f[11]+269.99999999999994*f[10]+467.65371804359694*f[9]+270.0*f[8])*vcut_lR5+(301.86917696247167*f[7]+174.28425057933373*f[6]+301.86917696247167*f[4]+174.28425057933373*f[2])*vcut_lR4+(-(519.6152422706631*f[11])-300.00000000000006*f[10]-519.6152422706633*f[9]-300.0*f[8]+232.37900077244504*f[5]+134.1640786499874*f[3]+232.37900077244504*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[7])-116.18950038622252*f[6]-201.2461179749811*f[4]-116.18950038622252*f[2])*vcut_lR2+(259.80762113533154*f[11]+150.00000000000003*f[10]+259.80762113533166*f[9]+150.0*f[8]-232.37900077244504*f[5]-134.1640786499874*f[3]-232.37900077244504*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[11]-120.00000000000001*f[10]-207.84609690826528*f[9]-120.0*f[8]-100.62305898749055*f[7]-58.09475019311126*f[6]-100.62305898749055*f[4]-58.09475019311126*f[2])); } @@ -442,6 +464,8 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double fReflSurfMu[1][2] = 0.0; } + } + fReflSurf[0] = 0.7071067811865475*(fReflSurfMu[1][0]+fReflSurfMu[0][0]); fReflSurf[1] = 0.7071067811865475*(fReflSurfMu[1][1]+fReflSurfMu[0][1]); fReflSurf[2] = 0.7071067811865475*(fReflSurfMu[1][0]-1.0*fReflSurfMu[0][0]); @@ -449,25 +473,23 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double fReflSurf[4] = 0.7071067811865475*(fReflSurfMu[1][2]+fReflSurfMu[0][2]); fReflSurf[5] = 0.7071067811865475*(fReflSurfMu[1][2]-1.0*fReflSurfMu[0][2]); - } - - fRefl[0] = 1.414213562373095*fReflSurf[0]; + fRefl[0] = 1.4142135623730951*fReflSurf[0]; fRefl[1] = 0.0; - fRefl[2] = 1.414213562373095*fReflSurf[1]; - fRefl[3] = 1.414213562373095*fReflSurf[2]; + fRefl[2] = 1.4142135623730951*fReflSurf[1]; + fRefl[3] = 1.4142135623730951*fReflSurf[2]; fRefl[4] = 0.0; fRefl[5] = 0.0; - fRefl[6] = 1.414213562373095*fReflSurf[3]; + fRefl[6] = 1.4142135623730951*fReflSurf[3]; fRefl[7] = 0.0; - fRefl[8] = 1.414213562373095*fReflSurf[4]; + fRefl[8] = 1.4142135623730951*fReflSurf[4]; fRefl[9] = 0.0; - fRefl[10] = 1.414213562373095*fReflSurf[5]; + fRefl[10] = 1.4142135623730951*fReflSurf[5]; fRefl[11] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double *vmap, double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; + double vcutsq_n; double fReflSurfX[2][6] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; double vparUp = 1.224744871391589*vmap[1]+0.7071067811865475*vmap[0]; @@ -475,119 +497,137 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; + double wv; + double dv; + + double xBar, xSqBar; + double fReflSurfXMu[2][3] = {0.}; + // node (x)_0 - vcutSq = 0.5*(1.732050807568877*phiWall[3]-1.732050807568877*(phi[3]+phiWall[2])+1.732050807568877*phi[2]-1.0*phiWall[1]+phi[1]+phiWall[0]-1.0*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfX[0][0] = 0.0; - fReflSurfX[0][1] = 0.0; - fReflSurfX[0][2] = 0.0; - fReflSurfX[0][3] = 0.0; - fReflSurfX[0][4] = 0.0; - fReflSurfX[0][5] = 0.0; + // node (mu)_0 + vcutsq_n = 0.5*(vcutsq[3]-1.0*(vcutsq[2]+vcutsq[1])+vcutsq[0]); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfX[0][0] = 0.5*(1.732050807568877*f[5]-1.0*(1.732050807568877*f[2]+f[1])+f[0]); - fReflSurfX[0][1] = 0.5*(1.732050807568877*f[11]-1.0*(1.732050807568877*f[7]+f[6])+f[3]); - fReflSurfX[0][2] = 0.5*(1.732050807568877*f[12]-1.0*(1.732050807568877*f[9]+f[8])+f[4]); - fReflSurfX[0][3] = 0.5*(1.732050807568877*f[15]-1.0*(1.732050807568877*f[14]+f[13])+f[10]); - fReflSurfX[0][4] = 0.03333333333333333*(25.98076211353316*f[20]-8.660254037844387*(3.0*f[18]+1.732050807568877*f[17])+15.0*f[16]); - fReflSurfX[0][5] = 0.03333333333333333*(25.98076211353316*f[23]-8.660254037844387*(3.0*f[22]+1.732050807568877*f[21])+15.0*f[19]); + fReflSurfXMu[0][0] = 0.0; + fReflSurfXMu[0][1] = 0.0; + fReflSurfXMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXMu[0][0] = -(0.3535533905932737*(1.7320508075688772*f[12]-1.0*(1.7320508075688772*f[9]+f[8]+1.7320508075688772*f[5])+f[4]+1.7320508075688772*f[2]+f[1]-1.0*f[0])); + fReflSurfXMu[0][1] = -(0.3535533905932737*(1.7320508075688772*f[15]-1.0*(1.7320508075688772*f[14]+f[13]+1.7320508075688772*f[11])+f[10]+1.7320508075688772*f[7]+f[6]-1.0*f[3])); + fReflSurfXMu[0][2] = -(0.023570226039551577*(25.98076211353316*f[23]-5.0*(5.196152422706631*f[22]+3.0*f[21]+5.196152422706631*f[20])+8.660254037844387*(1.7320508075688772*f[19]+3.0*f[18]+1.7320508075688772*f[17])-15.0*f[16])); - double xBar, xSqBar; - double fReflSurfXMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = -0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.41640786499874*f[8]-23.2379000772445*f[5]+13.41640786499874*f[4]+23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.41640786499874*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]+13.41640786499874*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[0][1] = -0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]+11.61895003862225*f[19]+20.1246117974981*f[18]+11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]-13.85640646055102*f[11]+8.0*f[10]+13.85640646055102*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]+7.745966692414834*f[21]+13.41640786499874*f[20]-7.745966692414834*f[19]-13.41640786499874*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]-6.708203932499369*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]+13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]+8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]+13.85640646055102*f[7]+8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[0][2] = -0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]-270.0*f[21]-467.6537180435967*f[20]+269.9999999999999*f[19]+467.6537180435969*f[18]+269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]-174.2842505793337*f[13]-301.8691769624717*f[11]+174.2842505793337*f[10]+301.8691769624717*f[7]+174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]-300.0000000000001*f[19]-519.6152422706633*f[18]-300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]+116.1895003862225*f[13]+201.2461179749811*f[11]-116.1895003862225*f[10]-201.2461179749811*f[7]-116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]-150.0*f[21]-259.8076211353315*f[20]+150.0*f[19]+259.8076211353317*f[18]+150.0*f[17]-150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]-207.8460969082653*f[22]-120.0*f[21]-207.8460969082653*f[20]+120.0*f[19]+207.8460969082653*f[18]+120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]+58.09475019311126*f[13]+100.6230589874906*f[11]-58.09475019311126*f[10]-100.6230589874906*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[0][0] = -(0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.416407864998739*f[8]-23.2379000772445*f[5]+13.416407864998739*f[4]+23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.416407864998739*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]+13.416407864998739*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[0][1] = -(0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]+11.618950038622252*f[19]+20.124611797498105*f[18]+11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]-13.856406460551018*f[11]+8.0*f[10]+13.856406460551018*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]+7.745966692414834*f[21]+13.416407864998739*f[20]-7.745966692414834*f[19]-13.416407864998737*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]-6.7082039324993685*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]+13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]+8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]+13.856406460551018*f[7]+8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXMu[0][2] = -(0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]-270.0*f[21]-467.65371804359665*f[20]+269.99999999999994*f[19]+467.65371804359694*f[18]+269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]-174.28425057933373*f[13]-301.86917696247167*f[11]+174.28425057933373*f[10]+301.86917696247167*f[7]+174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]-300.00000000000006*f[19]-519.6152422706633*f[18]-300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]+116.18950038622252*f[13]+201.2461179749811*f[11]-116.18950038622252*f[10]-201.2461179749811*f[7]-116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]-150.0*f[21]-259.80762113533154*f[20]+150.00000000000003*f[19]+259.80762113533166*f[18]+150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]-207.84609690826525*f[22]-120.0*f[21]-207.84609690826525*f[20]+120.00000000000001*f[19]+207.84609690826528*f[18]+120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]+58.09475019311126*f[13]+100.62305898749055*f[11]-58.09475019311126*f[10]-100.62305898749055*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.41640786499874*f[8]-23.2379000772445*f[5]+13.41640786499874*f[4]+23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.41640786499874*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]-13.41640786499874*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[0][1] = 0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]+11.61895003862225*f[19]+20.1246117974981*f[18]+11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]-13.85640646055102*f[11]+8.0*f[10]+13.85640646055102*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]+7.745966692414834*f[21]+13.41640786499874*f[20]-7.745966692414834*f[19]-13.41640786499874*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]-6.708203932499369*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]-13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]-8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]-13.85640646055102*f[7]-8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[0][2] = 0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]-270.0*f[21]-467.6537180435967*f[20]+269.9999999999999*f[19]+467.6537180435969*f[18]+269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]-174.2842505793337*f[13]-301.8691769624717*f[11]+174.2842505793337*f[10]+301.8691769624717*f[7]+174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]-300.0000000000001*f[19]-519.6152422706633*f[18]-300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]+116.1895003862225*f[13]+201.2461179749811*f[11]-116.1895003862225*f[10]-201.2461179749811*f[7]-116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]-150.0*f[21]-259.8076211353315*f[20]+150.0*f[19]+259.8076211353317*f[18]+150.0*f[17]-150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]+207.8460969082653*f[22]+120.0*f[21]+207.8460969082653*f[20]-120.0*f[19]-207.8460969082653*f[18]-120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]+58.09475019311126*f[13]+100.6230589874906*f[11]-58.09475019311126*f[10]-100.6230589874906*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.416407864998739*f[8]-23.2379000772445*f[5]+13.416407864998739*f[4]+23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.416407864998739*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]-13.416407864998739*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[0][1] = 0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]+11.618950038622252*f[19]+20.124611797498105*f[18]+11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]-13.856406460551018*f[11]+8.0*f[10]+13.856406460551018*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]+7.745966692414834*f[21]+13.416407864998739*f[20]-7.745966692414834*f[19]-13.416407864998737*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]-6.7082039324993685*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]-13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]-8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]-13.856406460551018*f[7]-8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXMu[0][2] = 0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]-270.0*f[21]-467.65371804359665*f[20]+269.99999999999994*f[19]+467.65371804359694*f[18]+269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]-174.28425057933373*f[13]-301.86917696247167*f[11]+174.28425057933373*f[10]+301.86917696247167*f[7]+174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]-300.00000000000006*f[19]-519.6152422706633*f[18]-300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]+116.18950038622252*f[13]+201.2461179749811*f[11]-116.18950038622252*f[10]-201.2461179749811*f[7]-116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]-150.0*f[21]-259.80762113533154*f[20]+150.00000000000003*f[19]+259.80762113533166*f[18]+150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]+207.84609690826525*f[22]+120.0*f[21]+207.84609690826525*f[20]-120.00000000000001*f[19]-207.84609690826528*f[18]-120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]+58.09475019311126*f[13]+100.62305898749055*f[11]-58.09475019311126*f[10]-100.62305898749055*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; - if (fReflSurfXMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; + if (fReflSurfXMu[0][0]<0.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = -(0.5*(vcutsq[3]-1.0*vcutsq[2]+vcutsq[1]-1.0*vcutsq[0])); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXMu[1][0] = 0.0; + fReflSurfXMu[1][1] = 0.0; + fReflSurfXMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXMu[1][0] = 0.3535533905932737*(1.7320508075688772*f[12]-1.0*(1.7320508075688772*f[9]+f[8])+1.7320508075688772*f[5]+f[4]-1.0*(1.7320508075688772*f[2]+f[1])+f[0]); + fReflSurfXMu[1][1] = 0.3535533905932737*(1.7320508075688772*f[15]-1.0*(1.7320508075688772*f[14]+f[13])+1.7320508075688772*f[11]+f[10]-1.0*(1.7320508075688772*f[7]+f[6])+f[3]); + fReflSurfXMu[1][2] = 0.023570226039551577*(25.98076211353316*f[23]+5.0*(5.196152422706631*f[20]-1.0*(5.196152422706631*f[22]+3.0*f[21]))+8.660254037844387*(1.7320508075688772*f[19]-1.0*(3.0*f[18]+1.7320508075688772*f[17]))+15.0*f[16]); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.41640786499874*f[8]+23.2379000772445*f[5]+13.41640786499874*f[4]-23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.41640786499874*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]+13.41640786499874*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[1][1] = 0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]+11.61895003862225*f[19]-20.1246117974981*f[18]-11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]+13.85640646055102*f[11]+8.0*f[10]-13.85640646055102*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]+7.745966692414834*f[21]-13.41640786499874*f[20]-7.745966692414834*f[19]+13.41640786499874*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]+6.708203932499369*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]+13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]+8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]-13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[1][2] = 0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]-270.0*f[21]+467.6537180435967*f[20]+269.9999999999999*f[19]-467.6537180435969*f[18]-269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]-174.2842505793337*f[13]+301.8691769624717*f[11]+174.2842505793337*f[10]-301.8691769624717*f[7]-174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]-300.0000000000001*f[19]+519.6152422706633*f[18]+300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]+116.1895003862225*f[13]-201.2461179749811*f[11]-116.1895003862225*f[10]+201.2461179749811*f[7]+116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]-150.0*f[21]+259.8076211353315*f[20]+150.0*f[19]-259.8076211353317*f[18]-150.0*f[17]+150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]-207.8460969082653*f[22]-120.0*f[21]+207.8460969082653*f[20]+120.0*f[19]-207.8460969082653*f[18]-120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]+58.09475019311126*f[13]-100.6230589874906*f[11]-58.09475019311126*f[10]+100.6230589874906*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.416407864998739*f[8]+23.2379000772445*f[5]+13.416407864998739*f[4]-23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.416407864998739*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]+13.416407864998739*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[1][1] = 0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]+11.618950038622252*f[19]-20.124611797498105*f[18]-11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]+13.856406460551018*f[11]+8.0*f[10]-13.856406460551018*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]+7.745966692414834*f[21]-13.416407864998739*f[20]-7.745966692414834*f[19]+13.416407864998737*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]+6.7082039324993685*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]+13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]+8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]-13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXMu[1][2] = 0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]-270.0*f[21]+467.65371804359665*f[20]+269.99999999999994*f[19]-467.65371804359694*f[18]-269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]-174.28425057933373*f[13]+301.86917696247167*f[11]+174.28425057933373*f[10]-301.86917696247167*f[7]-174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]-300.00000000000006*f[19]+519.6152422706633*f[18]+300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]+116.18950038622252*f[13]-201.2461179749811*f[11]-116.18950038622252*f[10]+201.2461179749811*f[7]+116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]-150.0*f[21]+259.80762113533154*f[20]+150.00000000000003*f[19]-259.80762113533166*f[18]-150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]-207.84609690826525*f[22]-120.0*f[21]+207.84609690826525*f[20]+120.00000000000001*f[19]-207.84609690826528*f[18]-120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]+58.09475019311126*f[13]-100.62305898749055*f[11]-58.09475019311126*f[10]+100.62305898749055*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = -0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.41640786499874*f[8]+23.2379000772445*f[5]+13.41640786499874*f[4]-23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.41640786499874*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]-13.41640786499874*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[1][1] = -0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]+11.61895003862225*f[19]-20.1246117974981*f[18]-11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]+13.85640646055102*f[11]+8.0*f[10]-13.85640646055102*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]+7.745966692414834*f[21]-13.41640786499874*f[20]-7.745966692414834*f[19]+13.41640786499874*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]+6.708203932499369*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]-13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]-8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]+13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[1][2] = -0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]-270.0*f[21]+467.6537180435967*f[20]+269.9999999999999*f[19]-467.6537180435969*f[18]-269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]-174.2842505793337*f[13]+301.8691769624717*f[11]+174.2842505793337*f[10]-301.8691769624717*f[7]-174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]-300.0000000000001*f[19]+519.6152422706633*f[18]+300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]+116.1895003862225*f[13]-201.2461179749811*f[11]-116.1895003862225*f[10]+201.2461179749811*f[7]+116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]-150.0*f[21]+259.8076211353315*f[20]+150.0*f[19]-259.8076211353317*f[18]-150.0*f[17]+150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]+207.8460969082653*f[22]+120.0*f[21]-207.8460969082653*f[20]-120.0*f[19]+207.8460969082653*f[18]+120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]+58.09475019311126*f[13]-100.6230589874906*f[11]-58.09475019311126*f[10]+100.6230589874906*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[1][0] = -(0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]-13.416407864998739*f[8]+23.2379000772445*f[5]+13.416407864998739*f[4]-23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.416407864998739*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]-13.416407864998739*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[1][1] = -(0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]+11.618950038622252*f[19]-20.124611797498105*f[18]-11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]+13.856406460551018*f[11]+8.0*f[10]-13.856406460551018*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]+7.745966692414834*f[21]-13.416407864998739*f[20]-7.745966692414834*f[19]+13.416407864998737*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]+6.7082039324993685*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]-13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]-8.0*f[10]+12.0*f[9]+6.928203230275509*f[8]+13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXMu[1][2] = -(0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]-270.0*f[21]+467.65371804359665*f[20]+269.99999999999994*f[19]-467.65371804359694*f[18]-269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]-174.28425057933373*f[13]+301.86917696247167*f[11]+174.28425057933373*f[10]-301.86917696247167*f[7]-174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]-300.00000000000006*f[19]+519.6152422706633*f[18]+300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]+116.18950038622252*f[13]-201.2461179749811*f[11]-116.18950038622252*f[10]+201.2461179749811*f[7]+116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]-150.0*f[21]+259.80762113533154*f[20]+150.00000000000003*f[19]-259.80762113533166*f[18]-150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]+207.84609690826525*f[22]+120.0*f[21]-207.84609690826525*f[20]-120.00000000000001*f[19]+207.84609690826528*f[18]+120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]+58.09475019311126*f[13]-100.62305898749055*f[11]-58.09475019311126*f[10]+100.62305898749055*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; - if (fReflSurfXMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; + if (fReflSurfXMu[1][0]<0.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; + } + } fReflSurfX[0][0] = 0.7071067811865475*(fReflSurfXMu[1][0]+fReflSurfXMu[0][0]); @@ -597,121 +637,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double fReflSurfX[0][4] = 0.7071067811865475*(fReflSurfXMu[1][2]+fReflSurfXMu[0][2]); fReflSurfX[0][5] = 0.7071067811865475*(fReflSurfXMu[1][2]-1.0*fReflSurfXMu[0][2]); - } - // node (x)_1 - vcutSq = -0.5*(1.732050807568877*phiWall[3]-1.732050807568877*phi[3]+1.732050807568877*phiWall[2]-1.732050807568877*phi[2]-1.0*phiWall[1]+phi[1]-1.0*phiWall[0]+phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfX[1][0] = 0.0; - fReflSurfX[1][1] = 0.0; - fReflSurfX[1][2] = 0.0; - fReflSurfX[1][3] = 0.0; - fReflSurfX[1][4] = 0.0; - fReflSurfX[1][5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.5*(vcutsq[3]+vcutsq[2]-1.0*(vcutsq[1]+vcutsq[0]))); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfX[1][0] = -0.5*(1.732050807568877*(f[5]+f[2])-1.0*(f[1]+f[0])); - fReflSurfX[1][1] = -0.5*(1.732050807568877*(f[11]+f[7])-1.0*(f[6]+f[3])); - fReflSurfX[1][2] = -0.5*(1.732050807568877*(f[12]+f[9])-1.0*(f[8]+f[4])); - fReflSurfX[1][3] = -0.5*(1.732050807568877*(f[15]+f[14])-1.0*(f[13]+f[10])); - fReflSurfX[1][4] = -0.03333333333333333*(25.98076211353316*f[20]+25.98076211353316*f[18]-1.0*(15.0*f[17]+15.0*f[16])); - fReflSurfX[1][5] = -0.03333333333333333*(25.98076211353316*f[23]+25.98076211353316*f[22]-1.0*(15.0*f[21]+15.0*f[19])); + fReflSurfXMu[0][0] = 0.0; + fReflSurfXMu[0][1] = 0.0; + fReflSurfXMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXMu[0][0] = 0.3535533905932737*(1.7320508075688772*(f[12]+f[9])-1.0*(f[8]+1.7320508075688772*f[5]+f[4]+1.7320508075688772*f[2])+f[1]+f[0]); + fReflSurfXMu[0][1] = 0.3535533905932737*(1.7320508075688772*(f[15]+f[14])-1.0*(f[13]+1.7320508075688772*f[11]+f[10]+1.7320508075688772*f[7])+f[6]+f[3]); + fReflSurfXMu[0][2] = 0.023570226039551577*(25.98076211353316*f[23]+5.0*(5.196152422706631*f[22]-1.0*(3.0*f[21]+5.196152422706631*f[20]))+8.660254037844387*(1.7320508075688772*f[17]-1.0*(1.7320508075688772*f[19]+3.0*f[18]))+15.0*f[16]); - double xBar, xSqBar; - double fReflSurfXMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.41640786499874*f[8]-23.2379000772445*f[5]-13.41640786499874*f[4]-23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.41640786499874*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]-13.41640786499874*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[0][1] = 0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]-11.61895003862225*f[19]-20.1246117974981*f[18]+11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]-13.85640646055102*f[11]-8.0*f[10]-13.85640646055102*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]+7.745966692414834*f[21]+13.41640786499874*f[20]+7.745966692414834*f[19]+13.41640786499874*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]+6.708203932499369*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]+13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]-8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]-13.85640646055102*f[7]+8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[0][2] = 0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]-270.0*f[21]-467.6537180435967*f[20]-269.9999999999999*f[19]-467.6537180435969*f[18]+269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]-174.2842505793337*f[13]-301.8691769624717*f[11]-174.2842505793337*f[10]-301.8691769624717*f[7]+174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]+300.0000000000001*f[19]+519.6152422706633*f[18]-300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]+116.1895003862225*f[13]+201.2461179749811*f[11]+116.1895003862225*f[10]+201.2461179749811*f[7]-116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]-150.0*f[21]-259.8076211353315*f[20]-150.0*f[19]-259.8076211353317*f[18]+150.0*f[17]+150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]+207.8460969082653*f[22]-120.0*f[21]-207.8460969082653*f[20]-120.0*f[19]-207.8460969082653*f[18]+120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]+58.09475019311126*f[13]+100.6230589874906*f[11]+58.09475019311126*f[10]+100.6230589874906*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.416407864998739*f[8]-23.2379000772445*f[5]-13.416407864998739*f[4]-23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.416407864998739*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]-13.416407864998739*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[0][1] = 0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]-11.618950038622252*f[19]-20.124611797498105*f[18]+11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]-13.856406460551018*f[11]-8.0*f[10]-13.856406460551018*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]+7.745966692414834*f[21]+13.416407864998739*f[20]+7.745966692414834*f[19]+13.416407864998737*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]+6.7082039324993685*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]+13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]-8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]-13.856406460551018*f[7]+8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXMu[0][2] = 0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]-270.0*f[21]-467.65371804359665*f[20]-269.99999999999994*f[19]-467.65371804359694*f[18]+269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]-174.28425057933373*f[13]-301.86917696247167*f[11]-174.28425057933373*f[10]-301.86917696247167*f[7]+174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]+300.00000000000006*f[19]+519.6152422706633*f[18]-300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]+116.18950038622252*f[13]+201.2461179749811*f[11]+116.18950038622252*f[10]+201.2461179749811*f[7]-116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]-150.0*f[21]-259.80762113533154*f[20]-150.00000000000003*f[19]-259.80762113533166*f[18]+150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]+207.84609690826525*f[22]-120.0*f[21]-207.84609690826525*f[20]-120.00000000000001*f[19]-207.84609690826528*f[18]+120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]+58.09475019311126*f[13]+100.62305898749055*f[11]+58.09475019311126*f[10]+100.62305898749055*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = -0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.41640786499874*f[8]-23.2379000772445*f[5]-13.41640786499874*f[4]-23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.41640786499874*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]+13.41640786499874*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[0][1] = -0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]-11.61895003862225*f[19]-20.1246117974981*f[18]+11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]-13.85640646055102*f[11]-8.0*f[10]-13.85640646055102*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]+7.745966692414834*f[21]+13.41640786499874*f[20]+7.745966692414834*f[19]+13.41640786499874*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]+6.708203932499369*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]-13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]+8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]+13.85640646055102*f[7]-8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[0][2] = -0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]-270.0*f[21]-467.6537180435967*f[20]-269.9999999999999*f[19]-467.6537180435969*f[18]+269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]-174.2842505793337*f[13]-301.8691769624717*f[11]-174.2842505793337*f[10]-301.8691769624717*f[7]+174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]+300.0000000000001*f[19]+519.6152422706633*f[18]-300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]+116.1895003862225*f[13]+201.2461179749811*f[11]+116.1895003862225*f[10]+201.2461179749811*f[7]-116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]-150.0*f[21]-259.8076211353315*f[20]-150.0*f[19]-259.8076211353317*f[18]+150.0*f[17]+150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]-207.8460969082653*f[22]+120.0*f[21]+207.8460969082653*f[20]+120.0*f[19]+207.8460969082653*f[18]-120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]+58.09475019311126*f[13]+100.6230589874906*f[11]+58.09475019311126*f[10]+100.6230589874906*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[0][0] = -(0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.416407864998739*f[8]-23.2379000772445*f[5]-13.416407864998739*f[4]-23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.416407864998739*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]+13.416407864998739*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[0][1] = -(0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]-20.12461179749811*f[20]-11.618950038622252*f[19]-20.124611797498105*f[18]+11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]-13.856406460551018*f[11]-8.0*f[10]-13.856406460551018*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]+7.745966692414834*f[21]+13.416407864998739*f[20]+7.745966692414834*f[19]+13.416407864998737*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]+6.7082039324993685*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]-13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]+8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]+13.856406460551018*f[7]-8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXMu[0][2] = -(0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]-270.0*f[21]-467.65371804359665*f[20]-269.99999999999994*f[19]-467.65371804359694*f[18]+269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]-174.28425057933373*f[13]-301.86917696247167*f[11]-174.28425057933373*f[10]-301.86917696247167*f[7]+174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]+519.6152422706631*f[20]+300.00000000000006*f[19]+519.6152422706633*f[18]-300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]+116.18950038622252*f[13]+201.2461179749811*f[11]+116.18950038622252*f[10]+201.2461179749811*f[7]-116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]-150.0*f[21]-259.80762113533154*f[20]-150.00000000000003*f[19]-259.80762113533166*f[18]+150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]-207.84609690826525*f[22]+120.0*f[21]+207.84609690826525*f[20]+120.00000000000001*f[19]+207.84609690826528*f[18]-120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]+58.09475019311126*f[13]+100.62305898749055*f[11]+58.09475019311126*f[10]+100.62305898749055*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; - if (fReflSurfXMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; + if (fReflSurfXMu[0][0]<0.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = 0.5*(vcutsq[3]+vcutsq[2]+vcutsq[1]+vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXMu[1][0] = 0.0; + fReflSurfXMu[1][1] = 0.0; + fReflSurfXMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXMu[1][0] = -(0.3535533905932737*(1.7320508075688772*(f[12]+f[9])-1.0*f[8]+1.7320508075688772*f[5]-1.0*f[4]+1.7320508075688772*f[2]-1.0*(f[1]+f[0]))); + fReflSurfXMu[1][1] = -(0.3535533905932737*(1.7320508075688772*(f[15]+f[14])-1.0*f[13]+1.7320508075688772*f[11]-1.0*f[10]+1.7320508075688772*f[7]-1.0*(f[6]+f[3]))); + fReflSurfXMu[1][2] = -(0.023570226039551577*(25.98076211353316*f[23]+5.0*(5.196152422706631*f[22]-3.0*f[21]+5.196152422706631*f[20])+8.660254037844387*(3.0*f[18]-1.7320508075688772*f[19])-1.0*(15.000000000000002*f[17]+15.0*f[16]))); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = -0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.41640786499874*f[8]+23.2379000772445*f[5]-13.41640786499874*f[4]+23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.41640786499874*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]-13.41640786499874*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[1][1] = -0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]-11.61895003862225*f[19]+20.1246117974981*f[18]-11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]+13.85640646055102*f[11]-8.0*f[10]+13.85640646055102*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]+7.745966692414834*f[21]-13.41640786499874*f[20]+7.745966692414834*f[19]-13.41640786499874*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]-6.708203932499369*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]+13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]-8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]+13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[1][2] = -0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]-270.0*f[21]+467.6537180435967*f[20]-269.9999999999999*f[19]+467.6537180435969*f[18]-269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]-174.2842505793337*f[13]+301.8691769624717*f[11]-174.2842505793337*f[10]+301.8691769624717*f[7]-174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]+300.0000000000001*f[19]-519.6152422706633*f[18]+300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]+116.1895003862225*f[13]-201.2461179749811*f[11]+116.1895003862225*f[10]-201.2461179749811*f[7]+116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]-150.0*f[21]+259.8076211353315*f[20]-150.0*f[19]+259.8076211353317*f[18]-150.0*f[17]-150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]+207.8460969082653*f[22]-120.0*f[21]+207.8460969082653*f[20]-120.0*f[19]+207.8460969082653*f[18]-120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]+58.09475019311126*f[13]-100.6230589874906*f[11]+58.09475019311126*f[10]-100.6230589874906*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[1][0] = -(0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.416407864998739*f[8]+23.2379000772445*f[5]-13.416407864998739*f[4]+23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.416407864998739*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]-13.416407864998739*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[1][1] = -(0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]-11.618950038622252*f[19]+20.124611797498105*f[18]-11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]+13.856406460551018*f[11]-8.0*f[10]+13.856406460551018*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]+7.745966692414834*f[21]-13.416407864998739*f[20]+7.745966692414834*f[19]-13.416407864998737*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]-6.7082039324993685*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]+13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]-8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]+13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXMu[1][2] = -(0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]-270.0*f[21]+467.65371804359665*f[20]-269.99999999999994*f[19]+467.65371804359694*f[18]-269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]-174.28425057933373*f[13]+301.86917696247167*f[11]-174.28425057933373*f[10]+301.86917696247167*f[7]-174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]+300.00000000000006*f[19]-519.6152422706633*f[18]+300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]+116.18950038622252*f[13]-201.2461179749811*f[11]+116.18950038622252*f[10]-201.2461179749811*f[7]+116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]-150.0*f[21]+259.80762113533154*f[20]-150.00000000000003*f[19]+259.80762113533166*f[18]-150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]+207.84609690826525*f[22]-120.0*f[21]+207.84609690826525*f[20]-120.00000000000001*f[19]+207.84609690826528*f[18]-120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]+58.09475019311126*f[13]-100.62305898749055*f[11]+58.09475019311126*f[10]-100.62305898749055*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.41640786499874*f[8]+23.2379000772445*f[5]-13.41640786499874*f[4]+23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.41640786499874*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]+13.41640786499874*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[1][1] = 0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]-11.61895003862225*f[19]+20.1246117974981*f[18]-11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]+13.85640646055102*f[11]-8.0*f[10]+13.85640646055102*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]+7.745966692414834*f[21]-13.41640786499874*f[20]+7.745966692414834*f[19]-13.41640786499874*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]-6.708203932499369*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]-13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]+8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]-13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[1][2] = 0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]-270.0*f[21]+467.6537180435967*f[20]-269.9999999999999*f[19]+467.6537180435969*f[18]-269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]-174.2842505793337*f[13]+301.8691769624717*f[11]-174.2842505793337*f[10]+301.8691769624717*f[7]-174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]+300.0000000000001*f[19]-519.6152422706633*f[18]+300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]+116.1895003862225*f[13]-201.2461179749811*f[11]+116.1895003862225*f[10]-201.2461179749811*f[7]+116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]-150.0*f[21]+259.8076211353315*f[20]-150.0*f[19]+259.8076211353317*f[18]-150.0*f[17]-150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]-207.8460969082653*f[22]+120.0*f[21]-207.8460969082653*f[20]+120.0*f[19]-207.8460969082653*f[18]+120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]+58.09475019311126*f[13]-100.6230589874906*f[11]+58.09475019311126*f[10]-100.6230589874906*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]-13.416407864998739*f[8]+23.2379000772445*f[5]-13.416407864998739*f[4]+23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.416407864998739*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]+13.416407864998739*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[1][1] = 0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]-11.61895003862225*f[21]+20.12461179749811*f[20]-11.618950038622252*f[19]+20.124611797498105*f[18]-11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]+13.856406460551018*f[11]-8.0*f[10]+13.856406460551018*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]+7.745966692414834*f[21]-13.416407864998739*f[20]+7.745966692414834*f[19]-13.416407864998737*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]-6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]+3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]-6.7082039324993685*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]-13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]+8.0*f[10]-12.0*f[9]+6.928203230275509*f[8]-13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXMu[1][2] = 0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]-270.0*f[21]+467.65371804359665*f[20]-269.99999999999994*f[19]+467.65371804359694*f[18]-269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]-174.28425057933373*f[13]+301.86917696247167*f[11]-174.28425057933373*f[10]+301.86917696247167*f[7]-174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]+300.0*f[21]-519.6152422706631*f[20]+300.00000000000006*f[19]-519.6152422706633*f[18]+300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]+116.18950038622252*f[13]-201.2461179749811*f[11]+116.18950038622252*f[10]-201.2461179749811*f[7]+116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]-150.0*f[21]+259.80762113533154*f[20]-150.00000000000003*f[19]+259.80762113533166*f[18]-150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]-207.84609690826525*f[22]+120.0*f[21]-207.84609690826525*f[20]+120.00000000000001*f[19]-207.84609690826528*f[18]+120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]+58.09475019311126*f[13]-100.62305898749055*f[11]+58.09475019311126*f[10]-100.62305898749055*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; - if (fReflSurfXMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; + if (fReflSurfXMu[1][0]<0.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; + } + } fReflSurfX[1][0] = 0.7071067811865475*(fReflSurfXMu[1][0]+fReflSurfXMu[0][0]); @@ -721,8 +771,6 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double fReflSurfX[1][4] = 0.7071067811865475*(fReflSurfXMu[1][2]+fReflSurfXMu[0][2]); fReflSurfX[1][5] = 0.7071067811865475*(fReflSurfXMu[1][2]-1.0*fReflSurfXMu[0][2]); - } - fRefl[0] = fReflSurfX[1][0]+fReflSurfX[0][0]; fRefl[1] = fReflSurfX[1][0]-1.0*fReflSurfX[0][0]; fRefl[2] = 0.0; @@ -740,18 +788,18 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double fRefl[14] = 0.0; fRefl[15] = 0.0; fRefl[16] = fReflSurfX[1][4]+fReflSurfX[0][4]; - fRefl[17] = 1.0*(fReflSurfX[1][4]-1.0*fReflSurfX[0][4]); + fRefl[17] = 1.0000000000000002*(fReflSurfX[1][4]-1.0*fReflSurfX[0][4]); fRefl[18] = 0.0; fRefl[19] = fReflSurfX[1][5]+fReflSurfX[0][5]; fRefl[20] = 0.0; - fRefl[21] = 1.0*(fReflSurfX[1][5]-1.0*fReflSurfX[0][5]); + fRefl[21] = 1.0000000000000002*(fReflSurfX[1][5]-1.0*fReflSurfX[0][5]); fRefl[22] = 0.0; fRefl[23] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double *vmap, double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; + double vcutsq_n; double fReflSurfX[2][6] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; double vparUp = 1.224744871391589*vmap[1]+0.7071067811865475*vmap[0]; @@ -759,119 +807,137 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; + double wv; + double dv; + + double xBar, xSqBar; + double fReflSurfXMu[2][3] = {0.}; + // node (x)_0 - vcutSq = -0.5*(1.732050807568877*phiWall[3]-1.732050807568877*(phi[3]+phiWall[2])+1.732050807568877*phi[2]+phiWall[1]-1.0*(phi[1]+phiWall[0])+phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfX[0][0] = 0.0; - fReflSurfX[0][1] = 0.0; - fReflSurfX[0][2] = 0.0; - fReflSurfX[0][3] = 0.0; - fReflSurfX[0][4] = 0.0; - fReflSurfX[0][5] = 0.0; + // node (mu)_0 + vcutsq_n = 0.5*(vcutsq[3]-1.0*(vcutsq[2]+vcutsq[1])+vcutsq[0]); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfX[0][0] = -0.5*(1.732050807568877*(f[5]-1.0*f[2])+f[1]-1.0*f[0]); - fReflSurfX[0][1] = -0.5*(1.732050807568877*(f[11]-1.0*f[7])+f[6]-1.0*f[3]); - fReflSurfX[0][2] = -0.5*(1.732050807568877*(f[12]-1.0*f[9])+f[8]-1.0*f[4]); - fReflSurfX[0][3] = -0.5*(1.732050807568877*(f[15]-1.0*f[14])+f[13]-1.0*f[10]); - fReflSurfX[0][4] = -0.03333333333333333*(25.98076211353316*f[20]+8.660254037844387*(1.732050807568877*f[17]-3.0*f[18])-15.0*f[16]); - fReflSurfX[0][5] = -0.03333333333333333*(25.98076211353316*f[23]+8.660254037844387*(1.732050807568877*f[21]-3.0*f[22])-15.0*f[19]); + fReflSurfXMu[0][0] = 0.0; + fReflSurfXMu[0][1] = 0.0; + fReflSurfXMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXMu[0][0] = 0.3535533905932737*(1.7320508075688772*(f[12]-1.0*f[9])+f[8]-1.0*(1.7320508075688772*f[5]+f[4])+1.7320508075688772*f[2]-1.0*f[1]+f[0]); + fReflSurfXMu[0][1] = 0.3535533905932737*(1.7320508075688772*(f[15]-1.0*f[14])+f[13]-1.0*(1.7320508075688772*f[11]+f[10])+1.7320508075688772*f[7]-1.0*f[6]+f[3]); + fReflSurfXMu[0][2] = 0.023570226039551577*(25.98076211353316*f[23]+5.0*(-(5.196152422706631*f[22])+3.0*f[21]-5.196152422706631*f[20])+8.660254037844387*(-(1.7320508075688772*f[19])+3.0*f[18]-1.7320508075688772*f[17])+15.0*f[16]); - double xBar, xSqBar; - double fReflSurfXMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.41640786499874*f[8]-23.2379000772445*f[5]-13.41640786499874*f[4]+23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.41640786499874*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]-13.41640786499874*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[0][1] = 0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]-11.61895003862225*f[19]+20.1246117974981*f[18]-11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]-13.85640646055102*f[11]-8.0*f[10]+13.85640646055102*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]-7.745966692414834*f[21]+13.41640786499874*f[20]+7.745966692414834*f[19]-13.41640786499874*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]-6.708203932499369*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]+13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]-8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]+13.85640646055102*f[7]-8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[0][2] = 0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]+270.0*f[21]-467.6537180435967*f[20]-269.9999999999999*f[19]+467.6537180435969*f[18]-269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]+174.2842505793337*f[13]-301.8691769624717*f[11]-174.2842505793337*f[10]+301.8691769624717*f[7]-174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]+300.0000000000001*f[19]-519.6152422706633*f[18]+300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]-116.1895003862225*f[13]+201.2461179749811*f[11]+116.1895003862225*f[10]-201.2461179749811*f[7]+116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]+150.0*f[21]-259.8076211353315*f[20]-150.0*f[19]+259.8076211353317*f[18]-150.0*f[17]+150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]-207.8460969082653*f[22]+120.0*f[21]-207.8460969082653*f[20]-120.0*f[19]+207.8460969082653*f[18]-120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]-58.09475019311126*f[13]+100.6230589874906*f[11]+58.09475019311126*f[10]-100.6230589874906*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.416407864998739*f[8]-23.2379000772445*f[5]-13.416407864998739*f[4]+23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.416407864998739*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]-13.416407864998739*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[0][1] = 0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]-11.618950038622252*f[19]+20.124611797498105*f[18]-11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]-13.856406460551018*f[11]-8.0*f[10]+13.856406460551018*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]-7.745966692414834*f[21]+13.416407864998739*f[20]+7.745966692414834*f[19]-13.416407864998737*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]-6.7082039324993685*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]+13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]-8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]+13.856406460551018*f[7]-8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXMu[0][2] = 0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]+270.0*f[21]-467.65371804359665*f[20]-269.99999999999994*f[19]+467.65371804359694*f[18]-269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]+174.28425057933373*f[13]-301.86917696247167*f[11]-174.28425057933373*f[10]+301.86917696247167*f[7]-174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]+300.00000000000006*f[19]-519.6152422706633*f[18]+300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]-116.18950038622252*f[13]+201.2461179749811*f[11]+116.18950038622252*f[10]-201.2461179749811*f[7]+116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]+150.0*f[21]-259.80762113533154*f[20]-150.00000000000003*f[19]+259.80762113533166*f[18]-150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]-207.84609690826525*f[22]+120.0*f[21]-207.84609690826525*f[20]-120.00000000000001*f[19]+207.84609690826528*f[18]-120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]-58.09475019311126*f[13]+100.62305898749055*f[11]+58.09475019311126*f[10]-100.62305898749055*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = -0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.41640786499874*f[8]-23.2379000772445*f[5]-13.41640786499874*f[4]+23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.41640786499874*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]+13.41640786499874*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[0][1] = -0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]-11.61895003862225*f[19]+20.1246117974981*f[18]-11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]-13.85640646055102*f[11]-8.0*f[10]+13.85640646055102*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]-7.745966692414834*f[21]+13.41640786499874*f[20]+7.745966692414834*f[19]-13.41640786499874*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]-6.708203932499369*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]-13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]+8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]-13.85640646055102*f[7]+8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[0][2] = -0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]+270.0*f[21]-467.6537180435967*f[20]-269.9999999999999*f[19]+467.6537180435969*f[18]-269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]+174.2842505793337*f[13]-301.8691769624717*f[11]-174.2842505793337*f[10]+301.8691769624717*f[7]-174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]+300.0000000000001*f[19]-519.6152422706633*f[18]+300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]-116.1895003862225*f[13]+201.2461179749811*f[11]+116.1895003862225*f[10]-201.2461179749811*f[7]+116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]+150.0*f[21]-259.8076211353315*f[20]-150.0*f[19]+259.8076211353317*f[18]-150.0*f[17]+150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]+207.8460969082653*f[22]-120.0*f[21]+207.8460969082653*f[20]+120.0*f[19]-207.8460969082653*f[18]+120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]-58.09475019311126*f[13]+100.6230589874906*f[11]+58.09475019311126*f[10]-100.6230589874906*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[0][0] = -(0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]-11.61895003862225*f[10]+20.12461179749811*f[7]-11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.416407864998739*f[8]-23.2379000772445*f[5]-13.416407864998739*f[4]+23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.416407864998739*f[8]-20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]+13.416407864998739*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[0][1] = -(0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]-11.618950038622252*f[19]+20.124611797498105*f[18]-11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]-13.856406460551018*f[11]-8.0*f[10]+13.856406460551018*f[7]-8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]-7.745966692414834*f[21]+13.416407864998739*f[20]+7.745966692414834*f[19]-13.416407864998737*f[18]+7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]-6.928203230275509*f[4]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]+3.872983346207417*f[19]-6.7082039324993685*f[18]+3.872983346207417*f[17]-3.872983346207417*f[16]-13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]+8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]-13.856406460551018*f[7]+8.0*f[6]+12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXMu[0][2] = -(0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]+270.0*f[21]-467.65371804359665*f[20]-269.99999999999994*f[19]+467.65371804359694*f[18]-269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]+174.28425057933373*f[13]-301.86917696247167*f[11]-174.28425057933373*f[10]+301.86917696247167*f[7]-174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]+300.00000000000006*f[19]-519.6152422706633*f[18]+300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]-116.18950038622252*f[13]+201.2461179749811*f[11]+116.18950038622252*f[10]-201.2461179749811*f[7]+116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]+150.0*f[21]-259.80762113533154*f[20]-150.00000000000003*f[19]+259.80762113533166*f[18]-150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]+207.84609690826525*f[22]-120.0*f[21]+207.84609690826525*f[20]+120.00000000000001*f[19]-207.84609690826528*f[18]+120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]-58.09475019311126*f[13]+100.62305898749055*f[11]+58.09475019311126*f[10]-100.62305898749055*f[7]+58.09475019311126*f[6]-58.09475019311126*f[3])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; - if (fReflSurfXMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; + if (fReflSurfXMu[0][0]<0.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = -(0.5*(vcutsq[3]-1.0*vcutsq[2]+vcutsq[1]-1.0*vcutsq[0])); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXMu[1][0] = 0.0; + fReflSurfXMu[1][1] = 0.0; + fReflSurfXMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXMu[1][0] = -(0.3535533905932737*(1.7320508075688772*(f[12]-1.0*f[9])+f[8]+1.7320508075688772*f[5]-1.0*(f[4]+1.7320508075688772*f[2])+f[1]-1.0*f[0])); + fReflSurfXMu[1][1] = -(0.3535533905932737*(1.7320508075688772*(f[15]-1.0*f[14])+f[13]+1.7320508075688772*f[11]-1.0*(f[10]+1.7320508075688772*f[7])+f[6]-1.0*f[3])); + fReflSurfXMu[1][2] = -(0.023570226039551577*(25.98076211353316*f[23]+5.0*(-(5.196152422706631*f[22])+3.0*f[21]+5.196152422706631*f[20])+8.660254037844387*(1.7320508075688772*f[17]-1.0*(1.7320508075688772*f[19]+3.0*f[18]))-15.0*f[16])); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = -0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.41640786499874*f[8]+23.2379000772445*f[5]-13.41640786499874*f[4]-23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.41640786499874*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]-13.41640786499874*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[1][1] = -0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]-11.61895003862225*f[19]-20.1246117974981*f[18]+11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]+13.85640646055102*f[11]-8.0*f[10]-13.85640646055102*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]-7.745966692414834*f[21]-13.41640786499874*f[20]+7.745966692414834*f[19]+13.41640786499874*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]+6.708203932499369*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]+13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]-8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]-13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[1][2] = -0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]+270.0*f[21]+467.6537180435967*f[20]-269.9999999999999*f[19]-467.6537180435969*f[18]+269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]+174.2842505793337*f[13]+301.8691769624717*f[11]-174.2842505793337*f[10]-301.8691769624717*f[7]+174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]+300.0000000000001*f[19]+519.6152422706633*f[18]-300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]-116.1895003862225*f[13]-201.2461179749811*f[11]+116.1895003862225*f[10]+201.2461179749811*f[7]-116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]+150.0*f[21]+259.8076211353315*f[20]-150.0*f[19]-259.8076211353317*f[18]+150.0*f[17]-150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]-207.8460969082653*f[22]+120.0*f[21]+207.8460969082653*f[20]-120.0*f[19]-207.8460969082653*f[18]+120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]-58.09475019311126*f[13]-100.6230589874906*f[11]+58.09475019311126*f[10]+100.6230589874906*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[1][0] = -(0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.416407864998739*f[8]+23.2379000772445*f[5]-13.416407864998739*f[4]-23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-23.2379000772445*f[9]+13.416407864998739*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]-13.416407864998739*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[1][1] = -(0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]-11.618950038622252*f[19]-20.124611797498105*f[18]+11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]+13.856406460551018*f[11]-8.0*f[10]-13.856406460551018*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]-7.745966692414834*f[21]-13.416407864998739*f[20]+7.745966692414834*f[19]+13.416407864998737*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]+6.7082039324993685*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]+13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]-8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]-13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXMu[1][2] = -(0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]+270.0*f[21]+467.65371804359665*f[20]-269.99999999999994*f[19]-467.65371804359694*f[18]+269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]+174.28425057933373*f[13]+301.86917696247167*f[11]-174.28425057933373*f[10]-301.86917696247167*f[7]+174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]+300.00000000000006*f[19]+519.6152422706633*f[18]-300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]-116.18950038622252*f[13]-201.2461179749811*f[11]+116.18950038622252*f[10]+201.2461179749811*f[7]-116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]+150.0*f[21]+259.80762113533154*f[20]-150.00000000000003*f[19]-259.80762113533166*f[18]+150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]-207.84609690826525*f[22]+120.0*f[21]+207.84609690826525*f[20]-120.00000000000001*f[19]-207.84609690826528*f[18]+120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]-58.09475019311126*f[13]-100.62305898749055*f[11]+58.09475019311126*f[10]+100.62305898749055*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]+15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])+25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]-15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.41640786499874*f[8]+23.2379000772445*f[5]-13.41640786499874*f[4]-23.2379000772445*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.41640786499874*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]+13.41640786499874*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[1][1] = 0.02209708691207959*((20.1246117974981*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]-11.61895003862225*f[19]-20.1246117974981*f[18]+11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]-13.85640646055102*f[14]+8.0*f[13]+13.85640646055102*f[11]-8.0*f[10]-13.85640646055102*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])+13.41640786499874*f[22]-7.745966692414834*f[21]-13.41640786499874*f[20]+7.745966692414834*f[19]+13.41640786499874*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]+6.708203932499369*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]-13.85640646055102*f[15]+13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]+8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]+13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[1][2] = 0.001473139127471973*((467.6537180435969*f[23]-467.6537180435967*f[22]+270.0*f[21]+467.6537180435967*f[20]-269.9999999999999*f[19]-467.6537180435969*f[18]+269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]-301.8691769624717*f[14]+174.2842505793337*f[13]+301.8691769624717*f[11]-174.2842505793337*f[10]-301.8691769624717*f[7]+174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]+300.0000000000001*f[19]+519.6152422706633*f[18]-300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]-232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])+201.2461179749811*f[14]-116.1895003862225*f[13]-201.2461179749811*f[11]+116.1895003862225*f[10]+201.2461179749811*f[7]-116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]-259.8076211353315*f[22]+150.0*f[21]+259.8076211353315*f[20]-150.0*f[19]-259.8076211353317*f[18]+150.0*f[17]-150.0*f[16]-232.379000772445*f[12]+232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]+207.8460969082653*f[22]-120.0*f[21]-207.8460969082653*f[20]+120.0*f[19]+207.8460969082653*f[18]-120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]+100.6230589874906*f[14]-58.09475019311126*f[13]-100.6230589874906*f[11]+58.09475019311126*f[10]+100.6230589874906*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]-25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]+15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]-20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]-11.61895003862225*f[10]-20.12461179749811*f[7]+11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])+25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]-15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]-23.2379000772445*f[9]+13.416407864998739*f[8]+23.2379000772445*f[5]-13.416407864998739*f[4]-23.2379000772445*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]+20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+23.2379000772445*f[9]-13.416407864998739*f[8]+20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]+13.416407864998739*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[1][1] = 0.022097086912079594*((20.124611797498105*f[23]-20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]-11.618950038622252*f[19]-20.124611797498105*f[18]+11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]-13.856406460551018*f[14]+8.0*f[13]+13.856406460551018*f[11]-8.0*f[10]-13.856406460551018*f[7]+8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])+13.416407864998739*f[22]-7.745966692414834*f[21]-13.416407864998739*f[20]+7.745966692414834*f[19]+13.416407864998737*f[18]-7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]-12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]-6.928203230275509*f[4]-12.0*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]+6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]+3.872983346207417*f[19]+6.7082039324993685*f[18]-3.872983346207417*f[17]+3.872983346207417*f[16]-13.856406460551018*f[15]+13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]+8.0*f[10]+12.0*f[9]-6.928203230275509*f[8]+13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]+6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXMu[1][2] = 0.001473139127471973*((467.65371804359694*f[23]-467.65371804359665*f[22]+270.0*f[21]+467.65371804359665*f[20]-269.99999999999994*f[19]-467.65371804359694*f[18]+269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]-301.86917696247167*f[14]+174.28425057933373*f[13]+301.86917696247167*f[11]-174.28425057933373*f[10]-301.86917696247167*f[7]+174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])+519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]+300.00000000000006*f[19]+519.6152422706633*f[18]-300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]-232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])+201.2461179749811*f[14]-116.18950038622252*f[13]-201.2461179749811*f[11]+116.18950038622252*f[10]+201.2461179749811*f[7]-116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]-259.80762113533154*f[22]+150.0*f[21]+259.80762113533154*f[20]-150.00000000000003*f[19]-259.80762113533166*f[18]+150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]+232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]+207.84609690826525*f[22]-120.0*f[21]-207.84609690826525*f[20]+120.00000000000001*f[19]+207.84609690826528*f[18]-120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]+100.62305898749055*f[14]-58.09475019311126*f[13]-100.62305898749055*f[11]+58.09475019311126*f[10]+100.62305898749055*f[7]-58.09475019311126*f[6]+58.09475019311126*f[3]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; - if (fReflSurfXMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; + if (fReflSurfXMu[1][0]<0.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; + } + } fReflSurfX[0][0] = 0.7071067811865475*(fReflSurfXMu[1][0]+fReflSurfXMu[0][0]); @@ -881,121 +947,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double fReflSurfX[0][4] = 0.7071067811865475*(fReflSurfXMu[1][2]+fReflSurfXMu[0][2]); fReflSurfX[0][5] = 0.7071067811865475*(fReflSurfXMu[1][2]-1.0*fReflSurfXMu[0][2]); - } - // node (x)_1 - vcutSq = 0.5*(1.732050807568877*phiWall[3]-1.732050807568877*phi[3]+1.732050807568877*phiWall[2]-1.732050807568877*phi[2]+phiWall[1]-1.0*phi[1]+phiWall[0]-1.0*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfX[1][0] = 0.0; - fReflSurfX[1][1] = 0.0; - fReflSurfX[1][2] = 0.0; - fReflSurfX[1][3] = 0.0; - fReflSurfX[1][4] = 0.0; - fReflSurfX[1][5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.5*(vcutsq[3]+vcutsq[2]-1.0*(vcutsq[1]+vcutsq[0]))); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfX[1][0] = 0.5*(1.732050807568877*(f[5]+f[2])+f[1]+f[0]); - fReflSurfX[1][1] = 0.5*(1.732050807568877*(f[11]+f[7])+f[6]+f[3]); - fReflSurfX[1][2] = 0.5*(1.732050807568877*(f[12]+f[9])+f[8]+f[4]); - fReflSurfX[1][3] = 0.5*(1.732050807568877*(f[15]+f[14])+f[13]+f[10]); - fReflSurfX[1][4] = 0.03333333333333333*(25.98076211353316*f[20]+8.660254037844387*(3.0*f[18]+1.732050807568877*f[17])+15.0*f[16]); - fReflSurfX[1][5] = 0.03333333333333333*(25.98076211353316*f[23]+8.660254037844387*(3.0*f[22]+1.732050807568877*f[21])+15.0*f[19]); + fReflSurfXMu[0][0] = 0.0; + fReflSurfXMu[0][1] = 0.0; + fReflSurfXMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXMu[0][0] = -(0.3535533905932737*(1.7320508075688772*(f[12]+f[9])+f[8]-1.7320508075688772*f[5]+f[4]-1.0*(1.7320508075688772*f[2]+f[1]+f[0]))); + fReflSurfXMu[0][1] = -(0.3535533905932737*(1.7320508075688772*(f[15]+f[14])+f[13]-1.7320508075688772*f[11]+f[10]-1.0*(1.7320508075688772*f[7]+f[6]+f[3]))); + fReflSurfXMu[0][2] = -(0.023570226039551577*(25.98076211353316*f[23]+5.0*(5.196152422706631*f[22]+3.0*f[21])+1.7320508075688772*(8.660254037844387*f[19]-15.0*f[20])-1.0*(8.660254037844387*(3.0*f[18]+1.7320508075688772*f[17])+15.0*f[16]))); - double xBar, xSqBar; - double fReflSurfXMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = -0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.41640786499874*f[8]-23.2379000772445*f[5]+13.41640786499874*f[4]-23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.41640786499874*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]+13.41640786499874*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[0][1] = -0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]+11.61895003862225*f[19]-20.1246117974981*f[18]-11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]-13.85640646055102*f[11]+8.0*f[10]-13.85640646055102*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]-7.745966692414834*f[21]+13.41640786499874*f[20]-7.745966692414834*f[19]+13.41640786499874*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]+6.708203932499369*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]+13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]+8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]-13.85640646055102*f[7]-8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[0][2] = -0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]+270.0*f[21]-467.6537180435967*f[20]+269.9999999999999*f[19]-467.6537180435969*f[18]-269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]+174.2842505793337*f[13]-301.8691769624717*f[11]+174.2842505793337*f[10]-301.8691769624717*f[7]-174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]-300.0000000000001*f[19]+519.6152422706633*f[18]+300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]-116.1895003862225*f[13]+201.2461179749811*f[11]-116.1895003862225*f[10]+201.2461179749811*f[7]+116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]+150.0*f[21]-259.8076211353315*f[20]+150.0*f[19]-259.8076211353317*f[18]-150.0*f[17]-150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]+207.8460969082653*f[22]+120.0*f[21]-207.8460969082653*f[20]+120.0*f[19]-207.8460969082653*f[18]-120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]-58.09475019311126*f[13]+100.6230589874906*f[11]-58.09475019311126*f[10]+100.6230589874906*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[0][0] = -(0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.416407864998739*f[8]-23.2379000772445*f[5]+13.416407864998739*f[4]-23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.416407864998739*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]-23.2379000772445*f[5]+13.416407864998739*f[4]+11.61895003862225*f[3]-23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[0][1] = -(0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]+11.618950038622252*f[19]-20.124611797498105*f[18]-11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]-13.856406460551018*f[11]+8.0*f[10]-13.856406460551018*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]-7.745966692414834*f[21]+13.416407864998739*f[20]-7.745966692414834*f[19]+13.416407864998737*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]+6.7082039324993685*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]+13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]+8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]-13.856406460551018*f[7]-8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXMu[0][2] = -(0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]+270.0*f[21]-467.65371804359665*f[20]+269.99999999999994*f[19]-467.65371804359694*f[18]-269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]+174.28425057933373*f[13]-301.86917696247167*f[11]+174.28425057933373*f[10]-301.86917696247167*f[7]-174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]-300.00000000000006*f[19]+519.6152422706633*f[18]+300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]-116.18950038622252*f[13]+201.2461179749811*f[11]-116.18950038622252*f[10]+201.2461179749811*f[7]+116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]+150.0*f[21]-259.80762113533154*f[20]+150.00000000000003*f[19]-259.80762113533166*f[18]-150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]+207.84609690826525*f[22]+120.0*f[21]-207.84609690826525*f[20]+120.00000000000001*f[19]-207.84609690826528*f[18]-120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]-58.09475019311126*f[13]+100.62305898749055*f[11]-58.09475019311126*f[10]+100.62305898749055*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]+15.0*f[21]-25.98076211353316*f[20]+15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]-15.0*f[21]+25.98076211353316*f[20]-15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.41640786499874*f[8]-23.2379000772445*f[5]+13.41640786499874*f[4]-23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.41640786499874*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]-13.41640786499874*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[0][1] = 0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]+11.61895003862225*f[19]-20.1246117974981*f[18]-11.61895003862225*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]-13.85640646055102*f[11]+8.0*f[10]-13.85640646055102*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]-7.745966692414834*f[21]+13.41640786499874*f[20]-7.745966692414834*f[19]+13.41640786499874*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]+6.708203932499369*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]-13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]-8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]+13.85640646055102*f[7]+8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXMu[0][2] = 0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]+270.0*f[21]-467.6537180435967*f[20]+269.9999999999999*f[19]-467.6537180435969*f[18]-269.9999999999999*f[17]-270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]+174.2842505793337*f[13]-301.8691769624717*f[11]+174.2842505793337*f[10]-301.8691769624717*f[7]-174.2842505793337*f[6]-174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]-300.0000000000001*f[19]+519.6152422706633*f[18]+300.0000000000001*f[17]+300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]-232.379000772445*f[5]+134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]-116.1895003862225*f[13]+201.2461179749811*f[11]-116.1895003862225*f[10]+201.2461179749811*f[7]+116.1895003862225*f[6]+116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]+150.0*f[21]-259.8076211353315*f[20]+150.0*f[19]-259.8076211353317*f[18]-150.0*f[17]-150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]+232.379000772445*f[5]-134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]-207.8460969082653*f[22]-120.0*f[21]+207.8460969082653*f[20]-120.0*f[19]+207.8460969082653*f[18]+120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]-58.09475019311126*f[13]+100.6230589874906*f[11]-58.09475019311126*f[10]+100.6230589874906*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3]); + fReflSurfXMu[0][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]+15.0*f[21]-25.980762113533157*f[20]+15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]-20.12461179749811*f[11]+11.61895003862225*f[10]-20.12461179749811*f[7]-11.61895003862225*f[6]-11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]-15.0*f[21]+25.980762113533157*f[20]-15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.416407864998739*f[8]-23.2379000772445*f[5]+13.416407864998739*f[4]-23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.416407864998739*f[8]+20.12461179749811*f[7]+11.61895003862225*f[6]+23.2379000772445*f[5]-13.416407864998739*f[4]+11.61895003862225*f[3]+23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[0][1] = 0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]-20.12461179749811*f[20]+11.618950038622252*f[19]-20.124611797498105*f[18]-11.618950038622252*f[17]-11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]-13.856406460551018*f[11]+8.0*f[10]-13.856406460551018*f[7]-8.0*f[6]-8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]-7.745966692414834*f[21]+13.416407864998739*f[20]-7.745966692414834*f[19]+13.416407864998737*f[18]+7.745966692414834*f[17]+7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]-12.0*f[5]+6.928203230275509*f[4]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]+6.708203932499369*f[20]-3.872983346207417*f[19]+6.7082039324993685*f[18]+3.872983346207417*f[17]+3.872983346207417*f[16]-13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]-8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]+13.856406460551018*f[7]+8.0*f[6]+12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXMu[0][2] = 0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]+270.0*f[21]-467.65371804359665*f[20]+269.99999999999994*f[19]-467.65371804359694*f[18]-269.99999999999994*f[17]-270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]+174.28425057933373*f[13]-301.86917696247167*f[11]+174.28425057933373*f[10]-301.86917696247167*f[7]-174.28425057933373*f[6]-174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]+519.6152422706631*f[20]-300.00000000000006*f[19]+519.6152422706633*f[18]+300.00000000000006*f[17]+300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]-232.37900077244504*f[5]+134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]-116.18950038622252*f[13]+201.2461179749811*f[11]-116.18950038622252*f[10]+201.2461179749811*f[7]+116.18950038622252*f[6]+116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]+150.0*f[21]-259.80762113533154*f[20]+150.00000000000003*f[19]-259.80762113533166*f[18]-150.00000000000003*f[17]-150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]+232.37900077244504*f[5]-134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]-207.84609690826525*f[22]-120.0*f[21]+207.84609690826525*f[20]-120.00000000000001*f[19]+207.84609690826528*f[18]+120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]-58.09475019311126*f[13]+100.62305898749055*f[11]-58.09475019311126*f[10]+100.62305898749055*f[7]+58.09475019311126*f[6]+58.09475019311126*f[3]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; - if (fReflSurfXMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[0][1])/fReflSurfXMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[0][2]+5.0*fReflSurfXMu[0][0]))/fReflSurfXMu[0][0]; + if (fReflSurfXMu[0][0]<0.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[0][0] = 0.0; fReflSurfXMu[0][1] = 0.0; fReflSurfXMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = 0.5*(vcutsq[3]+vcutsq[2]+vcutsq[1]+vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXMu[1][0] = 0.0; + fReflSurfXMu[1][1] = 0.0; + fReflSurfXMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXMu[1][0] = 0.3535533905932737*(1.7320508075688772*(f[12]+f[9])+f[8]+1.7320508075688772*f[5]+f[4]+1.7320508075688772*f[2]+f[1]+f[0]); + fReflSurfXMu[1][1] = 0.3535533905932737*(1.7320508075688772*(f[15]+f[14])+f[13]+1.7320508075688772*f[11]+f[10]+1.7320508075688772*f[7]+f[6]+f[3]); + fReflSurfXMu[1][2] = 0.023570226039551577*(25.98076211353316*f[23]+5.0*(5.196152422706631*f[22]+3.0*f[21]+5.196152422706631*f[20])+8.660254037844387*(1.7320508075688772*f[19]+3.0*f[18]+1.7320508075688772*f[17])+15.0*f[16]); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.41640786499874*f[8]+23.2379000772445*f[5]+13.41640786499874*f[4]+23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.41640786499874*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]+13.41640786499874*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXMu[1][1] = 0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]+11.61895003862225*f[19]+20.1246117974981*f[18]+11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]+13.85640646055102*f[11]+8.0*f[10]+13.85640646055102*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]-7.745966692414834*f[21]-13.41640786499874*f[20]-7.745966692414834*f[19]-13.41640786499874*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]-6.708203932499369*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]+13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]-12.0*f[12]+13.85640646055102*f[11]+8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]+13.85640646055102*f[7]+8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[1][2] = 0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]+270.0*f[21]+467.6537180435967*f[20]+269.9999999999999*f[19]+467.6537180435969*f[18]+269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]+174.2842505793337*f[13]+301.8691769624717*f[11]+174.2842505793337*f[10]+301.8691769624717*f[7]+174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]-300.0000000000001*f[19]-519.6152422706633*f[18]-300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]-116.1895003862225*f[13]-201.2461179749811*f[11]-116.1895003862225*f[10]-201.2461179749811*f[7]-116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]+150.0*f[21]+259.8076211353315*f[20]+150.0*f[19]+259.8076211353317*f[18]+150.0*f[17]+150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[23]+207.8460969082653*f[22]+120.0*f[21]+207.8460969082653*f[20]+120.0*f[19]+207.8460969082653*f[18]+120.0*f[17]+120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]-58.09475019311126*f[13]-100.6230589874906*f[11]-58.09475019311126*f[10]-100.6230589874906*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[1][0] = 0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.416407864998739*f[8]+23.2379000772445*f[5]+13.416407864998739*f[4]+23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]+23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+23.2379000772445*f[9]+13.416407864998739*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]+23.2379000772445*f[5]+13.416407864998739*f[4]-11.61895003862225*f[3]+23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXMu[1][1] = 0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]+11.618950038622252*f[19]+20.124611797498105*f[18]+11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]+13.856406460551018*f[11]+8.0*f[10]+13.856406460551018*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]-7.745966692414834*f[21]-13.416407864998739*f[20]-7.745966692414834*f[19]-13.416407864998737*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]-6.7082039324993685*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]+13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]-12.0*f[12]+13.856406460551018*f[11]+8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]+13.856406460551018*f[7]+8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]+8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXMu[1][2] = 0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]+270.0*f[21]+467.65371804359665*f[20]+269.99999999999994*f[19]+467.65371804359694*f[18]+269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]+174.28425057933373*f[13]+301.86917696247167*f[11]+174.28425057933373*f[10]+301.86917696247167*f[7]+174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]-300.00000000000006*f[19]-519.6152422706633*f[18]-300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]-116.18950038622252*f[13]-201.2461179749811*f[11]-116.18950038622252*f[10]-201.2461179749811*f[7]-116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]+150.0*f[21]+259.80762113533154*f[20]+150.00000000000003*f[19]+259.80762113533166*f[18]+150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826528*f[23]+207.84609690826525*f[22]+120.0*f[21]+207.84609690826525*f[20]+120.00000000000001*f[19]+207.84609690826528*f[18]+120.00000000000001*f[17]+120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]-58.09475019311126*f[13]-100.62305898749055*f[11]-58.09475019311126*f[10]-100.62305898749055*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXMu[1][0] = -0.01317615691736824*((25.98076211353316*f[23]+25.98076211353316*f[22]+15.0*f[21]+25.98076211353316*f[20]+15.0*f[19]+25.98076211353316*f[18]+15.0*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+((-25.98076211353316*f[23])-25.98076211353316*f[22]-15.0*f[21]-25.98076211353316*f[20]-15.0*f[19]-25.98076211353316*f[18]-15.0*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.41640786499874*f[8]+23.2379000772445*f[5]+13.41640786499874*f[4]+23.2379000772445*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.41640786499874*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]-13.41640786499874*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXMu[1][1] = -0.02209708691207959*((20.1246117974981*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]+11.61895003862225*f[19]+20.1246117974981*f[18]+11.61895003862225*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.85640646055102*f[15]+13.85640646055102*f[14]+8.0*f[13]+13.85640646055102*f[11]+8.0*f[10]+13.85640646055102*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+((-13.41640786499874*f[23])-13.41640786499874*f[22]-7.745966692414834*f[21]-13.41640786499874*f[20]-7.745966692414834*f[19]-13.41640786499874*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]-6.708203932499369*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]-13.85640646055102*f[15]-13.85640646055102*f[14]-8.0*f[13]-12.0*f[12]-13.85640646055102*f[11]-8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]-13.85640646055102*f[7]-8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXMu[1][2] = -0.001473139127471973*((467.6537180435969*f[23]+467.6537180435967*f[22]+270.0*f[21]+467.6537180435967*f[20]+269.9999999999999*f[19]+467.6537180435969*f[18]+269.9999999999999*f[17]+270.0*f[16])*vcut_lR5+(301.8691769624717*f[15]+301.8691769624717*f[14]+174.2842505793337*f[13]+301.8691769624717*f[11]+174.2842505793337*f[10]+301.8691769624717*f[7]+174.2842505793337*f[6]+174.2842505793337*f[3])*vcut_lR4+((-519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]-300.0000000000001*f[19]-519.6152422706633*f[18]-300.0000000000001*f[17]-300.0*f[16]+232.379000772445*f[12]+232.379000772445*f[9]+134.1640786499874*f[8]+232.379000772445*f[5]+134.1640786499874*f[4]+232.379000772445*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[15])-201.2461179749811*f[14]-116.1895003862225*f[13]-201.2461179749811*f[11]-116.1895003862225*f[10]-201.2461179749811*f[7]-116.1895003862225*f[6]-116.1895003862225*f[3])*vcut_lR2+(259.8076211353317*f[23]+259.8076211353315*f[22]+150.0*f[21]+259.8076211353315*f[20]+150.0*f[19]+259.8076211353317*f[18]+150.0*f[17]+150.0*f[16]-232.379000772445*f[12]-232.379000772445*f[9]-134.1640786499874*f[8]-232.379000772445*f[5]-134.1640786499874*f[4]-232.379000772445*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[23]-207.8460969082653*f[22]-120.0*f[21]-207.8460969082653*f[20]-120.0*f[19]-207.8460969082653*f[18]-120.0*f[17]-120.0*f[16]-100.6230589874906*f[15]-100.6230589874906*f[14]-58.09475019311126*f[13]-100.6230589874906*f[11]-58.09475019311126*f[10]-100.6230589874906*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3]); + fReflSurfXMu[1][0] = -(0.01317615691736824*((25.98076211353316*f[23]+25.980762113533157*f[22]+15.0*f[21]+25.980762113533157*f[20]+15.000000000000002*f[19]+25.98076211353316*f[18]+15.000000000000002*f[17]+15.0*f[16])*vcut_lR3+(20.12461179749811*f[15]+20.12461179749811*f[14]+11.61895003862225*f[13]+20.12461179749811*f[11]+11.61895003862225*f[10]+20.12461179749811*f[7]+11.61895003862225*f[6]+11.61895003862225*f[3])*vcut_lR2+(-(25.98076211353316*f[23])-25.980762113533157*f[22]-15.0*f[21]-25.980762113533157*f[20]-15.000000000000002*f[19]-25.98076211353316*f[18]-15.000000000000002*f[17]-15.0*f[16]+23.2379000772445*f[12]+23.2379000772445*f[9]+13.416407864998739*f[8]+23.2379000772445*f[5]+13.416407864998739*f[4]+23.2379000772445*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[15]-20.12461179749811*f[14]-11.61895003862225*f[13]-23.2379000772445*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-23.2379000772445*f[9]-13.416407864998739*f[8]-20.12461179749811*f[7]-11.61895003862225*f[6]-23.2379000772445*f[5]-13.416407864998739*f[4]-11.61895003862225*f[3]-23.2379000772445*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXMu[1][1] = -(0.022097086912079594*((20.124611797498105*f[23]+20.12461179749811*f[22]+11.61895003862225*f[21]+20.12461179749811*f[20]+11.618950038622252*f[19]+20.124611797498105*f[18]+11.618950038622252*f[17]+11.61895003862225*f[16])*vcut_lR4+(13.856406460551018*f[15]+13.856406460551018*f[14]+8.0*f[13]+13.856406460551018*f[11]+8.0*f[10]+13.856406460551018*f[7]+8.0*f[6]+8.0*f[3])*vcut_lR3+(-(13.416407864998737*f[23])-13.416407864998739*f[22]-7.745966692414834*f[21]-13.416407864998739*f[20]-7.745966692414834*f[19]-13.416407864998737*f[18]-7.745966692414834*f[17]-7.745966692414834*f[16]+12.0*f[12]+12.0*f[9]+6.928203230275509*f[8]+12.0*f[5]+6.928203230275509*f[4]+12.0*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.7082039324993685*f[23]-6.708203932499369*f[22]-3.872983346207417*f[21]-6.708203932499369*f[20]-3.872983346207417*f[19]-6.7082039324993685*f[18]-3.872983346207417*f[17]-3.872983346207417*f[16]-13.856406460551018*f[15]-13.856406460551018*f[14]-8.0*f[13]-12.0*f[12]-13.856406460551018*f[11]-8.0*f[10]-12.0*f[9]-6.928203230275509*f[8]-13.856406460551018*f[7]-8.0*f[6]-12.0*f[5]-6.928203230275509*f[4]-8.0*f[3]-12.0*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXMu[1][2] = -(0.001473139127471973*((467.65371804359694*f[23]+467.65371804359665*f[22]+270.0*f[21]+467.65371804359665*f[20]+269.99999999999994*f[19]+467.65371804359694*f[18]+269.99999999999994*f[17]+270.0*f[16])*vcut_lR5+(301.86917696247167*f[15]+301.86917696247167*f[14]+174.28425057933373*f[13]+301.86917696247167*f[11]+174.28425057933373*f[10]+301.86917696247167*f[7]+174.28425057933373*f[6]+174.28425057933373*f[3])*vcut_lR4+(-(519.6152422706633*f[23])-519.6152422706631*f[22]-300.0*f[21]-519.6152422706631*f[20]-300.00000000000006*f[19]-519.6152422706633*f[18]-300.00000000000006*f[17]-300.0*f[16]+232.37900077244504*f[12]+232.37900077244504*f[9]+134.1640786499874*f[8]+232.37900077244504*f[5]+134.1640786499874*f[4]+232.37900077244504*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[15])-201.2461179749811*f[14]-116.18950038622252*f[13]-201.2461179749811*f[11]-116.18950038622252*f[10]-201.2461179749811*f[7]-116.18950038622252*f[6]-116.18950038622252*f[3])*vcut_lR2+(259.80762113533166*f[23]+259.80762113533154*f[22]+150.0*f[21]+259.80762113533154*f[20]+150.00000000000003*f[19]+259.80762113533166*f[18]+150.00000000000003*f[17]+150.0*f[16]-232.37900077244504*f[12]-232.37900077244504*f[9]-134.1640786499874*f[8]-232.37900077244504*f[5]-134.1640786499874*f[4]-232.37900077244504*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826528*f[23]-207.84609690826525*f[22]-120.0*f[21]-207.84609690826525*f[20]-120.00000000000001*f[19]-207.84609690826528*f[18]-120.00000000000001*f[17]-120.0*f[16]-100.62305898749055*f[15]-100.62305898749055*f[14]-58.09475019311126*f[13]-100.62305898749055*f[11]-58.09475019311126*f[10]-100.62305898749055*f[7]-58.09475019311126*f[6]-58.09475019311126*f[3])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; - if (fReflSurfXMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXMu[1][1])/fReflSurfXMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXMu[1][2]+5.0*fReflSurfXMu[1][0]))/fReflSurfXMu[1][0]; + if (fReflSurfXMu[1][0]<0.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXMu[1][0] = 0.0; fReflSurfXMu[1][1] = 0.0; fReflSurfXMu[1][2] = 0.0; + } + } fReflSurfX[1][0] = 0.7071067811865475*(fReflSurfXMu[1][0]+fReflSurfXMu[0][0]); @@ -1005,8 +1081,6 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double fReflSurfX[1][4] = 0.7071067811865475*(fReflSurfXMu[1][2]+fReflSurfXMu[0][2]); fReflSurfX[1][5] = 0.7071067811865475*(fReflSurfXMu[1][2]-1.0*fReflSurfXMu[0][2]); - } - fRefl[0] = fReflSurfX[1][0]+fReflSurfX[0][0]; fRefl[1] = fReflSurfX[1][0]-1.0*fReflSurfX[0][0]; fRefl[2] = 0.0; @@ -1024,18 +1098,18 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double fRefl[14] = 0.0; fRefl[15] = 0.0; fRefl[16] = fReflSurfX[1][4]+fReflSurfX[0][4]; - fRefl[17] = 1.0*(fReflSurfX[1][4]-1.0*fReflSurfX[0][4]); + fRefl[17] = 1.0000000000000002*(fReflSurfX[1][4]-1.0*fReflSurfX[0][4]); fRefl[18] = 0.0; fRefl[19] = fReflSurfX[1][5]+fReflSurfX[0][5]; fRefl[20] = 0.0; - fRefl[21] = 1.0*(fReflSurfX[1][5]-1.0*fReflSurfX[0][5]); + fRefl[21] = 1.0000000000000002*(fReflSurfX[1][5]-1.0*fReflSurfX[0][5]); fRefl[22] = 0.0; fRefl[23] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double *vmap, double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; + double vcutsq_n; double fReflSurfXY[4][6] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; double vparUp = 1.224744871391589*vmap[1]+0.7071067811865475*vmap[0]; @@ -1043,119 +1117,136 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; + double wv; + double dv; + double xBar, xSqBar; + double fReflSurfXYMu[2][3] = {0.}; + // node (x,y)_0 - vcutSq = -0.25*(2.449489742783178*phiWall[7]-2.449489742783178*(phi[7]+phiWall[6])+2.449489742783178*phi[6]-2.449489742783178*phiWall[5]+2.449489742783178*phi[5]-1.414213562373095*phiWall[4]+1.414213562373095*phi[4]+2.449489742783178*phiWall[3]-2.449489742783178*phi[3]+1.414213562373095*phiWall[2]-1.414213562373095*phi[2]+1.414213562373095*phiWall[1]-1.414213562373095*(phi[1]+phiWall[0])+1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[0][0] = 0.0; - fReflSurfXY[0][1] = 0.0; - fReflSurfXY[0][2] = 0.0; - fReflSurfXY[0][3] = 0.0; - fReflSurfXY[0][4] = 0.0; - fReflSurfXY[0][5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*(vcutsq[6]+vcutsq[5]+vcutsq[4])+1.4142135623730951*(vcutsq[3]+vcutsq[2]+vcutsq[1])-1.4142135623730951*vcutsq[0])); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[0][0] = -0.3535533905932737*(1.732050807568877*f[16]-1.0*(1.732050807568877*(f[8]+f[7])+f[6])+1.732050807568877*f[3]+f[2]+f[1]-1.0*f[0]); - fReflSurfXY[0][1] = -0.3535533905932737*(1.732050807568877*f[26]-1.0*(1.732050807568877*(f[19]+f[18])+f[17])+1.732050807568877*f[11]+f[10]+f[9]-1.0*f[4]); - fReflSurfXY[0][2] = -0.3535533905932737*(1.732050807568877*f[27]-1.0*(1.732050807568877*(f[22]+f[21])+f[20])+1.732050807568877*f[14]+f[13]+f[12]-1.0*f[5]); - fReflSurfXY[0][3] = -0.3535533905932737*(1.732050807568877*f[31]-1.0*(1.732050807568877*(f[30]+f[29])+f[28])+1.732050807568877*f[25]+f[24]+f[23]-1.0*f[15]); - fReflSurfXY[0][4] = -0.02357022603955158*(25.98076211353316*f[43]-5.0*(5.196152422706631*(f[39]+f[38])+3.0*f[37])+8.660254037844387*(3.0*f[35]+1.732050807568877*(f[34]+f[33]))-15.0*f[32]); - fReflSurfXY[0][5] = -0.02357022603955158*(25.98076211353316*f[47]-5.0*(5.196152422706631*(f[46]+f[45])+3.0*f[44])+8.660254037844387*(3.0*f[42]+1.732050807568877*(f[41]+f[40]))-15.0*f[36]); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = 0.25*(1.7320508075688772*f[27]-1.0*(1.7320508075688772*(f[22]+f[21])+f[20])+1.7320508075688772*(f[14]-1.0*f[16])+f[13]+f[12]+1.7320508075688772*(f[8]+f[7])+f[6]-1.0*(f[5]+1.7320508075688772*f[3]+f[2]+f[1])+f[0]); + fReflSurfXYMu[0][1] = 0.25*(1.7320508075688772*f[31]-1.0*(1.7320508075688772*(f[30]+f[29])+f[28])+1.7320508075688772*(f[25]-1.0*f[26])+f[24]+f[23]+1.7320508075688772*(f[19]+f[18])+f[17]-1.0*(f[15]+1.7320508075688772*f[11]+f[10]+f[9])+f[4]); + fReflSurfXYMu[0][2] = 0.016666666666666666*(25.980762113533157*f[47]-8.660254037844387*(3.0*(f[46]+f[45])+1.7320508075688772*f[44]+3.0*f[43])+5.0*(5.196152422706631*f[42]+3.0*(f[41]+f[40])+5.196152422706631*(f[39]+f[38])+3.0*f[37])-8.660254037844387*(1.7320508075688772*f[36]+3.0*f[35]+1.7320508075688772*(f[34]+f[33]))+15.0*f[32]); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = 0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*(vcutsq[6]+vcutsq[5])+1.4142135623730951*(vcutsq[4]+vcutsq[3])-1.4142135623730951*(vcutsq[2]+vcutsq[1])+1.4142135623730951*vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = -(0.25*(1.7320508075688772*f[27]-1.0*(1.7320508075688772*(f[22]+f[21])+f[20])+1.7320508075688772*(f[16]+f[14])+f[13]+f[12]-1.0*(1.7320508075688772*(f[8]+f[7])+f[6]+f[5])+1.7320508075688772*f[3]+f[2]+f[1]-1.0*f[0])); + fReflSurfXYMu[1][1] = -(0.25*(1.7320508075688772*f[31]-1.0*(1.7320508075688772*(f[30]+f[29])+f[28])+1.7320508075688772*(f[26]+f[25])+f[24]+f[23]-1.0*(1.7320508075688772*(f[19]+f[18])+f[17]+f[15])+1.7320508075688772*f[11]+f[10]+f[9]-1.0*f[4])); + fReflSurfXYMu[1][2] = -(0.016666666666666666*(25.980762113533157*f[47]-8.660254037844387*(3.0*(f[46]+f[45])+1.7320508075688772*f[44]-3.0*f[43])+5.0*(5.196152422706631*f[42]+3.0*(f[41]+f[40])-1.0*(5.196152422706631*(f[39]+f[38])+3.0*f[37]))+8.660254037844387*(-(1.7320508075688772*f[36])+3.0*f[35]+1.7320508075688772*(f[34]+f[33]))-15.0*f[32])); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[0][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1165,121 +1256,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double fReflSurfXY[0][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[0][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - // node (x,y)_1 - vcutSq = 0.25*(2.449489742783178*phiWall[7]-2.449489742783178*(phi[7]+phiWall[6])+2.449489742783178*(phi[6]+phiWall[5])-2.449489742783178*phi[5]-1.414213562373095*phiWall[4]+1.414213562373095*phi[4]-2.449489742783178*phiWall[3]+2.449489742783178*phi[3]+1.414213562373095*phiWall[2]-1.414213562373095*(phi[2]+phiWall[1])+1.414213562373095*(phi[1]+phiWall[0])-1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[1][0] = 0.0; - fReflSurfXY[1][1] = 0.0; - fReflSurfXY[1][2] = 0.0; - fReflSurfXY[1][3] = 0.0; - fReflSurfXY[1][4] = 0.0; - fReflSurfXY[1][5] = 0.0; + // node (mu)_0 + vcutsq_n = 0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*vcutsq[6]+1.4142135623730951*vcutsq[5]-1.4142135623730951*(vcutsq[4]+vcutsq[3])+1.4142135623730951*vcutsq[2]-1.4142135623730951*vcutsq[1]+1.4142135623730951*vcutsq[0]); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[1][0] = 0.3535533905932737*(1.732050807568877*(f[16]-1.0*f[8]+f[7])-1.0*(f[6]+1.732050807568877*f[3])+f[2]-1.0*f[1]+f[0]); - fReflSurfXY[1][1] = 0.3535533905932737*(1.732050807568877*(f[26]-1.0*f[19]+f[18])-1.0*(f[17]+1.732050807568877*f[11])+f[10]-1.0*f[9]+f[4]); - fReflSurfXY[1][2] = 0.3535533905932737*(1.732050807568877*(f[27]-1.0*f[22]+f[21])-1.0*(f[20]+1.732050807568877*f[14])+f[13]-1.0*f[12]+f[5]); - fReflSurfXY[1][3] = 0.3535533905932737*(1.732050807568877*(f[31]-1.0*f[30]+f[29])-1.0*(f[28]+1.732050807568877*f[25])+f[24]-1.0*f[23]+f[15]); - fReflSurfXY[1][4] = 0.02357022603955158*(25.98076211353316*f[43]+5.0*(5.196152422706631*(f[38]-1.0*f[39])-3.0*f[37])+8.660254037844387*(1.732050807568877*(f[34]-1.0*f[33])-3.0*f[35])+15.0*f[32]); - fReflSurfXY[1][5] = 0.02357022603955158*(25.98076211353316*f[47]+5.0*(5.196152422706631*(f[45]-1.0*f[46])-3.0*f[44])+8.660254037844387*(1.732050807568877*(f[41]-1.0*f[40])-3.0*f[42])+15.0*f[36]); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = -(0.25*(1.7320508075688772*(f[27]-1.0*f[22]+f[21])-1.0*(f[20]+1.7320508075688772*(f[16]+f[14]))+f[13]-1.0*f[12]+1.7320508075688772*(f[8]-1.0*f[7])+f[6]+f[5]+1.7320508075688772*f[3]-1.0*f[2]+f[1]-1.0*f[0])); + fReflSurfXYMu[0][1] = -(0.25*(1.7320508075688772*(f[31]-1.0*f[30]+f[29])-1.0*(f[28]+1.7320508075688772*(f[26]+f[25]))+f[24]-1.0*f[23]+1.7320508075688772*(f[19]-1.0*f[18])+f[17]+f[15]+1.7320508075688772*f[11]-1.0*f[10]+f[9]-1.0*f[4])); + fReflSurfXYMu[0][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[45]-1.0*f[46])-1.0*(1.7320508075688772*f[44]+3.0*f[43]))+5.0*(-(5.196152422706631*f[42])+3.0*(f[41]-1.0*f[40])+5.196152422706631*(f[39]-1.0*f[38])+3.0*f[37])+8.660254037844387*(1.7320508075688772*f[36]+3.0*f[35]+1.7320508075688772*(f[33]-1.0*f[34]))-15.0*f[32])); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = -(0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*vcutsq[6]+1.4142135623730951*(vcutsq[5]+vcutsq[4])-1.4142135623730951*(vcutsq[3]+vcutsq[2])+1.4142135623730951*vcutsq[1]-1.4142135623730951*vcutsq[0])); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = 0.25*(1.7320508075688772*(f[27]-1.0*f[22]+f[21])-1.0*f[20]+1.7320508075688772*(f[16]-1.0*f[14])+f[13]-1.0*f[12]+1.7320508075688772*(f[7]-1.0*f[8])-1.0*f[6]+f[5]-1.7320508075688772*f[3]+f[2]-1.0*f[1]+f[0]); + fReflSurfXYMu[1][1] = 0.25*(1.7320508075688772*(f[31]-1.0*f[30]+f[29])-1.0*f[28]+1.7320508075688772*(f[26]-1.0*f[25])+f[24]-1.0*f[23]+1.7320508075688772*(f[18]-1.0*f[19])-1.0*f[17]+f[15]-1.7320508075688772*f[11]+f[10]-1.0*f[9]+f[4]); + fReflSurfXYMu[1][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[45]-1.0*f[46])-1.7320508075688772*f[44]+3.0*f[43])+5.0*(-(5.196152422706631*f[42])+3.0*(f[41]-1.0*f[40])+5.196152422706631*(f[38]-1.0*f[39])-3.0*f[37])+8.660254037844387*(1.7320508075688772*f[36]-3.0*f[35]+1.7320508075688772*(f[34]-1.0*f[33]))+15.0*f[32]); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[1][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1289,121 +1390,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double fReflSurfXY[1][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[1][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - // node (x,y)_2 - vcutSq = 0.25*(2.449489742783178*phiWall[7]-2.449489742783178*phi[7]+2.449489742783178*phiWall[6]-2.449489742783178*(phi[6]+phiWall[5])+2.449489742783178*phi[5]-1.414213562373095*phiWall[4]+1.414213562373095*phi[4]-2.449489742783178*phiWall[3]+2.449489742783178*phi[3]-1.414213562373095*phiWall[2]+1.414213562373095*(phi[2]+phiWall[1])-1.414213562373095*phi[1]+1.414213562373095*phiWall[0]-1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[2][0] = 0.0; - fReflSurfXY[2][1] = 0.0; - fReflSurfXY[2][2] = 0.0; - fReflSurfXY[2][3] = 0.0; - fReflSurfXY[2][4] = 0.0; - fReflSurfXY[2][5] = 0.0; + // node (mu)_0 + vcutsq_n = 0.25*(1.4142135623730951*(vcutsq[7]+vcutsq[6])-1.4142135623730951*(vcutsq[5]+vcutsq[4]+vcutsq[3]+vcutsq[2])+1.4142135623730951*(vcutsq[1]+vcutsq[0])); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[2][0] = 0.3535533905932737*(1.732050807568877*(f[16]+f[8])-1.0*(1.732050807568877*f[7]+f[6]+1.732050807568877*f[3]+f[2])+f[1]+f[0]); - fReflSurfXY[2][1] = 0.3535533905932737*(1.732050807568877*(f[26]+f[19])-1.0*(1.732050807568877*f[18]+f[17]+1.732050807568877*f[11]+f[10])+f[9]+f[4]); - fReflSurfXY[2][2] = 0.3535533905932737*(1.732050807568877*(f[27]+f[22])-1.0*(1.732050807568877*f[21]+f[20]+1.732050807568877*f[14]+f[13])+f[12]+f[5]); - fReflSurfXY[2][3] = 0.3535533905932737*(1.732050807568877*(f[31]+f[30])-1.0*(1.732050807568877*f[29]+f[28]+1.732050807568877*f[25]+f[24])+f[23]+f[15]); - fReflSurfXY[2][4] = 0.02357022603955158*(25.98076211353316*f[43]+5.0*(5.196152422706631*f[39]-1.0*(5.196152422706631*f[38]+3.0*f[37]))+8.660254037844387*(1.732050807568877*(f[33]-1.0*f[34])-3.0*f[35])+15.0*f[32]); - fReflSurfXY[2][5] = 0.02357022603955158*(25.98076211353316*f[47]+5.0*(5.196152422706631*f[46]-1.0*(5.196152422706631*f[45]+3.0*f[44]))+8.660254037844387*(1.732050807568877*(f[40]-1.0*f[41])-3.0*f[42])+15.0*f[36]); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = -(0.25*(1.7320508075688772*(f[27]+f[22])-1.0*(1.7320508075688772*f[21]+f[20]+1.7320508075688772*(f[16]+f[14])+f[13])+f[12]+1.7320508075688772*(f[7]-1.0*f[8])+f[6]+f[5]+1.7320508075688772*f[3]+f[2]-1.0*(f[1]+f[0]))); + fReflSurfXYMu[0][1] = -(0.25*(1.7320508075688772*(f[31]+f[30])-1.0*(1.7320508075688772*f[29]+f[28]+1.7320508075688772*(f[26]+f[25])+f[24])+f[23]+1.7320508075688772*(f[18]-1.0*f[19])+f[17]+f[15]+1.7320508075688772*f[11]+f[10]-1.0*(f[9]+f[4]))); + fReflSurfXYMu[0][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*f[46]-1.0*(3.0*f[45]+1.7320508075688772*f[44]+3.0*f[43]))+5.0*(-(5.196152422706631*f[42])+3.0*(f[40]-1.0*f[41])+5.196152422706631*(f[38]-1.0*f[39])+3.0*f[37])+8.660254037844387*(1.7320508075688772*f[36]+3.0*f[35]+1.7320508075688772*f[34])-1.0*(15.000000000000002*f[33]+15.0*f[32]))); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = -(0.25*(1.4142135623730951*(vcutsq[7]+vcutsq[6])-1.4142135623730951*vcutsq[5]+1.4142135623730951*vcutsq[4]-1.4142135623730951*vcutsq[3]+1.4142135623730951*vcutsq[2]-1.4142135623730951*(vcutsq[1]+vcutsq[0]))); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = 0.25*(1.7320508075688772*(f[27]+f[22])-1.0*(1.7320508075688772*f[21]+f[20])+1.7320508075688772*f[16]-1.0*(1.7320508075688772*f[14]+f[13])+f[12]+1.7320508075688772*f[8]-1.0*(1.7320508075688772*f[7]+f[6])+f[5]-1.0*(1.7320508075688772*f[3]+f[2])+f[1]+f[0]); + fReflSurfXYMu[1][1] = 0.25*(1.7320508075688772*(f[31]+f[30])-1.0*(1.7320508075688772*f[29]+f[28])+1.7320508075688772*f[26]-1.0*(1.7320508075688772*f[25]+f[24])+f[23]+1.7320508075688772*f[19]-1.0*(1.7320508075688772*f[18]+f[17])+f[15]-1.0*(1.7320508075688772*f[11]+f[10])+f[9]+f[4]); + fReflSurfXYMu[1][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*f[46]-1.0*(3.0*f[45]+1.7320508075688772*f[44]-3.0*f[43]))+5.0*(-(5.196152422706631*f[42])+3.0*(f[40]-1.0*f[41])+5.196152422706631*f[39]-1.0*(5.196152422706631*f[38]+3.0*f[37]))+8.660254037844387*(1.7320508075688772*f[36]-3.0*f[35]+1.7320508075688772*(f[33]-1.0*f[34]))+15.0*f[32]); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[2][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1413,121 +1524,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double fReflSurfXY[2][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[2][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - // node (x,y)_3 - vcutSq = -0.25*(2.449489742783178*phiWall[7]-2.449489742783178*phi[7]+2.449489742783178*phiWall[6]-2.449489742783178*phi[6]+2.449489742783178*phiWall[5]-2.449489742783178*phi[5]-1.414213562373095*phiWall[4]+1.414213562373095*phi[4]+2.449489742783178*phiWall[3]-2.449489742783178*phi[3]-1.414213562373095*phiWall[2]+1.414213562373095*phi[2]-1.414213562373095*phiWall[1]+1.414213562373095*phi[1]-1.414213562373095*phiWall[0]+1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[3][0] = 0.0; - fReflSurfXY[3][1] = 0.0; - fReflSurfXY[3][2] = 0.0; - fReflSurfXY[3][3] = 0.0; - fReflSurfXY[3][4] = 0.0; - fReflSurfXY[3][5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.25*(1.4142135623730951*(vcutsq[7]+vcutsq[6]+vcutsq[5])-1.4142135623730951*vcutsq[4]+1.4142135623730951*vcutsq[3]-1.4142135623730951*(vcutsq[2]+vcutsq[1]+vcutsq[0]))); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[3][0] = -0.3535533905932737*(1.732050807568877*(f[16]+f[8]+f[7])-1.0*f[6]+1.732050807568877*f[3]-1.0*(f[2]+f[1]+f[0])); - fReflSurfXY[3][1] = -0.3535533905932737*(1.732050807568877*(f[26]+f[19]+f[18])-1.0*f[17]+1.732050807568877*f[11]-1.0*(f[10]+f[9]+f[4])); - fReflSurfXY[3][2] = -0.3535533905932737*(1.732050807568877*(f[27]+f[22]+f[21])-1.0*f[20]+1.732050807568877*f[14]-1.0*(f[13]+f[12]+f[5])); - fReflSurfXY[3][3] = -0.3535533905932737*(1.732050807568877*(f[31]+f[30]+f[29])-1.0*f[28]+1.732050807568877*f[25]-1.0*(f[24]+f[23]+f[15])); - fReflSurfXY[3][4] = -0.02357022603955158*(25.98076211353316*f[43]+25.98076211353316*(f[39]+f[38])+3.0*(8.660254037844387*f[35]-5.0*f[37])-1.0*(15.0*(f[34]+f[33])+15.0*f[32])); - fReflSurfXY[3][5] = -0.02357022603955158*(25.98076211353316*f[47]+25.98076211353316*(f[46]+f[45])+3.0*(8.660254037844387*f[42]-5.0*f[44])-1.0*(15.0*(f[41]+f[40])+15.0*f[36])); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = 0.25*(1.7320508075688772*(f[27]+f[22]+f[21])-1.0*f[20]+1.7320508075688772*(f[14]-1.0*f[16])-1.0*(f[13]+f[12]+1.7320508075688772*(f[8]+f[7]))+f[6]-1.0*(f[5]+1.7320508075688772*f[3])+f[2]+f[1]+f[0]); + fReflSurfXYMu[0][1] = 0.25*(1.7320508075688772*(f[31]+f[30]+f[29])-1.0*f[28]+1.7320508075688772*(f[25]-1.0*f[26])-1.0*(f[24]+f[23]+1.7320508075688772*(f[19]+f[18]))+f[17]-1.0*(f[15]+1.7320508075688772*f[11])+f[10]+f[9]+f[4]); + fReflSurfXYMu[0][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[46]+f[45])-1.0*(1.7320508075688772*f[44]+3.0*f[43]))+5.0*(5.196152422706631*f[42]-1.0*(3.0*(f[41]+f[40])+5.196152422706631*(f[39]+f[38])-3.0*f[37]))+8.660254037844387*(1.7320508075688772*(f[34]+f[33])-1.0*(1.7320508075688772*f[36]+3.0*f[35]))+15.0*f[32]); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = 0.3535533905932738*(vcutsq[7]+vcutsq[6]+vcutsq[5]+vcutsq[4]+vcutsq[3]+vcutsq[2]+vcutsq[1]+vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = -(0.25*(1.7320508075688772*(f[27]+f[22]+f[21])-1.0*f[20]+1.7320508075688772*(f[16]+f[14])-1.0*(f[13]+f[12])+1.7320508075688772*(f[8]+f[7])-1.0*(f[6]+f[5])+1.7320508075688772*f[3]-1.0*(f[2]+f[1]+f[0]))); + fReflSurfXYMu[1][1] = -(0.25*(1.7320508075688772*(f[31]+f[30]+f[29])-1.0*f[28]+1.7320508075688772*(f[26]+f[25])-1.0*(f[24]+f[23])+1.7320508075688772*(f[19]+f[18])-1.0*(f[17]+f[15])+1.7320508075688772*f[11]-1.0*(f[10]+f[9]+f[4]))); + fReflSurfXYMu[1][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[46]+f[45])-1.7320508075688772*f[44]+3.0*f[43])+5.0*(5.196152422706631*f[42]-3.0*(f[41]+f[40])+5.196152422706631*(f[39]+f[38])-3.0*f[37])+8.660254037844387*(3.0*f[35]-1.7320508075688772*f[36])-1.0*(15.000000000000002*(f[34]+f[33])+15.0*f[32]))); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]-11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]+7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]+3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]-269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]-174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]-150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]+58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]-11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]+7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]+3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]-269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]-174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]+300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]+116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]-150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]+58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[3][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1537,8 +1658,6 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double fReflSurfXY[3][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[3][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - fRefl[0] = 0.7071067811865475*(fReflSurfXY[3][0]+fReflSurfXY[2][0]+fReflSurfXY[1][0]+fReflSurfXY[0][0]); fRefl[1] = 0.7071067811865475*(fReflSurfXY[3][0]+fReflSurfXY[2][0]-1.0*(fReflSurfXY[1][0]+fReflSurfXY[0][0])); fRefl[2] = 0.7071067811865475*(fReflSurfXY[3][0]-1.0*fReflSurfXY[2][0]+fReflSurfXY[1][0]-1.0*fReflSurfXY[0][0]); @@ -1589,9 +1708,9 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double fRefl[47] = 0.0; } -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double *vmap, double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl) +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl) { - double vcutSq; + double vcutsq_n; double fReflSurfXY[4][6] = {0.}; double vparLo = 0.7071067811865475*vmap[0]-1.224744871391589*vmap[1]; double vparUp = 1.224744871391589*vmap[1]+0.7071067811865475*vmap[0]; @@ -1599,119 +1718,136 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double double vparAbsSqLo = vmap[0]>0.? vparLo*vparLo : vparUp*vparUp; double vparAbsSqUp = vmap[0]>0.? vparUp*vparUp : vparLo*vparLo; + double wv; + double dv; + double xBar, xSqBar; + double fReflSurfXYMu[2][3] = {0.}; + // node (x,y)_0 - vcutSq = 0.25*(2.449489742783178*phiWall[7]-2.449489742783178*(phi[7]+phiWall[6])+2.449489742783178*phi[6]-2.449489742783178*phiWall[5]+2.449489742783178*phi[5]+1.414213562373095*phiWall[4]-1.414213562373095*phi[4]+2.449489742783178*phiWall[3]-2.449489742783178*phi[3]-1.414213562373095*phiWall[2]+1.414213562373095*phi[2]-1.414213562373095*phiWall[1]+1.414213562373095*(phi[1]+phiWall[0])-1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[0][0] = 0.0; - fReflSurfXY[0][1] = 0.0; - fReflSurfXY[0][2] = 0.0; - fReflSurfXY[0][3] = 0.0; - fReflSurfXY[0][4] = 0.0; - fReflSurfXY[0][5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*(vcutsq[6]+vcutsq[5]+vcutsq[4])+1.4142135623730951*(vcutsq[3]+vcutsq[2]+vcutsq[1])-1.4142135623730951*vcutsq[0])); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[0][0] = 0.3535533905932737*(1.732050807568877*(f[16]-1.0*(f[8]+f[7]))+f[6]+1.732050807568877*f[3]-1.0*(f[2]+f[1])+f[0]); - fReflSurfXY[0][1] = 0.3535533905932737*(1.732050807568877*(f[26]-1.0*(f[19]+f[18]))+f[17]+1.732050807568877*f[11]-1.0*(f[10]+f[9])+f[4]); - fReflSurfXY[0][2] = 0.3535533905932737*(1.732050807568877*(f[27]-1.0*(f[22]+f[21]))+f[20]+1.732050807568877*f[14]-1.0*(f[13]+f[12])+f[5]); - fReflSurfXY[0][3] = 0.3535533905932737*(1.732050807568877*(f[31]-1.0*(f[30]+f[29]))+f[28]+1.732050807568877*f[25]-1.0*(f[24]+f[23])+f[15]); - fReflSurfXY[0][4] = 0.02357022603955158*(25.98076211353316*f[43]+5.0*(3.0*f[37]-5.196152422706631*(f[39]+f[38]))+8.660254037844387*(3.0*f[35]-1.732050807568877*(f[34]+f[33]))+15.0*f[32]); - fReflSurfXY[0][5] = 0.02357022603955158*(25.98076211353316*f[47]+5.0*(3.0*f[44]-5.196152422706631*(f[46]+f[45]))+8.660254037844387*(3.0*f[42]-1.732050807568877*(f[41]+f[40]))+15.0*f[36]); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = -(0.25*(1.7320508075688772*(f[27]-1.0*(f[22]+f[21]))+f[20]+1.7320508075688772*(f[14]-1.0*f[16])-1.0*(f[13]+f[12])+1.7320508075688772*(f[8]+f[7])-1.0*f[6]+f[5]-1.7320508075688772*f[3]+f[2]+f[1]-1.0*f[0])); + fReflSurfXYMu[0][1] = -(0.25*(1.7320508075688772*(f[31]-1.0*(f[30]+f[29]))+f[28]+1.7320508075688772*(f[25]-1.0*f[26])-1.0*(f[24]+f[23])+1.7320508075688772*(f[19]+f[18])-1.0*f[17]+f[15]-1.7320508075688772*f[11]+f[10]+f[9]-1.0*f[4])); + fReflSurfXYMu[0][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(-(3.0*(f[46]+f[45]))+1.7320508075688772*f[44]-3.0*f[43])+5.0*(5.196152422706631*f[42]-3.0*(f[41]+f[40])+5.196152422706631*(f[39]+f[38])-3.0*f[37])+8.660254037844387*(1.7320508075688772*f[36]-3.0*f[35]+1.7320508075688772*(f[34]+f[33]))-15.0*f[32])); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = 0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*(vcutsq[6]+vcutsq[5])+1.4142135623730951*(vcutsq[4]+vcutsq[3])-1.4142135623730951*(vcutsq[2]+vcutsq[1])+1.4142135623730951*vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = 0.25*(1.7320508075688772*(f[27]-1.0*(f[22]+f[21]))+f[20]+1.7320508075688772*(f[16]+f[14])-1.0*(f[13]+f[12]+1.7320508075688772*(f[8]+f[7]))+f[6]+f[5]+1.7320508075688772*f[3]-1.0*(f[2]+f[1])+f[0]); + fReflSurfXYMu[1][1] = 0.25*(1.7320508075688772*(f[31]-1.0*(f[30]+f[29]))+f[28]+1.7320508075688772*(f[26]+f[25])-1.0*(f[24]+f[23]+1.7320508075688772*(f[19]+f[18]))+f[17]+f[15]+1.7320508075688772*f[11]-1.0*(f[10]+f[9])+f[4]); + fReflSurfXYMu[1][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(-(3.0*(f[46]+f[45]))+1.7320508075688772*f[44]+3.0*f[43])+5.0*(5.196152422706631*f[42]-1.0*(3.0*(f[41]+f[40])+5.196152422706631*(f[39]+f[38])-3.0*f[37]))+8.660254037844387*(1.7320508075688772*f[36]+3.0*f[35]-1.7320508075688772*(f[34]+f[33]))+15.0*f[32]); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]-270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]-174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]-150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]-11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]+7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]+3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]-270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]-174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]+300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]+116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]-150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]+58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[0][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1721,121 +1857,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double fReflSurfXY[0][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[0][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - // node (x,y)_1 - vcutSq = -0.25*(2.449489742783178*phiWall[7]-2.449489742783178*(phi[7]+phiWall[6])+2.449489742783178*(phi[6]+phiWall[5])-2.449489742783178*phi[5]+1.414213562373095*phiWall[4]-1.414213562373095*phi[4]-2.449489742783178*phiWall[3]+2.449489742783178*phi[3]-1.414213562373095*phiWall[2]+1.414213562373095*(phi[2]+phiWall[1])-1.414213562373095*(phi[1]+phiWall[0])+1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[1][0] = 0.0; - fReflSurfXY[1][1] = 0.0; - fReflSurfXY[1][2] = 0.0; - fReflSurfXY[1][3] = 0.0; - fReflSurfXY[1][4] = 0.0; - fReflSurfXY[1][5] = 0.0; + // node (mu)_0 + vcutsq_n = 0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*vcutsq[6]+1.4142135623730951*vcutsq[5]-1.4142135623730951*(vcutsq[4]+vcutsq[3])+1.4142135623730951*vcutsq[2]-1.4142135623730951*vcutsq[1]+1.4142135623730951*vcutsq[0]); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[1][0] = -0.3535533905932737*(1.732050807568877*(f[16]-1.0*f[8]+f[7])+f[6]-1.0*(1.732050807568877*f[3]+f[2])+f[1]-1.0*f[0]); - fReflSurfXY[1][1] = -0.3535533905932737*(1.732050807568877*(f[26]-1.0*f[19]+f[18])+f[17]-1.0*(1.732050807568877*f[11]+f[10])+f[9]-1.0*f[4]); - fReflSurfXY[1][2] = -0.3535533905932737*(1.732050807568877*(f[27]-1.0*f[22]+f[21])+f[20]-1.0*(1.732050807568877*f[14]+f[13])+f[12]-1.0*f[5]); - fReflSurfXY[1][3] = -0.3535533905932737*(1.732050807568877*(f[31]-1.0*f[30]+f[29])+f[28]-1.0*(1.732050807568877*f[25]+f[24])+f[23]-1.0*f[15]); - fReflSurfXY[1][4] = -0.02357022603955158*(25.98076211353316*f[43]+5.0*(5.196152422706631*(f[38]-1.0*f[39])+3.0*f[37])+8.660254037844387*(1.732050807568877*(f[33]-1.0*f[34])-3.0*f[35])-15.0*f[32]); - fReflSurfXY[1][5] = -0.02357022603955158*(25.98076211353316*f[47]+5.0*(5.196152422706631*(f[45]-1.0*f[46])+3.0*f[44])+8.660254037844387*(1.732050807568877*(f[40]-1.0*f[41])-3.0*f[42])-15.0*f[36]); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = 0.25*(1.7320508075688772*(f[27]-1.0*f[22]+f[21])+f[20]-1.0*(1.7320508075688772*(f[16]+f[14])+f[13])+f[12]+1.7320508075688772*f[8]-1.0*(1.7320508075688772*f[7]+f[6]+f[5])+1.7320508075688772*f[3]+f[2]-1.0*f[1]+f[0]); + fReflSurfXYMu[0][1] = 0.25*(1.7320508075688772*(f[31]-1.0*f[30]+f[29])+f[28]-1.0*(1.7320508075688772*(f[26]+f[25])+f[24])+f[23]+1.7320508075688772*f[19]-1.0*(1.7320508075688772*f[18]+f[17]+f[15])+1.7320508075688772*f[11]+f[10]-1.0*f[9]+f[4]); + fReflSurfXYMu[0][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[45]-1.0*f[46])+1.7320508075688772*f[44]-3.0*f[43])+5.0*(-(5.196152422706631*f[42])+3.0*(f[40]-1.0*f[41])+5.196152422706631*f[39]-1.0*(5.196152422706631*f[38]+3.0*f[37]))+8.660254037844387*(-(1.7320508075688772*f[36])+3.0*f[35]+1.7320508075688772*(f[34]-1.0*f[33]))+15.0*f[32]); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]+150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = -(0.25*(1.4142135623730951*vcutsq[7]-1.4142135623730951*vcutsq[6]+1.4142135623730951*(vcutsq[5]+vcutsq[4])-1.4142135623730951*(vcutsq[3]+vcutsq[2])+1.4142135623730951*vcutsq[1]-1.4142135623730951*vcutsq[0])); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = -(0.25*(1.7320508075688772*(f[27]-1.0*f[22]+f[21])+f[20]+1.7320508075688772*f[16]-1.0*(1.7320508075688772*f[14]+f[13])+f[12]+1.7320508075688772*(f[7]-1.0*f[8])+f[6]-1.0*(f[5]+1.7320508075688772*f[3]+f[2])+f[1]-1.0*f[0])); + fReflSurfXYMu[1][1] = -(0.25*(1.7320508075688772*(f[31]-1.0*f[30]+f[29])+f[28]+1.7320508075688772*f[26]-1.0*(1.7320508075688772*f[25]+f[24])+f[23]+1.7320508075688772*(f[18]-1.0*f[19])+f[17]-1.0*(f[15]+1.7320508075688772*f[11]+f[10])+f[9]-1.0*f[4])); + fReflSurfXYMu[1][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[45]-1.0*f[46])+1.7320508075688772*f[44]+3.0*f[43])+5.0*(-(5.196152422706631*f[42])+3.0*(f[40]-1.0*f[41])+5.196152422706631*(f[38]-1.0*f[39])+3.0*f[37])+8.660254037844387*(1.7320508075688772*(f[33]-1.0*f[34])-1.0*(1.7320508075688772*f[36]+3.0*f[35]))-15.0*f[32])); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])+13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]-467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]-270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]-301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]-174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]-259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]-150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]-150.0*f[32]-232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]+100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]-25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])+25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]-23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]-20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]-11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])+13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]+7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]-12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]+6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]+3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]-467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]-270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]-301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]-174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])+519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]+300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])+201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]+116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]-259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]-150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]+100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]+58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[1][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1845,121 +1991,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double fReflSurfXY[1][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[1][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - // node (x,y)_2 - vcutSq = -0.25*(2.449489742783178*phiWall[7]-2.449489742783178*phi[7]+2.449489742783178*phiWall[6]-2.449489742783178*(phi[6]+phiWall[5])+2.449489742783178*phi[5]+1.414213562373095*phiWall[4]-1.414213562373095*phi[4]-2.449489742783178*phiWall[3]+2.449489742783178*phi[3]+1.414213562373095*phiWall[2]-1.414213562373095*(phi[2]+phiWall[1])+1.414213562373095*phi[1]-1.414213562373095*phiWall[0]+1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[2][0] = 0.0; - fReflSurfXY[2][1] = 0.0; - fReflSurfXY[2][2] = 0.0; - fReflSurfXY[2][3] = 0.0; - fReflSurfXY[2][4] = 0.0; - fReflSurfXY[2][5] = 0.0; + // node (mu)_0 + vcutsq_n = 0.25*(1.4142135623730951*(vcutsq[7]+vcutsq[6])-1.4142135623730951*(vcutsq[5]+vcutsq[4]+vcutsq[3]+vcutsq[2])+1.4142135623730951*(vcutsq[1]+vcutsq[0])); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[2][0] = -0.3535533905932737*(1.732050807568877*(f[16]+f[8]-1.0*f[7])+f[6]-1.732050807568877*f[3]+f[2]-1.0*(f[1]+f[0])); - fReflSurfXY[2][1] = -0.3535533905932737*(1.732050807568877*(f[26]+f[19]-1.0*f[18])+f[17]-1.732050807568877*f[11]+f[10]-1.0*(f[9]+f[4])); - fReflSurfXY[2][2] = -0.3535533905932737*(1.732050807568877*(f[27]+f[22]-1.0*f[21])+f[20]-1.732050807568877*f[14]+f[13]-1.0*(f[12]+f[5])); - fReflSurfXY[2][3] = -0.3535533905932737*(1.732050807568877*(f[31]+f[30]-1.0*f[29])+f[28]-1.732050807568877*f[25]+f[24]-1.0*(f[23]+f[15])); - fReflSurfXY[2][4] = -0.02357022603955158*(25.98076211353316*f[43]+5.0*(5.196152422706631*(f[39]-1.0*f[38])+3.0*f[37])+8.660254037844387*(1.732050807568877*f[34]-3.0*f[35])-1.0*(15.0*f[33]+15.0*f[32])); - fReflSurfXY[2][5] = -0.02357022603955158*(25.98076211353316*f[47]+5.0*(5.196152422706631*(f[46]-1.0*f[45])+3.0*f[44])+8.660254037844387*(1.732050807568877*f[41]-3.0*f[42])-1.0*(15.0*f[40]+15.0*f[36])); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = 0.25*(1.7320508075688772*(f[27]+f[22]-1.0*f[21])+f[20]-1.7320508075688772*(f[16]+f[14])+f[13]-1.0*f[12]+1.7320508075688772*(f[7]-1.0*f[8])-1.0*(f[6]+f[5])+1.7320508075688772*f[3]-1.0*f[2]+f[1]+f[0]); + fReflSurfXYMu[0][1] = 0.25*(1.7320508075688772*(f[31]+f[30]-1.0*f[29])+f[28]-1.7320508075688772*(f[26]+f[25])+f[24]-1.0*f[23]+1.7320508075688772*(f[18]-1.0*f[19])-1.0*(f[17]+f[15])+1.7320508075688772*f[11]-1.0*f[10]+f[9]+f[4]); + fReflSurfXYMu[0][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[46]-1.0*f[45])+1.7320508075688772*f[44]-3.0*f[43])+5.0*(-(5.196152422706631*f[42])+3.0*(f[41]-1.0*f[40])+5.196152422706631*(f[38]-1.0*f[39])-3.0*f[37])+8.660254037844387*(-(1.7320508075688772*f[36])+3.0*f[35]+1.7320508075688772*(f[33]-1.0*f[34]))+15.0*f[32]); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.61895003862225*f[36]+20.1246117974981*f[35]-11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-8.0*f[15]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.41640786499874*f[39]-13.41640786499874*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.41640786499874*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.708203932499369*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]-467.6537180435967*f[39]+467.6537180435967*f[38]-270.0*f[37]-269.9999999999999*f[36]+467.6537180435969*f[35]-269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]-301.8691769624717*f[19]+301.8691769624717*f[18]-174.2842505793337*f[17]-174.2842505793337*f[15]+301.8691769624717*f[11]-174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.0000000000001*f[36]-519.6152422706633*f[35]+300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.1895003862225*f[17]+116.1895003862225*f[15]-201.2461179749811*f[11]+116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]-259.8076211353315*f[39]+259.8076211353315*f[38]-150.0*f[37]-150.0*f[36]+259.8076211353317*f[35]-150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.6230589874906*f[19]-100.6230589874906*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.6230589874906*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-11.61895003862225*f[15]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]-20.12461179749811*f[39]+20.12461179749811*f[38]-11.61895003862225*f[37]-11.618950038622252*f[36]+20.124611797498105*f[35]-11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-8.0*f[15]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]+13.416407864998739*f[39]-13.416407864998739*f[38]+7.745966692414834*f[37]+7.745966692414834*f[36]-13.416407864998737*f[35]+7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]+6.708203932499369*f[39]-6.708203932499369*f[38]+3.872983346207417*f[37]+3.872983346207417*f[36]-6.7082039324993685*f[35]+3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]-467.65371804359665*f[39]+467.65371804359665*f[38]-270.0*f[37]-269.99999999999994*f[36]+467.65371804359694*f[35]-269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]-301.86917696247167*f[19]+301.86917696247167*f[18]-174.28425057933373*f[17]-174.28425057933373*f[15]+301.86917696247167*f[11]-174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]+519.6152422706631*f[39]-519.6152422706631*f[38]+300.0*f[37]+300.00000000000006*f[36]-519.6152422706633*f[35]+300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]+201.2461179749811*f[19]-201.2461179749811*f[18]+116.18950038622252*f[17]+116.18950038622252*f[15]-201.2461179749811*f[11]+116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]-259.80762113533154*f[39]+259.80762113533154*f[38]-150.0*f[37]-150.00000000000003*f[36]+259.80762113533166*f[35]-150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]+100.62305898749055*f[19]-100.62305898749055*f[18]+58.09475019311126*f[17]+58.09475019311126*f[15]-100.62305898749055*f[11]+58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = -(0.25*(1.4142135623730951*(vcutsq[7]+vcutsq[6])-1.4142135623730951*vcutsq[5]+1.4142135623730951*vcutsq[4]-1.4142135623730951*vcutsq[3]+1.4142135623730951*vcutsq[2]-1.4142135623730951*(vcutsq[1]+vcutsq[0]))); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = -(0.25*(1.7320508075688772*(f[27]+f[22]-1.0*f[21])+f[20]+1.7320508075688772*(f[16]-1.0*f[14])+f[13]-1.0*f[12]+1.7320508075688772*(f[8]-1.0*f[7])+f[6]-1.0*(f[5]+1.7320508075688772*f[3])+f[2]-1.0*(f[1]+f[0]))); + fReflSurfXYMu[1][1] = -(0.25*(1.7320508075688772*(f[31]+f[30]-1.0*f[29])+f[28]+1.7320508075688772*(f[26]-1.0*f[25])+f[24]-1.0*f[23]+1.7320508075688772*(f[19]-1.0*f[18])+f[17]-1.0*(f[15]+1.7320508075688772*f[11])+f[10]-1.0*(f[9]+f[4]))); + fReflSurfXYMu[1][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[46]-1.0*f[45])+1.7320508075688772*f[44]+3.0*f[43])+5.0*(-(5.196152422706631*f[42])+3.0*(f[41]-1.0*f[40])+5.196152422706631*(f[39]-1.0*f[38])+3.0*f[37])+8.660254037844387*(1.7320508075688772*f[34]-1.0*(1.7320508075688772*f[36]+3.0*f[35]))-1.0*(15.000000000000002*f[33]+15.0*f[32]))); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]-207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]+120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]-207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]+120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]+11.61895003862225*f[15]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]-8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]-207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]+120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]-207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]+120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]+15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]-25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]+15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]-15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]+25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]-15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.41640786499874*f[13]-13.41640786499874*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]-23.2379000772445*f[3]+13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]-20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.61895003862225*f[36]-20.1246117974981*f[35]+11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]-13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]-13.85640646055102*f[25]+8.0*f[24]-8.0*f[23]+13.85640646055102*f[19]-13.85640646055102*f[18]+8.0*f[17]-8.0*f[15]-13.85640646055102*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]+13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]+13.41640786499874*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.41640786499874*f[39]+13.41640786499874*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.41640786499874*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]+6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.708203932499369*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]+13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]+13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.85640646055102*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]-467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]-467.6537180435967*f[42]+270.0*f[41]-270.0*f[40]+467.6537180435967*f[39]-467.6537180435967*f[38]+270.0*f[37]-269.9999999999999*f[36]-467.6537180435969*f[35]+269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]-301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]-301.8691769624717*f[25]+174.2842505793337*f[24]-174.2842505793337*f[23]+301.8691769624717*f[19]-301.8691769624717*f[18]+174.2842505793337*f[17]-174.2842505793337*f[15]-301.8691769624717*f[11]+174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.0000000000001*f[36]+519.6152422706633*f[35]-300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]-232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]-232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.1895003862225*f[24]+116.1895003862225*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.1895003862225*f[17]+116.1895003862225*f[15]+201.2461179749811*f[11]-116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]-259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]-259.8076211353315*f[42]+150.0*f[41]-150.0*f[40]+259.8076211353315*f[39]-259.8076211353315*f[38]+150.0*f[37]-150.0*f[36]-259.8076211353317*f[35]+150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]+232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]+232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]+207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]-120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]+207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]-120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]+100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]+100.6230589874906*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.6230589874906*f[19]+100.6230589874906*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.6230589874906*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]-25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]+15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]-25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]+15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]-20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]-20.12461179749811*f[25]+11.61895003862225*f[24]-11.61895003862225*f[23]+20.12461179749811*f[19]-20.12461179749811*f[18]+11.61895003862225*f[17]-11.61895003862225*f[15]-20.12461179749811*f[11]+11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]+25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]-15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]+25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]-15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]-23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]-23.2379000772445*f[14]+13.416407864998739*f[13]-13.416407864998739*f[12]+23.2379000772445*f[8]-23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]-23.2379000772445*f[3]+13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]+20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]+20.12461179749811*f[25]-11.61895003862225*f[24]+11.61895003862225*f[23]-23.2379000772445*f[22]+23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]+20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]+11.61895003862225*f[15]+23.2379000772445*f[14]-13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]-11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]+23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]-13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]-20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]-20.12461179749811*f[42]+11.61895003862225*f[41]-11.61895003862225*f[40]+20.12461179749811*f[39]-20.12461179749811*f[38]+11.61895003862225*f[37]-11.618950038622252*f[36]-20.124611797498105*f[35]+11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]-13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]-13.856406460551018*f[25]+8.0*f[24]-8.0*f[23]+13.856406460551018*f[19]-13.856406460551018*f[18]+8.0*f[17]-8.0*f[15]-13.856406460551018*f[11]+8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]+13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]+13.416407864998739*f[42]-7.745966692414834*f[41]+7.745966692414834*f[40]-13.416407864998739*f[39]+13.416407864998739*f[38]-7.745966692414834*f[37]+7.745966692414834*f[36]+13.416407864998737*f[35]-7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]-12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]-12.0*f[14]+6.928203230275509*f[13]-6.928203230275509*f[12]+12.0*f[8]-12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-12.0*f[3]+6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]+6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]+6.708203932499369*f[42]-3.872983346207417*f[41]+3.872983346207417*f[40]-6.708203932499369*f[39]+6.708203932499369*f[38]-3.872983346207417*f[37]+3.872983346207417*f[36]+6.7082039324993685*f[35]-3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]+13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]-8.0*f[24]+8.0*f[23]-12.0*f[22]+12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]+13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]+8.0*f[15]+12.0*f[14]-6.928203230275509*f[13]+6.928203230275509*f[12]+13.856406460551018*f[11]-8.0*f[10]+8.0*f[9]-12.0*f[8]+12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]-6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]-467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]-467.65371804359665*f[42]+270.0*f[41]-270.0*f[40]+467.65371804359665*f[39]-467.65371804359665*f[38]+270.0*f[37]-269.99999999999994*f[36]-467.65371804359694*f[35]+269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]-301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]-301.86917696247167*f[25]+174.28425057933373*f[24]-174.28425057933373*f[23]+301.86917696247167*f[19]-301.86917696247167*f[18]+174.28425057933373*f[17]-174.28425057933373*f[15]-301.86917696247167*f[11]+174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]+519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]+519.6152422706631*f[42]-300.0*f[41]+300.0*f[40]-519.6152422706631*f[39]+519.6152422706631*f[38]-300.0*f[37]+300.00000000000006*f[36]+519.6152422706633*f[35]-300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]-232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]+134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]-232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]+134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]+201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]+201.2461179749811*f[25]-116.18950038622252*f[24]+116.18950038622252*f[23]-201.2461179749811*f[19]+201.2461179749811*f[18]-116.18950038622252*f[17]+116.18950038622252*f[15]+201.2461179749811*f[11]-116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]-259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]-259.80762113533154*f[42]+150.0*f[41]-150.0*f[40]+259.80762113533154*f[39]-259.80762113533154*f[38]+150.0*f[37]-150.00000000000003*f[36]-259.80762113533166*f[35]+150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]+232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]-134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]+232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]-134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]+207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]-120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]+207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]-120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]+100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]+100.62305898749055*f[25]-58.09475019311126*f[24]+58.09475019311126*f[23]-100.62305898749055*f[19]+100.62305898749055*f[18]-58.09475019311126*f[17]+58.09475019311126*f[15]+100.62305898749055*f[11]-58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[2][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -1969,121 +2125,131 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double fReflSurfXY[2][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[2][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - // node (x,y)_3 - vcutSq = 0.25*(2.449489742783178*phiWall[7]-2.449489742783178*phi[7]+2.449489742783178*phiWall[6]-2.449489742783178*phi[6]+2.449489742783178*phiWall[5]-2.449489742783178*phi[5]+1.414213562373095*phiWall[4]-1.414213562373095*phi[4]+2.449489742783178*phiWall[3]-2.449489742783178*phi[3]+1.414213562373095*phiWall[2]-1.414213562373095*phi[2]+1.414213562373095*phiWall[1]-1.414213562373095*phi[1]+1.414213562373095*phiWall[0]-1.414213562373095*phi[0])*q2Dm; - if (vcutSq <= vparAbsSqLo) { // absorb (no reflection) + wv = 0.5*(vparUp+vparLo); + dv = vparUp-1.0*vparLo; - fReflSurfXY[3][0] = 0.0; - fReflSurfXY[3][1] = 0.0; - fReflSurfXY[3][2] = 0.0; - fReflSurfXY[3][3] = 0.0; - fReflSurfXY[3][4] = 0.0; - fReflSurfXY[3][5] = 0.0; + // node (mu)_0 + vcutsq_n = -(0.25*(1.4142135623730951*(vcutsq[7]+vcutsq[6]+vcutsq[5])-1.4142135623730951*vcutsq[4]+1.4142135623730951*vcutsq[3]-1.4142135623730951*(vcutsq[2]+vcutsq[1]+vcutsq[0]))); - } else if (vcutSq > vparAbsSqUp) { // full reflection + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) - fReflSurfXY[3][0] = 0.3535533905932737*(1.732050807568877*(f[16]+f[8]+f[7])+f[6]+1.732050807568877*f[3]+f[2]+f[1]+f[0]); - fReflSurfXY[3][1] = 0.3535533905932737*(1.732050807568877*(f[26]+f[19]+f[18])+f[17]+1.732050807568877*f[11]+f[10]+f[9]+f[4]); - fReflSurfXY[3][2] = 0.3535533905932737*(1.732050807568877*(f[27]+f[22]+f[21])+f[20]+1.732050807568877*f[14]+f[13]+f[12]+f[5]); - fReflSurfXY[3][3] = 0.3535533905932737*(1.732050807568877*(f[31]+f[30]+f[29])+f[28]+1.732050807568877*f[25]+f[24]+f[23]+f[15]); - fReflSurfXY[3][4] = 0.02357022603955158*(25.98076211353316*f[43]+5.0*(5.196152422706631*(f[39]+f[38])+3.0*f[37])+8.660254037844387*(3.0*f[35]+1.732050807568877*(f[34]+f[33]))+15.0*f[32]); - fReflSurfXY[3][5] = 0.02357022603955158*(25.98076211353316*f[47]+5.0*(5.196152422706631*(f[46]+f[45])+3.0*f[44])+8.660254037844387*(3.0*f[42]+1.732050807568877*(f[41]+f[40]))+15.0*f[36]); + fReflSurfXYMu[0][0] = 0.0; + fReflSurfXYMu[0][1] = 0.0; + fReflSurfXYMu[0][2] = 0.0; - } else { // partial reflection + } else if (vcutsq_n > vparAbsSqUp) { // full reflection - double wv = 0.5*(vparUp+vparLo); - double dv = vparUp-1.0*vparLo; + fReflSurfXYMu[0][0] = -(0.25*(1.7320508075688772*(f[27]+f[22]+f[21])+f[20]+1.7320508075688772*(f[14]-1.0*f[16])+f[13]+f[12]-1.0*(1.7320508075688772*(f[8]+f[7])+f[6])+f[5]-1.0*(1.7320508075688772*f[3]+f[2]+f[1]+f[0]))); + fReflSurfXYMu[0][1] = -(0.25*(1.7320508075688772*(f[31]+f[30]+f[29])+f[28]+1.7320508075688772*(f[25]-1.0*f[26])+f[24]+f[23]-1.0*(1.7320508075688772*(f[19]+f[18])+f[17])+f[15]-1.0*(1.7320508075688772*f[11]+f[10]+f[9]+f[4]))); + fReflSurfXYMu[0][2] = -(0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[46]+f[45])+1.7320508075688772*f[44]-3.0*f[43])+5.0*(5.196152422706631*f[42]+3.0*(f[41]+f[40])-1.0*(5.196152422706631*(f[39]+f[38])+3.0*f[37]))+15.000000000000002*f[36]-1.0*(8.660254037844387*(3.0*f[35]+1.7320508075688772*(f[34]+f[33]))+15.0*f[32]))); - double xBar, xSqBar; - double fReflSurfXYMu[2][3] = {0.}; + } else { // partial reflection - // node (mu)_0 if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]-207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]+120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]+11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[0][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])); + fReflSurfXYMu[0][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]-207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]+120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4])); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[0][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]-25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]+15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]+25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]-15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]+13.41640786499874*f[5]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]-13.41640786499874*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]-20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.61895003862225*f[36]-20.1246117974981*f[35]-11.61895003862225*f[34]-11.61895003862225*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]+8.0*f[15]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]+13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.41640786499874*f[39]+13.41640786499874*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.41640786499874*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]+6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.708203932499369*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); - fReflSurfXYMu[0][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]-467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]-467.6537180435967*f[39]-467.6537180435967*f[38]-270.0*f[37]+269.9999999999999*f[36]-467.6537180435969*f[35]-269.9999999999999*f[34]-269.9999999999999*f[33]-270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]-301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]-301.8691769624717*f[19]-301.8691769624717*f[18]-174.2842505793337*f[17]+174.2842505793337*f[15]-301.8691769624717*f[11]-174.2842505793337*f[10]-174.2842505793337*f[9]-174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.0000000000001*f[36]+519.6152422706633*f[35]+300.0000000000001*f[34]+300.0000000000001*f[33]+300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]-232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.1895003862225*f[17]-116.1895003862225*f[15]+201.2461179749811*f[11]+116.1895003862225*f[10]+116.1895003862225*f[9]+116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]-259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]-259.8076211353315*f[39]-259.8076211353315*f[38]-150.0*f[37]+150.0*f[36]-259.8076211353317*f[35]-150.0*f[34]-150.0*f[33]-150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]+232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]+207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]-120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]+100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.6230589874906*f[19]+100.6230589874906*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.6230589874906*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); + fReflSurfXYMu[0][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]-25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]+15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]-20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+11.61895003862225*f[15]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]+25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]-15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]+13.416407864998739*f[5]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]+20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]-13.416407864998739*f[5]+11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[0][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]-20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]-20.12461179749811*f[39]-20.12461179749811*f[38]-11.61895003862225*f[37]+11.618950038622252*f[36]-20.124611797498105*f[35]-11.618950038622252*f[34]-11.618950038622252*f[33]-11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]+8.0*f[15]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]+13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]+13.416407864998739*f[39]+13.416407864998739*f[38]+7.745966692414834*f[37]-7.745966692414834*f[36]+13.416407864998737*f[35]+7.745966692414834*f[34]+7.745966692414834*f[33]+7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]-12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]+6.928203230275509*f[5]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]+6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]+6.708203932499369*f[39]+6.708203932499369*f[38]+3.872983346207417*f[37]-3.872983346207417*f[36]+6.7082039324993685*f[35]+3.872983346207417*f[34]+3.872983346207417*f[33]+3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0]); + fReflSurfXYMu[0][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]-467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]-467.65371804359665*f[39]-467.65371804359665*f[38]-270.0*f[37]+269.99999999999994*f[36]-467.65371804359694*f[35]-269.99999999999994*f[34]-269.99999999999994*f[33]-270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]-301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]-301.86917696247167*f[19]-301.86917696247167*f[18]-174.28425057933373*f[17]+174.28425057933373*f[15]-301.86917696247167*f[11]-174.28425057933373*f[10]-174.28425057933373*f[9]-174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]+519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]+519.6152422706631*f[39]+519.6152422706631*f[38]+300.0*f[37]-300.00000000000006*f[36]+519.6152422706633*f[35]+300.00000000000006*f[34]+300.00000000000006*f[33]+300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]-232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]+134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]+201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]+201.2461179749811*f[19]+201.2461179749811*f[18]+116.18950038622252*f[17]-116.18950038622252*f[15]+201.2461179749811*f[11]+116.18950038622252*f[10]+116.18950038622252*f[9]+116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]-259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]-259.80762113533154*f[39]-259.80762113533154*f[38]-150.0*f[37]+150.00000000000003*f[36]-259.80762113533166*f[35]-150.00000000000003*f[34]-150.00000000000003*f[33]-150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]+232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]-134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]+207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]-120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]+100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]+100.62305898749055*f[19]+100.62305898749055*f[18]+58.09475019311126*f[17]-58.09475019311126*f[15]+100.62305898749055*f[11]+58.09475019311126*f[10]+58.09475019311126*f[9]+58.09475019311126*f[4]); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; - if (fReflSurfXYMu[0][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[0][1])/fReflSurfXYMu[0][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[0][2]+5.0*fReflSurfXYMu[0][0]))/fReflSurfXYMu[0][0]; + if (fReflSurfXYMu[0][0]<0.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[0][0] = 0.0; fReflSurfXYMu[0][1] = 0.0; fReflSurfXYMu[0][2] = 0.0; + } + } - // node (mu)_1 + // node (mu)_1 + vcutsq_n = 0.3535533905932738*(vcutsq[7]+vcutsq[6]+vcutsq[5]+vcutsq[4]+vcutsq[3]+vcutsq[2]+vcutsq[1]+vcutsq[0]); + + if (vcutsq_n <= vparAbsSqLo) { // absorb (no reflection) + + fReflSurfXYMu[1][0] = 0.0; + fReflSurfXYMu[1][1] = 0.0; + fReflSurfXYMu[1][2] = 0.0; + + } else if (vcutsq_n > vparAbsSqUp) { // full reflection + + fReflSurfXYMu[1][0] = 0.25*(1.7320508075688772*(f[27]+f[22]+f[21])+f[20]+1.7320508075688772*(f[16]+f[14])+f[13]+f[12]+1.7320508075688772*(f[8]+f[7])+f[6]+f[5]+1.7320508075688772*f[3]+f[2]+f[1]+f[0]); + fReflSurfXYMu[1][1] = 0.25*(1.7320508075688772*(f[31]+f[30]+f[29])+f[28]+1.7320508075688772*(f[26]+f[25])+f[24]+f[23]+1.7320508075688772*(f[19]+f[18])+f[17]+f[15]+1.7320508075688772*f[11]+f[10]+f[9]+f[4]); + fReflSurfXYMu[1][2] = 0.016666666666666666*(25.980762113533157*f[47]+8.660254037844387*(3.0*(f[46]+f[45])+1.7320508075688772*f[44]+3.0*f[43])+5.0*(5.196152422706631*f[42]+3.0*(f[41]+f[40])+5.196152422706631*(f[39]+f[38])+3.0*f[37])+8.660254037844387*(1.7320508075688772*f[36]+3.0*f[35]+1.7320508075688772*(f[34]+f[33]))+15.0*f[32]); + + } else { // partial reflection + if (wv > 0.) { // vcut in logical space. - double vcut_l = 2.*(sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = 0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]-12.0*f[27]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = 0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.8460969082653*f[47]+207.8460969082653*f[46]+207.8460969082653*f[45]+120.0*f[44]+207.8460969082653*f[43]+207.8460969082653*f[42]+120.0*f[41]+120.0*f[40]+207.8460969082653*f[39]+207.8460969082653*f[38]+120.0*f[37]+120.0*f[36]+207.8460969082653*f[35]+120.0*f[34]+120.0*f[33]+120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = 0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]+23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]+23.2379000772445*f[16]-11.61895003862225*f[15]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]-11.61895003862225*f[4]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0]); + fReflSurfXYMu[1][1] = 0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]+13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]-12.0*f[27]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]-12.0*f[16]+8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]+8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); + fReflSurfXYMu[1][2] = 0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l+207.84609690826525*f[47]+207.84609690826528*f[46]+207.84609690826528*f[45]+120.00000000000001*f[44]+207.84609690826528*f[43]+207.84609690826525*f[42]+120.0*f[41]+120.0*f[40]+207.84609690826525*f[39]+207.84609690826525*f[38]+120.0*f[37]+120.00000000000001*f[36]+207.84609690826528*f[35]+120.00000000000001*f[34]+120.00000000000001*f[33]+120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); } else { // vcut in logical space. - double vcut_l = 2.*(-sqrt(vcutSq)-wv)/dv; + double vcut_l = 2.*(-sqrt(vcutsq_n)-wv)/dv; const double vcut_lR2 = pow(vcut_l,2); const double vcut_lR3 = pow(vcut_l,3); const double vcut_lR4 = pow(vcut_l,4); const double vcut_lR5 = pow(vcut_l,5); - fReflSurfXYMu[1][0] = -0.009316949906249122*((25.98076211353316*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.0*f[44]+25.98076211353316*f[43]+25.98076211353316*f[42]+15.0*f[41]+15.0*f[40]+25.98076211353316*f[39]+25.98076211353316*f[38]+15.0*f[37]+15.0*f[36]+25.98076211353316*f[35]+15.0*f[34]+15.0*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+((-25.98076211353316*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.0*f[44]-25.98076211353316*f[43]-25.98076211353316*f[42]-15.0*f[41]-15.0*f[40]-25.98076211353316*f[39]-25.98076211353316*f[38]-15.0*f[37]-15.0*f[36]-25.98076211353316*f[35]-15.0*f[34]-15.0*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.41640786499874*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.41640786499874*f[13]+13.41640786499874*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.41640786499874*f[6]+13.41640786499874*f[5]+23.2379000772445*f[3]+13.41640786499874*f[2]+13.41640786499874*f[1]+13.41640786499874*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.41640786499874*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.41640786499874*f[13]-13.41640786499874*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.41640786499874*f[6]-13.41640786499874*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.41640786499874*f[2]-13.41640786499874*f[1]-13.41640786499874*f[0]); - fReflSurfXYMu[1][1] = -0.015625*((20.12461179749811*f[47]+20.1246117974981*f[46]+20.1246117974981*f[45]+11.61895003862225*f[44]+20.1246117974981*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.61895003862225*f[36]+20.1246117974981*f[35]+11.61895003862225*f[34]+11.61895003862225*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.85640646055102*f[31]+13.85640646055102*f[30]+13.85640646055102*f[29]+8.0*f[28]+13.85640646055102*f[26]+13.85640646055102*f[25]+8.0*f[24]+8.0*f[23]+13.85640646055102*f[19]+13.85640646055102*f[18]+8.0*f[17]+8.0*f[15]+13.85640646055102*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+((-13.41640786499874*f[47])-13.41640786499874*f[46]-13.41640786499874*f[45]-7.745966692414834*f[44]-13.41640786499874*f[43]-13.41640786499874*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.41640786499874*f[39]-13.41640786499874*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.41640786499874*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.708203932499369*f[46]-6.708203932499369*f[45]-3.872983346207417*f[44]-6.708203932499369*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.708203932499369*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.85640646055102*f[31]-13.85640646055102*f[30]-13.85640646055102*f[29]-8.0*f[28]-12.0*f[27]-13.85640646055102*f[26]-13.85640646055102*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.85640646055102*f[19]-13.85640646055102*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.85640646055102*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0]); - fReflSurfXYMu[1][2] = -0.001041666666666667*((467.6537180435967*f[47]+467.6537180435969*f[46]+467.6537180435969*f[45]+269.9999999999999*f[44]+467.6537180435969*f[43]+467.6537180435967*f[42]+270.0*f[41]+270.0*f[40]+467.6537180435967*f[39]+467.6537180435967*f[38]+270.0*f[37]+269.9999999999999*f[36]+467.6537180435969*f[35]+269.9999999999999*f[34]+269.9999999999999*f[33]+270.0*f[32])*vcut_lR5+(301.8691769624717*f[31]+301.8691769624717*f[30]+301.8691769624717*f[29]+174.2842505793337*f[28]+301.8691769624717*f[26]+301.8691769624717*f[25]+174.2842505793337*f[24]+174.2842505793337*f[23]+301.8691769624717*f[19]+301.8691769624717*f[18]+174.2842505793337*f[17]+174.2842505793337*f[15]+301.8691769624717*f[11]+174.2842505793337*f[10]+174.2842505793337*f[9]+174.2842505793337*f[4])*vcut_lR4+((-519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.0000000000001*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.0000000000001*f[36]-519.6152422706633*f[35]-300.0000000000001*f[34]-300.0000000000001*f[33]-300.0*f[32]+232.379000772445*f[27]+232.379000772445*f[22]+232.379000772445*f[21]+134.1640786499874*f[20]+232.379000772445*f[16]+232.379000772445*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.379000772445*f[8]+232.379000772445*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.379000772445*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+((-201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.1895003862225*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.1895003862225*f[24]-116.1895003862225*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.1895003862225*f[17]-116.1895003862225*f[15]-201.2461179749811*f[11]-116.1895003862225*f[10]-116.1895003862225*f[9]-116.1895003862225*f[4])*vcut_lR2+(259.8076211353315*f[47]+259.8076211353317*f[46]+259.8076211353317*f[45]+150.0*f[44]+259.8076211353317*f[43]+259.8076211353315*f[42]+150.0*f[41]+150.0*f[40]+259.8076211353315*f[39]+259.8076211353315*f[38]+150.0*f[37]+150.0*f[36]+259.8076211353317*f[35]+150.0*f[34]+150.0*f[33]+150.0*f[32]-232.379000772445*f[27]-232.379000772445*f[22]-232.379000772445*f[21]-134.1640786499874*f[20]-232.379000772445*f[16]-232.379000772445*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.379000772445*f[8]-232.379000772445*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.379000772445*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.8460969082653*f[47]-207.8460969082653*f[46]-207.8460969082653*f[45]-120.0*f[44]-207.8460969082653*f[43]-207.8460969082653*f[42]-120.0*f[41]-120.0*f[40]-207.8460969082653*f[39]-207.8460969082653*f[38]-120.0*f[37]-120.0*f[36]-207.8460969082653*f[35]-120.0*f[34]-120.0*f[33]-120.0*f[32]-100.6230589874906*f[31]-100.6230589874906*f[30]-100.6230589874906*f[29]-58.09475019311126*f[28]-100.6230589874906*f[26]-100.6230589874906*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.6230589874906*f[19]-100.6230589874906*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.6230589874906*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4]); + fReflSurfXYMu[1][0] = -(0.009316949906249122*((25.980762113533157*f[47]+25.98076211353316*f[46]+25.98076211353316*f[45]+15.000000000000002*f[44]+25.98076211353316*f[43]+25.980762113533157*f[42]+15.0*f[41]+15.0*f[40]+25.980762113533157*f[39]+25.980762113533157*f[38]+15.0*f[37]+15.000000000000002*f[36]+25.98076211353316*f[35]+15.000000000000002*f[34]+15.000000000000002*f[33]+15.0*f[32])*vcut_lR3+(20.12461179749811*f[31]+20.12461179749811*f[30]+20.12461179749811*f[29]+11.61895003862225*f[28]+20.12461179749811*f[26]+20.12461179749811*f[25]+11.61895003862225*f[24]+11.61895003862225*f[23]+20.12461179749811*f[19]+20.12461179749811*f[18]+11.61895003862225*f[17]+11.61895003862225*f[15]+20.12461179749811*f[11]+11.61895003862225*f[10]+11.61895003862225*f[9]+11.61895003862225*f[4])*vcut_lR2+(-(25.980762113533157*f[47])-25.98076211353316*f[46]-25.98076211353316*f[45]-15.000000000000002*f[44]-25.98076211353316*f[43]-25.980762113533157*f[42]-15.0*f[41]-15.0*f[40]-25.980762113533157*f[39]-25.980762113533157*f[38]-15.0*f[37]-15.000000000000002*f[36]-25.98076211353316*f[35]-15.000000000000002*f[34]-15.000000000000002*f[33]-15.0*f[32]+23.2379000772445*f[27]+23.2379000772445*f[22]+23.2379000772445*f[21]+13.416407864998739*f[20]+23.2379000772445*f[16]+23.2379000772445*f[14]+13.416407864998739*f[13]+13.416407864998739*f[12]+23.2379000772445*f[8]+23.2379000772445*f[7]+13.416407864998739*f[6]+13.416407864998739*f[5]+23.2379000772445*f[3]+13.416407864998739*f[2]+13.416407864998739*f[1]+13.416407864998739*f[0])*vcut_l-20.12461179749811*f[31]-20.12461179749811*f[30]-20.12461179749811*f[29]-11.61895003862225*f[28]-23.2379000772445*f[27]-20.12461179749811*f[26]-20.12461179749811*f[25]-11.61895003862225*f[24]-11.61895003862225*f[23]-23.2379000772445*f[22]-23.2379000772445*f[21]-13.416407864998739*f[20]-20.12461179749811*f[19]-20.12461179749811*f[18]-11.61895003862225*f[17]-23.2379000772445*f[16]-11.61895003862225*f[15]-23.2379000772445*f[14]-13.416407864998739*f[13]-13.416407864998739*f[12]-20.12461179749811*f[11]-11.61895003862225*f[10]-11.61895003862225*f[9]-23.2379000772445*f[8]-23.2379000772445*f[7]-13.416407864998739*f[6]-13.416407864998739*f[5]-11.61895003862225*f[4]-23.2379000772445*f[3]-13.416407864998739*f[2]-13.416407864998739*f[1]-13.416407864998739*f[0])); + fReflSurfXYMu[1][1] = -(0.015625*((20.12461179749811*f[47]+20.124611797498105*f[46]+20.124611797498105*f[45]+11.618950038622252*f[44]+20.124611797498105*f[43]+20.12461179749811*f[42]+11.61895003862225*f[41]+11.61895003862225*f[40]+20.12461179749811*f[39]+20.12461179749811*f[38]+11.61895003862225*f[37]+11.618950038622252*f[36]+20.124611797498105*f[35]+11.618950038622252*f[34]+11.618950038622252*f[33]+11.61895003862225*f[32])*vcut_lR4+(13.856406460551018*f[31]+13.856406460551018*f[30]+13.856406460551018*f[29]+8.0*f[28]+13.856406460551018*f[26]+13.856406460551018*f[25]+8.0*f[24]+8.0*f[23]+13.856406460551018*f[19]+13.856406460551018*f[18]+8.0*f[17]+8.0*f[15]+13.856406460551018*f[11]+8.0*f[10]+8.0*f[9]+8.0*f[4])*vcut_lR3+(-(13.416407864998739*f[47])-13.416407864998737*f[46]-13.416407864998737*f[45]-7.745966692414834*f[44]-13.416407864998737*f[43]-13.416407864998739*f[42]-7.745966692414834*f[41]-7.745966692414834*f[40]-13.416407864998739*f[39]-13.416407864998739*f[38]-7.745966692414834*f[37]-7.745966692414834*f[36]-13.416407864998737*f[35]-7.745966692414834*f[34]-7.745966692414834*f[33]-7.745966692414834*f[32]+12.0*f[27]+12.0*f[22]+12.0*f[21]+6.928203230275509*f[20]+12.0*f[16]+12.0*f[14]+6.928203230275509*f[13]+6.928203230275509*f[12]+12.0*f[8]+12.0*f[7]+6.928203230275509*f[6]+6.928203230275509*f[5]+12.0*f[3]+6.928203230275509*f[2]+6.928203230275509*f[1]+6.928203230275509*f[0])*vcut_lR2-6.708203932499369*f[47]-6.7082039324993685*f[46]-6.7082039324993685*f[45]-3.872983346207417*f[44]-6.7082039324993685*f[43]-6.708203932499369*f[42]-3.872983346207417*f[41]-3.872983346207417*f[40]-6.708203932499369*f[39]-6.708203932499369*f[38]-3.872983346207417*f[37]-3.872983346207417*f[36]-6.7082039324993685*f[35]-3.872983346207417*f[34]-3.872983346207417*f[33]-3.872983346207417*f[32]-13.856406460551018*f[31]-13.856406460551018*f[30]-13.856406460551018*f[29]-8.0*f[28]-12.0*f[27]-13.856406460551018*f[26]-13.856406460551018*f[25]-8.0*f[24]-8.0*f[23]-12.0*f[22]-12.0*f[21]-6.928203230275509*f[20]-13.856406460551018*f[19]-13.856406460551018*f[18]-8.0*f[17]-12.0*f[16]-8.0*f[15]-12.0*f[14]-6.928203230275509*f[13]-6.928203230275509*f[12]-13.856406460551018*f[11]-8.0*f[10]-8.0*f[9]-12.0*f[8]-12.0*f[7]-6.928203230275509*f[6]-6.928203230275509*f[5]-8.0*f[4]-12.0*f[3]-6.928203230275509*f[2]-6.928203230275509*f[1]-6.928203230275509*f[0])); + fReflSurfXYMu[1][2] = -(0.0010416666666666667*((467.65371804359665*f[47]+467.65371804359694*f[46]+467.65371804359694*f[45]+269.99999999999994*f[44]+467.65371804359694*f[43]+467.65371804359665*f[42]+270.0*f[41]+270.0*f[40]+467.65371804359665*f[39]+467.65371804359665*f[38]+270.0*f[37]+269.99999999999994*f[36]+467.65371804359694*f[35]+269.99999999999994*f[34]+269.99999999999994*f[33]+270.0*f[32])*vcut_lR5+(301.86917696247167*f[31]+301.86917696247167*f[30]+301.86917696247167*f[29]+174.28425057933373*f[28]+301.86917696247167*f[26]+301.86917696247167*f[25]+174.28425057933373*f[24]+174.28425057933373*f[23]+301.86917696247167*f[19]+301.86917696247167*f[18]+174.28425057933373*f[17]+174.28425057933373*f[15]+301.86917696247167*f[11]+174.28425057933373*f[10]+174.28425057933373*f[9]+174.28425057933373*f[4])*vcut_lR4+(-(519.6152422706631*f[47])-519.6152422706633*f[46]-519.6152422706633*f[45]-300.00000000000006*f[44]-519.6152422706633*f[43]-519.6152422706631*f[42]-300.0*f[41]-300.0*f[40]-519.6152422706631*f[39]-519.6152422706631*f[38]-300.0*f[37]-300.00000000000006*f[36]-519.6152422706633*f[35]-300.00000000000006*f[34]-300.00000000000006*f[33]-300.0*f[32]+232.37900077244504*f[27]+232.37900077244504*f[22]+232.37900077244504*f[21]+134.1640786499874*f[20]+232.37900077244504*f[16]+232.37900077244504*f[14]+134.1640786499874*f[13]+134.1640786499874*f[12]+232.37900077244504*f[8]+232.37900077244504*f[7]+134.1640786499874*f[6]+134.1640786499874*f[5]+232.37900077244504*f[3]+134.1640786499874*f[2]+134.1640786499874*f[1]+134.1640786499874*f[0])*vcut_lR3+(-(201.2461179749811*f[31])-201.2461179749811*f[30]-201.2461179749811*f[29]-116.18950038622252*f[28]-201.2461179749811*f[26]-201.2461179749811*f[25]-116.18950038622252*f[24]-116.18950038622252*f[23]-201.2461179749811*f[19]-201.2461179749811*f[18]-116.18950038622252*f[17]-116.18950038622252*f[15]-201.2461179749811*f[11]-116.18950038622252*f[10]-116.18950038622252*f[9]-116.18950038622252*f[4])*vcut_lR2+(259.80762113533154*f[47]+259.80762113533166*f[46]+259.80762113533166*f[45]+150.00000000000003*f[44]+259.80762113533166*f[43]+259.80762113533154*f[42]+150.0*f[41]+150.0*f[40]+259.80762113533154*f[39]+259.80762113533154*f[38]+150.0*f[37]+150.00000000000003*f[36]+259.80762113533166*f[35]+150.00000000000003*f[34]+150.00000000000003*f[33]+150.0*f[32]-232.37900077244504*f[27]-232.37900077244504*f[22]-232.37900077244504*f[21]-134.1640786499874*f[20]-232.37900077244504*f[16]-232.37900077244504*f[14]-134.1640786499874*f[13]-134.1640786499874*f[12]-232.37900077244504*f[8]-232.37900077244504*f[7]-134.1640786499874*f[6]-134.1640786499874*f[5]-232.37900077244504*f[3]-134.1640786499874*f[2]-134.1640786499874*f[1]-134.1640786499874*f[0])*vcut_l-207.84609690826525*f[47]-207.84609690826528*f[46]-207.84609690826528*f[45]-120.00000000000001*f[44]-207.84609690826528*f[43]-207.84609690826525*f[42]-120.0*f[41]-120.0*f[40]-207.84609690826525*f[39]-207.84609690826525*f[38]-120.0*f[37]-120.00000000000001*f[36]-207.84609690826528*f[35]-120.00000000000001*f[34]-120.00000000000001*f[33]-120.0*f[32]-100.62305898749055*f[31]-100.62305898749055*f[30]-100.62305898749055*f[29]-58.09475019311126*f[28]-100.62305898749055*f[26]-100.62305898749055*f[25]-58.09475019311126*f[24]-58.09475019311126*f[23]-100.62305898749055*f[19]-100.62305898749055*f[18]-58.09475019311126*f[17]-58.09475019311126*f[15]-100.62305898749055*f[11]-58.09475019311126*f[10]-58.09475019311126*f[9]-58.09475019311126*f[4])); } - // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], - // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. - xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; - xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; - if (fReflSurfXYMu[1][0]<0.) { + // If the cut distribution f(vpar), where vpar in [-1,vcut_l] or [vcut_l/1], + // has a cell average < 0, set to 0. If it's >0 but not realizable, set to p=0. + xBar = (0.5773502691896258*fReflSurfXYMu[1][1])/fReflSurfXYMu[1][0]; + xSqBar = (0.06666666666666667*(4.47213595499958*fReflSurfXYMu[1][2]+5.0*fReflSurfXYMu[1][0]))/fReflSurfXYMu[1][0]; + if (fReflSurfXYMu[1][0]<0.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; - } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { + } else if (fabs(xBar)>=1. || fabs(xSqBar)>=1.) { fReflSurfXYMu[1][0] = 0.0; fReflSurfXYMu[1][1] = 0.0; fReflSurfXYMu[1][2] = 0.0; + } + } fReflSurfXY[3][0] = 0.7071067811865475*(fReflSurfXYMu[1][0]+fReflSurfXYMu[0][0]); @@ -2093,8 +2259,6 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double fReflSurfXY[3][4] = 0.7071067811865475*(fReflSurfXYMu[1][2]+fReflSurfXYMu[0][2]); fReflSurfXY[3][5] = 0.7071067811865475*(fReflSurfXYMu[1][2]-1.0*fReflSurfXYMu[0][2]); - } - fRefl[0] = 0.7071067811865475*(fReflSurfXY[3][0]+fReflSurfXY[2][0]+fReflSurfXY[1][0]+fReflSurfXY[0][0]); fRefl[1] = 0.7071067811865475*(fReflSurfXY[3][0]+fReflSurfXY[2][0]-1.0*(fReflSurfXY[1][0]+fReflSurfXY[0][0])); fRefl[2] = 0.7071067811865475*(fReflSurfXY[3][0]-1.0*fReflSurfXY[2][0]+fReflSurfXY[1][0]-1.0*fReflSurfXY[0][0]); @@ -2144,3 +2308,707 @@ GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double fRefl[46] = 0.0; fRefl[47] = 0.0; } + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_lower_1x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out) +{ + double deltaphi_n = 0.5*(2.4494897427831783*phi_wall[1]-2.4494897427831783*phi[1]-1.4142135623730951*phi_wall[0]+1.4142135623730951*phi[0]); + double vcutsq_n[2] = {0.}; + + // node (mu)_0 + vcutsq_n[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n[1] = -q2Dm * deltaphi_n; + + vcutsq_out[0] = 0.7071067811865475*(vcutsq_n[1]+vcutsq_n[0]); + vcutsq_out[1] = 0.7071067811865475*(vcutsq_n[1]-1.0*vcutsq_n[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_upper_1x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out) +{ + double deltaphi_n = -(0.5*(2.4494897427831783*phi_wall[1]-2.4494897427831783*phi[1]+1.4142135623730951*phi_wall[0]-1.4142135623730951*phi[0])); + double vcutsq_n[2] = {0.}; + + // node (mu)_0 + vcutsq_n[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n[1] = -q2Dm * deltaphi_n; + + vcutsq_out[0] = 0.7071067811865475*(vcutsq_n[1]+vcutsq_n[0]); + vcutsq_out[1] = 0.7071067811865475*(vcutsq_n[1]-1.0*vcutsq_n[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_lower_2x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out) +{ + double deltaphi_n; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + + // node (x)_0 + deltaphi_n = -(0.5*(1.7320508075688772*phi_wall[3]-1.7320508075688772*(phi[3]+phi_wall[2])+1.7320508075688772*phi[2]-1.0*phi_wall[1]+phi[1]+phi_wall[0]-1.0*phi[0])); + + // node (mu)_0 + vcutsq_n_0[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_0[1] = -q2Dm * deltaphi_n; + + // node (x)_1 + deltaphi_n = 0.5*(1.7320508075688772*phi_wall[3]-1.7320508075688772*phi[3]+1.7320508075688772*phi_wall[2]-1.7320508075688772*phi[2]-1.0*phi_wall[1]+phi[1]-1.0*phi_wall[0]+phi[0]); + + // node (mu)_0 + vcutsq_n_1[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_1[1] = -q2Dm * deltaphi_n; + + vcutsq_out[0] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.5*(vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[2] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[3] = 0.5*(vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_1[0])+vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_upper_2x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out) +{ + double deltaphi_n; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + + // node (x)_0 + deltaphi_n = 0.5*(1.7320508075688772*phi_wall[3]-1.7320508075688772*(phi[3]+phi_wall[2])+1.7320508075688772*phi[2]+phi_wall[1]-1.0*(phi[1]+phi_wall[0])+phi[0]); + + // node (mu)_0 + vcutsq_n_0[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_0[1] = -q2Dm * deltaphi_n; + + // node (x)_1 + deltaphi_n = -(0.5*(1.7320508075688772*phi_wall[3]-1.7320508075688772*phi[3]+1.7320508075688772*phi_wall[2]-1.7320508075688772*phi[2]+phi_wall[1]-1.0*phi[1]+phi_wall[0]-1.0*phi[0])); + + // node (mu)_0 + vcutsq_n_1[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_1[1] = -q2Dm * deltaphi_n; + + vcutsq_out[0] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.5*(vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[2] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[3] = 0.5*(vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_1[0])+vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_lower_3x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out) +{ + double deltaphi_n; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + double vcutsq_n_2[2] = {0.}; + double vcutsq_n_3[2] = {0.}; + + // node (x,y)_0 + deltaphi_n = 0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*(phi[7]+phi_wall[6])+2.4494897427831783*phi[6]-2.4494897427831783*phi_wall[5]+2.4494897427831783*phi[5]-1.4142135623730951*phi_wall[4]+1.4142135623730951*phi[4]+2.4494897427831783*phi_wall[3]-2.4494897427831783*phi[3]+1.4142135623730951*phi_wall[2]-1.4142135623730951*phi[2]+1.4142135623730951*phi_wall[1]-1.4142135623730951*(phi[1]+phi_wall[0])+1.4142135623730951*phi[0]); + + // node (mu)_0 + vcutsq_n_0[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_0[1] = -q2Dm * deltaphi_n; + + // node (x,y)_1 + deltaphi_n = -(0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*(phi[7]+phi_wall[6])+2.4494897427831783*(phi[6]+phi_wall[5])-2.4494897427831783*phi[5]-1.4142135623730951*phi_wall[4]+1.4142135623730951*phi[4]-2.4494897427831783*phi_wall[3]+2.4494897427831783*phi[3]+1.4142135623730951*phi_wall[2]-1.4142135623730951*(phi[2]+phi_wall[1])+1.4142135623730951*(phi[1]+phi_wall[0])-1.4142135623730951*phi[0])); + + // node (mu)_0 + vcutsq_n_1[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_1[1] = -q2Dm * deltaphi_n; + + // node (x,y)_2 + deltaphi_n = -(0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*phi[7]+2.4494897427831783*phi_wall[6]-2.4494897427831783*(phi[6]+phi_wall[5])+2.4494897427831783*phi[5]-1.4142135623730951*phi_wall[4]+1.4142135623730951*phi[4]-2.4494897427831783*phi_wall[3]+2.4494897427831783*phi[3]-1.4142135623730951*phi_wall[2]+1.4142135623730951*(phi[2]+phi_wall[1])-1.4142135623730951*phi[1]+1.4142135623730951*phi_wall[0]-1.4142135623730951*phi[0])); + + // node (mu)_0 + vcutsq_n_2[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_2[1] = -q2Dm * deltaphi_n; + + // node (x,y)_3 + deltaphi_n = 0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*phi[7]+2.4494897427831783*phi_wall[6]-2.4494897427831783*phi[6]+2.4494897427831783*phi_wall[5]-2.4494897427831783*phi[5]-1.4142135623730951*phi_wall[4]+1.4142135623730951*phi[4]+2.4494897427831783*phi_wall[3]-2.4494897427831783*phi[3]-1.4142135623730951*phi_wall[2]+1.4142135623730951*phi[2]-1.4142135623730951*phi_wall[1]+1.4142135623730951*phi[1]-1.4142135623730951*phi_wall[0]+1.4142135623730951*phi[0]); + + // node (mu)_0 + vcutsq_n_3[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_3[1] = -q2Dm * deltaphi_n; + + vcutsq_out[0] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1])+vcutsq_n_3[0]+vcutsq_n_2[0]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[2] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[3] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[4] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*(vcutsq_n_2[0]+vcutsq_n_1[0])+vcutsq_n_0[0]); + vcutsq_out[5] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0])+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[6] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_3[0])+vcutsq_n_2[0]-1.0*vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[7] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]-1.0*vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_upper_3x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out) +{ + double deltaphi_n; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + double vcutsq_n_2[2] = {0.}; + double vcutsq_n_3[2] = {0.}; + + // node (x,y)_0 + deltaphi_n = -(0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*(phi[7]+phi_wall[6])+2.4494897427831783*phi[6]-2.4494897427831783*phi_wall[5]+2.4494897427831783*phi[5]+1.4142135623730951*phi_wall[4]-1.4142135623730951*phi[4]+2.4494897427831783*phi_wall[3]-2.4494897427831783*phi[3]-1.4142135623730951*phi_wall[2]+1.4142135623730951*phi[2]-1.4142135623730951*phi_wall[1]+1.4142135623730951*(phi[1]+phi_wall[0])-1.4142135623730951*phi[0])); + + // node (mu)_0 + vcutsq_n_0[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_0[1] = -q2Dm * deltaphi_n; + + // node (x,y)_1 + deltaphi_n = 0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*(phi[7]+phi_wall[6])+2.4494897427831783*(phi[6]+phi_wall[5])-2.4494897427831783*phi[5]+1.4142135623730951*phi_wall[4]-1.4142135623730951*phi[4]-2.4494897427831783*phi_wall[3]+2.4494897427831783*phi[3]-1.4142135623730951*phi_wall[2]+1.4142135623730951*(phi[2]+phi_wall[1])-1.4142135623730951*(phi[1]+phi_wall[0])+1.4142135623730951*phi[0]); + + // node (mu)_0 + vcutsq_n_1[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_1[1] = -q2Dm * deltaphi_n; + + // node (x,y)_2 + deltaphi_n = 0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*phi[7]+2.4494897427831783*phi_wall[6]-2.4494897427831783*(phi[6]+phi_wall[5])+2.4494897427831783*phi[5]+1.4142135623730951*phi_wall[4]-1.4142135623730951*phi[4]-2.4494897427831783*phi_wall[3]+2.4494897427831783*phi[3]+1.4142135623730951*phi_wall[2]-1.4142135623730951*(phi[2]+phi_wall[1])+1.4142135623730951*phi[1]-1.4142135623730951*phi_wall[0]+1.4142135623730951*phi[0]); + + // node (mu)_0 + vcutsq_n_2[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_2[1] = -q2Dm * deltaphi_n; + + // node (x,y)_3 + deltaphi_n = -(0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*phi[7]+2.4494897427831783*phi_wall[6]-2.4494897427831783*phi[6]+2.4494897427831783*phi_wall[5]-2.4494897427831783*phi[5]+1.4142135623730951*phi_wall[4]-1.4142135623730951*phi[4]+2.4494897427831783*phi_wall[3]-2.4494897427831783*phi[3]+1.4142135623730951*phi_wall[2]-1.4142135623730951*phi[2]+1.4142135623730951*phi_wall[1]-1.4142135623730951*phi[1]+1.4142135623730951*phi_wall[0]-1.4142135623730951*phi[0])); + + // node (mu)_0 + vcutsq_n_3[0] = -q2Dm * deltaphi_n; + + // node (mu)_1 + vcutsq_n_3[1] = -q2Dm * deltaphi_n; + + vcutsq_out[0] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1])+vcutsq_n_3[0]+vcutsq_n_2[0]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[2] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[3] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[4] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*(vcutsq_n_2[0]+vcutsq_n_1[0])+vcutsq_n_0[0]); + vcutsq_out[5] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0])+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[6] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_3[0])+vcutsq_n_2[0]-1.0*vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[7] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]-1.0*vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_lower_1x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) +{ + double temp_n = -(0.5*(2.4494897427831783*temperature[1]-1.4142135623730951*temperature[0])); + double bmag_n = -(0.5*(2.4494897427831783*bmag[1]-1.4142135623730951*bmag[0])); + double mu_ref = temp_n/bmag_n; + double vthSq = temp_n/GKYL_ELECTRON_MASS; + double mu; + double vcut; + double vcutsq_n[2] = {0.}; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n[1] = vcut*vcut * vthSq; + + vcutsq_out[0] = 0.7071067811865475*(vcutsq_n[1]+vcutsq_n[0]); + vcutsq_out[1] = 0.7071067811865475*(vcutsq_n[1]-1.0*vcutsq_n[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_upper_1x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) +{ + double temp_n = 0.5*(2.4494897427831783*temperature[1]+1.4142135623730951*temperature[0]); + double bmag_n = 0.5*(2.4494897427831783*bmag[1]+1.4142135623730951*bmag[0]); + double mu_ref = temp_n/bmag_n; + double vthSq = temp_n/GKYL_ELECTRON_MASS; + double mu; + double vcut; + double vcutsq_n[2] = {0.}; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n[1] = vcut*vcut * vthSq; + + vcutsq_out[0] = 0.7071067811865475*(vcutsq_n[1]+vcutsq_n[0]); + vcutsq_out[1] = 0.7071067811865475*(vcutsq_n[1]-1.0*vcutsq_n[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_lower_2x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) +{ + double temp_n; + double bmag_n; + double mu_ref; + double vthSq; + double mu; + double vcut; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + + // node (x)_0 + temp_n = 0.5*(1.7320508075688772*temperature[3]-1.7320508075688772*temperature[2]-1.0*temperature[1]+temperature[0]); + bmag_n = 0.5*(1.7320508075688772*bmag[3]-1.7320508075688772*bmag[2]-1.0*bmag[1]+bmag[0]); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[1] = vcut*vcut * vthSq; + + // node (x)_1 + temp_n = -(0.5*(1.7320508075688772*(temperature[3]+temperature[2])-1.0*(temperature[1]+temperature[0]))); + bmag_n = -(0.5*(1.7320508075688772*(bmag[3]+bmag[2])-1.0*(bmag[1]+bmag[0]))); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[1] = vcut*vcut * vthSq; + + vcutsq_out[0] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.5*(vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[2] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[3] = 0.5*(vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_1[0])+vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_upper_2x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) +{ + double temp_n; + double bmag_n; + double mu_ref; + double vthSq; + double mu; + double vcut; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + + // node (x)_0 + temp_n = -(0.5*(1.7320508075688772*temperature[3]-1.7320508075688772*temperature[2]+temperature[1]-1.0*temperature[0])); + bmag_n = -(0.5*(1.7320508075688772*bmag[3]-1.7320508075688772*bmag[2]+bmag[1]-1.0*bmag[0])); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[1] = vcut*vcut * vthSq; + + // node (x)_1 + temp_n = 0.5*(1.7320508075688772*(temperature[3]+temperature[2])+temperature[1]+temperature[0]); + bmag_n = 0.5*(1.7320508075688772*(bmag[3]+bmag[2])+bmag[1]+bmag[0]); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[1] = vcut*vcut * vthSq; + + vcutsq_out[0] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.5*(vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[2] = 0.5*(vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[3] = 0.5*(vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_1[0])+vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_lower_3x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) +{ + double temp_n; + double bmag_n; + double mu_ref; + double mu; + double vthSq; + double vcut; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + double vcutsq_n_2[2] = {0.}; + double vcutsq_n_3[2] = {0.}; + + // node (x,y)_0 + temp_n = -(0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*(temperature[6]+temperature[5])-1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]+1.4142135623730951*(temperature[2]+temperature[1])-1.4142135623730951*temperature[0])); + bmag_n = -(0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*(bmag[6]+bmag[5])-1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]+1.4142135623730951*(bmag[2]+bmag[1])-1.4142135623730951*bmag[0])); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[1] = vcut*vcut * vthSq; + + // node (x,y)_1 + temp_n = 0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*temperature[6]+2.4494897427831783*temperature[5]-1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]+1.4142135623730951*temperature[2]-1.4142135623730951*temperature[1]+1.4142135623730951*temperature[0]); + bmag_n = 0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*bmag[6]+2.4494897427831783*bmag[5]-1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]+1.4142135623730951*bmag[2]-1.4142135623730951*bmag[1]+1.4142135623730951*bmag[0]); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[1] = vcut*vcut * vthSq; + + // node (x,y)_2 + temp_n = 0.25*(2.4494897427831783*(temperature[7]+temperature[6])-2.4494897427831783*temperature[5]-1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]-1.4142135623730951*temperature[2]+1.4142135623730951*(temperature[1]+temperature[0])); + bmag_n = 0.25*(2.4494897427831783*(bmag[7]+bmag[6])-2.4494897427831783*bmag[5]-1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]-1.4142135623730951*bmag[2]+1.4142135623730951*(bmag[1]+bmag[0])); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+2*n_out, nn_out+2*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_2[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+2*n_out, nn_out+2*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_2[1] = vcut*vcut * vthSq; + + // node (x,y)_3 + temp_n = -(0.25*(2.4494897427831783*(temperature[7]+temperature[6]+temperature[5])-1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]-1.4142135623730951*(temperature[2]+temperature[1]+temperature[0]))); + bmag_n = -(0.25*(2.4494897427831783*(bmag[7]+bmag[6]+bmag[5])-1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]-1.4142135623730951*(bmag[2]+bmag[1]+bmag[0]))); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+3*n_out, nn_out+3*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_3[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+3*n_out, nn_out+3*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_3[1] = vcut*vcut * vthSq; + + vcutsq_out[0] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1])+vcutsq_n_3[0]+vcutsq_n_2[0]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[2] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[3] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[4] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*(vcutsq_n_2[0]+vcutsq_n_1[0])+vcutsq_n_0[0]); + vcutsq_out[5] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0])+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[6] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_3[0])+vcutsq_n_2[0]-1.0*vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[7] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]-1.0*vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_upper_3x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) +{ + double temp_n; + double bmag_n; + double mu_ref; + double mu; + double vthSq; + double vcut; + double vcutsq_n_0[2] = {0.}; + double vcutsq_n_1[2] = {0.}; + double vcutsq_n_2[2] = {0.}; + double vcutsq_n_3[2] = {0.}; + + // node (x,y)_0 + temp_n = 0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*(temperature[6]+temperature[5])+1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]-1.4142135623730951*(temperature[2]+temperature[1])+1.4142135623730951*temperature[0]); + bmag_n = 0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*(bmag[6]+bmag[5])+1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]-1.4142135623730951*(bmag[2]+bmag[1])+1.4142135623730951*bmag[0]); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+0*n_out, nn_out+0*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_0[1] = vcut*vcut * vthSq; + + // node (x,y)_1 + temp_n = -(0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*temperature[6]+2.4494897427831783*temperature[5]+1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]-1.4142135623730951*temperature[2]+1.4142135623730951*temperature[1]-1.4142135623730951*temperature[0])); + bmag_n = -(0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*bmag[6]+2.4494897427831783*bmag[5]+1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]-1.4142135623730951*bmag[2]+1.4142135623730951*bmag[1]-1.4142135623730951*bmag[0])); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+1*n_out, nn_out+1*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_1[1] = vcut*vcut * vthSq; + + // node (x,y)_2 + temp_n = -(0.25*(2.4494897427831783*(temperature[7]+temperature[6])-2.4494897427831783*temperature[5]+1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]+1.4142135623730951*temperature[2]-1.4142135623730951*(temperature[1]+temperature[0]))); + bmag_n = -(0.25*(2.4494897427831783*(bmag[7]+bmag[6])-2.4494897427831783*bmag[5]+1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]+1.4142135623730951*bmag[2]-1.4142135623730951*(bmag[1]+bmag[0]))); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+2*n_out, nn_out+2*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_2[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+2*n_out, nn_out+2*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_2[1] = vcut*vcut * vthSq; + + // node (x,y)_3 + temp_n = 0.25*(2.4494897427831783*(temperature[7]+temperature[6]+temperature[5])+1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]+1.4142135623730951*(temperature[2]+temperature[1]+temperature[0])); + bmag_n = 0.25*(2.4494897427831783*(bmag[7]+bmag[6]+bmag[5])+1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]+1.4142135623730951*(bmag[2]+bmag[1]+bmag[0])); + mu_ref = temp_n/bmag_n; + vthSq = temp_n/GKYL_ELECTRON_MASS; + + // node (mu)_0 + mu = 0.7071067811865475*vmap[2]-0.7071067811865475*vmap[3]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+3*n_out, nn_out+3*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_3[0] = vcut*vcut * vthSq; + + // node (mu)_1 + mu = 0.7071067811865475*vmap[3]+0.7071067811865475*vmap[2]; + bc_sheath_gyrokinetic_surr_interpf(nn_out+3*n_out, nn_out+3*n_out+n_out/2, n_out/2, &mu, 1, mu_ref, &vcut); + vcutsq_n_3[1] = vcut*vcut * vthSq; + + vcutsq_out[0] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[1] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1])+vcutsq_n_3[0]+vcutsq_n_2[0]-1.0*(vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[2] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); + vcutsq_out[3] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]+vcutsq_n_1[1]+vcutsq_n_0[1]-1.0*(vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]+vcutsq_n_0[0])); + vcutsq_out[4] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]+vcutsq_n_3[0]-1.0*(vcutsq_n_2[0]+vcutsq_n_1[0])+vcutsq_n_0[0]); + vcutsq_out[5] = 0.3535533905932737*(vcutsq_n_3[1]+vcutsq_n_2[1]-1.0*(vcutsq_n_1[1]+vcutsq_n_0[1]+vcutsq_n_3[0]+vcutsq_n_2[0])+vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[6] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*vcutsq_n_2[1]+vcutsq_n_1[1]-1.0*(vcutsq_n_0[1]+vcutsq_n_3[0])+vcutsq_n_2[0]-1.0*vcutsq_n_1[0]+vcutsq_n_0[0]); + vcutsq_out[7] = 0.3535533905932737*(vcutsq_n_3[1]-1.0*(vcutsq_n_2[1]+vcutsq_n_1[1])+vcutsq_n_0[1]-1.0*vcutsq_n_3[0]+vcutsq_n_2[0]+vcutsq_n_1[0]-1.0*vcutsq_n_0[0]); +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_lower_1x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) +{ + double phi_n = -(0.5*(2.4494897427831783*phi[1]-1.4142135623730951*phi[0])); + double phi_wall_n = -(0.5*(2.4494897427831783*phi_wall[1]-1.4142135623730951*phi_wall[0])); + double dens_n = -(0.5*(2.4494897427831783*density[1]-1.4142135623730951*density[0])); + double temp_n = -(0.5*(2.4494897427831783*temperature[1]-1.4142135623730951*temperature[0])); + double bmag_n = -(0.5*(2.4494897427831783*bmag[1]-1.4142135623730951*bmag[0])); + double angle_n = bimpact_angle[0]; + + nn_inp_out[0+n_inp*0] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*0] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*0] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_upper_1x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) +{ + double phi_n = 0.5*(2.4494897427831783*phi[1]+1.4142135623730951*phi[0]); + double phi_wall_n = 0.5*(2.4494897427831783*phi_wall[1]+1.4142135623730951*phi_wall[0]); + double dens_n = 0.5*(2.4494897427831783*density[1]+1.4142135623730951*density[0]); + double temp_n = 0.5*(2.4494897427831783*temperature[1]+1.4142135623730951*temperature[0]); + double bmag_n = 0.5*(2.4494897427831783*bmag[1]+1.4142135623730951*bmag[0]); + double angle_n = bimpact_angle[0]; + + nn_inp_out[0+n_inp*0] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*0] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*0] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_lower_2x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) +{ + double phi_n, phi_wall_n, dens_n, temp_n, bmag_n, angle_n; + + // node (x)_0 + phi_n = 0.5*(1.7320508075688772*phi[3]-1.7320508075688772*phi[2]-1.0*phi[1]+phi[0]); + phi_wall_n = 0.5*(1.7320508075688772*phi_wall[3]-1.7320508075688772*phi_wall[2]-1.0*phi_wall[1]+phi_wall[0]); + dens_n = 0.5*(1.7320508075688772*density[3]-1.7320508075688772*density[2]-1.0*density[1]+density[0]); + temp_n = 0.5*(1.7320508075688772*temperature[3]-1.7320508075688772*temperature[2]-1.0*temperature[1]+temperature[0]); + bmag_n = 0.5*(1.7320508075688772*bmag[3]-1.7320508075688772*bmag[2]-1.0*bmag[1]+bmag[0]); + angle_n = -(0.5*(1.4142135623730951*bimpact_angle[1]-1.4142135623730951*bimpact_angle[0])); + nn_inp_out[0+n_inp*0] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*0] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*0] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x)_1 + phi_n = -(0.5*(1.7320508075688772*(phi[3]+phi[2])-1.0*(phi[1]+phi[0]))); + phi_wall_n = -(0.5*(1.7320508075688772*(phi_wall[3]+phi_wall[2])-1.0*(phi_wall[1]+phi_wall[0]))); + dens_n = -(0.5*(1.7320508075688772*(density[3]+density[2])-1.0*(density[1]+density[0]))); + temp_n = -(0.5*(1.7320508075688772*(temperature[3]+temperature[2])-1.0*(temperature[1]+temperature[0]))); + bmag_n = -(0.5*(1.7320508075688772*(bmag[3]+bmag[2])-1.0*(bmag[1]+bmag[0]))); + angle_n = 0.7071067811865476*(bimpact_angle[1]+bimpact_angle[0]); + nn_inp_out[0+n_inp*1] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*1] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*1] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_upper_2x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) +{ + double phi_n, phi_wall_n, dens_n, temp_n, bmag_n, angle_n; + + // node (x)_0 + phi_n = -(0.5*(1.7320508075688772*phi[3]-1.7320508075688772*phi[2]+phi[1]-1.0*phi[0])); + phi_wall_n = -(0.5*(1.7320508075688772*phi_wall[3]-1.7320508075688772*phi_wall[2]+phi_wall[1]-1.0*phi_wall[0])); + dens_n = -(0.5*(1.7320508075688772*density[3]-1.7320508075688772*density[2]+density[1]-1.0*density[0])); + temp_n = -(0.5*(1.7320508075688772*temperature[3]-1.7320508075688772*temperature[2]+temperature[1]-1.0*temperature[0])); + bmag_n = -(0.5*(1.7320508075688772*bmag[3]-1.7320508075688772*bmag[2]+bmag[1]-1.0*bmag[0])); + angle_n = -(0.5*(1.4142135623730951*bimpact_angle[1]-1.4142135623730951*bimpact_angle[0])); + nn_inp_out[0+n_inp*0] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*0] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*0] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x)_1 + phi_n = 0.5*(1.7320508075688772*(phi[3]+phi[2])+phi[1]+phi[0]); + phi_wall_n = 0.5*(1.7320508075688772*(phi_wall[3]+phi_wall[2])+phi_wall[1]+phi_wall[0]); + dens_n = 0.5*(1.7320508075688772*(density[3]+density[2])+density[1]+density[0]); + temp_n = 0.5*(1.7320508075688772*(temperature[3]+temperature[2])+temperature[1]+temperature[0]); + bmag_n = 0.5*(1.7320508075688772*(bmag[3]+bmag[2])+bmag[1]+bmag[0]); + angle_n = 0.7071067811865476*(bimpact_angle[1]+bimpact_angle[0]); + nn_inp_out[0+n_inp*1] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*1] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*1] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_lower_3x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) +{ + double phi_n, phi_wall_n, dens_n, temp_n, bmag_n, angle_n; + + // node (x,y)_0 + phi_n = -(0.25*(2.4494897427831783*phi[7]-2.4494897427831783*(phi[6]+phi[5])-1.4142135623730951*phi[4]+2.4494897427831783*phi[3]+1.4142135623730951*(phi[2]+phi[1])-1.4142135623730951*phi[0])); + phi_wall_n = -(0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*(phi_wall[6]+phi_wall[5])-1.4142135623730951*phi_wall[4]+2.4494897427831783*phi_wall[3]+1.4142135623730951*(phi_wall[2]+phi_wall[1])-1.4142135623730951*phi_wall[0])); + dens_n = -(0.25*(2.4494897427831783*density[7]-2.4494897427831783*(density[6]+density[5])-1.4142135623730951*density[4]+2.4494897427831783*density[3]+1.4142135623730951*(density[2]+density[1])-1.4142135623730951*density[0])); + temp_n = -(0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*(temperature[6]+temperature[5])-1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]+1.4142135623730951*(temperature[2]+temperature[1])-1.4142135623730951*temperature[0])); + bmag_n = -(0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*(bmag[6]+bmag[5])-1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]+1.4142135623730951*(bmag[2]+bmag[1])-1.4142135623730951*bmag[0])); + angle_n = 0.5*(bimpact_angle[3]-1.0*(bimpact_angle[2]+bimpact_angle[1])+bimpact_angle[0]); + nn_inp_out[0+n_inp*0] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*0] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*0] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x,y)_1 + phi_n = 0.25*(2.4494897427831783*phi[7]-2.4494897427831783*phi[6]+2.4494897427831783*phi[5]-1.4142135623730951*phi[4]-2.4494897427831783*phi[3]+1.4142135623730951*phi[2]-1.4142135623730951*phi[1]+1.4142135623730951*phi[0]); + phi_wall_n = 0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*phi_wall[6]+2.4494897427831783*phi_wall[5]-1.4142135623730951*phi_wall[4]-2.4494897427831783*phi_wall[3]+1.4142135623730951*phi_wall[2]-1.4142135623730951*phi_wall[1]+1.4142135623730951*phi_wall[0]); + dens_n = 0.25*(2.4494897427831783*density[7]-2.4494897427831783*density[6]+2.4494897427831783*density[5]-1.4142135623730951*density[4]-2.4494897427831783*density[3]+1.4142135623730951*density[2]-1.4142135623730951*density[1]+1.4142135623730951*density[0]); + temp_n = 0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*temperature[6]+2.4494897427831783*temperature[5]-1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]+1.4142135623730951*temperature[2]-1.4142135623730951*temperature[1]+1.4142135623730951*temperature[0]); + bmag_n = 0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*bmag[6]+2.4494897427831783*bmag[5]-1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]+1.4142135623730951*bmag[2]-1.4142135623730951*bmag[1]+1.4142135623730951*bmag[0]); + angle_n = -(0.5*(bimpact_angle[3]-1.0*bimpact_angle[2]+bimpact_angle[1]-1.0*bimpact_angle[0])); + nn_inp_out[0+n_inp*1] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*1] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*1] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x,y)_2 + phi_n = 0.25*(2.4494897427831783*(phi[7]+phi[6])-2.4494897427831783*phi[5]-1.4142135623730951*phi[4]-2.4494897427831783*phi[3]-1.4142135623730951*phi[2]+1.4142135623730951*(phi[1]+phi[0])); + phi_wall_n = 0.25*(2.4494897427831783*(phi_wall[7]+phi_wall[6])-2.4494897427831783*phi_wall[5]-1.4142135623730951*phi_wall[4]-2.4494897427831783*phi_wall[3]-1.4142135623730951*phi_wall[2]+1.4142135623730951*(phi_wall[1]+phi_wall[0])); + dens_n = 0.25*(2.4494897427831783*(density[7]+density[6])-2.4494897427831783*density[5]-1.4142135623730951*density[4]-2.4494897427831783*density[3]-1.4142135623730951*density[2]+1.4142135623730951*(density[1]+density[0])); + temp_n = 0.25*(2.4494897427831783*(temperature[7]+temperature[6])-2.4494897427831783*temperature[5]-1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]-1.4142135623730951*temperature[2]+1.4142135623730951*(temperature[1]+temperature[0])); + bmag_n = 0.25*(2.4494897427831783*(bmag[7]+bmag[6])-2.4494897427831783*bmag[5]-1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]-1.4142135623730951*bmag[2]+1.4142135623730951*(bmag[1]+bmag[0])); + angle_n = -(0.5*(bimpact_angle[3]+bimpact_angle[2]-1.0*(bimpact_angle[1]+bimpact_angle[0]))); + nn_inp_out[0+n_inp*2] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*2] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*2] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x,y)_3 + phi_n = -(0.25*(2.4494897427831783*(phi[7]+phi[6]+phi[5])-1.4142135623730951*phi[4]+2.4494897427831783*phi[3]-1.4142135623730951*(phi[2]+phi[1]+phi[0]))); + phi_wall_n = -(0.25*(2.4494897427831783*(phi_wall[7]+phi_wall[6]+phi_wall[5])-1.4142135623730951*phi_wall[4]+2.4494897427831783*phi_wall[3]-1.4142135623730951*(phi_wall[2]+phi_wall[1]+phi_wall[0]))); + dens_n = -(0.25*(2.4494897427831783*(density[7]+density[6]+density[5])-1.4142135623730951*density[4]+2.4494897427831783*density[3]-1.4142135623730951*(density[2]+density[1]+density[0]))); + temp_n = -(0.25*(2.4494897427831783*(temperature[7]+temperature[6]+temperature[5])-1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]-1.4142135623730951*(temperature[2]+temperature[1]+temperature[0]))); + bmag_n = -(0.25*(2.4494897427831783*(bmag[7]+bmag[6]+bmag[5])-1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]-1.4142135623730951*(bmag[2]+bmag[1]+bmag[0]))); + angle_n = 0.5*(bimpact_angle[3]+bimpact_angle[2]+bimpact_angle[1]+bimpact_angle[0]); + nn_inp_out[0+n_inp*3] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*3] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*3] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + +} + +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_upper_3x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) +{ + double phi_n, phi_wall_n, dens_n, temp_n, bmag_n, angle_n; + + // node (x,y)_0 + phi_n = 0.25*(2.4494897427831783*phi[7]-2.4494897427831783*(phi[6]+phi[5])+1.4142135623730951*phi[4]+2.4494897427831783*phi[3]-1.4142135623730951*(phi[2]+phi[1])+1.4142135623730951*phi[0]); + phi_wall_n = 0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*(phi_wall[6]+phi_wall[5])+1.4142135623730951*phi_wall[4]+2.4494897427831783*phi_wall[3]-1.4142135623730951*(phi_wall[2]+phi_wall[1])+1.4142135623730951*phi_wall[0]); + dens_n = 0.25*(2.4494897427831783*density[7]-2.4494897427831783*(density[6]+density[5])+1.4142135623730951*density[4]+2.4494897427831783*density[3]-1.4142135623730951*(density[2]+density[1])+1.4142135623730951*density[0]); + temp_n = 0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*(temperature[6]+temperature[5])+1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]-1.4142135623730951*(temperature[2]+temperature[1])+1.4142135623730951*temperature[0]); + bmag_n = 0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*(bmag[6]+bmag[5])+1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]-1.4142135623730951*(bmag[2]+bmag[1])+1.4142135623730951*bmag[0]); + angle_n = 0.5*(bimpact_angle[3]-1.0*(bimpact_angle[2]+bimpact_angle[1])+bimpact_angle[0]); + nn_inp_out[0+n_inp*0] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*0] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*0] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x,y)_1 + phi_n = -(0.25*(2.4494897427831783*phi[7]-2.4494897427831783*phi[6]+2.4494897427831783*phi[5]+1.4142135623730951*phi[4]-2.4494897427831783*phi[3]-1.4142135623730951*phi[2]+1.4142135623730951*phi[1]-1.4142135623730951*phi[0])); + phi_wall_n = -(0.25*(2.4494897427831783*phi_wall[7]-2.4494897427831783*phi_wall[6]+2.4494897427831783*phi_wall[5]+1.4142135623730951*phi_wall[4]-2.4494897427831783*phi_wall[3]-1.4142135623730951*phi_wall[2]+1.4142135623730951*phi_wall[1]-1.4142135623730951*phi_wall[0])); + dens_n = -(0.25*(2.4494897427831783*density[7]-2.4494897427831783*density[6]+2.4494897427831783*density[5]+1.4142135623730951*density[4]-2.4494897427831783*density[3]-1.4142135623730951*density[2]+1.4142135623730951*density[1]-1.4142135623730951*density[0])); + temp_n = -(0.25*(2.4494897427831783*temperature[7]-2.4494897427831783*temperature[6]+2.4494897427831783*temperature[5]+1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]-1.4142135623730951*temperature[2]+1.4142135623730951*temperature[1]-1.4142135623730951*temperature[0])); + bmag_n = -(0.25*(2.4494897427831783*bmag[7]-2.4494897427831783*bmag[6]+2.4494897427831783*bmag[5]+1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]-1.4142135623730951*bmag[2]+1.4142135623730951*bmag[1]-1.4142135623730951*bmag[0])); + angle_n = -(0.5*(bimpact_angle[3]-1.0*bimpact_angle[2]+bimpact_angle[1]-1.0*bimpact_angle[0])); + nn_inp_out[0+n_inp*1] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*1] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*1] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x,y)_2 + phi_n = -(0.25*(2.4494897427831783*(phi[7]+phi[6])-2.4494897427831783*phi[5]+1.4142135623730951*phi[4]-2.4494897427831783*phi[3]+1.4142135623730951*phi[2]-1.4142135623730951*(phi[1]+phi[0]))); + phi_wall_n = -(0.25*(2.4494897427831783*(phi_wall[7]+phi_wall[6])-2.4494897427831783*phi_wall[5]+1.4142135623730951*phi_wall[4]-2.4494897427831783*phi_wall[3]+1.4142135623730951*phi_wall[2]-1.4142135623730951*(phi_wall[1]+phi_wall[0]))); + dens_n = -(0.25*(2.4494897427831783*(density[7]+density[6])-2.4494897427831783*density[5]+1.4142135623730951*density[4]-2.4494897427831783*density[3]+1.4142135623730951*density[2]-1.4142135623730951*(density[1]+density[0]))); + temp_n = -(0.25*(2.4494897427831783*(temperature[7]+temperature[6])-2.4494897427831783*temperature[5]+1.4142135623730951*temperature[4]-2.4494897427831783*temperature[3]+1.4142135623730951*temperature[2]-1.4142135623730951*(temperature[1]+temperature[0]))); + bmag_n = -(0.25*(2.4494897427831783*(bmag[7]+bmag[6])-2.4494897427831783*bmag[5]+1.4142135623730951*bmag[4]-2.4494897427831783*bmag[3]+1.4142135623730951*bmag[2]-1.4142135623730951*(bmag[1]+bmag[0]))); + angle_n = -(0.5*(bimpact_angle[3]+bimpact_angle[2]-1.0*(bimpact_angle[1]+bimpact_angle[0]))); + nn_inp_out[0+n_inp*2] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*2] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*2] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + + // node (x,y)_3 + phi_n = 0.25*(2.4494897427831783*(phi[7]+phi[6]+phi[5])+1.4142135623730951*phi[4]+2.4494897427831783*phi[3]+1.4142135623730951*(phi[2]+phi[1]+phi[0])); + phi_wall_n = 0.25*(2.4494897427831783*(phi_wall[7]+phi_wall[6]+phi_wall[5])+1.4142135623730951*phi_wall[4]+2.4494897427831783*phi_wall[3]+1.4142135623730951*(phi_wall[2]+phi_wall[1]+phi_wall[0])); + dens_n = 0.25*(2.4494897427831783*(density[7]+density[6]+density[5])+1.4142135623730951*density[4]+2.4494897427831783*density[3]+1.4142135623730951*(density[2]+density[1]+density[0])); + temp_n = 0.25*(2.4494897427831783*(temperature[7]+temperature[6]+temperature[5])+1.4142135623730951*temperature[4]+2.4494897427831783*temperature[3]+1.4142135623730951*(temperature[2]+temperature[1]+temperature[0])); + bmag_n = 0.25*(2.4494897427831783*(bmag[7]+bmag[6]+bmag[5])+1.4142135623730951*bmag[4]+2.4494897427831783*bmag[3]+1.4142135623730951*(bmag[2]+bmag[1]+bmag[0])); + angle_n = 0.5*(bimpact_angle[3]+bimpact_angle[2]+bimpact_angle[1]+bimpact_angle[0]); + nn_inp_out[0+n_inp*3] = (float)(angle_n*(180.0/GKYL_PI)); + nn_inp_out[1+n_inp*3] = (float)((1.0/bmag_n)*sqrt(GKYL_ELECTRON_MASS*fmax(0.0, dens_n)/GKYL_EPSILON0)); + nn_inp_out[2+n_inp*3] = (float)(fmax(0.0, (GKYL_ELEMENTARY_CHARGE*(phi_n-phi_wall_n))/temp_n)); + +} diff --git a/gyrokinetic/ker/bc_sheath_gyrokinetic/gkyl_bc_sheath_gyrokinetic_kernels.h b/gyrokinetic/ker/bc_sheath_gyrokinetic/gkyl_bc_sheath_gyrokinetic_kernels.h index 0242c3411d..7ef80783a8 100644 --- a/gyrokinetic/ker/bc_sheath_gyrokinetic/gkyl_bc_sheath_gyrokinetic_kernels.h +++ b/gyrokinetic/ker/bc_sheath_gyrokinetic/gkyl_bc_sheath_gyrokinetic_kernels.h @@ -1,5 +1,7 @@ #pragma once +#include +#include #include #include @@ -10,16 +12,57 @@ static inline double invL(double x) { return (3.*x-x*x*x*(6. + x*x - 2.*x*x*x*x)/5.)/(1.-x*x); } +// Linear interpolation of the surrogate output vcut[ng] (defined on the mu-grid +// mu_grid[ng], which the surrogate model supplies as the second half of each +// node's output block) onto mu_new[n], normalising mu by mu_ref (= T/B). Results +// are written into out[n]; clamps at the grid boundaries. +GKYL_CU_DH +static inline void +bc_sheath_gyrokinetic_surr_interpf(const float *vcut, const float *mu_grid, int ng, const double *mu_new, int n, double mu_ref, double *out) +{ + for (int i = 0; i < n; i++) { + double mu = mu_new[i]/mu_ref; + if (mu <= mu_grid[0]) { out[i] = vcut[0]; continue; } + if (mu >= mu_grid[ng - 1]) { out[i] = vcut[ng - 1]; continue; } + // binary search for the bracketing interval + int lo = 0, hi = ng - 1; + while (hi - lo > 1) { + int mid = (lo + hi) >> 1; + if (mu_grid[mid] <= mu) lo = mid; else hi = mid; + } + double t = (mu - mu_grid[lo]) / (mu_grid[hi] - mu_grid[lo]); + out[i] = vcut[lo] + t * (vcut[hi] - vcut[lo]); + } +} + EXTERN_C_BEG -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); -GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double *vmap, const double q2Dm, const double *phi, const double *phiWall, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x1v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x1v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_1x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_1x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_2x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_2x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_lower_3x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_reflectedf_upper_3x2v_ser_p1(const double *vmap, const double *vcutsq, const double *f, double *fRefl); +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_lower_1x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutSq_n) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_upper_1x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutSq_n) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_lower_2x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutSq_n) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_upper_2x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutSq_n) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_lower_3x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutSq_n) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_const_upper_3x2v_ser_p1(const double *phi, const double *phi_wall, double q2Dm, double *vcutSq_n) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_lower_1x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_upper_1x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_lower_2x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_upper_2x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_lower_3x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_vcutsq_surr_upper_3x2v_ser_p1(const double *vmap, const float *nn_out, int n_out, const double *temperature, const double *bmag, double *vcutsq_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_lower_1x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_upper_1x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_lower_2x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_upper_2x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_lower_3x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) ; +GKYL_CU_DH void bc_sheath_gyrokinetic_build_input_upper_3x2v_ser_p1(const double *phi, const double *phi_wall, const double *density, const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *nn_inp_out) ; EXTERN_C_END diff --git a/gyrokinetic/luareg/rt_gk_li_react_3x2v_p1.lua b/gyrokinetic/luareg/rt_gk_li_react_3x2v_p1.lua index ad9b35b8c9..df0cc6f637 100644 --- a/gyrokinetic/luareg/rt_gk_li_react_3x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_li_react_3x2v_p1.lua @@ -287,8 +287,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -411,8 +411,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -557,8 +557,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -703,8 +703,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_li_react_nonuniformv_3x2v_p1.lua b/gyrokinetic/luareg/rt_gk_li_react_nonuniformv_3x2v_p1.lua index 0b532964f7..e1d2867b01 100644 --- a/gyrokinetic/luareg/rt_gk_li_react_nonuniformv_3x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_li_react_nonuniformv_3x2v_p1.lua @@ -306,8 +306,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -430,8 +430,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -576,8 +576,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -722,8 +722,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_1x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_1x2v_p1.lua index f23aa2b28d..9c5ffe83d8 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_1x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_1x2v_p1.lua @@ -194,8 +194,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -284,8 +284,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_2x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_2x2v_p1.lua index 226c7a55b4..bd662dc4a7 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_2x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_2x2v_p1.lua @@ -240,8 +240,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -368,8 +368,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_3x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_3x2v_p1.lua index f774e17108..176520af35 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_3x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_3x2v_p1.lua @@ -238,8 +238,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -362,8 +362,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_bgk_1x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_bgk_1x2v_p1.lua index a4c8071128..ef5f2b4c11 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_bgk_1x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_bgk_1x2v_p1.lua @@ -191,8 +191,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -278,8 +278,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_1x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_1x2v_p1.lua index ad74eb55c3..8987beece2 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_1x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_1x2v_p1.lua @@ -213,8 +213,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -322,8 +322,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_2x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_2x2v_p1.lua index fb8d5c87d1..236265abe7 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_2x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_2x2v_p1.lua @@ -255,8 +255,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -398,8 +398,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_3x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_3x2v_p1.lua index aa436f1b90..63854f1470 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_3x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_nonuniformv_3x2v_p1.lua @@ -257,8 +257,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -400,8 +400,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_1x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_1x2v_p1.lua index 7ba90899bf..c5fdf6476d 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_1x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_1x2v_p1.lua @@ -224,8 +224,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -314,8 +314,8 @@ gyrokineticApp = Gyrokinetic.App.new { }, bcs = { - { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_2x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_2x2v_p1.lua index 3144ee4df2..d669eae83b 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_2x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_2x2v_p1.lua @@ -267,8 +267,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -392,8 +392,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 1, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 1, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_3x2v_p1.lua b/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_3x2v_p1.lua index 8d62cdc261..8dd268c155 100644 --- a/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_3x2v_p1.lua +++ b/gyrokinetic/luareg/rt_gk_sheath_nonuniformx_3x2v_p1.lua @@ -268,8 +268,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? @@ -392,8 +392,8 @@ gyrokineticApp = Gyrokinetic.App.new { bcs = { { dir = 0, edge = 0, type = G0.GyrokineticBc.speciesZeroFlux }, { dir = 0, edge = 1, type = G0.GyrokineticBc.speciesZeroFlux }, - { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheath }, - { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheath }, + { dir = 2, edge = 0, type = G0.GyrokineticBc.speciesSheathConducting }, + { dir = 2, edge = 1, type = G0.GyrokineticBc.speciesSheathConducting }, }, evolve = true, -- Evolve species? diff --git a/gyrokinetic/unit/ctest_bc_sheath_gyrokinetic.c b/gyrokinetic/unit/ctest_bc_sheath_gyrokinetic.c index bc9239dd23..bfbc4e9e34 100644 --- a/gyrokinetic/unit/ctest_bc_sheath_gyrokinetic.c +++ b/gyrokinetic/unit/ctest_bc_sheath_gyrokinetic.c @@ -1,6 +1,19 @@ -// Test creation and deallocation of updater that applies the -// conducting sheath BC for gyrokinetics. -// +/* This is the unit test for the sheath BC updater. + * The test does the following: + * 1. Initializes the sheath BC updater with a given configuration space dimension, edge. + * 2. Project a maxwellian distribution function with input parameters to the edge of the domain (skin cells). + * 3. Apply the sheath BC updater to the distribution function. + * 4. Check the ghost values of the distribution function (where the result of the sheath BC is stored). + * We check that the reflected function is zero in cells that are fully outside the cutoff + * and non zero in cells that are fully inside. You can check these numbers by setting pars.verbose to true. + * 5. Deallocate memory used by the updater. + * * This is done for each configuration space dimension (1x2v, 2x2v, 3x2v), for both lower and upper edge, and + * positive, negative potential, for electrons and ions. + * * The test is also able to verify the interface of the surrogate model for the sheath BC by setting + * pars.use_surrogate to true. In this case the check uses the surrogate directly to obtain the vcutsq. + * * Finally, one can set write_fields to true to write the distribution function and visualize it with postgkyl. + * */ + #include #include @@ -11,7 +24,15 @@ #include #include #include +#include #include +#include +#include + +// Path to the KANN surrogate model used in surrogate tests. +// Set to NULL (or set surr_test_enabled = false) to skip surrogate tests. +static const char *surr_model_path = "gyrokinetic/data/nn_model/nn_model_sheath_bc_conv_MPE.kann"; +static const bool surr_test_enabled = true; static struct gkyl_array* mkarr(bool use_gpu, long nc, long size) @@ -25,110 +46,163 @@ mkarr(bool use_gpu, long nc, long size) } struct test_sheath_ctx { + struct gkyl_kann_net *model; // KANN surrogate model for sheath BC. + int cdim; // Configuration space dimension. double lower[GKYL_MAX_DIM], upper[GKYL_MAX_DIM]; // Grid extents. int cells[GKYL_MAX_DIM]; // Number of cells. + double mass; // Species mass. + double charge; // Species charge. + double dens; // Reference density. double upar; // Mean parallel drift speed. + double temp; // Reference temperature. double B0; // Reference magnetic field. - double vt; // Reference thermal speed. - double mass; // Species mass. + double phi_mpe; // ES potential at the sheath entrance. + double phi_wall; // ES potential at the wall. + double impact_angle; // Angle [rad] of incidence if B to the plate (for surrogate sheath). double x0; // x-center double y0; // y-center double z0; // z-center double sigmax; // Width of distribution in x. double sigmay; // Width of distribution in y. double sigmaz; // Width of distribution in z. + bool use_surrogate; // Whether to use surrogate model for vcutsq. + const char *surrogate_model_path; // Path to the .kann model file (NULL if not using surrogate). + bool verbose; // Whether to print detailed output. }; +void +surr_interpf(const float *vcut, const double *mu_new, int n, double mu_ref, double *out) +{ + const double mu_grid[20] = { + 0.00, 0.02, 0.08, 0.18, 0.32, 0.50, 0.72, 0.98, 1.28, 1.62, + 2.00, 2.42, 2.88, 3.38, 3.92, 4.50, 5.12, 5.78, 6.48, 7.22}; + const int ng = 20; + for (int i = 0; i < n; i++) { + double mu = mu_new[i]/mu_ref; + if (mu <= mu_grid[0]) { out[i] = vcut[0]; continue; } + if (mu >= mu_grid[ng - 1]) { out[i] = vcut[ng - 1]; continue; } + // binary search for the bracketing interval + int lo = 0, hi = ng - 1; + while (hi - lo > 1) { + int mid = (lo + hi) >> 1; + if (mu_grid[mid] <= mu) lo = mid; else hi = mid; + } + double t = (mu - mu_grid[lo]) / (mu_grid[hi] - mu_grid[lo]); + out[i] = vcut[lo] + t * (vcut[hi] - vcut[lo]); + } +} + +void +eval_func_vcutsq(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) +{ + struct test_sheath_ctx *pars = ctx; + double mu = xn[pars->cdim-1]; // Mu is the last configuration/velocity dimension mapped. + + if (pars->use_surrogate) { + float alphadeg = pars->impact_angle * 180.0 / GKYL_PI; + float gamma = sqrt(pars->mass * fmax(pars->dens,0.0) / GKYL_EPSILON0) / pars->B0; + float phi = -pars->charge * (pars->phi_mpe - pars->phi_wall) / pars->temp; + struct gkyl_kn_vec *inp = gkyl_kn_vec_new(1,3); + inp->vals[0][0] = alphadeg; + inp->vals[0][1] = gamma; + inp->vals[0][2] = phi; + struct gkyl_kn_vec *out = gkyl_kn_vec_new(1,20); + gkyl_kann_net_apply(pars->model, inp, out); + + // Interp the output of the surrogate to get vcutsq corresponding to input mu. + double mu_ref = pars->temp / pars->B0; // Normalization for mu used in surrogate training. + double vcut_norm = 0.0; + surr_interpf(out->data, &mu, 1, mu_ref, &vcut_norm); + + double vt_sq = pars->temp / pars->mass; + fout[0] = (vcut_norm * vcut_norm) * vt_sq; + + // Clean up temporary neural net vectors to prevent severe memory leaks + gkyl_kn_vec_release(inp); + gkyl_kn_vec_release(out); + + } else { + // Physical analytical calculation of vcutsq = 2 * q * delta_phi / m + double delta_phi = pars->phi_mpe - pars->phi_wall; + double vcutsq_0 = fmax(0.0, -2.0 * pars->charge * delta_phi / pars->mass); + double Lmu = pars->temp / pars->B0; + if (Lmu == 0.0) Lmu = 1.0; + + // Smooth mu variation to test mu-dependent evaluation machinery + fout[0] = vcutsq_0 * (1.0 + 0.1 * exp(-mu / Lmu)); + } +} + void eval_func_1x2v(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) { - double vpar = xn[1], mu = xn[2]; double z = xn[0]; - + double vpar = xn[1], mu = xn[2]; struct test_sheath_ctx *pars = ctx; - double vt = pars->vt; double B0 = pars->B0; double m = pars->mass; double upar = pars->upar; - double z0 = pars->z0; - double sigmaz = pars->sigmaz; + double T = pars->temp; - double envelope = exp( -pow(z-z0,2)/(2.0*pow(sigmaz,2)) ); - fout[0] = exp( -(pow(vpar-upar,2) + 2.0*mu*B0/m) /(2.0*pow(vt,2)) ) * envelope + 0.1; + double envelope = 1; + fout[0] = exp( -(m*pow(vpar-upar,2)/2.0 + mu*B0) / T ) * envelope; } void eval_func_2x2v(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) { - double vpar = xn[2], mu = xn[3]; double x = xn[0], z = xn[1]; - + double vpar = xn[2], mu = xn[3]; struct test_sheath_ctx *pars = ctx; - double vt = pars->vt; double B0 = pars->B0; double m = pars->mass; double upar = pars->upar; - double x0 = pars->x0; - double z0 = pars->z0; - double sigmax = pars->sigmax; - double sigmaz = pars->sigmaz; + double T = pars->temp; - double envelope = exp( -pow(x-x0,2)/(2.0*pow(sigmax,2)) ) * exp( -pow(z-z0,2)/(2.0*pow(sigmaz,2)) ); - fout[0] = exp( -(pow(vpar-upar,2) + 2.0*mu*B0/m) /(2.0*pow(vt,2)) ) * envelope + 0.1; + double envelope = 1; + fout[0] = exp( -(m*pow(vpar-upar,2)/2.0 + mu*B0) / T ) * envelope; } void eval_func_3x2v(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) { - double vpar = xn[3], mu = xn[4]; double x = xn[0], y = xn[1], z = xn[2]; - + double vpar = xn[3], mu = xn[4]; struct test_sheath_ctx *pars = ctx; - double vt = pars->vt; double B0 = pars->B0; double m = pars->mass; double upar = pars->upar; - double x0 = pars->x0; - double y0 = pars->y0; - double z0 = pars->z0; - double sigmax = pars->sigmax; - double sigmay = pars->sigmay; - double sigmaz = pars->sigmaz; - - double envelope = exp( -pow(x-x0,2)/(2.0*pow(sigmax,2)) ) * exp( -pow(y-y0,2)/(2.0*pow(sigmay,2)) ) * exp( -pow(z-z0,2)/(2.0*pow(sigmaz,2)) ); - fout[0] = exp( -(pow(vpar-upar,2) + 2.0*mu*B0/m) /(2.0*pow(vt,2)) ) * envelope + 0.1; + double T = pars->temp; + + double envelope = 1; + fout[0] = exp( -(m*pow(vpar-upar,2)/2.0 + mu*B0) / T ) * envelope; } // Checks that the distribution function values in the ghost cells are set to -// 0 for velocities beyond the cutoff velocity and >0 otherwise. +// 0 for velocities beyond the cutoff velocity squared and >0 otherwise. void -check_function(double phi_mpe, double phi_wall, double charge, double mass, int cdim, - struct gkyl_array *distf_ho, struct gkyl_rect_grid grid, struct gkyl_range ghost_r, enum gkyl_edge_loc edge){ +check_function(struct test_sheath_ctx *pars, struct gkyl_array *distf_ho, struct gkyl_rect_grid grid, struct gkyl_range ghost_r, enum gkyl_edge_loc edge) +{ + double delta_phi = pars->phi_mpe - pars->phi_wall; + int cdim = pars->cdim; - double delta_phi = phi_mpe - phi_wall; - double vpar_cut; - if (delta_phi < 0) { - vpar_cut = charge < 0.? DBL_MAX : sqrt(charge*fabs(delta_phi)/(0.5*mass)); - } - else { - vpar_cut = charge < 0.? sqrt(fabs(charge)*delta_phi/(0.5*mass)) : DBL_MAX; - } int num_cells = 0; int num_zero_cells = 0; int num_zero_cells_expected = 0; - // We need the sign of charge*delta_phi to determine - // which part of the distribution function is cut off by the sheath BC. - double qphi_sign = charge * delta_phi > 0 ? 1.0 : -1.0; + int num_uknown_cells = 0; + + // Sign of charge * delta_phi determines if there is any reflection or full absorption + double qphi_sign = pars->charge * delta_phi > 0 ? 1.0 : -1.0; struct gkyl_range_iter iter; gkyl_range_iter_init(&iter, &ghost_r); while (gkyl_range_iter_next(&iter)) { int *idx_g = iter.idx; long linidx_g = gkyl_range_idx(&ghost_r, idx_g); - double *distf_c = gkyl_array_fetch(distf_ho, linidx_g); - double tol = 1e-8; + const double *distf_c = gkyl_array_cfetch(distf_ho, linidx_g); + double tol = 1e-12; double ref_val = 0.0; // Get cell boundaries along vpar. @@ -137,42 +211,70 @@ check_function(double phi_mpe, double phi_wall, double charge, double mass, int double cell_lower_vpar = xc[cdim] - 0.5*grid.dx[cdim]; double cell_upper_vpar = xc[cdim] + 0.5*grid.dx[cdim]; + // Compute the absolute velocity bounds of the cell (handle zero crossing safely) + double vr_min = (cell_lower_vpar * cell_upper_vpar < 0.0) ? 0.0 : fmin(fabs(cell_lower_vpar), fabs(cell_upper_vpar)); + double vr_max = fmax(fabs(cell_lower_vpar), fabs(cell_upper_vpar)); + + // Square the cell velocities to safely match vcutsq dimensions + double vr_min_sq = vr_min * vr_min; + double vr_max_sq = vr_max * vr_max; + + // Compute the vpar cut radius squared at the lower and upper mu boundaries + double cell_lower_mu = xc[cdim+1] - 0.5*grid.dx[cdim+1]; + double cell_upper_mu = xc[cdim+1] + 0.5*grid.dx[cdim+1]; + double vcut_coord_lower[GKYL_MAX_DIM], vcut_coord_upper[GKYL_MAX_DIM]; + + // Map dimensions correctly + for (int d=0; d tol ? 0 : 1; - if ( edge == GKYL_LOWER_EDGE && - ( cell_lower_vpar > -qphi_sign*vpar_cut || cell_upper_vpar < qphi_sign*vpar_cut ) ) { - num_zero_cells_expected++; - for (int k=0; kncomp; k++) { - TEST_CHECK( gkyl_compare(distf_c[k], ref_val, tol) ); - TEST_MSG( "Expected %.9e | Got: %.9e at idx=%d,%d,%d\n", ref_val, distf_c[k], idx_g[0], idx_g[1], idx_g[2]); - } - } - else if (edge == GKYL_UPPER_EDGE && - ( cell_lower_vpar > -qphi_sign*vpar_cut || cell_upper_vpar < qphi_sign*vpar_cut ) ) { + + if ( (vr_min_sq >= vcutsq_max) || (qphi_sign > 0) ) { + // Cell is fully outside cutoff or under full absorption -> expect exact zeros num_zero_cells_expected++; for (int k=0; kncomp; k++) { TEST_CHECK( gkyl_compare(distf_c[k], ref_val, tol) ); TEST_MSG( "Expected %.9e | Got: %.9e at idx=%d,%d,%d\n", ref_val, distf_c[k], idx_g[0], idx_g[1], idx_g[2]); } + } else if ( ((vcutsq_min < vr_max_sq) && (vcutsq_min > vr_min_sq)) || ((vcutsq_max > vr_min_sq) && (vcutsq_max < vr_max_sq)) ) { + // Cell is partially cut off by the sheath boundaries + num_uknown_cells++; } else { - // Check that the average cell value is bigger than 0 for cells that are not expected to be cut off by the sheath BC. + // Cell is fully inside the cutoff range -> average cell value must be non-zero double cell_avg = distf_c[0]; TEST_CHECK( cell_avg > ref_val ); TEST_MSG( "Expected > %.9e | Got: %.9e at idx=%d,%d,%d\n", ref_val, cell_avg, idx_g[0], idx_g[1], idx_g[2]); } } - // Uncomment for debugging. - // printf("\n"); - // printf("Edge: %s | Charge: %.1e | Delta phi: %.2e\n", - // edge == GKYL_LOWER_EDGE? "lower" : "upper", charge, delta_phi); - // printf("zero cell = %d | zero cell expected = %d | total cells = %d\n", num_zero_cells, num_zero_cells_expected, num_cells); } -void write_out_fields(int cdim, int vdim, enum gkyl_edge_loc edge, bool use_gpu, +void write_out_fields(struct test_sheath_ctx *pars, int cdim, int vdim, enum gkyl_edge_loc edge, bool use_gpu, struct gkyl_array *distf_ho, struct gkyl_array *phi_ho, struct gkyl_array *phiw_ho, struct gkyl_rect_grid grid_ext, struct gkyl_range local_ext, struct gkyl_rect_grid grid_conf, struct gkyl_range local_conf, struct gkyl_basis *basis, struct gkyl_basis basis_conf) { + struct gkyl_rect_grid grid_norm_ext = grid_ext; + double vt = sqrt(pars->temp/pars->mass); + grid_norm_ext.dx[cdim] /= vt; + grid_norm_ext.lower[cdim] /= vt; + grid_norm_ext.upper[cdim] /= vt; + grid_norm_ext.dx[cdim+1] *= pars->B0/pars->temp; + grid_norm_ext.lower[cdim+1] *= pars->B0/pars->temp; + grid_norm_ext.upper[cdim+1] *= pars->B0/pars->temp; + struct gkyl_msgpack_map_elem io_meta[] = { { .key = "poly_order", .elem_type = GKYL_MP_UNSIGNED_INT, .uval = basis->poly_order }, { .key = "basis_type", .elem_type = GKYL_MP_STRING, .cval = basis->id } @@ -190,7 +292,7 @@ void write_out_fields(int cdim, int vdim, enum gkyl_edge_loc edge, bool use_gpu, char fname[256]; const char *fmt = "bc_sheath_%dx%dv_%s_%s_%s.gkyl"; snprintf(fname, sizeof(fname), fmt, cdim, vdim, edge == GKYL_LOWER_EDGE? "lower" : "upper", use_gpu? "gpu" : "cpu", "distf_out"); - gkyl_grid_sub_array_write(&grid_ext, &local_ext, mt, distf_ho, fname); + gkyl_grid_sub_array_write(&grid_norm_ext, &local_ext, mt, distf_ho, fname); snprintf(fname, sizeof(fname), fmt, cdim, vdim, edge == GKYL_LOWER_EDGE? "lower" : "upper", use_gpu? "gpu" : "cpu", "phi_mpe"); gkyl_grid_sub_array_write(&grid_conf, &local_conf, mt_conf, phi_ho, fname); snprintf(fname, sizeof(fname), fmt, cdim, vdim, edge == GKYL_LOWER_EDGE? "lower" : "upper", use_gpu? "gpu" : "cpu", "phi_wall"); @@ -201,60 +303,49 @@ void write_out_fields(int cdim, int vdim, enum gkyl_edge_loc edge, bool use_gpu, } void -test_bc_sheath_gyrokinetic_1x2v(const int *cells, enum gkyl_edge_loc edge, - double charge, double phi_mpe, bool write_fields, bool use_gpu) +test_bc_sheath_gyrokinetic_1x2v(struct test_sheath_ctx *pars, enum gkyl_edge_loc edge, bool write_fields, bool use_gpu) { - /* - This test applies the sheath BC to a Maxwellian distribution function on both upper and lower edges in the z direction, - according to a potential drop between the magnetic presheath entrance and the wall. - The folloing files are written out if requested: - - "bc_sheath_1x2v_distf_in_${edge}_${cpugpu}.gkyl": Input distribution function. - - "bc_sheath_1x2v_phi_mpe.gkyl": Potential at the magnetic presheath entrance (constant everywhere). - - "bc_sheath_1x2v_phi_wall.gkyl": Potential at the wall (constant everywhere). - - "bc_sheath_1x2v_distf_out_${edge}_${cpugpu}.gkyl": Distribution after the sheath BC has been applied (includes ghost cells). - */ - - double mass = 1.0; // Species mass. - double vt = 1.0; // Reference thermal speed (for grid extents). - double B0 = 1.0; // Magnetic field magnitude. - double upar_distf = 1.0*vt; // Parallel flow speed in distribution function. - double vt_distf = 1.5*vt; // Thermal speed in distribution function. - double phi_wall = 0.0; // Potential at wall. - double z0 = 0.2; - double sigmaz = 1.0; - + double ms = pars->mass; + double qs = pars->charge; + double ns = pars->dens; + double Ts = pars->temp; + double B0 = pars->B0; + double phi_mpe = pars->phi_mpe; + double phi_wall = pars->phi_wall; + double impact_angle = pars->impact_angle; + double vt = sqrt(Ts/ms); + double mu0 = Ts/B0; + int poly_order = 1; - double lower[] = {-1.0, -5.0*vt, 0.}; - double upper[] = { 1.0, 5.0*vt, mass*(pow(5.0*vt,2))/(2.0*B0)}; + double lower[] = {-1.0, -3.0*vt, 0.}; + double upper[] = { 1.0, 3.0*vt, 5.0*mu0}; int vdim = 2; int ndim = sizeof(lower)/sizeof(lower[0]); int cdim = ndim - vdim; - int dir = cdim-1; // Always applied in the parallel direction. + int dir = cdim-1; double lower_conf[cdim], upper_conf[cdim]; int cells_conf[cdim]; for (int d=0; dcells[d]; } double lower_vel[vdim], upper_vel[vdim]; int cells_vel[vdim]; for (int d=0; dcells[cdim+d]; } - // Grid. struct gkyl_rect_grid grid; - gkyl_rect_grid_init(&grid, ndim, lower, upper, cells); + gkyl_rect_grid_init(&grid, ndim, lower, upper, pars->cells); struct gkyl_rect_grid grid_conf; gkyl_rect_grid_init(&grid_conf, cdim, lower_conf, upper_conf, cells_conf); struct gkyl_rect_grid grid_vel; gkyl_rect_grid_init(&grid_vel, vdim, lower_vel, upper_vel, cells_vel); - // Basis functions. struct gkyl_basis *basis; basis = use_gpu? gkyl_cart_modal_gkhybrid_cu_dev_new(cdim, vdim) : gkyl_cart_modal_gkhybrid_new(cdim, vdim); @@ -266,11 +357,11 @@ test_bc_sheath_gyrokinetic_1x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_cart_modal_serendip(&basis_conf, cdim, poly_order); int ghost_conf[] = { 1, 1, 1 }; - struct gkyl_range local_conf, local_conf_ext; // local, local-ext position-space ranges + struct gkyl_range local_conf, local_conf_ext; gkyl_create_grid_ranges(&grid_conf, ghost_conf, &local_conf_ext, &local_conf); int ghost_vel[] = { 0, 0 }; - struct gkyl_range local_vel, local_vel_ext; // local, local-ext vel-space ranges + struct gkyl_range local_vel, local_vel_ext; gkyl_create_grid_ranges(&grid_vel, ghost_vel, &local_vel_ext, &local_vel); int ghost[GKYL_MAX_DIM]; @@ -278,53 +369,40 @@ test_bc_sheath_gyrokinetic_1x2v(const int *cells, enum gkyl_edge_loc edge, ghost[d] = ghost_conf[d]; for (int d=0; dcells[d]; lower_ext[d] = lower[d]-dx*ghost[d]; upper_ext[d] = upper[d]+dx*ghost[d]; - cells_ext[d] = cells[d]+2*ghost[d]; + cells_ext[d] = pars->cells[d]+2*ghost[d]; } struct gkyl_rect_grid grid_ext; gkyl_rect_grid_init(&grid_ext, ndim, lower_ext, upper_ext, cells_ext); - // Create the skin/ghost ranges. struct gkyl_range skin_r, ghost_r; gkyl_skin_ghost_ranges(&skin_r, &ghost_r, dir, edge, &local_ext, ghost); - // Initialize the distribution struct gkyl_array *distf = mkarr(use_gpu, basis_ho.num_basis, local_ext.volume); struct gkyl_array *distf_ho = use_gpu? mkarr(false, distf->ncomp, distf->size) : gkyl_array_acquire(distf); - struct test_sheath_ctx proj_ctx = { - .B0 = B0, - .mass = mass, - .upar = upar_distf, - .vt = vt_distf, - .z0 = z0, - .sigmaz = sigmaz - }; gkyl_proj_on_basis *projDistf = gkyl_proj_on_basis_inew( &(struct gkyl_proj_on_basis_inp) { .grid = &grid, .basis = &basis_ho, .num_ret_vals = 1, .eval = eval_func_1x2v, - .ctx = &proj_ctx, + .ctx = pars, } ); gkyl_proj_on_basis_advance(projDistf, 0.0, &local, distf_ho); gkyl_array_copy(distf, distf_ho); - // Initialize the electrostatic potential at MPE and WALL double dgnormc = pow(sqrt(2.0), cdim); struct gkyl_array *phi = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); struct gkyl_array *phi_ho = use_gpu? mkarr(false, phi->ncomp, phi->size) : gkyl_array_acquire(phi); @@ -336,25 +414,94 @@ test_bc_sheath_gyrokinetic_1x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_array_shiftc(phiw_ho, phi_wall * dgnormc, 0 * basis_conf.num_basis); gkyl_array_copy(phiw, phiw_ho); - // Create the BC updater. struct gkyl_bc_sheath_gyrokinetic *bcsheath = gkyl_bc_sheath_gyrokinetic_new(dir, edge, - basis, &skin_r, &ghost_r, gvm, cdim, 2.*charge/mass, use_gpu); + basis, &skin_r, &ghost_r, gvm, cdim, 2.*qs/ms, pars->use_surrogate, pars->surrogate_model_path, + NULL, NULL, use_gpu); // No vcutsq diagnostic output in this test. + + if (pars->surrogate_model_path) { + pars->model = gkyl_kann_net_load(pars->surrogate_model_path, false); + } - // Advance the BC updater. - gkyl_bc_sheath_gyrokinetic_advance(bcsheath, phi, phiw, distf, &local_conf); + int vcutsq_dim = cdim - 1 + vdim - 1; + struct gkyl_basis vcutsq_basis; + gkyl_cart_modal_serendip(&vcutsq_basis, vcutsq_dim, poly_order); + struct gkyl_range vcutsq_local; + int nc_lower[vcutsq_dim], nc_upper[vcutsq_dim]; + for (int d=0; d < cdim-1; d++) { + nc_lower[d] = skin_r.lower[d]; + nc_upper[d] = skin_r.upper[d]; + } + nc_lower[vcutsq_dim-1] = skin_r.lower[skin_r.ndim-1]; + nc_upper[vcutsq_dim-1] = skin_r.upper[skin_r.ndim-1]; + gkyl_range_init(&vcutsq_local, vcutsq_basis.ndim, nc_lower, nc_upper); + struct gkyl_array *vcutsq = mkarr(use_gpu, vcutsq_basis.num_basis, vcutsq_local.volume); + struct gkyl_array *vcutsq_ho = use_gpu? mkarr(false, vcutsq->ncomp, vcutsq->size) : gkyl_array_acquire(vcutsq); + + struct gkyl_rect_grid vcut_grid; + double vcut_lower[cdim], vcut_upper[cdim]; + for (int d=0; dcells); + gkyl_proj_on_basis *projVcut = gkyl_proj_on_basis_inew( &(struct gkyl_proj_on_basis_inp) { + .grid = &vcut_grid, + .basis = &vcutsq_basis, + .num_ret_vals = 1, + .eval = eval_func_vcutsq, + .ctx = pars, + } + ); + gkyl_proj_on_basis_advance(projVcut, 0.0, &vcutsq_local, vcutsq_ho); + gkyl_array_copy(vcutsq, vcutsq_ho); + + gkyl_bc_sheath_gyrokinetic_set_vcutsq(bcsheath, vcutsq); + + if (pars->use_surrogate) { + struct gkyl_array *density = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *density_ho = use_gpu? mkarr(false, density->ncomp, density->size) : gkyl_array_acquire(density); + gkyl_array_shiftc(density_ho, ns * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(density, density_ho); + + struct gkyl_array *temperature = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *temperature_ho = use_gpu? mkarr(false, temperature->ncomp, temperature->size) : gkyl_array_acquire(temperature); + gkyl_array_shiftc(temperature_ho, Ts * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(temperature, temperature_ho); + + struct gkyl_array *bmag = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *bmag_ho = use_gpu? mkarr(false, bmag->ncomp, bmag->size) : gkyl_array_acquire(bmag); + gkyl_array_shiftc(bmag_ho, B0 * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(bmag, bmag_ho); + + struct gkyl_array *bimpact_angle = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *bimpact_angle_ho = use_gpu? mkarr(false, bimpact_angle->ncomp, bimpact_angle->size) : gkyl_array_acquire(bimpact_angle); + gkyl_array_shiftc(bimpact_angle_ho, impact_angle * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(bimpact_angle, bimpact_angle_ho); + + gkyl_bc_sheath_gyrokinetic_update_vcutsq(bcsheath, phi, phiw, density, temperature, bmag, bimpact_angle, &local_conf); + + gkyl_array_release(density); + gkyl_array_release(density_ho); + gkyl_array_release(temperature); + gkyl_array_release(temperature_ho); + gkyl_array_release(bmag); + gkyl_array_release(bmag_ho); + gkyl_array_release(bimpact_angle); + gkyl_array_release(bimpact_angle_ho); + } - // Copy back to host. + gkyl_bc_sheath_gyrokinetic_advance(bcsheath, distf, &local_conf); gkyl_array_copy(distf_ho, distf); - // Check the result. - check_function(phi_mpe, phi_wall, charge, mass, cdim, distf_ho, grid, ghost_r, edge); + check_function(pars, distf_ho, grid, ghost_r, edge); - // Write out the distribution function after applying BC if requested. if (write_fields) - write_out_fields(cdim, vdim, edge, use_gpu, distf_ho, phi_ho, phiw_ho, + write_out_fields(pars, cdim, vdim, edge, use_gpu, distf_ho, phi_ho, phiw_ho, grid_ext, local_ext, grid_conf, local_conf, &basis_ho, basis_conf); - // Clean up. + // Clean up and prevent memory leaks. gkyl_proj_on_basis_release(projDistf); gkyl_array_release(distf); gkyl_array_release(distf_ho); @@ -369,65 +516,60 @@ test_bc_sheath_gyrokinetic_1x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_velocity_map_release(gvm); gkyl_bc_sheath_gyrokinetic_release(bcsheath); + gkyl_proj_on_basis_release(projVcut); + gkyl_array_release(vcutsq); + gkyl_array_release(vcutsq_ho); + + if (pars->model) { + gkyl_kann_net_release(pars->model); + pars->model = NULL; + } } void -test_bc_sheath_gyrokinetic_2x2v(const int *cells, enum gkyl_edge_loc edge, - double charge, double phi_mpe, bool write_fields, bool use_gpu) +test_bc_sheath_gyrokinetic_2x2v(struct test_sheath_ctx *pars, enum gkyl_edge_loc edge, bool write_fields, bool use_gpu) { - /* - This test applies the sheath BC to a Maxwellian distribution function on both upper and lower edges in the z direction, - according to a potential drop between the magnetic presheath entrance and the wall. - The following files are written out if requested: - - "bc_sheath_2x2v_distf_in.gkyl": Input distribution function. - - "bc_sheath_2x2v_phi_mpe.gkyl": Potential at the magnetic presheath entrance (constant everywhere). - - "bc_sheath_2x2v_phi_wall.gkyl": Potential at the wall (constant everywhere). - - "bc_sheath_2x2v_distf_out.gkyl": Distribution after the sheath BC has been applied (includes ghost cells). - */ - - double mass = 1.; // Species mass. - double vt = 1.0; // Reference thermal speed (for grid extents). - double B0 = 1.0; // Magnetic field magnitude. - double upar_distf = 1.0*vt; // Parallel flow speed in distribution function. - double vt_distf = 1.5*vt; // Thermal speed in distribution function. - double phi_wall = 0.0; // Potential at wall. - double x0 = 0.0; // x-center of distribution function - double z0 = 0.2; // z-center of distribution function - double sigmax = 0.5; // Width of distribution function in x. - double sigmaz = 1.0; // Width of distribution function in z. + double ms = pars->mass; + double qs = pars->charge; + double ns = pars->dens; + double Ts = pars->temp; + double B0 = pars->B0; + double phi_mpe = pars->phi_mpe; + double phi_wall = pars->phi_wall; + double impact_angle = pars->impact_angle; + double vt = sqrt(Ts/ms); + double mu0 = Ts/B0; int poly_order = 1; - double lower[] = { 0.0, -1.0, -5.0*vt, 0.}; - double upper[] = { 1.0, 1.0, 5.0*vt, mass*(pow(5.0*vt,2))/(2.0*B0)}; + double lower[] = { 0.0, -1.0, -3.0*vt, 0.}; + double upper[] = { 1.0, 1.0, 3.0*vt, 5*mu0}; int vdim = 2; int ndim = sizeof(lower)/sizeof(lower[0]); int cdim = ndim - vdim; - int dir = cdim-1; // Always applied in the parallel direction. + int dir = cdim-1; double lower_conf[cdim], upper_conf[cdim]; int cells_conf[cdim]; for (int d=0; dcells[d]; } double lower_vel[vdim], upper_vel[vdim]; int cells_vel[vdim]; for (int d=0; dcells[cdim+d]; } - // Grid. struct gkyl_rect_grid grid; - gkyl_rect_grid_init(&grid, ndim, lower, upper, cells); + gkyl_rect_grid_init(&grid, ndim, lower, upper, pars->cells); struct gkyl_rect_grid grid_conf; gkyl_rect_grid_init(&grid_conf, cdim, lower_conf, upper_conf, cells_conf); struct gkyl_rect_grid grid_vel; gkyl_rect_grid_init(&grid_vel, vdim, lower_vel, upper_vel, cells_vel); - // Basis functions. struct gkyl_basis *basis; basis = use_gpu? gkyl_cart_modal_gkhybrid_cu_dev_new(cdim, vdim) : gkyl_cart_modal_gkhybrid_new(cdim, vdim); @@ -439,11 +581,11 @@ test_bc_sheath_gyrokinetic_2x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_cart_modal_serendip(&basis_conf, cdim, poly_order); int ghost_conf[] = { 1, 1, 1 }; - struct gkyl_range local_conf, local_conf_ext; // local, local-ext position-space ranges + struct gkyl_range local_conf, local_conf_ext; gkyl_create_grid_ranges(&grid_conf, ghost_conf, &local_conf_ext, &local_conf); int ghost_vel[] = { 0, 0 }; - struct gkyl_range local_vel, local_vel_ext; // local, local-ext vel-space ranges + struct gkyl_range local_vel, local_vel_ext; gkyl_create_grid_ranges(&grid_vel, ghost_vel, &local_vel_ext, &local_vel); int ghost[GKYL_MAX_DIM]; @@ -451,55 +593,40 @@ test_bc_sheath_gyrokinetic_2x2v(const int *cells, enum gkyl_edge_loc edge, ghost[d] = ghost_conf[d]; for (int d=0; dcells[d]; lower_ext[d] = lower[d]-dx*ghost[d]; upper_ext[d] = upper[d]+dx*ghost[d]; - cells_ext[d] = cells[d]+2*ghost[d]; + cells_ext[d] = pars->cells[d]+2*ghost[d]; } struct gkyl_rect_grid grid_ext; gkyl_rect_grid_init(&grid_ext, ndim, lower_ext, upper_ext, cells_ext); - // Create the skin/ghost ranges. struct gkyl_range skin_r, ghost_r; gkyl_skin_ghost_ranges(&skin_r, &ghost_r, dir, edge, &local_ext, ghost); - // Initialize the distribution. struct gkyl_array *distf = mkarr(use_gpu, basis_ho.num_basis, local_ext.volume); struct gkyl_array *distf_ho = use_gpu? mkarr(false, distf->ncomp, distf->size) : gkyl_array_acquire(distf); - struct test_sheath_ctx proj_ctx = { - .B0 = B0, - .mass = mass, - .upar = upar_distf, - .vt = vt_distf, - .x0 = x0, - .z0 = z0, - .sigmax = sigmax, - .sigmaz = sigmaz - }; gkyl_proj_on_basis *projDistf = gkyl_proj_on_basis_inew( &(struct gkyl_proj_on_basis_inp) { .grid = &grid, .basis = &basis_ho, .num_ret_vals = 1, .eval = eval_func_2x2v, - .ctx = &proj_ctx, + .ctx = pars, } ); gkyl_proj_on_basis_advance(projDistf, 0.0, &local, distf_ho); gkyl_array_copy(distf, distf_ho); - // Initialize the electrostatic potential at MPE and WALL. double dgnormc = pow(sqrt(2.0), cdim); struct gkyl_array *phi = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); struct gkyl_array *phi_ho = use_gpu? mkarr(false, phi->ncomp, phi->size) : gkyl_array_acquire(phi); @@ -511,25 +638,93 @@ test_bc_sheath_gyrokinetic_2x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_array_shiftc(phiw_ho, phi_wall * dgnormc, 0 * basis_conf.num_basis); gkyl_array_copy(phiw, phiw_ho); - // Create the BC updater. struct gkyl_bc_sheath_gyrokinetic *bcsheath = gkyl_bc_sheath_gyrokinetic_new(dir, edge, - basis, &skin_r, &ghost_r, gvm, cdim, 2.*charge/mass, use_gpu); + basis, &skin_r, &ghost_r, gvm, cdim, 2.*qs/ms, pars->use_surrogate, pars->surrogate_model_path, + NULL, NULL, use_gpu); // No vcutsq diagnostic output in this test. + + if (pars->surrogate_model_path) { + pars->model = gkyl_kann_net_load(pars->surrogate_model_path, false); + } - // Advance the BC updater. - gkyl_bc_sheath_gyrokinetic_advance(bcsheath, phi, phiw, distf, &local_conf); + int vcutsq_dim = cdim - 1 + vdim - 1; + struct gkyl_basis vcutsq_basis; + gkyl_cart_modal_serendip(&vcutsq_basis, vcutsq_dim, poly_order); + struct gkyl_range vcutsq_local; + int nc_lower[vcutsq_dim], nc_upper[vcutsq_dim]; + for (int d=0; d < cdim-1; d++) { + nc_lower[d] = skin_r.lower[d]; + nc_upper[d] = skin_r.upper[d]; + } + nc_lower[vcutsq_dim-1] = skin_r.lower[skin_r.ndim-1]; + nc_upper[vcutsq_dim-1] = skin_r.upper[skin_r.ndim-1]; + gkyl_range_init(&vcutsq_local, vcutsq_basis.ndim, nc_lower, nc_upper); + struct gkyl_array *vcutsq = mkarr(use_gpu, vcutsq_basis.num_basis, vcutsq_local.volume); + struct gkyl_array *vcutsq_ho = use_gpu? mkarr(false, vcutsq->ncomp, vcutsq->size) : gkyl_array_acquire(vcutsq); + + struct gkyl_rect_grid vcut_grid; + double vcut_lower[cdim], vcut_upper[cdim]; + for (int d=0; dcells); + gkyl_proj_on_basis *projVcut = gkyl_proj_on_basis_inew( &(struct gkyl_proj_on_basis_inp) { + .grid = &vcut_grid, + .basis = &vcutsq_basis, + .num_ret_vals = 1, + .eval = eval_func_vcutsq, + .ctx = pars, + } + ); + gkyl_proj_on_basis_advance(projVcut, 0.0, &vcutsq_local, vcutsq_ho); + gkyl_array_copy(vcutsq, vcutsq_ho); + + gkyl_bc_sheath_gyrokinetic_set_vcutsq(bcsheath, vcutsq); + + if (pars->use_surrogate) { + struct gkyl_array *density = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *density_ho = use_gpu? mkarr(false, density->ncomp, density->size) : gkyl_array_acquire(density); + gkyl_array_shiftc(density_ho, ns * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(density, density_ho); + + struct gkyl_array *temperature = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *temperature_ho = use_gpu? mkarr(false, temperature->ncomp, temperature->size) : gkyl_array_acquire(temperature); + gkyl_array_shiftc(temperature_ho, Ts * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(temperature, temperature_ho); + + struct gkyl_array *bmag = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *bmag_ho = use_gpu? mkarr(false, bmag->ncomp, bmag->size) : gkyl_array_acquire(bmag); + gkyl_array_shiftc(bmag_ho, B0 * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(bmag, bmag_ho); + + struct gkyl_array *bimpact_angle = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *bimpact_angle_ho = use_gpu? mkarr(false, bimpact_angle->ncomp, bimpact_angle->size) : gkyl_array_acquire(bimpact_angle); + gkyl_array_shiftc(bimpact_angle_ho, impact_angle * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(bimpact_angle, bimpact_angle_ho); + + gkyl_bc_sheath_gyrokinetic_update_vcutsq(bcsheath, phi, phiw, density, temperature, bmag, bimpact_angle, &local_conf); + + gkyl_array_release(density); + gkyl_array_release(density_ho); + gkyl_array_release(temperature); + gkyl_array_release(temperature_ho); + gkyl_array_release(bmag); + gkyl_array_release(bmag_ho); + gkyl_array_release(bimpact_angle); + gkyl_array_release(bimpact_angle_ho); + } - // Copy back to host. + gkyl_bc_sheath_gyrokinetic_advance(bcsheath, distf, &local_conf); gkyl_array_copy(distf_ho, distf); - // Check the result. - check_function(phi_mpe, phi_wall, charge, mass, cdim, distf_ho, grid, ghost_r, edge); + check_function(pars, distf_ho, grid, ghost_r, edge); - // Write out the distribution function after applying BC if requested. if (write_fields) - write_out_fields(cdim, vdim, edge, use_gpu, distf_ho, phi_ho, phiw_ho, + write_out_fields(pars, cdim, vdim, edge, use_gpu, distf_ho, phi_ho, phiw_ho, grid_ext, local_ext, grid_conf, local_conf, &basis_ho, basis_conf); - // Clean up. gkyl_proj_on_basis_release(projDistf); gkyl_array_release(distf); gkyl_array_release(distf_ho); @@ -544,67 +739,60 @@ test_bc_sheath_gyrokinetic_2x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_velocity_map_release(gvm); gkyl_bc_sheath_gyrokinetic_release(bcsheath); + gkyl_proj_on_basis_release(projVcut); + gkyl_array_release(vcutsq); + gkyl_array_release(vcutsq_ho); + + if (pars->model) { + gkyl_kann_net_release(pars->model); + pars->model = NULL; + } } void -test_bc_sheath_gyrokinetic_3x2v(const int *cells, enum gkyl_edge_loc edge, - double charge, double phi_mpe, bool write_fields, bool use_gpu) +test_bc_sheath_gyrokinetic_3x2v(struct test_sheath_ctx *pars, enum gkyl_edge_loc edge, bool write_fields, bool use_gpu) { - /* - This test applies the sheath BC to a Maxwellian distribution function on both upper and lower edges in the z direction, - according to a potential drop between the magnetic presheath entrance and the wall. - The following files are written out if requested: - - "bc_sheath_3x2v_distf_in.gkyl": Input distribution function. - - "bc_sheath_3x2v_phi_mpe.gkyl": Potential at the magnetic presheath entrance (constant everywhere). - - "bc_sheath_3x2v_phi_wall.gkyl": Potential at the wall (constant everywhere). - - "bc_sheath_3x2v_distf_out.gkyl": Distribution after the sheath BC has been applied (includes ghost cells). - */ - - double mass = 1.; // Species mass. - double vt = 1.0; // Reference thermal speed (for grid extents). - double B0 = 1.0; // Magnetic field magnitude. - double upar_distf = 1.0*vt; // Parallel flow speed in distribution function. - double vt_distf = 1.5*vt; // Thermal speed in distribution function. - double phi_wall = 0.0; // Potential at wall. + double ms = pars->mass; + double qs = pars->charge; + double ns = pars->dens; + double Ts = pars->temp; + double B0 = pars->B0; + double phi_mpe = pars->phi_mpe; + double phi_wall = pars->phi_wall; + double impact_angle = pars->impact_angle; + double vt = sqrt(Ts/ms); + double mu0 = Ts/B0; int poly_order = 1; - double lower[] = { 0.0, -2.0, -1.0, -5.0*vt, 0.}; - double upper[] = { 1.0, 2.0, 1.0, 5.0*vt, mass*(pow(5.0*vt,2))/(2.0*B0)}; + double lower[] = { 0.0, -2.0, -1.0, -3.0*vt, 0.}; + double upper[] = { 1.0, 2.0, 1.0, 3.0*vt, 5*mu0}; int vdim = 2; int ndim = sizeof(lower)/sizeof(lower[0]); int cdim = ndim - vdim; - int dir = cdim-1; // Always applied in the parallel direction. - double x0 = 0.0; // x-center of distribution function - double y0 = 0.0; // y-center of distribution function - double z0 = 0.2; // z-center of distribution function - double sigmax = 0.5; // Width of distribution function in x. - double sigmay = 0.5; // Width of distribution function in y. - double sigmaz = 1.0; // Width of distribution function in z. + int dir = cdim-1; double lower_conf[cdim], upper_conf[cdim]; int cells_conf[cdim]; for (int d=0; dcells[d]; } double lower_vel[vdim], upper_vel[vdim]; int cells_vel[vdim]; for (int d=0; dcells[cdim+d]; } - // Grid. struct gkyl_rect_grid grid; - gkyl_rect_grid_init(&grid, ndim, lower, upper, cells); + gkyl_rect_grid_init(&grid, ndim, lower, upper, pars->cells); struct gkyl_rect_grid grid_conf; gkyl_rect_grid_init(&grid_conf, cdim, lower_conf, upper_conf, cells_conf); struct gkyl_rect_grid grid_vel; gkyl_rect_grid_init(&grid_vel, vdim, lower_vel, upper_vel, cells_vel); - // Basis functions. struct gkyl_basis *basis; basis = use_gpu? gkyl_cart_modal_gkhybrid_cu_dev_new(cdim, vdim) : gkyl_cart_modal_gkhybrid_new(cdim, vdim); @@ -616,11 +804,11 @@ test_bc_sheath_gyrokinetic_3x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_cart_modal_serendip(&basis_conf, cdim, poly_order); int ghost_conf[] = { 1, 1, 1 }; - struct gkyl_range local_conf, local_conf_ext; // local, local-ext position-space ranges + struct gkyl_range local_conf, local_conf_ext; gkyl_create_grid_ranges(&grid_conf, ghost_conf, &local_conf_ext, &local_conf); int ghost_vel[] = { 0, 0 }; - struct gkyl_range local_vel, local_vel_ext; // local, local-ext vel-space ranges + struct gkyl_range local_vel, local_vel_ext; gkyl_create_grid_ranges(&grid_vel, ghost_vel, &local_vel_ext, &local_vel); int ghost[GKYL_MAX_DIM]; @@ -628,57 +816,40 @@ test_bc_sheath_gyrokinetic_3x2v(const int *cells, enum gkyl_edge_loc edge, ghost[d] = ghost_conf[d]; for (int d=0; dcells[d]; lower_ext[d] = lower[d]-dx*ghost[d]; upper_ext[d] = upper[d]+dx*ghost[d]; - cells_ext[d] = cells[d]+2*ghost[d]; + cells_ext[d] = pars->cells[d]+2*ghost[d]; } struct gkyl_rect_grid grid_ext; gkyl_rect_grid_init(&grid_ext, ndim, lower_ext, upper_ext, cells_ext); - // Create the skin/ghost ranges. struct gkyl_range skin_r, ghost_r; gkyl_skin_ghost_ranges(&skin_r, &ghost_r, dir, edge, &local_ext, ghost); - // Initialize the distribution. struct gkyl_array *distf = mkarr(use_gpu, basis_ho.num_basis, local_ext.volume); struct gkyl_array *distf_ho = use_gpu? mkarr(false, distf->ncomp, distf->size) : gkyl_array_acquire(distf); - struct test_sheath_ctx proj_ctx = { - .B0 = B0, - .mass = mass, - .upar = upar_distf, - .vt = vt_distf, - .x0 = x0, - .y0 = y0, - .z0 = z0, - .sigmax = sigmax, - .sigmay = sigmay, - .sigmaz = sigmaz - }; gkyl_proj_on_basis *projDistf = gkyl_proj_on_basis_inew( &(struct gkyl_proj_on_basis_inp) { .grid = &grid, .basis = &basis_ho, .num_ret_vals = 1, .eval = eval_func_3x2v, - .ctx = &proj_ctx, + .ctx = pars, } ); gkyl_proj_on_basis_advance(projDistf, 0.0, &local, distf_ho); gkyl_array_copy(distf, distf_ho); - // Initialize the electrostatic potential at MPE and WALL. double dgnormc = pow(sqrt(2.0), cdim); struct gkyl_array *phi = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); struct gkyl_array *phi_ho = use_gpu? mkarr(false, phi->ncomp, phi->size) : gkyl_array_acquire(phi); @@ -690,25 +861,93 @@ test_bc_sheath_gyrokinetic_3x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_array_shiftc(phiw_ho, phi_wall * dgnormc, 0 * basis_conf.num_basis); gkyl_array_copy(phiw, phiw_ho); - // Create the BC updater. struct gkyl_bc_sheath_gyrokinetic *bcsheath = gkyl_bc_sheath_gyrokinetic_new(dir, edge, - basis, &skin_r, &ghost_r, gvm, cdim, 2.*charge/mass, use_gpu); + basis, &skin_r, &ghost_r, gvm, cdim, 2.*qs/ms, pars->use_surrogate, pars->surrogate_model_path, + NULL, NULL, use_gpu); // No vcutsq diagnostic output in this test. - // Advance the BC updater. - gkyl_bc_sheath_gyrokinetic_advance(bcsheath, phi, phiw, distf, &local_conf); + if (pars->surrogate_model_path) { + pars->model = gkyl_kann_net_load(pars->surrogate_model_path, false); + } + + int vcutsq_dim = cdim - 1 + vdim - 1; + struct gkyl_basis vcutsq_basis; + gkyl_cart_modal_serendip(&vcutsq_basis, vcutsq_dim, poly_order); + struct gkyl_range vcutsq_local; + int nc_lower[vcutsq_dim], nc_upper[vcutsq_dim]; + for (int d=0; d < cdim-1; d++) { + nc_lower[d] = skin_r.lower[d]; + nc_upper[d] = skin_r.upper[d]; + } + nc_lower[vcutsq_dim-1] = skin_r.lower[skin_r.ndim-1]; + nc_upper[vcutsq_dim-1] = skin_r.upper[skin_r.ndim-1]; + gkyl_range_init(&vcutsq_local, vcutsq_basis.ndim, nc_lower, nc_upper); + struct gkyl_array *vcutsq = mkarr(use_gpu, vcutsq_basis.num_basis, vcutsq_local.volume); + struct gkyl_array *vcutsq_ho = use_gpu? mkarr(false, vcutsq->ncomp, vcutsq->size) : gkyl_array_acquire(vcutsq); + + struct gkyl_rect_grid vcut_grid; + double vcut_lower[cdim], vcut_upper[cdim]; + for (int d=0; dcells); + gkyl_proj_on_basis *projVcut = gkyl_proj_on_basis_inew( &(struct gkyl_proj_on_basis_inp) { + .grid = &vcut_grid, + .basis = &vcutsq_basis, + .num_ret_vals = 1, + .eval = eval_func_vcutsq, + .ctx = pars, + } + ); + gkyl_proj_on_basis_advance(projVcut, 0.0, &vcutsq_local, vcutsq_ho); + gkyl_array_copy(vcutsq, vcutsq_ho); + + gkyl_bc_sheath_gyrokinetic_set_vcutsq(bcsheath, vcutsq); + + if (pars->use_surrogate) { + struct gkyl_array *density = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *density_ho = use_gpu? mkarr(false, density->ncomp, density->size) : gkyl_array_acquire(density); + gkyl_array_shiftc(density_ho, ns * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(density, density_ho); + + struct gkyl_array *temperature = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *temperature_ho = use_gpu? mkarr(false, temperature->ncomp, temperature->size) : gkyl_array_acquire(temperature); + gkyl_array_shiftc(temperature_ho, Ts * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(temperature, temperature_ho); + + struct gkyl_array *bmag = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *bmag_ho = use_gpu? mkarr(false, bmag->ncomp, bmag->size) : gkyl_array_acquire(bmag); + gkyl_array_shiftc(bmag_ho, B0 * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(bmag, bmag_ho); + + struct gkyl_array *bimpact_angle = mkarr(use_gpu, basis_conf.num_basis, local_conf_ext.volume); + struct gkyl_array *bimpact_angle_ho = use_gpu? mkarr(false, bimpact_angle->ncomp, bimpact_angle->size) : gkyl_array_acquire(bimpact_angle); + gkyl_array_shiftc(bimpact_angle_ho, impact_angle * dgnormc, 0 * basis_conf.num_basis); + gkyl_array_copy(bimpact_angle, bimpact_angle_ho); + + gkyl_bc_sheath_gyrokinetic_update_vcutsq(bcsheath, phi, phiw, density, temperature, bmag, bimpact_angle, &local_conf); + + gkyl_array_release(density); + gkyl_array_release(density_ho); + gkyl_array_release(temperature); + gkyl_array_release(temperature_ho); + gkyl_array_release(bmag); + gkyl_array_release(bmag_ho); + gkyl_array_release(bimpact_angle); + gkyl_array_release(bimpact_angle_ho); + } - // Copy back to host. + gkyl_bc_sheath_gyrokinetic_advance(bcsheath, distf, &local_conf); gkyl_array_copy(distf_ho, distf); - // Check the result. - check_function(phi_mpe, phi_wall, charge, mass, cdim, distf_ho, grid, ghost_r, edge); + check_function(pars, distf_ho, grid, ghost_r, edge); - // Write out the distribution function after applying BC if requested. if (write_fields) - write_out_fields(cdim, vdim, edge, use_gpu, distf_ho, phi_ho, phiw_ho, + write_out_fields(pars, cdim, vdim, edge, use_gpu, distf_ho, phi_ho, phiw_ho, grid_ext, local_ext, grid_conf, local_conf, &basis_ho, basis_conf); - // Clean up. gkyl_proj_on_basis_release(projDistf); gkyl_array_release(distf); gkyl_array_release(distf_ho); @@ -723,217 +962,302 @@ test_bc_sheath_gyrokinetic_3x2v(const int *cells, enum gkyl_edge_loc edge, gkyl_velocity_map_release(gvm); gkyl_bc_sheath_gyrokinetic_release(bcsheath); + gkyl_proj_on_basis_release(projVcut); + gkyl_array_release(vcutsq); + gkyl_array_release(vcutsq_ho); + + if (pars->model) { + gkyl_kann_net_release(pars->model); + pars->model = NULL; + } } void test_bc_sheath_gk_1x2v_ho() { - double phi_mpe; // Potential at the magnetic presheath entrance. - double charge; // Species charge (+ or - for electrons/ions). + if (!surr_test_enabled || !surr_model_path) return; bool write_fields; - // Electrons with positive sheath entrance potential. - phi_mpe = 1.0; - charge = -1.0; + struct test_sheath_ctx pars = { + .cdim = 1, + .cells = {4, 16, 12}, + .mass = GKYL_ELECTRON_MASS, + .charge = -GKYL_ELEMENTARY_CHARGE, + .dens = 1.0e19, + .upar = 0.0, + .temp = 5.0 * GKYL_ELEMENTARY_CHARGE, + .B0 = 1.0, + .phi_mpe = 15.0, + .phi_wall = 0.0, + .impact_angle = 5.0 * GKYL_PI / 180.0, + .z0 = 0.0, + .sigmaz = 1.0, + .use_surrogate = true, + .surrogate_model_path = surr_model_path, + .verbose = false, + }; + write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + pars.use_surrogate = false; + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Electrons with negative sheath entrance potential. - phi_mpe = -1.0; - charge = -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.phi_mpe *= -1.0; + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Ions with positive sheath entrance potential. - phi_mpe = 1.0; - charge = 1.0; + pars.use_surrogate = false; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.charge = GKYL_ELEMENTARY_CHARGE; + pars.mass = GKYL_PROTON_MASS; + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Ions with negative sheath entrance potential. - phi_mpe = -1.0; - charge = 1.0; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.phi_mpe *= -1.0; + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); } void test_bc_sheath_gk_2x2v_ho() { - double phi_mpe; // Potential at the magnetic presheath entrance. - double charge; // Species charge (+ or - for electrons/ions). bool write_fields; - - // Electrons with positive sheath entrance potential. - phi_mpe = 1.0; - charge = -1.0; + + struct test_sheath_ctx pars = { + .cdim = 2, + .cells = {4, 4, 16, 12}, + .mass = GKYL_ELECTRON_MASS, + .charge = -GKYL_ELEMENTARY_CHARGE, + .dens = 1.0e19, + .upar = 0.0, + .temp = 5.0 * GKYL_ELEMENTARY_CHARGE, + .B0 = 1.0, + .phi_mpe = 15.0, + .phi_wall = 0.0, + .impact_angle = 5.0 * GKYL_PI / 180.0, + .x0 = 0.0, + .sigmax = 1.0, + .z0 = 0.0, + .sigmaz = 1.0, + .use_surrogate = true, + .surrogate_model_path = surr_model_path, + .verbose = false, + }; + write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + pars.use_surrogate = false; + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Electrons with negative sheath entrance potential. - phi_mpe = -1.0; - charge = -1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Ions with positive sheath entrance potential. - phi_mpe = 1.0; - charge = 1.0; + pars.use_surrogate = false; write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.charge = GKYL_ELEMENTARY_CHARGE; + pars.mass = GKYL_PROTON_MASS; + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Ions with negative sheath entrance potential. - phi_mpe = -1.0; - charge = 1.0; write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.phi_mpe *= -1.0; + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); } void test_bc_sheath_gk_3x2v_ho() { - double phi_mpe; // Potential at the magnetic presheath entrance. - double charge; // Species charge (+ or - for electrons/ions). + if (!surr_test_enabled || !surr_model_path) return; bool write_fields; - // Electrons with positive sheath entrance potential. - phi_mpe = 1.0; - charge = -1.0; + struct test_sheath_ctx pars = { + .cdim = 3, + .cells = {4, 4, 4, 16, 12}, + .mass = GKYL_ELECTRON_MASS, + .charge = -GKYL_ELEMENTARY_CHARGE, + .dens = 1.0e19, + .upar = 0.0, + .temp = 5.0 * GKYL_ELEMENTARY_CHARGE, + .B0 = 1.0, + .phi_mpe = 15.0, + .phi_wall = 0.0, + .impact_angle = 5.0 * GKYL_PI / 180.0, + .x0 = 0.0, + .sigmax = 1.0, + .y0 = 0.0, + .sigmay = 1.0, + .z0 = 0.0, + .sigmaz = 1.0, + .use_surrogate = true, + .surrogate_model_path = surr_model_path, + .verbose = false, + }; + write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + pars.use_surrogate = false; + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Electrons with negative sheath entrance potential. - phi_mpe = -1.0; - charge = -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.phi_mpe *= -1.0; + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Ions with positive sheath entrance potential. - phi_mpe = 1.0; - charge = 1.0; + pars.use_surrogate = false; write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.charge = GKYL_ELEMENTARY_CHARGE; + pars.mass = GKYL_PROTON_MASS; + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); - // Ions with negative sheath entrance potential. - phi_mpe = -1.0; - charge = 1.0; write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, false); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, false); + pars.phi_mpe *= -1.0; + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, false); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, false); } #ifdef GKYL_HAVE_CUDA void test_bc_sheath_gk_1x2v_dev() { - double phi_mpe; - double charge; bool write_fields; + + struct test_sheath_ctx pars = { + .cdim = 1, + .cells = {4, 16, 12}, + .mass = GKYL_ELECTRON_MASS, + .charge = -GKYL_ELEMENTARY_CHARGE, + .dens = 1.0e19, + .upar = 0.0, + .temp = 5.0 * GKYL_ELEMENTARY_CHARGE, + .B0 = 1.0, + .phi_mpe = 15.0, + .phi_wall = 0.0, + .impact_angle = 5.0 * GKYL_PI / 180.0, + .z0 = 0.0, + .sigmaz = 1.0, + .use_surrogate = true, + .surrogate_model_path = surr_model_path, + .verbose = false, + }; - // Electrons with positive sheath entrance potential. - phi_mpe = 1.0; - charge = -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + pars.use_surrogate = false; + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Electrons with negative sheath entrance potential. - phi_mpe = -1.0; - charge = -1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Ions with positive sheath entrance potential. - phi_mpe = 1.0; - charge = 1.0; + pars.charge = GKYL_ELEMENTARY_CHARGE; + pars.mass = GKYL_PROTON_MASS; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Ions with negative sheath entrance potential. - phi_mpe = -1.0; - charge = 1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_1x2v((int[]){4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_1x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); } void test_bc_sheath_gk_2x2v_dev() { - double phi_mpe; - double charge; bool write_fields; - // Electrons with positive sheath entrance potential. - phi_mpe = 1.0; - charge = -1.0; + struct test_sheath_ctx pars = { + .cdim = 2, + .cells = {4, 4, 16, 12}, + .mass = GKYL_ELECTRON_MASS, + .charge = -GKYL_ELEMENTARY_CHARGE, + .dens = 1.0e19, + .upar = 0.0, + .temp = 5.0 * GKYL_ELEMENTARY_CHARGE, + .B0 = 1.0, + .phi_mpe = 15.0, + .phi_wall = 0.0, + .impact_angle = 5.0 * GKYL_PI / 180.0, + .x0 = 0.0, + .sigmax = 1.0, + .z0 = 0.0, + .sigmaz = 1.0, + .use_surrogate = true, + .surrogate_model_path = surr_model_path, + .verbose = false, + }; + write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + pars.use_surrogate = false; + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Electrons with negative sheath entrance potential. - phi_mpe = -1.0; - charge = -1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Ions with positive sheath entrance potential. - phi_mpe = 1.0; - charge = 1.0; + pars.charge = GKYL_ELEMENTARY_CHARGE; + pars.mass = GKYL_PROTON_MASS; write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Ions with negative sheath entrance potential. - phi_mpe = -1.0; - charge = 1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_2x2v((int[]){4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_2x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); } void test_bc_sheath_gk_3x2v_dev() { - double phi_mpe; - double charge; bool write_fields; - // Electrons with positive sheath entrance potential. - phi_mpe = 1.0; - charge = -1.0; + struct test_sheath_ctx pars = { + .cdim = 3, + .cells = {4, 4, 4, 16, 12}, + .mass = GKYL_ELECTRON_MASS, + .charge = -GKYL_ELEMENTARY_CHARGE, + .dens = 1.0e19, + .upar = 0.0, + .temp = 5.0 * GKYL_ELEMENTARY_CHARGE, + .B0 = 1.0, + .phi_mpe = 15.0, + .phi_wall = 0.0, + .impact_angle = 5.0 * GKYL_PI / 180.0, + .x0 = 0.0, + .sigmax = 1.0, + .y0 = 0.0, + .sigmay = 1.0, + .z0 = 0.0, + .sigmaz = 1.0, + .use_surrogate = true, + .surrogate_model_path = surr_model_path, + .verbose = false, + }; + write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + pars.use_surrogate = false; + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Electrons with negative sheath entrance potential. - phi_mpe = -1.0; - charge = -1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Ions with positive sheath entrance potential. - phi_mpe = 1.0; - charge = 1.0; + pars.charge = GKYL_ELEMENTARY_CHARGE; + pars.mass = GKYL_PROTON_MASS; write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); - // Ions with negative sheath entrance potential. - phi_mpe = -1.0; - charge = 1.0; + pars.phi_mpe *= -1.0; write_fields = false; - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_LOWER_EDGE, charge, phi_mpe, write_fields, true); - test_bc_sheath_gyrokinetic_3x2v((int[]){4, 4, 4, 16, 12}, GKYL_UPPER_EDGE, charge, phi_mpe, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_LOWER_EDGE, write_fields, true); + test_bc_sheath_gyrokinetic_3x2v(&pars, GKYL_UPPER_EDGE, write_fields, true); } #endif @@ -947,4 +1271,4 @@ TEST_LIST = { { "test_bc_sheath_gk_3x2v_dev", test_bc_sheath_gk_3x2v_dev }, #endif { NULL, NULL }, -}; +}; \ No newline at end of file diff --git a/gyrokinetic/zero/bc_sheath_gyrokinetic.c b/gyrokinetic/zero/bc_sheath_gyrokinetic.c index ebbb0e50ab..b9a8f43b5b 100644 --- a/gyrokinetic/zero/bc_sheath_gyrokinetic.c +++ b/gyrokinetic/zero/bc_sheath_gyrokinetic.c @@ -1,12 +1,195 @@ -#include -#include +#include "gkyl_bc_sheath_gyrokinetic.h" +#include "gkyl_bc_sheath_gyrokinetic_priv.h" #include +#include +#include +#include #include +#include +static struct gkyl_array* +mkarr(bool on_gpu, long nc, long size) +{ + struct gkyl_array* a; + if (on_gpu) + a = gkyl_array_cu_dev_new(GKYL_DOUBLE, nc, size); + else + a = gkyl_array_new(GKYL_DOUBLE, nc, size); + return a; +} + +static void +bc_sheath_gyrokinetic_diag_init(struct gkyl_bc_sheath_gyrokinetic *up, + const struct gkyl_rect_grid *phase_grid, const struct gkyl_range *phase_local) +{ + // Decomposition is only along the parallel direction, so the (perpendicular + // conf-space + mu) vcutsq array is owned entirely by the single rank abutting + // this edge's boundary. That rank (non-empty skin range) writes it out + // serially; all others do nothing. + up->vcutsq_write = up->skin_r->volume > 0; + if (!phase_grid || !phase_local || !up->vcutsq_write) + return; + + int cdim = up->cdim; + int pdim = phase_grid->ndim; + int vdim = pdim - cdim; + int vc_ndim = up->vcutsq_dim; // (cdim-1) + (vdim-1). + + // vcutsq is only meaningful (and the sheath kernels only exist) for vdim>1. + if (vdim < 2) + return; + + // Build the output grid spanning the perpendicular conf-space directions and + // mu, mapping the (already SOL-aware) vcutsq index range to physical coords. + double vc_lo[GKYL_MAX_DIM], vc_up[GKYL_MAX_DIM]; + int vc_cells[GKYL_MAX_DIM]; + + int c = 0; + for (int d=0; dvcutsq_local.lower[c], idx_up = up->vcutsq_local.upper[c]; + vc_lo[c] = phase_grid->lower[d] + (idx_lo - phase_local->lower[d])*phase_grid->dx[d]; + vc_up[c] = phase_grid->lower[d] + (idx_up - phase_local->lower[d] + 1)*phase_grid->dx[d]; + vc_cells[c] = idx_up - idx_lo + 1; + c++; + } + for (int d=cdim+1; dlower[d]; + vc_up[c] = phase_grid->upper[d]; + vc_cells[c] = phase_grid->cells[d]; + c++; + } + gkyl_rect_grid_init(&up->vcutsq_grid, vc_ndim, vc_lo, vc_up, vc_cells); + + // Range matching the output grid (1-based), used to write the local array. + // Its shape matches up->vcutsq_local, so the flat data layout is identical. + int nghost[GKYL_MAX_DIM] = {0}; + gkyl_create_grid_ranges(&up->vcutsq_grid, nghost, &up->vcutsq_diag_range_ext, &up->vcutsq_diag_range); + + // Host output buffer. On CPU we alias the working array to avoid a copy. + up->vcutsq_ho = up->use_gpu? + gkyl_array_new(GKYL_DOUBLE, up->vcutsq_basis.num_basis, up->vcutsq_local.volume) + : gkyl_array_acquire(up->vcutsq); + + up->vcutsq_diag_on = true; +} + +void bc_gksheath_update_vcutsq_surrogate(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, + const struct gkyl_array *phi_wall, const struct gkyl_array *dens, const struct gkyl_array *temp, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, const struct gkyl_range *conf_r) +{ +#ifdef GKYL_HAVE_CUDA + if (up->use_gpu) { + bc_gksheath_update_vcutsq_surrogate_cu(up, phi, phi_wall, dens, temp, bmag, bimpact_angle, conf_r); + return; + } +#endif + + int cidx[GKYL_MAX_CDIM]; // Configuration space index. + int csurfidx[GKYL_MAX_CDIM]; // Configuration space surface index. + int vidx[GKYL_MAX_VDIM]; // Velocity space index. + + // Set the fixed parallel config index and vpar lower index. + cidx[up->cdim-1] = up->edge == GKYL_LOWER_EDGE ? up->skin_r->lower[up->cdim-1] : up->skin_r->upper[up->cdim-1]; + csurfidx[up->cdim-1] = up->edge == GKYL_LOWER_EDGE ? cidx[up->cdim-1] : cidx[up->cdim-1] + 1; + vidx[0] = up->skin_r->lower[up->cdim]; + + // Loop over perpendicular config cells only to fill the KANN input vectors. + // build_input writes n_nodes_per_cell nodes into nn_inp_out using stride dim_in: + // feature f of local node n -> nn_inp_out[f + dim_in * n] + // This matches gkyl_kn_vec layout: node g data at data[g*N], feature f at data[g*N + f]. + struct gkyl_range_iter iter_xy; + gkyl_range_iter_init(&iter_xy, &up->perp_local); + while (gkyl_range_iter_next(&iter_xy)) { + for (int d = 0; d < up->cdim-1; d++) { + cidx[d] = iter_xy.idx[d]; + csurfidx[d] = iter_xy.idx[d]; + } + long conf_loc = gkyl_range_idx(conf_r, cidx); + long conf_surf_loc = gkyl_range_idx(conf_r, csurfidx); + const double *phi_p = (const double*) gkyl_array_cfetch(phi, conf_loc); + const double *phi_wall_p = (const double*) gkyl_array_cfetch(phi_wall, conf_loc); + const double *dens_p = (const double*) gkyl_array_cfetch(dens, conf_loc); + const double *temp_p = (const double*) gkyl_array_cfetch(temp, conf_loc); + const double *bmag_p = (const double*) gkyl_array_cfetch(bmag, conf_loc); + const double *bimpact_angle_p = (const double*) gkyl_array_cfetch(bimpact_angle, conf_surf_loc); + + // Contiguous block stride for the input parameter of the NN. + long perp_k = gkyl_range_idx(&up->perp_local, iter_xy.idx); + int stride = perp_k * up->perp_node_per_cell * up->kann_inp->N; + + up->kernels->vcutsq_input(phi_p, phi_wall_p, dens_p, temp_p, bmag_p, bimpact_angle_p, + up->kann_inp->N, up->kann_inp->data + stride); + } + + // Infer NN. + gkyl_kann_net_apply(up->kann_net, up->kann_inp, up->kann_out); + + // Loop over perp config + mu cells to project NN output onto DG vcut_fact. + // vcut_calc reads local node n's output block as nn_out + n*dim_out, matching + // gkyl_kn_vec layout where node g data starts at data[g*N]. + struct gkyl_range_iter iter_xymu; + gkyl_range_iter_init(&iter_xymu, &up->vcutsq_local); + while (gkyl_range_iter_next(&iter_xymu)) { + + for (int d = 0; d < up->cdim-1; d++) + cidx[d] = iter_xymu.idx[d]; + vidx[1] = iter_xymu.idx[up->cdim-1]; + + long cperp_mu_loc = gkyl_range_idx(&up->vcutsq_local, iter_xymu.idx); + long conf_loc = gkyl_range_idx(conf_r, cidx); + long vel_loc = gkyl_range_idx(&up->vel_map->local_vel, vidx); + // 0-based sequential perp cell index from the perp part of the index. + long perp_k = gkyl_range_idx(&up->perp_local, cidx); + + const double *vmap_p = (const double*) gkyl_array_cfetch(up->vel_map->vmap, vel_loc); + const double *temp_p = (const double*) gkyl_array_cfetch(temp, conf_loc); + const double *bmag_p = (const double*) gkyl_array_cfetch(bmag, conf_loc); + double *vcutsq_p = (double*) gkyl_array_cfetch(up->vcutsq, cperp_mu_loc); + + int stride = perp_k * up->perp_node_per_cell * up->kann_out->N; + // Compute the DG representation of the interpolated vcutsq values. + up->kernels->vcutsq_surr(vmap_p, up->kann_out->data + stride, up->kann_out->N, temp_p, bmag_p, vcutsq_p); + } +} + +void bc_gksheath_update_vcutsq_const(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, + const struct gkyl_array *phi_wall, const struct gkyl_array *dens, const struct gkyl_array *temp, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, const struct gkyl_range *conf_r) +{ +#ifdef GKYL_HAVE_CUDA + if (up->use_gpu) { + bc_gksheath_update_vcutsq_const_cu(up, phi, phi_wall, dens, temp, bmag, bimpact_angle, conf_r); + return; + } +#endif + + int cidx[GKYL_MAX_CDIM]; // Configuration space index. + + // Set the fixed parallel config index and vpar lower index. + cidx[up->cdim-1] = up->edge == GKYL_LOWER_EDGE ? up->skin_r->lower[up->cdim-1] : up->skin_r->upper[up->cdim-1]; + + // Loop over perpendicular config cells to compute vcutsq using the conducting sheath model. + struct gkyl_range_iter iter_perpmu; + gkyl_range_iter_init(&iter_perpmu, &up->vcutsq_local); + while (gkyl_range_iter_next(&iter_perpmu)) { + + long perpmu_loc = gkyl_range_idx(&up->vcutsq_local, iter_perpmu.idx); + double *vcutsq_p = (double*) gkyl_array_cfetch(up->vcutsq, perpmu_loc); + + for (int d = 0; d < up->cdim-1; d++) + cidx[d] = iter_perpmu.idx[d]; + long conf_loc = gkyl_range_idx(conf_r, cidx); + const double *phi_p = (const double*) gkyl_array_cfetch(phi, conf_loc); + const double *phi_wall_p = (const double*) gkyl_array_cfetch(phi_wall, conf_loc); + + up->kernels->vcutsq_const(phi_p, phi_wall_p, up->q2Dm, vcutsq_p); + } +} struct gkyl_bc_sheath_gyrokinetic* gkyl_bc_sheath_gyrokinetic_new(int dir, enum gkyl_edge_loc edge, const struct gkyl_basis *basis, const struct gkyl_range *skin_r, const struct gkyl_range *ghost_r, const struct gkyl_velocity_map *vel_map, - int cdim, double q2Dm, bool use_gpu) + int cdim, double q2Dm, enum gkyl_gyrokinetic_bc_type type, const char *surrogate_model_path, + const struct gkyl_rect_grid *phase_grid, const struct gkyl_range *phase_local, unsigned int poly_order, bool use_gpu) { // Allocate space for new updater. @@ -21,42 +204,122 @@ gkyl_bc_sheath_gyrokinetic_new(int dir, enum gkyl_edge_loc edge, const struct gk up->skin_r = skin_r; up->ghost_r = ghost_r; up->vel_map = gkyl_velocity_map_acquire(vel_map); + int vdim = skin_r->ndim - cdim; + up->type = type; + up->update_vcutsq = bc_gksheath_update_vcutsq_const; + up->vcutsq_dim = cdim-1 + vdim-1; - // Choose the kernel that does the reflection/no reflection/partial - // reflection. + // vcutsq diagnostic output is set up below (bc_sheath_gyrokinetic_diag_init); + // these defaults keep release safe when the diagnostic is disabled. + up->vcutsq_diag_on = false; + up->vcutsq_write = false; + up->vcutsq_ho = NULL; + + gkyl_cart_modal_serendip(&up->vcutsq_basis, up->vcutsq_dim, poly_order); + + int lower[up->vcutsq_dim], upper[up->vcutsq_dim]; + for (int d=0; d < cdim-1; d++) { + lower[d] = skin_r->lower[d]; + upper[d] = skin_r->upper[d]; + } + lower[up->vcutsq_dim-1] = skin_r->lower[skin_r->ndim-1]; + upper[up->vcutsq_dim-1] = skin_r->upper[skin_r->ndim-1]; + gkyl_range_init(&up->vcutsq_local, up->vcutsq_basis.ndim, lower, upper); + + int perp_lower[GKYL_MAX_CDIM], perp_upper[GKYL_MAX_CDIM]; + for (int d = 0; d < up->cdim-1; d++) { + perp_lower[d] = up->skin_r->lower[d]; + perp_upper[d] = up->skin_r->upper[d]; + } + gkyl_range_init(&up->perp_local, up->cdim-1, perp_lower, perp_upper); + up->vcutsq = mkarr(use_gpu, up->vcutsq_basis.num_basis, up->vcutsq_local.volume); + + if (type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { + assert(vdim > 1); + assert(q2Dm == -2*GKYL_ELEMENTARY_CHARGE/GKYL_ELECTRON_MASS); // The surrogate is only valid for electrons. + // Assert existence of surrogate model path. + FILE *fp = fopen(surrogate_model_path, "r"); + if (fp == NULL) { + gkyl_exit("surrogate_model_path does not point to a valid file"); + } + up->perp_node_per_cell = 1 << (up->cdim-1); + + // gkyl KANN wrapper + up->kann_net = gkyl_kann_net_load(surrogate_model_path, up->use_gpu); + int dim_in = gkyl_kann_net_dim_in(up->kann_net); + int dim_out = gkyl_kann_net_dim_out(up->kann_net); + // The surrogate must be grid-augmented so dim_out is even. + assert(dim_in == 3 && dim_out > 0 && dim_out % 2 == 0); + int nperp_nodes = up->perp_node_per_cell * up->perp_local.volume; + up->kann_inp = up->use_gpu ? gkyl_kn_vec_cu_dev_new(nperp_nodes, dim_in) : gkyl_kn_vec_new(nperp_nodes, dim_in); + up->kann_out = up->use_gpu ? gkyl_kn_vec_cu_dev_new(nperp_nodes, dim_out) : gkyl_kn_vec_new(nperp_nodes, dim_out); + up->kann_infer_xy_out = mkarr(up->use_gpu, dim_out*pow(2, up->cdim-1), up->skin_r->volume); + up->nn_out = up->use_gpu ? gkyl_cu_malloc(dim_out*pow(2, up->cdim-1)*sizeof(double)) + : gkyl_malloc(dim_out*pow(2, up->cdim-1)*sizeof(double)); + + up->update_vcutsq = bc_gksheath_update_vcutsq_surrogate; + } + + // Choose the kernels that does the reflection/no reflection/partial reflection, + // and surrogate kernels if enabled. up->kernels = gkyl_malloc(sizeof(struct gkyl_bc_sheath_gyrokinetic_kernels)); #ifdef GKYL_HAVE_CUDA if (use_gpu) { up->kernels_cu = gkyl_cu_malloc(sizeof(struct gkyl_bc_sheath_gyrokinetic_kernels)); gkyl_bc_gksheath_choose_reflectedf_kernel_cu(basis, edge, up->kernels_cu); + if (type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { + gkyl_bc_gksheath_choose_surrogate_kernels_cu(basis, edge, up->kernels_cu); + } else { + gkyl_bc_gksheath_choose_const_kernels_cu(basis, edge, up->kernels_cu); + } } else { up->kernels->reflectedf = bc_gksheath_choose_reflectedf_kernel(basis, edge); assert(up->kernels->reflectedf); + if (type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { + bc_gksheath_choose_vcutsq_surr_kernels(basis, edge, up->kernels); + } else { + bc_gksheath_choose_vcutsq_const_kernels(basis, edge, up->kernels); + } up->kernels_cu = up->kernels; } #else up->kernels->reflectedf = bc_gksheath_choose_reflectedf_kernel(basis, edge); assert(up->kernels->reflectedf); + if (type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { + bc_gksheath_choose_vcutsq_surr_kernels(basis, edge, up->kernels); + } else { + bc_gksheath_choose_vcutsq_const_kernels(basis, edge, up->kernels); + } up->kernels_cu = up->kernels; #endif + // Set up diagnostic output of the sheath velocity cutoff (vcutsq). + bc_sheath_gyrokinetic_diag_init(up, phase_grid, phase_local); + return up; } /* Modeled after gkyl_array_flip_copy_to_buffer_fn */ void -gkyl_bc_sheath_gyrokinetic_advance(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, - const struct gkyl_array *phi_wall, struct gkyl_array *distf, const struct gkyl_range *conf_r) +gkyl_bc_sheath_gyrokinetic_advance(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, + const struct gkyl_array *phi_wall, const struct gkyl_array *density, const struct gkyl_array *temperature, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, + struct gkyl_array *distf, const struct gkyl_range *conf_r) { + + // Update the sheath velocity cutoff. + up->update_vcutsq(up, phi, phi_wall, density, temperature, bmag, bimpact_angle, conf_r); + #ifdef GKYL_HAVE_CUDA if (up->use_gpu) { - gkyl_bc_sheath_gyrokinetic_advance_cu(up, phi, phi_wall, distf, conf_r); + gkyl_bc_sheath_gyrokinetic_advance_cu(up, distf, conf_r); return; } #endif int fidx[GKYL_MAX_DIM]; // Flipped index. int vidx[2]; + int vcutsq_idx[up->vcutsq_local.ndim]; int pdim = up->skin_r->ndim; int vpar_dir = up->cdim; @@ -81,9 +344,13 @@ gkyl_bc_sheath_gyrokinetic_advance(const struct gkyl_bc_sheath_gyrokinetic *up, long conf_loc = gkyl_range_idx(conf_r, iter.idx); long vel_loc = gkyl_range_idx(&up->vel_map->local_vel, vidx); - const double *phi_p = (const double*) gkyl_array_cfetch(phi, conf_loc); - const double *phi_wall_p = (const double*) gkyl_array_cfetch(phi_wall, conf_loc); const double *vmap_p = (const double*) gkyl_array_cfetch(up->vel_map->vmap, vel_loc); + + int vcutsq_dim = up->vcutsq_local.ndim; + for (int d=0; dvcutsq_local, vcutsq_idx); + const double *vcutsq_p = (const double*) gkyl_array_cfetch(up->vcutsq, vcutsq_loc); // Calculate reflected distribution function fhat. // note: reflected distribution can be @@ -91,13 +358,34 @@ gkyl_bc_sheath_gyrokinetic_advance(const struct gkyl_bc_sheath_gyrokinetic *up, // 2) fhat=f (full reflection) // 3) fhat=c*f (partial reflection) double fhat[up->basis->num_basis]; - up->kernels->reflectedf(vmap_p, up->q2Dm, phi_p, phi_wall_p, inp, fhat); + up->kernels->reflectedf(vmap_p, vcutsq_p, inp, fhat); // Reflect fhat into skin cells. bc_gksheath_reflect(up->dir, up->basis, up->cdim, out, fhat); } } +void gkyl_bc_sheath_gyrokinetic_set_vcutsq(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *vcutsq) +{ + gkyl_array_copy_range(up->vcutsq, vcutsq, &up->vcutsq_local); +} + +void +gkyl_bc_sheath_gyrokinetic_write_vcutsq(struct gkyl_bc_sheath_gyrokinetic *up, + struct gkyl_msgpack_data *meta, const char *fname) +{ + if (!up->vcutsq_diag_on || !up->vcutsq_write) + return; + + // Copy from device to the host buffer if needed (on CPU vcutsq_ho aliases vcutsq). + if (up->use_gpu) + gkyl_array_copy(up->vcutsq_ho, up->vcutsq); + + // Serial write: this rank owns the entire (perp conf-space + mu) array. + gkyl_grid_sub_array_write(&up->vcutsq_grid, &up->vcutsq_diag_range, meta, + up->vcutsq_ho, fname); +} + void gkyl_bc_sheath_gyrokinetic_release(struct gkyl_bc_sheath_gyrokinetic *up) { // Release memory associated with this updater. @@ -106,7 +394,23 @@ void gkyl_bc_sheath_gyrokinetic_release(struct gkyl_bc_sheath_gyrokinetic *up) gkyl_cu_free(up->kernels_cu); } #endif - gkyl_velocity_map_release(up->vel_map); gkyl_free(up->kernels); + gkyl_velocity_map_release(up->vel_map); + gkyl_array_release(up->vcutsq); + + if (up->vcutsq_diag_on && up->vcutsq_ho) + gkyl_array_release(up->vcutsq_ho); + + if (up->type == GKYL_BC_GK_SPECIES_SHEATH_SURROGATE) { + gkyl_kann_net_release(up->kann_net); + gkyl_kn_vec_release(up->kann_inp); + gkyl_kn_vec_release(up->kann_out); + gkyl_array_release(up->kann_infer_xy_out); + if (up->use_gpu) { + gkyl_cu_free(up->nn_out); + } else { + gkyl_free(up->nn_out); + } + } gkyl_free(up); -} +} \ No newline at end of file diff --git a/gyrokinetic/zero/bc_sheath_gyrokinetic_cu.cu b/gyrokinetic/zero/bc_sheath_gyrokinetic_cu.cu index 59f89886cc..90a4c63924 100644 --- a/gyrokinetic/zero/bc_sheath_gyrokinetic_cu.cu +++ b/gyrokinetic/zero/bc_sheath_gyrokinetic_cu.cu @@ -7,7 +7,7 @@ extern "C" { // CUDA kernel to set device pointers to kernel that computes the reflected f. __global__ static void -gkyl_bc_gksheath_set_cu_ker_ptrs(const struct gkyl_basis *basis, +gkyl_bc_gksheath_set_reflectedf_cu_ker_ptrs(const struct gkyl_basis *basis, enum gkyl_edge_loc edge, struct gkyl_bc_sheath_gyrokinetic_kernels *kers) { int dim = basis->ndim; @@ -28,18 +28,73 @@ void gkyl_bc_gksheath_choose_reflectedf_kernel_cu(const struct gkyl_basis *basis, enum gkyl_edge_loc edge, struct gkyl_bc_sheath_gyrokinetic_kernels *kers) { - gkyl_bc_gksheath_set_cu_ker_ptrs<<<1,1>>>(basis, edge, kers); + gkyl_bc_gksheath_set_reflectedf_cu_ker_ptrs<<<1,1>>>(basis, edge, kers); } +// CUDA kernel to set device pointers to kernel that calls the surrogate. __global__ static void -gkyl_bc_sheath_gyrokinetic_advance_cu_ker(int cdim, int dir, const struct gkyl_range skin_r, const struct gkyl_range ghost_r, - const struct gkyl_range conf_r, const struct gkyl_range vel_r, const struct gkyl_basis *basis, - const struct gkyl_array *vmap, double q2Dm, const struct gkyl_array *phi, - const struct gkyl_array *phi_wall, struct gkyl_bc_sheath_gyrokinetic_kernels *kers, struct gkyl_array *distf) +gkyl_bc_gksheath_set_surrogate_cu_ker_ptrs(const struct gkyl_basis *basis, + enum gkyl_edge_loc edge, struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + int dim = basis->ndim; + enum gkyl_basis_type b_type = basis->b_type; + int poly_order = basis->poly_order; + + switch (b_type) { + case GKYL_BASIS_MODAL_GKHYBRID: + case GKYL_BASIS_MODAL_SERENDIPITY: + kers->vcutsq_surr = ser_sheath_vcutsq_surr_list[edge].dim_list[dim-2].kernels[poly_order-1]; + kers->vcutsq_input = ser_sheath_vcutsq_input_list[edge].dim_list[dim-2].kernels[poly_order-1]; + break; + default: + assert(false); + } +}; + +void +gkyl_bc_gksheath_choose_surrogate_kernels_cu(const struct gkyl_basis *basis, + enum gkyl_edge_loc edge, struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + gkyl_bc_gksheath_set_surrogate_cu_ker_ptrs<<<1,1>>>(basis, edge, kers); +} + +// CUDA kernel to set device pointers to kernel that calls the surrogate. +__global__ static void +gkyl_bc_gksheath_set_const_cu_ker_ptrs(const struct gkyl_basis *basis, + enum gkyl_edge_loc edge, struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + int dim = basis->ndim; + enum gkyl_basis_type b_type = basis->b_type; + int poly_order = basis->poly_order; + + switch (b_type) { + case GKYL_BASIS_MODAL_GKHYBRID: + case GKYL_BASIS_MODAL_SERENDIPITY: + kers->vcutsq_const = ser_sheath_vcutsq_const_list[edge].dim_list[dim-2].kernels[poly_order-1]; + break; + default: + assert(false); + } +}; + +void +gkyl_bc_gksheath_choose_const_kernels_cu(const struct gkyl_basis *basis, + enum gkyl_edge_loc edge, struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + gkyl_bc_gksheath_set_const_cu_ker_ptrs<<<1,1>>>(basis, edge, kers); +} + +__global__ static void +gkyl_bc_sheath_gyrokinetic_advance_cu_ker(int cdim, int dir, const struct gkyl_range skin_r, + const struct gkyl_range ghost_r, const struct gkyl_range conf_r, const struct gkyl_range vcut_r, + const struct gkyl_range vel_r, const struct gkyl_basis *basis, const struct gkyl_array *vmap, + double q2Dm, const struct gkyl_array *vcut_fact, struct gkyl_bc_sheath_gyrokinetic_kernels *kers, + struct gkyl_array *distf) { int fidx[GKYL_MAX_DIM]; // Flipped index. int pidx[GKYL_MAX_DIM]; int vidx[2]; + int vcut_fact_idx[GKYL_MAX_CDIM]; int pdim = skin_r.ndim; int vpar_dir = cdim; @@ -53,6 +108,7 @@ gkyl_bc_sheath_gyrokinetic_advance_cu_ker(int cdim, int dir, const struct gkyl_r // since update_range is a subrange gkyl_sub_range_inv_idx(&skin_r, linc, pidx); + // gkyl_sub_range_inv_idx(&vcut_r, linc, vcut_fact_idx); gkyl_copy_int_arr(pdim, pidx, fidx); fidx[vpar_dir] = uplo - pidx[vpar_dir]; @@ -69,32 +125,207 @@ gkyl_bc_sheath_gyrokinetic_advance_cu_ker(int cdim, int dir, const struct gkyl_r long conf_loc = gkyl_range_idx(&conf_r, pidx); long vel_loc = gkyl_range_idx(&vel_r, vidx); - const double *phi_p = (const double*) gkyl_array_cfetch(phi, conf_loc); - const double *phi_wall_p = (const double*) gkyl_array_cfetch(phi_wall, conf_loc); const double *vmap_p = (const double*) gkyl_array_cfetch(vmap, vel_loc); + // Get vcut factor. + int vcut_fact_dim = vcut_r.ndim; + for (int d=0; dreflectedf(vmap_p, q2Dm, phi_p, phi_wall_p, inp, fhat); + kers->reflectedf(vmap_p, vcut_fact_p, inp, fhat); // Reflect fhat into skin cells. bc_gksheath_reflect(dir, basis, cdim, out, fhat); } } +// Phase 1: fill kann_inp->data for all perpendicular config cells. +// Each thread handles one perp cell; build_input writes n_nodes_per_cell nodes +// with stride dim_in, matching gkyl_kn_vec node-major layout. +__global__ static void +bc_gksheath_fill_kann_inp_cu_ker(enum gkyl_edge_loc edge, + const struct gkyl_range conf_r, const struct gkyl_range perp_r, + const struct gkyl_array *phi, const struct gkyl_array *phi_wall, + const struct gkyl_array *dens, const struct gkyl_array *temp, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, + float *kann_inp_data, int n_nodes_per_cell, int dim_in, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + int perp_idx[GKYL_MAX_CDIM]; + int cidx[GKYL_MAX_CDIM]; + int surf_cidx[GKYL_MAX_CDIM]; + int cdim = conf_r.ndim; + + cidx[cdim-1] = (edge == GKYL_LOWER_EDGE) ? conf_r.lower[cdim-1] : conf_r.upper[cdim-1]; + surf_cidx[cdim-1] = (edge == GKYL_LOWER_EDGE) ? conf_r.lower[cdim-1] : conf_r.upper[cdim-1] + 1; + + for (unsigned long linc = threadIdx.x + blockIdx.x*blockDim.x; + linc < perp_r.volume; linc += blockDim.x*gridDim.x) { + + gkyl_sub_range_inv_idx(&perp_r, linc, perp_idx); + for (int d = 0; d < cdim-1; d++) { + cidx[d] = perp_idx[d]; + surf_cidx[d] = perp_idx[d]; + } + + long conf_loc = gkyl_range_idx(&conf_r, cidx); + long surf_conf_loc = gkyl_range_idx(&conf_r, surf_cidx); + // 0-based sequential perp cell index (gkyl_range_idx gives 0 at lower bound). + long perp_k = gkyl_range_idx(&perp_r, perp_idx); + + const double *phi_p = (const double*) gkyl_array_cfetch(phi, conf_loc); + const double *phi_wall_p = (const double*) gkyl_array_cfetch(phi_wall, conf_loc); + const double *dens_p = (const double*) gkyl_array_cfetch(dens, conf_loc); + const double *temp_p = (const double*) gkyl_array_cfetch(temp, conf_loc); + const double *bmag_p = (const double*) gkyl_array_cfetch(bmag, conf_loc); + const double *bimpact_angle_p = (const double*) gkyl_array_cfetch(bimpact_angle, surf_conf_loc); + + // Cell perp_k occupies nodes [perp_k*n_nodes_per_cell, (perp_k+1)*n_nodes_per_cell) + // in kann_inp_data, each node taking dim_in floats. + int kann_idx_shift = perp_k * n_nodes_per_cell * dim_in; + kers->vcutsq_input(phi_p, phi_wall_p, dens_p, temp_p, bmag_p, bimpact_angle_p, + dim_in, kann_inp_data + kann_idx_shift); + } +} + +// Phase 2 (after gkyl_kann_net_apply): read kann_out->data and project vcut_fact onto DG. +// Each thread handles one (perp, mu) cell. +__global__ static void +bc_gksheath_vcutsq_surr_cu_ker(enum gkyl_edge_loc edge, + const struct gkyl_range conf_r, const struct gkyl_range perp_r, + const struct gkyl_range vcutsq_r, const struct gkyl_range vel_r, + const struct gkyl_array *vmap, int vpar_lower, + const float *kann_out_data, int n_nodes_per_cell, int dim_out, + const struct gkyl_array *temp, const struct gkyl_array *bmag, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers, + struct gkyl_array *vcutsq) +{ + int vcut_idx[GKYL_MAX_CDIM]; + int cidx[GKYL_MAX_CDIM]; + int vidx[2]; + + int cdim = conf_r.ndim; + int vcut_dim = vcutsq_r.ndim; + + cidx[cdim-1] = (edge == GKYL_LOWER_EDGE) ? conf_r.lower[cdim-1] : conf_r.upper[cdim-1]; + vidx[0] = vpar_lower; + + for (unsigned long linc = threadIdx.x + blockIdx.x*blockDim.x; + linc < vcutsq_r.volume; linc += blockDim.x*gridDim.x) { + + gkyl_sub_range_inv_idx(&vcutsq_r, linc, vcut_idx); + for (int d = 0; d < cdim-1; d++) cidx[d] = vcut_idx[d]; // perp config indices. + vidx[1] = vcut_idx[vcut_dim-1]; // mu index. + + long conf_loc = gkyl_range_idx(&conf_r, cidx); + long vel_loc = gkyl_range_idx(&vel_r, vidx); + long vcut_fact_loc = gkyl_range_idx(&vcutsq_r, vcut_idx); + // cidx[0..cdim-2] are the perp indices; gkyl_range_idx on perp_r only reads those. + long perp_k = gkyl_range_idx(&perp_r, cidx); + + const double *vmap_p = (const double*) gkyl_array_cfetch(vmap, vel_loc); + const double *temp_p = (const double*) gkyl_array_cfetch(temp, conf_loc); + const double *bmag_p = (const double*) gkyl_array_cfetch(bmag, conf_loc); + double *vcutsq_p = (double*) gkyl_array_fetch(vcutsq, vcut_fact_loc); + + int kann_idx_shift = perp_k * n_nodes_per_cell * dim_out; + kers->vcutsq_surr(vmap_p, kann_out_data + kann_idx_shift, dim_out, temp_p, bmag_p, vcutsq_p); + } +} + +__global__ static void +bc_gksheath_vcutsq_const_cu_ker(enum gkyl_edge_loc edge, + const struct gkyl_range conf_r, const struct gkyl_range vcutsq_r, + const struct gkyl_array *phi, const struct gkyl_array *phi_wall, double q2Dm, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers, struct gkyl_array *vcutsq) +{ + int vcut_idx[GKYL_MAX_CDIM]; + int cidx[GKYL_MAX_CDIM]; + + int cdim = conf_r.ndim; + + cidx[cdim-1] = (edge == GKYL_LOWER_EDGE) ? conf_r.lower[cdim-1] : conf_r.upper[cdim-1]; + + for (unsigned long linc = threadIdx.x + blockIdx.x*blockDim.x; + linc < vcutsq_r.volume; linc += blockDim.x*gridDim.x) { + + gkyl_sub_range_inv_idx(&vcutsq_r, linc, vcut_idx); + for (int d = 0; d < cdim-1; d++) cidx[d] = vcut_idx[d]; // perp config indices. + + long conf_loc = gkyl_range_idx(&conf_r, cidx); + long vcut_fact_loc = gkyl_range_idx(&vcutsq_r, vcut_idx); + + const double *phi_p = (const double*) gkyl_array_cfetch(phi, conf_loc); + const double *phi_wall_p = (const double*) gkyl_array_cfetch(phi_wall, conf_loc); + double *vcutsq_p = (double*) gkyl_array_fetch(vcutsq, vcut_fact_loc); + + kers->vcutsq_const(phi_p, phi_wall_p, q2Dm, vcutsq_p); + } +} + void -gkyl_bc_sheath_gyrokinetic_advance_cu(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, - const struct gkyl_array *phi_wall, struct gkyl_array *distf, const struct gkyl_range *conf_r) +gkyl_bc_sheath_gyrokinetic_advance_cu(const struct gkyl_bc_sheath_gyrokinetic *up, + struct gkyl_array *distf, const struct gkyl_range *conf_r) { if (up->skin_r->volume > 0) { int nblocks = up->skin_r->nblocks, nthreads = up->skin_r->nthreads; gkyl_bc_sheath_gyrokinetic_advance_cu_ker<<>>(up->cdim, up->dir, *up->skin_r, *up->ghost_r, - *conf_r, up->vel_map->local_vel, up->basis, up->vel_map->vmap->on_dev, up->q2Dm, phi->on_dev, phi_wall->on_dev, - up->kernels_cu, distf->on_dev); + *conf_r, up->vcutsq_local, up->vel_map->local_vel, up->basis, up->vel_map->vmap->on_dev, up->q2Dm, + up->vcutsq->on_dev, up->kernels_cu, distf->on_dev); } } + +void +bc_gksheath_update_vcutsq_surrogate_cu(const struct gkyl_bc_sheath_gyrokinetic *up, + const struct gkyl_array *phi, const struct gkyl_array *phi_wall, const struct gkyl_array *dens, + const struct gkyl_array *temp, const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, + const struct gkyl_range *conf_r) +{ + int n_nodes_per_cell = 1 << (up->cdim-1); + int dim_in = up->kann_inp->N; + int dim_out = up->kann_out->N; + int vpar_lower = up->skin_r->lower[up->cdim]; + + // Phase 1: fill kann_inp on GPU. + if (up->perp_local.volume > 0) { + int nblocks = up->perp_local.nblocks, nthreads = up->perp_local.nthreads; + bc_gksheath_fill_kann_inp_cu_ker<<>>(up->edge, *conf_r, up->perp_local, + phi->on_dev, phi_wall->on_dev, dens->on_dev, temp->on_dev, bmag->on_dev, bimpact_angle->on_dev, + up->kann_inp->data, n_nodes_per_cell, dim_in, up->kernels_cu); + } + + // Phase 2: run NN inference (CUDA kernel dispatched inside gkyl_kann_net_apply). + // CUDA launches are serialized in the default stream, so this runs after phase 1. + gkyl_kann_net_apply(up->kann_net, up->kann_inp, up->kann_out); + + // Phase 3: project NN output onto DG vcut_fact. + if (up->vcutsq_local.volume > 0) { + int nblocks = up->vcutsq_local.nblocks, nthreads = up->vcutsq_local.nthreads; + bc_gksheath_vcutsq_surr_cu_ker<<>>(up->edge, *conf_r, up->perp_local, + up->vcutsq_local, up->vel_map->local_vel, up->vel_map->vmap->on_dev, vpar_lower, + up->kann_out->data, n_nodes_per_cell, dim_out, + temp->on_dev, bmag->on_dev, up->kernels_cu, up->vcutsq->on_dev); + } +} + +void +bc_gksheath_update_vcutsq_const_cu(const struct gkyl_bc_sheath_gyrokinetic *up, + const struct gkyl_array *phi, const struct gkyl_array *phi_wall, const struct gkyl_array *dens, + const struct gkyl_array *temp, const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, + const struct gkyl_range *conf_r) +{ + if (up->vcutsq_local.volume > 0) { + int nblocks = up->vcutsq_local.nblocks, nthreads = up->vcutsq_local.nthreads; + bc_gksheath_vcutsq_const_cu_ker<<>>(up->edge, *conf_r, + up->vcutsq_local, phi->on_dev, phi_wall->on_dev, up->q2Dm, up->kernels_cu, up->vcutsq->on_dev); + } +} \ No newline at end of file diff --git a/gyrokinetic/zero/calc_metric_mirror.c b/gyrokinetic/zero/calc_metric_mirror.c index ad8bbeac0e..502807256c 100644 --- a/gyrokinetic/zero/calc_metric_mirror.c +++ b/gyrokinetic/zero/calc_metric_mirror.c @@ -241,7 +241,6 @@ gkyl_calc_metric_mirror_advance_interior( gkyl_calc_metric_mirror *up, struct gk gkyl_nodal_ops_n2m(up->n2m, up->cbasis, up->grid, &gk_geom->nrange_int, &gk_geom->local, 1, gk_geom->geo_int.rtg33inv_nodal, gk_geom->geo_int.rtg33inv, true); gkyl_nodal_ops_n2m(up->n2m, up->cbasis, up->grid, &gk_geom->nrange_int, &gk_geom->local, 3, gk_geom->geo_int.bioverJB_nodal, gk_geom->geo_int.bioverJB, true); gkyl_nodal_ops_n2m(up->n2m, up->cbasis, up->grid, &gk_geom->nrange_int, &gk_geom->local, 1, gk_geom->geo_int.B3_nodal, gk_geom->geo_int.B3, true); - } void gkyl_calc_metric_mirror_advance_surface( gkyl_calc_metric_mirror *up, int dir, struct gk_geometry *gk_geom, struct gkyl_mirror_grid_gen *mirror_grid) diff --git a/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic.h b/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic.h index 0d613e4ab3..ca84ef8ba7 100644 --- a/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic.h +++ b/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic.h @@ -5,6 +5,12 @@ #include #include #include +#include +#include +#include + +// Forward declaration of msgpack metadata (defined in gkyl_array_rio.h). +struct gkyl_msgpack_data; // Object type typedef struct gkyl_bc_sheath_gyrokinetic gkyl_bc_sheath_gyrokinetic; @@ -20,28 +26,61 @@ typedef struct gkyl_bc_sheath_gyrokinetic gkyl_bc_sheath_gyrokinetic; * @param vel_map Velocity space mapping object. * @param cdim Configuration space dimensions. * @param q2Dm charge-to-mass ratio times 2. + * @param type Type of gyrokinetic BC to apply. + * @param surrogate_model_path Path to the .kann surrogate model file (NULL if not using surrogate). + * @param phase_grid Phase-space grid, used to build the vcutsq diagnostic grid. + * @param phase_local Local phase-space range. + * @param poly_order Polynomial order of the basis functions (used to build the vcutsq diagnostic grid). * @param use_gpu Boolean to indicate whether to use the GPU. * @return New updater pointer. */ struct gkyl_bc_sheath_gyrokinetic* gkyl_bc_sheath_gyrokinetic_new(int dir, enum gkyl_edge_loc edge, const struct gkyl_basis *basis, const struct gkyl_range *skin_r, const struct gkyl_range *ghost_r, - const struct gkyl_velocity_map *vel_map, int cdim, double q2Dm, bool use_gpu); + const struct gkyl_velocity_map *vel_map, int cdim, double q2Dm, enum gkyl_gyrokinetic_bc_type type, + const char *surrogate_model_path, const struct gkyl_rect_grid *phase_grid, + const struct gkyl_range *phase_local, unsigned int poly_order, bool use_gpu); /** - * Apply the sheath BC with the bc_sheath_gyrokinetic object. + * Compute the cutting velicity and apply the sheath BC with the bc_sheath_gyrokinetic object. * * @param up BC updater. - * @param phi Electrostatic potential. - * @param phi_wall Wall potential. + * @param phi Electrostatic potential at the magnetic presheath entrance (simulation boundary). + * @param phi_wall Electrostatic potential at the wall. + * @param density Density at the magnetic presheath entrance. + * @param temperature Temperature at the magnetic presheath entrance. + * @param bmag Magnetic field strength at the magnetic presheath entrance. + * @param bimpact_angle Angle of the magnetic field with respect to the wall at the magnetic presheath entrance. * @param distf Distribution function array to apply BC to. * @param conf_r Configuration space range (to index phi). */ -void gkyl_bc_sheath_gyrokinetic_advance(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, - const struct gkyl_array *phi_wall, struct gkyl_array *distf, const struct gkyl_range *conf_r); +void gkyl_bc_sheath_gyrokinetic_advance(const struct gkyl_bc_sheath_gyrokinetic *up, + const struct gkyl_array *phi, const struct gkyl_array *phi_wall, const struct gkyl_array *density, + const struct gkyl_array *temperature, const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, + struct gkyl_array *distf, const struct gkyl_range *conf_r); + +/** + * Set the vcut_fact array used in the sheath BC. + * This is used to implement a mu-dependent vcut in the sheath BC, + * where vcut_fact is the mu dependent multiplying factor in the expression for vcut. + * + * @param up BC updater. + * @param vcut_fact The vcut_fact array to use in the sheath BC. + */ +void gkyl_bc_sheath_gyrokinetic_set_vcutsq(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *vcut_fact); + +/** + * Write out the vcutsq array. + * + * @param up BC updater. + * @param meta Metadata to write (may be NULL). + * @param fname Name of output file (including .gkyl extension). + */ +void gkyl_bc_sheath_gyrokinetic_write_vcutsq(struct gkyl_bc_sheath_gyrokinetic *up, + struct gkyl_msgpack_data *meta, const char *fname); /** * Free memory associated with bc_sheath_gyrokinetic updater. * * @param up BC updater. */ -void gkyl_bc_sheath_gyrokinetic_release(struct gkyl_bc_sheath_gyrokinetic *up); +void gkyl_bc_sheath_gyrokinetic_release(struct gkyl_bc_sheath_gyrokinetic *up); \ No newline at end of file diff --git a/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic_priv.h b/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic_priv.h index b76ed35d6e..9319a015b5 100644 --- a/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic_priv.h +++ b/gyrokinetic/zero/gkyl_bc_sheath_gyrokinetic_priv.h @@ -2,13 +2,12 @@ // Private header for bc_sheath_gyrokinetic updater, not for direct use in user code. -#include -#include +#include "gkyl_bc_sheath_gyrokinetic.h" +#include "gkyl_bc_sheath_gyrokinetic_kernels.h" #include // Function pointer type for sheath reflection kernels. -typedef void (*sheath_reflectedf_t)(const double *vmap, const double q2Dm, - const double *phi, const double *phiWall, const double *f, double *fRefl); +typedef void (*sheath_reflectedf_t)(const double *vmap, const double *vcutsq, const double *f, double *fRefl); typedef struct { sheath_reflectedf_t kernels[3]; } sheath_reflectedf_kern_list; // For use in kernel tables. typedef struct { sheath_reflectedf_kern_list list[4]; } edged_sheath_reflectedf_kern_list; @@ -32,14 +31,92 @@ static const edged_sheath_reflectedf_kern_list ser_sheath_reflect_list[] = { }, }; +typedef void (*sheath_vcutsq_const_t)(const double *phi, const double *phi_wall, double q2Dm, double *vcutsq_out); +typedef struct { sheath_vcutsq_const_t kernels[3]; } sheath_vcutsq_const_kern_list; // For use in kernel tables. +typedef struct { sheath_vcutsq_const_kern_list dim_list[4]; } edged_sheath_vcutsq_const_kern_list; + +// Serendipity kernels to calculate vcut using conducting sheath model. +GKYL_CU_D +static const edged_sheath_vcutsq_const_kern_list ser_sheath_vcutsq_const_list[] = { + { .dim_list={ + { NULL, NULL }, + { bc_sheath_gyrokinetic_vcutsq_const_lower_1x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_const_lower_2x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_const_lower_3x2v_ser_p1, NULL }, + }, + }, + { .dim_list={ + { NULL, NULL }, + { bc_sheath_gyrokinetic_vcutsq_const_upper_1x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_const_upper_2x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_const_upper_3x2v_ser_p1, NULL }, + }, + }, +}; + +// Function pointer type for surrogate sheath BC to determine vcut factor from pre-computed NN output. +typedef void (*sheath_vcutsq_surr_t)(const double *vmap, const float *nn_out, int n_out, + const double *temperature, const double *bmag, double *vcutsq_out); + +typedef struct { sheath_vcutsq_surr_t kernels[3]; } sheath_vcutsq_surr_kern_list; // For use in kernel tables. +typedef struct { sheath_vcutsq_surr_kern_list dim_list[4]; } edged_sheath_vcutsq_surr_kern_list; + +// Serendipity to evaluate vcut from the KANN surrogate model output. +GKYL_CU_D +static const edged_sheath_vcutsq_surr_kern_list ser_sheath_vcutsq_surr_list[] = { + { .dim_list={ + { NULL, NULL }, + { bc_sheath_gyrokinetic_vcutsq_surr_lower_1x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_surr_lower_2x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_surr_lower_3x2v_ser_p1, NULL }, + }, + }, + { .dim_list={ + { NULL, NULL }, + { bc_sheath_gyrokinetic_vcutsq_surr_upper_1x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_surr_upper_2x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_vcutsq_surr_upper_3x2v_ser_p1, NULL }, + }, + }, +}; + +// Function pointer type for the build the KANN input. +typedef void (*sheath_surrogate_inp_t)(const double *phi, const double *phi_wall, const double *density, + const double *temperature, const double *bmag, const double *bimpact_angle, int n_inp, float *inp_out); +typedef struct { sheath_surrogate_inp_t kernels[3]; } sheath_inp_kern_list; +typedef struct { sheath_inp_kern_list dim_list[4]; } edged_sheath_inp_kern_list; + +// Serendipity kernels to build the KANN input. +GKYL_CU_D +static const edged_sheath_inp_kern_list ser_sheath_vcutsq_input_list[] = { + { .dim_list={ + { NULL, NULL }, + { bc_sheath_gyrokinetic_build_input_lower_1x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_build_input_lower_2x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_build_input_lower_3x2v_ser_p1, NULL }, + }, + }, + { .dim_list={ + { NULL, NULL }, + { bc_sheath_gyrokinetic_build_input_upper_1x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_build_input_upper_2x2v_ser_p1, NULL }, + { bc_sheath_gyrokinetic_build_input_upper_3x2v_ser_p1, NULL }, + }, + }, +}; + struct gkyl_bc_sheath_gyrokinetic_kernels { - sheath_reflectedf_t reflectedf; // reflectedf kernel. + sheath_reflectedf_t reflectedf; // reflectedf kernel. + sheath_surrogate_inp_t vcutsq_input; // NN input construction kernel. + sheath_vcutsq_surr_t vcutsq_surr; // vcut_fact DG projection kernel (uses pre-computed NN output). + sheath_vcutsq_const_t vcutsq_const; // vcut calculation using conducting sheath model. }; // Primary struct in this updater. struct gkyl_bc_sheath_gyrokinetic { int dir; // Direction perpendicular to the sheath boundary. int cdim; // Conf-space dimensionality. + enum gkyl_gyrokinetic_bc_type type; // Type of gyrokinetic BC. enum gkyl_edge_loc edge; // Lower or upper boundary. const struct gkyl_basis *basis; // Phase-space basis. bool use_gpu; // Whether to run on GPU. @@ -48,6 +125,27 @@ struct gkyl_bc_sheath_gyrokinetic { struct gkyl_bc_sheath_gyrokinetic_kernels *kernels_cu; // device copy. const struct gkyl_range *skin_r, *ghost_r; // Skin and ghost ranges. const struct gkyl_velocity_map *vel_map; // Velocity space mapping. + int vcutsq_dim; // Dimensionality of vcutsq array. + struct gkyl_array *vcutsq; // factor for mu dependent vcut in sheath BC. + struct gkyl_basis vcutsq_basis; // Basis for vcutsq array (expansion in perpendicular config space and mu). + struct gkyl_range vcutsq_local; // Range for vcutsq array. + struct gkyl_range perp_local; // Peprendicular conf space range. + int perp_node_per_cell; // Number of nodes per cell in the perpendicular conf. space. + void (*update_vcutsq) (const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, + const struct gkyl_array *phi_wall, const struct gkyl_array *dens, const struct gkyl_array *temp, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, const struct gkyl_range *conf_r); // Function pointer to update vcutsq array. + struct gkyl_kann_net *kann_net; // KANN sheath surrogate. + struct gkyl_kn_vec *kann_inp; // Input vector for KANN surrogate (3 x number of perp nodes). + struct gkyl_kn_vec *kann_out; // Output vector for KANN surrogate: dim_out x number of perp nodes, where each node block is dim_out/2 vcut values followed by dim_out/2 mu-grid values. + struct gkyl_array *kann_infer_xy_out; // Output array for KANN on a perpendicular plane. + double *nn_out; // Buffer to hold raw NN outputs for all perp nodes (device memory when using GPU). + + // Diagnostic output of the vcutsq array. + bool vcutsq_diag_on; // Whether the vcutsq diagnostic output is set up. + bool vcutsq_write; // Whether this rank abuts the boundary and writes vcutsq. + struct gkyl_rect_grid vcutsq_grid; // Grid for vcutsq output (perp conf-space + mu). + struct gkyl_range vcutsq_diag_range, vcutsq_diag_range_ext; // Output ranges (matching vcutsq_grid). + struct gkyl_array *vcutsq_ho; // Host buffer for vcutsq output. }; void @@ -60,15 +158,22 @@ bc_gksheath_choose_reflectedf_kernel(const struct gkyl_basis *basis, enum gkyl_e int dim = basis->ndim; enum gkyl_basis_type basis_type = basis->b_type; int poly_order = basis->poly_order; + + sheath_reflectedf_t kern = NULL; + switch (basis_type) { case GKYL_BASIS_MODAL_GKHYBRID: + kern = ser_sheath_reflect_list[edge].list[dim-2].kernels[poly_order-1]; + break; case GKYL_BASIS_MODAL_SERENDIPITY: - return ser_sheath_reflect_list[edge].list[dim-2].kernels[poly_order-1]; + kern = ser_sheath_reflect_list[edge].list[dim-2].kernels[poly_order-1]; + break; default: - assert(false); + kern = NULL; break; } - return 0; + assert(kern); // Reflection kernel must be non-null since we always use reflection BCs in the sheath updater. + return kern; } GKYL_CU_D @@ -79,6 +184,53 @@ bc_gksheath_reflect(int dir, const struct gkyl_basis *basis, int cdim, double *o basis->flip_odd_sign(cdim, out, out); // cdim is the vpar direction. } +void +gkyl_bc_gksheath_choose_surrogate_kernels_cu(const struct gkyl_basis *basis, enum gkyl_edge_loc edge, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers); + +GKYL_CU_D +static void +bc_gksheath_choose_vcutsq_surr_kernels(const struct gkyl_basis *basis, enum gkyl_edge_loc edge, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + int dim = basis->ndim; + enum gkyl_basis_type basis_type = basis->b_type; + int poly_order = basis->poly_order; + + switch (basis_type) { + case GKYL_BASIS_MODAL_GKHYBRID: + case GKYL_BASIS_MODAL_SERENDIPITY: + kers->vcutsq_surr = ser_sheath_vcutsq_surr_list[edge].dim_list[dim-2].kernels[poly_order-1]; + kers->vcutsq_input = ser_sheath_vcutsq_input_list[edge].dim_list[dim-2].kernels[poly_order-1]; + break; + default: + assert(false); + } +} + +void +gkyl_bc_gksheath_choose_const_kernels_cu(const struct gkyl_basis *basis, enum gkyl_edge_loc edge, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers); + +GKYL_CU_D +static void +bc_gksheath_choose_vcutsq_const_kernels(const struct gkyl_basis *basis, enum gkyl_edge_loc edge, + struct gkyl_bc_sheath_gyrokinetic_kernels *kers) +{ + int dim = basis->ndim; + enum gkyl_basis_type basis_type = basis->b_type; + int poly_order = basis->poly_order; + + switch (basis_type) { + case GKYL_BASIS_MODAL_GKHYBRID: + case GKYL_BASIS_MODAL_SERENDIPITY: + kers->vcutsq_const = ser_sheath_vcutsq_const_list[edge].dim_list[dim-2].kernels[poly_order-1]; + break; + default: + assert(false); + } +} + #ifdef GKYL_HAVE_CUDA /** @@ -90,7 +242,40 @@ bc_gksheath_reflect(int dir, const struct gkyl_basis *basis, int cdim, double *o * @param distf Distribution function array to apply BC to. * @param conf_r Configuration space range (to index phi). */ -void gkyl_bc_sheath_gyrokinetic_advance_cu(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, - const struct gkyl_array *phi_wall, struct gkyl_array *distf, const struct gkyl_range *conf_r); +void gkyl_bc_sheath_gyrokinetic_advance_cu(const struct gkyl_bc_sheath_gyrokinetic *up, + struct gkyl_array *distf, const struct gkyl_range *conf_r); +/** + * CUDA device function to update the vcutsq array with surrogate. + * + * @param up BC updater. + * @param phi Electrostatic potential. + * @param phi_wall Wall potential. + * @param dens Density array. + * @param temp Temperature array. + * @param bmag Magnetic field magnitude array. + * @param bimpact_angle Magnetic field impact angle array. + * @param conf_r Configuration space range (to index phi, dens, temp, bmag, and bimpact_angle). + * + */ +void bc_gksheath_update_vcutsq_surrogate_cu(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, + const struct gkyl_array *phi_wall, const struct gkyl_array *dens, const struct gkyl_array *temp, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, const struct gkyl_range *conf_r); + +/** + * CUDA device function to update the vcutsq array with conducting sheath model. + * + * @param up BC updater. + * @param phi Electrostatic potential. + * @param phi_wall Wall potential. + * @param dens Density array. + * @param temp Temperature array. + * @param bmag Magnetic field magnitude array. + * @param bimpact_angle Magnetic field impact angle array. + * @param conf_r Configuration space range (to index phi, dens, temp, bmag, and bimpact_angle). + * + */ +void bc_gksheath_update_vcutsq_const_cu(const struct gkyl_bc_sheath_gyrokinetic *up, const struct gkyl_array *phi, + const struct gkyl_array *phi_wall, const struct gkyl_array *dens, const struct gkyl_array *temp, + const struct gkyl_array *bmag, const struct gkyl_array *bimpact_angle, const struct gkyl_range *conf_r); #endif diff --git a/gyrokinetic/zero/gkyl_gk_bc_type.h b/gyrokinetic/zero/gkyl_gk_bc_type.h index 05be67186e..2c433aa600 100644 --- a/gyrokinetic/zero/gkyl_gk_bc_type.h +++ b/gyrokinetic/zero/gkyl_gk_bc_type.h @@ -14,7 +14,8 @@ enum gkyl_gyrokinetic_bc_type { GKYL_BC_GK_SPECIES_FUNC, // Fill ghost cell using a user-function. GKYL_BC_GK_SPECIES_FIXED_FUNC, // Fixed function, time-independent. GKYL_BC_GK_SPECIES_ZERO_FLUX, // Zero flux. - GKYL_BC_GK_SPECIES_SHEATH, // Sheath. + GKYL_BC_GK_SPECIES_SHEATH_CONDUCTING, // Conducting sheath model. + GKYL_BC_GK_SPECIES_SHEATH_SURROGATE, // Surrogate sheath model. GKYL_BC_GK_SPECIES_RECYCLE, // Recycling. GKYL_BC_GK_SPECIES_PERIODIC, // Periodic. GKYL_BC_GK_SPECIES_TWISTSHIFT, // Twist-shift.