BD_Integratoren/Auswertung/main.py
2021-10-27 22:00:24 +02:00

55 lines
2.1 KiB
Python

import glob
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sb
def make_figure(length_index, length, forces, integrators, computes):
sb.set_theme()
fig, axs = plt.subplots(nrows=len(forces), ncols=len(computes), figsize=(40, 24))
fig.suptitle(length, fontsize=30)
for index_compute, compute in enumerate(computes):
for index_forces, force in enumerate(forces):
legend = []
plt.sca(axs[index_forces][index_compute])
for index_integrator, integrator in enumerate(integrators):
for filename in glob.glob(f'data/out/*{force}*{integrator}*L{length_index}*_{compute}.dat'):
file = pd.read_csv(filename, delimiter=',')
sb.lineplot(x="time", y="val", data=file)
plt.ylabel(compute)
legend.append(integrator)
if index_integrator == 0:
sb.lineplot(x="time", y="target", data=file)
legend.append("analytisch")
plt.legend(title='iterators', labels=legend)
# plt.title("OAF without a force")
pad = 5 # in points
for ax, col in zip(axs[0], computes):
ax.annotate(col, xy=(0.5, 1), xytext=(0, pad),
xycoords='axes fraction', textcoords='offset points',
size='large', ha='center', va='baseline', fontsize=25)
for ax, row in zip(axs[:, 0], forces):
ax.annotate(row, xy=(0, 0.5), xytext=(-ax.yaxis.labelpad - pad, 0),
xycoords=ax.yaxis.label, textcoords='offset points',
size='large', ha='right', va='center', fontsize=25)
fig.tight_layout()
def main():
forces = ["zero", "const", "harmonic"]
integrators = ["euler", "heun", "exact", "bdas", "mbd"]
computes = ["msd", "oaf", "empxx", "empyy", "x", "x_squared"]
for l_i, l in enumerate(["sphere", "L = 1.5", "L = 2.0"]):
make_figure(length=l, length_index=l_i, forces=forces, computes=computes, integrators=integrators)
plt.show()
if __name__ == "__main__":
main()