Skip to content

Instantly share code, notes, and snippets.

View gonuke's full-sized avatar

Paul Wilson gonuke

View GitHub Profile
@gonuke
gonuke / get_material_volume_mapping.py
Last active December 18, 2021 16:12
*untested* short script to get map of volumes and their materials from a DAGMC H5M file
import numpy as np
import pymoab as mb
def load_model(filename):
mbcore = mb.core.Core()
mbcore.load_file(filename)
return mbcore
import numpy as np
num_blocks = 64
lines_in_block = 300
skip_lines = 1
data_offset = { 'up' : 0, 'down' : 17 }
names = ['block',' energy', 's_up', 'p_up', 'd_up', 'f_up', 's_down', 'p_down', 'd_down', 'f_down']
formats = ['i8', 'f8', 'f8', '3f8', '5f8', '7f8', 'f8', '3f8', '5f8', '7f8']
rec_type = np.dtype({'names':names, 'formats': formats})
@gonuke
gonuke / mh_data_split_1.py
Last active August 15, 2018 14:43
Python to split data for Megan Hoover
num_blocks = 64
lines_in_block = 300
skip_lines = 1
data_offset = { 'up' : 0, 'down' : 17 }
# This could be even more compact, although arguably less readable,
# if you just immediately wrote everything to the output file rather
# that storing in variables.
@gonuke
gonuke / build.log (Ubuntu 14.04)
Last active March 14, 2016 11:20
Logs of cyclus build
/usr/bin/cmake
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
@gonuke
gonuke / cycamore.install.log
Created November 16, 2015 22:11
failed cyamore install
cmake: /root/miniconda/lib/liblzma.so.5: no version information available (required by /usr/lib/x86_64-linux-gnu/libarchive.so.13)
cmake: /root/miniconda/lib/libssl.so.1.0.0: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
cmake: /root/miniconda/lib/libssl.so.1.0.0: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
cmake: /root/miniconda/lib/libssl.so.1.0.0: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
cmake: /root/miniconda/lib/libcrypto.so.1.0.0: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
-- The C compiler identification is GNU 5.2.1
-- The CXX compiler identification is GNU 5.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
\[\e[33m\]\w\[\e[1;$(get_git_color)m\] $(parse_git_branch)\[\e[0m\]\n>
Range siblings;
Range::iterator cn;
EntityHandle parent;
siblings.clear()
siblings.insert(head);
cn = siblings.begin();
insertion = false;
# put the following into your bash startup files
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
function get_git_color() {
isred=`git status -s 2> /dev/null | egrep "^.[^? ]" | wc | awk '{print $1}'`
mat_lib = MaterialLibrary(
{
'Water': Material(
density=1.0,
comp={1000: 11.11, 8000: 88.89}
)
})
{'Water' :
@gonuke
gonuke / Alias table generation
Last active December 12, 2015 02:28
Pseudo-code for efficient alias table generation
given: p(k) for k = 1..n such that sum(p(k)) = 1, p(k) >= 0
# multiply entire vector by n
p *= n
# initialize pair to -1
pair = -1
for k=1..n
if p(k) <= 1
small_list.append(k)