Skip to content

Commit 3c68888

Browse files
Convert to md format
01-Modeling-setup
1 parent ba8447b commit 3c68888

File tree

2 files changed

+64
-110
lines changed

2 files changed

+64
-110
lines changed

examples/01-Modeling-Setup/Optimetrics.py

+25-47
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
"""
2-
General: optimetrics setup
3-
--------------------------
4-
This example shows how you can use PyAEDT to create a project in HFSS and create all optimetrics setups.
5-
"""
6-
7-
###############################################################################
8-
# Perform required imports
9-
# ~~~~~~~~~~~~~~~~~~~~~~~~
1+
# # General: optimetrics setup
2+
#
3+
# This example shows how you can use PyAEDT to create a project in HFSS and create all optimetrics setups.
4+
5+
6+
# ## Perform required imports
7+
#
108
# Perform required imports.
119

1210
import pyaedt
1311

1412
import os
1513

16-
###############################################################################
17-
# Set non-graphical mode
18-
# ~~~~~~~~~~~~~~~~~~~~~~
14+
# ## Set non-graphical mode
15+
#
1916
# Set non-graphical mode.
2017
# You can set ``non_graphical`` either to ``True`` or ``False``.
2118

2219
non_graphical = False
2320

24-
###############################################################################
25-
# Initialize object and create variables
26-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
# ## Initialize object and create variables
22+
#
2723
# Initialize the ``Hfss`` object and create two needed design variables,
2824
# ``w1`` and ``w2``.
2925

3026
hfss = pyaedt.Hfss(specified_version="2023.2", new_desktop_session=True, non_graphical=non_graphical)
3127
hfss["w1"] = "1mm"
3228
hfss["w2"] = "100mm"
3329

34-
###############################################################################
35-
# Create waveguide with sheets on it
36-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30+
# ## Create waveguide with sheets on it
31+
#
3732
# Create one of the standard waveguide structures and parametrize it.
3833
# You can also create rectangles of waveguide openings and assign ports later.
3934

@@ -51,17 +46,13 @@
5146
model.show_grid = False
5247
model.plot(os.path.join(hfss.working_directory, "Image.jpg"))
5348

54-
###############################################################################
55-
# Create wave ports on sheets
56-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5749
# Create two wave ports on the sheets.
5850

5951
hfss.wave_port(p1, integration_line=hfss.AxisDir.ZPos, name="1")
6052
hfss.wave_port(p2, integration_line=hfss.AxisDir.ZPos, name="2")
6153

62-
###############################################################################
63-
# Create setup and frequency sweep
64-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54+
# ## Create setup and frequency sweep
55+
#
6556
# Create a setup and a frequency sweep to use as the base for optimetrics
6657
# setups.
6758

@@ -70,30 +61,23 @@
7061
setupname=setup.name, unit="GHz", freqstart=1, freqstop=5, step_size=0.1, sweepname="Sweep1", save_fields=True
7162
)
7263

73-
###############################################################################
74-
# Optimetrics analysis
75-
# ----------------------
76-
# Create parametrics analysis
77-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
64+
# ## Optimetrics analysis
65+
#
66+
# ### Parametric Analysis
67+
#
7868
# Create a simple optimetrics parametrics analysis with output calculations.
7969

8070
sweep = hfss.parametrics.add("w2", 90, 200, 5)
8171
sweep.add_variation("w1", 0.1, 2, 10)
8272
sweep.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"})
8373
sweep.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})
8474

85-
###############################################################################
86-
# Create sensitivity analysis
87-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
8875
# Create an optimetrics sensitivity analysis with output calculations.
8976

9077
sweep2 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="Sensitivity")
9178
sweep2.add_variation("w1", 0.1, 3, 0.5)
9279
sweep2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})
9380

94-
###############################################################################
95-
# Create optimization based on goals and calculations
96-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9781
# Create an optimization analysis based on goals and calculations.
9882

9983
sweep3 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"})
@@ -106,24 +90,19 @@
10690
condition="Maximize",
10791
)
10892

109-
###############################################################################
110-
# Create DX optimization based on a goal and calculation
111-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11293
# Create a DX (DesignXplorer) optimization based on a goal and a calculation.
11394

11495
sweep4 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DesignExplorer")
11596
sweep4.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})
11697

117-
###############################################################################
118-
# Create DOE based on a goal and calculation
119-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98+
# ## Create DOE based on a goal and calculation
99+
#
120100
# Create a DOE (Design of Experiments) based on a goal and a calculation.
121101

122102
sweep5 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DXDOE")
123103

124-
###############################################################################
125-
# Create DOE based on a goal and calculation
126-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104+
# ## Create DOE based on a goal and calculation
105+
#
127106
# Create a DOE based on a goal and a calculation.
128107

129108
region = hfss.modeler.create_region()
@@ -136,9 +115,8 @@
136115
context="Infinite_1",
137116
)
138117

139-
###############################################################################
140-
# Close AEDT
141-
# ----------
118+
# ## Close AEDT
119+
#
142120
# After the simulaton completes, you can close AEDT or release it using the
143121
# :func:`pyaedt.Desktop.release_desktop` method.
144122
# All methods provide for saving the project before closing.

0 commit comments

Comments
 (0)