Python Forum
Heat equation (not stationary)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Heat equation (not stationary)
#5
It is done ! There is the new code, hope you find it more clear.

Still with the message error :
File "F:\TIPE\Modélisation Python\Programme.py", line 65
Temperature.append( l_row[N] + dt / (dr*rho*capa(l_row[N])) * ( h*(Text - l_row[N]) + lambd(l_row[N])/dr * (l_row[N-1] - l_row[N]) ) )
^
SyntaxError: invalid syntax





## TIPE

#Importation

import matplotlib.pyplot as plt

#Numeric values

rho=2500
le=1.4e-3
ce=4186
rhoe=1000
h=10
e=5e-3

#Coefficients for thermal dependency

conduc0=-11.91
conduc1=87.6e-3
conduc2=-145e-6

capa0=-243e3
capa1=2e3
capa2=-2

#Functions for thrmal dependency

def conduc(T, coeff1=conduc1, coeff2=conduc2): #Thermal conductivity
       return (conduc0 + conduc1*T + conduc2*T**2)

def capa(T, coeff1=capa1, coeff2=capa2): #Thermal capacity per mass
       return (capa0 + coeff1*T + coeff2*T**2)

#Parameters of discreditation

N=10
dt=10
dr=e/N+1

#Initial parameters

T_start=90
T_ext=20 

#Function

def résolution(M):
       '''Stop at time_max=M*dt, return the list of Temperatures at the interface with the water at every time'''

       Interface_water=[T_start]
       Time = [elt for elt in range(M+1)]
       L = [ [T_start] + N*[T_ext] ] #List where every temperature calculated will remain

       for l_row in L:
              Temperature=[]

              #Calculation at the interface water (i=0)
              Temperature.append( l_row[0] + lambd(l_row[0])*dr*dt / (dr*rho*capa(l_row[0]) - le*rhoe*ce) /dr/dr * (l_row[1] - l_row[0]) )

              #Calculation in the mug (i from 1 to N)
              for i in range(1, N+1):
                     Temperature.append( (l_row[i] + lambd(l_row[i])*dr*dt / (dr*rho*capa(l_row[i])) /dr/dr * (l_row[i+1] + l_row[i-1] - 2*l_row[i]) )

              #Calculation at the interface air (i=N+1)
              Temperature.append( l_row[N] + dt / (dr*rho*capa(l_row[N])) * ( h*(Text - l_row[N]) + lambd(l_row[N])/dr * (l_row[N-1] - l_row[N]) ) )


              L.append(Temperature)
              Interface_water.append(Temperature[0])

       plt.plot(Time, Interface_water)
       return (Interface_water)


#Execution

résolution(10)
Reply


Messages In This Thread
Heat equation (not stationary) - by Zulian - May-13-2017, 07:19 AM
RE: Heat equation (not stationary) - by volcano63 - May-13-2017, 08:56 AM
RE: Heat equation (not stationary) - by Zulian - May-13-2017, 09:01 AM
RE: Heat equation (not stationary) - by volcano63 - May-13-2017, 09:03 AM
RE: Heat equation (not stationary) - by Zulian - May-13-2017, 03:03 PM
RE: Heat equation (not stationary) - by Zulian - May-14-2017, 12:54 PM
RE: Heat equation (not stationary) - by volcano63 - May-14-2017, 04:03 PM
RE: Heat equation (not stationary) - by Ofnuts - May-15-2017, 06:33 AM
RE: Heat equation (not stationary) - by Zulian - May-15-2017, 02:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  animating 2d heat map schniefen 0 1,412 Nov-20-2022, 10:00 PM
Last Post: schniefen
  Heat equation HugoL 1 36,650 Mar-07-2017, 05:22 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020