forked from idaholab/blackbear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardize Assessment Plot Organization
Refs idaholab#143 @bwspenc @SudiptaBiswas Checkout the new plot additions and where I've placed the directory structure. I've also updated the current assessment case to include the plots.
- Loading branch information
Showing
18 changed files
with
3,174 additions
and
0 deletions.
There are no files selected for viewing
238 changes: 238 additions & 0 deletions
238
assessment/asr_validation/wald2017B/analysis/plots/ASR_validation_plotting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
#!/usr/bin/env python3 | ||
# /*************************************************/ | ||
# /* DO NOT MODIFY THIS HEADER */ | ||
# /* */ | ||
# /* BlackBear */ | ||
# /* */ | ||
# /* (c) 2020 Battelle Energy Alliance, LLC */ | ||
# /* ALL RIGHTS RESERVED */ | ||
# /* */ | ||
# /* Prepared by Battelle Energy Alliance, LLC */ | ||
# /* Under Contract No. DE-AC07-05ID14517 */ | ||
# /* With the U. S. Department of Energy */ | ||
# /* */ | ||
# /* See COPYRIGHT for full restrictions */ | ||
# /*************************************************/ | ||
"""Create all plots for asr_validation/wald2017b assessment case.""" | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
|
||
# Plot Settings | ||
plt.style.use('../../../../../scripts/plot_style.mplstyle') | ||
|
||
# Global Constants | ||
AXES = ["x", "y", "z"] | ||
SEQ = range(1, 7) | ||
TIME_DIV = 86400 | ||
MEAN_DIV = 0.48 | ||
|
||
# plotting constants | ||
COLOR_LINES = ["r-", "b-", "g-"] | ||
SUBSCRIPTS = ["xx", "yy", "zz"] | ||
AXES_LIST = ['dispx', 'dispy', 'dispz'] | ||
|
||
|
||
def define_dataframes(*args): | ||
"""Return a list of pandas dataframes.""" | ||
return [pd.read_csv(fp) for fp in args] | ||
|
||
|
||
def sum_cols(df, col1, col2): | ||
"""Compute absolute value of two columns from a dataframe.""" | ||
return abs(df[col1]) + abs(df[col2]) | ||
|
||
|
||
def make_disp_sum_func(df): | ||
"""Return a function initialized with a dataframe.""" | ||
|
||
def sum_abs_cols(axis, num): | ||
"""Sum the columns specified by axis and num.""" | ||
return sum_cols(df, f"disp_{axis}_p{num}_pos", f"disp_{axis}_p{num}_neg") | ||
|
||
return sum_abs_cols | ||
|
||
|
||
def disp_dict(func): | ||
"""Return dictionary of key:values for all axes and numbers.""" | ||
return {f"disp{ax}_p{i}": func(ax, i) for ax in AXES for i in SEQ} | ||
|
||
|
||
def compute_displacements(df): | ||
disp_func = make_disp_sum_func(df) | ||
new_df = df.assign(**disp_dict(disp_func)) | ||
return new_df | ||
|
||
|
||
def disp_group(idx): | ||
"""Utility function used by groupby to group disp{x,y,z} values.""" | ||
return idx.split("_")[0] | ||
|
||
|
||
def get_displacement_mean(df): | ||
"""Return dataframe with each row being an axis of displacement.""" | ||
cols_wanted = [f'disp{i}_p{j}' for i in AXES for j in SEQ] | ||
dat = df[cols_wanted].transpose() | ||
dat_mean = dat.groupby(by=disp_group).apply(lambda x: x.mean()) | ||
return dat_mean | ||
|
||
|
||
def row_to_list(df, identifier): | ||
"""Return row of dataframe as list where index == identifier.""" | ||
return df.filter(like=identifier, axis=0).squeeze() | ||
|
||
|
||
def simplify(df, identifier): | ||
"""Return a dataframe with two columns: [time, disp{x|y|z}].""" | ||
df_mean = get_displacement_mean(df) | ||
temp = {'time': df.time, | ||
identifier: row_to_list(df_mean, identifier)} | ||
return pd.DataFrame(temp) | ||
|
||
|
||
def main(): | ||
"""Script Driver Function.""" | ||
# Experiment Data | ||
experiment, temp, rh, rebar2 = define_dataframes( | ||
"./data/asr_experiment.csv", | ||
"./data/ASR_validation_temperature1.csv", | ||
"./data/ASR_humidity.csv", | ||
"./data/asr_experiment_rebarz.csv" | ||
) | ||
|
||
# Simulation Data | ||
updated_out, refined_out, time01_out, time02_out, damage_out = define_dataframes( | ||
"./data/asr_concrete_block_calibration_creep_updated_out.csv", | ||
"./data/asr_concrete_block_calibration_creep_updated_refine_out.csv", | ||
"./data/asr_concrete_block_calibration_creep_updated_refine_time1_out.csv", | ||
"./data/asr_concrete_block_calibration_creep_updated_refine_time2_out.csv", | ||
"./data/asr_concrete_block_validation_rebar_creep_damage_updated_refine_out.csv", | ||
) | ||
|
||
# Add new displacement columns | ||
updated_out = compute_displacements(updated_out) | ||
refined_out = compute_displacements(refined_out) | ||
time01_out = compute_displacements(time01_out) | ||
time02_out = compute_displacements(time02_out) | ||
damage_out = compute_displacements(damage_out) | ||
|
||
################################################################### | ||
# Plots # | ||
################################################################### | ||
|
||
############# | ||
# Figure 01 # | ||
############# | ||
ax = plt.figure(1) | ||
for ax, cl, sub in zip(AXES_LIST, COLOR_LINES, SUBSCRIPTS): | ||
temp_dat = simplify(refined_out, ax) | ||
plt.plot( | ||
temp_dat.time / TIME_DIV, | ||
temp_dat[ax] / MEAN_DIV * 100, | ||
cl, | ||
label=f"$\epsilon_{{ {sub} }}$", | ||
markersize=5, | ||
linewidth=3, | ||
) | ||
|
||
plt.plot(experiment.x, experiment.y, "k*", label="Experiment", markersize=5) | ||
|
||
plt.xlabel("Time (days)") | ||
plt.ylabel("Axial Expansion (%)") | ||
plt.legend(frameon=False) | ||
plt.savefig("./figures/conc_calibration3.png", bbox_inches='tight') | ||
|
||
############# | ||
# Figure 02 # | ||
############# | ||
ax = plt.figure(2) | ||
for idx, df in enumerate([refined_out, time01_out, time02_out]): | ||
tmp_dat = simplify(df, 'dispx') | ||
plt.plot( | ||
tmp_dat.time / TIME_DIV, | ||
tmp_dat.dispx / MEAN_DIV * 100, | ||
COLOR_LINES[idx], | ||
label=f'Set-{idx}', | ||
markersize=5, | ||
linewidth=3 | ||
) | ||
plt.ylim(0,) | ||
plt.xlabel('Time (days)') | ||
plt.ylabel('Axial Expansion (%)') | ||
plt.legend(frameon=False) | ||
plt.savefig("./figures/plain_conc_sets3.png", bbox_inches='tight') | ||
|
||
############# | ||
# Figure 03 # | ||
############# | ||
ax = plt.figure(3) | ||
for ax, cl, sub in zip(AXES_LIST, COLOR_LINES, SUBSCRIPTS): | ||
tmp_dat = simplify(damage_out, ax) | ||
plt.plot( | ||
tmp_dat.time / TIME_DIV, | ||
tmp_dat[ax] / MEAN_DIV * 100, | ||
cl, | ||
label=f'$\epsilon_{{ {sub} }}$', | ||
markersize=5, | ||
linewidth=3 | ||
) | ||
plt.plot(rebar2.x, rebar2.y, 'k*', label='Experiment', markersize=5) | ||
plt.xlabel('Time (days)') | ||
plt.ylabel('Axial Expansion (%)') | ||
plt.legend(frameon=False) | ||
plt.savefig("./figures/uniaxial_rebar3.png", bbox_inches='tight') | ||
|
||
############# | ||
# Figure 04 # | ||
############# | ||
fig, (ax1, ax2) = plt.subplots(2, figsize=(10, 15)) | ||
refined_out = refined_out.iloc[1:] # Drop points up to approximately 28 days | ||
ax1.plot( | ||
refined_out.time / TIME_DIV, | ||
refined_out.temp, | ||
'r-', | ||
label='Average response from simulation', | ||
markersize=5, | ||
linewidth=3 | ||
) | ||
|
||
ax1.plot( | ||
temp.time / TIME_DIV, | ||
temp.temp, | ||
'b+', | ||
label='Experimental conditions ', | ||
markersize=6, | ||
markeredgewidth=2 | ||
) | ||
|
||
ax2.plot( | ||
rh.time_sec / TIME_DIV, | ||
rh.rh * 100, | ||
'b+', | ||
label='Experimental conditions', | ||
markersize=6, | ||
markeredgewidth=2 | ||
) | ||
|
||
ax2.plot( | ||
refined_out.time / TIME_DIV, | ||
refined_out.humidity * 100, | ||
'r-', | ||
label='Average response from simulation', | ||
markersize=5, | ||
linewidth=3 | ||
) | ||
|
||
ax1.set_xlim(0,) | ||
ax1.set_ylim(0,) | ||
ax1.set_ylabel('Temperature ($^o$C)') | ||
ax2.set_xlim(0,) | ||
ax2.set_ylim(0,) | ||
ax2.set_ylabel('Relative Humidity (%)') | ||
plt.xlabel('Time (days)') | ||
fig.tight_layout() | ||
ax1.legend(bbox_to_anchor=(0.5, 0), loc='lower center', frameon=False) | ||
fig.savefig("./figures/temp_rh_history3.png", bbox_inches='tight') | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
77 changes: 77 additions & 0 deletions
77
assessment/asr_validation/wald2017B/analysis/plots/data/ASR_experiment_3Rebar.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
x,y | ||
29.504799,0.006349773 | ||
37.47113646,0.046931555 | ||
42.55636768,0.080665323 | ||
44.91793017,0.122162871 | ||
49.18973432,0.161459884 | ||
52.00261764,0.198155151 | ||
56.23243845,0.214117841 | ||
61.65878425,0.260146816 | ||
66.04604257,0.193593207 | ||
72.45374878,0.234745658 | ||
72.86938378,0.283338244 | ||
79.2078175,0.318479373 | ||
79.72736125,0.356130583 | ||
84.40325497,0.295116315 | ||
87.22363532,0.385975718 | ||
90.98414244,0.312036118 | ||
99.98956739,0.38076799 | ||
102.0677424,0.30884277 | ||
113.4977048,0.311510828 | ||
113.6708861,0.378656948 | ||
124.9276673,0.31122998 | ||
125.9667548,0.380459057 | ||
136.3576297,0.303862396 | ||
138.4358047,0.379841191 | ||
147.7875922,0.307578953 | ||
152.1171234,0.389469603 | ||
159.2175546,0.3172963 | ||
165.2788983,0.39976737 | ||
170.647517,0.328642567 | ||
179.7024224,0.42106168 | ||
182.0774795,0.34830194 | ||
191.4292669,0.442503102 | ||
193.5074419,0.370910219 | ||
203.0076704,0.463208968 | ||
204.9374044,0.393237649 | ||
214.8087356,0.480347395 | ||
216.3673668,0.407163039 | ||
227.5004471,0.459898972 | ||
227.7973293,0.382986691 | ||
239.2272917,0.384952628 | ||
240.2663792,0.459854839 | ||
250.6572541,0.394295511 | ||
252.8838702,0.472256292 | ||
262.0872166,0.404143921 | ||
266.0703853,0.479575062 | ||
273.517179,0.408731108 | ||
281.829879,0.481055366 | ||
284.9471415,0.418317392 | ||
296.3771039,0.504997674 | ||
296.3771039,0.430787052 | ||
307.8070664,0.420479923 | ||
311.0975101,0.490645161 | ||
319.2370288,0.42413095 | ||
323.56656,0.500170596 | ||
330.6669912,0.423428829 | ||
338.1137849,0.490130273 | ||
342.0969537,0.424411798 | ||
351.2755599,0.487298387 | ||
353.5269161,0.427079856 | ||
364.9568786,0.429467065 | ||
366.1691473,0.496823821 | ||
376.386841,0.431854275 | ||
378.6381972,0.494506824 | ||
387.8168034,0.465724566 | ||
388.0765753,0.414312965 | ||
397.1685909,0.393237649 | ||
404.4422034,0.46522255 | ||
408.5985533,0.403348184 | ||
415.2487133,0.452440447 | ||
420.0285158,0.379335664 | ||
426.3669495,0.421409843 | ||
436.3075532,0.392075919 | ||
437.6930032,0.453198737 | ||
442.8884407,0.388182382 | ||
444.9666157,0.440186104 | ||
445.4861594,0.48626861 |
Oops, something went wrong.