From ecf3eba458f9c1a84deb9c9a0aefb5ea0c550ae3 Mon Sep 17 00:00:00 2001 From: gmalinve <103059376+gmalinve@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:24:15 +0200 Subject: [PATCH 1/6] improve nominal variation (#3794) * improve nominal variation * add UT --- _unittest/test_01_Design.py | 3 +++ pyaedt/application/Analysis.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/_unittest/test_01_Design.py b/_unittest/test_01_Design.py index de6f9c5793d..1dc5fc7c31f 100644 --- a/_unittest/test_01_Design.py +++ b/_unittest/test_01_Design.py @@ -129,6 +129,9 @@ def test_13_designs(self): def test_14_get_nominal_variation(self): assert self.aedtapp.get_nominal_variation() != [] or self.aedtapp.get_nominal_variation() is not None + assert isinstance(self.aedtapp.get_nominal_variation(), list) + assert isinstance(self.aedtapp.get_nominal_variation(with_values=True), list) + assert self.aedtapp.get_nominal_variation(with_values=True) != [] def test_15a_duplicate_design(self): self.aedtapp.duplicate_design("non_valid1", False) diff --git a/pyaedt/application/Analysis.py b/pyaedt/application/Analysis.py index 23d37b3ebf0..7c490d965fa 100644 --- a/pyaedt/application/Analysis.py +++ b/pyaedt/application/Analysis.py @@ -1091,15 +1091,24 @@ def get_setups(self): return list(setups) @pyaedt_function_handler() - def get_nominal_variation(self): + def get_nominal_variation(self, with_values=False): """Retrieve the nominal variation. + Parameters + ---------- + with_values : bool + Whether to return nominal variation or nominal variation with values. + The default is ``False``. + Returns ------- list of str List of nominal variations. """ - return self.available_variations.nominal + if not with_values: + return self.available_variations.nominal + else: + return self.available_variations.nominal_w_values @pyaedt_function_handler() def get_sweeps(self, name): From 723c2209a5bcaf127817e67879e923cfc179a956 Mon Sep 17 00:00:00 2001 From: gmalinve <103059376+gmalinve@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:51:20 +0200 Subject: [PATCH 2/6] fix object cs duplicate (#3791) * fix object cs duplicate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- pyaedt/modeler/cad/Modeler.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/pyaedt/modeler/cad/Modeler.py b/pyaedt/modeler/cad/Modeler.py index ab4bfaa1511..44b50ac0ed4 100644 --- a/pyaedt/modeler/cad/Modeler.py +++ b/pyaedt/modeler/cad/Modeler.py @@ -2829,9 +2829,7 @@ def duplicate_coordinate_system_to_global(self, coordinate_system): if name in cs_names: name = cs.name + generate_unique_name("_RefToGlobal") face_cs = FaceCoordinateSystem(self, props=cs.props, name=name, face_id=cs.props["FaceID"]) - obj = [ - obj for obj in self._app.modeler.object_list for face in obj.faces if face.id == face_cs.props["FaceID"] - ][0] + obj = [obj for obj in self.object_list for face in obj.faces if face.id == face_cs.props["FaceID"]][0] face = [face for face in obj.faces if face.id == face_cs.props["FaceID"]][0] if face_cs.props["Origin"]["PositionType"] == "FaceCenter": origin = face @@ -2868,16 +2866,24 @@ def duplicate_coordinate_system_to_global(self, coordinate_system): ) if result: return face_cs - elif isinstance(coordinate_system, ObjectCoordinateSystem): + elif isinstance(cs, ObjectCoordinateSystem): name = cs.name + "_RefToGlobal" if name in cs_names: name = cs.name + generate_unique_name("_RefToGlobal") obj_cs = ObjectCoordinateSystem(self, props=cs.props, name=name, entity_id=cs.entity_id) - obj = self.objects[cs.entity_id] + objs_by_name_list = [obj for obj in self.object_list if obj.part_coordinate_system == cs.name] + objs_by_id_list = [o for o in self.object_list if o.id == cs.entity_id] + if objs_by_name_list: + obj = objs_by_name_list[0] + elif objs_by_id_list: + obj = [o for o in self.object_list if o.id == cs.entity_id][0] if cs.props["Origin"]["PositionType"] != "AbsolutePosition": if cs.props["Origin"]["PositionType"] == "FaceCenter": origin = [f for f in obj.faces if f.id == cs.props["Origin"]["EntityID"]][0] - elif cs.props["Origin"]["PositionType"] == "EdgeCenter": + elif ( + cs.props["Origin"]["PositionType"] == "EdgeCenter" + or cs.props["Origin"]["PositionType"] == "ArcCenter" + ): origin = [e for e in obj.edges if e.id == cs.props["Origin"]["EntityID"]][0] elif cs.props["Origin"]["PositionType"] == "OnVertex": origin = [v for v in obj.vertices if v.id == cs.props["Origin"]["EntityID"]][0] @@ -2890,7 +2896,10 @@ def duplicate_coordinate_system_to_global(self, coordinate_system): if "xAxisPos" in cs.props: if cs.props["xAxisPos"]["PositionType"] == "FaceCenter": x_axis = [f for f in obj.faces if f.id == cs.props["xAxisPos"]["EntityID"]][0] - elif cs.props["xAxisPos"]["PositionType"] == "EdgeCenter": + elif ( + cs.props["xAxisPos"]["PositionType"] == "EdgeCenter" + or cs.props["xAxisPos"]["PositionType"] == "ArcCenter" + ): x_axis = [e for e in obj.edges if e.id == cs.props["xAxisPos"]["EntityID"]][0] elif cs.props["xAxisPos"]["PositionType"] == "OnVertex": x_axis = [v for v in obj.vertices if v.id == cs.props["xAxisPos"]["EntityID"]][0] @@ -2903,7 +2912,10 @@ def duplicate_coordinate_system_to_global(self, coordinate_system): if "yAxisPos" in cs.props: if cs.props["yAxisPos"]["PositionType"] == "FaceCenter": y_axis = [f for f in obj.faces if f.id == cs.props["yAxisPos"]["EntityID"]][0] - elif cs.props["yAxisPos"]["PositionType"] == "EdgeCenter": + elif ( + cs.props["yAxisPos"]["PositionType"] == "EdgeCenter" + or cs.props["yAxisPos"]["PositionType"] == "ArcCenter" + ): y_axis = [e for e in obj.edges if e.id == cs.props["yAxisPos"]["EntityID"]][0] elif cs.props["yAxisPos"]["PositionType"] == "OnVertex": y_axis = [v for v in obj.vertices if v.id == cs.props["yAxisPos"]["EntityID"]][0] From 93b685915e2620735b89a8aa35a25726db209191 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:42:46 +0200 Subject: [PATCH 3/6] Clear message when GetFaceCenter fails (#3796) --- pyaedt/aedt_logger.py | 3 +++ pyaedt/modeler/cad/elements3d.py | 1 + 2 files changed, 4 insertions(+) diff --git a/pyaedt/aedt_logger.py b/pyaedt/aedt_logger.py index a3a307eb1f8..3a09e5d5694 100644 --- a/pyaedt/aedt_logger.py +++ b/pyaedt/aedt_logger.py @@ -517,6 +517,9 @@ def clear_messages(self, proj_name=None, des_name=None, level=2): >>> hfss.clear_messages(level=3) + Clear all messages. + + >>> hfss.clear_messages(proj_name="", des_name="", level=3) """ if self._log_on_desktop: if proj_name is None: diff --git a/pyaedt/modeler/cad/elements3d.py b/pyaedt/modeler/cad/elements3d.py index 4b3f549022e..07beef5235a 100644 --- a/pyaedt/modeler/cad/elements3d.py +++ b/pyaedt/modeler/cad/elements3d.py @@ -598,6 +598,7 @@ def center(self): try: return [float(i) for i in self.oeditor.GetFaceCenter(self.id)] except: # pragma: no cover + self.logger.clear_messages() vtx = self.vertices[:] if len(vtx) > 1: return GeometryOperators.get_polygon_centroid([pos.position for pos in vtx]) From 96f58b362eb393761c22b11f786d5e3baceb5a50 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 25 Oct 2023 14:11:54 +0200 Subject: [PATCH 4/6] fix wrong default parameter values in SIWAVE setup (#3793) * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix --------- Co-authored-by: ring630 <@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- _unittest/test_00_EDB.py | 16 ++--- pyaedt/edb.py | 2 + .../edb_data/siwave_simulation_setup_data.py | 65 ++++++++++++++++--- 3 files changed, 65 insertions(+), 18 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 83ee20bb97d..716acbb0ca1 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2277,6 +2277,12 @@ def test_131_siwave_ac_simulation_setup(self): assert sweep.save_rad_fields_only assert sweep.use_q3d_for_dc + setup1.pi_slider_postion = 0 + setup1.pi_slider_postion = 1 + setup1.pi_slider_postion = 2 + setup1.si_slider_postion = 0 + setup1.si_slider_postion = 1 + setup1.si_slider_postion = 2 assert setup1.automatic_mesh assert setup1.enabled assert setup1.dc_settings @@ -2289,16 +2295,14 @@ def test_131_siwave_ac_simulation_setup(self): assert setup1.include_trace_coupling assert not setup1.include_vi_sources assert setup1.infinite_ground_location == "0" - assert setup1.max_coupled_lines == 12 + assert setup1.max_coupled_lines == 40 assert setup1.mesh_frequency == "4GHz" assert setup1.min_pad_area_to_mesh == "1mm2" assert setup1.min_plane_area_to_mesh == "6.25e-6mm2" assert setup1.min_void_area == "2mm2" assert setup1.name == "AC1" assert setup1.perform_erc - assert setup1.pi_slider_postion == 1 - assert setup1.si_slider_postion == 1 - assert not setup1.return_current_distribution + assert setup1.return_current_distribution assert setup1.snap_length_threshold == "2.5um" assert setup1.use_si_settings assert setup1.use_custom_settings @@ -2323,8 +2327,6 @@ def test_131_siwave_ac_simulation_setup(self): setup1.min_void_area = "1mm2" setup1.name = "AC2" setup1.perform_erc = False - setup1.pi_slider_postion = 0 - setup1.si_slider_postion = 2 setup1.return_current_distribution = True setup1.snap_length_threshold = "3.5um" setup1.use_si_settings = False @@ -2349,8 +2351,6 @@ def test_131_siwave_ac_simulation_setup(self): assert setup1.min_void_area == "1mm2" assert setup1.name == "AC2" assert not setup1.perform_erc - assert setup1.pi_slider_postion == 0 - assert setup1.si_slider_postion == 2 assert setup1.return_current_distribution assert setup1.snap_length_threshold == "3.5um" assert not setup1.use_si_settings diff --git a/pyaedt/edb.py b/pyaedt/edb.py index ee9a5b13c4b..667b2ea3104 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3367,6 +3367,8 @@ def create_siwave_syz_setup(self, name=None): if name in self.setups: return False setup = SiwaveSYZSimulationSetup(self, name) + setup.si_slider_postion = 1 + setup.pi_slider_postion = 1 self._setups[name] = setup return setup diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index bcfb82a3fd3..71e10479425 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -756,29 +756,74 @@ def enabled(self): """Whether the setup is enabled.""" return self._edb_sim_setup_info.SimulationSettings.Enabled - @property - def pi_slider_postion(self): - """PI solider position. Values are from ``1`` to ``3``.""" - return self._edb_sim_setup_info.SimulationSettings.PISliderPos - - @property - def si_slider_postion(self): - """SI solider position. Values are from ``1`` to ``3``.""" - return self._edb_sim_setup_info.SimulationSettings.SISliderPos - @enabled.setter def enabled(self, value): self._edb_sim_setup_info.SimulationSettings.Enabled = value self._update_setup() + @property + def pi_slider_postion(self): + """PI solider position. Values are from ``1`` to ``3``.""" + return self._edb_sim_setup_info.SimulationSettings.PISliderPos + @pi_slider_postion.setter def pi_slider_postion(self, value): + if value == 0: + self.include_coplane_coupling = False + self.include_inter_plane_coupling = False + self.include_split_plane_coupling = False + self.include_fringe_coupling = False + self.include_trace_coupling = False + self.max_coupled_lines = 12 + elif value == 1: + self.include_coplane_coupling = False + self.include_inter_plane_coupling = False + self.include_split_plane_coupling = False + self.include_fringe_coupling = True + self.include_trace_coupling = False + self.max_coupled_lines = 12 + else: + self.include_coplane_coupling = True + self.include_inter_plane_coupling = False + self.include_split_plane_coupling = True + self.include_fringe_coupling = True + self.include_trace_coupling = True + self.max_coupled_lines = 40 self._edb_sim_setup_info.SimulationSettings.UseCustomSettings = False self._edb_sim_setup_info.SimulationSettings.PISliderPos = value self._update_setup() + @property + def si_slider_postion(self): + """SI solider position. Values are from ``1`` to ``3``.""" + return self._edb_sim_setup_info.SimulationSettings.SISliderPos + @si_slider_postion.setter def si_slider_postion(self, value): + if value == 0: + self.include_coplane_coupling = False + self.include_inter_plane_coupling = False + self.include_split_plane_coupling = False + self.include_fringe_coupling = False + self.include_trace_coupling = True + self.max_coupled_lines = 12 + self.return_current_distribution = False + elif value == 1: + self.include_coplane_coupling = True + self.include_inter_plane_coupling = False + self.include_split_plane_coupling = True + self.include_fringe_coupling = True + self.include_trace_coupling = True + self.max_coupled_lines = 12 + self.return_current_distribution = False + else: + self.include_coplane_coupling = True + self.include_inter_plane_coupling = False + self.include_split_plane_coupling = True + self.include_fringe_coupling = True + self.include_trace_coupling = True + self.max_coupled_lines = 40 + self.return_current_distribution = True self._edb_sim_setup_info.SimulationSettings.UseCustomSettings = False self._edb_sim_setup_info.SimulationSettings.SISliderPos = value self._update_setup() From 8af5e38d8d3fe0cdcdd165be7195e7b60a1433d1 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:06:26 +0200 Subject: [PATCH 5/6] Add GRPC port (#3798) --- pyaedt/misc/Run_PyAEDT_Script.py_build | 5 ++++- pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pyaedt/misc/Run_PyAEDT_Script.py_build b/pyaedt/misc/Run_PyAEDT_Script.py_build index 152b833b19d..85bfca277d2 100644 --- a/pyaedt/misc/Run_PyAEDT_Script.py_build +++ b/pyaedt/misc/Run_PyAEDT_Script.py_build @@ -48,7 +48,10 @@ def main(): check_file(python_exe) check_file(pyaedt_script) os.environ["PYAEDT_SCRIPT_PROCESS_ID"] = str(oDesktop.GetProcessID()) - os.environ["PYAEDT_SCRIPT_VERSION"] = str(oDesktop.GetVersion()[:6]) + version = str(oDesktop.GetVersion()[:6]) + os.environ["PYAEDT_SCRIPT_VERSION"] = version + if version > "2022.2": + os.environ["PYAEDT_SCRIPT_PORT"] = str(oDesktop.GetGrpcServerPort()) if is_linux: edt_root = os.path.normpath(oDesktop.GetExeDir()) os.environ["ANSYSEM_ROOT{}".format(version)] = edt_root diff --git a/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build b/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build index aaac748a78b..119e1ecced6 100644 --- a/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build +++ b/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build @@ -38,7 +38,10 @@ def main(): check_file(python_exe) check_file(pyaedt_script) os.environ["PYAEDT_SCRIPT_PROCESS_ID"] = str(oDesktop.GetProcessID()) - os.environ["PYAEDT_SCRIPT_VERSION"] = str(oDesktop.GetVersion()[:6]) + version = str(oDesktop.GetVersion()[:6]) + os.environ["PYAEDT_SCRIPT_VERSION"] = version + if version > "2022.2": + os.environ["PYAEDT_SCRIPT_PORT"] = str(oDesktop.GetGrpcServerPort()) if is_linux: edt_root = os.path.normpath(oDesktop.GetExeDir()) os.environ["ANSYSEM_ROOT{}".format(version)] = edt_root From 5507831094c9eeecc58864f17ae193b55006a69e Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 25 Oct 2023 19:23:08 +0200 Subject: [PATCH 6/6] fix (#3797) Co-authored-by: ring630 <@gmail.com> --- _unittest/test_00_EDB.py | 2 ++ pyaedt/edb_core/edb_data/terminals.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 716acbb0ca1..c47d1346d6b 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -1387,6 +1387,8 @@ def test_107_create_edge_ports(self): gap_port.name = "gap_port" assert gap_port.name == "gap_port" assert isinstance(gap_port.renormalize_z0, tuple) + gap_port.is_circuit_port = True + assert gap_port.is_circuit_port edb.close() def test_108_create_dc_simulation(self): diff --git a/pyaedt/edb_core/edb_data/terminals.py b/pyaedt/edb_core/edb_data/terminals.py index 30e551e241e..2a996f08df1 100644 --- a/pyaedt/edb_core/edb_data/terminals.py +++ b/pyaedt/edb_core/edb_data/terminals.py @@ -65,6 +65,10 @@ def is_circuit_port(self): """Whether it is a circuit port.""" return self._edb_object.GetIsCircuitPort() + @is_circuit_port.setter + def is_circuit_port(self, value): + self._edb_object.SetIsCircuitPort(value) + @property def _port_post_processing_prop(self): """Get port post processing properties."""