pyleecan icon indicating copy to clipboard operation
pyleecan copied to clipboard

Using xfemm or wine to run the coupling with FEMM on Linux

Open normansdog opened this issue 5 years ago • 16 comments

It would be nice to have Pyleecan running on Linux but FEMM would have to run using Wine which needs to be tried out.

normansdog avatar Jun 15 '20 18:06 normansdog

Alternatively, you could look into xfemm, which is supposed to run natively on Linux. Does anyone have an idea of how feasible it is to link to xfemm instead of FEMM?

magnetron avatar Jun 18 '20 04:06 magnetron

Hello,

Having the pyleecan coupling with FEMM working as well on Linux would be great. As for now FEMM is the only magnetic module, pyleecan is kind of "windows only" which it should not. There is a dedicated page on FEMM about how to make it run on Linux: http://www.femm.info/wiki/LinuxSupport

Indeed XFEMM can be a good solution (we should be able to reuse most of the existing code), but it would require to find a way to call it from python (I think that there is no "pyxfemm"). The xfemm provide code for C++ and Matlab/octave. When working on MANATEE (matlab) we used xfemm and there will be also the need to "clean" the geometry (remove duplicate lines and points). Anyway we need to work on such a feature for issue #16 as well (that was for xfemm that we started the "is_simplified" work).

Does anyone knows what kind of modifications is required to call FEMM using Wine ?

Best regards, Pierre

BonneelP avatar Jun 18 '20 07:06 BonneelP

I am the author of xfemm. The problem with FEMM on Linux is that it cannot use ActiveX on Linux and instead uses a very slow and less reliable file based communication method. Otherwise it works surprisingly well on Linux. I'd happily accept contributions to xfemm to add python support, but have no time to develop it myself.

crobarcro avatar Jun 18 '20 08:06 crobarcro

Thank you for your feedback. Do you have any document/information about how much work it would represent to provide a python support to xfemm? We are not using too many femm methods so maybe we can start the work by focusing on what we are needing. Although, I don't think that I will have the time to develop it myself, maybe someone from the community can be interested.

BonneelP avatar Jun 18 '20 16:06 BonneelP

No documents I'm afraid, the main things to be done are create a means of creating input files, you could translate the octave/matlab preprocessor to python, which wouldn't be too difficult using numpy.

The slightly harder part would be to interface with the xfemm post processing library, which would require creating a python wrapper for the c++ lib, could maybe be done automatically with swig.

18 Jun 2020 17:29:12 Pierre Bonneel [email protected]:

Thank you for your feedback. Do you have any document/information about how much work it would represent to provide a python support to xfemm? We are not using too many femm methods so maybe we can start the work by focusing on what we are needing. Although, I don't think that I will have the time to develop it myself, maybe someone from the community can be interested.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub [https://github.com/Eomys/pyleecan/issues/104#issuecomment-646145854] , or unsubscribe [https://github.com/notifications/unsubscribe-auth/AAYDNDH5Q2UC2IU3Q2A5MKTRXI6FPANCNFSM4N6N2TPA] . [https://github.com/notifications/beacon/AAYDNDCTGSCSS2TOPJYBQ2DRXI6FPA5CNFSM4N6N2TPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOE2BWOPQ.gif]

crobarcro avatar Jun 18 '20 17:06 crobarcro

It seems that there was an update in Pyfemm in July 2021 that can help on this topic: image It could be worth investigating if it solves our coupling problem.

BonneelP avatar Feb 28 '22 08:02 BonneelP

Hello, I was able to merge the latest pyfemm mentioned above with pyleecan and get FEMM drawing and simulation working on ubuntu. Its pretty slow, and parallelization wasnt working though. On long simulations it also crashed once in a while. Should I share the code in a PR so that the community can see if and improve it?

harshasunder-1 avatar Aug 31 '22 12:08 harshasunder-1

Hello,

Great news :) Indeed we would be very interested by this PR. We can discuss afterwards about how to improve/make parallelization work. Thank you for having investigated this issue !

Best regards, Pierre

BonneelP avatar Aug 31 '22 13:08 BonneelP

Hello, I'm also very interested into running FEMM on Linux. I've tried several options:

  • I've executed FEMM using pyfemm, but it is still too slow because it relies on file system and parallelization does not work.
  • I've interfaced FEMM with octave both under Wine. I think it is feasible running on parallel, but then I have to install also Python under Wine to be able to wrap the octave code. (I think it is too much complicated)
  • I tried with xfemm directly from Octave, it works really fast in parallel using linux, but I'm getting far different results w.r.t FEMM results.

So if you need some help to integrate FEMM (or xfemm) with pyleecan to run it parallely, let me know. I would be happy to contribute.

amunozh avatar Sep 20 '22 16:09 amunozh

Hello,

I'm wondering if pyleecan installer can be installed in Wine ? If yes it may enable to run some simulations in FEMM maybe even with parallelization (I'm not using Linux so I never used Wine). The installer is available here: https://pyleecan.org/get.pyleecan.html. Do you think you can check that ?

If you want to contribute, we already have an open PR on the subject: #560

Best regards, Pierre

BonneelP avatar Sep 21 '22 07:09 BonneelP

Hello! Good news - i was able to run the pyleecan installer in Wine. Once installed it was able to parallely run the simulations in FEMM also! Drawing of the machine and loading of predrawn machines worked fine also. The pyleecan installer installs without trouble. However it crashed on my machine till I installed winetricks and used it to install vcrun2015. (using the command ./winetricks vcrun2015) Thanks Harsha

harshasunder-1 avatar Sep 22 '22 09:09 harshasunder-1

Great news :) Do you think you could write a small text to extend the "Method 1: GUI installer" part of this page for other Linux user ? If I understood correctly the process is:

  • install wine
  • install femm
  • install pyleecan exe
  • install vcrun2015

The corresponding file is available here https://github.com/Eomys/pyleecan-doc/blob/master/get.pyleecan.md but I can update it myself if you prefer.

Best regards, Pierre

BonneelP avatar Sep 22 '22 09:09 BonneelP

Awesome! I think it is a good starting point. For me it would be more interesting to run it natively on Linux. Anyone knows how to use XFEMM? Because I think it would be the best solution.

amunozh avatar Sep 22 '22 10:09 amunozh

Hi, I am interested in running the GUI in linux but I found that newer pyleecan versions fail due to pythoncom (pywin32) in FEMM_Handler.py. Is there any way to disable FEMM handler in order to just open the GUI in Linux with no FEMM coupling?
Best, Alejandro

ajpina avatar Nov 05 '22 22:11 ajpina

Hi, I think the PR 'basic linux support' in the pull requests should allow you to open the GUI. In that FEMM_Handler supports both linux and windows. Otherwise, if you use the pyleecan exe installer through wine, the GUI should open also. (See above for one winetricks command you might need to run) harsha

harshasunder-1 avatar Nov 06 '22 07:11 harshasunder-1

FYI there is a new release of xfemm, which fixes some long standing bugs, introduces the air gap element (which implements a sliding mesh scheme to avoid remeshing) and includes a program femmcli which can run lua scripts just like FEMM.

Your python code could generate a lua script to run a simulation if you didn't want to directly link to the code.

It also includes a ctest based test suite to improve reliability of releases in the future.

It also includes the code to do frozen permeability simulations implemented in FEMM, for more accurate time-stepped simulations, but I confess this has not been extensively tested. I would welcome PRs to add tests for this.

crobarcro avatar Apr 04 '23 20:04 crobarcro