Skip to content

Commit

Permalink
FEAT: Assign two way coupling in Mechanical (#5145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Sep 10, 2024
1 parent 761a7ba commit 618cfec
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions _unittest/test_29_Mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ def test_05_assign_load(self, add_app):
assert self.aedtapp.assign_em_losses(hfss.design_name, hfss.setups[0].name, "LastAdaptive", freq)

def test_06a_create_setup(self):
assert not self.aedtapp.assign_2way_coupling()
mysetup = self.aedtapp.create_setup()
mysetup.props["Solver"] = "Direct"
assert mysetup.update()

def test_06b_two_way(self):
assert self.aedtapp.assign_2way_coupling()

@pytest.mark.skipif(config["desktopVersion"] < "2021.2", reason="Skipped on versions lower than 2021.2")
def test_07_assign_thermal_loss(self, add_app):
ipk = add_app(application=Icepak, solution_type=self.aedtapp.SOLUTIONS.Icepak.SteadyTemperatureAndFlow)
Expand Down
47 changes: 47 additions & 0 deletions src/ansys/aedt/core/mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,53 @@ def assign_heat_generation(self, assignment, value, name=""):
return bound
return False

@pyaedt_function_handler()
def assign_2way_coupling(self, setup=None, number_of_iterations=2):
"""Assign two-way coupling to a setup.
Parameters
----------
setup : str, optional
Name of the setup. The default is ``None``, in which case the active setup is used.
number_of_iterations : int, optional
Number of iterations. The default is ``2``.
Returns
-------
bool
``True`` when successful, ``False`` when failed.
References
----------
>>> oModule.AddTwoWayCoupling
Examples
--------
>>> from ansys.aedt.core import Mechanical
>>> mech = Mechanical()
>>> setup = mech.create_setup()
>>> mech.assign_2way_coupling(setup.name, 1)
>>> mech.release_desktop()
"""
if not setup:
if self.setups:
setup = self.setups[0].name
else:
self.logger.error("Setup is not defined.")
return False

self.oanalysis.AddTwoWayCoupling(
setup,
[
"NAME:Options",
"NumCouplingIters:=",
number_of_iterations,
],
)
return True

@pyaedt_function_handler(setupname="name", setuptype="setup_type")
def create_setup(self, name="MySetupAuto", setup_type=None, **kwargs):
"""Create an analysis setup for Mechanical.
Expand Down

0 comments on commit 618cfec

Please sign in to comment.