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: Add distributed filters topology #5687

Merged
merged 37 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2f37b0d
FEAT: Add distributed filters
ramin4667 Dec 23, 2024
09ef5c9
Merge branch 'main' into FEAT__Add_distributed_filters
ramin4667 Dec 23, 2024
da0174d
FAET: Filter implementation is removed
ramin4667 Dec 28, 2024
73ebce0
Merge remote-tracking branch 'origin/main' into FEAT__Add_distributed…
ramin4667 Dec 28, 2024
5275ce8
Merge branch 'FEAT__Add_distributed_filters' of https://github.com/an…
ramin4667 Dec 28, 2024
1e188e2
Merge branch 'main' into FEAT__Add_distributed_filters
ramin4667 Jan 2, 2025
c3676da
CHORE: Auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
619e77b
Comments are applied.
ramin4667 Jan 6, 2025
25dce17
FEAT: Add distributed filter netlist update
ramin4667 Jan 6, 2025
dc3d474
Merge branch 'main' into FEAT__Add_distributed_filters
ramin4667 Jan 6, 2025
c716cee
FEAT: Error Messages are updated
ramin4667 Jan 8, 2025
7457843
Merge branch 'FEAT__Add_distributed_filters' of https://github.com/an…
ramin4667 Jan 8, 2025
24260aa
Version check and some other updates
ramin4667 Jan 14, 2025
59f6bfd
Test resource files update.
ramin4667 Jan 14, 2025
f35f87d
Sphinx document updated, typos are fixed.
ramin4667 Jan 22, 2025
25292f4
Merge branch 'main' into FEAT__Add_distributed_filters_topology
ramin4667 Jan 22, 2025
36a4113
Typo fix.
ramin4667 Jan 22, 2025
bb69587
Merge branch 'FEAT__Add_distributed_filters_topology' of https://gith…
ramin4667 Jan 22, 2025
ba072e1
Sphinx and docstring update
ramin4667 Jan 23, 2025
4b204a0
Test coverage is improved, some tests are updated.
ramin4667 Jan 27, 2025
6654131
Merge branch 'main' into FEAT__Add_distributed_filters_topology
ramin4667 Jan 27, 2025
158cf53
Sphinx document file updated as comments.
ramin4667 Jan 28, 2025
630e270
Merge branch 'FEAT__Add_distributed_filters_topology' of https://gith…
ramin4667 Jan 28, 2025
825a0d8
Test cases are improved.
ramin4667 Jan 28, 2025
28863ec
Some test improvements.
ramin4667 Jan 30, 2025
f6b6d65
Merge branch 'main' into FEAT__Add_distributed_filters_topology
ramin4667 Jan 30, 2025
5de3293
Test coverage is improved.
ramin4667 Jan 30, 2025
dbd1944
Merge branch 'FEAT__Add_distributed_filters_topology' of https://gith…
ramin4667 Jan 30, 2025
9a98dcb
Codacy error fix.
ramin4667 Jan 31, 2025
7e7cb38
Merge branch 'main' into FEAT__Add_distributed_filters_topology
ramin4667 Jan 31, 2025
50ca3bd
Codacy error improvement
ramin4667 Jan 31, 2025
16795f8
Merge branch 'FEAT__Add_distributed_filters_topology' of https://gith…
ramin4667 Jan 31, 2025
fb2e4b0
Merge branch 'main' into FEAT__Add_distributed_filters_topology
ramin4667 Jan 31, 2025
d52c6a1
Codacy error test.
ramin4667 Feb 3, 2025
77ef040
Merge branch 'FEAT__Add_distributed_filters_topology' of https://gith…
ramin4667 Feb 3, 2025
390e0d7
Codacy error improved with defined parameters.
ramin4667 Feb 3, 2025
8f34ac0
Merge branch 'main' into FEAT__Add_distributed_filters_topology
ramin4667 Feb 3, 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
1 change: 0 additions & 1 deletion doc/source/API/Application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Available PyAEDT apps are:
ansys.aedt.core.maxwellcircuit.MaxwellCircuit
ansys.aedt.core.emit.Emit
ansys.aedt.core.twinbuilder.TwinBuilder
ansys.aedt.core.filtersolutions.FilterSolutions

All other classes and methods are inherited into the app class.
AEDT, which is also referred to as the desktop app, is implicitly launched in any PyAEDT app.
Expand Down
119 changes: 100 additions & 19 deletions doc/source/API/FilterSolutions.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,105 @@
Filter design
==========================
The ``FilterSolutions`` module contains all classes needed to create and edit an object including.


* ``Attributes`` to defines attributes and parameters of filters.
* ``DllInterface`` to interface with the FilterSolutions DLL.
* ``GraphSetup`` to define the frequency and time limits of the exported responses.
* ``IdealResponse`` to return the data for available ideal filter responses.
* ``MultipleBandsTable`` to manipulate access to the entries of multiple bands table.
* ``TransmissionZeros`` to manipulates access to ratio and bandwidth entries in the transmission zeros table.
* ``LumpedTopology`` to define attributes and parameters of filters implemented with lumped topology.
* ``LumpedParasitics`` to define attributes of the lumped element parasitic values.
====================
This section describes the classes used for creating and modifying parameters in the ``filtersolutions`` module.
The module provides tools for designing and customizing filter configurations.

The module includes two classes, ``LumpedDesign`` and ``DistributedDesign``, both inherited from the ``FilterDesignBase`` class as described in the :ref:`BaseFilterDesign` section.

Each class implements methods specific to its design approach while leveraging common functionality from the base class.


Lumped design
~~~~~~~~~~~~~~~~~~~
The ``LumpedDesign`` module includes all the necessary classes for creating and modifying parameters used in lumped filter designs.
Lumped filters use discrete components such as capacitors, inductors, and resistors.

* ``LumpedTopology`` to define attributes and parameters of filters implemented using a lumped topology.
* ``LumpedParasitics`` to define attributes of parasitic values associated with lumped elements.
* ``LumpedNodesandLeads`` to define attributes of the lumped node capacitors and lead inductors.
* ``LumpedTerminationImpedance`` to manipulate access to the entries of source and load complex impedance table.
* ``ExportToAedt`` to define attributes and parameters of the export page for exporting to AEDT.
* ``OptimizationGoalsTable`` to manipulate access to the entries of the optimization goals table.
* ``LumpedTerminationImpedance`` to manage access to the entries in the source and load complex impedance table.

They are accessible through:


.. currentmodule:: ansys.aedt.core.filtersolutions_core

.. autosummary::
:toctree: _autosummary
:nosignatures:


lumped_topology.LumpedTopology
lumped_parasitics.LumpedParasitics
lumped_nodes_and_leads.LumpedNodesandLeads
lumped_termination_impedance_table.LumpedTerminationImpedance

``Lumped Filter`` example:

.. code:: python

import ansys.aedt.core
import ansys.aedt.core.filtersolutions
# This call returns an instance of the LumpedDesign class
design = ansys.aedt.core.FilterSolutions.LumpedDesign(version= "2025.1")
# This property in the Attributes class specifies the filter class as band pass
design.attributes.filter_class = FilterClass.BAND_PASS
# This property in the Attributes class specifies the filter type as Elliptic
design.attributes.filter_type = FilterType.ELLIPTIC
# This property in the LumpedTopology class enables the trap topology by setting it to true
design.topology.trap_topology = True
...



Distributed design
~~~~~~~~~~~~~~~~~~~
The ``DistributedDesign`` module includes all the necessary classes for creating and modifying parameters used in distributed filter designs.
Distributed filters rely on transmission lines and resonators.

* ``DistributedTopology`` to define attributes and parameters of filters implemented using a distributed topology.

They are accessible through:


.. currentmodule:: ansys.aedt.core.filtersolutions_core

.. autosummary::
:toctree: _autosummary
:nosignatures:


distributed_topology.DistributedTopology

``Distributed Filter`` example:

.. code:: python

import ansys.aedt.core
import ansys.aedt.core.filtersolutions
# This call returns an instance of the DistributedDesign class
design = ansys.aedt.core.FilterSolutions.DistributedDesign(version= "2025.2")
# This property in the Attributes class specifies the filter class as band pass
design.attributes.filter_class = FilterClass.BAND_PASS
# This property in the Attributes class specifies the filter type as Elliptic
design.attributes.filter_type = FilterType.ELLIPTIC
# This property in the DistributedTopology class sets the load resistance to 50 ohms.
design.topology.load_resistance = "50"
...

.. _BaseFilterDesign:

Base filter design
~~~~~~~~~~~~~~~~~~~
The ``FilterDesignBase`` module provides all the essential classes for creating and modifying the primary parameters applicable to all design types.

* ``Attributes`` to define attributes and parameters of filters.
* ``DllInterface`` to establish an interface with the FilterSolutions DLL.
* ``GraphSetup`` to define the frequency and time graph parameters of the exported responses.
* ``IdealResponse`` to return the data for the available ideal filter responses.
* ``MultipleBandsTable`` to manage access to the entries in the multiple bands table.
* ``TransmissionZeros`` to manage access to ratio and bandwidth entries in the transmission zeros table.
* ``ExportToAedt`` to define attributes and parameters for the export page when exporting to AEDT.
* ``OptimizationGoalsTable`` to manage access to the entries in the optimization goals table.

They are accessible through:

Expand All @@ -27,15 +110,13 @@ They are accessible through:
:toctree: _autosummary
:nosignatures:


attributes.Attributes
dll_interface.DllInterface
graph_setup.GraphSetup
ideal_response.IdealResponse
multiple_bands_table.MultipleBandsTable
transmission_zeros.TransmissionZeros
lumped_topology.LumpedTopology
lumped_parasitics.LumpedParasitics
lumped_nodes_and_leads.LumpedNodesandLeads
lumped_termination_impedance_table.LumpedTerminationImpedance
export_to_aedt.ExportToAedt
optimization_goals_table.OptimizationGoalsTable

110 changes: 76 additions & 34 deletions src/ansys/aedt/core/filtersolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import ansys.aedt.core
import ansys.aedt.core.filtersolutions_core
from ansys.aedt.core.filtersolutions_core.attributes import Attributes
from ansys.aedt.core.filtersolutions_core.attributes import FilterImplementation
from ansys.aedt.core.filtersolutions_core.distributed_topology import DistributedTopology
from ansys.aedt.core.filtersolutions_core.export_to_aedt import ExportToAedt
from ansys.aedt.core.filtersolutions_core.graph_setup import GraphSetup
from ansys.aedt.core.filtersolutions_core.ideal_response import IdealResponse
Expand All @@ -39,54 +39,96 @@
from ansys.aedt.core.filtersolutions_core.transmission_zeros import TransmissionZeros


class FilterSolutions:
"""Provides the :doc:`FilterSolutions` application interface.

class FilterDesignBase:
"""Provides the `FilterSolutions` main parameters applicable for all design types.
This class has access to ideal filter attributes and calculated output parameters.
"""

def __init__(self, version=None):
self.version = version
ansys.aedt.core.filtersolutions_core._dll_interface(version)
self.attributes = Attributes()
self.ideal_response = IdealResponse()
self.graph_setup = GraphSetup()
self.transmission_zeros_ratio = TransmissionZeros(TableFormat.RATIO)
self.transmission_zeros_bandwidth = TransmissionZeros(TableFormat.BANDWIDTH)
self.export_to_aedt = ExportToAedt()


class LumpedDesign(FilterDesignBase):
"""Provides the `FilterSolutions` application interface for lumped filter designs.
This class provides access to lumped filter design parameters.

Parameters
----------
version : str, optional
Version of AEDT in ``xxxx.x`` format. The default is ``None``.
implementation_type : FilterImplementation, optional
Technology used to implement the filter. The default is ``LUMPED``.
The ``FilterImplementation`` enum provides the list of implementations.

Examples
Example
--------
Create a ``FilterSolutions`` instance with a band-pass elliptic ideal filter.
Create a ``FilterSolutions.LumpedDesign`` instance with a band-pass elliptic filter.

>>> import ansys.aedt.core
>>> from ansys.aedt.core.filtersolutions_core.attributes import FilterImplementation

>>> design = ansys.aedt.core.FilterSolutions(version="2025 R1", projectname= "fs1",
>>> implementation_type= FilterImplementation.LUMPED,
>>> )
>>> import ansys.aedt.core.filtersolutions
>>> LumpedDesign = ansys.aedt.core.FilterSolutions.LumpedDesign(version= "2025.1")
>>> LumpedDesign.attributes.filter_class = FilterClass.BAND_PASS
>>> LumpedDesign.attributes.filter_type = FilterType.ELLIPTIC
"""

def __init__(self, version=None, implementation_type=None):
self.version = version
self.implementation_type = implementation_type
ansys.aedt.core.filtersolutions_core._dll_interface(version)

if implementation_type == FilterImplementation.LUMPED or implementation_type is None:
self._init_lumped_design()
else:
raise RuntimeError("The " + str(implementation_type) + " is not supported in this release.")
def __init__(self, version=None):
super().__init__(version)
self._init_lumped_design()

def _init_lumped_design(self):
"""Initialize the ``FilterSolutions`` object to support a lumped filter design."""

self.attributes = Attributes()
self.ideal_response = IdealResponse()
self.graph_setup = GraphSetup()
self.topology = LumpedTopology()
self.parasitics = LumpedParasitics()
self.leads_and_nodes = LumpedNodesandLeads()
self.source_impedance_table = LumpedTerminationImpedance(TerminationType.SOURCE)
self.load_impedance_table = LumpedTerminationImpedance(TerminationType.LOAD)
self.multiple_bands_table = MultipleBandsTable()
self.transmission_zeros_ratio = TransmissionZeros(TableFormat.RATIO)
self.transmission_zeros_bandwidth = TransmissionZeros(TableFormat.BANDWIDTH)
self.export_to_aedt = ExportToAedt()
self.optimization_goals_table = OptimizationGoalsTable()
self.topology = LumpedTopology()
self.parasitics = LumpedParasitics()
self.leads_and_nodes = LumpedNodesandLeads()


class DistributedDesign(FilterDesignBase):
"""Provides the `FilterSolutions` application interface for distributed filter designs.
This class provides access to distributed filter design parameters.

Parameters
----------
version : str, optional
Version of AEDT in ``xxxx.x`` format. The default is ``None``.

Example
--------
Create a ``FilterSolutions.DistributedDesign`` instance with a band-pass interdigital filter.

>>> import ansys.aedt.core
>>> import ansys.aedt.core.filtersolutions
>>> DistributedDesign = ansys.aedt.core.FilterSolutions.DistributedDesign(version= "2025.2")
>>> DistributedDesign.attributes.filter_class = FilterClass.BAND_PASS
>>> DistributedDesign.topology.topology_type = TopologyType.INTERDIGITAL
"""

def __init__(self, version=None):
super().__init__(version)
self._dll = ansys.aedt.core.filtersolutions_core._dll_interface()._dll
self._dll_interface = ansys.aedt.core.filtersolutions_core._dll_interface()
self._check_version()
self._init_distributed_design()
self._set_distributed_implementation()

def _init_distributed_design(self):
"""Initialize the ``FilterSolutions`` object to support a distributed filter design."""
self.topology = DistributedTopology()

def _set_distributed_implementation(self):
"""Set ``FilterSolutions`` implementation to ``Distributed Design``."""
filter_implementation_status = self._dll.setFilterImplementation(1)
self._dll_interface.raise_error(filter_implementation_status)
first_shunt_status = self._dll.setDistributedFirstElementShunt(True)
self._dll_interface.raise_error(first_shunt_status)

def _check_version(self):
if self._dll_interface._version < "2025.2":
raise ValueError("FilterSolutions API supports distributed designs in version 2025 R2 and later.")
5 changes: 2 additions & 3 deletions src/ansys/aedt/core/filtersolutions_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
def _dll_interface(version=None) -> DllInterface:
if _this._internal_dll_interface is None:
_this._internal_dll_interface = DllInterface(show_gui=False, version=version)
elif version is not None and version != _this._internal_dll_interface.version:
elif version is not None and version != _this._internal_dll_interface._version:
raise Exception(
f"The requested version {version} does not match with the previously defined version {_this._internal_dll_interface.version}."
f"{_this._internal_dll_interface.version}."
f"The requested version {version} does not match with the previously defined version {_this._internal_dll_interface._version}."
)

return _this._internal_dll_interface
Expand Down
58 changes: 10 additions & 48 deletions src/ansys/aedt/core/filtersolutions_core/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,6 @@ class FilterClass(Enum):
STOP_STOP = 9


class FilterImplementation(Enum):
"""Provides an enum of filter implementation types.

**Attributes:**

- LUMPED: Represents a lumped implementation.
- DISTRIB: Represents a distributed implementation.
- ACTIVE: Represents an active implementation.
- SWCAP: Represents a switched capacitor implementation.
- DIGITAL: Represents a digital implementation.
"""

LUMPED = 0
DISTRIB = 1
ACTIVE = 2
SWCAP = 3
DIGITAL = 4


class DiplexerType(Enum):
"""Provides an enum of diplexer and triplexer types.

Expand Down Expand Up @@ -155,14 +136,14 @@ class RaisedCosineAlphaPercentage(Enum):
"""

FIFTEEN = 0
TWENTY = 1
TWENTY_FIVE = 2
THIRTY = 3
THIRTY_FIVE = 4
FORTY = 5
FORTY_FIVE = 6
FIFTY = 7
SEVENTY_FIVE = 8
FORTY = 1
TWENTY = 2
FORTY_FIVE = 3
TWENTY_FIVE = 4
FIFTY = 5
THIRTY = 6
SEVENTY_FIVE = 7
THIRTY_FIVE = 8
HUNDRED = 9


Expand Down Expand Up @@ -303,9 +284,9 @@ def _define_attributes_dll_functions(self):
self._dll.getFilterClass.argtypes = [c_char_p, c_int]
self._dll.getFilterClass.restype = int

self._dll.setFilterImplementation.argtype = c_char_p
self._dll.setFilterImplementation.argtype = c_int
self._dll.setFilterImplementation.restype = c_int
self._dll.getFilterImplementation.argtypes = [c_char_p, c_int]
self._dll.getFilterImplementation.argtype = POINTER(c_int)
self._dll.getFilterImplementation.restype = c_int

self._dll.setMultipleBandsEnabled.argtype = c_bool
Expand Down Expand Up @@ -652,25 +633,6 @@ def filter_class(self, filter_class: FilterClass):
string_value = self._dll_interface.enum_to_string(filter_class)
self._dll_interface.set_string(self._dll.setFilterClass, string_value)

@property
def filter_implementation(self) -> FilterImplementation:
"""Technology for implementing the filter. The default is ``LUMPED``.

The ``FilterImplementation`` enum provides a list of all implementations.

Returns
-------
:enum:`FilterImplementation`
"""
type_string = self._dll_interface.get_string(self._dll.getFilterImplementation)
return self._dll_interface.string_to_enum(FilterImplementation, type_string)

@filter_implementation.setter
def filter_implementation(self, filter_implementation: FilterImplementation):
if filter_implementation:
string_value = self._dll_interface.enum_to_string(filter_implementation)
self._dll_interface.set_string(self._dll.setFilterImplementation, string_value)

@property
def diplexer_type(self) -> DiplexerType:
"""Type of diplexer topology. This property is only applicable to lumped filters.
Expand Down
Loading
Loading