Last active
February 27, 2022 19:44
-
-
Save kastnerp/e76fb8ec1394fe0b0926deb07b9689f1 to your computer and use it in GitHub Desktop.
Plotting OpenFOAM residuals with Python
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
# 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