Skip to main content

Converts CAD files to a DAGMC h5m file using Cubit

Project description

N|Python docker based CI PyPI codecov

This is a minimal Python package that provides both command line and API interfaces for converting multiple CAD files (STP and SAT format) into a DAGMC h5m file using the Cubit Python API.

This is useful for creating the DAGMC geometry for use in compatible neutronics codes such as OpenMC, FLUKA and MCNP.

The geometry is imprinting or merging during the process which can speed up particle transport.

Command line usage

Perhaps the most common use of this program is to convert a STP file into DAGMC geometry.

cad-to-h5m -i part1.stp -o dagmc.h5m -t mat:1 -c /opt/Coreform-Cubit-2020.2/bin/python3/
  • the -i or --input argument specifies the input CAD filename(s)
  • the -o or --output argument specifies the output h5m filename
  • the -t or --tags argument specifies the tags to apply to the CAD volumes.
  • the -c or --cubit argument specifies the path to the Cubit python3 folder
  • the -v or --verbose argument enables (true) or disables (false) the printing of additional details

Multiple STP or SAT files can also be combined and converted into a DAGMC geometry. This example combines two STP files into a single geometry with seperate material tags for each STP file and saves the result as a h5m file.

cad-to-h5m -i part1.stp part2.stp -o dagmc.h5m -t mat:1 mat:2 -c /opt/Coreform-Cubit-2020.2/bin/python3/

It is also possible to convert .sat files in the following way.

cad-to-h5m -i part1.sat -o dagmc.h5m -t mat:1 -c /opt/Coreform-Cubit-2020.2/bin/python3/

Python API usage

Creating a h5m file from a single STP file called part1.stp and applying a material tag to the volume.

from cad_to_h5m import stp_converter

stp_converter(
    input='part1.stp',
    output='dagmc.h5m',
    tags='mat:1',
    cubit_path='/opt/Coreform-Cubit-2020.2/bin/python3/'
)

Creating a h5m file from two STP files called part1.stp and part2.stp. Both parts have distinct material tag applied to them and the result is output as a h5m file.

from cad_to_h5m import stp_converter

stp_converter(
    input=['part1.stp', 'part2.stp'],
    output='dagmc.h5m',
    tags=['mat:1', 'mat:2'],
    cubit_path='/opt/Coreform-Cubit-2020.2/bin/python3/'
)

Creating a h5m file from a single SAT is a similar process.

from cad_to_h5m import sat_converter

sat_converter(
    input='part1.sat',
    output='dagmc.h5m',
    tags='mat:1',
    cubit_path='/opt/Coreform-Cubit-2020.2/bin/python3/'
)

Installation

The package is available via the PyPi package manager and the recommended method of installing is via pip.

pip install cad_to_h5m

Some Python dependencies (such as Numpy) are installed during the pip install cad_to_h5m process, however Cubit needs to be installed seperatly to make full use of this package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cad_to_h5m-0.0.1.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

cad_to_h5m-0.0.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page