This file contains 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
import numpy as np | |
from numpy import pi as π | |
K_1 = 1e-2 | |
k_2 = 1e5 | |
k_3 = 1e-16 | |
t_d = 24 * 60 * 60 | |
def f(c, t): | |
k_1 = K_1 * max(0, np.sin(2 * π * t / t_d)) |
This file contains 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
import subprocess | |
from petsc4py import PETSc | |
geo_text = """ | |
Point(1) = {0, 0, 0, 1.0}; | |
Point(2) = {-0.5, -0, 0, 1.0}; | |
Point(3) = {0, -0.5, 0, 1.0}; | |
Point(4) = {0, 0.5, 0, 1.0}; | |
Point(5) = {0.5, -0, 0, 1.0}; | |
Characteristic Length { 1,2,3,4,5 } = 0.25; |
This file contains 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
import argparse | |
import firedrake | |
from firedrake import ( | |
max_value, sqrt, Constant, inner, as_vector, grad, dx, ds, dS | |
) | |
import numpy as np | |
from numpy import pi as π | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--method', choices=['good', 'bad']) |
This file contains 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
#include <tuple> | |
/* ============== | |
* Multi-iterator | |
* ============== */ | |
template <size_t> struct int_{}; | |
template <class... Args> |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Oct 28 16:28:02 2014 | |
@author: nicola | |
""" | |
import numpy as np | |
from scipy.sparse import * | |
def read_sparsity_pattern(filename): |
This file contains 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
import subprocess | |
import numpy as np | |
from scipy.sparse import lil_matrix | |
from matplotlib.path import Path | |
# ------------------------------ | |
def read_triangle_mesh(filename): | |
""" | |
Read in a mesh in Triangle's format. |
This file contains 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
import os | |
import glob | |
import sys | |
""" | |
This script processes the raw Landsat imagery into an RGB image. | |
The stem of the filename is passed as the only command-line argument. | |
""" | |
if __name__ == "__main__": |
This file contains 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
(defmacro iloop [[i istart iend] [sym init] expr] | |
`(loop [~i ~istart | |
~sym ~init] | |
(if (= ~i ~iend) | |
~sym | |
(recur (inc ~i) | |
~expr)))) | |
(defmacro iter [forms pred ret] | |
(let [syms (take-nth 3 forms) |
This file contains 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
import numpy as np | |
from scipy.io import * | |
import struct | |
import sys | |
import math | |
def read_geodat(filename): | |
""" | |
Read in one of Ian's geodat files. |
This file contains 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
import numpy as np | |
import shapefile | |
import itertools | |
from matplotlib.path import Path | |
import sys | |
class GeometryError(Exception): | |
pass |