This repository was archived by the owner on Apr 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot-vmax.py
More file actions
75 lines (52 loc) · 1.26 KB
/
plot-vmax.py
File metadata and controls
75 lines (52 loc) · 1.26 KB
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
#!/usr/bin/env python3
# Plot the vmax
# @author patrickdiehl@lsu.edu
# @author serge.prudhomme@polymtl.ca
# @date 03/02/2021
import numpy as np
import sys
import matplotlib.pyplot as plt
import matplotlib
pgf_with_latex = {"text.usetex": True, "font.size" : 12, "pgf.preamble" : [r'\usepackage{xfrac}'] }
a = 1
b = 2
c = 3
delta = 1/8
lam = 24
def vm(x):
if x < a :
return (lam*delta*delta)/24 *(b-a) * x
if x < b :
return (lam*delta*delta)/48 * (b*b-a*a-(b-x)*(b-x))
if x < c :
return (lam*delta*delta)/48 * (b*b-a*a)
def vd(x):
if x < a :
return (lam*delta*delta/48) * (b-a)/c * (2*c-(a+b)) *x
if x < b :
return (lam*delta*delta/48) * ( (b*b-a*a ) * (c-x) /c -(b-x)*(b-x) )
if x < c :
return (lam*delta*delta/48) * (b*b-a*a) * (c-x) / c
x = np.linspace(0,3,300)
y = []
for xi in x:
y.append(vm(xi))
plt.plot(x,y,c="black")
plt.ylabel("v(x)")
plt.title("")
#plt.legend()
plt.grid()
plt.xlabel("$x$")
plt.savefig("vmax-neumann.pdf",bbox_inches='tight')
plt.clf()
y = []
lam=128/7
for xi in x:
y.append(vd(xi))
plt.plot(x,y,c="black")
plt.ylabel("v(x)")
plt.title("")
#plt.legend()
plt.grid()
plt.xlabel("$x$")
plt.savefig("vmax-dirichlet.pdf",bbox_inches='tight')