1515// exo3
1616#include < exo3/cubed_sphere.hpp>
1717
18+ // snap
19+ #include < snap/thermodynamics/thermodynamics.hpp>
20+
21+ // microphysics
22+ #include < microphysics/microphysics.hpp>
23+
1824// checks
1925#include < checks.hpp>
2026
@@ -27,8 +33,12 @@ void Hydro::RiemannSolver(const int k, const int j, const int il, const int iu,
2733 const int ivx, AthenaArray<Real> &wl,
2834 AthenaArray<Real> &wr, AthenaArray<Real> &flx,
2935 const AthenaArray<Real> &dxw) {
36+ auto pthermo = Thermodynamics::GetInstance ();
37+ auto pmicro = pmy_block->pimpl ->pmicro ;
38+
3039 int ivy = IVX + ((ivx - IVX) + 1 ) % 3 ;
3140 int ivz = IVX + ((ivx - IVX) + 2 ) % 3 ;
41+ int dir = ivx - IVX;
3242 auto pcoord = pmy_block->pcoord ;
3343
3444 Real wli[(NHYDRO)], wri[(NHYDRO)];
@@ -69,6 +79,30 @@ void Hydro::RiemannSolver(const int k, const int j, const int il, const int iu,
6979 wri[IVZ] = wr (ivz, i);
7080 wri[IPR] = wr (IPR, i);
7181
82+ for (int n = 1 ; n <= NVAPOR; ++n) {
83+ wli[n] = wl (n, i);
84+ wri[n] = wr (n, i);
85+ }
86+
87+ // correction for gamma
88+ // left
89+ Real fsig = 1 ., feps = 1 .;
90+ for (int n = 1 ; n <= NVAPOR; ++n) {
91+ fsig += wli[n] * (pthermo->GetCvRatioMass (n) - 1 .);
92+ feps += wli[n] * (1 . / pthermo->GetMuRatio (n) - 1 .);
93+ }
94+ Real kappal = 1 . / (gamma - 1 .) * fsig / feps;
95+ Real gammal = 1 . / kappal + 1 .;
96+
97+ // right
98+ fsig = 1 ., feps = 1 .;
99+ for (int n = 1 ; n <= NVAPOR; ++n) {
100+ fsig += wri[n] * (pthermo->GetCvRatioMass (n) - 1 .);
101+ feps += wri[n] * (1 . / pthermo->GetMuRatio (n) - 1 .);
102+ }
103+ Real kappar = 1 . / (gamma - 1 .) * fsig / feps;
104+ Real gammar = 1 . / kappar + 1 .;
105+
72106 // --- Step 2. Compute middle state estimates with PVRS (Toro 10.5.2)
73107
74108 Real al, ar, el, er, vy, vz, KE_l, KE_r;
@@ -96,8 +130,8 @@ void Hydro::RiemannSolver(const int k, const int j, const int il, const int iu,
96130 el = pmy_block->peos ->EgasFromRhoP (wli[IDN], wli[IPR]) + KE_l;
97131 er = pmy_block->peos ->EgasFromRhoP (wri[IDN], wri[IPR]) + KE_r;
98132 } else {
99- el = wli[IPR] * igm1 + KE_l;
100- er = wri[IPR] * igm1 + KE_r;
133+ el = wli[IPR] * kappal + KE_l;
134+ er = wri[IPR] * kappar + KE_r;
101135 }
102136 Real rhoa = .5 * (wli[IDN] + wri[IDN]); // average density
103137 Real ca = .5 * (cl + cr); // average sound speed
@@ -121,10 +155,10 @@ void Hydro::RiemannSolver(const int k, const int j, const int il, const int iu,
121155 : std::sqrt (1.0 + (gr + 1 ) / (2 * gr) * (pmid / wri[IPR] - 1.0 ));
122156 } else {
123157 ql = (pmid <= wli[IPR]) ? 1.0
124- : std::sqrt (1.0 + (gamma + 1 ) / (2 * gamma ) *
158+ : std::sqrt (1.0 + (gammal + 1 ) / (2 * gammal ) *
125159 (pmid / wli[IPR] - 1.0 ));
126160 qr = (pmid <= wri[IPR]) ? 1.0
127- : std::sqrt (1.0 + (gamma + 1 ) / (2 * gamma ) *
161+ : std::sqrt (1.0 + (gammar + 1 ) / (2 * gammar ) *
128162 (pmid / wri[IPR] - 1.0 ));
129163 }
130164
@@ -160,8 +194,19 @@ void Hydro::RiemannSolver(const int k, const int j, const int il, const int iu,
160194 vxl = wli[IVX] - bm;
161195 vxr = wri[IVX] - bp;
162196
163- fl[IDN] = wli[IDN] * vxl;
164- fr[IDN] = wri[IDN] * vxr;
197+ Real rdl = 1 ., rdr = 1 .;
198+ for (int n = 1 ; n <= NVAPOR; ++n) {
199+ rdl -= wli[n];
200+ rdr -= wri[n];
201+ }
202+
203+ fl[IDN] = wli[IDN] * vxl * rdl;
204+ fr[IDN] = wri[IDN] * vxr * rdr;
205+
206+ for (int n = 1 ; n <= NVAPOR; ++n) {
207+ fl[n] = wli[IDN] * wli[n] * vxl;
208+ fr[n] = wri[IDN] * wri[n] * vxr;
209+ }
165210
166211 fl[IVX] = wli[IDN] * wli[IVX] * vxl + wli[IPR];
167212 fr[IVX] = wri[IDN] * wri[IVX] * vxr + wri[IPR];
@@ -192,17 +237,27 @@ void Hydro::RiemannSolver(const int k, const int j, const int il, const int iu,
192237 // contribution
193238 // of the flux along the contact
194239
195- flxi[IDN ] = sl * fl[IDN ] + sr * fr[IDN ];
240+ for ( int n = 0 ; n <= NVAPOR; ++n) flxi[n ] = sl * fl[n ] + sr * fr[n ];
196241 flxi[IVX] = sl * fl[IVX] + sr * fr[IVX] + sm * cp;
197242 flxi[IVY] = sl * fl[IVY] + sr * fr[IVY];
198243 flxi[IVZ] = sl * fl[IVZ] + sr * fr[IVZ];
199244 flxi[IEN] = sl * fl[IEN] + sr * fr[IEN] + sm * cp * am;
200245
201- flx (IDN , k, j, i) = flxi[IDN ];
246+ for ( int n = 0 ; n <= NVAPOR; ++n) flx (n , k, j, i) = flxi[n ];
202247 flx (ivx, k, j, i) = flxi[IVX];
203248 flx (ivy, k, j, i) = flxi[IVY];
204249 flx (ivz, k, j, i) = flxi[IVZ];
205250 flx (IEN, k, j, i) = flxi[IEN];
251+
252+ // tracer flux
253+ Real tfl[(NCLOUD)], tfr[(NCLOUD)], tflxi[(NCLOUD)];
254+ for (int n = 0 ; n < NCLOUD; ++n) {
255+ Real vsed = pmicro->vsedf [dir](n, k, j, i);
256+ tfl[n] = wli[IDN] * rdl * (vxl + vsed);
257+ tfr[n] = wri[IDN] * rdr * (vxr + vsed);
258+ tflxi[n] = sl * tfl[n] + sr * tfr[n];
259+ pmicro->mass_flux [dir](n, k, j, i) = tflxi[n];
260+ }
206261 }
207262
208263#if defined(AFFINE) || defined(CUBED_SPHERE) // need of deprojection
0 commit comments