Mathematica table integration error

  • #1
Youssi
6
2
TL;DR Summary
Error in Table Command: Storing Integration Results for Different Upper Bounds
I am calculating the temperature distribution and utilizing the obtained results to calculate the current distribution. In order to do this , I employ a table in which I stock all the current distribution for each value of radius . Subsequently, I aim to identify the radius corresponding to a current distribution of 0.9 with a precision of 0.01. Here are the commands I am using:

table=Table[{x,NIntegrate[2*Pi*r*σ[sol[r]]*F⁄Iarc,{r,10^(-10),x}]},{x,10^(-10),Rlimite}]
table// TableForm
desiredValue=0.9;
precision=0.01;
selectedValues=Select[table,Abs[#[[2]]-desiredValue]<precision&]
chosenX=First[selectedValues][[1]]
The command (table) provides results for only a single value, ( x is within the range of 10^-10 and Rlimite = 0.0071150228199034085). Below are the results for the command table I am utilizing:
{{1/10000000000,0.}}

So It ‘s doesn’t calculate the integral for all the values of x.

the whole program is bellow :

Code:
ClearAll["Global`*"

(*Importation des coéfficient non linéaire : conductivité thermique \

et conductivité thermique*)

Lambda =

Import["C:\\Users\\calcul\\Desktop\\1_mathematica\\condu_therm_rer.\

xlsx"][[1]];

Sigma = Import[

"C:\\Users\\calcul\\Desktop\\1_mathematica\\condu_elec.xlsx"][[1]];



(*Interpolation et création des fonctions de Lamdba et sigma*)

(*Lambda*)

\[Lambda]Interp = Interpolation[Lambda, InterpolationOrder -> 1];

(*Définir la fonction \[Lambda](t)*)

Clear[\[Lambda]];

\[Lambda][t_] := \[Lambda]Interp[t];

(*sigma*)

\[Sigma]Interp = Interpolation[Sigma, InterpolationOrder -> 1];

(*Définir la fonction \[Sigma](t)*)

Clear[\[Sigma]];

\[Sigma][t_] := \[Sigma]Interp[t];

F = 600;

Tmax = 20000;

(*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"]*)

Rlimite = 0;

sol = NDSolveValue[{Div[\[Lambda][T[r]]*

Grad[T[r], {r, \[Theta], z}, "Cylindrical"], {r, \[Theta], z},

"Cylindrical"] + \[Sigma][T[r]]*F^2 == 0, T'[10^-10] == 0,

T[10^-10] == Tmax,

WhenEvent[T[r] <= 6500, {Rlimite = r, "StopIntegration"}]},

T, {r, 10^-10, 10^-2}];

Iarc = NIntegrate[2*\[Pi]*r*\[Sigma][sol[r]]*F, {r, 10^-10, Rlimite}]

(*plot de la dsitriution du courant en fonction du rayon de l'arc*)

Plot[NIntegrate[2*\[Pi]*r*\[Sigma][sol[r]]*F, {r, 10^-10, x}]/

Iarc, {x, 10^-10, Rlimite},

AxesLabel -> {"Rayon de l'arc[m]", "Distribution du courant "}]

(*Générer un tableau de valeurs pour différentes valeurs de x*)

table = Table[{x,

NIntegrate[2*Pi*r*\[Sigma][sol[r]]*F/Iarc, {r, 10^-10, x}]}, {x,

10^-10, Rlimite}]

(*Afficher le tableau résultant*)

table // TableForm

desiredValue = 0.9;

precision = 0.01;



(*Utiliser Select pour filtrer les résultats*)

selectedValues =

Select[table, Abs[#[[2]] - desiredValue] < precision &]



(*Si plusieurs valeurs sont proches de 0.9,vous pouvez choisir la \

première*)

chosenX = First[selectedValues][[1]]



(*Afficher le résultat*)

chosenX
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
By default the Table steps the variable by 1 unit at a time, so for {x,10^(-10),Rlimite} with Rlimite = 0.0071150228199034085, you get only x = 10^(-10) since 10^(-10) + 1 < Rlimite. You need to use something like {x,10^(-10),Rlimite,xstep} with xstep the step you want to take in x. However, my guess is that you would be better off using a logarithmic scale, so you will have to rework this a bit.

By the way, please use CODE tags to delimit code. I have edited your post accordingly.
 

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
333
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
331
  • Math Proof Training and Practice
3
Replies
97
Views
19K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top