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

CHORE: Fix 2025R1 compatibility #5261

Merged
merged 24 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6ebadd3
Fix 3D Component import issue
Samuelopez-ansys Sep 16, 2024
655e8e8
Multizone is crashing in Graphical mode
Samuelopez-ansys Sep 16, 2024
9d92a0a
Add evaluated value exception
Samuelopez-ansys Sep 17, 2024
6a08429
Fix test
Samuelopez-ansys Sep 17, 2024
6f74141
Fix test 12
Samuelopez-ansys Sep 17, 2024
b398728
Revert 2025.1 limitation
Samuelopez-ansys Sep 20, 2024
3be4711
Update EvaluatedPropValue 2025.1
Samuelopez-ansys Sep 24, 2024
5250cbc
Fix EvaluatedValue
Samuelopez-ansys Sep 24, 2024
fdde34d
Merge branch 'main' into chore/fix_2025r1
Samuelopez-ansys Sep 26, 2024
7aacf01
Fix documentation
Samuelopez-ansys Sep 26, 2024
442a241
Merge branch 'main' into chore/fix_2025r1
Sep 26, 2024
6330fc5
Fixed few 25R1 Bugs
Sep 26, 2024
6003b46
Fixed Duplicate test
Sep 26, 2024
8cdd107
Merge remote-tracking branch 'origin/chore/fix_2025r1' into chore/fix…
Samuelopez-ansys Oct 1, 2024
251958e
Merge branch 'main' into chore/fix_2025r1
Samuelopez-ansys Oct 1, 2024
6be3adb
In 2025.1, field plot is not raising exception
Samuelopez-ansys Oct 1, 2024
907ac4d
fix pyvista plot
Samuelopez-ansys Oct 1, 2024
db568d9
Add fixed AEDT bugs
Samuelopez-ansys Oct 1, 2024
1ef8744
Fix Fields Calculator
Samuelopez-ansys Oct 2, 2024
5790424
Remove duplicated method
Samuelopez-ansys Oct 2, 2024
9efcf40
Merge branch 'main' into chore/fix_2025r1
Samuelopez-ansys Oct 8, 2024
5928322
Fix Twin Builder pin
Samuelopez-ansys Oct 8, 2024
175e56a
Fix GitHub comments
Samuelopez-ansys Oct 8, 2024
2b19f21
Fix 2024.2 compatibility
Samuelopez-ansys Oct 8, 2024
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
Binary file added _unittest/example_models/T12/EMI_RCV_251.aedtz
Binary file not shown.
Binary file not shown.
1,203 changes: 705 additions & 498 deletions _unittest/example_models/T40/SMA_RF_Jack.a3dcomp

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ def test_08_merge(self, add_app):
assert (comp.location[1] - 0.2) < tol

def test_10_change_stackup(self):
assert self.aedtapp.modeler.layers.change_stackup_type("Multizone", 4)
assert len(self.aedtapp.modeler.layers.zones) == 3
if config["NonGraphical"]:
assert self.aedtapp.modeler.layers.change_stackup_type("Multizone", 4)
assert len(self.aedtapp.modeler.layers.zones) == 3
assert self.aedtapp.modeler.layers.change_stackup_type("Overlap")
assert self.aedtapp.modeler.layers.change_stackup_type("Laminate")
assert not self.aedtapp.modeler.layers.change_stackup_type("lami")
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_12_variables(self):
assert "test" not in self.aedtapp.variable_manager.variables

def test_13_designs(self):
assert self.aedtapp._insert_design("HFSS", design_name="TestTransient") == "TestTransient"
assert self.aedtapp._insert_design(design_name="TestTransient", design_type="HFSS") == "TestTransient"
self.aedtapp.delete_design("TestTransient")
self.aedtapp.insert_design("NewDesign")

Expand Down
11 changes: 9 additions & 2 deletions _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@
m2d_file = "m2d_field_lines_test"

test_circuit_name = "Switching_Speed_FET_And_Diode"
test_emi_name = "EMI_RCV_241"
if config["desktopVersion"] > "2024.2":
test_emi_name = "EMI_RCV_251"
else:
test_emi_name = "EMI_RCV_241"

eye_diagram = "SimpleChannel"
ami = "ami"
ipk_post_proj = "for_icepak_post"
if config["desktopVersion"] > "2024.2":
ipk_post_proj = "for_icepak_post_parasolid"
else:
ipk_post_proj = "for_icepak_post"
test_subfolder = "T12"
settings.enable_pandas_output = True

Expand Down
27 changes: 18 additions & 9 deletions _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,14 @@ def test_12_create_perfects_on_objects(self):
self.aedtapp.insert_design("test_12")
box1 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "perfect1", "Copper")
box2 = self.aedtapp.modeler.create_box([0, 0, 10], [10, 10, 5], "perfect2", "copper")
pe = self.aedtapp.create_perfecth_from_objects("perfect1", "perfect2", self.aedtapp.AxisDir.ZPos)
ph = self.aedtapp.create_perfecte_from_objects("perfect1", "perfect2", self.aedtapp.AxisDir.ZNeg)

ph = self.aedtapp.create_perfecth_from_objects(
box1.name, box2.name, self.aedtapp.AxisDir.ZNeg, is_boundary_on_plane=False
)

pe = self.aedtapp.create_perfecte_from_objects(
box1.name, box2.name, self.aedtapp.AxisDir.ZNeg, is_boundary_on_plane=False
)
assert pe.name in self.aedtapp.modeler.get_boundaries_name()
assert pe.update()
assert ph.name in self.aedtapp.modeler.get_boundaries_name()
Expand Down Expand Up @@ -978,8 +984,8 @@ def test_34_object_material_properties(self):
assert props

def test_35_set_export_touchstone(self):
assert self.aedtapp.set_export_touchstone(True)
assert self.aedtapp.set_export_touchstone(False)
assert self.aedtapp.export_touchstone_on_completion(True)
assert self.aedtapp.export_touchstone_on_completion(False)

def test_36_assign_radiation_to_objects(self):
self.aedtapp.modeler.create_box([-100, -100, -100], [200, 200, 200], name="Rad_box")
Expand Down Expand Up @@ -1567,12 +1573,15 @@ def test_65_component_array(self, add_app):
array.cells[0][1].component = array.component_names[3]
assert array.cells[0][1].component == array.component_names[3]

hfss_array.component_array["A1"].name = "Array_new"
assert hfss_array.component_array_names[0] == "Array_new"
hfss_array.component_array["Array_new"].name = "A1"
name = "Array_new"
hfss_array.component_array["A1"].name = name
assert hfss_array.component_array_names[0] == name

if config["desktopVersion"] < "2025.1":
name = "A1"
hfss_array.component_array["Array_new"].name = name
omodel = hfss_array.get_oo_object(hfss_array.odesign, "Model")
oarray = hfss_array.get_oo_object(omodel, "A1")
oarray = hfss_array.get_oo_object(omodel, name)

assert array.visible
array.visible = False
Expand Down Expand Up @@ -1708,4 +1717,4 @@ def test_70_export_on_completion(self, add_app, local_scratch):
aedtapp = add_app(project_name="test_70")
assert aedtapp.export_touchstone_on_completion()
assert aedtapp.export_touchstone_on_completion(export=True, output_dir=self.local_scratch.path)
assert aedtapp.set_export_touchstone()
assert aedtapp.export_touchstone_on_completion()
5 changes: 3 additions & 2 deletions _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,9 @@ def test_21_variables(self):
assert isinstance(self.aedtapp.available_variations.nominal_w_values, list)

def test_26_duplicate(self):
assert self.aedtapp.modeler.duplicate("myrectangle", 2, [1, 1])
assert self.aedtapp.modeler.duplicate_across_layers("mycircle2", "Bottom")
n2 = self.aedtapp.modeler.create_rectangle("Top", [0, 0], [6, 8], 3, 2, "myrectangle_d")
assert self.aedtapp.modeler.duplicate("myrectangle_d", 2, [1, 1])
assert self.aedtapp.modeler.duplicate_across_layers("myrectangle_d", "Bottom")

def test_27_create_pin_port(self):
port = self.aedtapp.create_pin_port("PinPort1")
Expand Down
45 changes: 45 additions & 0 deletions _unittest/test_45_FilterSolutions/resources/library_parts_test.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
modsubType=2
modsubEr=2.25
modsubRho=4.2E+07
modsubTand=0.065
modsubH=0.003
modsubT=3.5E-07
modsubS=0.00127
modsubC=0.00635
modsubErsel=-1
modsubRhosel=-1
modsubTandsel=-1
modsubTanddef=0
modsubiSubSel=0
modsubName=User Defined Substrate
modsubBrow=
modsubNameVal=2.25
modAnsSubIndex=0
modAWRSubIndex=0
webAWRSubIndex=0
locAWRSubIndex=0
ModelData=2
ModelDataV=1
ModelInd=0
ModelCap=0
ModelRes=0
ModelIndV=1
ModelCapV=1
ModelResV=1
modRatLen=2
modRatZ=1
Interc=1
modActLen=0.00254
modActWid=0.00127
modRatZMin=0.5
modRatZMax=2
modRatLenMin=0.5
modRatLenMax=2
modActLenMin=0.00127
modActWidMin=0.000635
modActLenMax=0.00508
modActWidMax=0.00254
useGeo=0
OptGeo=1
indTol=1
capTol=1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


@pytest.mark.skipif(is_linux, reason="FilterSolutions API is not supported on Linux.")
@pytest.mark.skipif(config["desktopVersion"] < "2025.1", reason="Skipped on versions earlier than 2025.1")
@pytest.mark.skipif(config["desktopVersion"] < "2025.2", reason="Skipped on versions earlier than 2025.2")
class TestClass:
def test_modelithics_inductor_list_count(self):
lumpdesign = ansys.aedt.core.FilterSolutions(implementation_type=FilterImplementation.LUMPED)
Expand Down
9 changes: 8 additions & 1 deletion _unittest/test_launch_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_run_desktop_maxwell2d(self):
assert aedtapp.solution_type == "Magnetostatic"

def test_run_desktop_hfss(self):
aedtapp = Hfss()
aedtapp = Hfss(solution_type="Terminal")
assert aedtapp.design_type == "HFSS"
assert "Terminal" in aedtapp.solution_type

Expand All @@ -103,3 +103,10 @@ def test_run_desktop_circuit_netlist(self):
aedtapp = CircuitNetlist()
assert aedtapp.design_type == "Circuit Netlist"
assert aedtapp.solution_type == ""

def test_run_desktop_settings(self):
aedtapp = Hfss()
assert aedtapp.desktop_class.disable_optimetrics()
assert aedtapp.get_registry_key_int("Desktop/Settings/ProjectOptions/EnableLegacyOptimetricsTools") == 0
assert aedtapp.desktop_class.enable_optimetrics()
assert aedtapp.get_registry_key_int("Desktop/Settings/ProjectOptions/EnableLegacyOptimetricsTools") == 1
14 changes: 10 additions & 4 deletions _unittest_solvers/test_00_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
original_project_name = "ANSYS-HSD_V1"
transient = "Transient_StrandedWindings"

if config["desktopVersion"] > "2022.2":
if desktop_version > "2022.2":
component = "Circ_Patch_5GHz_232.a3dcomp"
else:
component = "Circ_Patch_5GHz.a3dcomp"
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_02_hfss_export_results(self, hfss_app):
hfss_app.insert_design("Array_simple_resuts", "Modal")
from ansys.aedt.core.generic.general_methods import read_json

if config["desktopVersion"] > "2023.1":
if desktop_version > "2023.1":
dict_in = read_json(os.path.join(local_path, "example_models", test_subfolder, "array_simple_232.json"))
dict_in["Circ_Patch_5GHz_232_1"] = os.path.join(local_path, "example_models", test_subfolder, component)
dict_in["cells"][(3, 3)] = {"name": "Circ_Patch_5GHz_232_1"}
Expand Down Expand Up @@ -349,6 +349,10 @@ def test_04a_3dl_generate_mesh(self):
def test_04b_3dl_analyze_setup(self):
assert self.hfss3dl_solve.export_touchstone_on_completion(export=False)
assert self.hfss3dl_solve.export_touchstone_on_completion(export=True)
if desktop_version > "2024.2":
assert self.hfss3dl_solve.set_export_touchstone()
else:
assert not self.hfss3dl_solve.set_export_touchstone()
assert self.hfss3dl_solve.analyze_setup("Setup1", cores=4, blocking=False)
assert self.hfss3dl_solve.are_there_simulations_running
assert self.hfss3dl_solve.stop_simulations()
Expand Down Expand Up @@ -377,8 +381,10 @@ def test_04e_3dl_export_results(self):
assert len(files) > 0

def test_04f_3dl_set_export_touchstone(self):
assert self.hfss3dl_solve.set_export_touchstone(True)
assert self.hfss3dl_solve.set_export_touchstone(False)
assert self.hfss3dl_solve.export_touchstone_on_completion(True)
assert self.hfss3dl_solve.export_touchstone_on_completion(False)
if desktop_version > "2024.2":
assert self.hfss3dl_solve.set_export_touchstone()

def test_04g_3dl_get_all_sparameter_list(self):
assert self.hfss3dl_solve.get_all_sparameter_list == ["S(Port1,Port1)", "S(Port1,Port2)", "S(Port2,Port2)"]
Expand Down
16 changes: 11 additions & 5 deletions _unittest_solvers/test_45_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ansys.aedt.core.generic.settings import is_linux
from _unittest.conftest import local_path
from _unittest_solvers.conftest import local_path as solver_local_path
from _unittest_solvers.conftest import desktop_version

push_project = "push_excitation"
export_3d_project = "export"
Expand Down Expand Up @@ -294,11 +295,16 @@ def test_09_advanced_fields_calculator_general(self, add_app):

from ansys.aedt.core.workflows.project.advanced_fields_calculator import main

assert main({"is_test": True,
"setup": "Setup1 : LastAdaptive",
"calculation": "voltage_drop",
"assignment": ["Face9", "inner"]})

if desktop_version > "2024.2":
assert main({"is_test": True,
"setup": "Setup1 : LastAdaptive",
"calculation": "voltage_drop_2025",
"assignment": ["Face9", "inner"]})
else:
assert main({"is_test": True,
"setup": "Setup1 : LastAdaptive",
"calculation": "voltage_drop",
"assignment": ["Face9", "inner"]})
assert len(aedtapp.post.ofieldsreporter.GetChildNames()) == 2

aedtapp.close_project(aedtapp.project_name)
Expand Down
21 changes: 19 additions & 2 deletions src/ansys/aedt/core/application/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,18 @@
return list(ast.literal_eval(self._value))
try:
var_obj = self._aedt_obj.GetChildObject("Variables").GetChildObject(self._variable_name)
val, _ = decompose_variable_value(var_obj.GetPropEvaluatedValue("EvaluatedValue"))
evaluated_value = (
var_obj.GetPropEvaluatedValue()
if self._app._aedt_version > "2024.2"
else var_obj.GetPropEvaluatedValue("EvaluatedValue")
)
if (
isinstance(evaluated_value, str)
and evaluated_value.strip().startswith("[")
and evaluated_value.strip().endswith("]")
):
evaluated_value = ast.literal_eval(evaluated_value)

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

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/variables.py#L1814

Added line #L1814 was not covered by tests
val, _ = decompose_variable_value(evaluated_value)
return val
except (TypeError, AttributeError):
if is_number(self._value):
Expand All @@ -1828,7 +1839,13 @@
"""Units."""
try:
var_obj = self._aedt_obj.GetChildObject("Variables").GetChildObject(self._variable_name)
_, self._units = decompose_variable_value(var_obj.GetPropEvaluatedValue("EvaluatedValue"))
evaluated_value = (
var_obj.GetPropEvaluatedValue()
if self._app._aedt_version > "2024.2"
else var_obj.GetPropEvaluatedValue("EvaluatedValue")
)

_, self._units = decompose_variable_value(evaluated_value)
return self._units
except (TypeError, AttributeError, GrpcApiError):
pass
Expand Down
32 changes: 31 additions & 1 deletion src/ansys/aedt/core/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ def disable_autosave(self):
"""
self.odesktop.EnableAutoSave(False)

def change_license_type(self, license_type="Pool"):
def change_license_type(self, license_type="Pool"): # pragma: no cover
"""Change the license type.

Parameters
Expand All @@ -1703,6 +1703,36 @@ def change_license_type(self, license_type="Pool"):
except Exception:
return False

def enable_optimetrics(self): # pragma: no cover
"""Enable optimetrics.

Returns
-------
bool
``True`` when successful, ``False`` when failed.

"""
try:
return self.change_registry_key("Desktop/Settings/ProjectOptions/EnableLegacyOptimetricsTools", 1)
except Exception:
self.logger.error("Failed to enable optimetrics.")
return False

def disable_optimetrics(self): # pragma: no cover
"""Disable optimetrics.

Returns
-------
bool
``True`` when successful, ``False`` when failed.

"""
try:
return self.change_registry_key("Desktop/Settings/ProjectOptions/EnableLegacyOptimetricsTools", 0)
except Exception:
self.logger.error("Failed to disable optimetrics.")
return False

def change_registry_key(self, key_full_name, key_value):
"""Change an AEDT registry key to a new value.

Expand Down
40 changes: 2 additions & 38 deletions src/ansys/aedt/core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4460,42 +4460,6 @@ def create_qfactor_report(self, project_dir, output, setup, name, x_axis="X"):
)
return True

@pyaedt_function_handler()
def set_export_touchstone(self, activate, export_dir=""):
"""Set automatic export of the Touchstone file after simulation.

Parameters
----------
activate : bool
Whether to export the Touchstone file after simulation finishes.
export_dir : str, optional
Directory to export the Touchstone file to. The default is ``""``,
in which case the Touchstone file is exported to the working directory.

Returns
-------
bool
``True`` when successful, ``False`` when failed.

References
----------

>>> oDesign.SetDesignSettings
"""
settings = []
if activate:
settings.append("NAME:Design Settings Data")
settings.append("Export After Simulation:=")
settings.append(True)
settings.append("Export Dir:=")
settings.append(export_dir)
elif not activate:
settings.append("NAME:Design Settings Data")
settings.append("Export After Simulation:=")
settings.append(False)
self.odesign.SetDesignSettings(settings)
return True

@pyaedt_function_handler(obh_names="assignment", boundary_name="name")
def assign_radiation_boundary_to_objects(self, assignment, name=None):
"""Assign a radiation boundary to one or more objects (usually airbox objects).
Expand Down Expand Up @@ -7062,7 +7026,7 @@ def export_touchstone_on_completion(self, export=True, output_dir=None):
Parameters
----------
export : bool, optional
Whether to enable the export.
Whether to export the Touchstone file after the simulation.
The default is ``True``.
output_dir : str, optional
Path to the directory of exported file. The default is the project path.
Expand Down Expand Up @@ -7163,7 +7127,7 @@ def set_export_touchstone(
>>> from ansys.aedt.core import Hfss
>>> hfss = Hfss()
>>> hfss.export_touchstone_on_completion()
>>> hfss.set_export_touchstone()
>>> hfss.export_touchstone_on_completion()


"""
Expand Down
Loading
Loading