Skip to content

Commit

Permalink
Merge pull request #380 from TristanHehnen/master
Browse files Browse the repository at this point in the history
BUWFZJ: Added Initial Plotting Scripts for Parallel Panel Simulation
  • Loading branch information
rmcdermo authored Aug 25, 2023
2 parents df7d266 + 05f99ec commit 7ec72e6
Show file tree
Hide file tree
Showing 10 changed files with 3,130 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/Fire_Growth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ jobs:

# ADD YOUR INSTITUTION BELOW, COPY STEPS 1 AND 2, CHANGE INSTITUTE NAME (AFTER 2023 AND WITHIN ZIP FILENAME)

# Step 1: generate the plots
- name: BUWFZJ Results
run: |
echo $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/Fire_Growth/NIST_Parallel_Panel/Computational_Results/2023/BUWFZJ
python NIST_Parallel_Panel_plot_BUWFZJ_cmp.py
python plot_burner_heat_flux_centerline.py
# Step 2: push the plots to the releases page
- name: Push BUWFZJ Results to release
if: ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' ) && github.repository_owner == 'MaCFP'
run: |
cd $GITHUB_WORKSPACE/Fire_Growth/NIST_Parallel_Panel/Computational_Results/2023/BUWFZJ/Output
zip Plots.zip -r Plots
mv Plots.zip NIST_Parallel_Panel_BUWFZJ_Plots.zip
gh release upload SCRIPT_FIGURES NIST_Parallel_Panel_BUWFZJ_Plots.zip --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# When submitting computational results, add your script to the list below (follow the example)

# Step 1: generate the plots
Expand Down Expand Up @@ -128,4 +147,4 @@ jobs:
mv Plots.zip UMD_SBI_FSRI-UMD_Plots.zip
gh release upload SCRIPT_FIGURES UMD_SBI_FSRI-UMD_Plots.zip --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Exp_Filename ,Exp_Header_Row,Exp_Data_Row,Exp_x_Col_Name,Exp_y_Col_Name,Exp_Data_Label ,Exp_Marker_Style,Cmp_Filename ,Cmp_Header_Row,Cmp_Data_Row,Cmp_x_Col_Name,Cmp_y_Col_Name,Cmp_Data_Label,Cmp_Marker_Style,Cmp_Line_Style,Plot_Title ,Plot_x_Label,Plot_y_Label ,Plot_x_Min,Plot_x_Max,Plot_y_Min,Plot_y_Max,Plot_Legend_Location,Plot_Filename
PMMA_HRR_qrad_R6.csv ,1,3,Time,HRR,Exp ,o ,PP_C5_01_cat_hrr.csv ,2,3,Time,HRR,Sim (2.0 cm), ,- ,NIST Parallel Panels ,Time (s),Heat Release Rate (kW),0,900,0,4000,upper right ,NIST_Parallel_Panel_HRR_BUWFZJ.pdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/python3
# T. Hehnen
# 24 August 2023

import sys
sys.path.append('../../../../../../macfp-db/Utilities/')

import macfp
import importlib
importlib.reload(macfp) # use for development (while making changes to macfp.py)
import matplotlib.pyplot as plt

macfp.dataplot(config_filename='NIST_Parallel_Panel_BUWFZJ_cmp_config.csv',
institute='BUW-FZJ',
revision='MaCFP-3, Tsukuba, 2023',
expdir='../../../Experimental_Data/',
cmpdir='./Output/',
pltdir='./Output/Plots/',
close_figs=True,
verbose=True,
plot_list=['all'])

# plt.show()

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#!/usr/bin/python3
# T. Hehnen
# 24 August 2023

import sys
sys.path.append('../../../../../../macfp-db/Utilities/')

import os
import macfp
import importlib
importlib.reload(macfp) # use for development (while making changes to macfp.py)
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

plt.close('all')


# Define general information.
# ------------------------------
# Basic information about cases.
burner_sim_info = {
"MaCFP_Burner_04": {
"FluidCells": "2.0 cm",
"fps": 2},
"MaCFP_Burner_08": {
"FluidCells": "1.0 cm",
"fps": 2},
"MaCFP_Burner_09": {
"FluidCells": "0.5 cm",
"fps": 2},
# "MaCFP_Burner_10": {
# "FluidCells": "0.5 cm",
# "fps": 2}
}

# Initialise simulation data collection.
burner_sims = dict()
sim_dir = os.path.join("Output")


# Device heights, in cm.
heights = [20, 50, 75, 100]
# Interesting times, in s.
desired_times = [20, 40, 60, 80]

# Define headers for experiment data extraction.
hf_labels = ["HF_z20", "HF_z50", "HF_z75", "HF_z100"]
u_hf_labels = ["u_exp_HF_z20", "u_exp_HF_z50", "u_exp_HF_z75", "u_exp_HF_z100"]
# Define headers for simulation data extraction.
devc_labels = ["HF_y0_z20", "HF_y0_z50", "HF_y0_z75", "HF_y0_z100"]

# Define plot elements.
colors = ['green', 'red', 'purple', 'brown']
line_styles = ['-', '--', '-.', ':']


# Read experiment data.
# ------------------------------
# Read centre line heat flux to empty panel, from experiment.
centreline_hf_path = os.path.join("..", "..", "..", "Experimental_Data",
"Burner_HF_Centerline_multi-layer.csv")
# First row as header and row with units skipped.
centreline_hf_df = pd.read_csv(centreline_hf_path, header=0, skiprows=[1])


# Read simulation data.
# ------------------------------
# Collect simulation responses.
for sim_label in burner_sim_info:
# Add dictionary per simulation setup.
if sim_label not in list(burner_sims):
# Prevent overwriting existing data ('CHID_hrr' and 'CHID_devc').
burner_sims[sim_label] = dict()

# Read 'CHID_devc.csv'-file as Pandas DataFrame.
devc_path = os.path.join(sim_dir, f"{sim_label}_devc.csv")
devc_df = pd.read_csv(devc_path, sep=',', header=1)
burner_sims[sim_label]["DEVC"] = devc_df

# Simulation response.
sim_fluxes = list()
for time_id, desired_time in enumerate(desired_times):
flux_avrgs = list()
# Define time window to average over.
base_frame = desired_time * burner_sim_info[sim_label]["fps"]
frame_window = 3

# Go over desired DEVC labels.
for devc_label in devc_labels:
# Get CHID_devc data.
devc_data = burner_sims[sim_label]["DEVC"]

# Find time window over which to average.
t_min = int(base_frame - frame_window)
t_max = int(base_frame + frame_window + 1)
# Compute average within the above window.
flux_avrg = np.average(devc_data[devc_label][t_min:t_max].to_numpy())
flux_avrgs.append(flux_avrg)

# Collect fluxes per time step.
sim_fluxes.append(flux_avrgs)

# Collect fluxes per sim setup.
burner_sims[sim_label]["Fluxes"] = sim_fluxes


# Create empty figure?
f = macfp.plot_to_fig(x_data=[0,1], y_data=[0,1], marker_style='None',line_style='None')


# Plot experiment data points per time step.
for time_id, time_step in enumerate(centreline_hf_df["Time"]):
# Get centre line heat flux per time step.
hf_centre = centreline_hf_df.iloc[time_id][hf_labels].to_numpy()
# Get related uncertainty.
hf_u_centre = centreline_hf_df.iloc[time_id][u_hf_labels].to_numpy()

# Define data series label.
ds_label = f"Exp ({time_step} s)"

# Plot experiment data points per time step.
f = macfp.plot_to_fig(x_data=hf_centre,
y_data=heights,
data_label=ds_label,
x_min=0,x_max=80,
y_min=0,y_max=180,
x_label='Heat Flux [kW/m²]',
y_label='Height [cm]',
marker_style='o',
marker_edge_color=colors[time_id],
marker_fill_color=colors[time_id],
line_style=' ',
show_legend=True,
figure_right_adjust=0,
legend_fontsize=10,
figure_handle=f)

# Draw error bars from reported experiment uncertainty, per time step.
plt.errorbar(hf_centre, heights,
xerr=hf_u_centre,
capsize=4, fmt=' ',
ecolor=colors[time_id])


# Plot simulation data points per time step.
for sim_id, sim_label in enumerate(list(burner_sims)):
# Get fluid cell size for setup.
cell_size = burner_sim_info[sim_label]["FluidCells"]

# burner_sims[sim_label]['Fluxes']
for time_id, time_step in enumerate(centreline_hf_df["Time"]):
# Define data series label.
ds_label = f"Sim ({time_step} s, {cell_size})"
f = macfp.plot_to_fig(x_data=burner_sims[sim_label]['Fluxes'][time_id],
y_data=heights,
data_label=ds_label,
x_min=0,x_max=80,
y_min=0,y_max=180,
x_label='Heat Flux [kW/m²]',
y_label='Height [cm]',
line_color=colors[time_id],
line_style=line_styles[sim_id],
show_legend=True,
figure_right_adjust=0,
legend_fontsize=10,
figure_handle=f)


# fig.tight_layout(pad=1.0, h_pad=0.0, w_pad=0.0, rect=[0.05, 0.05, 0.90, 0.95])

plot_dir = os.path.join(sim_dir, "Plots", "Burner_heatflux.pdf")
plt.savefig(plot_dir)

# plt.show()

0 comments on commit 7ec72e6

Please sign in to comment.