Skip to content

Commit

Permalink
Added lip option to parabolic reflector, and fixed typo in antenna pa…
Browse files Browse the repository at this point in the history
…ttern class, referencing deprecated directivity_transformv2.
  • Loading branch information
LyceanEM committed Jun 25, 2024
1 parent 68f8075 commit 30f4eec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
29 changes: 13 additions & 16 deletions lyceanem/base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)


Expand Down Expand Up @@ -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, :],
Expand Down
2 changes: 1 addition & 1 deletion lyceanem/geometry/geometryfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 14 additions & 7 deletions lyceanem/geometry/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))])
Expand All @@ -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)
Expand Down Expand Up @@ -411,10 +422,6 @@ def parabola(x):
return mesh, aperture_points






def gridedReflectorPoints(
majorsize, minorsize, thickness, grid_resolution, sides="all"
):
Expand Down

0 comments on commit 30f4eec

Please sign in to comment.