Skip to content

Instantly share code, notes, and snippets.

View shimwell's full-sized avatar

Jonathan Shimwell shimwell

View GitHub Profile
@shimwell
shimwell / cadquery-to-dagmc-with-surfaces-sense.py
Last active August 31, 2023 22:49
cadquery to h5m with moab and surface sense
# this scrip makes a cadquery geometry, uses cadquery to imprint the surfaces, uses cadquery to mesh the faces of each solid
# then makes a moab core object by adding faces one at a time.
# if a face appears in two solids then the surface sense will be reversed
# work in progress
import cadquery as cq
import openmc
from typing import Tuple
import numpy as np
@shimwell
shimwell / plot_neutron_energy_distribution
Created March 28, 2023 12:18
Comparing neutron source production rates and energy fission fusion
import openmc
import openmc_source_plotter # extends openmc.Source with plotting functions
import pint
total_energy = pint.Quantity(1, 'GJ')
energy_per_dd = pint.Quantity(12.5, 'MeV/particle')
energy_per_dt = pint.Quantity(17.6, 'MeV/particle')
energy_per_fission = pint.Quantity(200., 'MeV/particle')
my_dt_source = openmc.Source()
@shimwell
shimwell / neutron_reaction_threshold_plot
Created March 28, 2023 10:35
Plot neutron reaction threshold energy for an isotopes. Setup to show different reactions resulting from DD (~2.5MeV) and DT (~14.1MeV) neutron sources.
import matplotlib.pyplot as plt
import openmc
from matplotlib.lines import Line2D
def plot_thresholds(nuclide="Fe56"):
plt.clf()
threshold_below_14 = 0
threshold_below_2 = 0
@shimwell
shimwell / rs2_minimum_viable_example
Last active December 6, 2022 16:48
makes a sphere of Silver and irradiates it with a 14MeV neutron source. The activated material emits gammas and these are transported and tallied on a mesh tally. The resulting decay gamma flux is plotted as a series of images so that the variation over time can be observed. Note that silver activation results in Ag110 which has a half life of …
# makes a sphere of Silver and irradiates it with a 14MeV neutron source.
# The activated material emits gammas and these are transported and tallied
# on a mesh tally. The resulting decay gamma flux is plotted as a series of
# images so that the variation over time can be observed. Note that silver
# activation results in Ag110 which has a half life of 24 seconds. The
# irradiation and decay timescales are set so that the buildup and decay can be
# observed
# Makes use of eepeterson branch of OpenMC https://github.com/eepeterson/openmc/tree/r2s_model_wrapper
@shimwell
shimwell / magic_ww_iter
Last active November 22, 2022 18:31
minimal_magic_from_ps
#!/usr/bin/env python
from copy import deepcopy
import numpy as np
import openmc
import openmc.lib
from openmc.mpi import comm
from matplotlib import pyplot as plt
@shimwell
shimwell / openmc-statepoint-3d.py
Last active September 18, 2019 11:26 — forked from pshriwise/openmc-statepoint-3d.py
Convert OpenMC Meshtally to MOAB/VTK mesh
#!/usr/env/python3
"""
Script for converting OpenMC mesh in an OpenMC
statepoint file to other mesh formats for visualization
"""
import argparse
import sys
import math