Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions doc/changelog.d/6742.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve Variable management in Circuit
6 changes: 5 additions & 1 deletion src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -4057,8 +4057,12 @@ def get_evaluated_value(self, name, units=None):
if self.design_type in ["Circuit Design", "Twin Builder", "HFSS 3D Layout Design"]:
if name in self.get_oo_name(app, f"Instance:{self._odesign.GetName()}"):
var_obj = self.get_oo_object(app, f"Instance:{self._odesign.GetName()}/{name}")
elif name in self.get_oo_name(app, "Variables"):
var_obj = self.get_oo_object(app, f"Variables/{name}")
elif name in self.get_oo_object(app, "DefinitionParameters").GetPropNames():
val = self.get_oo_object(app, "DefinitionParameters").GetPropEvaluatedValue(name)
val = self.get_oo_object(app, "DefinitionParameters").GetPropSIValue(name)
elif self.design_type in ["Maxwell Circuit"]:
return None
else:
var_obj = self.get_oo_object(app, f"Variables/{name}")
if var_obj:
Expand Down
893 changes: 441 additions & 452 deletions src/ansys/aedt/core/application/variables.py

Large diffs are not rendered by default.

100 changes: 53 additions & 47 deletions src/ansys/aedt/core/modules/boundary/q3d_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from typing import Optional
from typing import Union
import warnings

from ansys.aedt.core.base import PyAedtBase
from ansys.aedt.core.generic.constants import CATEGORIESQ3D
from ansys.aedt.core.generic.constants import MatrixOperationsQ3D
from ansys.aedt.core.generic.constants import PlotCategoriesQ3D
from ansys.aedt.core.generic.file_utils import generate_unique_name
from ansys.aedt.core.generic.general_methods import filter_tuple
Expand Down Expand Up @@ -65,17 +68,17 @@ def CATEGORIES(self):
return CATEGORIESQ3D

@pyaedt_function_handler()
def sources(self, is_gc_sources=True):
def sources(self, is_gc_sources: bool = True) -> list:
"""List of matrix sources.

Parameters
----------
is_gc_sources : bool,
In Q3d, define if to return GC sources or RL sources. Default `True`.
is_gc_sources : bool
In Q3d, define if to return GC sources or RL sources. The default is ``True``.

Returns
-------
List
list
"""
if self.name in list(self._app.omatrix.ListReduceMatrixes()):
if self._app.design_type == "Q3D Extractor":
Expand All @@ -87,12 +90,12 @@ def sources(self, is_gc_sources=True):
@pyaedt_function_handler()
def get_sources_for_plot(
self,
get_self_terms=True,
get_mutual_terms=True,
first_element_filter=None,
second_element_filter=None,
category="C",
):
get_self_terms: bool = True,
get_mutual_terms: bool = True,
first_element_filter: Optional[str] = None,
second_element_filter: Optional[str] = None,
category: Optional[Union[str, MatrixOperationsQ3D]] = "C",
) -> list:
"""Return a list of source of specified matrix ready to be used in plot reports.

Parameters
Expand All @@ -105,7 +108,7 @@ def get_sources_for_plot(
Filter to apply to first element of equation. It accepts `*` and `?` as special characters.
second_element_filter : str, optional
Filter to apply to second element of equation. It accepts `*` and `?` as special characters.
category : str
category : str or :class:`ansys.aedt.core.generic.constants.MatrixOperationsQ3D`, optional
Plot category name as in the report. Eg. "C" is category Capacitance.
Matrix `CATEGORIES` property can be used to map available categories.

Expand Down Expand Up @@ -144,12 +147,12 @@ def get_sources_for_plot(
return list_output

@property
def operations(self):
def operations(self) -> list:
"""List of matrix operations.

Returns
-------
List
list
"""
if self.name in list(self._app.omatrix.ListReduceMatrixes()):
self._operations = self._app.omatrix.ListReduceMatrixOperations(self.name)
Expand All @@ -158,17 +161,17 @@ def operations(self):
@pyaedt_function_handler()
def create(
self,
source_names=None,
new_net_name=None,
new_source_name=None,
new_sink_name=None,
):
source_names: Optional[Union[str, list]] = None,
new_net_name: Optional[str] = None,
new_source_name: Optional[str] = None,
new_sink_name: Optional[str] = None,
) -> bool:
"""Create a new matrix.

Parameters
----------
source_names : str, list
List or str containing the content of the matrix reduction (eg. source name).
source_names : str or list
List or str containing the content of the matrix reduction.
new_net_name : str, optional
Name of the new net. The default is ``None``.
new_source_name : str, optional
Expand All @@ -189,7 +192,7 @@ def create(
return True

@pyaedt_function_handler()
def delete(self):
def delete(self) -> bool:
"""Delete current matrix.

Returns
Expand All @@ -206,19 +209,19 @@ def delete(self):
@pyaedt_function_handler()
def add_operation(
self,
operation_type,
source_names=None,
new_net_name=None,
new_source_name=None,
new_sink_name=None,
):
operation_type: Union[str, MatrixOperationsQ3D],
source_names: Optional[Union[str, list]] = None,
new_net_name: Optional[str] = None,
new_source_name: Optional[str] = None,
new_sink_name: Optional[str] = None,
) -> bool:
"""Add a new operation to existing matrix.

Parameters
----------
operation_type : str
operation_type : str or :class:`ansys.aedt.core.generic.constants.MatrixOperationsQ3D`
Operation to perform
source_names : str, list
source_names : str or list, optional
List or str containing the content of the matrix reduction (eg. source name).
new_net_name : str, optional
Name of the new net. The default is ``None``.
Expand Down Expand Up @@ -251,33 +254,36 @@ def add_operation(

@pyaedt_function_handler()
def _write_command(self, source_names, new_name, new_source, new_sink):
if self._operations[-1] == "JoinSeries":
command = f"""{self._operations[-1]}('{new_name}', '{"', '".join(source_names)}')"""
elif self._operations[-1] == "JoinParallel":
command = (
f"""{self._operations[-1]}('{new_name}', '{new_source}', '{new_sink}', '{"', '".join(source_names)}')"""
)
elif self._operations[-1] == "JoinSelectedTerminals":
command = f"""{self._operations[-1]}('', '{"', '".join(source_names)}')"""
elif self._operations[-1] == "FloatInfinity":
operation_name = self._operations[-1]
operation_name = (
str(operation_name.value) if isinstance(operation_name, MatrixOperationsQ3D) else operation_name
)

if operation_name == "JoinSeries":
command = f"""{operation_name}('{new_name}', '{"', '".join(source_names)}')"""
elif operation_name == "JoinParallel":
command = f"""{operation_name}('{new_name}', '{new_source}', '{new_sink}', '{"', '".join(source_names)}')"""
elif operation_name == "JoinSelectedTerminals":
command = f"""{operation_name}('', '{"', '".join(source_names)}')"""
elif operation_name == "FloatInfinity":
command = "FloatInfinity()"
elif self._operations[-1] == "AddGround":
command = f"""{self._operations[-1]}(SelectionArray[{len(source_names)}: '{"', '".join(source_names)}'],
elif operation_name == "AddGround":
command = f"""{operation_name}(SelectionArray[{len(source_names)}: '{"', '".join(source_names)}'],
OverrideInfo())"""
elif (
self._operations[-1] == "SetReferenceGround"
or self._operations[-1] == "SetReferenceGround"
or self._operations[-1] == "Float"
operation_name == "SetReferenceGround"
or operation_name == "SetReferenceGround"
or operation_name == "Float"
):
command = f"""{self._operations[-1]}(SelectionArray[{len(source_names)}: '{"', '".join(source_names)}'],
command = f"""{operation_name}(SelectionArray[{len(source_names)}: '{"', '".join(source_names)}'],
OverrideInfo())"""
elif self._operations[-1] == "Parallel" or self._operations[-1] == "DiffPair":
elif operation_name == "Parallel" or operation_name == "DiffPair":
id_ = 0
for el in self._app.boundaries:
if el.name == source_names[0]:
id_ = self._app.modeler[el.props["Objects"][0]].id
command = f"""{self._operations[-1]}(SelectionArray[{len(source_names)}: '{"', '".join(source_names)}'],
command = f"""{operation_name}(SelectionArray[{len(source_names)}: '{"', '".join(source_names)}'],
OverrideInfo({id_}, '{new_name}'))"""
else:
command = f"""{self._operations[-1]}('{"', '".join(source_names)}')"""
command = f"""{operation_name}('{"', '".join(source_names)}')"""
return command
7 changes: 7 additions & 0 deletions tests/system/general/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,10 @@ def test_42_save_project_with_file_name(self, aedtapp, local_scratch):
def test_43_edit_notes(self, aedtapp):
assert aedtapp.edit_notes("this a test")
assert not aedtapp.edit_notes(1)

def test_value_with_units(self, aedtapp):
assert aedtapp.value_with_units("10mm") == "10mm"
assert aedtapp.value_with_units("10") == "10mm"
assert aedtapp.value_with_units("10", units_system="Angle") == "10deg"
assert aedtapp.value_with_units("10", units_system="invalid") == "10"
assert aedtapp.value_with_units("A + Bmm") == "A + Bmm"
Loading
Loading