Using Component keywords

The graphical user interface of Elmer
Post Reply
matsuiSL
Posts: 7
Joined: 15 Oct 2022, 02:48
Antispam: Yes

Using Component keywords

Post by matsuiSL »

I'm trying to extract the magnetic forces between an electromagnet and an iron plate in a 3D steady state MgDyn problem.

I've seen a few mentions to the 'Component' keyword but found it to be poorly documented in the sense of how to actually use it to obtain the desired results.

My question is essentially: what's the best practice for extracting magnetic forces from a body? Would rather not manually post process from nodal forces.

.sif file:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
End

Simulation
  Max Output Level = 5
  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = Steady state
  Steady State Max Iterations = 100
  Output Intervals(1) = 10
  Solver Input File = case.sif
  Post File = case.vtu
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.670374419e-08
  Permittivity of Vacuum = 8.85418781e-12
  Permeability of Vacuum = 1.25663706e-6
  Boltzmann Constant = 1.380649e-23
  Unit Charge = 1.6021766e-19
End

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

Body 2
  Target Bodies(1) = 2
  Name = "2"
  Equation = 2
  Material = 3
End

Body 3
  Target Bodies(1) = 3
  Name = "3"
  Equation = 2
  Material = 1
End

Solver 2
  Equation = MgDyn
  Use Elemental CoilCurrent = True
  Fix Input Current Density = True
  Procedure = "MagnetoDynamics" "WhitneyAVSolver"
  Exec Solver = Always
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 30
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILU0
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 1
  Equation = MgDynPost
  Procedure = "MagnetoDynamics" "MagnetoDynamicsCalcFields"
  Skip Nodal Fields = False
  Calculate Current Density = True
  Discontinuous Bodies = True
  Calculate Nodal Forces = True
  Exec Solver = Before Saving
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILU0
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 3
  Equation = CoilSolver
  Coil Closed = True
  Coil Normal(3) = 0 0 1
  Narrow Interface = True
  Normalize Coil Current = True
  Desired Coil Current = 1000
  Procedure = "CoilSolver" "CoilSolver"
  Fix Input Current Density = True
  Exec Solver = Before Simulation
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILU0
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

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

Equation 2
  Name = "air"
  Active Solvers(2) = 2 1
End

Material 1
  Name = "air"
  Heat Conductivity = 0.0257
  Relative Permeability = 1.00000037
  Heat Capacity = 1005.0
  Viscosity = 1.983e-5
  Sound speed = 343.0
  Heat expansion Coefficient = 3.43e-3
  Density = 1.205
  Relative Permittivity = 1.00059
End

Material 2
  Name = "alu"
  Electric Conductivity = 3.526e7
  Relative Permeability = 1
End

Material 3
  Name = "Iron (generic)"
  Mesh Poisson ratio = 0.29
  Density = 7870.0
  Youngs modulus = 193.053e9
  Heat Conductivity = 80.2
  Sound speed = 5000.0
  Electric Conductivity = 10.30e6
  Heat expansion Coefficient = 11.8e-6
  Heat Capacity = 449.0
  Relative Permeability = 200000
End

Body Force 1
  Name = "coil current"
  Current Density Multiplier = 1
End

Boundary Condition 1
  Target Boundaries(6) = 25 26 27 28 29 30 
  Name = "inf"
  AV {e} = 0
  Jfix = real 0.0
End

Component 1
  Calculate Magnetic Force = True
  Master Bodies = 1
End
The problem runs okay but I'm not sure where magdynpost is outputting the component results?

Code: Select all

ComputeChange: NS (ITER=1) (NRM,RELC): ( 0.10940997E-02  2.0000000     ) :: mgdynpost

       5 0.9004E-11

ComputeChange: NS (ITER=2) (NRM,RELC): ( 0.10972690E-02 0.28924992E-02 ) :: mgdynpost

       5 0.5368E-11

ComputeChange: NS (ITER=3) (NRM,RELC): ( 0.15190562E-02 0.32242726     ) :: mgdynpost
SolveLinearSystem: Solution trivially zero!
SolveLinearSystem: Solution trivially zero!
SolveLinearSystem: Solution trivially zero!
WARNING:: ListFind: 
WARNING:: ListFind:  Requested property: [Name], not found
WARNING:: ListFind: 

WARNING:: ListFind: 
WARNING:: ListFind:  Requested property: [Name], not found
WARNING:: ListFind: 
MagnetoDynamicsCalcFields: Eddy current power:    0.000000E+00
MagnetoDynamicsCalcFields: ElectroMagnetic Field Energy:    4.491436E+00

ResultOutputSolver: -------------------------------------
ResultOutputSolver: Saving in unstructured VTK XML (.vtu) format

ResultOutputSolver: -------------------------------------
ElmerSolver: *** Elmer Solver: ALL DONE ***

ElmerSolver: The end
SOLVER TOTAL TIME(CPU,REAL):       146.70      146.70
ELMER SOLVER FINISHED AT: 2022/10/14 16:21:33
kevinarden
Posts: 2286
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Using Component keywords

Post by kevinarden »

My only experience with component names is in conjunction with the save scalar solver, this one prints out the sum of the nodal forces as the total force of the body
two_bodies.sif
(4.04 KiB) Downloaded 88 times
matsuiSL
Posts: 7
Joined: 15 Oct 2022, 02:48
Antispam: Yes

Re: Using Component keywords

Post by matsuiSL »

kevinarden wrote: 17 Oct 2022, 23:59 this one prints out the sum of the nodal forces as the total force of the body
I've added that Solver snippet but now I'm just trying to understand the meaning of the output. I've gotten the forces.dat file, but I'm not sure of how the data is formatted. I would have expected a 1x3 vector of Fx, Fy, Fz. But I'm getting a 1x5 vector of something I'm not sure of how to interpret.

Code: Select all

   0.000000000000E+000   4.491435661543E+000  -1.166961654382E-003  -2.847680669190E-003  -3.485839439160E+000
When I add a component for the iron plate body, I get a 1x8 vector.

Code: Select all

   0.000000000000E+000   4.491435661543E+000  -1.166961654382E-003  -2.847680669190E-003  -3.485839439160E+000   5.449568681620E-004   3.292338623747E-004   3.475852812277E+000
So given what I'm seeing, I'm not sure what the first two values are but the rest of the values seem to be [Fx,Fy,Fz],[Fx,Fy,Fz].... outputs of the requested bodies? The force reactions seem to balance out reasonably well within tolerance.

The .sif file as it stands

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
End

Simulation
  Max Output Level = 5
  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = Steady state
  Steady State Max Iterations = 100
  Output Intervals(1) = 10
  Solver Input File = case.sif
  Post File = case.vtu
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.670374419e-08
  Permittivity of Vacuum = 8.85418781e-12
  Permeability of Vacuum = 1.25663706e-6
  Boltzmann Constant = 1.380649e-23
  Unit Charge = 1.6021766e-19
End

Body 1
  Target Bodies(1) = 1
  Name = "coilbody"
  Equation = 1
  Material = 2
  Body Force = 1
End

Body 2
  Target Bodies(1) = 2
  Name = "platebody"
  Equation = 2
  Material = 3
End

Body 3
  Target Bodies(1) = 3
  Name = "airbody"
  Equation = 2
  Material = 1
End

Solver 2
  Equation = MgDyn
  Use Elemental CoilCurrent = True
  Fix Input Current Density = True
  Procedure = "MagnetoDynamics" "WhitneyAVSolver"
  Exec Solver = Always
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 30
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILU0
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 1
  Equation = MgDynPost
  Procedure = "MagnetoDynamics" "MagnetoDynamicsCalcFields"
  Skip Nodal Fields = False
  Calculate Current Density = True
  Discontinuous Bodies = True
  Calculate Nodal Forces = True
  Exec Solver = Before Saving
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILU0
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 3
  Equation = CoilSolver
  Coil Closed = True
  Coil Normal(3) = 0 0 1
  Narrow Interface = True
  Normalize Coil Current = True
  Desired Coil Current = -2742
  Procedure = "CoilSolver" "CoilSolver"
  Fix Input Current Density = True
  Exec Solver = Before Simulation
  Stabilize = True
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = ILU0
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 4
  Exec Solver = After All
  Equation = SaveScalars
  Procedure = "SaveData" "SaveScalars"
  Filename = "forces.dat"
  Save Component Results = logical true
End

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

Equation 2
  Name = "air"
  Active Solvers(2) = 2 1
End

Material 1
  Name = "air"
  Heat Conductivity = 0.0257
  Relative Permeability = 1.00000037
  Heat Capacity = 1005.0
  Viscosity = 1.983e-5
  Sound speed = 343.0
  Heat expansion Coefficient = 3.43e-3
  Density = 1.205
  Relative Permittivity = 1.00059
End

Material 2
  Name = "alu"
  Electric Conductivity = 3.526e7
  Relative Permeability = 1
End

Material 3
  Name = "Iron (generic)"
  Mesh Poisson ratio = 0.29
  Density = 7870.0
  Youngs modulus = 193.053e9
  Heat Conductivity = 80.2
  Sound speed = 5000.0
  Electric Conductivity = 10.30e6
  Heat expansion Coefficient = 11.8e-6
  Heat Capacity = 449.0
  Relative Permeability = 200000
End

Body Force 1
  Name = "coil current"
  Current Density Multiplier = 1
End

Boundary Condition 1
  Target Boundaries(6) = 25 26 27 28 29 30 
  Name = "inf"
  AV {e} = 0
  Jfix = real 0.0
End

Component 1
  Calculate Magnetic Force = True
  Master Bodies = 1
End

Component 2
  Calculate Magnetic Force = True
  Master Bodies = 2
End
Thanks for the help!
kevinarden
Posts: 2286
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Using Component keywords

Post by kevinarden »

There should be another file that provides the names of the variables printed in the output file. Do not know why the titles are not in the same file.
matsuiSL
Posts: 7
Joined: 15 Oct 2022, 02:48
Antispam: Yes

Re: Using Component keywords

Post by matsuiSL »

Ah yep got it.

Code: Select all

forces.dat.names
Thanks again!

Code: Select all

Elmer version: 9.0
Elmer revision: Release
Elmer compilation date: 2022-08-02
Solver input file: case.sif
File started at: 2022/10/18 10:34:02
 
Variables in columns of matrix: ./forces.dat
   1: res: eddy current power
   2: res: electromagnetic field energy
   3: component 1: res: magnetic force 1
   4: component 1: res: magnetic force 2
   5: component 1: res: magnetic force 3
   6: component 2: res: magnetic force 1
   7: component 2: res: magnetic force 2
   8: component 2: res: magnetic force 3
Post Reply