Skip to content

Instantly share code, notes, and snippets.

@kastnerp
Last active February 27, 2022 19:44
Show Gist options
  • Save kastnerp/e76fb8ec1394fe0b0926deb07b9689f1 to your computer and use it in GitHub Desktop.
Save kastnerp/e76fb8ec1394fe0b0926deb07b9689f1 to your computer and use it in GitHub Desktop.
Plotting OpenFOAM residuals with Python
# https://bit.ly/plot-openfoam-residuals
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv("residuals.dat",skiprows=1, delimiter='\s+').iloc[:, 1:].shift(+1,axis=1).drop(["Time"], axis= 1)
plot = data.plot(logy= True, figsize=(15,5))
fig = plot.get_figure()
ax = plt.gca()
ax.legend(loc='upper right')
ax.set_xlabel("Iterations")
ax.set_ylabel("Residuals")
plt.savefig("residuals.png",dpi=600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment