Simulating a solenoid in Elmer

General discussion about Elmer
Post Reply
granzer
Posts: 49
Joined: 23 Feb 2021, 10:48
Antispam: Yes

Simulating a solenoid in Elmer

Post by granzer »

Hello, I am new to Elmer and to simulating electromagnetic fields as I come from a background in simulating fluid flow fields and FVM.

Problem Definition: Currently I am trying to simulate the magnetic field created around a solenoid and measure the actuation force the generated magnetic field would impose on the plunger at the core of the solenoid.

What I have learnt so far: Going through the various manuals and post on the forum I have come to the understating that to solve my problem I have to put together hierarchical solver consisting of coilSolver to get the current in the coil -> then use magdyn solver to simulate the magnetic field this current would generate -> 'magdynpost' to derive required quantity -> and somehow get the magnetic field to apply force on the plunger.
Ref: viewtopic.php?t=6954
elmerfem.org/forum/viewtopic.php?f=3&t=6939
viewtopic.php?t=4007
http://elmerfem.org/forum/viewtopic.php?t=7254
viewtopic.php?t=6905

My Queries: Currently I am facing problem on the first step ie modeling the coil itself.( I am hoping I don't have to model every single turn in the coil on a CAD software and then meh it as the number of turns for my model is larger and the radius of the wire is pretty small.)
i)For creating a coil, I read that the computational model is created as a closed loop (it my understating that this is like a solid cylinder of certain thickness and the current is looped around this cylinder using 'coilSolver' and the cylinder doesn't need to have a input and outlet). How does one give the number of turns in the the coil and the wire diameter or does it not matter how many turns the winding has [As its my rudimentary understating that the number of turns in the coil does have a effect on the generated magnetic field. One cannot replace a, say, winding made of 1 x 1 mm copper wire (let it be square wire) and having 3 layers (so the winding is 3mm thick) with a winding made of 3 x 3 mm copper wire but not layered. Wont the skin effects be more pronounced in thicker wires]?
ii) I did find the mention of 'number of turns' (but not dia of wire) in the CircuitsAndDynamics solver using stranded coil type. Can this be used to model the coil for my purpose?
granzer
Posts: 49
Joined: 23 Feb 2021, 10:48
Antispam: Yes

Re: Simulating a solenoid in Elmer

Post by granzer »

Anyone knows anything about these questions that could help out?
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Simulating a solenoid in Elmer

Post by raback »

Hi,

Well, if you have a number of turns you can just multiply the current with that.

The CoilSolver does not currently use the same definitions as the circuit simulator. We should harmonize some of this stuff. So just use the "desired coil current".

If you aim to model skin effects of individual wires then you have to mesh them also individually. However, this is not usually done. Maybe if you would like to make some academic study of accuracy of homogenization would it be worth the effort as a reference solution.

-Peter
granzer
Posts: 49
Joined: 23 Feb 2021, 10:48
Antispam: Yes

Re: Simulating a solenoid in Elmer

Post by granzer »

raback wrote: 26 Feb 2021, 16:55 Hi,

Well, if you have a number of turns you can just multiply the current with that.

The CoilSolver does not currently use the same definitions as the circuit simulator. We should harmonize some of this stuff. So just use the "desired coil current".

If you aim to model skin effects of individual wires then you have to mesh them also individually. However, this is not usually done. Maybe if you would like to make some academic study of accuracy of homogenization would it be worth the effort as a reference solution.

-Peter
Hello Mr.Peter, Thank you for your time.
If I am using the CoilSolver to simulate a coil, making a CAD model of the coil as a solid cylinder with wall thickness that is the same as the coil thickness, and give current density as the condition, then will this 'cylinder' will act similar to a coil with a given number of turns? I am asking because the cylinder is a thick solid piece and coils are made of thin would wire.
No, I am not looking to capture the skin effect, I want the current inside the cylinder to be properly distributed, like in the case of a coil, and not be concentrated towards the cylinder wall's edge. I am asking to make sure that a thick solid piece of the cylinder will act as a coil (made of thin would wire), i.e. the current in the thick wall of the cylinder won't just be concentrated towards the edge of the cylinder if the current is varying (because I saw in the magDyn tutorial I saw that magDyn solver was capturing the skin effect).

I am Sorry if these questions sound trivial, but I am new to modeling EM fields and trying to get the hang of the ropes.

Best Regards,
-Mandeep
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Simulating a solenoid in Elmer

Post by raback »

Hi Mandeep,

If you use "normalize coil current = logical true" then the current density will be constant. This corresponds to a stranded coil whereas the non-normalized current density would be for massive coil.

Note that after normalization the current density might not be exactly divergence free. Therefore you must use "fix input current density" flag to enable a convergent solution.

-Peter
granzer
Posts: 49
Joined: 23 Feb 2021, 10:48
Antispam: Yes

Re: Simulating a solenoid in Elmer

Post by granzer »

raback wrote: 26 Feb 2021, 18:44 Hi Mandeep,

If you use "normalize coil current = logical true" then the current density will be constant. This corresponds to a stranded coil whereas the non-normalized current density would be for massive coil.

Note that after normalization the current density might not be exactly divergence free. Therefore you must use "fix input current density" flag to enable a convergent solution.

-Peter
Hello Mr.Peter,
Thank you so much for your valuable input. When you say "then the current density will be constant" I am taking it to mean that current density at any 'point' in the coil cross section will have the same value. Please do correct me if I am wrong.
I am using Elmer on Windows 10 with GUI and I am not able to find he CoilSolver in the Model->equations, nor can i find the 'coilSolver.xml' to load the definitions from. I did however find the a dynamic lib file called coilSolve.dll but not sure how to load it and use it in GUI. Is the coilSolver only available for non-gui use?
I also found this post from 2015, containing the coilSolver efd: viewtopic.php?t=4086.
Has the Elmer installation not been updated to contain the coilSolver edf yet and so should I use this .xml file?

Best Regards,
-Mandeep
granzer
Posts: 49
Joined: 23 Feb 2021, 10:48
Antispam: Yes

Re: Simulating a solenoid in Elmer

Post by granzer »

This answers.my previous question I guess: viewtopic.php?t=4124
ftrillaudp
Posts: 42
Joined: 23 May 2012, 05:26
Antispam: Yes

Simulating a solenoid with manually imposed current density in Elmer

Post by ftrillaudp »

Dear all,

I did a quick test for a solenoid with a manually impressed current density. If it is of use, here is the code. Body 1 is a long solenoid with a thin wall and Body 2 is the surrounding air (a sphere). The mesh is too large to be added, therefore I am attaching a picture of the solenoid and the current density.

The definition of the current etc... in the Simulation body is for my specific case study (not detailed here). It is only used here for defining the time step and the number of time steps for a transient case.

Header
CHECK KEYWORDS Warn
Mesh DB "." "MESH"
Results Directory "RESU"
End

$ scaling=0.001
$ coilWidth=0.015
$ coilThickness=0.6
$ coilInnerRadius=0.18
$ airRadius=1.2

Simulation
Coordinate System = String "Cartesian 3D"
Coordinate Mapping(3) = 1 2 3
Simulation Type = String "Transient"
Steady State Max Iterations = 1
TimeStepping Method = BDF
BDF Order = 1

$ I = 100 / (coilWidth*coilThickness)
$ ramp_rate = 1000 ! A/s
$ ramp_time = I/ramp_rate ! time to reach the current I in [s]
$ plateau_time = 1
$ nof_tstp_1 = 10
$ nof_tstp_2 = 100
$ sz_tstp_1 = ramp_time / nof_tstp_1
$ sz_tstp_2 = plateau_time / nof_tstp_2
Timestep Sizes(2) = Real $ sz_tstp_1 sz_tstp_2
TimeStep Intervals(2) = Integer $ nof_tstp_1 nof_tstp_2
Output Intervals(2) = Integer 1 1

Max Output Level = 5
End

Constants
Gravity(4) = 0 0 -1 9.82
Stefan Boltzmann = 5.67e-08
Permittivity of Vacuum = 8.8542e-12
Permeability of Vacuum = 1.256e-6
Boltzmann Constant = 1.3807e-23
Unit Charge = 1.602e-19
End

Body 1
Name = "coil"
Target Bodies(1) = 1
Equation = 1
Material = 2
Body Force = 1
Initial Condition = 1
End

Body 2
Name = "air"
Target Bodies(1) = 2
Equation = 1
Material = 1
Initial Condition = 1
End

Material 1
Name = "Air"
Relative Permeability = Real 1.0
Relative Permittivity = Real 1.0
End

Material 2
Name = "Inductor"
Relative Permeability = Real 1.0
Relative Permittivity = Real 1.0
End

Initial Condition 1
Name = "Initial state"
A {e} = real 0
A = real 0
End

Boundary Condition 1
Name = "Air boundary"
Target Boundaries(1) = 4
A {e} = real 0
A = real 0.0
End

Body Force 1
Name = "Source"
Current Density 1 = Variable Coordinate 1, Coordinate 2; Real lua "-1e6*sin(math.atan2(tx[1],tx[0]))"
Current Density 2 = Variable Coordinate 1, Coordinate 2; Real lua "1e6*cos(math.atan2(tx[1],tx[0]))"
Current Density 3 = Real 0.0
End

!!! SOLVERS !!!
Solver 1 !---- MagnetoDynamics, WhitneyAVSolver: A-V solver
Exec Solver = Always

Equation = "MGDynamics"
Variable = "A"
Procedure = "MagnetoDynamics" "WhitneyAVSolver"

Nonlinear System Relaxation Factor = 1
Nonlinear System Consistent Norm = Logical True

Linear System Robust = Logical True
Linear System Solver = Iterative
Linear System Iterative Method = BicgstabL
Linear System preconditioning = none
Linear System Convergence Tolerance = 1e-8
Linear System Max Iterations = 1000
Linear System Residual Output = 10
Linear System ILUT Tolerance=1e-6
BicgstabL polynomial degree = 6
Linear System Row Equilibration = Logical True

Steady State Convergence Tolerance = 1e-6

Export Lagrange Multiplier = Logical True

Automated Source Projection BCs = Logical False
Fix Input Current density = Logical True
End

Solver 2 !---- MagnetoAndDynamics, MagnetoDynamicsCalcFields: filed computation from A-V solver
Exec Solver = Always
Equation = MGDynamicsCalc
Procedure = "MagnetoDynamics" "MagnetoDynamicsCalcFields"

Potential Variable = String "A"

Steady State Convergence Tolerance = 1.0e-6

Linear System Solver = Iterative
Linear System Symmetric = True
Linear System Iterative Method = CG
Linear System Max Iterations = 2000
Linear System Convergence Tolerance = 1.0e-6
Linear System Preconditioning = ILU0
Linear System ILUT Tolerance = 1.0e-3
Linear System Abort Not Converged = False
Linear System Residual Output = 1
Linear System Precondition Recompute = 1
Discontinuous Bodies = Logical True

Calculate Elemental Fields = Logical True
Calculate Current Density = Logical True
End

Solver 3 !--- ResultOuputSolve, ResultOuputSolver: save computed fields
Exec Solver = After timestep
Equation = "ResultOutput"
Procedure = "ResultOutputSolve" "ResultOutputSolver"

Vtu Format = Logical True
Binary Output = Logical True

Output File Name = File "coil"

Save Geometry Ids = Logical True
End


Equation 1
Name = "Magnetostatics"
Active Solvers(3) = 1 2 3
End


Best,

Frederic
Attachments
currentDensity.png
Curren density in solenoid
(474.48 KiB) Not downloaded yet
Post Reply