-
-
Save ellisonbg/959768 to your computer and use it in GitHub Desktop.
cranck nicholson stuck on BCs
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
from numpy import * | |
from matplotlib.pyplot import * | |
from time import sleep | |
import numpy as np | |
import networkx as nx | |
dim = [3,2] | |
dt = 1 #time step | |
G = nx.generators.classic.grid_graph(dim, periodic=False, create_using=None) | |
L = nx.laplacian(G) | |
#print L.shape[0] #gets the length of the zeroth entry of the laplacian | |
n = L.shape[0] | |
tup = 100 | |
tlow = 0 | |
dt = .5 | |
nt = (tup-tlow)/dt | |
T = 60*ones( (n,tup) ) #setting initial temperature | |
for i in range(n/2): | |
T[i,0] = 0; | |
i=0 | |
W = ones( (n,n) ) + dt/2*L | |
print W | |
print dt | |
#for i in range(t): | |
for i in range(2): | |
T[:,i+2] = dot(linalg.inv( ones( (n,n) ) + dt/2*L )*(ones( (n,n) ) - dt/2*L),T[:,i+1]) #note dot(a,v) treats v as a column | |
#vector while dot(v,a) treats v like | |
#print T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment