J-0
00m
00j
00h
00min
00s

Version interactive avec LaTeX compilé

CCINP Informatique Commune PC 2015

Notez ce sujet en cliquant sur l'étoile
0.0(0 votes)
Logo ccinp
2025_08_29_07f572d59bf14d56533dg
\# II.B.2.j.(iv)
T_tous_k[ : , 0]=T0
\# II.B.2.j. (v)
T_tous_k[0,1]=r*Tint+(1-2*r)*T_tous_k[0,0]+r*T_tous_k[1,0]
T_tous_k[N-1,1] $=r^{*}$ T_tous_k[N-2,0]+(1-2*r)*T_tous_k[N-1,0]+r*Text
for i in range ( $2, \mathrm{~N}$ ) :
    T_tous_k[i-1,1]=r*T_tous_k[i-2,0]+(1-2*r)*T_tous_k[i-1,0]+r*T_tous_k[i,0]
\# II.B.2.j. (vi)
def calc_norme(V):
    $\mathrm{N}=$ len (V)
    $s=0$
for
        $i$ in $\operatorname{range}(N):$
$s+=V[i]^{* * 2}$
    return sqrt(s)
\# II.B.2.j.(vii)
k=1
while calc_norm( $\mathrm{T}[:, \mathrm{k}]-\mathrm{T}[:, \mathrm{k}-1])>=10^{* *}(-2)$ and $\mathrm{k}<$ ItMax-1:
    k+=1
    T_tous_k[0,k]=r*Tint+(1-2*r)*T_tous_k[0,k-1] +r*T_tous_k[1,k-1]
    T_tous_k[N-1,k]=r*T_tous_k[N-2, k-1]+(1-2*r)*T_tous_k[N-1, k-1]+r*Text
    for i in range $(2, N)$ :
[i,k-1]
\# II.B.2.j.(viii)
nbIter=k
return nbIter, T_tous_k
\# II.B.3.a. l'équation (1) donne
\# alpha * ( T^\{k+1\}_i - T^k_i )/( Delta t ) = ( T^\{k+1\}_\{i+1\} + T^\{k+1\}_\{i-1\} -
2. $\mathrm{T} \wedge\{\mathrm{k}+1\} \_$i )/( Delta $\mathrm{x}^{\wedge} 2$ )
\# II.B.3.b.on a donc
\# T^k_i=-r. T^\{k+1\}_\{i-1\}+(1+2r). T^\{k+1\}_i-r.t^\{k+1\}_\{i+1\}
\# toujours avec r=(Delta t / (alpha*Delta x^2))
\# II.B.3.c.
\# M est tridiagonale: sur la diagonale principale tous les coefficients valent 1
$+2 r$
\# sur la diagonale supérieure tous les coefficients valent $r$
\# sur la diagonale inférieure tous les coefficients valent $r$
\# v=[Tint,0,.....,0,Text2]
\# II.B.3.d.
def CalcTkp1(M,d):
    N=1en(d)
    cprime=[ 0 for k in range( N )
    cprime[0]=M[0,1]/float(M[0,0]) \# Python 2.7
    for 1 range(1, N-1):
    dprime=
    dprime[0]=float(d[0])/M[0,0] \# Python 2.7
    dprimplon 2.7
    for i in range( $1, \mathrm{~N}$ ):
\# dprime[i]=float(d[i]-M[i,i-1]*dprime[i-1])/(M[i,i]-M[i,i-1]*cprime[i-1])
\# Python 2.7
    - [ or k in range(N) ]
    u[-1]=dprime[-1]
    for $i$ in range( $N-2,-1,-1$ ):
févr. 24, 16 9:50 stdin
u[i]=dprime[i]-cprime[i]*u[i+1] return u
# II.B.3.e.(i)
# def schema_implicite(T0,alpha,e,Delta_t,Tint,Text):
# ....
# return nbIter, T_tous_k # II.B.3.e.(ii) ItMax=2000 N=len(T0) T_tous_k=np.zeros((N,ItMax))
# II.B.3.e.(iv)
Deltax=e/float(N+1)
r=(Deltat/float(alpha*Deltax**2))
M=zeros( (N,N))
for i in range(N):
# II.B.3.e.(v)
T_tous_k[:,1]=CalcTkp1(M,T_tous_k[:,0]+r*v[:,0]) # mauvais résultat avec v à la place de v[:,0]
# II.B.3.e.(vi)
k=1
while calc_norm(T_tous_k[:,k]-T_tous_k[:,k-1])>=10**(-2) and k<ItMax-1:
# II.B.3.e.(vii)
nbIter=k
return nbIter,T_tous_k
# II.C.1.a.
epais=0.4 # 40cm
conduc=1.65
rho=2150
Cp=1000
Tint=20
Text1=10
Text2=-10
Dt
# II.C.1.d.
é
*
# II.C.1.e.
alpha=rho*Cp/float(conduc) # Python 2.7
Delta_x=epais/float(N+1)
r=Dt/(alpha*Delta_x**2)
# II.C.2.a.
def choix(T0,alpha,epais,Delta_t,Tint,Text2):
x=int(input('schéma explicite choix 0, schéma implicite choix 1'))
if :
schema_explicite(T0,alpha,epais,Delta_t,Tint,Text2)
else:
schema_implicite(T0,alpha,epais,Delta_t,Tint,Text2)
# II.C.3.a.
[nbIter, T_tous_k]=choix(T0, alpha, epais, Dt, Tint, Text2)
for in range(nbIter/100): # Python 2.7
plt.plot(x,T_tous_k[:,k])
#plt.xlabel('abscisse x')
#plt.ylabel('température')
plt.show()
# II.C.3.b.
temps=nbIter*Dt
print "Le régime permanent est atteint au bout de "+str(temps/60.)+" heures."
# si nbIter=ItMax il faut songer à augmenter la valeur de ItMax
CCINP Informatique Commune PC 2015 - Version Web LaTeX | WikiPrépa | WikiPrépa