Creating a uniform H-field and a question about the B-field

General discussion about Elmer
Post Reply
Nick_99
Posts: 42
Joined: 12 Jul 2023, 10:07
Antispam: Yes

Creating a uniform H-field and a question about the B-field

Post by Nick_99 »

Hi everyone,

I'm experimenting with creating regions that have uniform B- or H-fields. I have two questions.

Uniform B-field
I can successfully create a uniform B-field by using similar boundary conditions given in this post. In my sim, I just have a cylinder lying along the z-axis. The material is set to air. The BCs for the sides of the cylinder are

Code: Select all

Boundary Condition 1 ! left side
  Target Boundaries(1) = 1 
  Name = "BoundaryCondition 1"
  Magnetic Flux Density 3 = Real 5.0
End

Boundary Condition 2 ! right side
  Target Boundaries(1) = 2 
  Name = "BoundaryCondition 2"
  Magnetic Flux Density 3 = Real 5.0
End


The rectangular part of the cylinder has the following BC

Code: Select all

Boundary Condition 3 ! rectangle
  Target Boundaries(1) = 3 
  Name = "BoundaryCondition 3"
  Magnetic Flux Density {n} = Real 0.0
End
My resulting magnetic flux density is
mag_flux_density.png
(19.83 KiB) Not downloaded yet

My question has to do with the edges of the plot. Why does it look like the plot is tending towards infinity? Does it have to do with the simulator trying to obey the rule that the normal component of the flux density is continuous just before and just after an interface between two different materials? So the infinity would be a result of the outside of the region not being defined.

Uniform H-field
If my understanding is correct, I can create an arbitrary H-field using the Magnetic Field Strength 1..3 keyword. However, if I replace the boundary conditions mentioned earlier with that keyword (see code below), I can only get the solver to run successfully if I set everything to zero. The other combinations I've tried either end up in a solution that doesn't converge or H-fields that flow from the top of one side and back down to the bottom of the same side (this happens if I set BC3 to use AV {e} = 0).

Code: Select all

Boundary Condition 1 ! left circle
  Target Boundaries(1) = 1 
  Name = "BoundaryCondition 1"
  Magnetic Field Strength 1 = Real 0.0
  Magnetic Field Strength 2 = Real 0.0
  Magnetic Field Strength 3 = Real 0.0
End

Boundary Condition 2 ! right circle
  Target Boundaries(1) = 2 
  Name = "BoundaryCondition 2"
  Magnetic Field Strength 1 = Real 0.0
  Magnetic Field Strength 2 = Real 0.0
  Magnetic Field Strength 3 = Real 0.0
End

Boundary Condition 3 ! rectangle
  Target Boundaries(1) = 3 
  Name = "BoundaryCondition 3"
  Magnetic Field Strength 1 = Real 0.0
  Magnetic Field Strength 2 = Real 0.0
  Magnetic Field Strength 3 = Real 0.0
End
Does anyone have any advice for me to create a uniform H-field? The complete sif as well as the geometry input file are attached to this post.

If it helps, here is the gmsh file as well.

Code: Select all

SetFactory("OpenCASCADE");

Circle(1) = {0, 0, -300, 200, 0, 2*Pi};

Curve Loop(1) = {1};
Plane Surface(1) = {1};

Extrude {0, 0, 600} { Curve{1}; }

Curve Loop(3) = {3};
Plane Surface(3) = {3};
Surface Loop(1) = {1, 2, 3};

Volume(1) = {1};
Thanks in advance.

Kind regards,
Nick.
Attachments
untitled.msh
(859.69 KiB) Downloaded 28 times
case.sif
(3.78 KiB) Downloaded 32 times
Nick_99
Posts: 42
Joined: 12 Jul 2023, 10:07
Antispam: Yes

Re: Creating a uniform H-field and a question about the B-field

Post by Nick_99 »

Hmm ok so I think I have something but I'm just a bit suspicious of the result :lol: Can someone tell me if this looks sensible?

I went back to using a cube instead of a cylinder as I think the circular nature of the cylinder was confusing me when it came to making the boundary conditions.

The boundary conditions are as follows

Code: Select all

Boundary Condition 1
  Target Boundaries(1) = 1
  Name = "Front"
  Magnetic Field Strength 2 = Real 1000
End

Boundary Condition 2
  Target Boundaries(1) = 2
  Name = "Back"
  Magnetic Field Strength 2 = Real -1000
End

Boundary Condition 3
  Target Boundaries(1) = 5
  Name = "Left"
  Magnetic Field Strength 3 = Real 1000
End

Boundary Condition 4
  Target Boundaries(1) = 6
  Name = "Right"
  Magnetic Field Strength 3 = Real 1000
End

Boundary Condition 5
  Target Boundaries(2) = 3 4 
  Name = "Top_and_Bottom"
  AV {e} = Real 0
End

The glyphs in ParaView can be seen below. The range for the scale might be of interest.
field_strength_glyphs.png
(455.52 KiB) Not downloaded yet

The field strength plotted over a line that runs diagonally from one top corner to the opposite bottom corner can be seen below. Again, the range of the y-axis might be of interest.
field_strength_plot.png
(27.32 KiB) Not downloaded yet

I'm guessing the glyphs having slightly different magnitudes and the plot having different magnitudes despite the ranges being zero is a result of my mesh size not being very fine.

The complete case.sif is attached. The gmsh script can be seen below.

Code: Select all

// Gmsh project created on Fri Aug 11 14:40:33 2023
SetFactory("OpenCASCADE");
Box(1) = {-0.5, -0.5, -0.5, 1, 1, 1};
Kind regards,
Nick
Attachments
case.sif
(3.69 KiB) Downloaded 34 times
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Creating a uniform H-field and a question about the B-field

Post by raback »

I don't think you have to worry about some 6th decimal or so. It seems that the 4 first numbers are correct. There will always be some noise when using iterative methods...
Nick_99
Posts: 42
Joined: 12 Jul 2023, 10:07
Antispam: Yes

Re: Creating a uniform H-field and a question about the B-field

Post by Nick_99 »

Thanks for double checking for me. Much appreciated.

Would you also happen to know why the B-field behaves weirdly close to the boundaries (see this image from my first post)? This is more just out of curiosity than anything else.

Cheers,
Nick
Post Reply