Skip to content

Instantly share code, notes, and snippets.

@pshriwise
pshriwise / geometry-examples.ipynb
Last active May 16, 2024 17:00
OpenMC CSG Geometry Examples
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / new_dagmc_names.py
Created March 25, 2024 06:45
Convert old DAGMC group names that appear from MCNP imports to the current DAGMC naming format
#!python
for (group_name, group_id) in cubit.group_names_ids():
# ignore group "picked". It is always present by default and isn't
# relevant for DAGMC metadata
if group_name == 'picked':
continue
tokens = group_name.split('_')
properties = [f'{p}:{v}' for p, v in zip(tokens[::2], tokens[1::2])]
new_name = '/'.join(properties)
@pshriwise
pshriwise / compute_faceting_tolerance.py
Created January 26, 2024 04:36
Compute the faceting tolerance for a surface or all surfaces of a model
#!python
import numpy as np
import sys
# sys.path.append( r"C:\Program Files\Coreform Cubit 2023.11\bin")
# import cubit
def compute_tri_surf_dist_err(surface_id=None):
"""Compute the maximum distance between a surface's triangles the closest point on a surface."""
@pshriwise
pshriwise / random-sampling.ipynb
Created January 24, 2024 22:10
Test Notebook for NE506 Exercises
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / export_slides_url.py
Created January 21, 2024 05:26
Generate a URL for PDF export of a Google slide deck
import sys
template = 'https://docs.google.com/presentation/d/{}/export/pdf'
document_id = sys.argv[1]
print(template.format(document_id))
@pshriwise
pshriwise / threaded_scaling.py
Last active October 31, 2023 18:38
A script for checking scaling of a DAGMC model.
import sys
from matplotlib import pyplot as plt
import openmc
import numpy as np
def threaded_scaling(threads, model, output_filename=None):
"""Run simulation with various threads and collect timing results
@pshriwise
pshriwise / groups_to_block_mats.py
Last active March 28, 2024 03:54
A code snippet for converting DAGMC Cubit groups to blocks and material assignments
import cubit
for (name, gid) in cubit.group_names_ids():
# skip the 'picked' group and other groups
# that aren't materials
if name == 'picked' or 'mat' not in name:
continue
mat = name.split('/')[0].split(':')[1]
if not mat:
@pshriwise
pshriwise / dagmc_material_swap.ipynb
Last active October 24, 2023 05:10
How to swap materials in a DAGMC .h5m file using PyMOAB
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / SFR.ipynb
Last active September 2, 2023 01:50
SFR Model ID Weridness
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / angular_filters_after.ipynb
Last active August 10, 2023 20:36
SurfaceFilter and MuFitler combination
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.