- #1
Youssi
- 6
- 2
- TL;DR Summary
- Mathematic, error in using the command WhenEvent in Mathematica
Reference: https://www.physicsforums.com/forums/matlab-maple-mathematica-latex.189/post-thread
Hello, I'm trying to solve a heat differential equation to obtain the temperature distribution as a function of R. Since I have the coefficients of electrical and thermal conductivity that start from the temperature of 6500 K, I want the solution to stop when T reaches 6500. I'm using the command:
However, I'm encountering the following errors:
Can someone help me resolve this issue?
Thank you in advance for your assistance
The program is listed below :
Code:
WhenEvent[T[r] >= 6500, {RlimiteValue = r, "StopIntegration"}].
However, I'm encountering the following errors:
Code:
`Plot::plln: Limiting value RlimiteValue in {r, 1/10000000000, RlimiteValue} is not
a machine-sized real number.
Can someone help me resolve this issue?
Thank you in advance for your assistance
The program is listed below :
Code:
ClearAll["Global`*"]
(*Importation des coéfficient non linéaire : conductivité thermique et conductivité thermique*)
Lambda=Import["C:\\Users\\yousra\\Documents\\thèse\\Modélisation\\1_mathematica\\condu_therm_rer.xlsx"][[1]];
Sigma=Import["C:\\Users\\yousra\\Documents\\thèse\\Modélisation\\1_mathematica\\condu_elec.xlsx"][[1]];
(*Interpolation et création des fonctions de Lamdba et sigma*)
(*Lambda*)
λInterp=Interpolation[Lambda,InterpolationOrder->1];
(*Définir la fonction λ(t)*)
Clear[λ];
λ[t_]:=λInterp[t];
(*Vérifier la fonction λ(t) pour quelques valeurs de t*)
λ[3000];
λ[700];
λ[12000];
(*sigma*)
σInterp=Interpolation[Sigma,InterpolationOrder->1];
(*Définir la fonction σ(t)*)
Clear[σ];
σ[t_]:=σInterp[t];
σ[3000];
(*Dessin de lambda et sigma interpolé*)
(*Tracer la fonction λ(t)*)
Plot[λ[t],{t,Min[Lambda],Max[Lambda]},AxesLabel->{"t","λ(t)"},PlotLabel->"Plot of λ(t)"]
(*Tracer la fonction σ(t)*)
Plot[σ[t],{t,Min[Sigma],Max[Sigma]},AxesLabel->{"t","σ(t)"},PlotLabel->"Plot of σ(t)"]
(*l'équation de chaleur*)
Equ1=Div[λ[T[r]]*Grad[T[r],{r,θ,z},"Cylindrical"],{r,θ,z},"Cylindrical"]+σ[T[r]]*F^2==0//FullSimplify
F=6000;
Tmax=29000;
(*sol=NDSolve[{Equ1,T'[0]==0,T[0]==10000,T[10^-2]==6000},T,{r,0,10^-2}][[1]];
Plot[T[r]/. sol,{r,0,10^-2},AxesLabel->{"r","T(r)"},PlotLabel->"Graphique de T en fonction de r"]*)
(*Define the solution*)
(*Define the solution*)
(*Define the solution*)
sol=NDSolveValue[{Div[λ[T[r]]*Grad[T[r],{r,θ,z},"Cylindrical"],{r,θ,z},"Cylindrical"]+σ[T[r]]*F^2==0,
T'[10^-10]==0,
T[10^-10]==Tmax,
WhenEvent[T[r]>=6500,{RlimiteValue=r,"StopIntegration"}]},
T,{r,10^-10,10^-2}];
(*Print the result*)
Print["Rlimite corresponding to T >= 6500: ",RlimiteValue]
(*Plot the solution up to the RlimiteValue*)
Plot[sol[r],
{r, 10^-10, RlimiteValue},
AxesLabel -> {"r", "T[r]"},
PlotLabel -> "Solution up to RlimiteValue"]
Plot[sol[r],
{r,10^-10,RlimiteValue},
AxesLabel->{"r","T[r]"},
PlotLabel->"Solution up to RlimiteValue"]
Last edited by a moderator: