rizer.cantera_ext
C++ Cantera 1-D plasma extension (custom Domain1D models and solvers)
Loading...
Searching...
No Matches
EulerFlux_test.cpp
Go to the documentation of this file.
1
15
16#include "numeric/EulerFlux.h"
17
18#include <gtest/gtest.h>
19
20#include <cmath>
21
22namespace
23{
24
31
32 // ------------------------------------------------------------------------------ //
33 // maxWaveSpeed //
34 // ------------------------------------------------------------------------------ //
35
38 TEST(MaxWaveSpeed, TakesTheLargerOfTheTwoSides)
39 {
40 EXPECT_DOUBLE_EQ(maxWaveSpeed(10.0, 300.0, 20.0, 340.0), 360.0);
41 EXPECT_DOUBLE_EQ(maxWaveSpeed(50.0, 400.0, 20.0, 340.0), 450.0);
42 }
43
46 TEST(MaxWaveSpeed, UsesTheMagnitudeOfTheVelocity)
47 {
48 EXPECT_DOUBLE_EQ(maxWaveSpeed(-100.0, 300.0, 0.0, 300.0), 400.0);
49 EXPECT_DOUBLE_EQ(maxWaveSpeed(-100.0, 300.0, 0.0, 300.0),
50 maxWaveSpeed(100.0, 300.0, 0.0, 300.0));
51 }
52
56 TEST(MaxWaveSpeed, IsTheSoundSpeedAtRest)
57 {
58 EXPECT_DOUBLE_EQ(maxWaveSpeed(0.0, 347.2, 0.0, 347.2), 347.2);
59 }
60
61 // ------------------------------------------------------------------------------ //
62 // rusanovScalarFlux //
63 // ------------------------------------------------------------------------------ //
64
67 TEST(RusanovScalarFlux, ScalesTheWholeBlendByTheFaceRadius)
68 {
69 const double one = rusanovScalarFlux(1.0, 2.0, 3.0, 10.0, 20.0, 400.0);
70 const double seven = rusanovScalarFlux(7.0, 2.0, 3.0, 10.0, 20.0, 400.0);
71 EXPECT_DOUBLE_EQ(seven, 7.0 * one);
72 // 0.5*(10*2 + 20*3) - 0.5*400*(3 - 2) = 40 - 200
73 EXPECT_DOUBLE_EQ(one, -160.0);
74 }
75
78 TEST(RusanovScalarFlux, VanishesOnAZeroAreaFace)
79 {
80 EXPECT_DOUBLE_EQ(rusanovScalarFlux(0.0, 2.0, 3.0, 10.0, 20.0, 400.0), 0.0);
81 }
82
85 TEST(RusanovScalarFlux, HasNoDissipationWithoutAJump)
86 {
87 EXPECT_DOUBLE_EQ(rusanovScalarFlux(2.0, 5.0, 5.0, 10.0, 30.0, 400.0),
88 2.0 * 0.5 * (10.0 * 5.0 + 30.0 * 5.0));
89 }
90
93 TEST(RusanovScalarFlux, DissipationOpposesTheJump)
94 {
95 const double rising = rusanovScalarFlux(1.0, 1.0, 2.0, 0.0, 0.0, 400.0);
96 const double falling = rusanovScalarFlux(1.0, 2.0, 1.0, 0.0, 0.0, 400.0);
97 EXPECT_LT(rising, 0.0);
98 EXPECT_GT(falling, 0.0);
99 EXPECT_DOUBLE_EQ(rising, -falling);
100 }
101
102 // ------------------------------------------------------------------------------ //
103 // rusanovMomentumFlux //
104 // ------------------------------------------------------------------------------ //
105
109 TEST(RusanovMomentumFlux, CarriesThePressureTerm)
110 {
111 // At rest the advective part is zero and only p survives.
112 EXPECT_DOUBLE_EQ(
113 rusanovMomentumFlux(2.0, 1.2, 0.0, 1.0e5, 1.2, 0.0, 3.0e5, 400.0),
114 2.0 * 0.5 * (1.0e5 + 3.0e5));
115 }
116
119 TEST(RusanovMomentumFlux, MatchesTheClosedFormWithFlowAndPressure)
120 {
121 const double expected =
122 3.0 * (0.5 * ((2.0 * 10.0 * 10.0 + 100.0) + (4.0 * 20.0 * 20.0 + 500.0)) -
123 0.5 * 450.0 * (4.0 * 20.0 - 2.0 * 10.0));
124 EXPECT_DOUBLE_EQ(
125 rusanovMomentumFlux(3.0, 2.0, 10.0, 100.0, 4.0, 20.0, 500.0, 450.0),
126 expected);
127 }
128
132 TEST(RusanovMomentumFlux, DissipatesConservedMomentumNotVelocity)
133 {
134 // rho*u = 20 on both sides, so the dissipation must vanish even though
135 // the velocities differ by a factor of four.
136 const double flux =
137 rusanovMomentumFlux(1.0, 2.0, 10.0, 0.0, 8.0, 2.5, 0.0, 400.0);
138 EXPECT_DOUBLE_EQ(flux, 0.5 * (2.0 * 100.0 + 8.0 * 6.25));
139 }
140
141 // ------------------------------------------------------------------------------ //
142 // rusanovEnergyFlux //
143 // ------------------------------------------------------------------------------ //
144
148 TEST(RusanovEnergyFlux, AdvectsEnthalpyButDissipatesEnergy)
149 {
150 const double expected =
151 2.0 * (0.5 * (10.0 * (1000.0 + 300.0) + 30.0 * (2000.0 + 700.0)) -
152 0.5 * 500.0 * (2000.0 - 1000.0));
153 EXPECT_DOUBLE_EQ(
154 rusanovEnergyFlux(2.0, 1000.0, 300.0, 10.0, 2000.0, 700.0, 30.0, 500.0),
155 expected);
156 }
157
161 TEST(RusanovEnergyFlux, IsZeroAtRestAcrossAPressureJump)
162 {
163 EXPECT_DOUBLE_EQ(
164 rusanovEnergyFlux(2.0, 1000.0, 300.0, 0.0, 1000.0, 900.0, 0.0, 500.0),
165 0.0);
166 }
167
168 // ------------------------------------------------------------------------------ //
169 // faceVelocityFlux //
170 // ------------------------------------------------------------------------------ //
171
176 TEST(FaceVelocityFlux, IsTheAreaWeightedAverageVelocity)
177 {
178 EXPECT_DOUBLE_EQ(faceVelocityFlux(4.0, 10.0, 30.0), 4.0 * 20.0);
179 EXPECT_DOUBLE_EQ(faceVelocityFlux(0.0, 10.0, 30.0), 0.0);
180 }
181
184 TEST(FaceVelocityFlux, CancelsForAMirroredPair)
185 {
186 EXPECT_DOUBLE_EQ(faceVelocityFlux(2.0, -17.0, 17.0), 0.0);
187 }
188
189 // ------------------------------------------------------------------------------ //
190 // momentumGeometricSourceIntegral //
191 // ------------------------------------------------------------------------------ //
192
195 TEST(MomentumGeometricSourceIntegral, IsThePressureTimesTheFaceSpan)
196 {
197 EXPECT_DOUBLE_EQ(momentumGeometricSourceIntegral(1.0e5, 2.0e-4), 20.0);
198 }
199
204 TEST(MomentumGeometricSourceIntegral, VanishesWhenTheFaceSpanIsZero)
205 {
206 EXPECT_DOUBLE_EQ(momentumGeometricSourceIntegral(1.0e5, 0.0), 0.0);
207 }
208
213 TEST(MomentumGeometricSourceIntegral, CancelsTheFluxDifferenceAtUniformPressure)
214 {
215 const double pressure = 1.0e5;
216 // A deliberately lopsided pair of faces, as a stretched mesh produces.
217 const double r_west = 1.0e-3;
218 const double r_east = 1.7e-3;
219 const double flux_west =
220 rusanovMomentumFlux(r_west, 1.2, 0.0, pressure, 1.2, 0.0, pressure, 400.0);
221 const double flux_east =
222 rusanovMomentumFlux(r_east, 1.2, 0.0, pressure, 1.2, 0.0, pressure, 400.0);
223 const double source =
224 momentumGeometricSourceIntegral(pressure, r_east - r_west);
225 EXPECT_NEAR(flux_east - flux_west - source, 0.0, 1.0e-10);
226 }
227
228} // namespace
Pure-arithmetic primitives for the explicit hydrodynamic sub-step of the 1D radial channel: one face'...
double rusanovScalarFlux(double r_face, double phi_left, double phi_right, double u_left, double u_right, double wave_speed)
Rusanov face flux for any node-centred conserved scalar – and each .
Definition EulerFlux.h:93
double maxWaveSpeed(double u_left, double c_left, double u_right, double c_right)
Rusanov dissipation coefficient at a face: the fastest wave speed that can reach it from either side,...
Definition EulerFlux.h:67
double momentumGeometricSourceIntegral(double p, double dr)
Cell-integrated cylindrical momentum source, the second term of NUMERICS.md equation (13):
Definition EulerFlux.h:226
double faceVelocityFlux(double r_face, double u_left, double u_right)
Face velocity flux , whose difference gives the electron-pool compression source of NUMERICS....
Definition EulerFlux.h:199
double rusanovMomentumFlux(double r_face, double rho_left, double u_left, double p_left, double rho_right, double u_right, double p_right, double wave_speed)
Pressure-inclusive Rusanov face flux for the radial momentum row, NUMERICS.md equation (12):
Definition EulerFlux.h:123
double rusanovEnergyFlux(double r_face, double E_left, double p_left, double u_left, double E_right, double p_right, double u_right, double wave_speed)
Pressure-inclusive Rusanov face flux for the total energy row, NUMERICS.md equation (14a) – the face ...
Definition EulerFlux.h:170