Commit 16ef5be7 authored by Salko Jr, Robert's avatar Salko Jr, Robert
Browse files

Add a plotting tool for new CTF residual file

Also update default turbulent mixing coefficient.
parent 6ac43004
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 numpy as np

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 = np.loadtxt(args.residual_file, delimiter=',', skiprows=4, comments='#')

   timestep = list(range(csv.shape[0]))

   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[:, 0], label='av l-inf')
   ax.plot(timestep, csv[:, 3], label='av l2')
   ax.plot(timestep, csv[:, 4].tolist(), label='ae l-inf')
   ax.plot(timestep, csv[:, 7].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 [bar]")
   ax.plot(timestep, csv[:, 16], label='p l-inf')
   ax.plot(timestep, csv[:, 19], label='p l2')
   ax.plot(timestep, csv[:, 20], label='gas l-inf')
   ax.plot(timestep, csv[:, 23], 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 [kJ/kg]")
   ax.plot(timestep, csv[:, 8], label='av*hv l-inf')
   ax.plot(timestep, csv[:, 11], label='av*hv l2')
   ax.plot(timestep, csv[:, 12], label='(1-av)*hl l-inf')
   ax.plot(timestep, csv[:, 15].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