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
/
plot-con.py
72 lines (59 loc) · 2.31 KB
/
plot-con.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
#!/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 csv
import sys
import matplotlib.pyplot as plt
import matplotlib
pgf_with_latex = {"text.usetex": True, "font.size" : 12, "pgf.preamble" : [r'\usepackage{xfrac}'] }
plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
def read_csv(filename):
x = []
with open(filename,'r') as csvfile:
plots = csv.reader(csvfile, delimiter = ',')
for row in plots:
x.append(float(row[0]))
return x
x = np.linspace(0,1,7)
vhm_con = read_csv("con-vhm-neumann.txt")
approach_1_con = read_csv("con-approach-1-neumann.txt")
approach_2_con = read_csv("con-approach-2-neumann.txt")
fdm_con = read_csv("con-fdm-neumann.txt")
ax = plt.gca()
ax.set_xticks(x)
ax.set_xticklabels([r"$1/8$", r"$1/16$", r"$1/32$", r"$1/64$",
r"$1/128$",r"$1/256$",r"$1/512$"])
ax.set_yscale('log')
plt.plot(x,approach_1_con,label="MDCM",marker="o",color="black")
plt.plot(x,vhm_con,label="VHCM",marker="s",color="black",markerfacecolor='none', markeredgecolor='black')
plt.plot(x,approach_2_con,label="MSCM",marker="x",color="black")
plt.plot(x,fdm_con,label="FDM",marker=".",color="black")
plt.grid()
plt.legend()
plt.xlabel("$\delta$")
plt.ylabel("Condition number of stiffness matrices")
plt.title("Mixed boundary conditions")
plt.savefig("condition-neumann.pdf",bbox_inches='tight')
plt.clf()
vhm_con = read_csv("con-vhm-direchlet.txt")
approach_1_con = read_csv("con-approach-1-direchlet.txt")
approach_2_con = read_csv("con-approach-2-dirchlet.txt")
fdm_con = read_csv("con-fdm-direchlet.txt")
ax = plt.gca()
ax.set_xticks(x)
ax.set_xticklabels([r"$1/8$", r"$1/16$", r"$1/32$", r"$1/64$",
r"$1/128$",r"$1/256$",r"$1/512$"])
ax.set_yscale('log')
plt.plot(x,approach_1_con,label="MDCM",marker="o",color="black")
plt.plot(x,vhm_con,label="VHCM",marker="s",color="black",markerfacecolor='none', markeredgecolor='black')
plt.plot(x,approach_2_con,label="MSCM",marker="x",color="black")
plt.plot(x,fdm_con,label="FDM",marker=".",color="black")
plt.grid()
plt.legend()
plt.xlabel("$\delta$")
plt.ylabel("Condition number of the stiffness matrix")
plt.title("Homogeneous Dirichlet boundary conditions")
plt.savefig("condition.pdf",bbox_inches='tight')