Skip to content

Commit 4129c94

Browse files
authored
Merge pull request #14099 from rmcdermo/master
Python: add pyrolysis.py to special cases
2 parents e029e8a + ea39ca1 commit 4129c94

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

Utilities/Python/FDS_verification_script.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@
2828

2929
# Special cases
3030

31+
print("pyrolysis..."); subprocess.run(["python","./scripts/pyrolysis.py"])
32+
3133
print("verification scripts completed successfully!")
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
This step will get you 90% of the way there. Then there usually a few extra steps to get a working script.
66

7+
#### Use pandas.read_csv
8+
9+
I'd like to standardize on using Pandas for reading csv files. This is not a hard rule, but there are many options and it would help if we are consistent. You can give this instruction to your AI prior to your conversion. You should end up with
10+
```
11+
import pandas as pd
12+
```
13+
at the top of your script and you read the csv file with, for example,
14+
```
15+
fds_data = pd.read_csv(fds_file, skiprows=2, header=None) # note: your header row may be different and remember Python is 0 based
16+
```
17+
718
## 2. Import `fdsplotlib`
819

920
You will use this library for the Matlab equivalent of `plot_style` and `addverstr`. At the top of your script add the following:
@@ -12,7 +23,11 @@ You will use this library for the Matlab equivalent of `plot_style` and `addvers
1223
import fdsplotlib
1324
```
1425

15-
For now, we will assume that you are running your scripts from the `fds/Utilities/Python/` directory where `fdsplotlib` lives. If you need to run your python scripts from another directory, you need to add `fds/Utilities/Python/` to the path or else copy `fdsplotlibl.py` to your working directory.
26+
To make sure `fdsplotlib` is visible to all your python scripts add the following to your `~/.bashrc`
27+
```
28+
# add PYTHONPATH for FDS scripts
29+
export PYTHONPATH=$FIREMODELS/fds/Utilities/Python:$PYTHONPATH
30+
```
1631

1732
## 3. Add the plot style parameters
1833

Utilities/Python/scripts/cantera_ignition_delay.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
9090
caseCount = 0
9191

9292
# Metahne_grimech 12
93-
print("Soving for Metahne_grimech:")
93+
print("Solving for Metahne_grimech:")
9494
gas = ct.Solution(Cantera_DIR+"Methane_grimech30.yaml")
9595
equivRatios = np.array([0.6, 1.0, 1.4])
9696
T = np.array([900, 1000, 1100, 1200])
@@ -100,7 +100,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
100100
print("Done Metahne_grimech, caseCount=", str(caseCount))
101101

102102
# Methane_TianfengLu
103-
print("Soving for Methane_TianfengLu:")
103+
print("Solving for Methane_TianfengLu:")
104104
gas = ct.Solution(Cantera_DIR+"Methane_TianfengLu.yaml")
105105
equivRatios = np.array([1.0])
106106
T = np.array([1100])
@@ -110,7 +110,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
110110
print("Done Methane_TianfengLu, caseCount=", str(caseCount))
111111

112112
# Methane_Smooke
113-
print("Soving for Methane_Smooke:")
113+
print("Solving for Methane_Smooke:")
114114
gas = ct.Solution(Cantera_DIR+"Methane_Smooke.yaml")
115115
equivRatios = np.array([1.0])
116116
T = np.array([1100])
@@ -120,7 +120,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
120120
print("Done Methane_Smooke, caseCount=", str(caseCount))
121121

122122
# Ethylene_TianfengLu
123-
print("Soving for Ethylene_TianfengLu:")
123+
print("Solving for Ethylene_TianfengLu:")
124124
gas = ct.Solution(Cantera_DIR+"Ethylene_TianfengLu.yaml")
125125
equivRatios = np.array([1.0])
126126
T = np.array([1100])
@@ -130,7 +130,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
130130
print("Done Ethylene_TianfengLu, caseCount=", str(caseCount))
131131

132132
# Propane_USC
133-
print("Soving for Propane_USC:")
133+
print("Solving for Propane_USC:")
134134
gas = ct.Solution(Cantera_DIR+"Propane_USC.yaml")
135135
equivRatios = np.array([1.0])
136136
T = np.array([1100])
@@ -140,7 +140,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
140140
print("Done Propane_USC, caseCount=", str(caseCount))
141141

142142
# Propane_Z66
143-
print("Soving for Propane_Z66:")
143+
print("Solving for Propane_Z66:")
144144
gas = ct.Solution(Cantera_DIR+"Propane_Z66.yaml")
145145
equivRatios = np.array([1.0])
146146
T = np.array([1100])
@@ -150,7 +150,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times
150150
print("Done Propane_Z66, caseCount=", str(caseCount))
151151

152152
# nHeptane_Chalmers
153-
print("Soving for nHeptane_Chalmers:")
153+
print("Solving for nHeptane_Chalmers:")
154154
gas = ct.Solution(Cantera_DIR+"nHeptane_Chalmers.yaml")
155155
equivRatios = np.array([1.0])
156156
T = np.array([1100])

Utilities/Python/scripts/pyrolysis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def reaction_rate(T, Y, dTdt, R0, E, A, residue):
3636
plot_style = fdsplotlib.get_plot_style("fds")
3737
plt.rcParams["font.family"] = plot_style["Font_Name"]
3838
plt.rcParams["font.size"] = plot_style["Label_Font_Size"]
39+
# print(plot_style)
3940

4041
# Define the base path for files
4142
base_path = "../../Verification/Pyrolysis/" # Update this to the relative path of your files
@@ -116,7 +117,7 @@ def odes(T, Y):
116117
# Plot attributes
117118
ax1.set_xlabel("Temperature (°C)",fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]})
118119
ax1.set_ylabel("Normalized Mass",color=color1,fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]})
119-
ax2.set_ylabel("Mass Loss Rate × 1000 (1/s)",color=color2,fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]})
120+
ax2.set_ylabel("Normalized Mass Loss Rate × 1000 (1/s)",color=color2,fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]})
120121
ax1.tick_params(axis="y", colors=color1)
121122
ax2.tick_params(axis="y", colors=color2)
122123
ax1.set_ylim([0, 1.1])

0 commit comments

Comments
 (0)