Advices to couple CAD tools with MCNP and Geant4


Here's a tutorial for CAD to MCNP/Geant4 coupling.
It summarizes weeks of exhaustive attempts with Marc Krauth and Christophe Ruescas.
Off-the-shelf solutions do not exist but a few tools are doing great.
After a brief warning and a description of the benchmark data, the most relevant results are presented for each software:
first for MCNP (section 3), then for Geant4 (section 4).
Some advices are given at the end.

In the following, the notation MCsc is used as a short for Monte Carlo simulation code.
I'll then speak of CAD2MCsc softs/tools for softwares enabling to convert CAD files to MCsc input files.


1. Warning

All CAD2MCsc softwares import STEP files (.st[e]p).
So first make sure your CAD soft exports .step files.

I made the mistake at the beginning, using Google Sketch'Up (GSU) which is a nice free CAD soft everybody can install on its own machine.
Unfortunately, it does not export in .step and I lost several tens of hours trying bunches of softwares
(CATIA, AutoCAD, TurboCAD, gCAD3D, Acrobat3D, CrossCAD, DataCAD, Moritz, MCNP Vised, MCAM, ...)
to create a .step file of my model from all the available GSU export formats (.wrl, .x3d, .3ds, .igs, .stl, .ics, .dae, .mtl, .obj, .fbx, .sat, .brep, ...), in vain!

CAD format conversion is really a nightmare! Avoid it as much as you can!

According to me, the smartest thing to do is to work with Catia since it is the IN2P3 official CAD soft (and of course includes .step exportation).
You can install it on your own machine at lab and you'll always find someone from the mechanics team to help you
( Marc Krauth, Christophe Ruescas, Thierry Goeltzenlichter, Valeria Zeter, ...).
Only snag, Catia's not free.


2. Benchmark

Loads of pieces have been created by Marc Krauth, in order I can test the limits of the CAD2MCsc tools I found googling around and browsing literature.
A particular attention has been paid to the way pieces were created (boolean operations or not, ...).
This does not seem to have any impact at the MCsc level.
So don't bother too much.

The response of each CAD2MCsc tool is described in the following sections.
But we can already mention a few results:


source:mtrocme/cad/catia_01.png


source:mtrocme/cad/catia_02.png

source:mtrocme/cad/catia_03.png


source:mtrocme/cad/catia_04.png


source:mtrocme/cad/catia_05.png


3. CAD tools for MCNP


All CAD tools for MCNP are for Windows users only.
Depending on the licence type, some might be installed on xxx. Contact xxx.


3.1. Moritz :-((

Homepage / CAD page

Lots of mails have been (indirectly) exchanged with the developer that is keen to answer. (Thanks to Amokrane Allaoua, amokrane.allaoua@irsn.fr)
But the import functions provided (for STEP or VRML files) are just fancy features and tests with basic geometric volumes fail miserably.
Furthermore, no development is scheduled in a near future. So forget about it.
It nevertheless remains a very nice (but not free) visualization tool (see e.g. here).


3.2. Vised (MCNP VISual EDitor) :-(

Homepage / CAD page

Since the 22XS release, some CAD possibilities are offered, especially SAT files (.sat) can be imported.
Nevertheless I don't recommend its use for two reasons:

  1. All the tests we made with Christophe Ruescas, although juggling with 7 import options, were not convincing.
  2. AutoCAD is no more used at lab (almost nobody will be able to help you).

Yet, as for Moritz, it remains a very nice visualization tool (see below) and it's free for MCNPX beta-users (ask xxx).


3.3. MCAM :-)))

Homepage

3.3.1. Introduction

This tool originates from the fusion community (see here) and is by far the best you could find!
It is freely available. Just send a mail to the FDS team (fds@ipp.ac.cn).

MCAM is really designed to convert CAD files to MCsc input files.
It can import STEP (.st[e]p), SAT (.sat) or IGES (.ig[e]s) files and contains lots of smart functions such as:
scaling a whole volume, checking and fixing gaps and overlaps, decomposing a complex cell into basic ones, glueing cells together, ...

Further nice options are available.
Materials and names can be directly assigned to each cell directly in MCAM (a same material can be assigned to several cells in one go).
You can also create via Tools/Write MCNP a complete MCNP file by specifying a Material file (watch out the density line position! See e.g. my own file),
a SDEF file and a Tally file. They will be parsed (material density) then appended properly.

But that's not all folks! MCAM's more powerful than that!
Indeed, you can also

3.3.2. Using the decompose function?

From the manual, once you've imported your .step file (File/New, File/Import), all you have to do to create the MCNP file is to click:

  1. Preprocess/Heal (removing possible geometry errors)
  2. Preprocess/Scale and enter 0.1 as a scaling factor
  3. Preprocess/Decompose (cell splitting for a best MCNP export)
  4. Preprocess/Check (checking interference between entities)
  5. Preprocess/Reconstruct (removing gaps and overlaps)
  6. Tools/Write MCNP

As shown in the picture below, this approach is far from satisfying.
You'll end up with bunches of odd shaped cells you will have to name and give a material.



source:mtrocme/cad/mcam/mcam_decompose_01.png


I rather recommend to skip the steps 3, 4 and 5 and directly write the MCNP file.
In all the cases I encounter, it went fine...


source:mtrocme/cad/mcam/mcam_decompose_02.png

... all but one



source:mtrocme/cad/mcam/mcam_decompose_03.png

So don't bother!

Alternatively you could also

3.3.3. How good's MCAM?

As abovementioned, no probs with basic volumes.

For fancy-shaped ones, it depends.
It can go fine:


source:mtrocme/cad/mcam/mcam_01.png

or not:



source:mtrocme/cad/mcam/mcam_02.png

(I reported this weird bug to the FDS team. I'll let you know.)



source:mtrocme/cad/mcam/mcam_03.png

In the latter cases, no choice, you will have to simplify the original geometry.

3.3.4. Warning

As illustrated below, do not blindly trust the MCAM output.
Check the result by plotting it in all the viewers you have:

But watch out!
Some viewers (namely Moritz and Vised) are a bit fuzzy (faulty 3D rendering, unrecognition of some MCNP official shapes, ...)
and may not properly display your geometry in 3D whereas there is absolutely no problem.


source:mtrocme/cad/mcam/warning_visu_01.png

In case basic display function fails, try the "3D View/3D Ray Traced Image/Normal 3D Plot" of MCNP-Vised
and play with the different options (lower the resolution to find a nice point of view first). You can use the usual zoom button.


source:mtrocme/cad/mcam/warning_visu_02.png

If you're still not convinced, you may

3.3.5. Notes


4. CAD tools for Geant4


4.1. GDML

Geant4 can only import GDML files.
This requires a specific installation of Geant4 (please see here).
For the time being, only two softwares are able to convert .step files to .gdml files: Fastrad and Esabase2 (see below).
Both are for Windows users only.

4.1.1. Tests' automation

Below's a basic Geant4 program I wrote to convert any .gdml file to any Geant4 visualization driver file (See my G4 tutorial here).
Of course the corresponding drivers should be installed and Geant4 compiled accordingly (see here).
The following outputs are provided: VRML{1,2}, heprep[.zip], Dawn and OpenGL. It's up to you to add more.
>> gdml2G4viz.tgz / doxydoc
Watch out! If you use Fastrad (see below), you cannot directly import the .gdml file generated.
You will have to remove and add some stuff.
The script gdmlify.pl, also included in the above archive, will do that for you.
The z_gdml/ directory contains a .stp file, the GDML output from Fastrad and the resulting file in .wrl (VRML) as an example.
Everything is (should be) explained in the readme file.
Whinge if it's not!

4.1.2. Root GDML binding

Note a GDML binding is included in Root. This can be useful to check your geometry.
To do so, just type the following lines in the Root prompt

----------------------------------------------------------------------------
TGeoManager::Import("myFile.gdml") ; gGeoManager->GetTopVolume()->Draw("ogl") ; ----------------------------------------------------------------------------

Be aware though it rarely works at first time.
You may have to hack your .gdml file commenting some lines and/or changing the "gdml.xsd" location.


4.2. Fastrad

Homepage

4.2.1. Introduction

Fastrad can be downloaded as a free trial after registration.
For Linux users, Fastrad is installed on xxx (the Windows apps server).
Connect using: rdesktop xxx -g 1270x920 -k fr (change your screen resolution and keyboard language accordingly).

Once installed, all you have to do is to

  1. Load your .step file via Translation/Step/Import.
    For curved-shaped volumes, use the highest discretisation for a best renderer and export.
  2. Create the .gdml file Translation/Gdml/Export.
    Save it as a one piece file by answering "no" to the question: "Do you want to save to isolate the tesselated geometries in the GDML project?"

In the trial version, you can also

4.2.2. Tests performed

The following figures resume the tests performed with the above benchmark pieces.
On average, the result is very satisfying.


source:mtrocme/cad/fastrad/fastrad_01.png


source:mtrocme/cad/fastrad/fastrad_02.png


source:mtrocme/cad/fastrad/fastrad_03.png

I've contacted Fastrad for these last cases.

4.2.3. Notes


4.3. Esabase2

Homepage / CAD functions

4.3.1. 1st challenge: Getting the soft

To get the soft, register on the website and be (very) patient...
Do not hesitate to contact the developer (Karl Dietrich Bunte, K.Bunte@etamax.de) if it lasts too long.
You will receive a contract (paper) you will have to sign and send back.
Some days later, you'll get an email with your ID (login/psw), giving you access to the download area.

4.3.2. 2nd challenge: Doing something...

Once you have it, good luck!
I didn't have much time to try it but I didn't manage to do anything (even displaying the provided .step files).
I was a bit discouraged by the fact that:

If you can go further (I'm sure you can), please let me know.


5. Epilogue

5.1. Advices for people starting from scratch

5.2. How I would work today...

If you're planning to design something with the mechanics team, ask them to create a toy model in parallel
to the true model that will be used for machining, making sure this toy model roughly respects the abovementioned advices.
Superimposing 2 geometries in one file and hide one or the other is possible in Catia. The STEP conversion will only care about the visible one.

Good luck!

5.3. Feel free to contribute!

This work is far from finished.
Further tests would be necessary to enrich this page.
Almost all the tests made so far are stored on xxx (ask xxx).

A useful improvement would be material importation from Catia.
I didn't have time to work on it but that would really be time-saving...

5.4. Acknowledgements

Thanks again to Marc Krauth and Christophe Ruescas for their invaluable help.


Back to Table of Contents
Copyright: Mathieu Trocmé, Mon 28 Dec 2009 (14:13:46)