Skip to content

Instantly share code, notes, and snippets.

@thider
thider / Crankin
Created May 4, 2011 03:56
Starting Crank Nicholson
from numpy import *
from matplotlib.pyplot import *
from time import sleep
import numpy as np
import networkx as nx
dim = [2,2]
@thider
thider / gist:956525
Created May 5, 2011 04:10
cranck nicholson stuck on BCs
from numpy import *
from matplotlib.pyplot import *
from time import sleep
import numpy as np
import networkx as nx
dim = [3,2]
"""Solve the 1D diffusion equation using CN and finite differences."""
from time import sleep
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
# The total number of nodes
nodx = 3
nody = 3
@thider
thider / 1DdiffusionTim
Created May 18, 2011 18:13
1DdiffusionTim
"""Solve the 1D diffusion equation using CN and finite differences."""
from time import sleep
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
# The total number of nodes
nnodes = 10
# The total number of times
@thider
thider / 2Ddiffusion
Created June 2, 2011 17:40
2Ddiffusion
"""Solve the 2D diffusion equation using CN and finite differences."""
from time import sleep
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from pylab import *
# The total number of nodes
nodx = 3
@thider
thider / crank3D
Created June 6, 2011 19:11
crank3D
"""Solve the 3D diffusion equation using CN and finite differences."""
from time import sleep
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from pylab import *
# The total number of nodes
nodx = 3