Skip to content

Instantly share code, notes, and snippets.

@ilciavo
ilciavo / sphere.py
Last active Nov 17, 2016
Drawing a sliced sphere
View sphere.py
import matplotlib.pyplot as plt
from matplotlib import cm, colors
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from matplotlib.patches import FancyArrowPatch
from mpl_toolkits.mplot3d import proj3d
class Arrow3D(FancyArrowPatch):
def __init__(self, xs, ys, zs, *args, **kwargs):
FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
View 1D_FKPP_Solver.py
% matplotlib inline
#modified from
#http://nbviewer.ipython.org/github/diogro/ode_examples/blob/master/The%20Fisher-Kolmogorov%20equation.ipynb?create=1
from numpy import *
from scipy.integrate import odeint
from matplotlib.pyplot import plot, xlabel, ylabel, figure, axes, style
style.use('ggplot')
#import time
from timeit import default_timer as timer
import Fmodules
View Diffusion_Reaction.m
%Modified from http://www.wikiwaves.org/Reaction-Diffusion_Systems
%Reaction Diffusion
% A + E -> 2A
% Differential Equations
% A_t = A_xx + A*E
% E_t = E_xx - E*A
% Equivalente to
% A_t = A_xx + A*(1-A)
clc
@ilciavo
ilciavo / Fisher-Kolmogorov1D.m
Last active Aug 29, 2015
Fisher-Kolmogorov1D
View Fisher-Kolmogorov1D.m
% Use of 2D FFT for Fourier-spectral solution of
%
% ut = u_xx + u(1-u) , 0< x < 50
%
% where
% u0 = exp(-r^2/(2*sig^2)),
% r^2 = (x-0.5)^2 , sig = 1
%
% with periodic BCs on u in x,y, using N = 16 modes in each direction.
% Script makes a surface plot of u at the Fourier grid points.
@ilciavo
ilciavo / Fisher-Kolmogorov.m
Created Jul 10, 2015
2D-Fisher-Kolmogorov
View Fisher-Kolmogorov.m
% Use of 2D FFT for Fourier-spectral solution of
%
% ut = u_xx + u_yy 0 + u(1-u) , 0< x,y < 1
%
% where
% u0 = exp(-r^2/(2*sig^2)),
% r^2 = (x-0.5)^2 + (y-0.5)^2, sig = 1
%
% with periodic BCs on u in x,y, using N = 16 modes in each direction.
% Script makes a surface plot of u at the Fourier grid points.
@ilciavo
ilciavo / BoundaryConditions.py
Last active Jun 4, 2020
Poisson and Heat Equation with boundary conditions
View BoundaryConditions.py
#poisson solver
#u_xx = b(x)
%matplotlib inline
from __future__ import division
import numpy as np
from numpy import cos, sin, zeros, pi
from numpy.linalg import solve, norm
import matplotlib.pyplot as plt
from matplotlib import rcParams
You can’t perform that action at this time.