diff --git a/ntrfc/postprocessing/meshconvergence/grid_convergece_index.py b/ntrfc/postprocessing/meshconvergence/grid_convergece_index.py index 5bd26848aa8a845cb8ee3c2cdb9d65794659fd14..56642ec2d0a3ab6761e3abdaef452253b27024e6 100644 --- a/ntrfc/postprocessing/meshconvergence/grid_convergece_index.py +++ b/ntrfc/postprocessing/meshconvergence/grid_convergece_index.py @@ -67,18 +67,3 @@ def getGCI(N1,N2,N3,fc1,fc2,fc3,D, Fs=1.25): # return [GCI_1, GCI_2, GCI_3], [EERE_1, EERE_2, EERE_3], [GCI_1_p1, GCI_2_p1, GCI_3_p1], \ # [EERE_1_p1, EERE_2_p1, EERE_3_p1] - -# fc3 = 25.263 -# fc2 = 23.565 -# fc1 = 23.151 -# -# N3 = 1 -# N2 = 8 -# N1 = 27 -# Fs=1.25 -# D = 3 - - - -#print('p(min) = ',p_min,'\np(max) = ',p_max,'\np(act) = ',P,'\np(rel) = ',prel(p_opt,P)) -# GCI_1, GCI_2, GCI_3 = getGCI(N1, N2, N3, fc1, fc2, fc3, D, Fs=1.25) diff --git a/ntrfc/postprocessing/turbo/probegeneration.py b/ntrfc/postprocessing/turbo/probegeneration.py new file mode 100644 index 0000000000000000000000000000000000000000..a2ec26aab3a5d602c1a978bf813312d7ce29b44e --- /dev/null +++ b/ntrfc/postprocessing/turbo/probegeneration.py @@ -0,0 +1,68 @@ +from ntrfc.utils.geometry.cascade_geometry import calcmidpassagestreamline +from ntrfc.utils.pyvista_utils.line import polyline_from_points, refine_spline +from ntrfc.utils.geometry.pointcloud_methods import midline_from_sides +import pyvista as pv +import numpy as np + + +def create_profileprobes(ssPoly,psPoly,midspan_z,pden_ps,pden_ss,tolerance=1e-10): + + ref_ss_x, ref_ss_y = refine_spline(ssPoly.points[::, 0], ssPoly.points[::, 1], 4000) + ref_ss_points = np.stack((ref_ss_x, ref_ss_y, np.zeros(len(ref_ss_y)))).T + ref_ssPoly = pv.PolyData(ref_ss_points) + ref_ss_poly = polyline_from_points(ref_ssPoly.points) + ref_ss_face = ref_ss_poly.extrude((0, 0, midspan_z * 2)).compute_normals() + ref_ss_face_shift = ref_ss_face.copy() + ref_ss_face_shift.points += tolerance * ref_ss_face_shift.point_data["Normals"] + ref_ss_cut = ref_ss_face_shift.slice(normal="z", origin=(0, 0, midspan_z)) + + ref_ps_x, ref_ps_y = refine_spline(psPoly.points[::, 0], psPoly.points[::, 1], 4000) + ref_ps_points = np.stack((ref_ps_x, ref_ps_y, np.zeros(len(ref_ps_y)))).T + ref_psPoly = pv.PolyData(ref_ps_points) + ref_ps_poly = polyline_from_points(ref_psPoly.points) + ref_ps_face = ref_ps_poly.extrude((0, 0, midspan_z * 2)).compute_normals() + ref_ps_face_shift = ref_ps_face.copy() + ref_ps_face_shift.points += tolerance * ref_ps_face_shift.point_data["Normals"] + ref_ps_cut = ref_ps_face_shift.slice(normal="z", origin=(0, 0, midspan_z)) + + x_ss_shift = ref_ss_cut.points[::, 0] + y_ss_shift = ref_ss_cut.points[::, 1] + + x_ps_shift = ref_ps_cut.points[::, 0] + y_ps_shift = ref_ps_cut.points[::, 1] + + x_bl_ss, y_bl_ss = refine_spline(x_ss_shift, y_ss_shift, pden_ss) + x_bl_ps, y_bl_ps = refine_spline(x_ps_shift, y_ps_shift, pden_ps) + + probes_ps = pv.PolyData(np.stack((x_bl_ss, y_bl_ss,midspan_z*np.ones(len(x_bl_ss)))).T) + probes_ss = pv.PolyData(np.stack((x_bl_ps, y_bl_ps,midspan_z*np.ones(len(x_bl_ps)))).T) + + return probes_ss, probes_ps + + + + +def create_midpassageprobes(midspan_z,x_inlet, x_outlet,pitch,beta1, beta2,midspoly,nop_streamline): + x_mcl, y_mcl = midspoly.points[::,0],midspoly.points[::,1] + + x_mpsl, y_mpsl = calcmidpassagestreamline(x_mcl, y_mcl, beta1, beta2, x_inlet, x_outlet, pitch) + + # x_probes = [] + # y_probes = [] + z_probes = [] + + nop = int(nop_streamline) + + xn, yn = refine_spline(x_mpsl, y_mpsl, nop) + for i in range(nop): + z_probes.append(midspan_z) + + x_probes = xn + y_probes = yn + + dist = np.sqrt((x_probes[0] - x_probes[1]) ** 2 + (y_probes[0] - y_probes[1]) ** 2) + + x_probes[0] = x_probes[0] + 0.00001 * dist + x_probes[-1] = x_probes[-1] - 0.00001 * dist + + return pv.PolyData(np.stack([x_probes,y_probes,np.ones(len(x_probes)*midspan_z)]).T) diff --git a/ntrfc/utils/geometry/cascade_geometry.py b/ntrfc/utils/geometry/cascade_geometry.py new file mode 100644 index 0000000000000000000000000000000000000000..869be32a1fbe5fd0294ca8c6a8350e295915581b --- /dev/null +++ b/ntrfc/utils/geometry/cascade_geometry.py @@ -0,0 +1,37 @@ +import numpy as np + +from ntrfc.utils.pyvista_utils.line import refine_spline + + +def calcmidpassagestreamline(x_mcl, y_mcl, beta1, beta2, x_inlet, x_outlet, t): + """ + Returns mid-passage line from sceletal-line + Returns two lists of Points representing a curve through the passage + Input: + x_mcl = Tuple + y_mcl = Tuple + beta1, beta2 = Angle in deg - Beta = Anströmwinkel + x_inlet, x_outlet = scalar - representing position x-component of in/outlet + t = scalar pitch + """ + + delta_x_vk = x_mcl[0] - x_inlet + delta_y_vk = np.tan(np.deg2rad(beta1 - 90)) * delta_x_vk + + p_inlet_x = x_mcl[0] - delta_x_vk + p_inlet_y = y_mcl[0] - delta_y_vk + + delta_x_hk = x_outlet - x_mcl[-1] + delta_y_hk = delta_x_hk * np.tan(np.deg2rad(beta2 - 90)) + + p_outlet_x = x_mcl[-1] + delta_x_hk + p_outlet_y = y_mcl[-1] + delta_y_hk + + x_mpsl = [p_inlet_x] + list(x_mcl) + [p_outlet_x] + y_mpsl = [p_inlet_y] + list(y_mcl) + [p_outlet_y] + + for i in range(len(x_mpsl)): + y_mpsl[i] = y_mpsl[i] + 0.5 * t + + return refine_spline(x_mpsl, y_mpsl, 1000) + diff --git a/ntrfc/utils/geometry/profile_tele_extraction.py b/ntrfc/utils/geometry/profile_tele_extraction.py index eaa3fa4818cbb712298a98652004983742927939..9212b7384f8827a9ab63bcd627102bee016b224f 100644 --- a/ntrfc/utils/geometry/profile_tele_extraction.py +++ b/ntrfc/utils/geometry/profile_tele_extraction.py @@ -261,10 +261,10 @@ def extract_vk_hk(sortedPoly, verbose=False): # todo: check if the next 5 lines are really necessary. its supposed to be a quickfix for high stagger angles poly = sortedPoly.copy() - vk_est,hk_est = calc_largedistant_idx(poly.points[::,0],poly.points[::,1]) - camber_est = (poly.points[vk_est]-poly.points[hk_est]) - stagger_est = vecAngle(np.array([1,0,0]),camber_est)*180/np.pi - poly.rotate_z(-stagger_est,inplace=True) + # vk_est,hk_est = calc_largedistant_idx(poly.points[::,0],poly.points[::,1]) + # camber_est = (poly.points[vk_est]-poly.points[hk_est]) + # stagger_est = vecAngle(np.array([1,0,0]),camber_est)*180/np.pi+1 + # poly.rotate_z(-stagger_est,inplace=True) para_int_points = np.array([3000, 3000]) para_filt = np.array([[1 * 10 ** -5, 3 * 10 ** -5, 8 * 10 ** -5, 1.1, 1]]) diff --git a/tests/test_ntrfc_geometry.py b/tests/test_ntrfc_geometry.py index f2ec16c3f27b1846f6b8587c21b5e31f29c163dc..cc329f6b6506a1562dc93fbb104c5e7aedc641f0 100644 --- a/tests/test_ntrfc_geometry.py +++ b/tests/test_ntrfc_geometry.py @@ -1,3 +1,6 @@ +from ntrfc.utils.geometry.cascade_geometry import calcmidpassagestreamline + + def test_calc_concavehull(): """ in these simple geometries, each point must be found by calcConcaveHull @@ -93,7 +96,7 @@ def test_extract_vk_hk(verbose=False): # manifold problems with other profiles with veronoi-mid and other unoptimized code. therefor tests only 0009 # todo: currently we cant test half_cosine_spacing profiles, as the resolution is too good for extract_vk_hk naca_code = "6509" - angle = 60# deg + angle = 30# deg res = 420 xs, ys = naca(naca_code, res, half_cosine_spacing=False) sorted_poly = pv.PolyData(np.stack([xs[:-1], ys[:-1], np.zeros(len(xs) - 1)]).T) @@ -102,7 +105,7 @@ def test_extract_vk_hk(verbose=False): ind_1 = res ind_2 = 0 - points = np.stack((X[:-1], Y[:-1], np.zeros(len(X) - 1))).T + points = np.stack((X[:], Y[:], np.zeros(len(X)))).T profile_points = pv.PolyData(points) sorted_poly = pv.PolyData(profile_points) ind_hk, ind_vk = extract_vk_hk(sorted_poly, verbose=verbose) @@ -205,12 +208,12 @@ def test_extract_geo_paras(verbose=False): import numpy as np import pyvista as pv - naca_code = "0009" - angle = 20 # deg + naca_code = "6009" + angle = 10 # deg alpha = 1 res = 240 xs, ys = naca(naca_code, res, half_cosine_spacing=False) - sorted_poly = pv.PolyData(np.stack([xs[:-1], ys[:-1], np.zeros(len(xs) - 1)]).T) + sorted_poly = pv.PolyData(np.stack([xs, ys, np.zeros(len(xs))]).T) sorted_poly.rotate_z(angle) poly, ps_poly, ss_poly, ind_hk, ind_vk, mids_poly, beta_leading, beta_trailing, camber_angle = extract_geo_paras( @@ -230,3 +233,8 @@ def test_extract_geo_paras(verbose=False): assert np.isclose(beta_trailing, angle, rtol=0.03), "wrong leading edge angle" assert np.isclose(mids_poly.length, 1, rtol=0.03) assert np.isclose(camber_angle, angle, rtol=0.03) + + +def test_calcmidpassagestreamline(): + # todo FILL + calcmidpassagestreamline diff --git a/tests/test_ntrfc_job.py b/tests/test_ntrfc_job.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/test_ntrfc_postprocessing.py b/tests/test_ntrfc_postprocessing.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..997fd83e210d16bc4d39e6d40309a67a057d076c 100644 --- a/tests/test_ntrfc_postprocessing.py +++ b/tests/test_ntrfc_postprocessing.py @@ -0,0 +1,48 @@ +from ntrfc.postprocessing.turbo.probegeneration import create_profileprobes, create_midpassageprobes +from ntrfc.utils.geometry.airfoil_generators.naca_airfoil_creator import naca +from ntrfc.utils.geometry.pointcloud_methods import extract_geo_paras +import pyvista as pv +import numpy as np + +def test_createprofileprobes(): + naca_code = "6009" + angle = 10 # deg + res = 240 + xs, ys = naca(naca_code, res, half_cosine_spacing=False) + sorted_poly = pv.PolyData(np.stack([xs, ys, np.zeros(len(xs))]).T) + sorted_poly.rotate_z(angle) + sorted_extracted_poly, psPoly, ssPoly, ind_vk, ind_hk, midsPoly, beta_leading, beta_trailing, camber_angle = extract_geo_paras(sorted_poly,1) + n_psprobes = 24 + n_ssprobes = 36 + probes_ss, probes_ps = create_profileprobes(ssPoly, psPoly, 1, n_ssprobes, n_psprobes,tolerance=1e-6) + assert probes_ps.number_of_points == n_psprobes, "number of pressure side probes not correct" + assert probes_ss.number_of_points == n_ssprobes, "number of suction side probes not correct" + +def test_create_midpassageprobes(): + naca_code = "6009" + angle = 10 # deg + res = 240 + xs, ys = naca(naca_code, res, half_cosine_spacing=False) + sorted_poly = pv.PolyData(np.stack([xs, ys, np.zeros(len(xs))]).T) + sorted_poly.rotate_z(angle) + sorted_extracted_poly, psPoly, ssPoly, ind_vk, ind_hk, midsPoly, beta_leading, beta_trailing, camber_angle = extract_geo_paras(sorted_poly,1) + nop = 40 + midspan_probes = create_midpassageprobes(1,-0.3, 0.3,0.1,beta_leading, beta_trailing,midsPoly,nop) + assert midspan_probes.number_of_points==nop, "number of probes on midpassage line not correct" + + +def test_getgci(): + # todo FILL + from ntrfc.postprocessing.meshconvergence.grid_convergece_index import getGCI + + fc3 = 23.263 + fc2 = 23.165 + fc1 = 23.151 + + N3 = 18576 + N2 = 74304 + N1 = 297216 + Fs=1.25 + D = 2 + + GCI_1, GCI_2, GCI_3 = getGCI(N1, N2, N3, fc1, fc2, fc3, D, Fs=1.25)