This repository has been archived by the owner on Apr 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coupling-all-direchlet.py
61 lines (44 loc) · 1.85 KB
/
coupling-all-direchlet.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
#!/usr/bin/env python3
# Plot the solution of all approaches in one plot
# @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}'] }
example = sys.argv[1]
#############################################################################
# Exact solution
#############################################################################
def exactSolution(x):
if example == "Cubic":
return (2/3/np.sqrt(3)) * ( 9*x - 9*x*x + 2 * x * x * x )
elif example == "Quartic":
return 16/9 * x * x - 32/27 * x * x * x + 16/81 * x * x * x * x
elif example == "Quadratic":
return 4/3 * x - 4/9 * x * x
else:
print("Error: Either provide Linear, Quadratic, Quartic, or Cubic")
sys.exit()
markers = ['s','o','x','.']
n = np.power(2,4)
h = 1./n
nodesFull = 3 * n + 1
xFull = np.linspace(0,3.,nodesFull)
uMDCM = np.loadtxt("coupling-"+example.lower()+"-approach-1-direchlet.csv")
uMSCM = np.loadtxt("coupling-"+example.lower()+"-approach-2-direchlet.csv")
uVHCM = np.loadtxt("coupling-"+example.lower()+"-vhm-direchlet.csv")
plt.axvline(x=1,c="#536872")
plt.axvline(x=2,c="#536872")
plt.plot(xFull,exactSolution(xFull),label="Exact solution",c="black")
plt.plot(xFull,uMDCM,label=r"MDCM",c="black",marker=markers[0],markevery=4)
plt.plot(xFull,uMSCM,label=r"MSCM",c="black",marker=markers[1],markevery=4)
plt.plot(xFull,uVHCM,label=r"VHCM",c="black",marker=markers[2],markevery=4)
plt.ylabel("Displacement")
plt.title("Example with "+example.lower()+" solution with $\delta=1/8$ and $m=2$")
plt.legend()
plt.grid()
plt.xlabel("$x$")
plt.savefig("coupling-"+example.lower()+"-all-direchlet.pdf",bbox_inches='tight')