ammarhakim / gkylzero

Lowest, compiled layer of Gkeyll infrastructure.
MIT License
22 stars 5 forks source link

Energy Conserving P2 Can-pb Colls Fix #464

Closed johnson452 closed 1 month ago

johnson452 commented 1 month ago

Branch: can_pb_total_energy_dynvec.

Summary: This branch corrects an inconsistency in the way canonical-pb handled BGK collisions in p2. Essentially the issue was calculating pressure in terms of the quantity "h^{ij}M{2ij}" where "M{2ij}" was not within the Serindipity basis. This has been corrected by replacing this term with "2E" where E = int (Hf dp).

In addition to this correction, a new moment routine was added to compute E = int (H*f dp), as well as integrated canonical-pb moments: [Density, Momenta, Energy]. (Described further in the attached notes). Integrated moments are accessed through the existing integrated moment infrastructure, and for can-pb Energy is from specifying the moment "MEnergy".

New functions zero/gkyl_mom_canonical_pb.h (Mirrored from the moments of gkyl_mom_vlasov_sr.h)

// Create new canonical-pb moment type object.

// Valid 'mom' strings are "MEnergy" which is the integral(hamil*f) 
struct gkyl_mom_type* gkyl_mom_canonical_pb_new(const struct gkyl_basis* cbasis,
  const struct gkyl_basis* pbasis, 
  const struct gkyl_range* phase_range, 
  const char *mom, bool use_gpu);

 // Create new canonical-pb integrated moment type object. Integrates (MEnergy).
struct gkyl_mom_type* gkyl_int_mom_canonical_pb_new(const struct gkyl_basis* cbasis,
  const struct gkyl_basis* pbasis, 
  const struct gkyl_range* phase_range, 
  bool use_gpu);

New Regression Tests regression/rt_can_pb_neut_bgk_sodshock_im_1x1v_p2.c regression/rt_can_pb_bgk_surf_annulus_sodshock_im.c

Tests of energy conservation p1, p2 with/without collisions for flat 1x1v sodshock and 2x2v annular disk sodshock (See regression tests)

Canonical_Poisson_Bracket-6.pdf

johnson452 commented 1 month ago

Evidence of p2 energy conservation from the integrated moments for the annular sodshock case. What is shown is integrated density, momenta (R-direction), momenta (theta-direction), Energy vs time. Integrated_moms_can_pb_p2_annular_sodshock

JunoRavin commented 1 month ago

This design review is now implemented in main via PR: https://github.com/ammarhakim/gkylzero/pull/491