Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ exclude: |
doc/source/conf.py
)


repos:

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [--line-length=200]

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
Expand All @@ -20,6 +22,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following guidelines help ensure that the examples are consistent, easy to r
be rendered and run in [Jupyter Lab](https://docs.jupyter.org/en/latest/) as Notebook files. Jupyter can be used to ensure correct
rendering of markdown, images, and equations.
```
pip install .[doc]
pip install -r requirements/requirements_doc.txt
jupyter lab
```
- You can use this [template](./examples/template.py) to help you start creating a new example
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def convert_examples_into_notebooks(app):
"template.py",
"gui_manipulation.py",
"electrothermal.py",
# TODO: Remove the following example when 2025.1 is released, currently the latest version is 24.1.
# GitHub CI/CD Pipeline fails to run lumped_element.py but it runs locally.
"lumped_element.py",
# TODO: Remove once EMIT examples are moved into extensions.
"interference_type.py",
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions examples/high_frequency/radiofrequency_mmwave/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ These examples use PyAEDT to show some radio frequency and millimeter wave appli
:align: center

This example shows how to use PyAEDT to use the FilterSolutions module to design and visualize the frequency
response of a band-pass Butterworth filter.

response of a band-pass Butterworth filter and export the lumped element model to AEDT Circuit.

.. grid-item-card:: Flex cable CPWG
:padding: 2 2 2 2
Expand Down
119 changes: 92 additions & 27 deletions examples/high_frequency/radiofrequency_mmwave/lumped_element.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# # Lumped element filter design
#
# This example shows how to use PyAEDT to use the ``FilterSolutions`` module to design and
# visualize the frequency response of a band-pass Butterworth filter.
# visualize the frequency response of a band-pass Butterworth filter and export the lumped element model to AEDT Circuit.
#
# Keywords: **filter solutions**

# ## Perform imports and define constants
#
# Perform required imports.

# +

import ansys.aedt.core
from ansys.aedt.core.filtersolutions_core.attributes import (
FilterClass, FilterImplementation, FilterType)
from ansys.aedt.core.filtersolutions_core.ideal_response import \
FrequencyResponseColumn
import ansys.aedt.core.filtersolutions
import matplotlib.pyplot as plt
# -
from ansys.aedt.core.filtersolutions_core.attributes import FilterClass, FilterType
from ansys.aedt.core.filtersolutions_core.export_to_aedt import ExportFormat
from ansys.aedt.core.filtersolutions_core.ideal_response import (
SParametersResponseColumn,
)

# Define constants.

Expand All @@ -30,7 +31,7 @@
def format_plot():
plt.xlabel("Frequency (Hz)")
plt.ylabel("Magnitude S21 (dB)")
plt.title("Ideal Frequency Response")
plt.title("Frequency Response")
plt.xscale("log")
plt.legend()
plt.grid()
Expand All @@ -40,44 +41,108 @@ def format_plot():
#
# Create a lumped element filter design and assign the class, type, frequency, and order.

design = ansys.aedt.core.FilterSolutions(
version=AEDT_VERSION, implementation_type=FilterImplementation.LUMPED
)
design.attributes.filter_class = FilterClass.BAND_PASS
design.attributes.filter_type = FilterType.BUTTERWORTH
design.attributes.pass_band_center_frequency = "1G"
design.attributes.pass_band_width_frequency = "500M"
design.attributes.filter_order = 5
lumped_design = ansys.aedt.core.filtersolutions.LumpedDesign(version=AEDT_VERSION)
lumped_design.attributes.filter_class = FilterClass.BAND_PASS
lumped_design.attributes.filter_type = FilterType.BUTTERWORTH
lumped_design.attributes.pass_band_center_frequency = "1G"
lumped_design.attributes.pass_band_width_frequency = "500M"
lumped_design.attributes.filter_order = 5

# ## Plot frequency response of filter
#
# Plot the frequency response of the filter without any transmission zeros.

freq, mag_db = design.ideal_response.frequency_response(
FrequencyResponseColumn.MAGNITUDE_DB
)
plt.plot(freq, mag_db, linewidth=2.0, label="Without Tx Zero")
freq, s21_db = lumped_design.ideal_response.s_parameters(SParametersResponseColumn.S21_DB)
plt.plot(freq, s21_db, linewidth=2.0, label="Without Tx Zero")
format_plot()
plt.show()

# <img src="_static/ideal_filter_response.png" width="400">


# ## Add a transmission zero to filter design
#
# Add a transmission zero that yields nulls separated by two times the pass band width (1 GHz).
# Plot the frequency response of the filter with the transmission zero.

design.transmission_zeros_ratio.append_row("2.0")
freq_with_zero, mag_db_with_zero = design.ideal_response.frequency_response(
FrequencyResponseColumn.MAGNITUDE_DB
)
plt.plot(freq, mag_db, linewidth=2.0, label="Without Tx Zero")
plt.plot(freq_with_zero, mag_db_with_zero, linewidth=2.0, label="With Tx Zero")
lumped_design.transmission_zeros_ratio.append_row("2.0")
freq_with_zero, s21_db_with_zero = lumped_design.ideal_response.s_parameters(SParametersResponseColumn.S21_DB)
plt.plot(freq, s21_db, linewidth=2.0, label="Without Tx Zero")
plt.plot(freq_with_zero, s21_db_with_zero, linewidth=2.0, label="With Tx Zero")
format_plot()
plt.show()

# <img src="_static/filter_response_added_zeros.png" width="400">

# ## Generate netlist for designed filter
#
# Generate and print the netlist for the designed filter with the added transmission zero to
# the filter.

netlist = design.topology.circuit_response()
netlist = lumped_design.topology.netlist()
print("Netlist: \n", netlist)

# ### Printed output:
# ```
# Netlist:
# *
# V1 1 0 AC 1 PULSE 0 1 0 1.592E-13 0
# R0 1 2 50
# *
# * Dummy Resistors Required For Spice
# * Have Been Added to Net List.
# *
# L1 2 0 6.674E-09
# C2 2 0 3.796E-12
# C3 2 3 1.105E-12
# L4 3 4 2.292E-08
# L5 4 5 8.53E-09
# C5 5 0 7.775E-12
# L6 4 6 3.258E-09
# C6 6 0 2.97E-12
# C7 4 7 1.105E-12
# Rq7 4 7 5E+10
# L8 7 8 2.292E-08
# L9 8 0 6.674E-09
# C10 8 0 3.796E-12
# R11 8 0 50
# *
# .AC DEC 200 2E+08 5E+09
# .PLOT AC VDB(8) -80 0
# .PLOT AC VP(8) -200 200
# .PLOT AC VG(8) 0 5E-09
# .TRAN 5E-11 1E-08 0
# .PLOT TRAN V(8) -0.09 0.1
# .END
# ```

# ## Export lumped element model of the filter to AEDT Circuit
#
# Export the designed filter with the added transmission zero to
# AEDT Circuit with the defined export parameters.

lumped_design.export_to_aedt.schematic_name = "LumpedElementFilter"
lumped_design.export_to_aedt.simulate_after_export_enabled = True
lumped_design.export_to_aedt.smith_plot_enabled = True
lumped_design.export_to_aedt.table_data_enabled = True
circuit = lumped_design.export_to_aedt.export_design(export_format=ExportFormat.DIRECT_TO_AEDT)

# <img src="_static/exported_filter_to_desktop.png" width="400">

# ## Plot the simulated circuit
#
# Get the scattering parameter data from the AEDT Circuit simulation and create a plot.

solutions = circuit.post.get_solution_data(
expressions=circuit.get_traces_for_plot(category="S"),
)
sim_freq = solutions.primary_sweep_values
sim_freq_ghz = [i * 1e9 for i in sim_freq]
sim_s21_db = solutions.data_db20(expression="S(Port2,Port1)")
plt.plot(freq, s21_db, linewidth=2.0, label="Without Tx Zero")
plt.plot(freq_with_zero, s21_db_with_zero, linewidth=2.0, label="With Tx Zero")
plt.plot(sim_freq_ghz, sim_s21_db, linewidth=2.0, linestyle="--", label="Simulated")
format_plot()
plt.show()

# <img src="_static/simulated_filter_response.png" width="400">
Loading