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 #5608

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
97 changes: 64 additions & 33 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,85 @@
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.
"""

# See Also
# --------
# :doc:`filtersolutions`

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)


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)
ramin4667 marked this conversation as resolved.
Show resolved Hide resolved
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._init_distributed_design()

def _init_distributed_design(self):
"""Initialize the ``FilterSolutions`` object to support a distributed filter design."""
self.topology = DistributedTopology()
4 changes: 2 additions & 2 deletions src/ansys/aedt/core/filtersolutions_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +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"The requested version {version} does not match with the previously defined version {_this._internal_dll_interface._version}."
f"{_this._internal_dll_interface.version}."
)

Expand Down
42 changes: 2 additions & 40 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 @@ -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