Skip to content

Experiment with explicit hybrid solver#22

Open
henry2004y wants to merge 1 commit intoSWMFsoftware:masterfrom
henry2004y:hybrid
Open

Experiment with explicit hybrid solver#22
henry2004y wants to merge 1 commit intoSWMFsoftware:masterfrom
henry2004y:hybrid

Conversation

@henry2004y
Copy link
Contributor

This is the first experiment with an explicit hybrid solver in FLEKS. During the changes, I noticed that the current design always assumes species 0 to be electron. As a temporary workaround, we introduced a activeSpecies vector to keep track of active populations.

Summary of Changes

  1. Hybrid Solver & Generalized Ohm's Law
    Implemented the full generalized Ohm's law: $$\mathbf{E} = -\mathbf{U}_i \times \mathbf{B} + \frac{\mathbf{J} \times \mathbf{B}}{n_e} + \eta\mathbf{J} + \frac{\nabla P_e}{n_e}$$

where:

$\mathbf{U}_i$: Ion bulk velocity (from particle moments)
$\mathbf{J} = \nabla \times \mathbf{B}$: Current density
$n_e \approx n_i$: Electron density (quasi-neutrality)
$P_e$: Electron pressure (adiabatic)
New Parameters:

  • useHybridPIC (logical): Activates hybrid mode (disables Maxwell solver).
  • etaResistivity (real): Resistivity $\eta$.
  • electronTemperature, electronGamma, electronDensity0 (real): For adiabatic pressure gradient.
  • nHallSubcycle (int): Number of subcycles for B-field update (Hall term stability).
  1. Architecture Updates
  • update_E_hybrid(): Computes the convection term $-\mathbf{U}_i \times \mathbf{B}$. This term depends on particle moments and is frozen during the B-field subcycling.
  • update_B_hybrid(): New function that subcycles the B-field update. In each substep (dt_sub = dt/nHallSubcycle), it:
    • Recomputes $\mathbf{J} = \nabla \times \mathbf{B}$.
    • Computes B-dependent terms: Hall, Resistivity, and Pressure Gradient.
    • Updates $\mathbf{B}$ using the combined E-field.
  • Particle Handling:
    • Electron Removal: When useHybridPIC is true, electron particles are not initialized or moved.
    • Active Species Refactor: Replaced raw nSpecies loops with activeSpecies vector iteration to efficiently handle cases where some species (electrons) are present in the config but active (null).
  1. File Changes
  • Pic.h: Added new parameters and update_B_hybrid declaration.
  • Pic.cpp:
    • Implemented update_E_hybrid and update_B_hybrid.
    • Modified particle_mover and iterators to use activeSpecies.
    • Added parsing for #HYBRIDPIC, #RESISTIVITY, #ELECTRONTEMPERATURE, #HALLSUBCYCLE.
  • Domain.cpp: Registered new commands.
  • PARAM.XML: Updated XML schema for new commands.

Verification

Hybrid Mode Validation

  • Test Case: test_hybrid (based on test16_2d, not included in this PR since it is in the SWMF git repository; this is quite annoying for development!)
  • Configuration:
    • useHybridPIC = T
    • etaResistivity = 1.0
    • electronTemperature = 5.12e-4, gamma = 5/3
    • nHallSubcycle = 4
  • Result: Stable simulation, correct parameter parsing, and physics terms active.

Regression Testing (Standard GM-PC)

Verified that standard GM-PC functionality is unaffected by running the following regression tests (all passed with 0 differences against reference):

  • test16_2d (GM-PC 2D)
  • test16_3d (GM-PC 3D)
  • test17 (2D Alfven Wave)
  • test18 (3D Reconnection)
  • test23_2d (2D Fast Wave AMR)
  • test23_3d (3D Fast Wave AMR)
  • test25 (3D Light Wave AMR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant