How can I get data from For
loops to use in ListStreamDensityPlot
? I tried AppendTo
, but it didn't work. I probably did it wrong.
Clear[a, x, y, z, m, n, o, Bx, By, Bz]
a = 0.1 (*amplitude*)
z = 0 (*ploting on different heights*)
For[i = 1; x = m, i < 6, i++, x = 2 Pi/4*(i - 1);
For[j = 1; y = n, j < 7, j++, y = -3 + (j - 1);
{Bx = NIntegrate[a*z*Cos[t]/((t^2 - 2 t x + x^2 + y^2 + z^2)^(3/2) -
3 (y Sqrt[t^2 - 2 t x + x^2 + y^2 + z^2]Sin[t]) a),
{t, -Infinity, Infinity}, AccuracyGoal -> 20,MaxRecursion -> 15];
By = NIntegrate[-z/((t^2 - 2 t x + x^2 + y^2 + z^2)^(3/2) -
3 (y Sqrt[t^2 - 2 t x + x^2 + y^2 + z^2]Sin[t]) a),
{t, -Infinity, Infinity}, AccuracyGoal -> 20, MaxRecursion -> 15];
Bz = NIntegrate[(y + a*(t*Cos[t] - x*Cos[t] - Sin[t]))/
((t^2 - 2 t x + x^2 + y^2 + z^2)^(3/2) -
3 (y Sqrt[t^2 - 2 t x + x^2 + y^2 + z^2]Sin[t]) a),
{t, -Infinity, Infinity}, AccuracyGoal -> 20, MaxRecursion -> 15]};
]
]
ListStreamDensityPlot[{x, y}, {Bx, By, Bz}]
I only get
[out]=ListStreamDensityPlot[{2 \[Pi], 2}, {0., 0., 1.00294}]
Thanks in advance.
EDIT: With the help of Verbeia I can now make the plot. I would like to get something like this https://i.sstatic.net/3ixqI.png
My wire is a different one than the above though. Mine is a sinusoid.
Is ListVectorDensityPlot the right plot to get plots like the ones above?
a = 0.1
x = Pi/2
data = Table[With[{y = -1 + 0.1 (i - 1),
z = -1 + 0.1 (j - 1)}, {{NIntegrate[ a*z*Cos[t]/((t^2 - 2 t x + x^2 +
y^2 + z^2)^(3/2) - 3 (y Sqrt[t^2 - 2 t x + x^2 + y^2 + z^2] Sin[t]) a),
{t, -Infinity, Infinity}, AccuracyGoal -> 20, MaxRecursion -> 20],
NIntegrate[-z/((t^2 - 2 t x + x^2 + y^2 + z^2)^(3/2) -
3 (y Sqrt[t^2 - 2 t x + x^2 + y^2 + z^2] Sin[t]) a),
{t, -Infinity,Infinity}, AccuracyGoal -> 20, MaxRecursion -> 20]},
NIntegrate[(y + a*(t*Cos[t] - x*Cos[t] - Sin[t]))/((t^2 - 2 t x + x^2 + y^2 +
z^2)^(3/2) - 3 (y Sqrt[t^2 - 2 t x + x^2 + y^2 + z^2] Sin[t]) a),
{t, -Infinity, Infinity}, AccuracyGoal -> 20, MaxRecursion -> 20]}],
{i, 1, 21}, {j, 1, 21}]
ListVectorDensityPlot[data, DataRange -> {{-1, 1}, {-1, 1}}]
I get this graph. https://i.sstatic.net/YvqyD.jpg
The field should be rotational.
Is the problem that integrals don't converge? How can I improve the convergence of integrals then? I doubt upping max recursions to 80 would be smart because it would increase the process time a lot. It takes a couple of minutes anyway.
Table[]
? $\endgroup$