Skip to content

Commit

Permalink
Changes to frequency domain to allow automatic calculation of diffrac…
Browse files Browse the repository at this point in the history
…tion integral components from field strengths in V/m. Alteration of the point area method to be based upon a third of the area of each triangle which uses the point. Improvement of spherical farfield function to avoid hole at poles.
  • Loading branch information
LyceanEM committed Dec 8, 2024
1 parent 0e1f64c commit 81a48b9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .idea/LyceanEM-Python.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 0 additions & 38 deletions docs/examples/DepthCamera_2023-03-22-08-38-43.json

This file was deleted.

8 changes: 4 additions & 4 deletions lyceanem/electromagnetics/emfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ def PoyntingVector(field_data, measurement=False, aperture=None):
if measurement:
poynting_vector_complex = poynting_vector_complex / aperture

field_data.point_data["Poynting_Vector_(Magnitude)"] = np.zeros(
field_data.point_data["Poynting_Vector_(Magnitude_(W/m2))"] = np.zeros(
(field_data.points.shape[0], 1)
)
field_data.point_data["Poynting_Vector_(Magnitude_(dB))"] = np.zeros(
field_data.point_data["Poynting_Vector_(Magnitude_(dBW/m2))"] = np.zeros(
(field_data.points.shape[0], 1)
)
field_data.point_data["Poynting_Vector_(Magnitude)"] = np.linalg.norm(
field_data.point_data["Poynting_Vector_(Magnitude_(W/m2))"] = np.linalg.norm(
poynting_vector_complex, axis=1
).reshape(-1, 1)
field_data.point_data["Poynting_Vector_(Magnitude_(dB))"] = 10 * np.log10(
field_data.point_data["Poynting_Vector_(Magnitude_(dBW/m2))"] = 10 * np.log10(
np.linalg.norm(poynting_vector_complex.reshape(-1, 1), axis=1)
)
return field_data
Expand Down
15 changes: 8 additions & 7 deletions lyceanem/geometry/geometryfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,13 @@ def compute_areas(field_data):
field_data.cell_data["Area"] = cell_areas
field_data.point_data["Area"] = np.zeros((field_data.points.shape[0]))
for inc, cell in enumerate(field_data.cells):
for point_inc in range(field_data.points.shape[0]):
field_data.point_data["Area"][point_inc] = np.mean(
field_data.cell_data["Area"][inc][
np.where(field_data.cells[inc].data == point_inc)[0]
]
)
if field_data.cells[inc].type == "triangle":
for point_inc in range(field_data.points.shape[0]):
field_data.point_data["Area"][point_inc] = np.sum(
field_data.cell_data["Area"][inc][
np.where(field_data.cells[inc].data == point_inc)[0]
] / 3
)

return field_data

Expand Down Expand Up @@ -457,7 +458,7 @@ def elevationtotheta(el):
return theta


def translate_mesh(mesh, translation_vector):
def mesh_translate(mesh, translation_vector):
"""
Translate a mesh by a given translation vector.
"""
Expand Down
21 changes: 14 additions & 7 deletions lyceanem/geometry/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from importlib.resources import files
from scipy.spatial.transform import Rotation as R

from ..base_classes import antenna_structures, structures, points
#from ..base_classes import antenna_structures, structures, points
from ..geometry import geometryfunctions as GF
from ..raycasting import rayfunctions as RF
from ..utility import math_functions as math_functions
Expand Down Expand Up @@ -483,9 +483,16 @@ def spherical_field(az_range, elev_range, outward_normals=False, field_radius=1.
mesh : meshio object
spherical field of points at specified azimuth and elevation angles, with meshed triangles
"""
vista_pattern = pv.grid_from_sph_coords(
az_range, (90 - elev_range), field_radius
).extract_surface()
vista_pattern=pv.Sphere(radius=field_radius,
theta_resolution=az_range.shape[0],
phi_resolution=elev_range.shape[0],
start_theta=az_range[0],
end_theta=az_range[-1],
start_phi=elev_range[0],
end_phi=elev_range[-1]).extract_surface()
#vista_pattern = pv.grid_from_sph_coords(
# az_range, (90 - elev_range), field_radius
#).extract_surface()
if outward_normals:
vista_pattern.point_data["Normals"] = vista_pattern.points / (
np.linalg.norm(vista_pattern.points, axis=1).reshape(-1, 1)
Expand Down Expand Up @@ -738,8 +745,8 @@ def gridedReflectorPoints(
],
point_data={"Normals": mesh_normals},
)
mesh_points.point_data["Area"] = np.ones((mesh_points.points.shape[0])) * (
grid_resolution**2
)
from ..utility.mesh_functions import pyvista_to_meshio
from .geometryfunctions import compute_areas
mesh_points = compute_areas(pyvista_to_meshio(pv.from_meshio(mesh_points).delaunay_2d()))

return mesh_points
2 changes: 2 additions & 0 deletions lyceanem/models/frequency_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def calculate_scattering(
axis=0,
)

#convert from field strengths to diffraction integral components
conformal_E_vectors=conformal_E_vectors*aperture_coords.point_data['Area'].reshape(-1,1)
if scattering == 0:
# only use the aperture point cloud, no scattering required.
scatter_points = meshio.Mesh(points=np.empty((0, 3)), cells=[])
Expand Down

0 comments on commit 81a48b9

Please sign in to comment.