Skip to content

Commit 042efa8

Browse files
Merge branch 'main' into add/circuit_maxwell
2 parents 3a88ffb + 8ccaf84 commit 042efa8

17 files changed

+900
-142
lines changed

.github/workflows/ci_cd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ env:
1616
DOCUMENTATION_CNAME: 'examples.aedt.docs.pyansys.com'
1717
MAIN_PYTHON_VERSION: '3.10'
1818
ON_CI: True
19-
PACKAGE_NAME: 'pyaedt-examples'
2019
PYAEDT_NON_GRAPHICAL: '1'
20+
# To keep as it impacts pyaedt behavior
2121
PYAEDT_DOC_GENERATION: '1'
2222

2323
concurrency:

doc/source/conf.py

+5
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ def convert_examples_into_notebooks(app):
252252
EXAMPLES_TO_NOT_EXECUTE = (
253253
"03_gui_manipulation.py",
254254
"05_electrothermal.py",
255+
# TODO: Remove the following example when 2025.1 is released, currently the latest version is 24.1.
256+
"Lumped_Element_Response.py",
257+
# TODO: Remove once EMIT examples are moved into extensions.
258+
"ComputeInterferenceType.py",
259+
"interference_gui.py",
255260
)
256261

257262
# NOTE: Only convert the examples if the workflow isn't tagged as coupling HTML and PDF build.

examples/02-HFSS/Waveguide_Filter.py

-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
"t": 0.15,
4646
"units": "in",
4747
}
48-
49-
non_graphical = False
50-
new_thread = True
5148
# -
5249

5350
# ## Create temporary directory and download files

examples/04-Layout/hfss_3d_layout/03_gui_manipulation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
AEDT_VERSION = "2024.2"
2525
NUM_CORES = 4
26-
NG_MODE = False # Open Electronics UI when the application is launched.
26+
NG_MODE = True # Open Electronics UI when the application is launched.
2727

2828
# Check if AEDT is launched in graphical mode.
2929

30-
if not NG_MODE or os.getenv("PYAEDT_DOC_GENERATION", "0") == "1":
30+
if not NG_MODE:
3131
print("Warning: this example requires graphical mode enabled.")
3232
sys.exit()
3333

examples/04-Layout/hfss_3d_layout/05_electrothermal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030

3131
AEDT_VERSION = "2024.2"
3232
NUM_CORES = 4
33-
NG_MODE = False # Open Electronics UI when the application is launched.
33+
NG_MODE = True # Open Electronics UI when the application is launched.
3434

3535
# Check if AEDT is launched in graphical mode.
3636

37-
if not NG_MODE or os.getenv("PYAEDT_DOC_GENERATION", "0") == "1":
37+
if not NG_MODE:
3838
print("Warning: this example requires graphical mode enabled.")
3939
sys.exit()
4040

examples/04-Layout/hfss_3d_layout/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pre-layout design creation.
99
01_power_integrity
1010
02_dc_ir_analysis
1111
03_gui_manipulation.py
12+
04_pre_layout_sma_connector_on_pcb.py
1213
05_electrothermal.py
1314
06_ipc2581_export.py
1415
07_import_gds.py

examples/08-Circuit/Circuit_Example.py

-11
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@
3333

3434
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
3535

36-
# ## Launch AEDT
37-
#
38-
# Launch AEDT in graphical mode. This example uses SI units.
39-
40-
# ## Set non-graphical mode
41-
#
42-
# Set non-graphical mode.
43-
# You can set ``non_graphical`` either to ``True`` or ``False``.
44-
# The Boolean parameter ``new_thread`` defines whether to create a new instance
45-
# of AEDT or try to connect to an existing instance of it.
46-
4736
# ## Launch AEDT and Circuit
4837
#
4938
# Launch AEDT and Circuit. The [pyaedt.Desktop](

examples/08-Circuit/Results.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#
4242
# - The argument ``non_graphical`` specifies whether or not an interactive session will be launched or if
4343
# AEDT runs in non-graphical mode.
44-
# - The Boolean parameter ``new_thread`` specifies if a new instance
44+
# - The Boolean parameter ``new_desktop`` specifies if a new instance
4545
# of AEDT will be launched. If it is set to ``False`` the API will try to connect to a running session.
4646
#
4747
# This example extracts an archived project. The full path

examples/10-EMIT/ComputeInterferenceType.py

+10-39
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
# Perform required imports
1010

1111
# +
12-
import os
13-
import subprocess
1412
import sys
1513
import tempfile
1614

1715
import ansys.aedt.core
16+
import plotly.graph_objects as go
1817
from ansys.aedt.core import Emit
1918
from ansys.aedt.core.emit_core.emit_constants import InterfererType
2019

@@ -25,34 +24,6 @@
2524
AEDT_VERSION = "2024.2"
2625
NG_MODE = False # Open Electronics UI when the application is launched.
2726

28-
# ## Python Dependencies
29-
#
30-
# The following cell can be run to make sure the ``plotly`` package is installed
31-
# in the current Python environment. If ``plotly`` is installed there is no need
32-
# to run this cell.
33-
34-
# +
35-
reqs = subprocess.check_output([sys.executable, "-m", "pip", "freeze"])
36-
installed_packages = [r.decode().split("==")[0] for r in reqs.split()]
37-
38-
39-
# Install required packages if they are not installed
40-
def install(package):
41-
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
42-
43-
44-
# Install plotly (if needed) to display legend and
45-
# scenario matrix results (internet connection needed)
46-
required_packages = ["plotly"]
47-
for package in required_packages:
48-
if package not in installed_packages:
49-
install(package)
50-
51-
# Import plotly library
52-
import plotly.graph_objects as go
53-
54-
# -
55-
5627
# ## Create temporary directory
5728
#
5829
# Create temporary directory.
@@ -103,10 +74,11 @@ def install(package):
10374

10475
power_matrix = []
10576
all_colors = []
106-
if os.getenv("PYAEDT_DOC_GENERATION", "0") != "1":
107-
all_colors, power_matrix = rev.interference_type_classification(
108-
domain, use_filter=False, filter_list=[]
109-
)
77+
78+
79+
all_colors, power_matrix = rev.interference_type_classification(
80+
domain, use_filter=False, filter_list=[]
81+
)
11082

11183
# ## Release AEDT
11284
#
@@ -238,12 +210,11 @@ def create_legend_table():
238210
fig.show()
239211

240212

241-
if os.getenv("PYAEDT_DOC_GENERATION", "0") != "1":
242-
# Create a scenario view for all the interference types
243-
create_scenario_view(power_matrix, all_colors, tx_radios, rx_radios)
213+
# Create a scenario view for all the interference types
214+
create_scenario_view(power_matrix, all_colors, tx_radios, rx_radios)
244215

245-
# Create a legend for the interference types
246-
create_legend_table()
216+
# Create a legend for the interference types
217+
create_legend_table()
247218

248219
# ## Cleanup
249220
#

examples/10-EMIT/ComputeProtectionLevels.py

+20-45
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212

1313
# +
1414
import os
15-
import subprocess
1615
import sys
1716
import tempfile
1817
import time
1918

19+
import plotly.graph_objects as go
2020
from ansys.aedt.core import Emit
21-
from ansys.aedt.core.emit_core.emit_constants import InterfererType
21+
from ansys.aedt.core.emit_core.emit_constants import \
22+
InterfererType # noqa: F401
2223

2324
# -
2425

@@ -27,34 +28,6 @@
2728
AEDT_VERSION = "2024.2"
2829
NG_MODE = False # Open Electronics UI when the application is launched.
2930

30-
# ## Python Dependencies
31-
#
32-
# The following cell can be run to make sure the ``plotly`` package is installed
33-
# in the current Python environment. If ``plotly`` is installed there is no need
34-
# to run this cell.
35-
36-
# +
37-
# Check to see which Python packages have been installed
38-
reqs = subprocess.check_output([sys.executable, "-m", "pip", "freeze"])
39-
installed_packages = [r.decode().split("==")[0] for r in reqs.split()]
40-
41-
42-
# Install required packages if they are not installed
43-
def install(package):
44-
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
45-
46-
47-
# Install any missing libraries
48-
required_packages = ["plotly"]
49-
for package in required_packages:
50-
if package not in installed_packages:
51-
install(package)
52-
# -
53-
54-
# Import to support plotting.
55-
56-
import plotly.graph_objects as go
57-
5831
# ## Create temporary directory
5932
#
6033
# Create temporary directory.
@@ -271,31 +244,33 @@ def create_scenario_view(emis, colors, tx_radios, rx_radios):
271244
#
272245
# Get lists of all transmitters and receivers in the project.
273246

274-
if os.getenv("PYAEDT_DOC_GENERATION", "0") != "1":
275-
rev = emitapp.results.current_revision
276-
rx_radios = rev.get_receiver_names()
277-
tx_radios = rev.get_interferer_names(InterfererType.TRANSMITTERS)
278-
domain = emitapp.results.interaction_domain()
247+
# NOTE : The following code can be uncommented.
248+
#
249+
# rev = emitapp.results.current_revision
250+
# rx_radios = rev.get_receiver_names()
251+
# tx_radios = rev.get_interferer_names(InterfererType.TRANSMITTERS)
252+
# domain = emitapp.results.interaction_domain()
279253

280254
# ## Classify the results
281255
#
282256
# Iterate over all the transmitters and receivers and compute the power
283257
# at the input to each receiver due to each of the transmitters. Computes
284258
# which, if any, protection levels are exceeded by these power levels.
285259

286-
if os.getenv("PYAEDT_DOC_GENERATION", "0") != "1":
287-
power_matrix = []
288-
all_colors = []
260+
# NOTE : The following code can be uncommented but depends on the previous commented code.
261+
#
262+
# power_matrix = []
263+
# all_colors = []
289264

290-
all_colors, power_matrix = rev.protection_level_classification(
291-
domain, global_levels=protection_levels
292-
)
265+
# all_colors, power_matrix = rev.protection_level_classification(
266+
# domain, global_levels=protection_levels
267+
# )
293268

294-
# Create a scenario matrix-like view for the protection levels
295-
create_scenario_view(power_matrix, all_colors, tx_radios, rx_radios)
269+
# # Create a scenario matrix-like view for the protection levels
270+
# create_scenario_view(power_matrix, all_colors, tx_radios, rx_radios)
296271

297-
# Create a legend for the protection levels
298-
create_legend_table()
272+
# # Create a legend for the protection levels
273+
# create_legend_table()
299274

300275
# ## Release AEDT
301276
#

examples/10-EMIT/EMIT_Example.py

+18-22
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,19 @@
1212
# Perform required imports.
1313

1414
# +
15-
import os
1615
import tempfile
1716
import time
1817

1918
import ansys.aedt.core
20-
from ansys.aedt.core.emit_core.emit_constants import ResultType, TxRxMode
19+
from ansys.aedt.core.emit_core.emit_constants import (
20+
ResultType, TxRxMode) # noqa: F401
2121

2222
# -
2323

2424
# ## Define constants
2525

2626
AEDT_VERSION = "2024.2"
27-
28-
# ## Set non-graphical mode
29-
#
30-
# Set non-graphical mode.
31-
# You can set ``non_graphical`` either to ``True`` or ``False``.
32-
33-
non_graphical = False
27+
NG_MODE = False # Open Electronics UI when the application is launched.
3428

3529
# ## Create temporary directory and download files
3630
#
@@ -50,7 +44,7 @@
5044
project_name = ansys.aedt.core.generate_unique_project_name(
5145
rootname=temp_folder.name, project_name="antenna_cosite"
5246
)
53-
d = ansys.aedt.core.launch_desktop(AEDT_VERSION, non_graphical, True)
47+
d = ansys.aedt.core.launch_desktop(AEDT_VERSION, NG_MODE, new_desktop=True)
5448
aedtapp = ansys.aedt.core.Emit(project_name, version=AEDT_VERSION)
5549

5650
# ## Create and connect EMIT components
@@ -87,18 +81,20 @@
8781
#
8882
# This part of the example requires Ansys AEDT 2023 R2.
8983

90-
if AEDT_VERSION > "2023.1" and os.getenv("PYAEDT_DOC_GENERATION", "0") != "1":
91-
rev = aedtapp.results.analyze()
92-
rx_bands = rev.get_band_names(rad2.name, TxRxMode.RX)
93-
tx_bands = rev.get_band_names(rad3.name, TxRxMode.TX)
94-
domain = aedtapp.results.interaction_domain()
95-
domain.set_receiver(rad2.name, rx_bands[0], -1)
96-
domain.set_interferer(rad3.name, tx_bands[0])
97-
interaction = rev.run(domain)
98-
worst = interaction.get_worst_instance(ResultType.EMI)
99-
if worst.has_valid_values():
100-
emi = worst.get_value(ResultType.EMI)
101-
print("Worst case interference is: {} dB".format(emi))
84+
# NOTE : The following code can be uncommented.
85+
#
86+
# if AEDT_VERSION > "2023.1":
87+
# rev = aedtapp.results.analyze()
88+
# rx_bands = rev.get_band_names(rad2.name, TxRxMode.RX)
89+
# tx_bands = rev.get_band_names(rad3.name, TxRxMode.TX)
90+
# domain = aedtapp.results.interaction_domain()
91+
# domain.set_receiver(rad2.name, rx_bands[0], -1)
92+
# domain.set_interferer(rad3.name, tx_bands[0])
93+
# interaction = rev.run(domain)
94+
# worst = interaction.get_worst_instance(ResultType.EMI)
95+
# if worst.has_valid_values():
96+
# emi = worst.get_value(ResultType.EMI)
97+
# print("Worst case interference is: {} dB".format(emi))
10298

10399
# ## Release AEDT
104100
#

0 commit comments

Comments
 (0)