-
Notifications
You must be signed in to change notification settings - Fork 163
Added Spiral Inductor Example #640
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4529c66
Added Spiral Example
maxcapodi78 79526f7
Added Spiral Example
maxcapodi78 125c16f
Update examples/02-HFSS/HFSS_Spiral.py
MaxJPRey 6d59142
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 9afbe8e
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 82dc246
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 7ef3228
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 2de919f
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 082f43f
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 6f5b26f
Update pyaedt/modeler/Primitives3D.py
MaxJPRey 70aaaf7
Apply suggestions from code review
maxcapodi78 aa8247d
Apply suggestions from code review
maxcapodi78 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
""" | ||
Spiral Inductor Example | ||
----------------------- | ||
This example shows how you can use PyAEDT to create a spiral inductor, solve it and plot results. | ||
""" | ||
# sphinx_gallery_thumbnail_path = 'Resources/spiral.png' | ||
|
||
############################################################# | ||
# Import packages | ||
# | ||
|
||
import os | ||
import matplotlib.pyplot as plt | ||
from pyaedt import Hfss, constants | ||
|
||
|
||
############################################################# | ||
# Launch Hfss 2021.2 in non graphical mode. | ||
# Change units to micron | ||
hfss = Hfss(specified_version="2021.2", non_graphical=False, designname='A1') | ||
hfss.modeler.model_units = "um" | ||
p = hfss.modeler.primitives | ||
|
||
############################################################# | ||
# Input Variables. Edit it to change your inductor. | ||
# | ||
rin = 10 | ||
width = 2 | ||
spacing = 1 | ||
thickness = 1 | ||
Np = 8 | ||
Nr = 10 | ||
gap = 3 | ||
Tsub = 6 | ||
|
||
|
||
############################################################# | ||
# This method standardizes the usage of polyline in this | ||
# example by fixing the width, thickness and material. | ||
# | ||
def create_line(pts): | ||
p.create_polyline(pts, | ||
xsection_type='Rectangle', | ||
xsection_width=width, | ||
xsection_height=thickness, matname='copper') | ||
|
||
|
||
################################################################ | ||
# Here a spiral inductor is created. | ||
# Spiral is not parameteric but could be parametrized later on. | ||
# | ||
|
||
ind = hfss.modeler.create_spiral(internal_radius=rin, width=width, spacing=spacing, turns=Nr, faces=Np, | ||
thickness=thickness, material="copper", name="Inductor1") | ||
|
||
|
||
################################################################ | ||
# Center Return Path. | ||
# | ||
|
||
x0, y0, z0 = ind.points[0] | ||
x1, y1, z1 = ind.points[-1] | ||
create_line([(x0 - width / 2, y0, -gap), (abs(x1) + 5, y0, -gap)]) | ||
p.create_box((x0 - width / 2, y0 - width / 2, -gap - thickness / 2), | ||
(width, width, gap + thickness), | ||
matname='copper') | ||
|
||
################################################################ | ||
# Port 1 creation. | ||
# | ||
p.create_rectangle(constants.PLANE.YZ, | ||
(abs(x1) + 5, y0 - width / 2, -gap - thickness / 2), | ||
(width, -Tsub + gap), | ||
name='port1') | ||
hfss.create_lumped_port_to_sheet(sheet_name='port1', axisdir=constants.AXIS.Z) | ||
|
||
|
||
################################################################ | ||
# Port 2 creation. | ||
# | ||
create_line([(x1 + width / 2, y1, 0), (x1 - 5, y1, 0)]) | ||
p.create_rectangle(constants.PLANE.YZ, | ||
(x1 - 5, y1 - width / 2, -thickness / 2), | ||
(width, -Tsub), | ||
name='port2') | ||
hfss.create_lumped_port_to_sheet(sheet_name='port2', axisdir=constants.AXIS.Z) | ||
|
||
|
||
################################################################ | ||
# Silicon Substrate and Ground plane. | ||
# | ||
p.create_box([x1 - 20, x1 - 20, -Tsub - thickness / 2], | ||
[-2 * x1 + 40, -2 * x1 + 40, Tsub], | ||
matname='silicon') | ||
|
||
p.create_box([x1 - 20, x1 - 20, -Tsub - thickness / 2], | ||
[-2 * x1 + 40, -2 * x1 + 40, -0.1], | ||
matname='PEC') | ||
|
||
################################################################ | ||
# Airbox and radiation assignment. | ||
# | ||
|
||
box = p.create_box([x1 - 20, x1 - 20, -Tsub - thickness / 2 - 0.1], | ||
[-2 * x1 + 40, -2 * x1 + 40, 100], | ||
name='airbox', | ||
matname='air') | ||
|
||
hfss.assign_radiation_boundary_to_objects('airbox') | ||
|
||
################################################################ | ||
# Material override is needed to avoid validation check to fail. | ||
# | ||
hfss.change_material_override() | ||
|
||
################################################################ | ||
# Create a setup and define a frequency sweep. | ||
# Project will be solved after that. | ||
|
||
setup1 = hfss.create_setup(setupname='setup1') | ||
setup1.props['Frequency'] = '10GHz' | ||
hfss.create_linear_count_sweep('setup1', 'GHz', 1e-3, 50, 451, sweep_type="Interpolating") | ||
setup1.update() | ||
hfss.save_project() | ||
hfss.analyze_all() | ||
|
||
################################################################ | ||
# Get Report Data and plot it on matplotlib. | ||
# Inductance. | ||
L_formula = '1e9*im(1/Y(1,1))/(2*pi*freq)' | ||
x = hfss.post.get_report_data(L_formula) | ||
|
||
plt.plot(x.sweeps["Freq"], x.data_real(L_formula)) | ||
|
||
plt.grid() | ||
plt.xlabel('Freq') | ||
plt.ylabel('L(nH)') | ||
plt.show() | ||
|
||
plt.clf() | ||
|
||
|
||
################################################################ | ||
# Get Report Data and plot it on matplotlib. | ||
# Quality Factor. | ||
|
||
L_formula = 'im(Y(1,1))/re(Y(1,1))' | ||
x = hfss.post.get_report_data(L_formula) | ||
hfss.save_project() | ||
|
||
plt.plot(x.sweeps["Freq"], x.data_real(L_formula)) | ||
maxcapodi78 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
plt.grid() | ||
plt.xlabel('Freq') | ||
plt.ylabel('Q') | ||
plt.show() | ||
|
||
################################################################ | ||
# Get Report Data and plot it on matplotlib. | ||
# Save and close the project. | ||
|
||
hfss.save_project() | ||
if os.name != "posix": | ||
hfss.release_desktop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.