Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CompressibleEulerPlasma equations #53

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

warisa-r
Copy link

The system consists of two conservation laws, one for ions and the other for electrons. An example of these equations is also added.

This is what running elixir_euler_ion_electron.jl yields

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'CompressibleEulerPlasmaEquations1D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                156                run time:       1.35516830e+00 s
 Δt:             6.21881047e-03                └── GC time:    2.30169700e-01 s (16.985%)
 sim. time:      2.00000000e+00 (100.000%)     time/DOF/rhs!:  3.50239101e-07 s
                                               PID:            1.38579241e-06 s
 #DOFs per field:            64                alloc'd memory:        143.465 MiB
 #elements:                  16

 Variable:       rho_ion          rho_v1_ion       rho_e_ion        rho_el           rho_v1_el        rho_e_el
 L2 error:       1.93556997e-02   2.23269846e-02   2.52366595e-02   1.93556997e-02   2.23269846e-02   2.52366595e-02
 Linf error:     2.89596113e-02   3.29344248e-02   4.24609828e-02   2.89596113e-02   3.29344248e-02   4.24609828e-02
 Variable:       rho_ion          v1_ion           p_ion            rho_el           v1_el            p_el
 L2 error prim.: 1.93556997e-02   2.72638095e-03   5.58520892e-03   1.93556997e-02   2.72638095e-03   5.58520892e-03
 Linf error pri.:2.89596113e-02   4.12820033e-03   1.04425919e-02   2.89596113e-02   4.12820033e-03   1.04425919e-02
 ∑∂S/∂U ⋅ Uₜ :  -2.51963484e-03

Copy link

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Copy link
Owner

@DanielDoehring DanielDoehring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good first effort!
Seeing this, I would in general opt for implementing the Multi-Ion Euler equations, similar to the Multi-Ion MHD equations. Then, we can derive the Electron-Ion as a special case for this.

src/equations/compressible_euler_plasma.jl Outdated Show resolved Hide resolved
new{typeof(γ)}(γ, inv_gamma_minus_one)
end
end

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general comment: Maybe the best idea is to implement at first Multi-Ion Euler in a general fashion, such as done by Andres. Then, we can derive the Electron-Ion system from that as a special case.

Comment on lines 22 to 26
@inline function single_species_flux(rho, rho_v1, rho_e, gamma)
v1 = rho_v1 / rho
p = (gamma - 1) * (rho_e - 0.5 * rho_v1 * v1)
return SVector(rho_v1, rho_v1 * v1 + p, (rho_e + p) * v1)
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of the extracted single species flux. Should be dispatched for the equation type and orientation/normal direction, though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Maybe the implementation of iterating through each ion species (the way ideal_glm_mhd_multiion_2d.jl is handling this aspect) might be more compact. However, if you still think that this is a good idea, I can bring this function back.

src/equations/compressible_euler_plasma.jl Outdated Show resolved Hide resolved
src/equations/compressible_euler_plasma.jl Outdated Show resolved Hide resolved
src/equations/compressible_euler_plasma.jl Outdated Show resolved Hide resolved
src/equations/compressible_euler_plasma.jl Outdated Show resolved Hide resolved
@warisa-r
Copy link
Author

warisa-r commented Jan 14, 2025

Good first effort! Seeing this, I would in general opt for implementing the Multi-Ion Euler equations, similar to the Multi-Ion MHD equations. Then, we can derive the Electron-Ion as a special case for this.

Thank you for your detailed feedback! I have implemented the multi-ion system for compressible Euler equations. Is this now more in line with what you had in mind?

Running elixir_euler_multiion.jl yields

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'CompressibleEulerMultiIonEquations1D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                197                run time:       8.55753000e-02 s
 Δt:             7.92328612e-03                └── GC time:    0.00000000e+00 s (0.000%)
 sim. time:      2.00000000e+00 (100.000%)     time/DOF/rhs!:  1.84606481e-07 s
                                               PID:            3.91723582e-07 s
 #DOFs per field:            64                alloc'd memory:        158.932 MiB
 #elements:                  16

 Variable:       rho_1            rho_v1_1         rho_e_1          rho_2            rho_v1_2         rho_e_2          rho_3            rho_v1_3         rho_e_3
 L2 error:       2.31589449e-02   2.56244270e-02   2.69083460e-02   9.56221097e-03   1.90514680e-02   3.00279574e-02   2.31589449e-02   2.56244270e-02   2.69083460e-02
 Linf error:     3.31077549e-02   3.76854873e-02   4.56909872e-02   1.53340143e-02   3.08183559e-02   4.70978104e-02   3.31077549e-02   3.76854873e-02   4.56909872e-02
 Variable:       rho_1            v1_1             p_1              rho_2            v1_2             p_2              rho_3            v1_3             p_3
 L2 error prim.: 2.31589449e-02   3.35902165e-03   5.62572214e-03   9.56221097e-03   6.53763949e-03   1.18176493e-02   2.31589449e-02   3.35902165e-03   5.62572214e-03   
 Linf error pri.:3.31077549e-02   6.01291036e-03   1.08211138e-02   1.53340143e-02   1.15000182e-02   2.10914894e-02   3.31077549e-02   6.01291036e-03   1.08211138e-02
 ∑∂S/∂U ⋅ Uₜ :  -2.33315322e-03
────────────────────────────────────────────────────────────────────────────────────────────────────

P.S. The example also works with lax-friedrichs flux.

@DanielDoehring
Copy link
Owner

Yeah, looking good!

Now we need to find a way to make this system really coupled. Staying for the moment with the ion-only case, you could take a look at the work by Andres

trixi-framework#2213

and implement the ion-ion collision source terms. I am not sure if the testcase itself makes sense, or if you need for this the electron temperature/pressure business.

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.

2 participants