FreeCAD GDML Workbench & Geant Workbench

I have a FreeCAD GDML workbench that I would be grateful if people could try out and evaluate. It still needs further work but in its current state one can load all be it very slowly the sample file lhcbvelo.gdml which I believe originally came from CERN.

Rather than convert GDML solids to FreeCAD BREP objects FreeCADs ability to implement objects as Python features is used to implement GDML solids. So by activating the workbench one is offered a number of icons. Selecting one of the icons means a GDML solid is created. One can then change the solids attributes which are the same as in the GDML User Manual via fhe FreeCAD facility to change an objects properties. At present only a subset of GDML solids is implemented, basically all those used in the lhcvelo.gdml file. The plan is to implement more if people think the workbench might prove to be useful. I would like to get some feedback before pressing on.

There is also a sister workbench that uses the ability to call Geant4 from Python. If the plain GDML workbench proves useful then the plan is to look at running simulations under FreeCAD.

For further details of workbenches please see

https://github.com/KeithSloan/FreeCAD_Python_GDML

https://github.com/KeithSloan/FreeCAD_Geant4

For further details of FreeCAD please see
https://www.freecadweb.org/
https://forum.freecadweb.org/

5 Likes

I see that a couple of people have liked the application - Thanks.

Do you have any GDML solids that you would like to see implemented in the shortish term?

Do you have any sample GDML files that the current version does not completely handle?

Thanks “keith at sloan-home.co.uk

By the way is there a way to message users in the forum? Have not found one so far.

Have found a number of sample GDML files at https://github.com/JeffersonLab/remoll which have shown up a number of bugs. Will start trying to address these in a week or so’s time

Update

Seems to now be okay with
remoll / geometry_Mainz / detector_Mainz.gdml
remoll / geometry_Mainz / detector_Mainz.v2.gdml

Going to start work testing
remoll / geometry_sculpt / hybridDaughter_merged.gdml

which needs tessellated function to be added at least.

Latest version should now support loading of a default GDML file and export should create GDML definitions for constants, isotopes, elements, materials the same as imported either from the Default or selected GDML file.

Okay assuming people create a GDML file to allow Monte Carlo simulations via ROOT or Geant4. Is there any mileage in being able to output a STEP or FreeCAD file?

With the workbench implementing GDML solids as FreeCAD Python Objects the created solids therefore have a FreeCAD shape (i.e. OCC shape) for display as well as the GDML solid details. It would therefore not be hard to add the facility to export a STEP or non GDML FreeCAD file. If you think this would be useful please could I trouble you to like this post, so I can gauge response.

1 Like

Like to think code is in reasonable shape to be able to import/open gdml
and use standard FreeCAD export to save STEP file.

If somebody could try and report back.

Thanks

First of all I think this is really nice project and I am definitely following this!
I tried to import some of my handmade GDML files, but it crashes on Nist materials definition. I tried also to make few solids, export and import again, but it does not work at all.
Is there some specific thing I should test for now?

Thanks for your interest.
Are using the latest version on github?

Please could you send some of your handmade files, also exports of the few solids you have tried and do not import correctly. email is at the bottom of the readme.

In SampleFiles you should find

Subdirectory GDML_Solids of SampleFiles should load or report unsupported solid.

Subdirectory CERN has a file lhcbvelo should load although it does take sometime and you have to click on the first wait.

The ones in Alice subdirectory are very large and I have yet to manage to load.

Other files in SampleFiles should load.

If you try at https://github.com/JeffersonLab/remoll

and file detector_Mainz geometry_v2.gdml in geometry_Mainz that should load okay.

When exporting as GDML are you using export, selecting file type as GDML and adding gdml as file extension i.e. test.gdml

[quote] I tried also to make few solids, export and import again, but it does not work at all.
[/quote]

When I added use of App::Part to facilitate STEP export I broke Export :frowning:
Sorry about that. In the process of fixing.

Okay Changing to use FreeCAD Part for Volumes so that hopefully STEP export would retain structure broke a lot of things.

Hopefully they have now been fixed, so if somebody has a small GDML design that they could check if it exports to STEP okay, then that would be appreciated.

Thanks

I know the main use of GDML is to allow Monte Carlo simulations but do people ever need to perform Finite Element Analysis on the same structures?

Analyses of Heat Transfer comes to mind.

I have added an experimental branch called compound to the github repository with the intention of facilitating use of the FreeCAD FEM workbench with GDML.

There is now another experimental branch called scan.

Very large files like Alice.gdml take far far to long to load. So switching to the scan branch means that the file is initially only scanned to a limit volume depth.

You can then expand individual un-expanded volumes by selecting them and clicking on the expand volume.

Would appreciate feedback on this and the compound branch.

note: There is also a branch named comp+scan which is a merge of compound and scan.

Was hoping that my icon designer would have done the business for the new
icons, but for some reason he has not come back to me so at present they are both X’s

New master branch prompts for import or just for scan.

I see the presentation https://agenda.infn.it/event/10937/sessions/908/attachments/4415/4860/Advanced_geometry_GSSI2016.pdf

Has reference to LHCb 5000 volumes and CMS Detector 19,000 volumes.
Is it possible to obtain the GDML files for testing?

Thanks

You can find a version of the CMS geometry in the VecGeom repository along with a set of simple examples. A part of LHCb geometry is available on the CAD-DGML website.

1 Like

Hi @KeithSloan,

The GDML workbench is great and long overdue! I have been using it to create a model of an instrument so that I can use it in Geant4/GRAS. I am having issues with it which are probably due to my lack of understanding of FreeCAD rather than the workbench itself.

However, one important issue that comes to mind is the lack of ability to sketch onto planes other than XY plane. In my instance I have a box with a bevelled edge and I have slotted a circular hole in bevelled surface to accommodate another bit of the instrument’s assembly. Would the gdml export function work for this box? It is difficult to test this with my model as I am getting other unrelated errors which I am currently working through.

All the best, keep up the good work!

Munther has been doing a lot of work exportGDML including supporting of sketch on other Planes.

I plan to create a new branch this evening with lots of enhancements for exportGDML but will not merge with Main until we complete further testing. I will update with name of Branch etc later.

Basically the work as outlined at GitHub - KeithSloan/FreeCAD_GDML_Test_Collection: A set of FreeCAD files created with the GDML workbench - In Future will be used for Auto Testing.
has showed up a number of bug/limitation and each time I go to do a merger, I get a message wait I found something else.

If I understand your situation correctly you would need to create a sketch on one of the Planes and then change the extrusions Rotation part of its Placement or the Part it is in.

Again handling of Placements in either extrusion or Parent Part should be in coming update.

Possibly then doing a Boolean with the rest of the instruments assembly.

I have just created branch TestMerge20-08-24

Should be able to fetch from command line i.e. in FreeCAD’s Mod/GDML directory
git status ( check in right place )

git fetch origin TestMerge20-08-24:TestMerge20-08-24
git checkout TestMerge20-08-24

start FreeCAD

This should support extruding sketches on Planes other than X-Y.

(There may still be at least one outstanding issue with extruded sketches)

Hi Keith, I think I also spotted a bug. When I conduct a second boolean to a body that i have displaced from the origin placement, it appears to maintain that displacement in the BREP representation in FreeCAD, however the export results in a gdml volume that no longer has the displacement and overlaps with another. Is this something you are aware of? Perhaps I should mention it on the workbench github under issues.