Demo entry 1487257

Some Code

   

Submitted by Sebastian on Apr 21, 2015 at 15:33
Language: Python. Code size: 599 Bytes.

# ---------------------- Analytical Solution

def heat(r,t,k,L,D,T_0):
    return (2*T_0/(k*np.pi)*(1-np.cos(k*np.pi)))*np.exp(-D*(k*np.pi/L)**2*t) * np.sin((k*np.pi/L)*r)



# ---------------------- Variables
t = np.linspace(0,10,11)
r = np.linspace(0,1,51)
k = range(1,100,1)         # range of summation (infinity would be a bit too much)
profile = []

# ---------------------- Calculate temperature profiles
for time in t:
    var = 0
    for kk in k:
        var += heat(r,time,kk,L,D,T0)
    profile.append(var)
    
profile = np.asarray(profile)
rs, ts = np.meshgrid(r,t)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).