Flusso di calore.

1
2
3
for time in range(1,tstep):
  for i in range(1,N-1):
	T[i,time]=T[i,time-1]+0.5*tau/ts*(T[i-1,time-1]+T[i+1,time-1]-2*T[i,time-1])

1
2
3
4
5
6
7
8
9
N=100
tstep=1000
T=zeros((N,tstep))

#Temperatura iniziale
T[50,0]=10.

ts=1
tau=0.9*ts

1
2
3
4
5
from mpl_toolkits.mplot3d import Axes3D

ax = gca(projection='3d')
gridx , gridy = meshgrid(range(tstep),range(N))
ax.plot_wireframe(gridx,gridy,T,cstride=10,rstride=2)

1
2
3
4
5
from mpl_toolkits.mplot3d import Axes3D

ax = gca(projection='3d')
gridx , gridy = meshgrid(range(2,200),range(0,N,2))
ax.plot_wireframe(gridx,gridy,Temp[::2,2:200])

1
2
3
4
5
for time in range(1,tstep):
	#ciclo for su i
	...
	T[0,time]=T[1,time]
	T[99,time]=T[98,time]

1
2
3
4
N=100
tstep=3000
Temp=zeros((N,tstep))
Temp[35:65,0]=500.

1
ax.plot_surface(gridx,gridy,Temp,cmap=cm.coolwarm,vmax=250,linewidth=0,rstride=2, cstride=100)