Ejemplo n.º 1
0


# Individual case's name
case_names = []
case_names.append('PH-Breuer-10595')
case_names.append('PH-Breuer-5600')
case_names.append('PH-Breuer-2800')
case_names.append('PH-Breuer-1400')
case_names.append('PH-Breuer-700')


# Instantiate cases
hifi_data = []
for case_name in case_names:
    hifi_data.append(flowCase(case_name))


#####################################################################
### Figures
#####################################################################
# Fig 21 (b) pressure distribution
# compare_profiles('pm', 'x', 0, *hifi_data)
#
# # Fig 27 (a), (c)
# compare_profiles('um', 'y', 4, *hifi_data, xlim=[-0.2, 1.2], ylim=[-0.1, 3.1])
# compare_profiles('uu', 'y', 4, *hifi_data, xlim=[0, 0.1], ylim=[-0.1, 3.1])
#
# # Fig 23, tiny separation bubble
# hifi_data[3].show_flow('um', contour_level=[-0.1, 0, 0.1, 0.2, 0.3], xlim=[0.55, 0.93], ylim=[0.58, 0.82])
#
Ejemplo n.º 2
0
import numpy as np
import matplotlib.pyplot as plt

from uncert_ident.data_handling.flowcase import flowCase

case = flowCase("PH-Breuer-10595")
data = case.flow_dict

x = data['x']
y = data['y']

nx = data['nx']
ny = data['ny']

pos = np.linspace(0, 210, 22)

for p in pos:
    rng = range(int(p * ny), int((p + 1) * ny))

    yi = y[rng]
    ui = data['um'][rng]

    # dyi = np.abs(yi[1:] - yi[0:-1])
    # dui = np.mean([ui[1:], ui[:-1]], axis=0)

    # plt.plot(dui, np.cumsum(dyi))
    # plt.plot(ui, yi)

    # volflow = np.sum(dui*dyi)
    volflow = np.trapz(ui, yi)
    mflow = volflow * data['rho']
    labl_test = labl_tests[-1]
    qualitative_eval(model,
                     test_case,
                     feat_test,
                     labl_test,
                     model_idx,
                     result_name,
                     zoom_data=zoom_data)
    show()
    close_all()

    # True error metric
    if not exist_eval_file(
            result_name,
            "/figures/true_" + emetric + "_" + test_case + ".jpg"):
        case = flowCase(test_case)
        case.get_labels()
        fig, ax = case.show_label(
            emetric, show_background=True,
            labelpos='upper right')  #, zoom_box=zoom_data)
        # if zoom_data:
        # set_limits(ax, zoom_data[0][0], zoom_data[1][0])
        save("./results/" + result_name + "/figures/true_" + emetric + "_" +
             test_case + ".jpg")  #_zoom#_zoom_window
        show()
        close_all()

    # Model matrix
    if algo == "spaRTA" and not exist_eval_file(result_name,
                                                "model_matrix.pdf"):
        # get_model_matrix(result_name)
# ###################################################################
# test line_label
#
# Description
# Test appending line labels to lining plots.
#
# ###################################################################
# Author: hw
# created: 26. Apr. 2020
# ###################################################################
import matplotlib.pyplot as plt

from uncert_ident.data_handling.flowcase import flowCase, compare_profiles

case_name1 = 'Breuer_PH_LES_DNS_Re10595'
case_name2 = 'Breuer_PH_LES_DNS_Re5600'
case_name3 = 'Breuer_PH_LES_DNS_Re1400'
case1 = flowCase(case_name1, dimension=2)
case2 = flowCase(case_name2, dimension=2)
case3 = flowCase(case_name3, dimension=2)

compare_profiles('um', 'y', 2.0, case1, case2, case3)

plt.show()
# ###################################################################
# test lumley_triangle
#
# Description
# Test for the lumley triangle plot.
#
# ###################################################################
# Author: hw
# created: 24. Apr. 2020
# ###################################################################
import matplotlib.pyplot as plt

from uncert_ident.visualisation import plotter as plot
from uncert_ident.data_handling.flowcase import flowCase

# case_name = 'Breuer_PH_LES_DNS_Re10595'
case_name = 'Xiao_PH_DNS_case_1p0_refined_XYZ'
case = flowCase(case_name, dimension=2)

case.show_anisotropy(lumley=False)
case.show_anisotropy(lumley=False, loc_key='x', loc_value=2)

case.show_anisotropy(lumley=True)
case.show_anisotropy(lumley=True, loc_key='x', loc_value=2)

plt.show()
Ejemplo n.º 6
0
### Import
#####################################################################
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D

from uncert_ident.data_handling.flowcase import flowCase
from uncert_ident.methods.labels import compute_all_labels
import uncert_ident.visualisation.plotter as plot

#####################################################################
### Test
#####################################################################
# Choose case
case = flowCase('PH-Breuer-10595')
# case = flowCase('PH-Xiao-15')
# case = flowCase('CBFS-Bentaleb')
# case = flowCase('NACA4412-Vinuesa-top-10')
# case = flowCase('TBL-APG-Bobke-m13')

# Choose label
label = 'anisotropic'
# label = 'non_negative'

# Get flow data
dit = case.flow_dict
x, y = dit['x'], dit['y']
nx, ny = dit['nx'], dit['ny']

# Get labels without filter
Ejemplo n.º 7
0
#####################################################################
# Load data
# case_name = 'PH-Breuer-5600'
# case_name = 'PH-Xiao-15'
# case_name = 'CBFS-Bentaleb'
# case_name = 'NACA4412-Vinuesa-bottom-1'
# case_name = 'NACA4412-Vinuesa-top-1'
# case_name = 'NACA0012-Tanarro-top-4'
case_name = 'TBL-APG-Bobke-m13'
case_names = [case_name]

# case_names = ['PH-Breuer-10595', 'PH-Xiao-15', 'CBFS-Bentaleb', 'NACA4412-Vinuesa-top-4', 'TBL-APG-Bobke-b1']


for case_name in case_names:
    case = flowCase(case_name)
    data = case.flow_dict

    nx, ny = case.nx, case.ny
    X, Y = data['x'].reshape(nx, ny), data['y'].reshape(nx, ny)
    U, V = data['um'].reshape(nx, ny), data['vm'].reshape(nx, ny)
    spd = np.sqrt(U**2 + V**2)



    # Boundaries, seeding points, mask and axis label
    if "PH" in case_name:
        boundaries = get_boundaries(case)
        boundaries = list(boundaries)
        # boundaries.append([np.array([0.05, 8.9]), np.array([0.05, 0.05])])
        # boundaries.append([np.array([0.1, 0.1]), np.array([0.05, 2.985])])
import uncert_ident.visualisation.plotter as plot

from uncert_ident.methods.gradient import gradient_2d_with_transformation
from uncert_ident.data_handling.flowcase import flowCase

#####################################################################
### Tests
#####################################################################
print("TEST OF GRADIENT COMPUTATION RUNNING...")

# Read any flowcase data
# case_name = 'Breuer_PH_LES_DNS_Re10595'
case_name = 'Noorani_bent_pipe_DNS_R11700k001'

if 'Noorani' in case_name:
    case = flowCase(case_name, dimension=2, coord_sys='polar')
else:
    case = flowCase(case_name, dimension=2, coord_sys='cartesian')

dictionary = case.flow_dict

# Read non-uniform grid coordinates
nx = dictionary['nx']
ny = dictionary['ny']
x = dictionary['x'].reshape(nx, ny)
y = dictionary['y'].reshape(nx, ny)

# Compute test function and exact gradient in both coordinate systems
f = np.sin(x) * np.cos(y)
exact_gradient = np.array([np.cos(x) * np.cos(y),
                           -np.sin(x) * np.sin(y)]).reshape(2, -1)
from uncert_ident.data_handling.flowcase import flowCase
from uncert_ident.data_handling.data_import import find_case_names
from uncert_ident.methods.classification import get_databasis_frames, confusion_matrix, TRUE_POSITIVE, TRUE_NEGATIVE, FALSE_POSITIVE, FALSE_NEGATIVE
from uncert_ident.utilities import LABEL_KEYS
from uncert_ident.visualisation import plotter as plot

#####################################################################
### Test
#####################################################################
df_data, df_features, df_labels = get_databasis_frames(get_features=True, get_labels=True)
pred_case = 'PH-Breuer-10595'


# Get test case physical data
pred_data = flowCase(pred_case).flow_dict
stat_x, stat_y = pred_data['x'], pred_data['y']
nx, ny = pred_data['nx'], pred_data['ny']


# Build confusion matrix from predicted and true labels
pred_labl = np.random.choice([0, 1], size=nx*ny)
true_labl = df_labels.loc[df_labels['case'] == pred_case, LABEL_KEYS[1]].to_numpy()
confusion = confusion_matrix(pred_labl, true_labl)

pred_deci = np.random.randint(-100, 100, nx*ny)


# Plot random predictions
plot.physical_confusion(pred_data, confusion, show_background=False)
plot.physical_decision(pred_data, pred_deci, show_background=False)
#####################################################################
### Import
#####################################################################
import pandas as pd

from uncert_ident.data_handling.flowcase import flowCase
from uncert_ident.data_handling.data_import import find_case_names

#####################################################################
### Tests
#####################################################################
# Get cases
case_names = find_case_names()
hifi_data = list()
for case_name in case_names:
    hifi_data.append(flowCase(case_name, get_features=True, get_labels=True))
print("No of cases: " + str(len(hifi_data)))


# Get metadata
nams, npts, dims, geos, feat, labl = list(), list(), list(), list(), list(), list()
for case in hifi_data:
    nams.append(case.case_name)
    npts.append(case.num_of_points)
    dims.append(case.dimension)
    geos.append(case.geometry)
    case.feature_dict.update({'case': case.case_name})
    case.label_dict.update({'case': case.case_name})
    feat.append(pd.DataFrame(case.feature_dict))
    labl.append(pd.DataFrame(case.label_dict))
Ejemplo n.º 11
0
    assert len(vector.shape) == 2
    assert vector.shape[0] < vector.shape[1]

    for i in range(vector.shape[0]):
        maxabs = np.nanmax(abs(vector[i]))
        vector[i] = safe_divide(vector[i], maxabs)

    return vector


#####################################################################
### Test
#####################################################################
# Load data
# case = flowCase('PH-Breuer-10595')
case = flowCase('TBL-APG-Bobke-b2')

# Build anti-symmetric pseudotensors Pij, Kij
construct_antisymmetric_grad_p_grad_k(case.flow_dict)

# Normalise all tensors
normalise_Sij_Wij_Pij_Kij(case.flow_dict)

# Compute invariants by hand
inv = get_inv(case.flow_dict)
inv_norm = inv.copy()

# Normalise invariants
inv_norm = normalise_max_abs(inv_norm)

# Safe invariants to flow_dict (Only for visualisation, safe to feature_dict!)
Ejemplo n.º 12
0
import pandas as pd
import numpy as np

from uncert_ident.utilities import feature_to_q_keys
from uncert_ident.data_handling.flowcase import flowCase
from uncert_ident.visualisation.plotter import *

# case = flowCase("NACA4412-Vinuesa-top-1")
case = flowCase("PH-Xiao-10")
case.get_features()
case.get_labels()

a = 500
# idx = range(a*52, (a+1)*52)
idx = range(a * 385, (a + 1) * 385)

data = case.flow_dict
x = data['x'][idx]
y = data['y'][idx]

labl = case.label_dict['anisotropic'][idx]

feat = case.feature_dict
tke = feat['tke'][idx]
red = feat['Re_d'][idx]
keps = feat["k_eps_Sij"][idx]
orthogonal = feat["orthogonal"][idx]
stream_curv = feat["stream_curv"][idx]
pm_normal_shear_ratio = feat["pm_normal_shear_ratio"][idx]
inv02 = feat['inv02'][idx]
inv03 = feat['inv03'][idx]