Skip to content

Commit

Permalink
FEAT: Shielding effectiveness extension (#5672)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Morais <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent df25e9d commit 4fca434
Show file tree
Hide file tree
Showing 11 changed files with 755 additions and 2 deletions.
51 changes: 51 additions & 0 deletions doc/source/User_guide/pyaedt_extensions_doc/hfss/shielding.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Shielding Effectiveness
=======================

The **Shielding Effectiveness** extension computes the shielding effectiveness of an enclosure.
It calculates the attenuation of an electromagnetic field inside the enclosure due to the presence of a shield.

The extension provides a graphical user interface (GUI) for configuration,
or it can be used in batch mode via command line arguments.

The following image shows the extension GUI:

.. image:: ../../../_static/extensions/shielding_ui.png
:width: 800
:alt: Shielding Effectiveness GUI


Features
--------

- Configure input parameters including source sphere radius, polarization, start and stop frequency and dipole type.
- Automatic HFSS setup.
- Switch between light and dark themes in the GUI.


Using the extension
-------------------

1. Open the **Automation** tab in the HFSS interface.
2. Locate and click the **Shielding Effectiveness** icon under the Extension Manager.
3. In the GUI, users can interact with the following elements:
- **Source sphere radius**: Source sphere radius in meters. It must fit inside the shielding.
- **Polarization**: X, Y, Z polarization component.
- **Frequency**: Start and stop frequency and the number of steps to analyze.
- **Electric dipole**: Activate electric dipole. Electric or magnetic dipole are available.
- **Cores**: Number of cores for the simulation.
- Toggle between light and dark themes.
4. Click on **Launch** to start the automated workflow.


Command line
------------

The extension can also be used directly via the command line for batch processing.


Use the following syntax to run the extension:

.. toctree::
:maxdepth: 2

../commandline
Binary file added doc/source/_static/extensions/shielding_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions src/ansys/aedt/core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -6766,6 +6766,110 @@ def plane_wave(

return self._create_boundary(name, inc_wave_args, "Plane Incident Wave")

@pyaedt_function_handler()
def hertzian_dipole_wave(
self,
assignment=None,
origin=None,
polarization=None,
is_electric=True,
radius="10mm",
name=None,
) -> BoundaryObject:
"""Create a hertzian dipole wave excitation.
The excitation is assigned in the assigned sphere. Inside this sphere, the field magnitude
is equal to the field magnitude calculated on the surface of the sphere.
Parameters
----------
assignment : str or list, optional
One or more objects or faces to assign finite conductivity to. The default is ``None``, in which
case the excitation is assigned to anything.
origin : list, optional
Excitation location. The default is ``["0mm", "0mm", "0mm"]``.
polarization : list, optional
Electric field polarization vector.
The default is ``[0, 0, 1]``.
is_electric : bool, optional
Type of dipole. Electric dipole if ``True``, magnetic dipole if ``False``. The default is ``True``.
radius : str or float, optional
Radius of surrounding sphere. The default is "10mm".
name : str, optional
Name of the boundary.
Returns
-------
:class:`pyaedt.modules.Boundary.BoundaryObject`
Port object.
References
----------
>>> oModule.AssignHertzianDipoleWave
Examples
--------
Create a hertzian dipole wave excitation.
>>> from ansys.aedt.core import Hfss
>>> hfss = Hfss()
>>> sphere = hfss.modeler.primitives.create_sphere([0, 0, 0], 10)
>>> port1 = hfss.hertzian_dipole_wave(assignment=sphere, radius=10)
"""
userlst = self.modeler.convert_to_selections(assignment, True)
lstobj = []
lstface = []
for selection in userlst:
if selection in self.modeler.model_objects:
lstobj.append(selection)
elif isinstance(selection, int) and self.modeler._find_object_from_face_id(selection):
lstface.append(selection)

props = {"Objects": [], "Faces": []}

if lstobj:
props["Objects"] = lstobj
if lstface:
props["Faces"] = lstface

if not origin:
origin = ["0mm", "0mm", "0mm"]
elif not isinstance(origin, list) or len(origin) != 3:
self.logger.error("Invalid value for `origin`.")
return False

x_origin, y_origin, z_origin = self.modeler._pos_with_arg(origin)

name = self._get_unique_source_name(name, "IncPWave")

hetzian_wave_args = {"OriginX": x_origin, "OriginY": y_origin, "OriginZ": z_origin}

if not polarization:
polarization = [0, 0, 1]
elif not isinstance(polarization, list) or len(polarization) != 3:
self.logger.error("Invalid value for `polarization`.")
return False

new_hertzian_args = {
"IsCartesian": True,
"EoX": polarization[0],
"EoY": polarization[1],
"EoZ": polarization[2],
"kX": polarization[0],
"kY": polarization[1],
"kZ": polarization[2],
}

hetzian_wave_args["IsElectricDipole"] = False
if is_electric:
hetzian_wave_args["IsElectricDipole"] = True

hetzian_wave_args["SphereRadius"] = radius
hetzian_wave_args.update(new_hertzian_args)
hetzian_wave_args.update(props)

return self._create_boundary(name, hetzian_wave_args, "Hertzian Dipole Wave")

@pyaedt_function_handler()
def set_radiated_power_calc_method(self, method="Auto"):
"""Set the radiated power calculation method in Hfss.
Expand Down
5 changes: 4 additions & 1 deletion src/ansys/aedt/core/modeler/modeler_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ def create_waveguide(
}

if wgmodel in WG:
original_model_units = self.model_units
self.model_units = "mm"

wgwidth = WG[wgmodel][0]
wgheight = WG[wgmodel][1]
if not wg_thickness:
Expand Down Expand Up @@ -840,7 +843,7 @@ def create_waveguide(
wgbox = self.create_box(origin, [wg_length, wb, hb], name=name)
self.subtract(wgbox, airbox, False)
wgbox.material_name = wg_material

self.model_units = original_model_units
return wgbox, p1, p2
else:
return None
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/aedt/core/modules/boundary/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ def create(self):
self._app.oboundary.AssignFluxTangential(self._get_args())
elif bound_type == "Plane Incident Wave":
self._app.oboundary.AssignPlaneWave(self._get_args())
elif bound_type == "Hertzian Dipole Wave":
self._app.oboundary.AssignHertzianDipoleWave(self._get_args())
elif bound_type == "ResistiveSheet":
self._app.oboundary.AssignResistiveSheet(self._get_args())
else:
Expand Down Expand Up @@ -681,6 +683,8 @@ def update(self):
self._app.oboundary.EditTerminal(self.name, self._get_args())
elif bound_type == "Plane Incident Wave":
self._app.oboundary.EditIncidentWave(self.name, self._get_args())
elif bound_type == "Hertzian Dipole Wave":
self._app.oboundary.EditIncidentWave(self.name, self._get_args())
elif bound_type == "ResistiveSheet":
self._app.oboundary.EditResistiveSheet(self.name, self._get_args())
else:
Expand Down
6 changes: 5 additions & 1 deletion src/ansys/aedt/core/visualization/report/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,11 @@ def create(self, name=None):
self.plot_name = generate_unique_name("Plot")
else:
self.plot_name = name
if self.setup not in self._post._app.existing_analysis_sweeps and "AdaptivePass" not in self.setup:
if (
self.setup not in self._post._app.existing_analysis_sweeps
and "AdaptivePass" not in self.setup
and " : Table" not in self.setup
):
self._post._app.logger.error("Setup doesn't exist in this design.")
return False
self._post.oreportsetup.CreateReport(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4fca434

Please sign in to comment.