Testing package and running examples with dependencies installed via Conda
Testing package and running examples with dependencies installed vua PIP
Testing with Model Benchmark Zoo
A minimal package that converts CAD geometry to DAGMC (h5m) files, unstructured mesh files (vtk) and Gmsh (msh) files ready for use in neutronics simulations.
cad-to-dagmc can create DAGMC compatible:
- surface meshes / faceted geometry / triangular meshes
- unstructured mesh / tetrahedral meshes / volume meshes
cad-to-dagmc can convert the following in to DAGMC compatible meshes:
- STEP files
- CadQuery objects (in memory)
- Gmsh meshes
Cad-to-dagmc offers a wide range of features including.
- Geometry scaling with
scale_factor
argument - Model wide mesh size parameters with
min_mesh_size
andmax_mesh_size
arguments - Volume specific mesh sizing parameters with the
set_size
argument - Parallel meshing to quickly mesh the geometry using multiple CPU cores
- Imprint and merging of CAD geometry, or disable with the
imprint
argument - Add geometry from multiple sources (STEP files, CadQuery objects and Gmsh meshes)
- Ability to tag the DAGMC implicit complement material using the
implicit_complement_material_tag
argument - Selected different Gmesh mesh algorithms (defaults to 1) using the
mesh_algorithm
argument - Pass CadQuery objects in memory for fast transfer of geometry using the
method
argument - Easy to install with pip and Conda/Mamba
- Well tested both with CI unit tests, integration tests and the CSG Model Benchmark Zoo.
- Compatible with Paramak geometry for fusion simulations.
- Install using Mamba
- Install using Conda
- Install using pip and source compilations
In principle, installing any Conda/Mamba distribution will work. A few Conda/Mamba options are:
This example assumes you have installed the Miniforge option or separately have installed Mamba with conda install -c conda-forge mamba -y
Create a new environment, I've chosen Python 3.10 here but newer versions are also supported.
mamba create --name new_env python=3.10 -y
Activate the environment
mamba activate new_env
Then you can install the cad_to_dagmc package
mamba install -y -c conda-forge cad_to_dagmc
In principle, installing any Conda/Mamba distribution will work. A few Conda/Mamba options are:
Create a new environment, I've chosen Python 3.10 here but newer versions are also supported.
conda create --name new_env python=3.10 -y
Activate the environment
conda activate new_env
Then you can install the cad_to_dagmc package
conda install -y -c conda-forge cad_to_dagmc
It is also possible to avoid the use of conda/mamba and installing using pip.
First ensure hdf5 is installed as this is needed by MOAB pip install command
sudo apt-get install libhdf5-dev
Then clone the latest version of MOAB and cd into the moab directory.
git clone master https://bitbucket.org/fathomteam/moab/
cd moab
Ensure pip is up to date as a new version is needed
python -m pip install --upgrade pip
Run the pip install command with cmake arguments.
pip install . --config-settings=cmake.args=-DENABLE_HDF5=ON
Then you can install the cad_to_dagmc package with pip
pip install cad_to_dagmc
You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others link to DAGMC documentation.
To install OpenMC you can run mamba install -c conda-forge openmc
however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
mamba install -c conda-forge -y "openmc=0.15.0=dagmc*nompi*"
It might not be possible to install OpenMC and cad-to-dagmc in the same conda/mamba python environment so you may have to create a new conda/mamba environment and install OpenMC there.
Another option would be to install OpenMC from source which would also need compiling with MOAB and DAGMC options.
The package requires newer versions of Linux. For example the package does not work on Ubuntu 18.04 or older.
The package requires newer versions of pip. It is recommended to ensure that your version of pip is up to date. This can be done with python -m pip install --upgrade pip
Installing one of the package dependancies (Gmsh) with pip appears to result in errors when passing cad objects in memory between cadquery / ocp and gmsh. The default method of passing cad objects is via file so this should not impact most users. The conda install gmsh appears to work fine with in memory passing of cad objects as the version of OCP matches between Gmsh and CadQuery.
For examples showing creation of DAGMC h5m files, vtk files and usage within OpenMC transport code see the examples folder
For more examples see the CAD tasks in the neutronics-workshop and model benchmark zoo
Also checkout these other software projects that also create DAGMC geometry CAD-to-OpenMC, Stellarmesh and Coreform Cubit.