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

FIX: Get variables with "sweep" enabled #5230

Merged
merged 14 commits into from
Oct 4, 2024
11 changes: 7 additions & 4 deletions _unittest/test_09_VariableManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,15 @@ def test_03_test_evaluated_value(self):
eval_p3_nom = v._app.get_evaluated_value("p3")
assert isclose(eval_p3_nom, 0.0002)
v_app = self.aedtapp.variable_manager
assert v_app["p1"].read_only == False
assert v_app["p1"].sweep
v_app["p1"].sweep = False
assert not v_app["p1"].sweep
assert not v_app["p1"].read_only
v_app["p1"].read_only = True
assert v_app["p1"].read_only == True
assert v_app["p1"].hidden == False
assert v_app["p1"].read_only
assert not v_app["p1"].hidden
v_app["p1"].hidden = True
assert v_app["p1"].hidden == True
assert v_app["p1"].hidden
assert v_app["p2"].description == ""
v_app["p2"].description = "myvar"
assert v_app["p2"].description == "myvar"
Expand Down
10 changes: 5 additions & 5 deletions src/ansys/aedt/core/application/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,12 +1183,12 @@ def nominal(self):

@property
def nominal_w_values(self):
"""Nominal with values.
"""Nominal independent with values in a list.

Returns
-------
dict
Dictionary of nominal variations with expressions.
list
List of nominal independent variations with expressions.

References
----------
Expand Down Expand Up @@ -1229,12 +1229,12 @@ def nominal_w_values_dict(self):

@property
def nominal_w_values_dict_w_dependent(self):
"""Nominal with values in a dictionary.
"""Nominal independent and dependent with values in a dictionary.

Returns
-------
dict
Dictionary of nominal variations with values.
Dictionary of nominal independent and dependent variations with values.

References
----------
Expand Down
28 changes: 28 additions & 0 deletions src/ansys/aedt/core/application/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@
read_only=False,
hidden=False,
description=None,
sweep=True,
overwrite=True,
is_post_processing=False,
circuit_parameter=True,
Expand All @@ -988,6 +989,11 @@
description : str, optional
Text to display for the design property or project variable in the
``Properties`` window. The default is ``None``.
sweep : bool, optional
Allows you to designate variables to include in solution indexing as a way to
permit faster post-processing.
Variables with the Sweep check box cleared are not used in solution indexing.
The default is ``True``.
overwrite : bool, optional
Whether to overwrite an existing value for the design
property or project variable. The default is ``False``, in
Expand Down Expand Up @@ -1128,6 +1134,8 @@
read_only,
"Hidden:=",
hidden,
"Sweep:=",
sweep,
],
],
],
Expand Down Expand Up @@ -1178,6 +1186,8 @@
read_only,
"Hidden:=",
hidden,
"Sweep:=",
sweep,
],
],
],
Expand Down Expand Up @@ -1441,6 +1451,7 @@
app=None,
readonly=False,
hidden=False,
sweep=True,
description=None,
postprocessing=False,
circuit_parameter=True,
Expand All @@ -1451,6 +1462,7 @@
self._app = app
self._readonly = readonly
self._hidden = hidden
self._sweep = sweep
self._postprocessing = postprocessing
self._circuit_parameter = circuit_parameter
self._description = description
Expand Down Expand Up @@ -1503,6 +1515,7 @@
self._expression,
read_only=self._readonly,
hidden=self._hidden,
sweep=self._sweep,
description=self._description,
is_post_processing=self._postprocessing,
circuit_parameter=self._circuit_parameter,
Expand Down Expand Up @@ -1715,6 +1728,21 @@
if self._app:
self._app.logger.error('Failed to update property "hidden".')

@property
def sweep(self):
"""Sweep flag value."""
self._sweep = self._get_prop_val("Sweep")
return self._sweep

@sweep.setter
def sweep(self, value):
fallback_val = self._sweep
self._sweep = value
if not self._update_var():
self._sweep = fallback_val
if self._app:
self._app.logger.error('Failed to update property "sweep".')

Check warning on line 1744 in src/ansys/aedt/core/application/variables.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/variables.py#L1742-L1744

Added lines #L1742 - L1744 were not covered by tests

@property
def description(self):
"""Description value."""
Expand Down
15 changes: 9 additions & 6 deletions src/ansys/aedt/core/visualization/post/post_common_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,9 @@ def get_scalar_field_value(

variation = []
for el, value in variations.items():
variation.append(el + ":=")
variation.append(value)
if self._app.variable_manager.variables[el].sweep:
variation.append(el + ":=")
variation.append(value)

variation.extend(intrinsics)

Expand Down Expand Up @@ -674,8 +675,9 @@ def export_field_file_on_grid(

variation = []
for el, value in variations.items():
variation.append(el + ":=")
variation.append(value)
if self._app.variable_manager.variables[el].sweep:
variation.append(el + ":=")
variation.append(value)
variation.extend(intrinsics)

export_options = [
Expand Down Expand Up @@ -842,8 +844,9 @@ def export_field_file(

variation = []
for el, value in variations.items():
variation.append(el + ":=")
variation.append(value)
if self._app.variable_manager.variables[el].sweep:
variation.append(el + ":=")
variation.append(value)
variation.extend(intrinsics)

if not sample_points_file and not sample_points:
Expand Down
Loading