Skip to content

Instantly share code, notes, and snippets.

View ryjmacdonell's full-sized avatar

Ryan MacDonell ryjmacdonell

View GitHub Profile
@ryjmacdonell
ryjmacdonell / vector_parser.py
Last active September 2, 2019 18:58
A basic pyparsing parser for 3D vector operations
"""
Test script for the vector parsing routines.
Based largely on the pyparsing example,
https://github.com/pyparsing/pyparsing/blob/master/examples/eval_arith.py
"""
import operator as op
import pyparsing as pp
import numpy as np
@ryjmacdonell
ryjmacdonell / build_dens.py
Created March 5, 2019 16:24
Build atomic densities from hydrogenic orbitals with an iterative, integrated effective charge
"""
Script for building an atomic density using an integrated form of
Slater's rules.
"""
from sys import argv
import numpy as np
import scipy.misc as sp
import matplotlib.pyplot as plt
@ryjmacdonell
ryjmacdonell / rqueue
Last active December 1, 2020 02:55
User specific squeue with job counting and tracking
#!/bin/bash
allj=$(squeue --sort=+i -o "%.8i %.16j %.8u %.3C %.2t %.12M")
echo "($(date +"%Y-%m-%d %H:%M:%S"))"
echo "$HOSTNAME: Running $(echo "$allj" | awk '{print $5}' | grep R |wc -l) of $(($(echo "$allj" | wc -l)-1)) jobs"
myj=$(echo "$allj" | grep $USER)
if [ -z "$myj" ]; then
echo "$USER: Running 0 of 0 jobs"
echo "" >& $HOME/.runqueue.tmp
else
@ryjmacdonell
ryjmacdonell / getnrg
Last active December 10, 2018 20:36
Get energies from electronic structure files
#!/bin/bash
#
# Get the energies from electronic structure output files and convert
# by a given conversion factor (default: eV) minus an optional base value
#
# Usage:
# getnrg [options] {filenames}
#
# Options:
# c: conversion factor (default: hartree to eV)
@ryjmacdonell
ryjmacdonell / pytouch
Last active March 5, 2018 16:22
Generate template files for python
#!/usr/bin/env python
"""
Script for generating an unfilled python template.
Usage
-----
pytouch [options] filename
Options
-------
@ryjmacdonell
ryjmacdonell / hyd_dens.py
Last active February 8, 2018 23:59
Build radial densities of atoms using hydrogenic densities and effective charge
"""
A script for generating atomic electron densities using hydrogenic
densities with charge screening.
"""
import numpy as np
import matplotlib.pyplot as plt
def R1s(r, Z):
"""Returns the radial n = 1, l = 0 density."""
"""
Test code for generating point distributions based on sums of 3D Gaussian
functions.
This is written in order to be translated to Fortran, i.e. it uses
minimal calls to numpy. Remaining non-trivial calls [Fortran equivalents]:
1. arange: used to generate axis points [array constructor]
2. sum: used to normalize the distribution function [SUM]
3. random.rand: used to generate random x, y, and z points [RAND]
4. argmin: used to find the minimum distance to centroids [MINLOC]
"""
A test script for comparing different types of Voronoi diagrams.
The type of Voronoi weighting can be changed by choosing 'func'.
voronoi_bsc: Basic Voronoi cells. Finds the minimum of
di = ||z - zi||
for position zi.
voronoi_mul: Multiplicative weighting. Finds the minimum of
di = ||z - zi|| / ri^p
for position zi, power p and weighting factor ri.
@ryjmacdonell
ryjmacdonell / rm-to-trash
Last active January 28, 2018 21:38
Bash script calling gvfs-trash for a non-permanent rm -i (if alias set in .bashrc)
#!/bin/bash
removedir=false
forceful=false
while getopts "rf" opt; do
case $opt in
r) removedir=true ;;
f) forceful=true ;;
esac
@ryjmacdonell
ryjmacdonell / passgenerator.py
Created July 3, 2016 17:56
ASCII password generation script in Python
"""
ASCII password generation script
By default, the script runs from the command line and asks for types of
characters, length of password(s) and number of passwords to generate.
"""
import string
import random