From 2c7ae0ab2ad7316d82ca1f722d7ad1020312a6e9 Mon Sep 17 00:00:00 2001 From: anur7 Date: Thu, 17 Jul 2025 11:23:31 +0200 Subject: [PATCH 1/9] FIX: analyze_from_zero --- src/ansys/aedt/core/maxwell.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ansys/aedt/core/maxwell.py b/src/ansys/aedt/core/maxwell.py index 58c30bd9dfe..9919f8ab02b 100644 --- a/src/ansys/aedt/core/maxwell.py +++ b/src/ansys/aedt/core/maxwell.py @@ -1639,7 +1639,14 @@ def analyze_from_zero(self): raise AEDTRuntimeError("This methods work only with Maxwell Transient Analysis.") self.oanalysis.ResetSetupToTimeZero(self._setup) - self.analyze() + if self.boundaries[2].type == "Balloon": + self.logger.warning( + "With Balloon boundary is not possible to parallelize the simulation " + "using the Time Decomposition Method (TDM)." + ) + self.analyze(cores=1) + else: + self.analyze() return True @pyaedt_function_handler(val="angle") From 1550e0d8bbcc5ea24e194aaed6417028ff836e8d Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 17 Jul 2025 09:35:43 +0000 Subject: [PATCH 2/9] chore: adding changelog file 6425.fixed.md [dependabot-skip] --- doc/changelog.d/6425.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/6425.fixed.md diff --git a/doc/changelog.d/6425.fixed.md b/doc/changelog.d/6425.fixed.md new file mode 100644 index 00000000000..a771173211f --- /dev/null +++ b/doc/changelog.d/6425.fixed.md @@ -0,0 +1 @@ +Analyze_from_zero \ No newline at end of file From 9998c61259b883d64adf3c64a14bd8ce88c5a0f1 Mon Sep 17 00:00:00 2001 From: anur7 Date: Fri, 18 Jul 2025 23:34:59 +0200 Subject: [PATCH 3/9] FIX: fix analyze_from_zero, added unit test --- src/ansys/aedt/core/maxwell.py | 14 +++++++++----- tests/system/general/test_27_Maxwell2D.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/ansys/aedt/core/maxwell.py b/src/ansys/aedt/core/maxwell.py index b681bd6c177..2dd25f58d27 100644 --- a/src/ansys/aedt/core/maxwell.py +++ b/src/ansys/aedt/core/maxwell.py @@ -1640,11 +1640,15 @@ def analyze_from_zero(self): raise AEDTRuntimeError("This methods work only with Maxwell Transient Analysis.") self.oanalysis.ResetSetupToTimeZero(self._setup) - if self.boundaries[2].type == "Balloon": - self.logger.warning( - "With Balloon boundary is not possible to parallelize the simulation " - "using the Time Decomposition Method (TDM)." - ) + bound = [] + for k in range(len(self.boundaries)): + if self.boundaries[k].type == "Balloon": + self.logger.warning( + "With Balloon boundary is not possible to parallelize the simulation " + "using the Time Decomposition Method (TDM)." + ) + bound.append(self.boundaries[k].type) + if "Balloon" in bound: self.analyze(cores=1) else: self.analyze() diff --git a/tests/system/general/test_27_Maxwell2D.py b/tests/system/general/test_27_Maxwell2D.py index 4d3b06b7182..3011a6ae84e 100644 --- a/tests/system/general/test_27_Maxwell2D.py +++ b/tests/system/general/test_27_Maxwell2D.py @@ -105,6 +105,13 @@ def m2d_setup(add_app): app.close_project(app.project_name) +@pytest.fixture() +def m2d_analyze(add_app): + app = add_app(application=ansys.aedt.core.Maxwell2d, project_name="Maxwell_Test", design_name="test_analyze") + yield app + app.close_project(app.project_name) + + class TestClass: def test_assign_initial_mesh_from_slider(self, aedtapp): assert aedtapp.mesh.assign_initial_mesh_from_slider(4) @@ -834,3 +841,14 @@ def test_export_rl_matrix(self, local_scratch, m2d_export_matrix): matrix_type="RL", matrix_name="Matrix1", output_file=export_path_2 ) assert os.path.exists(export_path_2) + + def test_analyze_from_zero(self, m2d_analyze): + m2d_analyze.solution_type = "TransientXY" + conductor = m2d_analyze.modeler.create_circle(origin=[0, 0, 0], radius=10, material="Copper") + m2d_analyze.assign_winding(assignment=conductor.name, is_solid=False, current="5*cos(2*PI*50*time)") + region = m2d_analyze.modeler.create_region(pad_percent=100) + m2d_analyze.assign_balloon(assignment=region.edges) + setup1 = m2d_analyze.create_setup() + setup1.props["StopTime"] = "2/50s" + setup1.props["TimeStep"] = "1/500s" + assert m2d_analyze.analyze_from_zero() From da17219f58931bac06b085a7142dbcef8439712b Mon Sep 17 00:00:00 2001 From: Abdun Nur <146203416+anur7@users.noreply.github.com> Date: Mon, 21 Jul 2025 11:39:05 +0200 Subject: [PATCH 4/9] Update src/ansys/aedt/core/maxwell.py Co-authored-by: Giulia Malinverno <103059376+gmalinve@users.noreply.github.com> --- src/ansys/aedt/core/maxwell.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ansys/aedt/core/maxwell.py b/src/ansys/aedt/core/maxwell.py index 2dd25f58d27..002e3ec1699 100644 --- a/src/ansys/aedt/core/maxwell.py +++ b/src/ansys/aedt/core/maxwell.py @@ -1640,16 +1640,12 @@ def analyze_from_zero(self): raise AEDTRuntimeError("This methods work only with Maxwell Transient Analysis.") self.oanalysis.ResetSetupToTimeZero(self._setup) - bound = [] - for k in range(len(self.boundaries)): - if self.boundaries[k].type == "Balloon": - self.logger.warning( - "With Balloon boundary is not possible to parallelize the simulation " - "using the Time Decomposition Method (TDM)." - ) - bound.append(self.boundaries[k].type) - if "Balloon" in bound: - self.analyze(cores=1) + if any(boundary.type == "Balloon" for boundary in self.boundaries): + self.logger.warning( + "With Balloon boundary, it is not possible to parallelize the simulation " + "using the Time Decomposition Method (TDM)." + ) + self.analyze(use_auto_settings=False, cores=1) else: self.analyze() return True From 6475930744e9b089b49c34f7a4b840a016cbaf0a Mon Sep 17 00:00:00 2001 From: anur7 Date: Mon, 21 Jul 2025 12:33:42 +0200 Subject: [PATCH 5/9] FIX: code improvement, added test for non Balloon boundary condition --- src/ansys/aedt/core/maxwell.py | 10 ++++----- tests/system/general/test_27_Maxwell2D.py | 27 ++++++++++------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/ansys/aedt/core/maxwell.py b/src/ansys/aedt/core/maxwell.py index 002e3ec1699..7f1b1e59c3a 100644 --- a/src/ansys/aedt/core/maxwell.py +++ b/src/ansys/aedt/core/maxwell.py @@ -1641,11 +1641,11 @@ def analyze_from_zero(self): self.oanalysis.ResetSetupToTimeZero(self._setup) if any(boundary.type == "Balloon" for boundary in self.boundaries): - self.logger.warning( - "With Balloon boundary, it is not possible to parallelize the simulation " - "using the Time Decomposition Method (TDM)." - ) - self.analyze(use_auto_settings=False, cores=1) + self.logger.warning( + "With Balloon boundary, it is not possible to parallelize the simulation " + "using the Time Decomposition Method (TDM)." + ) + self.analyze(use_auto_settings=False, cores=1) else: self.analyze() return True diff --git a/tests/system/general/test_27_Maxwell2D.py b/tests/system/general/test_27_Maxwell2D.py index 3011a6ae84e..d4bb85214bf 100644 --- a/tests/system/general/test_27_Maxwell2D.py +++ b/tests/system/general/test_27_Maxwell2D.py @@ -105,13 +105,6 @@ def m2d_setup(add_app): app.close_project(app.project_name) -@pytest.fixture() -def m2d_analyze(add_app): - app = add_app(application=ansys.aedt.core.Maxwell2d, project_name="Maxwell_Test", design_name="test_analyze") - yield app - app.close_project(app.project_name) - - class TestClass: def test_assign_initial_mesh_from_slider(self, aedtapp): assert aedtapp.mesh.assign_initial_mesh_from_slider(4) @@ -842,13 +835,17 @@ def test_export_rl_matrix(self, local_scratch, m2d_export_matrix): ) assert os.path.exists(export_path_2) - def test_analyze_from_zero(self, m2d_analyze): - m2d_analyze.solution_type = "TransientXY" - conductor = m2d_analyze.modeler.create_circle(origin=[0, 0, 0], radius=10, material="Copper") - m2d_analyze.assign_winding(assignment=conductor.name, is_solid=False, current="5*cos(2*PI*50*time)") - region = m2d_analyze.modeler.create_region(pad_percent=100) - m2d_analyze.assign_balloon(assignment=region.edges) - setup1 = m2d_analyze.create_setup() + def test_analyze_from_zero(self, m2d_app): + m2d_app.solution_type = "TransientXY" + conductor = m2d_app.modeler.create_circle(origin=[0, 0, 0], radius=10, material="Copper") + m2d_app.assign_winding(assignment=conductor.name, is_solid=False, current="5*cos(2*PI*50*time)") + region = m2d_app.modeler.create_region(pad_percent=100) + m2d_app.assign_balloon(region.edges) + setup1 = m2d_app.create_setup() setup1.props["StopTime"] = "2/50s" setup1.props["TimeStep"] = "1/500s" - assert m2d_analyze.analyze_from_zero() + assert m2d_app.analyze_from_zero() + m2d_app.modeler.delete(region.name) + region2 = m2d_app.modeler.create_region(pad_percent=100) + m2d_app.assign_vector_potential(assignment=region2.edges) + assert m2d_app.analyze_from_zero() From df31439da242a09992468c3c6ce15d3a9519c544 Mon Sep 17 00:00:00 2001 From: anur7 Date: Mon, 21 Jul 2025 15:52:13 +0200 Subject: [PATCH 6/9] FIX: improved test for non Balloon BC and added test for AEDTRuntimeError --- tests/system/general/test_27_Maxwell2D.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/system/general/test_27_Maxwell2D.py b/tests/system/general/test_27_Maxwell2D.py index d4bb85214bf..6e930d1e534 100644 --- a/tests/system/general/test_27_Maxwell2D.py +++ b/tests/system/general/test_27_Maxwell2D.py @@ -836,16 +836,19 @@ def test_export_rl_matrix(self, local_scratch, m2d_export_matrix): assert os.path.exists(export_path_2) def test_analyze_from_zero(self, m2d_app): - m2d_app.solution_type = "TransientXY" + m2d_app.solution_type = SolutionsMaxwell2D.TransientXY conductor = m2d_app.modeler.create_circle(origin=[0, 0, 0], radius=10, material="Copper") m2d_app.assign_winding(assignment=conductor.name, is_solid=False, current="5*cos(2*PI*50*time)") region = m2d_app.modeler.create_region(pad_percent=100) - m2d_app.assign_balloon(region.edges) + bound = m2d_app.assign_balloon(region.edges) setup1 = m2d_app.create_setup() setup1.props["StopTime"] = "2/50s" setup1.props["TimeStep"] = "1/500s" assert m2d_app.analyze_from_zero() - m2d_app.modeler.delete(region.name) - region2 = m2d_app.modeler.create_region(pad_percent=100) - m2d_app.assign_vector_potential(assignment=region2.edges) + bound.delete() + m2d_app.assign_vector_potential(assignment=region.edges) assert m2d_app.analyze_from_zero() + m2d_app.solution_type = SolutionsMaxwell2D.MagnetostaticXY + m2d_app.create_setup() + with pytest.raises(AEDTRuntimeError): + m2d_app.analyze_from_zero() From 3a02db7ce132583a337cb5b2324a4c41aeee962c Mon Sep 17 00:00:00 2001 From: anur7 Date: Thu, 7 Aug 2025 12:35:09 +0200 Subject: [PATCH 7/9] FIX: updated warning message in case of balloon boundary --- src/ansys/aedt/core/maxwell.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ansys/aedt/core/maxwell.py b/src/ansys/aedt/core/maxwell.py index 495193b9fa1..8336899e5d3 100644 --- a/src/ansys/aedt/core/maxwell.py +++ b/src/ansys/aedt/core/maxwell.py @@ -1643,7 +1643,8 @@ def analyze_from_zero(self): if any(boundary.type == "Balloon" for boundary in self.boundaries): self.logger.warning( "With Balloon boundary, it is not possible to parallelize the simulation " - "using the Time Decomposition Method (TDM)." + "using the Time Decomposition Method (TDM). " + "The simulation ran without HPC auto settings and using one single core." ) self.analyze(use_auto_settings=False, cores=1) else: From 8a32cff5b647ea2f4dfcfb092538e67641e0cf00 Mon Sep 17 00:00:00 2001 From: anur7 Date: Fri, 8 Aug 2025 10:13:59 +0200 Subject: [PATCH 8/9] FIX: updated warning message in case of balloon boundary --- src/ansys/aedt/core/maxwell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/aedt/core/maxwell.py b/src/ansys/aedt/core/maxwell.py index 8336899e5d3..6ca42c4b959 100644 --- a/src/ansys/aedt/core/maxwell.py +++ b/src/ansys/aedt/core/maxwell.py @@ -1644,7 +1644,7 @@ def analyze_from_zero(self): self.logger.warning( "With Balloon boundary, it is not possible to parallelize the simulation " "using the Time Decomposition Method (TDM). " - "The simulation ran without HPC auto settings and using one single core." + "Running the simulation without HPC auto settings and using one single core." ) self.analyze(use_auto_settings=False, cores=1) else: From f3f3b4213fc8b29a34b388151b0499e1bef00c52 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:47:03 +0000 Subject: [PATCH 9/9] chore: adding changelog file 6425.fixed.md [dependabot-skip] --- doc/changelog.d/6425.fixed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.d/6425.fixed.md b/doc/changelog.d/6425.fixed.md index a771173211f..4e58609f505 100644 --- a/doc/changelog.d/6425.fixed.md +++ b/doc/changelog.d/6425.fixed.md @@ -1 +1 @@ -Analyze_from_zero \ No newline at end of file +Analyze_from_zero