Skip to content

Instantly share code, notes, and snippets.

View andersx's full-sized avatar
🤓
LFG

Anders Steen Christensen andersx

🤓
LFG
View GitHub Profile
\begin{figure}
\begin{center}
\includegraphics[width=8.3cm]{my_figure.pdf}
\caption{This is my figure.}
\end{center}
\end{figure}
@andersx
andersx / pbconstraint.py
Created December 4, 2013 09:33
Constraint optimization in Python with Open Babel
import openbabel as ob
# Standard openbabel molecule load
conv = ob.OBConversion()
conv.SetInAndOutFormats('xyz','xyz')
mol = obOBMol()
conv.ReadFile(mol,'my_mol.xyz')
# Define constraints
constraints = ob.OBFFConstraints()
@andersx
andersx / make_scan.py
Last active January 2, 2016 00:09
make scan
from fragbuilder import Peptide
# Create a peptide object with the sequence
# glycine-glycine-glycine.
sequence = "GGG"
pep = Peptide(sequence)
# Define a list of angles.
angles = range(-180, 180, 60)
@andersx
andersx / linus
Last active January 3, 2016 01:19
linus stuff
all: main
main: funclib.o getch_linux.o rovarsprak.c
gcc -O3 -Wall --pedantic -o main rovarsprak.c funclib.o getch_linux.o
funclib.o: funclib.c funclib.h
gcc -c -O3 -Wall --pedantic funclib.c -o funclib.o
getch_linux.o: getch_linux.c getch_linux.h
gcc -c -O3 -Wall --pedantic getch_linux.c -o getch_linux.o
@andersx
andersx / dftb3_gradient.inp
Created August 28, 2014 21:06
CHARMM input file for dftb3 energy+gradient
* water dimer test case for DFTB3 (D3RD HBON)
* DFTB3 single point + gradient.
bomlev 0
! prnlev 7
if ?SCCDFTB .NE. 1 then
echo "Test NOT Performed."
STOP
endif
@andersx
andersx / jamess_standard.f90
Last active August 29, 2015 14:05
JAMESS' FORTRAN90 standard syntax.
! Variable declaration:
! =========================
!
! 1) Pythonic naming is used. See: http://legacy.python.org/dev/peps/pep-0008/#naming-conventions
! 2) In brief, this means "lowercase" or "lower_case_with_underscores" are acceptable examples.
! 3) Use descriptive naming.
! 4) Use of abbreviations is discouraged, unless they are very standard.
! - E.g. "kcal" for kilocalories is acceptable.
! - E.g "http" for hypertext transfer protocol is acceptable.
! - E.g "disp_ver" instead of, say, dispersion version is not acceptable.
$contrl
nprint=-5
runtyp=gradient
ispher=-1
maxit=50
$end
$system
mwords=40
@andersx
andersx / exp_avx.cpp
Last active March 16, 2018 15:28
EXP(x) for AVX2
// Approximation for EXP(x), only valid for -126.0f < x < 0.0f.
static inline __m256 _mm256_expfast_ps(const __m256 &q) {
const __m256 INVLOG_2 = _mm256_set1_ps(1.442695040f);
const __m256 BIT_SHIFT = _mm256_set1_ps(8388608);
const __m256 ONE = _mm256_set1_ps(1.0f);
const __m256 C1 = _mm256_set1_ps(121.2740838f);
const __m256 C2 = _mm256_set1_ps(27.7280233f);
const __m256 C3 = _mm256_set1_ps(4.84252568f);
@andersx
andersx / fastexp.h
Created February 16, 2015 01:27
Very fast EXP(x) for AVX2+FMA instructions
// Approximation for EXP(x) -- very fast, but not super accurate
static inline __m256 _mm256_expfaster_ps(const __m256 &q) {
const __m256 C1 = _mm256_set1_ps(1064872507.1541044f);
const __m256 C2 = _mm256_set1_ps(12102203.161561485f);
return _mm256_castsi256_ps(_mm256_cvttps_epi32(_mm256_fmadd_ps(C2, q, C1)));
}
@andersx
andersx / tinkermin
Created April 26, 2015 21:43
TINKER script to minimize .pdb files
#!/bin/bash
# Input pdbfile, force field key, optimization convergence
PDB=$1
FF=$2
CONV=$3
TINKERBIN=/home/andersx/programs/tinker/bin