Skip to content

Instantly share code, notes, and snippets.

@tgmaxson
tgmaxson / fmax.py
Created March 15, 2024 08:04
Plot Energy/Force on cmd using ASE
#! /usr/bin/env python
import gnuplotlib as gp
from ase.io import read
from sys import argv
import numpy as np
atoms = []
for fname in argv[1:]:
try:
from math import exp
from ase import Atoms
from ase.io import read
from ase.neighborlist import natural_cutoffs, NeighborList
import numpy as np
from icecream import ic
atoms = read("FILENAME")
def get_d3_CN(atoms: Atoms, use_d3_radii=True, k1=16, k2=4/3, mult=0.9):
#!/bin/bash
if [ $# -eq 1 ]; then
rm ~/.tmpdb.db ~/.tmpdb.db.lock 2> /dev/null
cp $1 ~/.tmpdb.db
exit 0
elif [ $# -eq 0 ]; then
echo "Not enough arguments: Supply db file as arg1"
exit 1
fi
import os, glob
os.chdir(os.path.dirname(os.path.realpath(__file__)))
print >>open('./FolderTally.csv', 'w'),"Folder, Unmarked, SD, HD"
for dir in glob.iglob("./*/"):
count=0
full=glob.glob("./"+dir+"/*")
dirs=glob.glob("./"+dir+"/*/")
dirs=map(lambda x: x[:-1], dirs)
for file in full:
if file not in dirs and "thumbs" not in file:
@tgmaxson
tgmaxson / qtlist
Created July 13, 2015 11:11
A version of qlist modified to show held jobs for the clusters at Purdue University.
#!/bin/bash
Queues=$(qlist | tail -n +5 | head -n -1 | awk '{print $1}' | xargs)
OUT="NAME MAXCONCURRENT QUEUED HOLD RUN FREE WALLTIME"
for q in $Queues
do
echo $q
Q=$( qstat "${q}" | tail -n +3 | awk '{print $3}' | sort | uniq | xargs -n 1 qstat -u 2>/dev/null | awk '$10 == "Q"' | awk '{print $7}' | paste -sd+ - | bc)
if [ "$Q" = "" ]
then
Q=0
@tgmaxson
tgmaxson / fmax
Created July 13, 2015 11:08
Gets the maximum force from the OUTCAR and CONTCAR of a VASP calculation.
#!/usr/bin/env python
from ase.io import read
def WriteForce(outdata, atoms):
'''
Write the max last reported force in the system.
'''
f = []
last = -1
@tgmaxson
tgmaxson / GPAW.py
Created July 13, 2015 11:04
A set of files (probably outdated, but easily changable) that can be used to automate setting up calculations in GPAW to some extent. Manually tuning is still required, but creates a boilerplate for you and sets up a restart method.
##REQUIRED IMPORTS
from ase.io import read
from ase.io.trajectory import PickleTrajectory
from gpaw import GPAW
from gpaw import Mixer
from ase.parallel import parprint
import os.path
import sys
import os
##REQUIRED IMPORTS
@tgmaxson
tgmaxson / general_coordination_number.py
Created July 13, 2015 10:59
A script to get the general coordination number of an atom based on covalent_radii as supplied by Atomic Simulation Enviroment.
from ase.io import read
from ase.data import covalent_radii as CR
import sys
from datetime import datetime
import numpy as np
def get_coordination_numbers(atoms, covalent_percent=1.25):
"""Returns an array of coordination numbers and an array of existing bonds determined by
distance and covalent radii. By default a bond is defined as 120% of the combined radii
@tgmaxson
tgmaxson / pourbiax_3_phase.py
Created July 13, 2015 10:27
Extract 3 phase boundaries from pourbiax diagram generated by pymatgen on an example set of data from Materials Project.
from pymatgen.matproj.rest import MPRester
from pymatgen.core.ion import Ion
from pymatgen import Element
from pymatgen.phasediagram.pdmaker import PhaseDiagram
from pymatgen.analysis.pourbaix.entry import PourbaixEntry, IonEntry
from pymatgen.analysis.pourbaix.maker import PourbaixDiagram
from pymatgen.analysis.pourbaix.plotter import PourbaixPlotter
from pymatgen.entries.compatibility import MaterialsProjectAqueousCompatibility
@tgmaxson
tgmaxson / simulate.py
Last active August 29, 2015 14:24
Dirty Bomb Loadout Monte Carlo Stats Generator
# Created by Tristan Maxson, data at https://docs.google.com/spreadsheets/d/11GjntlqLki_ft-ocHRLSnCfVtxVzh3JCdqcqHr5RMGE
from __future__ import division
from sys import argv as args
import random
TCost = [None, 500, 1000, 2000, 4000, 10000]
TNum = [None, 3, 3, 4, 4, 5]
def RollCase(chance=[80, 15, 3, 1.5, 0.4, 0.1]):
def sum(z):