Skip to content

Instantly share code, notes, and snippets.

@ibab
ibab / h2.py
Created May 6, 2012 12:56
Graphical solutions of the Schrödinger-equation for an idealised H_2 potential well
# encoding: utf-8
# Needs the python2 version of maplotlib because of a bug in the python3 version :(
from pylab import *
coth = lambda x: cosh(x)/sinh(x)
# ∞ ∞
# | |
# | |
@ibab
ibab / fermi.py
Last active March 2, 2021 17:11
Simulation that explores Fermi Dirac statistics
from pylab import *
from scipy import diff
from collections import Counter
from sympy.combinatorics.partitions import IntegerPartition
from scipy.optimize import curve_fit
rc('text', usetex=True)
rc('font', family='serif', serif='cm')
def fermi_dirac(E, μ, T):
@ibab
ibab / diagram.tex
Created June 29, 2013 19:48
A simple particle interaction diagram
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{trees}
\usetikzlibrary{matrix,arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{calc,through}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{pgffor}
@ibab
ibab / recompile.sh
Created April 1, 2014 08:53
A shell script for automatically recompiling a .tex file on Linux and viewing the result with mupdf.
#!/bin/sh
FILE=$1
red='\e[0;31m'
green='\e[0;32m'
reset='\e[0m'
mupdf ${FILE%.*}.pdf &

Keybase proof

I hereby claim:

  • I am ibab on github.
  • I am ibab (https://keybase.io/ibab) on keybase.
  • I have a public key whose fingerprint is 144B 7F62 78AC 54BC 998F 2488 ADD1 A3AE ADCE E6BB

To claim this, I am signing this object:

@ibab
ibab / plot_serial.py
Created April 6, 2014 21:20
Plot continuous stream of data from serial port.
from pylab import *
from matplotlib import pyplot as plt
import matplotlib.animation as animation
import serial
import time
arduino = serial.Serial('/dev/ttyACM0', 9600)
time.sleep(1)
@ibab
ibab / array2d.cpp
Created May 21, 2014 13:12
array2d
#include <vector>
#include <iostream>
#include <array>
#include <algorithm>
template <class T, unsigned I, unsigned J>
using array2d = std::array<std::array<T, J>, I>;
int main(int argc, char *argv[])
{
@ibab
ibab / progress.h
Last active August 29, 2015 14:01
A convenient iterator that prints a progress bar to the terminal.
#ifndef PROGRESS_H
#define PROGRESS_H
#include <iostream>
template <class T>
class Progress {
public:
class ProgressIterator {
@ibab
ibab / enum_strings.h
Created June 18, 2014 18:52
A macro that allows you to create an enum with toString and fromString conversion functions defined automatically for you.
#ifndef ENUMS_H
#define ENUMS_H
#include <boost/preprocessor.hpp>
#include <string>
/*
* The following macros allow you to define an enum and get `toString`
* and `fromString` functions generated automatically.
* If you use
@ibab
ibab / oscillation.py
Last active August 29, 2015 14:11
Plot of neutrino oscillation probabilities using newest NuFit data.
import numpy as np
# normal ordering values from NuFit 2.0, JHEP 11 (2014) 052 [arXiv:1409.5439]
θ_12 = np.deg2rad(33.48)
θ_23 = np.deg2rad(42.3)
θ_13 = np.deg2rad(8.50)
δ_CP = np.deg2rad(306)
Δm21 = np.sqrt(7.50e-5) # eV^2
Δm31 = np.sqrt(2.449e-3) # eV^2