Mathematica table integration error

Click For Summary
SUMMARY

The forum discussion addresses an issue with calculating the temperature distribution and current distribution using Mathematica. The user employs the command table=Table[{x,NIntegrate[2*Pi*r*σ[sol[r]]*F/Iarc,{r,10^(-10),x}]},{x,10^(-10),Rlimite}] but encounters a limitation where the integral only computes for a single value of x. The solution involves adjusting the step size in the Table command to allow for more values of x to be evaluated, potentially using a logarithmic scale for better results.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of numerical integration techniques in Mathematica
  • Knowledge of interpolation methods in Mathematica
  • Basic concepts of cylindrical coordinates in mathematical modeling
NEXT STEPS
  • Learn how to implement custom step sizes in Mathematica's Table function
  • Explore logarithmic scaling techniques for numerical computations
  • Investigate advanced numerical integration methods in Mathematica
  • Study the use of NDSolve for solving differential equations in Mathematica
USEFUL FOR

Mathematica users, engineers, and researchers involved in computational modeling of thermal and electrical distributions, particularly those working with numerical integration and interpolation techniques.

Youssi
Messages
6
Reaction score
2
TL;DR
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
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

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K