Skip to main content

Converts Brep files to a DAGMC h5m file using Gmsh

Project description

N|Python

CI with install

Upload Python Package anaconda-publish

Brep-part-finder is able to search within a Brep file for parts that match user specified properties such as volume, center of mass and bounding box. The matching ID number of the part will be returned if found.

This is useful because the order or parts changes when exporting to Brep files. This part finder package helps keep track of meta data within a workflow. The neutronics workflow makes use of this package to help correctly identify materials when making DAGMC h5m files from Paramak geometries for neutronics simulations.

Installation (Conda)

The installation instructions below create a new conda enviroment and install

conda create --name bpf_env
conda activate bpf_env
conda install -c cadquery -c fusion-energy -c conda-forge brep_part_finder

Installation (Conda + Pip)

The installation instructions below create a new conda enviroment, install CadQuery and install this package. The master branch of CadQuery is currently required as latest features are required. When CadQuery version 2.2 is released then install can target a stable version.

conda create --name bpf_env
conda activate bpf_env
conda install -c cadquery -c conda-forge cadquery=master
pip install brep_part_finder

Usage

To view the properties of the parts in the Brep file the first stage is to import the package and make use of the get_brep_part_properties function.

import brep_part_finder as bpf

my_brep_part_properties = bpf.get_brep_part_properties('my_brep_file.brep')

print(my_brep_part_properties)
>>>{
    1: {
        'Center.x': 0, 'Center.y': 0, 'Center.z': 0,
        'Volume': 10,
        'BoundingBox.xmin': -20, 'BoundingBox.ymin': -20, 'BoundingBox.zmin': -20,
        'BoundingBox.xmax': 20, 'BoundingBox.ymax': 20, 'BoundingBox.zmax': 20
       },
     2: {
         'Center.x': 5, 'Center.y': 6, 'Center.z': 7,
         'Volume': 10,
         'BoundingBox.xmin': -40.0, 'BoundingBox.ymin': -40.0, 'BoundingBox.zmin': -40.0,
         'BoundingBox.xmax': 40.0, 'BoundingBox.ymax': 40.0, 'BoundingBox.zmax': 40.0
        },
     3: {
         'Center.x': 0, 'Center.y': 0, 'Center.z': 0,
         'Volume': 10,
         'BoundingBox.xmin': -10, 'BoundingBox.ymin': -10, 'BoundingBox.zmin': -10,
         'BoundingBox.xmax': 10, 'BoundingBox.ymax': 10, 'BoundingBox.zmax': 10
        } 
    }

From the above dictionary it is possible to identify parts from their central of mass (x,y,z coordinate), volume and bounding box. This can be done manually or one can pass the required properties into the find_part_id or find_part_ids functions to identify the part numbers of solids automatically.

A minimal example that finds the part id numbers with matching volumes

import brep_part_finder as bpf

my_brep_part_properties = bpf.get_brep_part_properties('my_brep_file.brep')
part_id = bpf.find_part_id(
    brep_part_properties=my_brep_part_properties,
    volume=10,

)

print(part_id)
>> [1, 3, 4]

The above example found 3 part ids with matching volumes.

The follow example also specifies the center of mass which helps narrow down the part ids to just to matching parts.

import brep_part_finder as bpf

my_brep_part_properties = bpf.get_brep_part_properties('my_brep_file.brep')
part_id = bpf.find_part_id(
    brep_part_properties=my_brep_part_properties,
    volume=10,
    center_of_mass=(0,0,0),
)

print(part_id)
>> [1, 3]

In the this example the bounding box of the part has also been specified and these three pieces of information are enough to find one part that matches all three criteria.

import brep_part_finder as bpf

my_brep_part_properties = bpf.get_brep_part_properties('my_brep_file.brep')
part_id = bpf.find_part_id(
    brep_part_properties=my_brep_part_properties,
    volume=10,
    center_of_mass=(0,0,0),
    bounding_box = [[10,10,10], [-10,-10,10]]
)

print(part_id)
>> [3]

For more usage examples see the examples folder in this repository

Combining with Paramak

When reactor models made with Paramak are exported to Brep files it is likely that the order of parts in the Brep file does not match the order of parts within the Paramak object. Therefore this program is useful when identifying parts in the Brep file. See the paramak_example file in the examples folder of this repository.

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

brep_part_finder-0.3.16.tar.gz (75.4 kB view details)

Uploaded Source

Built Distribution

brep_part_finder-0.3.16-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file brep_part_finder-0.3.16.tar.gz.

File metadata

  • Download URL: brep_part_finder-0.3.16.tar.gz
  • Upload date:
  • Size: 75.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for brep_part_finder-0.3.16.tar.gz
Algorithm Hash digest
SHA256 c25aed7c210b53b783535a1464a1ced4cbcc5c205a8d13c64cfb6ed1a0d035e4
MD5 3e1c6ed21798a4a4f978e120c3b39ca5
BLAKE2b-256 39e905ec74c9e2ac5b5a232f12f242f674be0c89da1525e4809daaa970fc2b9a

See more details on using hashes here.

File details

Details for the file brep_part_finder-0.3.16-py3-none-any.whl.

File metadata

  • Download URL: brep_part_finder-0.3.16-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for brep_part_finder-0.3.16-py3-none-any.whl
Algorithm Hash digest
SHA256 1fcf7cdc1c81a4e08dbdb7c62221de78da679de0c546165d2ba20a4e51cb2c27
MD5 422fccbbcd02cd5a4e22d9f1deeea006
BLAKE2b-256 a4aad36fe6f286c9e06de3426807cc814b229380fb8bfe76bc6c7b5f013ef504

See more details on using hashes here.

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