From 30f4eece0ad59c9e18bad3cfd05c4c12a6f704d0 Mon Sep 17 00:00:00 2001 From: LyceanEM <60020395+LyceanEM@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:13:24 +0100 Subject: [PATCH] Added lip option to parabolic reflector, and fixed typo in antenna pattern class, referencing deprecated directivity_transformv2. --- lyceanem/base_classes.py | 29 ++++++++++++-------------- lyceanem/geometry/geometryfunctions.py | 2 +- lyceanem/geometry/targets.py | 21 ++++++++++++------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lyceanem/base_classes.py b/lyceanem/base_classes.py index f77a7b4..f3f677b 100644 --- a/lyceanem/base_classes.py +++ b/lyceanem/base_classes.py @@ -174,20 +174,18 @@ def export_points(self, point_index=None): combined points """ if point_index == None: - + points=np.empty((0,3)) for item in range(len(self.points)): if item == 0: - points = np.array(self.points[item].points) + points = np.append(points,np.array(self.points[item].points),axis=0) else: points = np.append(points, self.points[item].points, axis=0) point_data = {} for key in self.points[0].point_data.keys(): + point_data[key] = np.empty((0,self.points[0].point_data[key].shape[1])) for item in range(len(self.points)): - if item == 0: - point_data[key] = np.array(self.points[item].point_data[key]) - else: - point_data_element = np.array(self.points[item].point_data[key]) - point_data[key] = np.append(point_data[key], point_data_element, axis=0) + point_data_element = np.array(self.points[item].point_data[key]) + point_data[key] = np.append(point_data[key], point_data_element, axis=0) combinded_points = meshio.Mesh(points, cells = [("vertex", np.array([[i, ] for i in range(points.shape[0])]))], point_data=point_data) combinded_points = GF.mesh_transform(combinded_points, self.pose, False) @@ -197,22 +195,21 @@ def export_points(self, point_index=None): else: + points=np.empty((0,3)) for item in point_index: if item == 0: - points = np.array(self.points[item].points) + points = np.append(points,np.array(self.points[item].points),axis=0) else: points = np.append(points, self.points[item].points, axis=0) point_data = {} - for key in self.points[0].point_data.keys(): + for key in self.points[point_index[0]].point_data.keys(): + point_data[key] = np.empty((0,self.points[point_index[0]].point_data[key].shape[1])) for item in point_index: - if item == 0: - point_data[key] = np.array(self.points[item].point_data[key]) - else: - point_data_element = np.array(self.points[item].point_data[key]) - point_data[key] = np.append(point_data[key], point_data_element, axis=0) + point_data_element = np.array(self.points[item].point_data[key]) + point_data[key] = np.append(point_data[key], point_data_element, axis=0) - combinded_points = meshio.Mesh(points, point_data=point_data) + combinded_points = meshio.Mesh(points, cells = [("vertex", np.array([[i, ] for i in range(points.shape[0])]))], point_data=point_data) combinded_points = GF.mesh_transform(combinded_points, self.pose, False) @@ -1044,7 +1041,7 @@ def directivity(self): the maximum directivity for each pattern """ - Dtheta, Dphi, Dtotal, Dmax = BM.directivity_transformv2( + Dtheta, Dphi, Dtotal, Dmax = BM.directivity_transform( self.pattern[:, :, 0], self.pattern[:, :, 1], az_range=self.az_mesh[0, :], diff --git a/lyceanem/geometry/geometryfunctions.py b/lyceanem/geometry/geometryfunctions.py index 7725a22..03d725d 100644 --- a/lyceanem/geometry/geometryfunctions.py +++ b/lyceanem/geometry/geometryfunctions.py @@ -146,9 +146,9 @@ def compute_normals(mesh): mesh.cell_data['Normals'] = cell_normal_list #calculate vertex normals + point_normals=np.empty((0,3)) for inc, cell in enumerate(mesh.cells): if cell.type == 'triangle': - point_normals=np.empty((0,3)) for inc in range(mesh.points.shape[0]): associated_cells=np.where(inc==cell.data)[0] print(associated_cells) diff --git a/lyceanem/geometry/targets.py b/lyceanem/geometry/targets.py index ae80390..dd35877 100755 --- a/lyceanem/geometry/targets.py +++ b/lyceanem/geometry/targets.py @@ -304,13 +304,16 @@ def meshedHorn( return structure, mesh_points -def parabolic_aperture(diameter, focal_length, thickness, mesh_size, sides='front'): +def parabolic_aperture(diameter, focal_length, thickness, mesh_size, sides='front', lip=False, lip_height=1e-3, + lip_width=1e-3): # Define function for parabola equation (y^2 = 4*focal_length*x) + import lyceanem.geometry.geometryfunctions as GF + import lyceanem.utility.math_functions as math_functions def parabola(x): return (1 / (4 * focal_length)) * x ** 2 with pygmsh.occ.Geometry() as geom: - geom.characteristic_length_max = mesh_size + geom.characteristic_length_max = mesh_size * 0.8 # Define points cp1 = geom.add_point([0, 0, 0]) # Center point cp2 = geom.add_point([diameter * 0.5 * (1 / 6), 0, parabola(diameter * 0.5 * (1 / 6))]) @@ -331,12 +334,20 @@ def parabola(x): angle=0.25 * np.pi) volume_list.append(b) for inc in range(7): - geom.rotate(surface, point=[0.0, 0.0, 0.0], angle=(1 / 4) * np.pi, axis=[0.0, 0.0, 1.0]) _, b2, _ = geom.revolve(surface, rotation_axis=[0.0, 0.0, 1.0], point_on_axis=[0.0, 0.0, 0.0], angle=0.25 * np.pi) volume_list.append(b2) + if lip: + axis1 = np.array([0.0, 0.0, -lip_height]) + + start_point = np.array([0.0, 0.0, parabola(diameter * 0.5)]) + cylinder1 = geom.add_cylinder(start_point.ravel(), axis1, diameter / 2) + cylinder2 = geom.add_cylinder(start_point.ravel(), axis1, diameter / 2 + lip_width) + final = geom.boolean_difference([cylinder2], [cylinder1]) + volume_list.append(final) + full_reflector = geom.boolean_union(volume_list) mesh_temp = geom.generate_mesh(dim=2) @@ -411,10 +422,6 @@ def parabola(x): return mesh, aperture_points - - - - def gridedReflectorPoints( majorsize, minorsize, thickness, grid_resolution, sides="all" ):