Skip to content

Instantly share code, notes, and snippets.

View ellisonbg's full-sized avatar

Brian E. Granger ellisonbg

View GitHub Profile
@ellisonbg
ellisonbg / bar.py
Created October 28, 2014 04:32
Another test...
def g(x):
print x
b = 20
@ellisonbg
ellisonbg / foo.py
Created October 28, 2014 04:26
Sample gist for importing
def f(x):
print x
a = 10
@ellisonbg
ellisonbg / log_plot.ipynb
Created November 21, 2014 21:46
Log Plots
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ellisonbg
ellisonbg / CalPolyLibraryAPI
Created February 1, 2015 03:48
Cal Poly Library API
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploration of the Cal Poly Library API"
]
},
{
@ellisonbg
ellisonbg / binary_pi_digits.py
Created November 14, 2009 17:17
Functions for reading digits of pi in binary form
"""Functions for reading binary files with the digits of pi stored
as 4-bit ints."""
def bin_file_to_digits(filename, the_type=str):
raw_bytes = np.fromfile(filename, dtype=np.byte)
for b in raw_bytes[0:10000]:
digits = byte_to_digits(b)
yield the_type(digits[0])
yield the_type(digits[1])
@ellisonbg
ellisonbg / quantum_demo.py
Created October 27, 2010 05:05
Simple Demos for sympy.physics.quantum and friends
from sympy.physics.quantum import *
from sympy.physics.cartesian import *
from sympy.physics.piab import *
from sympy.physics.spin import *
# Basic manipulations with operators, bras, kets and commutators
psi, phi = Ket('psi'), Ket('phi')
psi, phi
A, B, C = Operator('A'), Operator('B'), Operator('C')
@ellisonbg
ellisonbg / physgraph.py
Created April 25, 2011 19:44
Quantum mechanics on graphs
"""Quantum mechanics on graphs.
Todo:
* Implement dirichlet boundary conditions.
* Use node attributes to label boundary points and impose dirichlet boundary
conditions.
* Develop plotting/viz routines using matplotlib/mayavi2.
* Use node attributes to store the physics coordinates of the point.
* Write a bisect function to put additional nodes between existing ones.
@ellisonbg
ellisonbg / diffusion1d.py
Created May 6, 2011 20:58
1D Diffusion Equation with FD+CN
"""Solve the 1D diffusion equation using CN and finite differences."""
from time import sleep
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
# The total number of nodes
nnodes = 10
# The total number of times
@ellisonbg
ellisonbg / gist:959768
Created May 6, 2011 20:58 — forked from thider/gist:956525
cranck nicholson stuck on BCs
from numpy import *
from matplotlib.pyplot import *
from time import sleep
import numpy as np
import networkx as nx
dim = [3,2]
@ellisonbg
ellisonbg / diffusion2d.py
Created May 10, 2011 15:16
2D Diffusion Equation with CN
"""Solve the 1D diffusion equation using CN and finite differences."""
from time import sleep
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
# The total number of nodes
numx = 5
numy = 5