/
params.py
102 lines (77 loc) · 1.39 KB
/
params.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from __future__ import division
#import numpy as np
#import scipy.integrate as integrate
#from scipy import optimize
Animation = True
charac = False
screen = True
# number of cells in space for an uniform mesh
#Nx = 8
# number of cells in space follwing the mass
Nm = 1000
# step of time
dt = 0.002
# time of controllability = minimal_time + epsilon
epsilon = 0.1
# step for the uniform discretisation
delta_x = 0.02
step_m = 1.0/Nm
test_case = 3
if test_case ==2:
a0 = 0
b0 = 1.25
a1 = 4
b1 = 7
a = 2
b = 3
if test_case ==3:
a0 = 0
b0 = 2
a1 = 7
b1 = 11
a = 5
b = 6
# initial measure
def mu_0(x,test_case):
if test_case == 1:
if x>-10 and x<0:
res = 1.0/10.0
else:
res = 0.0
if test_case == 2:
if (x>0 and x<0.75):
res = 1.0
elif (x>1 and x<1.25):
res = 1.0
else:
res = 0.0
if test_case == 3:
if (x>0 and x<2):
res = 1.0/2
else:
res = 0.0
return res
# target
def mu_1(x,test_case):
if test_case == 1:
if (x>3 and x<4) or (x>9 and x<10):
res = 0.5
else:
res = 0
if test_case == 2:
if (x>7 and x<10) or (x>12 and x<13):
res = 0.5
else:
res = 0
if test_case == 3:
if (x>7 and x<8) or (x>10 and x<11):
res = 1.0/2
else:
res = 0
return res
# velocity for the forward computation of the solution
def velocity(x,t):
return 1.0
# velocity for the forward computation of the solution
def velocity2(x,t):
return -1.0