Closed narnia-mason closed 1 year ago
@narnia-mason launch_mechanical
may actually be misnamed here. It is only capable of launching mechanical on the local machine, and when a remote IP is used, it only tries to connect to it. @samigithub2022 is that correct?
@koubaa I'm not sure... π₯² I just found a different approach in here. It says
from ansys.mechanical.core import Mechanical
mechanical = Mechanical(ip=my_ip_address, port=my_port)
But it does not work either.
Many materials say using launch_mechanical
with ip address argument to connect remotely.
@narnia-mason - as @koubaa mentioned launch_mechanical is only capable of launching on a local machine. You can use the same function to connect to a mechanical instance running on a different machine. Mechanical(ip, port) - is also used for only connecting. These two apis are similar to pymapdl.
Your requirement is - launch a Mechanical session on Windows. Connect from Linux machine.
you can try something like this:
On Windows machine: You can either launch mechanical manually. "C:\Program Files\ANSYS Inc\v232\aisol\bin\winx64\AnsysWBU.exe" -DSApplet -nosplash -notabctrl -grpc 10000
or using the pymechanical API
import ansys.mechanical.core as pymechanical
# to launch in batch/non-UI mode with the given path to AnsysWBU.exe
# useful, if you need to work with different versions / installs
# mechanical = pymechanical.launch_mechanical(exec_file=exe_path, batch=True, cleanup_on_exit=False, port=10000)
# to launch with latest version in batch mode
mechanical = pymechanical.launch_mechanical(batch=True, cleanup_on_exit=False, port=10000)
On Linux machine:
import ansys.mechanical.core as pymechanical
mechanical = pymechanical.launch_mechanical(start_instance=False, cleanup_on_exit=False, clear_on_connect=False, ip=windows_hostname_or_ip, port=10000)
...
mechanical.Exit(force=True) # Exit without asking for the confirmation from the UI
Please let me know if you need more info.
@samigithub2022 Thanks! It works! :) So, I need to run AnsysWBU.exe on the local machine, and then I can access it from the other machine, right? But, can I run AnsysWBU.exe without GUI (batch mode)? I cannot find any related document for other AnsysWBU.exe options.
@samigithub2022 This is not the first time I see users wondering how to start a remote session from remote computer, and then connect to it. Could we add a page in the help about this? Thanks
@samigithub2022 @pmaroneh @koubaa @klmcadams @dipinknair
We should create a FAQ site in the documentation, similarly to other projects:
https://fluent.docs.pyansys.com/version/stable/getting_started/faqs.html https://geometry.docs.pyansys.com/version/stable/getting_started/faq.html https://mapdl.docs.pyansys.com/version/stable/getting_started/faq.html
@narnia-mason - we do give that control - launch in UI or batch launch_mechanical(batch=True,...) 'batch' argument controls the behavior.
We don't currently document the AnsysWBU.exe options. I can create a story on the development side for v242.
@RobPasMue That's a good idea. We should be able to add that in the FAQ.@pmaroneh @koubaa @klmcadams @dipinknair
@narnia-mason
we already have a documentation on the pymechanical side about
"Launch Mechanical from the command line"
Please refer the following link for details
thanks @koubaa for pointing to this.
FYI @koubaa @pmaroneh @klmcadams @dipinknair
π Before submitting the issue
π Description of the bug
I'm struggling with using PyMechanical remote session.
A valid Ansys has been installed in a local Windows machine. I'm planning to run Mechanical using PyMechanical remote session from a different Linux machine. The main script is as follow:
However,
launch_mechanical
does not respond and eventually it returns timeout error.I've checked that it works with a PyMechanical installed in the same Windows machine.
Is there any necessary setting for the local Ansys or Windows machine beforehand? Or do I need to try with every possible port?
P.S. the
ping
test has been passed.π Steps to reproduce
Installing WSL2 Ubuntu-20.04 distribution on a Windows machine.
Checking the IP address of the local Windows machine from the WSL Ubuntu as follows:
It returns
The IP address after
default via
is the IP of the local Windows machine.Creating a new Windows Firewall inbound rule (for the
ping
test).Creating a new
conda
environment in the WSL Ubuntu.Installing PyMechanical
$ python -m pip install ansys-mechanical-core
in theconda
environment.Running
launch_mechanical(ip='172.xxx.xxx.1')
it returnsOSError: Unable to connect to Mechanical instance at 172.xxx.xxx.1:10000.
π» Which operating system are you using?
Windows
π Which ANSYS version are you using?
2023 R1
π Which Python version are you using?
3.10
π¦ Installed packages