Commit 10d771d6 authored by Salko Jr, Robert's avatar Salko Jr, Robert Committed by Salko Jr, Robert
Browse files

Update test and add plotter for CTF residuals file

Description:

CASL Ticket # - N/A
parent 578d72f1
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
import argparse
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import pandas

def main():
   parser = argparse.ArgumentParser(description="Plot the solver residuals for the CTF solution")
   parser.add_argument('residual_file', type=str, help="The .ctf.residuals.csv file produced by CTF")
   args = parser.parse_args()

   csv = pandas.read_csv(args.residual_file, comment='#')

   timestep = list(range(len(csv['dav_li'].tolist())))

   fig, ax = plt.subplots()
   plt.title('Vapor and droplet void residuals')
   ax.grid()
   ax.set_xlabel("Timestep")
   ax.set_ylabel("Residual [-]")
   ax.plot(timestep, csv['dav_li'].tolist(), label='av l-inf')
   ax.plot(timestep, csv['dav_l2'].tolist(), label='av l2')
   ax.plot(timestep, csv['dae_li'].tolist(), label='ae l-inf')
   ax.plot(timestep, csv['dae_l2'].tolist(), label='ae l2')
   ax.legend()
   plt.savefig('void.png')
   plt.close(fig)

   fig, ax = plt.subplots()
   plt.title('Pressure residuals')
   ax.grid()
   ax.set_xlabel("Timestep")
   ax.set_ylabel("Residual [psi]")
   ax.plot(timestep, csv['dp_li'].tolist(), label='p l-inf')
   ax.plot(timestep, csv['dp_l2'].tolist(), label='p l2')
   ax.plot(timestep, csv['dng_li'].tolist(), label='gas l-inf')
   ax.plot(timestep, csv['dng_l2'].tolist(), label='gas l2')
   ax.legend()
   plt.savefig('pressure.png')
   plt.close(fig)

   fig, ax = plt.subplots()
   plt.title('Enthalpy residuals')
   ax.grid()
   ax.set_xlabel("Timestep")
   ax.set_ylabel("Residual [BTU/lbm]")
   ax.plot(timestep, csv['davhv_li'].tolist(), label='av*hv l-inf')
   ax.plot(timestep, csv['davhv_l2'].tolist(), label='av*hv l2')
   ax.plot(timestep, csv['daelhl_li'].tolist(), label='(1-av)*hl l-inf')
   ax.plot(timestep, csv['daelhl_l2'].tolist(), label='(1-av)*hl l2')
   ax.legend()
   plt.savefig('enthalpy.png')
   plt.close(fig)

if __name__=='__main__':
   main()
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
# Convert in to cm
t_in_cm = 2.54
t_cm_m = 0.01 # cm/m
t_m_cm = 1/t_cm_m
t_mm_m = t_cm_m/10
t_m_mm = 1/t_mm_m
t_in_m = t_in_cm*t_cm_m
t_m_in = 1.0/t_in_m
t_J_kJ = 0.001  # J/kJ
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ setup(name='SubKit',
            'skplot_pin_coupling_temp=SubKit.process.plotCouplingSurfTemp:main',
            'skplot_pin_temp_time=SubKit.process.plotPinTempTime:main',
            'skplot_pin_surf_temp_axial=SubKit.process.plotPinTempAxial:main',
            'skplot_residuals=SubKit.process.plotSolverResiduals:main',
            'sk_gen_from_template=SubKit.utils.gen_from_template:main',
            'sksummary_dnb=SubKit.process.genDNBSummary:main',
            'sksummary_chan_time_data=SubKit.process.genChanTimeSummaryData:main']
+2 −0
Original line number Diff line number Diff line
@@ -63,3 +63,5 @@ runScriptTest "../SubKit/process/plotCouplingSurfTKE.py unitTests/coupling.h5 1
runScriptTest "../SubKit/process/plotCouplingSurfTemp.py unitTests/coupling.h5 1"
runScriptTest "../SubKit/process/plotCouplingSurfTemp.py unitTests/coupling.h5 1 --state=1 --figname=custom.png --min_axial=0.0 --max_axial=1.0 --max=0.1"
runScriptTest "../SubKit/process/plotCouplingSurfTemp.py unitTests/coupling.h5 1 --state=1 --figname=custom.png --min_axial=0.0 --max_axial=1.0 --min=0.05 --max=0.1"

runScriptTest "../SubKit/process/plotSolverResiduals.py unitTests/dummy.residuals.csv"
+1027 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading