anisotropy/extra/theta-flowrate.py

80 lines
1.8 KiB
Python
Raw Normal View History

2021-05-20 16:17:57 +05:00
import matplotlib.pyplot as plt
from math import sqrt
import sys, os
if __name__ == "__main__":
BUILD = "../build"
postProcessing = "postProcessing/flowRatePatch(name=outlet)/0/surfaceFieldValue.dat"
#structures = [
# "simple",
# #"bodyCentered",
# #"faceCentered"
#]
theta = [c * 0.01 for c in range(1, 28 + 1)]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
flowrate = [ [] for n in range(3) ]
2021-05-21 12:59:23 +05:00
#nu = 1e-06
#p = [1e-03, 0]
2021-05-20 16:17:57 +05:00
for num, d in enumerate(directions):
for t in theta:
path = os.path.join(
BUILD,
"simple",
"direction-{}{}{}".format(*d),
"theta-{}".format(t),
postProcessing
)
with open(path, "r") as io:
lastLine = io.readlines()[-1]
value = lastLine.replace(" ", "").replace("\n", "").split("\t")[1]
flowrate[num].append(float(value))
2021-05-21 12:59:23 +05:00
k2, k3 = [], []
for n, _ in enumerate(flowrate[0]):
k2.append(2 * flowrate[1][n] / flowrate[0][n])
k3.append(2 * flowrate[2][n] / flowrate[0][n])
2021-05-20 16:17:57 +05:00
plt.figure(1)
2021-05-21 12:59:23 +05:00
ax = plt.subplot(211)
line, = ax.plot(theta, flowrate[0], "o")
2021-05-20 16:17:57 +05:00
line.set_label("[1, 0, 0]")
2021-05-21 12:59:23 +05:00
line, = ax.plot(theta, flowrate[1], "o")
2021-05-20 16:17:57 +05:00
line.set_label("[0, 0, 1]")
line, = plt.plot(theta, flowrate[2], "o")
line.set_label("[1, 1, 1]")
2021-05-21 12:59:23 +05:00
ax.set_yscale("log")
2021-05-20 16:17:57 +05:00
plt.legend()
plt.grid(True)
plt.xlabel("theta")
plt.ylabel("flowRate")
2021-05-21 12:59:23 +05:00
ax = plt.subplot(212)
line, = ax.plot(theta, k2, "o")
line.set_label("k2")
line, = ax.plot(theta, k3, "o")
line.set_label("k3")
plt.legend()
plt.grid(True)
plt.xlabel("theta")
plt.ylabel("k")
2021-05-20 16:17:57 +05:00
plt.show()