-
Notifications
You must be signed in to change notification settings - Fork 34
[SPH][NIMHD] Add Non-Ideal MHD terms #1765
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
base: main
Are you sure you want to change the base?
Changes from 13 commits
5b5fc0a
5f4c2ea
a7ede8d
547a81d
015819b
32aec9b
54d00cf
42428b4
70586aa
23b20f0
6636ce8
071924a
8b64f74
06c57c9
347fa18
36ae82e
452bbcf
b231638
2aec96b
30f5b05
a9bd332
140d56f
4ef2daf
b01a705
bf3c101
09caf22
1d693f6
8ff7743
2f1bb96
02c1b44
ffa662f
c956764
4fa54e6
db3c168
b2456f5
3dbec73
60e828a
34f60c1
d12fbe0
734d05b
1a9e737
f293787
3c60761
03761fc
9906201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| #include "shammodels/sph/SolverConfig.hpp" | ||
| #include "shammodels/sph/math/forces.hpp" | ||
| #include "shammodels/sph/math/q_ab.hpp" | ||
| #include "shammodels/sph/modules/SolverStorage.hpp" | ||
| #include "shamphys/mhd.hpp" | ||
| #include "shamunits/Constants.hpp" | ||
| #include <tuple> | ||
|
|
@@ -32,6 +33,49 @@ namespace shamrock::sph::mhd { | |
|
|
||
| enum MHDType { Ideal = 0, NonIdeal = 1 }; | ||
|
|
||
| template<class Tvec, class Tscal, MHDType MHD_mode = NonIdeal> | ||
| inline void MagCurrentJ_sum( | ||
| Tscal m_b, Tvec B_a, Tvec B_b, Tvec nabla_Wab_ha, Tscal sub_fact_a, Tscal mu_0, Tvec &J_a) { | ||
|
|
||
| J_a += m_b * sham::inv_sat_zero(sub_fact_a) * sycl::cross(B_a - B_b, nabla_Wab_ha) / mu_0; | ||
| } | ||
|
y-lapeyre marked this conversation as resolved.
|
||
|
|
||
| template<class Tvec, class Tscal, MHDType MHD_mode = NonIdeal> | ||
| inline Tvec WursterD(Tvec B, Tvec J, Tscal etaO, Tscal etaH, Tscal etaAD) { | ||
|
|
||
| Tvec Bhat = B / sham::inv_sat_zero(sycl::length(B)); | ||
|
y-lapeyre marked this conversation as resolved.
Outdated
|
||
| Tvec D = etaO * J + etaH * sycl::cross(J, Bhat) | ||
| + etaAD * sycl::cross(sycl::cross(J, Bhat), Bhat); | ||
|
y-lapeyre marked this conversation as resolved.
Outdated
|
||
|
|
||
| return D; | ||
| } | ||
|
|
||
| template<class Tvec, class Tscal, MHDType MHD_mode = NonIdeal> | ||
| inline Tscal u_NI_heating(Tvec D, Tvec J, Tscal rho) { | ||
|
|
||
| return -sycl::dot(D, J) * sham::inv_sat_zero(rho); | ||
|
y-lapeyre marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| template<class Tvec, class Tscal, MHDType MHD_mode = NonIdeal> | ||
| inline Tvec B_NI_terms( | ||
| Tvec D_a, | ||
| Tvec D_b, | ||
| Tscal m_b, | ||
| Tscal rho_a_sq, | ||
| Tscal rho_b_sq, | ||
| Tscal omega_a, | ||
| Tscal omega_b, | ||
| Tvec nabla_Wab_ha, | ||
| Tvec nabla_Wab_hb) { | ||
|
y-lapeyre marked this conversation as resolved.
|
||
|
|
||
| Tscal sub_fact_a = rho_a_sq * omega_a; | ||
| Tscal sub_fact_b = rho_b_sq * omega_b; | ||
|
|
||
| Tvec acc_a = sham::inv_sat_zero(sub_fact_a) * (sycl::cross(D_a, nabla_Wab_ha)); | ||
| Tvec acc_b = sham::inv_sat_zero(sub_fact_b) * (sycl::cross(D_b, nabla_Wab_hb)); | ||
| return -m_b * (acc_a + acc_b); | ||
| } | ||
|
|
||
| // mag tension form the Tricco 2023 formula | ||
| template<class Tvec, class Tscal> | ||
| inline Tvec B_dot_grad_W( | ||
|
|
@@ -159,7 +203,7 @@ namespace shamrock::sph::mhd { | |
| Tvec psisubterm_a = ((psi_a) *sham::inv_sat_zero(sub_fact_a)) * nabla_Wab_ha; | ||
| Tvec psisubterm_b = ((psi_b) *sham::inv_sat_zero(sub_fact_b)) * nabla_Wab_hb; | ||
|
|
||
| Tvec psiterm = -m_b * (psisubterm_a + psisubterm_a); | ||
| Tvec psiterm = -m_b * (psisubterm_a + psisubterm_b); | ||
|
|
||
| return psiterm; | ||
| } | ||
|
|
@@ -227,12 +271,19 @@ namespace shamrock::sph::mhd { | |
| Tvec B_a, | ||
| Tvec B_b, | ||
|
|
||
| Tvec J_a, | ||
| Tvec J_b, | ||
|
|
||
| Tscal psi_a, | ||
| Tscal psi_b, | ||
|
|
||
| Tscal mu_0, | ||
| Tscal sigma_mhd, | ||
|
|
||
| Tscal etaO, | ||
| Tscal etaH, | ||
| Tscal etaAD, | ||
|
|
||
| Tvec &dv_dt, | ||
| Tscal &du_dt, | ||
| Tvec &dB_on_rho_dt, | ||
|
|
@@ -364,8 +415,9 @@ namespace shamrock::sph::mhd { | |
| Tvec dB_on_rho_dissipation_term | ||
| = 0.5 * pmass * (rho_diss_term_a + rho_diss_term_b) * (B_a - B_b) * vsig_B; | ||
|
|
||
| dB_on_rho_dt | ||
| += v_ab * dB_on_rho_induction_term(pmass, rho_a_sq, B_a, omega_a, r_ab_unit * dWab_b); | ||
| dB_on_rho_dt += v_ab | ||
| * dB_on_rho_induction_term( | ||
| pmass, rho_a_sq, B_a, omega_a, r_ab_unit * dWab_a); // @@@ dWab_b ? | ||
|
y-lapeyre marked this conversation as resolved.
y-lapeyre marked this conversation as resolved.
|
||
|
|
||
| dB_on_rho_dt += dB_on_rho_psi_term( | ||
| pmass, | ||
|
|
@@ -401,6 +453,37 @@ namespace shamrock::sph::mhd { | |
|
|
||
| // for conservative checks | ||
| drho_dt += (1. / omega_a) * pmass * sycl::dot(v_ab, r_ab_unit * dWab_a); | ||
|
|
||
| // Non-ideal MHD terms | ||
| if constexpr (MHD_mode == NonIdeal) { | ||
| // logger::raw_ln("############# NON IDEAL MHD #############"); | ||
|
|
||
| // Tvec J_a = MagCurrentJ<Tvec, Tscal, MHD_mode>( | ||
| // pmass, B_a, B_b, r_ab_unit * dWab_a, sub_fact_a, mu_0); | ||
| // Tvec J_b = MagCurrentJ<Tvec, Tscal, MHD_mode>( | ||
| // pmass, B_a, B_b, r_ab_unit * dWab_b, sub_fact_b, mu_0); | ||
|
y-lapeyre marked this conversation as resolved.
Outdated
|
||
|
|
||
| Tvec D_a = WursterD<Tvec, Tscal, MHD_mode>(B_a, J_a, etaO, etaH, etaAD); | ||
| Tvec D_b = WursterD<Tvec, Tscal, MHD_mode>(B_b, J_b, etaO, etaH, etaAD); | ||
|
y-lapeyre marked this conversation as resolved.
|
||
|
|
||
| Tvec B_NI = B_NI_terms<Tvec, Tscal, MHD_mode>( | ||
| D_a, | ||
| D_b, | ||
| pmass, | ||
| rho_a_sq, | ||
| rho_b * rho_b, | ||
| omega_a, | ||
| omega_b, | ||
| r_ab_unit * dWab_a, | ||
| r_ab_unit * dWab_b); | ||
|
|
||
| dB_on_rho_dt += B_NI; | ||
|
Comment on lines
+503
to
+514
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Do not add the ambipolar induction term twice.
Remove 🤖 Prompt for AI Agents |
||
|
|
||
| Tscal u_NI = u_NI_heating<Tvec, Tscal, MHD_mode>(D_a, J_a, rho_a) * 0.5 | ||
| + u_NI_heating<Tvec, Tscal, MHD_mode>(D_b, J_b, rho_b) * 0.5; | ||
|
|
||
| du_dt += u_NI; | ||
|
y-lapeyre marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| } // namespace shamrock::sph::mhd | ||
Uh oh!
There was an error while loading. Please reload this page.