Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Shielding effectiveness extension #5672

Merged
merged 21 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0b6981d
Add hertzian dipole
Samuelopez-ansys Jan 16, 2025
9d7efee
Create report from a table
Samuelopez-ansys Jan 16, 2025
0782bf1
SE extension
Samuelopez-ansys Jan 16, 2025
77a3044
Merge branch 'main' into feat/shielding_effectiveness
Samuelopez-ansys Jan 16, 2025
207c660
Add unit test
Samuelopez-ansys Jan 17, 2025
79276d1
Merge branch 'main' into feat/shielding_effectiveness
Samuelopez-ansys Jan 17, 2025
9d0a80d
Fix codacy
Samuelopez-ansys Jan 17, 2025
4568a89
Merge branch 'main' into feat/shielding_effectiveness
Samuelopez-ansys Jan 21, 2025
e7768d6
Merge branch 'main' into feat/shielding_effectiveness
Samuelopez-ansys Jan 29, 2025
7ec904b
Modify test number
Samuelopez-ansys Jan 29, 2025
7ae5537
Change 2 cores
Samuelopez-ansys Jan 29, 2025
a72cfff
Merge remote-tracking branch 'origin/feat/shielding_effectiveness' in…
Samuelopez-ansys Jan 29, 2025
5f2ae81
Merge branch 'main' into feat/shielding_effectiveness
Samuelopez-ansys Jan 29, 2025
a4ea97a
Skip test in Linux, simulation is taking too long
Samuelopez-ansys Jan 29, 2025
bed43e4
Add doc
Samuelopez-ansys Jan 29, 2025
467ca3e
Update src/ansys/aedt/core/hfss.py
Samuelopez-ansys Jan 31, 2025
1beeadf
Update doc/source/User_guide/pyaedt_extensions_doc/hfss/shielding.rst
Samuelopez-ansys Jan 31, 2025
2829479
CHORE: Auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 31, 2025
42aa6f1
Add comments
Samuelopez-ansys Jan 31, 2025
ca4cfe1
Merge branch 'main' into feat/shielding_effectiveness
Samuelopez-ansys Jan 31, 2025
ff43f08
Merge remote-tracking branch 'origin/feat/shielding_effectiveness' in…
Samuelopez-ansys Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Samuelopez-ansys marked this conversation as resolved.
Show resolved Hide resolved

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