Skip to content

Commit

Permalink
Added holdUp to pyBUMP
Browse files Browse the repository at this point in the history
  • Loading branch information
GiordiR committed Apr 7, 2022
1 parent d1efc96 commit 6d86c7a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*/constant/polyMesh/
*/bubbleColumn.*
/bubbleColumn-kOmega2/
__pycache__/
2 changes: 1 addition & 1 deletion bubbleColumnDegass/input
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ inizioMedia 0;
// Force models

Dbubble 3e-3;
Dragmodel SchillerNaumann; // SchillerNaumann - IshiiZuber - TomiyamaAnalytic -
Dragmodel IshiiZuber; // SchillerNaumann - IshiiZuber - TomiyamaAnalytic -
// TomiyamaCorrelated
Liftmodel none; // none - Tomiyama
Walllub none; // none - Antal - Frank - Tomiyama
Expand Down
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@


# CASO BASE
xVars, avgVars = readScalar("bubbleColumn", "surfaces", "alphaMean.air_y_63cm.raw")
plot(xVars, avgVars, "surfaces", 63)
xVars, avgVars = readScalar("bubbleColumnDegass", "surfaces", "alphaMean.air_y_8cm.raw")
plot(1,xVars, avgVars, "surfaces", 63)


xHold, yHold = readScalar("bubbleColumnDegass", "holdUp", "volFieldValue.dat")
plot(2,xHold, yHold, "holdUp", 8)
50 changes: 38 additions & 12 deletions pyBUMP.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from random import sample
import readline
from grpc import stream_stream_rpc_method_handler
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
Expand All @@ -8,35 +10,59 @@ def readScalar(caseFolder, sampleType, fileName):

#Find sample path
sampleTypePath = os.path.join(caseFolder, "postProcessing", sampleType)
samplePath = os.path.join(sampleTypePath, os.listdir(sampleTypePath)[-1], fileName)
samplePath = os.path.join(sampleTypePath, os.listdir(sampleTypePath)[0], fileName)

#Find data firs line
iRow = findFirstRow(samplePath)

#Read sample file and sort
varDf = pd.read_csv(samplePath, delimiter="\s+", skiprows=2, header=None)
varDf = pd.read_csv(samplePath, delimiter="\s+", skiprows=iRow, header=None)
vars = varDf.to_numpy(dtype=float)
vars = vars[np.argsort(vars[:, 0])]

#Mean over equal x values
avgVars = np.average(vars[:,3].reshape(-1, 4), axis=1)
if sampleType=="surfaces":
#Sort data
vars = vars[np.argsort(vars[:, 0])]

#Mean over equal x values
yVars = np.average(vars[:,3].reshape(-1, 4), axis=1)

#x values
xVars = vars[::4, 0]
elif sampleType=="holdUp":
xVars = vars[:,0]
yVars = vars[:,1]


#x values
xVars = vars[::4, 0]
return xVars, yVars

def findFirstRow(filePath):

return xVars, avgVars
with open(filePath) as file:
i = 0
lines = file.readlines()
for line in lines:
if not line.startswith("#"):
break
i += 1

return i

def plot(xVar, yVar, sampleType, h):

def plot(figID, xVars, yVars, sampleType, h):

# INSERIRE DATI SPERIMENTALI A CONFRONTO

fig = plt.figure()
fig = plt.figure(figID)
ax = fig.subplots()

if sampleType=="surfaces":
ax.plot(xVar, yVar, label = r"$J_G$")
ax.plot(xVars, yVars, label = r"$J_G$")
ax.set_title('Gas volume fraction distribution at h = '+str(h)+' cm')
ax.set_xlabel('x (m)')
ax.set_ylabel('gas volume fraction (-)')
ax.legend()
else:
ax.plot(xVar, yVar, label = 'test')
ax.plot(xVars, yVars, label = 'test')

plt.show()

0 comments on commit 6d86c7a

Please sign in to comment.