Skip to content

Instantly share code, notes, and snippets.

% 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
@ilciavo
ilciavo / BoundaryConditions.py
Last active June 4, 2020 09:36
Poisson and Heat Equation with boundary conditions
#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
@ilciavo
ilciavo / sphere.py
Last active November 17, 2016 10:36
Drawing a sliced sphere
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)
%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-Kolmogorov.m
Created July 10, 2015 13:25
2D-Fisher-Kolmogorov
% 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 / Fisher-Kolmogorov1D.m
Last active August 29, 2015 14:24
Fisher-Kolmogorov1D
% 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.