diff --git a/Utilities/Python/FDS_verification_script.py b/Utilities/Python/FDS_verification_script.py index 20eacea73d8..b10639e61ee 100644 --- a/Utilities/Python/FDS_verification_script.py +++ b/Utilities/Python/FDS_verification_script.py @@ -28,4 +28,6 @@ # Special cases +print("pyrolysis..."); subprocess.run(["python","./scripts/pyrolysis.py"]) + print("verification scripts completed successfully!") diff --git a/Utilities/Python/scripts/m2py_README.md b/Utilities/Python/scripts/README.md similarity index 58% rename from Utilities/Python/scripts/m2py_README.md rename to Utilities/Python/scripts/README.md index 48d9f5c5a2b..a4c0e85dff8 100644 --- a/Utilities/Python/scripts/m2py_README.md +++ b/Utilities/Python/scripts/README.md @@ -4,6 +4,17 @@ This step will get you 90% of the way there. Then there usually a few extra steps to get a working script. +#### Use pandas.read_csv + +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 +``` +import pandas as pd +``` +at the top of your script and you read the csv file with, for example, +``` +fds_data = pd.read_csv(fds_file, skiprows=2, header=None) # note: your header row may be different and remember Python is 0 based +``` + ## 2. Import `fdsplotlib` 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 import fdsplotlib ``` -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. +To make sure `fdsplotlib` is visible to all your python scripts add the following to your `~/.bashrc` +``` +# add PYTHONPATH for FDS scripts +export PYTHONPATH=$FIREMODELS/fds/Utilities/Python:$PYTHONPATH +``` ## 3. Add the plot style parameters diff --git a/Utilities/Python/scripts/cantera_ignition_delay.py b/Utilities/Python/scripts/cantera_ignition_delay.py index 33dac9483e2..2182c03c955 100644 --- a/Utilities/Python/scripts/cantera_ignition_delay.py +++ b/Utilities/Python/scripts/cantera_ignition_delay.py @@ -90,7 +90,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times caseCount = 0 # Metahne_grimech 12 -print("Soving for Metahne_grimech:") +print("Solving for Metahne_grimech:") gas = ct.Solution(Cantera_DIR+"Methane_grimech30.yaml") equivRatios = np.array([0.6, 1.0, 1.4]) T = np.array([900, 1000, 1100, 1200]) @@ -100,7 +100,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times print("Done Metahne_grimech, caseCount=", str(caseCount)) # Methane_TianfengLu -print("Soving for Methane_TianfengLu:") +print("Solving for Methane_TianfengLu:") gas = ct.Solution(Cantera_DIR+"Methane_TianfengLu.yaml") equivRatios = np.array([1.0]) T = np.array([1100]) @@ -110,7 +110,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times print("Done Methane_TianfengLu, caseCount=", str(caseCount)) # Methane_Smooke -print("Soving for Methane_Smooke:") +print("Solving for Methane_Smooke:") gas = ct.Solution(Cantera_DIR+"Methane_Smooke.yaml") equivRatios = np.array([1.0]) T = np.array([1100]) @@ -120,7 +120,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times print("Done Methane_Smooke, caseCount=", str(caseCount)) # Ethylene_TianfengLu -print("Soving for Ethylene_TianfengLu:") +print("Solving for Ethylene_TianfengLu:") gas = ct.Solution(Cantera_DIR+"Ethylene_TianfengLu.yaml") equivRatios = np.array([1.0]) T = np.array([1100]) @@ -130,7 +130,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times print("Done Ethylene_TianfengLu, caseCount=", str(caseCount)) # Propane_USC -print("Soving for Propane_USC:") +print("Solving for Propane_USC:") gas = ct.Solution(Cantera_DIR+"Propane_USC.yaml") equivRatios = np.array([1.0]) T = np.array([1100]) @@ -140,7 +140,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times print("Done Propane_USC, caseCount=", str(caseCount)) # Propane_Z66 -print("Soving for Propane_Z66:") +print("Solving for Propane_Z66:") gas = ct.Solution(Cantera_DIR+"Propane_Z66.yaml") equivRatios = np.array([1.0]) T = np.array([1100]) @@ -150,7 +150,7 @@ def calc_ignition_delay(gas, equivRatios, T, fuel,estimated_ignition_delay_times print("Done Propane_Z66, caseCount=", str(caseCount)) # nHeptane_Chalmers -print("Soving for nHeptane_Chalmers:") +print("Solving for nHeptane_Chalmers:") gas = ct.Solution(Cantera_DIR+"nHeptane_Chalmers.yaml") equivRatios = np.array([1.0]) T = np.array([1100]) diff --git a/Utilities/Python/scripts/pyrolysis.py b/Utilities/Python/scripts/pyrolysis.py index b700f56e4c7..4d98d4f1596 100644 --- a/Utilities/Python/scripts/pyrolysis.py +++ b/Utilities/Python/scripts/pyrolysis.py @@ -36,6 +36,7 @@ def reaction_rate(T, Y, dTdt, R0, E, A, residue): plot_style = fdsplotlib.get_plot_style("fds") plt.rcParams["font.family"] = plot_style["Font_Name"] plt.rcParams["font.size"] = plot_style["Label_Font_Size"] +# print(plot_style) # Define the base path for files base_path = "../../Verification/Pyrolysis/" # Update this to the relative path of your files @@ -116,7 +117,7 @@ def odes(T, Y): # Plot attributes ax1.set_xlabel("Temperature (°C)",fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]}) ax1.set_ylabel("Normalized Mass",color=color1,fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]}) - ax2.set_ylabel("Mass Loss Rate × 1000 (1/s)",color=color2,fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]}) + ax2.set_ylabel("Normalized Mass Loss Rate × 1000 (1/s)",color=color2,fontdict={"fontname": plot_style["Font_Name"], "fontsize": plot_style["Label_Font_Size"]}) ax1.tick_params(axis="y", colors=color1) ax2.tick_params(axis="y", colors=color2) ax1.set_ylim([0, 1.1])