-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlotWSSHistogram.py
43 lines (34 loc) · 1.46 KB
/
PlotWSSHistogram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
import argparse
import os.path
import numpy as np
from hemeTools.parsers.extraction import ExtractedProperty
import matplotlib.pyplot as plt
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('results_folder', type=str, help='Folder containing simulation results.')
args = parser.parse_args()
resultsFolder = args.results_folder
# Reading in flow simulation results
fileToCompare = 'surface-tractions.xtr'
fieldToCompare = 'tangentialprojectiontraction'
resultsFileName = os.path.join(resultsFolder, 'results', 'Extracted',
fileToCompare)
resultsProperties = ExtractedProperty(resultsFileName)
lastTimestep = resultsProperties.times[-1]
resultsLastTimeStep = resultsProperties.GetByTimeStep(lastTimestep)
wssMagnitude = np.linalg.norm(getattr(resultsLastTimeStep, fieldToCompare), axis=1)
# Set the bin width
binWidth = 0.25
bins = np.arange(min(wssMagnitude), max(wssMagnitude) + binWidth, binWidth)
# Compute weights such that histogram appears normalised
weights = np.ones_like(wssMagnitude)/float(len(wssMagnitude))
# Plot WSS histogram
plt.hist(wssMagnitude, bins=bins, weights=weights)
plt.xlabel('Wall shear stress (Pa)')
plt.ylabel('Probability')
plt.title('Computed wall shear stress histogram')
xMax = 15
plt.xlim([0, xMax])
plt.xticks(np.arange(0, xMax+1, 1))
plt.show()