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 collision source terms for multi-ion MHD #2213

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

Conversation

amrueda
Copy link
Contributor

@amrueda amrueda commented Dec 17, 2024

This PR introduces collision source terms for multi-ion MHD, accompanied by detailed documentation and a physically relevant test case based on the following reference:

  • Ghosh, D., Chapman, T. D., Berger, R. L., Dimits, A., & Banks, J. W. (2019). A multispecies, multifluid model for laser–induced counterstreaming plasma simulations. Computers & Fluids, 186, 38-57.

The Figure shows the temperature of two ion species for the second frictional slow-down test described in the reference above, as computed with examples/tree_2d_dgsem/elixir_mhdmultiion_collisions.jl and source_terms = source_terms_collision_ion_ion.
image

@amrueda amrueda marked this pull request as draft December 17, 2024 18:48
Copy link
Contributor

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

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.38%. Comparing base (f09a707) to head (1b036f4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2213      +/-   ##
==========================================
+ Coverage   96.37%   96.38%   +0.01%     
==========================================
  Files         486      487       +1     
  Lines       39186    39291     +105     
==========================================
+ Hits        37764    37869     +105     
  Misses       1422     1422              
Flag Coverage Δ
unittests 96.38% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@amrueda amrueda marked this pull request as ready for review December 19, 2024 17:49
Comment on lines +194 to +197
v_mag = sqrt(v1^2 + v2^2 + v3^2)
gamma = equations.gammas[k]
p[k] = (gamma - 1) *
(rho_e - 0.5f0 * rho * v_mag^2 - 0.5f0 * (B1^2 + B2^2 + B3^2))
Copy link
Contributor

@DanielDoehring DanielDoehring Dec 20, 2024

Choose a reason for hiding this comment

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

This is a little inconsistent as there is v_mag but no B_mag.

Comment on lines +524 to +527
References:
- P. Rambo, J. Denavit, Interpenetration and ion separation in colliding plasmas, Physics of Plasmas 1 (1994) 4050–4060.
- Schunk, R. W., Nagy, A. F. (2000). Ionospheres: Physics, plasma physics, and chemistry.
Cambridge university press.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you provide the DOI here?

Comment on lines +529 to +530
function source_terms_collision_ion_ion(u, x, t,
equations::AbstractIdealGlmMhdMultiIonEquations)
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: Could one re-use this for a 2 fluid (ion-electron) Euler-Poisson Plasma approximation?

Comment on lines +614 to +617
References:
- P. Rambo, J. Denavit, Interpenetration and ion separation in colliding plasmas, Physics of Plasmas 1 (1994) 4050–4060.
- Schunk, R. W., Nagy, A. F. (2000). Ionospheres: Physics, plasma physics, and chemistry.
Cambridge university press.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Comment on lines +78 to +79
- Schunk, R. W., & Nagy, A. F. (2000). Ionospheres: Physics, plasma physics, and chemistry.
Cambridge university press.
Copy link
Contributor

Choose a reason for hiding this comment

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

As above: DOI would be nice.

gas_constants = (1.0, 1.0), # [nondimensional]
molar_masses = (1.0, 1.0), # [nondimensional]
ion_ion_collision_constants = [0.0 0.4079382480442680;
0.4079382480442680 0.0], # [nondimensional] (computed with eq (4.142) of Schunk&Nagy (2009))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
0.4079382480442680 0.0], # [nondimensional] (computed with eq (4.142) of Schunk&Nagy (2009))
0.4079382480442680 0.0], # [nondimensional] (computed with eq (4.142) of Schunk & Nagy (2009))

rho_1, _ = Trixi.get_component(1, u, equations)
p = pressure(u, equations)

return p[1] / rho_1 / equations.gas_constants[1]
Copy link
Contributor

@DanielDoehring DanielDoehring Dec 20, 2024

Choose a reason for hiding this comment

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

This looks a bit strange - maybe add some parantheses?

Suggested change
return p[1] / rho_1 / equations.gas_constants[1]
return p[1] / (rho_1 * equations.gas_constants[1])

rho_2, _ = Trixi.get_component(2, u, equations)
p = pressure(u, equations)

return p[2] / rho_2 / equations.gas_constants[2]
Copy link
Contributor

@DanielDoehring DanielDoehring Dec 20, 2024

Choose a reason for hiding this comment

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

Same as above

Suggested change
return p[2] / rho_2 / equations.gas_constants[2]
return p[2] / (rho_2 * equations.gas_constants[2])

Comment on lines +107 to +108
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 1,
Copy link
Contributor

@DanielDoehring DanielDoehring Dec 20, 2024

Choose a reason for hiding this comment

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

Maybe mention again here why such a coarse mesh is used?

Compute the ion-ion collision source terms for the momentum and energy equations of each ion species as
```math
\begin{aligned}
\vec{s}_{\rho_k \vec{v}_k} =& \rho_k\sum_{k'}\bar{\nu}_{kk'}(\vec{v}_{k'} - \vec{v}_k),\\
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you have k' for consistency with the paper. Alternatively, one could maybe think about using l as in the implementation?

Comment on lines +521 to +522
The additional coefficient ``\bar{\nu}^1_{kk'}`` is a non-dimensional drift correction factor proposed by Rambo and
Denavit.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The additional coefficient ``\bar{\nu}^1_{kk'}`` is a non-dimensional drift correction factor proposed by Rambo and
Denavit.
The additional coefficient ``\bar{\nu}^1_{kk'}`` is a non-dimensional drift correction factor proposed by Rambo and Denavit.

The ion-ion and ion-electron collision source terms can be computed using the functions
[`source_terms_collision_ion_ion`](@ref) and [`source_terms_collision_ion_electron`](@ref), respectively.

For ion-ion collision terms, the optional arguments `gas_constants`, `molar_masses`, and `ion_ion_collision_constants`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For ion-ion collision terms, the optional arguments `gas_constants`, `molar_masses`, and `ion_ion_collision_constants`
For ion-ion collision terms, the optional keyword arguments `gas_constants`, `molar_masses`, and `ion_ion_collision_constants`

[`source_terms_collision_ion_ion`](@ref) and [`source_terms_collision_ion_electron`](@ref), respectively.

For ion-ion collision terms, the optional arguments `gas_constants`, `molar_masses`, and `ion_ion_collision_constants`
must be provided. For ion-electron collision terms, the optional arguments `gas_constants`, `molar_masses`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
must be provided. For ion-electron collision terms, the optional arguments `gas_constants`, `molar_masses`,
must be provided. For ion-electron collision terms, the optional keyword arguments `gas_constants`, `molar_masses`,

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.

3 participants