Skip to content

Instantly share code, notes, and snippets.

@pshriwise
pshriwise / decay_heat_ex.ipynb
Last active August 1, 2023 18:35
Example of depletion cooling times and decay heat extraction for Radiant GAIN
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / mp_psuedo_inv.cpp
Last active July 3, 2023 06:12
Moore-Penrose Pseudo-Inverse Using Eigen
// method for calculating the pseudo-Inverse as recommended by Eigen developers
template<typename _Matrix_Type_>
_Matrix_Type_ pseudoInverse(const _Matrix_Type_ &a, double epsilon = std::numeric_limits<double>::epsilon())
{
Eigen::JacobiSVD< _Matrix_Type_ > svd(a ,Eigen::ComputeFullU | Eigen::ComputeFullV);
// For a non-square matrix
// Eigen::JacobiSVD< _Matrix_Type_ > svd(a ,Eigen::ComputeThinU | Eigen::ComputeThinV);
double tolerance = epsilon * std::max(a.cols(), a.rows()) *svd.singularValues().array().abs()(0);
return svd.matrixV() * (svd.singularValues().array().abs() > tolerance).select(svd.singularValues().array().inverse(), 0).matrix().asDiagonal() * svd.matrixU().adjoint();
@pshriwise
pshriwise / main.cpp
Last active October 12, 2022 15:06
Plucker Triangle Test Functions
#include "position.h"
#include "plucker.h"
int main() {
}
@pshriwise
pshriwise / build_cardinal_aurora.sh
Created August 18, 2022 04:37
Script for building Cardinal & Aurora with same MOOSE installation. All dependencies use the HDF5 version from MOOSE
#!/bin/bash
# stop script on returned error code
set -e
# SCRIPT PARAMETERS
topdir=$HOME/aurora_build
compile_cores=20
# GLOBAL VARS
@pshriwise
pshriwise / triso_compact_mats.ipynb
Last active July 13, 2022 04:48
Example of fuel material per compact in TRISO problem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / Session1.ipynb
Created May 25, 2022 14:24
Session1 Notebook ICTP Summer School 2022
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshriwise
pshriwise / lattice_ex.py
Created March 2, 2022 12:56
Lattice within manually defined cells
import openmc
# constants
l = 1.0
h = 1.0
model = openmc.model.Model()
# materials
@pshriwise
pshriwise / check_homogenous.py
Last active February 5, 2022 03:46
Check for axial homogeneity in OpenMC model
#!/usr/bin/env python
import numpy as np
from progressbar import progressbar
import openmc
import openmc.lib
# main parameters
n_axial = 500
@pshriwise
pshriwise / dag_geom_ids.py
Created October 4, 2021 15:48
Print DAGMC Geom IDs
#! /bin/env python
from argparse import ArgumentParser
from pymoab import core, types
_VALID_GEOM_TYPES = ("Group", "Volume", "Surface", "Curve", "Vertex")
@pshriwise
pshriwise / update_dagmc_mat_names.py
Last active September 7, 2021 13:26
Python file designed to update DAGMC model group names from the old conventions to the new ones.
#!/usr/bin/env python
import numpy as np
import argparse
from pymoab import core, types
# some convenience functions
def get_category(mbi, category):