Message Boards Message Boards

0
|
5615 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Magnetic field of torus in Mathematica

Posted 9 years ago

Hello , I am a student of electrical engineering. I'm new here, I'm trying to model the magnetic field inside a toroid . But I'm finding it very difficult to do so. The code below is an example already compiled a code I found on the internet , but when I copied the code to a new nb and tried to run it accused the compiler error. Someone could test and tell me what 's wrong? the result should be a magnetic field composed of arrows

bfieldp = {0, 0, 
  1/(2*\[Pi]*
     r)}(*This is the simplified expression for magnetic field, in \
spherical coordinates *)
bCartp = TransformedField["Spherical" -> "Cartesian", 
  bfieldp, {r, \[Theta], \[CurlyPhi]} -> {x, y, 
    z}] (*Here, I convert the spherical expression for B to \
cartesian, since that is what VectorPlot3D takes as input*)
bzero = (Piecewise[{{1, 2.5 < Sqrt[x^2 + y^2 + z^2] < 3.8}}, 0])
fullp = Show[
  VectorPlot3D[(bCartp*bzero), {x, -3.5, 3.5}, {y, -3.5, 
    3.5}, {z, -3.5, 3.5}, ViewPoint -> Above] ]
POSTED BY: Aleff Vinicius
6 Replies
Posted 9 years ago

Do not want to mess up a lot, but do you have any idea how to implement this code to animalo and make the vectors move in the direction to which they point . In the case revolve around this central axis , so that when plotted in the toroid becomes simulating the magnetic field.

POSTED BY: Aleff Vinicius

Here is the documentation for Piecewise:

http://reference.wolfram.com/language/ref/Piecewise.html

The particular use in

Piecewise[{{1, 2.5 < Sqrt[x^2 + y^2 + z^2] < 3.8}}, 0]

is a function of x, y and z which is 1 in the spherical shell with a radius between 2.5 and 3.8 and zero elsewhere. So in the expression

bCartp * Bzero 

the multiplication by Bzero is just making the function bCartp be non-zero only within that spherical shell.

POSTED BY: David Reiss
Posted 9 years ago

Ohh , great. Now is working here. Another thing you could explain to me what the next line is :

bzero = (Piecewise[{{1, 2.5 < Sqrt[x^2 + y^2 + z^2] < 3.8}}, 0])

And also because in VectorPlot3d expression appears ( bCartp * Bzero ) ?

POSTED BY: Aleff Vinicius
Posted 9 years ago

Magnetic field of torus in Mathematica

POSTED BY: Aleff Vinicius

What errors do you get?
The code worked fine for me. Note that you do not need the Show in the final line.

Here is the resulting graphic:

enter image description here

POSTED BY: David Reiss
Posted 9 years ago

What version do Your Mathematica ? Mine is 10

POSTED BY: Aleff Vinicius
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract