-
Notifications
You must be signed in to change notification settings - Fork 0
/
entropy_shock.py
executable file
·68 lines (51 loc) · 1.55 KB
/
entropy_shock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# encoding: utf-8
# SPDX-License-Identifier: MIT
# Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval
import numpy as np
from morinth.euler_experiment import EulerExperiment
from morinth.quadrature import GaussLegendre
from morinth.boundary_conditions import Outflow
class EntropyShockIC(object):
def __init__(self, model):
self.model = model
self.amplitude = 0.01
self.wave_number = 13
self.x_crit = 0.5
self.quadrature = GaussLegendre(5)
def __call__(self, grid):
x = grid.cell_centers
w = np.empty((4,) + x.shape[:1])
is_inside = x[:,0] < self.x_crit
w[0,...] = np.where(is_inside,
3.85714,
np.exp(-self.amplitude*np.sin(self.wave_number*x[:,0])))
w[1,...] = np.where(is_inside, 2.629369, 0.0)
w[2,...] = 0.0
w[3,...] = np.where(is_inside, 10.33333, 1.0)
return self.model.conserved_variables(w)
class EntropyShock(EulerExperiment):
@property
def final_time(self):
return 2.0
@property
def n_cells(self):
return 200
@property
def domain(self):
return [0.0, 5.0]
@property
def order(self):
return 5
@property
def initial_condition(self):
return EntropyShockIC(self.model)
@property
def output_filename(self):
return "img/entropy_shock"
@property
def boundary_condition(self):
return Outflow(self.grid)
if __name__ == '__main__':
sim = EntropyShock()
sim()