-
Notifications
You must be signed in to change notification settings - Fork 123
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
Launching MAPDL from WSL #2315
Comments
Hi @Abdulla060 I think I am going to need a bit more explanations about this. If you are working on WSL, can you launch MAPDL from inside WSL?? I didn't know you can do that. In that case, I guess you can launch MAPDL ( Before I do any changes on this, I will have to test locally. Feel free to recommend any approach or suggest any script for this. See Windows Subsystem Linux in PyMAPDL for more information. |
Definitely interested... 😄 |
In wsl you can run ANY Windows program simply by calling it from the terminal ref. ANSYS is no different. to test this: import time
import threading
import matplotlib.pyplot as plt
from ansys.mapdl.core import launch_mapdl
def starter():
launch_mapdl(
exec_file='/mnt/c/Program Files/ANSYS Inc/v231/ANSYS/bin/winx64/ANSYS231.exe',
start_timeout=10000
)
# some threading gymnastics to run the instance and connect to it.
# launch_mapdl will block until it connects to the instance (which will never happen)
starter_thread = threading.Thread(target=starter)
starter_thread.start()
apdl = launch_mapdl(
ip='172.25.192.1' # ip of the windows host in the hyper-v VLAN
)
apdl.prep7()
apdl.et(1, 183)
apdl.mp('ex', 1, 200e6)
apdl.mp('prxy', 1, 0.3)
apdl.k(1, 0, 0)
apdl.k(2, 50, 0)
apdl.k(3, 50, 50)
apdl.k(4, 0, 50)
apdl.l(1, 2)
apdl.l(2, 3)
apdl.l(3, 4)
apdl.l(4, 1)
apdl.lesize(5)
apdl.al(1, 2, 3, 4)
apdl.amesh('all')
apdl.run('/solu')
apdl.nsel('s', 'loc', 'y', 0)
apdl.d('all', 'ux', 0)
apdl.d('all', 'uy', 0)
apdl.nsel('s', 'loc', 'y', 50)
apdl.f('all', 'fy', -100)
apdl.nsel('all')
apdl.solve()
coords_x = apdl.mesh.nodes[:, 0]
coords_y = apdl.mesh.nodes[:, 1]
displacement_y = apdl.post_processing.nodal_displacement('y')
plt.tricontourf(coords_x, coords_y, displacement_y, levels=50)
plt.colorbar()
plt.show()
apdl.exit()
starter_thread.join() |
Hi @Abdulla060 I'm trying locally, but I think my WSL Python process cannot connect to the MAPDL process in the host machine. I believe it is a firewall issue or IP mapping. I have disabled the firewall and try as IP the one in Do you have any suggestions to allow WSL to connect to the MAPDL process at the host?? (Windows 11) |
@germa89 in the Windows host run the edit: the ip of the host machine is also shown when you run the
|
I still cannot connect to the local instance. I am not sure what is happening. In the meantime, if you can check this branch, it will be very helpful. |
I'll check it in a couple of hours. For the record, i didn't do anything in term of configuration. My code worked pretty much out of the box. To troubleshoot, try to run something else on the windows host and try to access it from wsl. Just to rule out that the problem is not in Ansys of mapdl. Example: hfs on Windows and try to get a file using |
@germa89 I just tested this out. works like a charm. one issue though, I still had to specify the |
I could do some checks. Furthermore, we could check if the But given the WSL architecture and my problems to test it, it might be buggy.
|
@Abdulla060 The changes required to allow PyMAPDL to launch MAPDL in the host OS natively must be done in the package ansys-tools-path. Hence I'm closing here as completed. If I have time, I will explore the possibility of doing the changes required in that library. |
@germa89 I will also look at it when I have the time. That said the original issue of |
On the branch I'm working in #2324 the
pymapdl/src/ansys/mapdl/core/launcher.py Line 1396 in ffd43cd
and pymapdl/src/ansys/mapdl/core/launcher.py Line 1454 in ffd43cd
|
@Abdulla060 Once #2324 is merged, you should be able to launch and connect to MAPDL from WSL. Please do check it and report any issues. The |
Description of the feature
This will allow the ANSYS instance to be started from within wsl2 even if ANSYS is not installed there.
This situation is relatively common when using conda with wsl2. For example, a user might be doing machine learning research and they are using Tensorflow with conda. This creates a situation where they have to maintain 2 separate Python environments, inside and outside wsl.
Steps for implementing the feature
I'm not really sure as i haven't delved into the source code yet
Useful links and references
No response
The text was updated successfully, but these errors were encountered: