Skip to content

Commit

Permalink
Version check and some other updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin4667 committed Jan 14, 2025
1 parent c972594 commit f2d7a32
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 72 deletions.
15 changes: 15 additions & 0 deletions src/ansys/aedt/core/filtersolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,24 @@ class DistributedDesign(FilterDesignBase):

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()
self.substrate = DistributedSubstrate()

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.")
32 changes: 12 additions & 20 deletions src/ansys/aedt/core/filtersolutions_core/distributed_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@


class DistributedSubstrate:
"""Defines topology parameters of distributed filters.
"""Defines substrate parameters of distributed filters.
This class lets you construct all paramaeters for the ``DistributedDesign`` class.
This class lets you construct all parameters for the substrate page of the ``DistributedDesign`` class.
"""

def __init__(self):
self._dll = ansys.aedt.core.filtersolutions_core._dll_interface()._dll
self._dll_interface = ansys.aedt.core.filtersolutions_core._dll_interface()
self._define_substrate_dll_functions()
self._set_distributed_implementation()

def _define_substrate_dll_functions(self):
"""Define C++ API DLL functions."""
Expand Down Expand Up @@ -105,13 +104,6 @@ def _define_substrate_dll_functions(self):
self._dll.getDistributedGroundedCoverAboveLine.argtype = POINTER(c_bool)
self._dll.getDistributedGroundedCoverAboveLine.restype = c_int

def _set_distributed_implementation(self):
"""Set ``FilterSolutions`` attributes to distributed design."""
filter_implementation_status = self._dll.setFilterImplementation(1)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(filter_implementation_status)
first_shunt_status = self._dll.setDistributedFirstElementShunt(True)
self._dll_interface.raise_error(first_shunt_status)

@property
def substrate_type(self) -> SubstrateType:
"""Subctrate type of the filter.
Expand Down Expand Up @@ -146,7 +138,7 @@ def substrate_er(self) -> Union[SubstrateType, str]:
substrate_er_index = c_int()
substrate_er_value_str = create_string_buffer(100)
status = self._dll.getDistributedEr(substrate_er_value_str, byref(substrate_er_index), 100)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)
if substrate_er_index.value in [e.value for e in SubstrateEr]:
return SubstrateEr(substrate_er_index.value)
else:
Expand All @@ -165,7 +157,7 @@ def substrate_er(self, substrate_input):

substrate_er_value_bytes = bytes(substrate_er_value, "ascii")
status = self._dll.setDistributedEr(substrate_er_value_bytes, substrate_er_index)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)

@property
def substrate_resistivity(self) -> Union[SubstrateResistivity, str]:
Expand All @@ -183,7 +175,7 @@ def substrate_resistivity(self) -> Union[SubstrateResistivity, str]:
status = self._dll.getDistributedResistivity(
substrate_resistivity_value_str, byref(substrate_resistivity_index), 100
)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)
if substrate_resistivity_index.value in [e.value for e in SubstrateResistivity]:
return SubstrateResistivity(substrate_resistivity_index.value)
else:
Expand All @@ -201,7 +193,7 @@ def substrate_resistivity(self, substrate_input):
raise ValueError("Invalid substrate input. Must be a SubstrateResistivity enum member or a string.")
substrate_resistivity_value_bytes = bytes(substrate_resistivity_value, "ascii")
status = self._dll.setDistributedResistivity(substrate_resistivity_value_bytes, substrate_resistivity_index)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)

@property
def substrate_loss_tangent(self) -> Union[SubstrateEr, str]:
Expand All @@ -219,7 +211,7 @@ def substrate_loss_tangent(self) -> Union[SubstrateEr, str]:
status = self._dll.getDistributedLossTangent(
substrate_loss_tangent_value_str, byref(substrate_loss_tangent_index), 100
)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)
if substrate_loss_tangent_index.value in [e.value for e in SubstrateEr]:
return SubstrateEr(substrate_loss_tangent_index.value)
else:
Expand All @@ -237,7 +229,7 @@ def substrate_loss_tangent(self, substrate_input):
raise ValueError("Invalid substrate input. Must be a SubstrateEr enum member or a string.")
substrate_loss_tangent_value_bytes = bytes(substrate_loss_tangent_value, "ascii")
status = self._dll.setDistributedLossTangent(substrate_loss_tangent_value_bytes, substrate_loss_tangent_index)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)

@property
def substrate_conductor_thickness(self) -> str:
Expand Down Expand Up @@ -343,13 +335,13 @@ def substrate_unbalanced_stripline_enabled(self) -> bool:
"""
substrate_unbalanced_stripline_enabled = c_bool()
status = self._dll.getDistributedUnbalancedStripLine(byref(substrate_unbalanced_stripline_enabled))
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)
return bool(substrate_unbalanced_stripline_enabled.value)

@substrate_unbalanced_stripline_enabled.setter
def substrate_unbalanced_stripline_enabled(self, substrate_unbalanced_stripline_enabled: bool):
status = self._dll.setDistributedUnbalancedStripLine(substrate_unbalanced_stripline_enabled)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)

@property
def substrate_cover_height_enabled(self) -> bool:
Expand All @@ -361,10 +353,10 @@ def substrate_cover_height_enabled(self) -> bool:
"""
substrate_cover_height_enabled = c_bool()
status = self._dll.getDistributedGroundedCoverAboveLine(byref(substrate_cover_height_enabled))
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)
return bool(substrate_cover_height_enabled.value)

@substrate_cover_height_enabled.setter
def substrate_cover_height_enabled(self, substrate_cover_height_enabled: bool):
status = self._dll.setDistributedGroundedCoverAboveLine(substrate_cover_height_enabled)
ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status)
self._dll_interface.raise_error(status)
Loading

0 comments on commit f2d7a32

Please sign in to comment.