Giter VIP home page Giter VIP logo

g4cad's Introduction

DOI

G4CAD - A FreeCAD workbench for converting CAD files to GDML

Physicists usually spend most of the time developing the mass model when developing a Geant4-based Monte Carlo simulation package. For simple geometries, it is relatively easy to describe them using CGS models. However, this becomes almost impossible for complex geometries. G4CAD is a free, open-source FreeCAD workbench. With the workbench and FreeCAD, users can

  • import and edit CAD files
  • set materials and material management. Users can define their own materials and set the predefined materials for different solids
  • add simple CGS models
  • set the tessellation tolerance for each individual solid
  • convert models to GDML files

G4CAD also provides other tools useful for creating mass models and converting CAD files to GDML, like measuring tools, tools to find/remove small solids.

Installation

Make sure you have already installed FreeCAD 0.19 or 0.20 (should also work with v0.17 and v0.18).

  • To install it on Linux, execute the following commands:
  git clone --depth 1 https://github.com/drhlxiao/g4cad
  mkdir -p ~/.FreeCAD/Mod
  cp -r g4cad/g4cad ~/.FreeCAD/Mod
  • To install it on Windows, please follow the steps as follows:

More information about installing FreeCAD workbenchs can be found at https://wiki.freecadweb.org/Installing_more_workbenches

Typical Workflow

  1. Open FreeCAD
  2. Activate the workbench "G4CAD" in FreeCAD (View->Workbench->G4CAD)
  3. Import a CAD file
  4. Click the icon "add world volume" in the G4CAD toolbar to add a world volume
  5. Select a solid or multiple solids, set material(s)
    • If not set, the default material G4_Al is used when exporting
    • Adding more materials: open the file user_materials.json in the source code folder, open it with a text editor, add materials to it, validate the json file before saving it.
  6. Select the solids in the tree view to be exported
  7. click the button "Export solids to GDML files" in the toolbar to generate GDML files
    • Only visible solids will be exported
    • If everything goes well, GDML files will be written to gdml/ in your specified folder and a log file will also be created.
  8. Reading the exported GDML files in Geant4 Here is a code snippet
G4VPhysicalVolume* DetectorConstruction::Construct(){
G4String worldGdmlFilename="<GDML_PATH>/gdml/World.gdml"
G4GDMLParser parser;
parser.Read(worldGdmlFilename);
world = parser.GetWorldVolume();     
//other code goes here
  return world;
}

Extended services

Extended services related to this tool can be provided by SE2S Ltd.

SE2S GmbH is a Swiss-based high-tech company with over 30 years of experience in radiation qualification, particle detection, and data analysis. Its founders gathered profound expertise in radiation qualification and testing, electronics design, hardware and software development, and data evaluation for applications in aerospace. SE2S GmbH offers next-generation services and products in the following fields:

  • Radiation detection systems
  • Radiation analysis software and services
  • Radiation qualification and testing services

For more info about SE2S, please visit: https://se2s.ch

Screenshot

  • G4CAD Workbench g4cad workbench

Cite this work

If you use G4CAD in your work, please use the following citation,

@software{g4cad,
  author       = {Hualin Xiao, Wojtek Hajdas},
  title        = {{G4CAD - A FreeCAD Workbench for converting CAD 
                   files to gdml}},
  month        = sep,
  year         = 2022,
  publisher    = {Zenodo},
  version      = {v1.0},
  doi          = {10.5281/zenodo.7085915},
  url          = {https://doi.org/10.5281/zenodo.7085915}
}

Reporting issues, contributing code, contacting me

  • If you find issues, please create an github issue on this repo
  • If you want to contribute code, please create a pull request
  • send an email to [email protected] if you have anything else

web-based CAD to GDML converter

We also developed a web-based CAD to GDML converter. URL: http://polar.psi.ch/cadmc/converter/

g4cad's People

Contributors

drhlxiao avatar

Forkers

alexaerphys

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.