This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instantiation. | |
# Make a solver object, created automatically with default options. The solve is instantiated | |
# only with the variables that are common to all of the solvers. This means 1) the r.h.s. of | |
# function to solve, 2) a start time, 3) initial conditions, 4) Jacobian function. Strictly | |
# speaking the Jacobian is optional here because only some solvers will require it. As a | |
# compromise lets pass it as a keyword argument, this also gets around any awkward 'use_jac' | |
# options because the solver either has a Jacobian function at init time or it does not. | |
solver = odesolver("cvodes", ode_function, time_start, initial_conditions, jacobian_function=None) | |
# Solver options. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import numpy as np | |
from scipy.integrate import simps | |
from scipy.sparse import spdiags, coo_matrix, csc_matrix, dia_matrix, dok_matrix, identity | |
from scipy.sparse.linalg import spsolve | |
from itertools import chain | |
import pylab | |
import scipy | |
print "scipy", scipy.__version__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Cell centered finite volumes" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://stackoverflow.com/questions/2520978/how-to-tile-the-contents-of-a-calayer */ | |
// callback for CreateImagePattern. | |
static void DrawPatternImage (void *info, CGContextRef ctx) { | |
CGImageRef image = (CGImageRef) info; | |
CGContextDrawImage(ctx, | |
CGRectMake(0,0, CGImageGetWidth(image),CGImageGetHeight(image)), | |
image); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |