Commit 5ec7c457 authored by Salko Jr, Robert's avatar Salko Jr, Robert Committed by Salko Jr, Robert
Browse files

Fix plot script and get rid of pandas dependency

Description:

CASL Ticket # - N/A
parent 6893dc4d
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -2,26 +2,26 @@ import argparse
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import pandas
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 = pandas.read_csv(args.residual_file, comment='#')
   csv = np.loadtxt(args.residual_file, delimiter=',', skiprows=4, comments='#')

   timestep = list(range(len(csv['dav_li'].tolist())))
   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['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.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)
@@ -30,11 +30,11 @@ def main():
   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.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)
@@ -43,11 +43,11 @@ def main():
   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.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)