Converts CAD files to a DAGMC h5m file
Project description
Single volumes pass tests :heavy_check_mark:
Multiple non touching volumes pass tests :heavy_check_mark:
Multiple touching volumes FAIL tests :heavy_multiplication_x:
Assigning material tags to correct volumes NON EXISTENT tests :heavy_multiplication_x:
A minimal package that uses CadQuery functionality to convert Cad geometry to DAGMC h5m files
This particular method of producing DAGMC compatible h5m files from CAD geometry is intended to convert STP files or CadQuery objects to h5m file.
The use of CadQuery based surface tesselation and then conversion of the vertices and triangle sets into h5m files directly (in memory) is relatively fast with minimal file IO and the resulting meshed volumes have low triangle count while maintaining a good representation of the volume as described in this publication.
While this package concentrates on loading the CAD and meshing the surface it then hands off the vertices and triangles sets to vertices_to_h5m which converts these into a h5m geometry file. Due to the modularity of this workflow if you have a preferred meshing algorithm then it is entirely possible to pipe your own vertices and triangles directly into vertices_to_h5m.
Install
You will some dependencies installing (moab, pymoab and cadquery).
conda install -c conda-forge mamba
mamba install -c conda-forge moab
mamba install -c cadquery -c conda-forge cadquery=master
There you can install the cad_to_dagmc
package
pip install cad_to_dagmc
To use the h5m geometry you will need a transport code with DAGMC enabled such as OpenMC. Just to note that currently the conda install for CadQuery and OpenMC can't be installed in the same conda environment. A work around for this is to create the h5m geometry in one conda environment and simulate with OpenMC in another conda environment.
Usage
Produces a tagged h5m file for a STP file with a single part / volume
import cad_to_dagmc
stp_file = cad_to_dagmc.load_stp_file("tests/single_cube.stp")
vertices, triangles = cad_to_dagmc.tessellate(stp_file, tolerance=2)
vertices_to_h5m(
vertices=vertices,
triangles=triangles,
material_tags=["mat1"],
h5m_filename="dagmc.h5m",
)
Produces a tagged h5m file for a STP file with a multiple part / volume
import cad_to_dagmc
stp_file = cad_to_dagmc.load_stp_file("tests/multi_volume_cylinders.stp")
vertices, triangles = cad_to_dagmc.tessellate(stp_file, tolerance=2)
vertices_to_h5m(
vertices=vertices,
triangles=triangles,
material_tags=["mat1", "mat2", "mat3", "mat4", "mat5", "mat6"],
h5m_filename="dagmc.h5m",
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cad_to_dagmc-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8a3c64b29c8c62ce47aad33d41ded7bd5e2006158c1dfff3aea318d9f9f904c |
|
MD5 | 01e1e270b04b69d6df0124017d033ab5 |
|
BLAKE2b-256 | d7b0fe6362855628409c9726e67e2b3c42a33b18c9d932c8991d55eddde8799a |