Python Forum
Heat equation (not stationary)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Heat equation (not stationary)
#1
Good morning,

I would be very greatful if someone take the time to help me.
I have a scientific research study to deal with, my topic is : The the evolution of the transfers in a mug with temperature.
I have now to simulate this with the Heat equation in a 1D problem (to simplify) as a wall.

I have already modelised it, (with termal sources so as to simulate the exchange of the mug with the water on the one hand (i=0, water temperature not fixed) and the air (i=N+1, air temperature fixed at Text)).
So I have 3 expressions for the temperature at the moment k+1 that requires the température at the moment k.
I would like to calculate these températures time after time ( incrementation 1 by 1 for k ) and to finally only return the temperature at the interface with the water (i=0).

Nevertheless, my code is not working:
File "F:\TIPE\Modélisation Python\Programme.py", line 71
Temp.append(L[k][N]+dt/(dr*rho*capa(L[k][N],0,0))*(h*(Text-L[k][N])+lambd(L[k][N],0,0)/dr*(L[k][N-1]-L[k][N])))
^
SyntaxError: invalid syntax


I have tried to change a lot of things with my basic ability, but I can't go over this "SyntaxError" and I don't know where could be the error. I'll be greatful for you help.

L a list of list, it contains the list of the temperature at the points i=0 to i=N+1, at each instant k from 0 to M.
capa and lambd are functions that provide the evolution of physic parameters with the temperature.
Interface_eau is the list of temperature at the point i=0 at each moment k from 0 to M.


## Importation des modules

import numpy as np
import matplotlib.pyplot as plt

## Definition des fonctions

# Données fixes:

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

#Coefficients dépendances thermiques

lambda0=-11.91
lambda1=87.6e-3
lambda2=-145e-6

c0=-243e3
c1=2e3
c2=-2

#Fonctions dépendances thermiques

def lambd(T,coeff1,coeff2):
      '''O si prends les valeurs exp, 1 si prends les valeurs entrées pour coeff1 et coeff2'''
      if coeff1==0 and coeff2==0:
            coeff1=lambda1
            coeff2=lambda2
      return (lambda0+coeff1*T+coeff2*T*T)

def capa(T,coeff1,coeff2):
      '''O si prends les valeurs exp, 1 si prends les valeurs entrées pour coeff1 et coeff2'''
      if coeff1==0 and coeff2==0:
            coeff1=c1
            coeff2=c2
      return (c0+coeff1*T+coeff2*T*T)

#Paramètres de pas

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

#Paramètres initiaux

Tdeb=90
Text=20 

#Fonction méthode explicite

def résolution(M):
      '''S'arrete à tmax=M*dt, renvoie la liste des T en r=0 aux différents temps'''
      Interface_eau=[Tdeb]
      Temps=[elt for elt in range(M+1)]
      L=[[Tdeb]+(N)*[Text]]
      for k in range(0,M):
            Temp=[]
            #Calcul interface eau i=0
            Temp.append(L[k][0]+lambd(L[k][0],0,0)*dr*dt/(dr*rho*capa(L[k][0],0,0)-le*rhoe*ce)/dr/dr*(L[k][1]-L[k][0]))
            #Calcul intérieur tasse i entre 1 et N
                  for i in range(1,N):
                  Temp.append((L[k][i]+lambd(L[k][i],0,0)*dr*dt/(dr*rho*capa(L[k][i],0,0))/dr/dr*(L[k][i+1]+L[k][i-1]-2*L[k][i]))
            #Calcul interface air i=N+1
            Temp.append(L[k][N]+dt/(dr*rho*capa(L[k][N],0,0))*(h*(Text-L[k][N])+lambd(L[k][N],0,0)/dr*(L[k][N-1]-L[k][N])))
            L.append(Temp)
            Interface_eau.append(Temp[0])
      plt.plot(Temps, Interface_eau)

#Lançage

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,411 Nov-20-2022, 10:00 PM
Last Post: schniefen
  Heat equation HugoL 1 36,503 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