Skip to main content

N|Python

CI with install

CI with examples

Upload Python Package anaconda-publish

conda-publish PyPI

This is a minimal Python package that provides a Python API interfaces for converting mesh vertices into a DAGMC h5m file ready for use in simulation.

Convert a set of vertices with their connectivity in to a DAGMC h5m file complete with material tags and ready for use neutronics simulations.

warning this approach does not imprint and merge the geometry and therefore requires that the mesh is well formed and does not overlap. Overlaps could lead to particles being lost during transport. If imprinting and merging is required consider using Paramak export_dagmc_h5m() method or cad-to-h5m to make the DAGMC geometry.

It is strongly advised to used the DAGMC overlap checker to check the resulting h5m file (see checking for overlaps section below).

Installation - Conda

This single line command should install the package and dependencies (including moab)

conda install -c fusion-energy -c fusion-energy vertices_to_h5m

Installation - Pip + Conda

These two commands should install the package and dependencies. Moab requires a separate install as it is not available on pip

conda install -c conda-forge moab
pip install vertices_to_h5m

Examples

These examples with volumes made from just four triangles to keep the examples minimal. The package can also convert larger meshes as shown in the picture below.

Usage - single volume

To convert a single volume mesh into a h5m file. This also tags the volume with the material tag mat1.

from vertices_to_h5m import vertices_to_h5m
import numpy as np

# these are the x,y,z coordinates of each vertex. Entries should be floats 
vertices = np.array(
    [
        [0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0],
        [0.0, 0.0, 1.0],
    ]
)


# These are the triangle that connect individual vertices together to form a continious surface and also a closed volume. Entries should be ints
triangles = [
    np.array([[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]]),
]


# This will produce a h5m file called one_volume.h5m ready for use with DAGMC enabled codes.
vertices_to_h5m(
    vertices=vertices,
    triangles=triangles,
    material_tags=["mat1"],
    h5m_filename="one_volume.h5m",
)

single_volume

Usage - multiple volumes

To convert multiple mesh volumes files into a h5m file. This also tags the relevant volumes with material tags called mat1 and mat2. This example also uses numpy arrays instead of lists, both are acceptable.

from vertices_to_h5m import vertices_to_h5m
import numpy as np

# These are the x,y,z coordinates of each vertex. Numpy array is set to type float to enforce floats
vertices = np.array(
    [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 1], [1, 1, 0]], dtype="float64"
)

# These are the two sets triangle that connect individual vertices together to form a continious surfaces and also two closed volume.
triangles = [
    np.array([[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]]),
    np.array([[4, 5, 1], [4, 5, 2], [4, 1, 2], [5, 1, 2]]),
]

# This will produce a h5m file called two_volume_touching_edge.h5m ready for use with DAGMC enabled codes
vertices_to_h5m(
    vertices=vertices,
    triangles=triangles,
    material_tags=["mat1", "mat2"],
    h5m_filename="two_volume_touching_edge.h5m",
)

two_volumes

Checking for overlaps

To check for overlaps in the resulting h5m file one can use the DAGMC overlap checker. -p is the number of points to check on each line

conda install -c conda-forge
overlap_check dagmc.h5m -p 1000

Metadata

Release files for vertices-to-h5m 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vertices-to-h5m 0.1.7
File Size Uploaded
vertices_to_h5m-0.1.7.tar.gz 345.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vertices-to-h5m 0.1.7
File Interpreter ABI Platform
vertices_to_h5m-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 351.7 kB

Release files / vertices_to_h5m-0.1.7.tar.gz

Download URL vertices_to_h5m-0.1.7.tar.gz
Size 345.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5687a0481b0070255cf10db62168ae5264c6270a37965a85cf5610d20959d732
BLAKE2b-256 checksum
How to use checksums
72aef938b6b7ab551b7b22570b2a73c5477f447011c6ab594310021b10de7b3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / vertices_to_h5m-0.1.7-py3-none-any.whl

Download URL vertices_to_h5m-0.1.7-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fee6c89d3629308f3a65cb44d6d25a4bcc258cae1d41ffcfa2c67a40768f33d9
BLAKE2b-256 checksum
How to use checksums
093557a23b6f73dd32afc717186ed310e9a6a9932c43a857c8b1003d12312b67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page