Skip to content
Munther Hindi edited this page Mar 13, 2022 · 74 revisions

Welcome to the GDML Workbench Wiki !

!!!! ***** UNDER CONSTRUCTION ***** !!!!

Geometry Description Markup Language (GDML) is a specialized XML-based language used to specify
Geometries for Monte Carlo Simulation software such as ROOT, Geant4, etc see GDML Manual.

It defines a rich set of Solid Computer Graphic Objects for details of GDML Solids

The GDML Workbench lets the user

  • Import
  • View
  • Edit
  • Create
  • Export

Such Geometries.

Selecting/Activating the GDML workbench

From the FreeCAD command bar select View | Workbench then select GDML

Workbenches

FreeCAD Setup for Workbench use.

It is recommended that when you have the GDML workbench active that the following Toolbars are viewable

  • Workbench
  • Structure
  • GDMLTools
  • GDML Part Tools

So Icons displayed should look similar to the following

Icons

To make a Toolbar viewable, from the FreeCAD command bar select View | Toolbars

GDML Objects / Solids

GDML Solids

GDML Solids are implemented as FreeCAD Python Objects and have the same properties as defined by GDML. By selecting an Object the properties can be changed via the FreeCAD properties windows and the resulting changes displayed.

GDML Objects Currently Supported for creation via the GUI are

GDMLBox

GDML_Box-Icon Short decription

GDMLCone

GDML_Clone-Icon Short decription

GDMLElTube

GDML_EllipticalTube-Icon Short decription

GDMLEllipsoid

GDML_Ellipsoid-Icon Short decription

GDMLSphere

GDML_Sphere-Icon Short decription

GDMLTrap

GDML_Trapezoid-Icon Short decription

GDMLTube

GDML_Tube-Icon Short decription

Given a lot more solids are supported for import, it is not too difficult to add more, so if you feel you need a particular solid to be added please contact me.

Boolean Operations

Select two Parts/Logical Volumes and then click on the appropriate boolean icon

Importing Files

Importing a STEP file and creating GDML Tessellated Objects

Viewing a GDML Model

Modifying a GDML Model

Creating a GDML model from scratch

GDML Model Creation

Export/Import - Materials XML files

When creating a new file from the GDML workbench the file Defaults.gdml is read from the Resources directory, this may or may not have material definitions, as supplied there are none.

A Materials Group called Geant4 is created by reading the file Geant4Materials.xml from the Resources directory which define all the materials that GEANT4 implicitly defines by default.

When a file is exported the the materials in the geant4 group are ignored as GEANT4 implicitly defines these.

If you need the Geant4 materials for use in a none GEANT4 situation, for example ROOT, then one option is to

  • Select the geant4 group.
  • export as an xml file
  • import the xml file

This should add the materials in the main materials definitions which should be exported in any subsequent GDML exports

Mesh Operations

FreeCAD Objects (Non-GDML)

In addition to the GDML solids, the GDML Workbench supports the export of a subset of the solids one can create in the FreeCAD Parts Workbench. These are documented below. For those shapes not directly supported for export, the recommended way to proceed is to take the resulting BREP (Boundary Representation) Shape and then translate it to a GDML Tessellate, or use some software like McCad to decompose the BREP Shapes into GDML Objects.

The GDML Workbench provides a number of facilities to

  • Export FreeCAD(BREP) shapes as GDML Tessellated Objects.

  • Allocate a GDML Material and directly Convert a FreeCAD(BREP) Shape to a GDML Tessellated Object
    using a number of different algorithms

    • Standard FreeCAD mesh facilties
    • Gmsh
    • Tetrahedron (This does not directly translate to GDML, but to a GDML Assembly of GDML Tetra)

Part Objects directly exportable to GDML

(Note some of these are currently only supported in the Beta2 branch)

Extruded Sketches

Shapes created by the Sketch Workbench and extruded via the Part Extrude command can be exported to GDML. The exrusion must be added to a Part under the worldVol tree. Currently extrusion exports have the following limitations: (1) only extrusions along the z-axis are supported (i.e., the sketches must be in the x-y plane). Note that this does not pose a real limitation, since the extrusion object itself can be rotated or translated to any desired orientation or location. (2) Arcs/elliptical whose chords are crossed by lines (or other arcs) cannot currently be processed. Arcs/lines that are completely inside or outside other arcs, are supported, though. Examples of Extruded sketches are in Extruded sketches examples

Exporting GDML files

To export a GDML file, select the root Part ( GDML World Volume ) then use the standard FreeCAD export facility ( File | Export )

Single GDML file

If a filetype of lowercase gdml is selected a single GDML file is produced.

Multi GDML file

If a filetype of uppercase GDML is selected then the following files are created in a directory derived from the path name less the GDML file extension.

  • A [Name].gdml with imbeds for the following xml files
  • setup.xml
  • constants.xml
  • defines.xml
  • materials.xml
  • [Name]-solids.xml
  • [Name]-structure.xml

Note: Provided you have the lxml python library installed, you should be able to successfully open the [Name].gdml file

GDML - Multi Files

ROOT only supports GDML defined in a single file, as it does not support the required DOCTYPE !ENTITIES.

There are two options

  1. Open the multi file with the workbench and then export with as a single GDML file.

  2. Use the standalone python program supplied in Utils

    combineGDML.py [input file with imbeds] [output single file]

Such multi files are supported by Geant4.

STEP files

When exporting STEP files that include GDML objects set the FreeCAD Preference for Export to use legacy exporter

Export STEP

Command line utilities

Processing a Volume for subsequent Finite Element (FEM) Analysis

Installation - For Installation see the README