====pyFEMM -- A Python Interface to FEMM==== pyFEMM is a Python interface to Finite Element Method Magnetics (FEMM). The module uses win32com to communicate with FEMM's out-of-proc activex server. The functions in the module wrap interactions with FEMM, making it easy to script FEMM from a Python program. FEMM is available from the **[[download|Download]]** page. The pyFEMM package is available for download **{{:upload:pyfemm:pyfemm-0.1.1.tar.gz|here}}** or from **[[https://pypi.python.org/pypi/pyfemm/0.1.1|PyPI]]**. Documentation is available at **[[https://www.femm.info/wiki/pyFEMM/manual.pdf]]** **Versions:** //v0.1.3, 20Jul2021// * Support for non-Windows machine using a file-based message passing scheme like the one used by FEMM to support legacy or Linux and Mac version of Octave (big thanks to Melina Merkel) * Fixed an error in the "doargs" function that broke complex numbers being returned by FEMM * Fixed a bug in "ci_setnodeprop" * Added "mi_setcomment", "ei_setcomment", "hi_setcomment", and "ci_setcomment" functions to allow the comment field in the problem definition to be programmatically defined //v0.1.1, 11May2020// Bug fix update. * Fixed errors in the implementation of ''ci_smartmesh'', ''mi_smartmesh'', ''ei_smartmesh'', and ''hi_smartmesh'' functions * Fixed error in ''mo_showcontourplot'' //v0.1.0, 17Mar2018// Initial release. ===Examples=== Several examples show how to use Python to do scripting with FEMM. Most of these examples are presented in Matlab, Mathematica, and Scilab formats in the examples directory of the FEMM distribution. ==DC Magnetics: Coilgun Example== {{:upload:pyfemm:coilgun.zip|Coilgun.zip}} contains a Python script and a FEMM model for the problem discussed on the [[coilgun|CoilGun]] page. The Python script is a port of the original Lua version. The Matplotlib package is used to make a Matlab-like plot of the resulting forces projectile. {{https://www.femm.info/examples/coilgun/coilgun_files/image002.jpg}}{{:upload:images:pyfemm_coilgun_force_sm.png|pyFEMM_coilgun_force_sm.png}} Figure 1: Plot of force on projectile created by coilgun.py using the Matplotlib package. ==DC Magnetics: Demo2 Example== {{:upload:pyfemm:demo2.py|Demo2.py}} builds a coil with an iron core and plots flux density in the core. {{:upload:images:pyfemm_demo2.png|pyFEMM_demo2.png}} ==Electrostatics: Microstrip Example== {{:upload:pyfemm:strips.py|strips.py}} computes the capacitance of coupled microstrip lines. {{:upload:images:pyfemm_strips.png|pyFEMM_strips.png}} ==Heat Flow: Microstrip Example== {{:upload:pyfemm:htutor.py|htutor.py}} computes the heat flow through a rectangular chimney. {{:upload:images:pyfemm_chimney.png|pyFEMM_chimney.png}} ==Current Flow== {{:upload:pyfemm:acelec2.py|ACElec2.py}} Cylindrical capacitor as described [[http://quickfield.com/help/QuickField.chm/html/Examples/ACElec2_CylindricalCapacitor.htm|here]]. {{:upload:images:pyfemm_acelec2.png|pyFEMM_ACElec2.png}} ==DC Magnetics: Roters1b Example== {{:upload:pyfemm:roters1b.zip|roters1.zip}} is the same as [[rotersexample|RotersExample]] but with a 0.8A coil current. {{https://www.femm.info/examples/roters1b/roters1b_files/image002.jpg}}\\ {{:upload:images:pyfemm_roters_results.png|pyFEMM_roters_results.png}} ==AC Magnetics: 3-Phase Power Line Example== {{:upload:pyfemm:phase3.py|Phase3.py}} models a three-phase power line in an unbounded region carrying balanced currents. The script returns the per-meter impedance of each line: The per-meter 60Hz impedance of each line is 3.807e-05+0.0001629j Ohms {{:upload:images:phase3.png|Phase3.png}}