Adding a computational electromagnetics workbench

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Ravn
Posts: 8
Joined: Fri Apr 25, 2014 6:49 am

Adding a computational electromagnetics workbench

Post by Ravn »

Hi Guys,

I am an electrical engineer who has been using FreeCAD on an off for some time now as a user. The project is really cool! Professionally I do some electro -magnetics simulations. There is a FOSS (GPL) package developed by MIT called MEEP http://ab-initio.mit.edu/wiki/index.php/Meep which is quite fast and competent. However the geometry is defined in a script file using the Scheme language. Computed results from MEEP are output to the open data format HDF5.

I was thinking to add a Workbench to FreeCAD to support defining the simulation geometry for MEEP in FreeCAD. The idea would consist of the following steps:
- Create a new export type (.ctl) which exports the selected geometry to a scheme script for later execution by MEEP.
- Create read-capability of HDF5-datafiles to plot resulting field quantities in the 3D FreeCAD view after simulation finished.

To get this going nicely, some things needs to be implemented in FreeCAD:
- Support for electromagnetic material properties like dielectric constant and other stuff that MEEP supports to simulate.
- Support for some special materials and regions in FreeCAD like
* PML which is an artificial material used to define boundaries in FDTD simulations
* Bounding box
* Source and sink regions. I am not sure how these should be defined, but I was thinking maybe these can be derived from Part::Box since they always have that shape in MEEP.
- A settings dialog for the new workbench where some special settings used by MEEP can be defined.

How does the FreeCAD people feel about this? With the suggested approach, FreeCAD will not be linked to MEEP, but only use the MEEP binary. So far I managed to export some of the geometry to the .ctl-files and that seem to work well. I am now working not getting the Workbench up and running, but it would be great to get answers here on some questions that I think will pop up. In particular it would be nice to get some hint on defining these new materials I was discussing above. How should that be done? I know that there is some work on materials en FreeCAD, could these things fit to that?

Cheers,
Robert
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Adding a computational electromagnetics workbench

Post by ian.rees »

Hi Robert,

Sounds like a very interesting proposal you have! I'd love to see it working. Assume you've already had a look through the FEM forum at all the recent work there?

You've probably already seen the recent discussion regarding materials here viewtopic.php?f=23&t=10503 . Although I haven't personally had much reason to use materials in FreeCAD yet, I think it would be good if different workbenches were consistent in their material handling within FreeCAD. Seems like it shouldn't be a problem to have both mechanical and EM properties for relevant materials, perhaps the UI could have a filter such that when I'm picking materials for an EM simulation, the default is to only show materials that have EM properties specified?

Would it make sense to have some special "materials" that are the source or sink? -Ian-
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Adding a computational electromagnetics workbench

Post by PrzemoF »

My suggestions:
1. Add whatever material properies you want to existing material files - we want to converge Arch and Mechanical materials into one category (work it progress)
2. Your workflow is more or less what's in the FEM wb. Create geometry -> export .inp -> run CalculiX -> import results -> show results
If you're interested to check how CalculiX import/export is handled check ccxInpWriter and ccxFrdReader files in the FEM wb. We're using external ccx (CalculiX) binary, location can be defined by user in FEM preferences.

P.S. MEEP seems to have a python interface - maybe export-import is not necessary?
Ravn
Posts: 8
Joined: Fri Apr 25, 2014 6:49 am

Re: Adding a computational electromagnetics workbench

Post by Ravn »

PrzemoF wrote:My suggestions:
1. Add whatever material properies you want to existing material files - we want to converge Arch and Mechanical materials into one category (work it progress)
2. Your workflow is more or less what's in the FEM wb. Create geometry -> export .inp -> run CalculiX -> import results -> show results
If you're interested to check how CalculiX import/export is handled check ccxInpWriter and ccxFrdReader files in the FEM wb. We're using external ccx (CalculiX) binary, location can be defined by user in FEM preferences.

P.S. MEEP seems to have a python interface - maybe export-import is not necessary?
Thanks PrzemoF,

Yes, the workflow is very simliar to the FEM module. Everything is more or less the same, just other equations to solve in the solver :)

I know MEEP has a python interface, but it's third-part and I have not used it, so I believe sticking with the ctl-file will be fine to start with. Exporting to that format is more or less done. What I need now is to work on the materials. And then a general question for everyone is if there is any documentation on how to make a new Workbench? Is there some API that I can read?
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Adding a computational electromagnetics workbench

Post by sgrogan »

Module_Creation
Has any one seen anything on compiling MEEP on Windows?
"fight the good fight"
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Adding a computational electromagnetics workbench

Post by ian.rees »

From a quick search, I found a few-years-old thread on MEEP for Windows, using cygwin - http://permalink.gmane.org/gmane.comp.s ... neral/3428 . -Ian-
mckonga
Posts: 1
Joined: Wed Aug 19, 2015 2:32 pm

Re: Adding a computational electromagnetics workbench

Post by mckonga »

Hi guys,

even if this is a pretty old post I would be interested, if the .ctl generation for MEEP is already existing or still "nice to have".
This feature would be extremely helpful for some users.

Cheers,
T.
Post Reply