Skip to content

Instantly share code, notes, and snippets.

View danieljfarrell's full-sized avatar

Daniel danieljfarrell

View GitHub Profile
import DAQ
daq = DAQ("Dev1/ai0:2")
volts = daq.voltage()
amps = daq.current()
@danieljfarrell
danieljfarrell / gist:1569734
Created January 6, 2012 08:37
autogen failure on MacOS Lion
brew install autogen --use-clang
==> Downloading http://ftpmirror.gnu.org/autogen/rel5.14/autogen-5.14.tar.gz
File already downloaded in /Users/daniel/Library/Caches/Homebrew
==> ./configure --disable-debug --prefix=/usr/local/Cellar/autogen/5.14
==> make
make all-recursive
Making all in compat
:
Making all in snprintfv
for f in filament.c format.c printf.c mem.c stream.c custom.c ; do echo "#include \"$f\"" ; done > snv.c
@danieljfarrell
danieljfarrell / happytime.py
Created January 11, 2012 05:33
Intercontinental StarCraft 2 Happy Time Finder
from datetime import *
from clint.textui import colored, columns
#
# Using a module called Clint to take care of printing columns and text colour
#
# Examples: http://www.nicosphere.net/clint-command-line-library-for-python/
# Github: https://github.com/kennethreitz/clint
# Install: pip install clint
@danieljfarrell
danieljfarrell / DBR2.py
Created February 6, 2012 08:39
Extended version of CAMFR Planar 1D example to include absolute electric field and Poynting vector profiles
#!/usr/bin/env python
#########################################################################################
#
# planar 1D DBR modified to export absolute electric field and Poynting vector profiles
#
########################################################################################
from camfr import *
@danieljfarrell
danieljfarrell / simple_semiconductor_rates.py
Created April 2, 2012 04:46
Very simple semiconductor optical generation and recombination processes using FiPy
from fipy import *
#
# Solution mesh
#
nx = 200
dx = 0.01
L = nx * dx
mesh = Grid1D(nx = nx, dx = dx)
@danieljfarrell
danieljfarrell / multipass_beer_lambert.py
Created June 7, 2012 02:08
Fipy: Beer-Lambert law with multiple reflections
# http://matforge.org/wd15/blog
from __future__ import division
from fipy import *
# Grid things
N = 1000
D = 1
dx = D / N
m = Grid1D(nx=N, dx=dx)
I_right = CellVariable(mesh=m, value=1., name='I_right') # Intensity along the positive direction
@danieljfarrell
danieljfarrell / multipass_beer_lambert.py
Created June 11, 2012 08:06 — forked from guyer/multipass_beer_lambert.py
Fipy: Beer-Lambert law with multiple reflections
# http://matforge.org/wd15/blog
from __future__ import division
from fipy import *
# Grid things
N = 1000
D = 1
dx = D / N
m = Grid1D(nx=N+1, dx=dx) + [[-dx/2.]]
I_right = CellVariable(mesh=m, value=1., name='I_right') # Intensity along the positive direction
@danieljfarrell
danieljfarrell / diff_prob1.py
Created November 8, 2012 09:48
Fipy: problems with flux=0 constraints
from fipy import *
from fipy.tools.numerix import exp
# Basic Setup
nx = 200; dx = 0.01; L = nx * dx
A = 15.0; B = 0.1; phi_0 = 1.; D = 1.
mesh = Grid1D(nx = nx, dx = dx)
# Cell variable and constrains
@danieljfarrell
danieljfarrell / sq_thermal.py
Created December 3, 2012 11:08
Openopt thermal pv
from __future__ import division
from openopt import *
from FuncDesigner import *
# Constants
kb = 1.3806503e-23 # Boltzmann's Constant (m2 kg s-2 K-1)
elq = 1.60217646e-19 # Elemental charge (C)
h = 6.626068e-34 # Planck's constant (m2 kg s-1)
c = 299792458.0 # Speed of light (m/s)
fs = 6.8e-5 # Solar etendue (fraction of pi)
NSPoint ConstrainPointInsideRect(CGPoint freePoint, NSRect boundaryRect)
{
//NSPoint constrainedViewPoint = DFConstrainPointToRect(viewPoint, boundaryRect);
// Make sure the handle cannot be dragged outside of the plot range
if (NSPointInRect(freePoint, boundaryRect)) {
return freePoint;
}
NSPoint cp = freePoint;