Skip to content
Snippets Groups Projects
Commit 7ed80d28 authored by Felix's avatar Felix
Browse files

much code for bad diagrams

parent 12231072
No related branches found
No related tags found
No related merge requests found
../..
\ No newline at end of file
#! /usr/bin/env python3
import sys
import os.path
import numpy
import matplotlib.pyplot as pyplot
import tikzplotlib
from fluidfoam.readpostpro import readforce
CASE_PATH = ".maindir/openfoam2012/freeCylinderFlow-N{N}-u{u}"
SUBPATH_FORCE_COEFFS = "forceCoeffsIncompressible/0/coefficiant.dat"
SUBPATH_GRADT = "patchAverage(name=cylinder,mag(grad(T)))"
PATH_DIAGRAMS = ".maindir/zeichnungen/generated"
DIAGRAM_WIDTH = r'\diagramwidth'
if __name__ == "__main__":
if len(sys.argv) == 3:
N = sys.argv[1]
u = sys.argv[2]
cases = [(N, u)]
else:
cases = [(N, u) for N in range(1, 3) for u in range(-2, 2) if os.path.isdir(CASE_PATH.format(N=N, u=u))]
print("cases:", cases)
for N, u in cases:
filenumber = "{nr}-u-{u}-N{N}".format(nr=(u + 3)*10 + N, u=u, N=N)
try:
force = numpy.array(readforce(CASE_PATH.format(N=N, u=u), namepatch='forceCoeffsIncompressible', name='coefficient'))
except FileNotFoundError as error:
print(error)
print("abort this case")
continue
times = force[len(force)//3:, 0]
drag_coeffs = force[len(force)//3:, 1]
if len(cases) == 1:
print("times:", times)
print("D:", drag_coeffs)
fig = pyplot.figure()
axis = pyplot.axes()
axis.set_xlabel('time')
axis.set_ylabel('Drag coefficiant')
print("plot D_c for N={N}, u={u}")
axis.plot(times, drag_coeffs)
tikzplotlib.save(figure=fig, filepath=(
PATH_DIAGRAMS + '{nr}-D.tex'.format(nr=filenumber)),
axis_width=DIAGRAM_WIDTH
)
fig.savefig(PATH_DIAGRAMS + '{nr}-D'.format(nr=filenumber))
# grad(T)
try:
gradT = numpy.array(readforce(CASE_PATH.format(N=N, u=u),
time_name='latestTime',
namepatch='patchAverage(name=cylinder,mag(grad(T)))',
name='surfaceFieldValue'))
except FileNotFoundError as error:
print(error)
print("abort this case")
continue
times = gradT[len(gradT)//3:, 0]
dT = gradT[len(gradT)//3:, 1]
if len(cases) == 1:
print("times:", times)
print("dT:", dT)
fig = pyplot.figure()
axis = pyplot.axes()
axis.set_xlabel('time')
axis.set_ylabel('avg(|n·∇T|)')
axis.plot(times, dT)
print("plot dt for N={N}, u = {u}".format(N=N, u=u))
tikzplotlib.save(figure=fig, filepath=(
PATH_DIAGRAMS + '{nr}-gT.tex'.format(nr=filenumber)),
axis_width=DIAGRAM_WIDTH
)
fig.savefig(PATH_DIAGRAMS + '{nr}-gT'.format(N=N, u=u))
name: diagrams
channels:
- conda-forge
- defaults
dependencies:
- matplotlib
- tikzplotlib
- pylint
- fluidfoam
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment