Debian Codegraph @

docs/exact.rst

raw
1
2 .. _sec:exact:
3
4 Exact solutions
5 ================
6 splash contains a library of exact or analytic solutions to common
7 test problems that have been used extensively in benchmarking
8 codes (e.g. [PM04]_, [RP07]_, [Price12]_, [Price18]_).
9
10 Errors
11 ------
12
13 The error norms calculated when exact solutions are plotted are as
14 follows: The error for each particle is given by
15
16 .. math:: e_i = f_i - f_{exact},
17
18 where the exact solution :math:`f_{exact}(x)` is the solution returned
19 from the exact solution subroutines (with resolution adjustable in the
20 exact solution options menu option) interpolated to the position of the
21 current particle :math:`x_i` via a simple linear interpolation. The
22 absolute :math:`L_1` error norm is simply the average of the errors
23 across the domain, calculated according to
24
25 .. math:: \Vert e \Vert_{L_1} = \frac{1}{N f_{max}} \sum_{i=1}^N \vert e_i \vert,
26
27 where :math:`f_{max}` is the maximum value of the exact solution in the
28 region in which the particles lie (also only particles in the current
29 plot are used) which is used to normalise the error estimate. A better
30 error norm is the :math:`L_2` or *Root Mean Square* (RMS) norm given by
31
32 .. math::
33
34 \Vert e \Vert_{L_2} = \left[\frac{1}{N} \left( \frac{1}{f_{max}^2} \sum_{i=1}^N \vert e_i
35 \vert^2 \right)\right]^{1/2}.
36
37 Finally the maximum error, or :math:`L_\infty` norm is calculated
38 according to
39
40 .. math:: \Vert e \Vert_{L_\infty} = \frac{1}{f_{max}} {\rm max}_i \vert e_i \vert.
41
42 which is the most stringent error norm.
43
44 The inset plot of the individual particle errors shows the fractional
45 deviation for each particle given by
46
47 .. math:: e_{i,frac} = (f_i - f_{exact}) / f_{exact}.
48
49 Shock tubes (Riemann problem)
50 -----------------------------
51
52 The subroutine ``exact_shock`` plots the exact solution for a
53 one-dimensional shock tube (Riemann problem). The difficult bit of the
54 problem is to determine the jump in pressure and velocity across the
55 shock front given the initial left and right states. This is performed
56 in a separate subroutine (riemannsolver) as there are many different
57 methods by which this can be done (see e.g.
58 [Toro92]_). The actual subroutine exact_shock
59 reconstructs the shock profile (consisting of a rarefaction fan, contact
60 discontinuity and shock, summarised in :numref:`fig:shocktube`), given the post-shock values of
61 pressure and velocity.
62
63 .. figure:: figs/sodshock.pdf
64 :alt: exact solution for one-dimensional shock tube
65 :name: fig:shocktube
66 :width: 100.0%
67
68 Example of exact solution for one-dimensional shock tube problem (red
69 line) compared to the SPH solution (black line/particles), utilising
70 the exact solutions incorporated in splash
71
72 The speed at which the shock travels into the ‘right’ fluid can be
73 computed from the post shock velocity using the relation
74
75 .. math:: v_{shock} = v_{post}\frac{(\rho_{post}/\rho_R)}{(\rho_{post}/\rho_R)- 1},
76
77 where the jump conditions imply
78
79 .. math:: \frac{\rho_{post}}{\rho_R} = \frac{(P_{post}/P_R) + \beta}{1 + \beta (P_{post}/P_R)}
80
81 with
82
83 .. math:: \beta = \frac{\gamma - 1}{\gamma + 1}.
84
85 Riemann solver
86 ~~~~~~~~~~~~~~~
87
88 The algorithm for determining the post-shock velocity and pressure is
89 taken from [Toro92]_.
90
91 Polytrope
92 ---------
93
94 The subroutine ``exact_polytrope`` computes the exact solution for a
95 static polytrope with arbitrary :math:`\gamma`. From Poisson’s equation
96
97 .. math:: \nabla^2 \phi = 4\pi G \rho,
98
99 assuming only radial dependence this is given by
100
101 .. math::
102 :label: eq_poissonsph
103
104 \frac{1}{r^{2}} \frac{d}{dr} \left(r^{2} \frac{d\phi}{dr} \right) = 4\pi G \rho(r).
105
106 The momentum equation assuming an equilibrium state
107 (:math:`{\bf v} = 0`) and a polytropic equation of state
108 :math:`P = K\rho^{\gamma}` gives
109
110 .. math::
111 :label: eq_polyk
112
113 \frac{d\phi}{dr} = - \frac{\gamma K}{\gamma-1}\frac{d}{dr} \left[\rho^{(\gamma -1)} \right]
114
115 Combining (:eq:`eq_poissonsph`) and
116 (:eq:`eq_polyk`) we obtain an equation for the density
117 profile
118
119 .. math::
120 :label: eq:dens
121
122 \frac{\gamma K}{4\pi G (\gamma - 1)} \frac{1}{r^{2}} \frac{d}{dr} \left[r^{2}
123 \frac{d}{dr}\left( \rho^{\gamma-1} \right) \right] + \rho(r) = 0.
124
125 This equation can be rearranged to give
126
127 .. math::
128
129 \frac{\gamma K}{4\pi G (\gamma - 1)} \frac{d^2}{dr^2}
130 \left[r\rho^{\gamma-1}\right] + r\rho = 0.
131
132 The program solves this equation numerically by defining a variable
133
134 .. math:: \mathcal{E} = r \rho^{\gamma-1}
135
136 and finite differencing the equation according to
137
138 .. math::
139
140 \frac{\mathcal{E}^{i+1} - \mathcal{E}^i + \mathcal{E}^{i-1}}{(\Delta r)^2} =
141 \frac{4\pi G (\gamma - 1)}{\gamma K} r
142 \left(\frac{\mathcal{E}}{r}\right)^{1/(\gamma-1)}.
143
144 Linear wave
145 -----------
146
147 The subroutine ``exact_wave`` simply plots a sine function on a given
148 graph. The function is of the form
149
150 .. math:: y = \sin{(k x - \omega t)}
151
152 where :math:`k` is the wavenumber and :math:`\omega` is the angular
153 frequency. These parameters are set via the input values of wavelength
154 :math:`\lambda = 2\pi/k` and wave period :math:`P = 2\pi/\omega`.
155
156 .. table:: Input parameters for the linear wave exact solution
157
158 +-----------------+------------+
159 | :math:`\lambda` | wavelength |
160 +-----------------+------------+
161 | :math:`P` | period |
162 +-----------------+------------+
163
164 Sedov blast wave
165 ----------------
166
167 The subroutine ``exact_sedov`` computes the self-similar Sedov solution
168 for a blast wave.
169
170 Toy stars
171 ---------
172
173 The subroutine ``exact_toystar1D`` computes the exact solutions for the
174 ‘Toy Stars’ described in [MP04]_. The system is one
175 dimensional with velocity :math:`v`, density :math:`\rho`, and pressure
176 :math:`P`. The acceleration equation is
177
178 .. math:: \frac{dv}{dt} = - \frac{1}{\rho} \frac{\partial P}{\partial x} - \Omega^2 x,
179
180 We assume the equation of state is
181
182 .. math:: P = K \rho^\gamma,
183
184 The exact solutions provided assume the equations are scaled such that
185 :math:`\Omega^2 = 1`.
186
187 Static structure
188 ~~~~~~~~~~~~~~~~~
189
190 The static structure is given by
191
192 .. math:: \bar \rho = 1- x^2,
193
194 Linear solutions
195 ~~~~~~~~~~~~~~~~~
196
197 The linear solution for the velocity is given by
198
199 .. math:: v = 0.05 C_s G_n(x) \cos{\omega t} ).
200
201 The density is
202
203 .. math:: \rho = \bar{\rho} + \eta,
204
205 where
206
207 .. math:: \eta = 0.1 C_s \omega P_{n+1}(x) \sin{(\omega t)}.
208
209 Non-linear solution
210 ~~~~~~~~~~~~~~~~~~~~
211
212 In this case the velocity is given by
213
214 .. math:: v = A(t) x,
215
216 while the density solution is
217
218 .. math:: \rho^{\gamma -1} = H(t) - C(t) x^2.
219
220 where the parameters A, H and C are determined by solving the ordinary
221 differential equations
222
223 .. math::
224
225 \begin{aligned}
226 \dot{H} & = & -AH(\gamma -1), \\
227 \dot{A} & = & \frac{2K \gamma}{\gamma -1} C - 1 - A^2 \\
228 \dot{C} & = & -AC(1+ \gamma),\end{aligned}
229
230 The relation
231
232 .. math::
233 :label: eq:kconst
234
235 A^2 = -1 - \frac{2 \sigma C}{\gamma -1} + kC^{\frac{2}{\gamma +1}},
236
237 is used to check the quality of the solution of the differential
238 equations by evaluating the constant :math:`k` (which should remain
239 close to its initial value).
240
241 MHD shock tubes
242 ---------------
243
244 These are some tabulated solutions for specific MHD shock tube problems
245 at a given time taken from the tables given in [DW94]_
246 and [RJ95]_.
247
248 h vs :math:`\rho`
249 -----------------
250
251 The subroutine exact_hrho simply plots the relation between smoothing
252 length and density, i.e.,
253
254 .. math:: h = h_{\rm fact} \left(\frac{m}{\rho}\right)^{1/\nu}
255
256 where :math:`\nu` is the number of spatial dimensions. The parameter
257 :math:`h_{\rm fact}` is output by the code into the header of each timestep.
258 For particles of different masses, a different curve is plotted for each
259 different mass value.