-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotting.py
More file actions
96 lines (69 loc) · 2.11 KB
/
Copy pathplotting.py
File metadata and controls
96 lines (69 loc) · 2.11 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import matplotlib.pyplot as plt
import numpy as np
import os
from config import PLOT_DIR
def ensure_plot_dir():
os.makedirs(PLOT_DIR, exist_ok=True)
def set_plot_style():
plt.rcParams.update({
"figure.figsize": (6,4),
"figure.dpi": 120,
"font.size": 11,
"axes.titlesize": 12,
"axes.labelsize": 11,
"axes.linewidth": 1.1,
"lines.linewidth": 2,
"legend.frameon": False,
"legend.fontsize": 10,
"grid.alpha": 0.3,
"xtick.direction": "in",
"ytick.direction": "in"
})
def plot_conversion(time, y_upper_lim, conversions, labels):
"""
time: array of time values
conversions: list of conversion arrays
labels: list of names for each curve
"""
for i in range(len(conversions)):
plt.plot(time, conversions[i], label=labels[i])
plt.ylabel("Conversion")
plt.xlabel("Time")
plt.title("Reactor Conversion Over Time")
plt.legend()
plt.ylim(0, y_upper_lim)
plt.grid(True)
plt.tight_layout()
ensure_plot_dir()
plt.savefig(f"{PLOT_DIR}/conversion_plot.png", dpi=300)
plt.show()
def plot_reaction_rate(time, rates, labels):
"""
time: array of time values
rates: list of reaction rate arrays
labels: list of names for each curve
"""
for i in range(len(rates)):
plt.plot(time, rates[i], label=labels[i])
plt.ylabel("Reaction Rate")
plt.xlabel("Time")
plt.title("Reaction Rate Over Time")
plt.legend()
plt.grid(True)
plt.tight_layout()
ensure_plot_dir()
plt.savefig(f"{PLOT_DIR}/reaction_rate_plot.png", dpi=300)
plt.show()
def plot_average_conversion(labels, conversions):
average_conversions = []
for conversion in conversions:
average_conversions.append(np.mean(conversion))
plt.figure()
plt.bar(labels, average_conversions)
plt.ylabel("Average Conversion")
plt.title("Average Reactor Conversion by Scenario")
plt.grid(True, axis="y")
plt.tight_layout()
ensure_plot_dir()
plt.savefig(f"{PLOT_DIR}/average_conversion_comparison.png", dpi=300)
plt.show()