Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Numerical methods and mathematical models of Elmer
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by raback »

Hi

The quadratic elements require significantly more resources than the linear ones. It could be a memory allocation issue. Perhaps you could reduce the size problem significantly to eliminate that possibility.

-Peter
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

I had thought this was likely, I will try reducing the mesh density,

It would be nice if the output gave a little more information on what the problem might be, like 'Out of Mem' or similar;
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

Results for quad elements with reduced size mesh (1235170 elements) and no discontinuous bodies or galerkin:
I would say the femm and elmer results appear closer in this case, but Elmer's fields are still very spiky.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by raback »

Hi

Yes, looks better. I don't know how good a fit you can expect. Certainly with Elmer 2D the fit would be easier to make ;-) Are you sure that the iterative solvers have been solved with sufficient accuracy?

The vector potential has a nonzero null-space. Therefore comparing that does not necessarily make much sense. The uniqueness of the solution is ensured by the iterative Krylov methods. One could try to use the three gauge with direct solver also but that does not work in parallel. The derived fields should be comparable though...

-Peter
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

Well, the vector potential is important as this is used to compute important quantities, in particular the flux linkage in a coil by integrating directly on the A field (see viewtopic.php?f=3&t=4311&p=15365&hilit= ... 5ff#p15365 ).

Having said this, I am getting close results with such an integral on the field produced by Elmer in comparison with FEMM for the coil in this example (around 2% difference), so perhaps the noise cancels out over a given region?

I understand that 2D vs 2D would be a more direct comparison, but I'm not so interested in 2D as FEMM works very well for this. I'm mainly interested in Elmer for the 3D capabilities and this was the easiest way for me to compare the two. I would expect that a pure axisymmetric solution should give very similar results to the same problem in 3D? To be clear, FEMM is solving the problem in cylindrical coordinates, not Cartesian, so they should be very comparable solutions I think, including the vector potential.

A final plot using the quad mesh and Discontinuous Bodies = True
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

I will have a look into using the Tree Guage as a starting point.

To make sure it's not something I've done in my post processing, here's a screenshot of the same measurements in Paraview:
measuring_in_paraview.png
(334.5 KiB) Not downloaded yet
It actually looks much worse!
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

raback wrote: Are you sure that the iterative solvers have been solved with sufficient accuracy?
I'm pretty sure. I set the tolerance both Linear System Convergence Tolerance = 1.0e-8 and Steady State Convergence Tolerance = 1e-8 for the most recent examples, is there something else I should change?
raback wrote: One could try to use the three gauge with direct solver also but that does not work in parallel.
I tried using a direct solver and setting Use Tree Gauge = True

My first issue is that it is apparently incompatible with the Piola Transform, which means I can't use it with my quad mesh. However, I tried with my original mesh, but got a segfault. In all cases Elmer actually complains that "use tree gauge" is an unlisted keyword. Here's the sif file:

Code: Select all

$filename  = "elmer_vs_femm"  

! ======================================================================!
!	HEADER								!
! ======================================================================!

Header
   CHECK KEYWORDS "Warn"
   Mesh DB "/home/rcrozier/build/fea_temp_files/elmer_vs_femm" $filename
End

! ======================================================================!
!		Simulation						!
! ======================================================================!

Simulation
   Max Output Level = 7
   Coordinate System = "Cartesian 3D"
   Coordinate Mapping(3) = 1 2 3 
   Simulation Type = Steady state
   Steady State Max Iterations = 1
   Output Intervals = 1
   Use Mesh Names = Logical True
End

! ======================================================================!
!		Constants						!
! ======================================================================!

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

! ======================================================================!
!		Body, Material,	Body Force, Initial Cond.		!
! ======================================================================!

Material 1
  Name = "Air"
  Density = 1000
  Electric Conductivity = 0.0
  Relative Permeability = 1.0
End

Material 2
  Name = "Magnet"
  Density = 1000
  Electric Conductivity = 0.0
  Relative Permeability = 1.05
End

Material 3
  Name = "Iron"
  Density = 7500
  Electric Conductivity = 0.0
  Relative Permeability = 1000.0
  
  H-B Curve = Variable "dummy"
   Real  Cubic Monotone
     INCLUDE HB_Iron
   End
End

Body 1
   Name = "magnet"
   Equation = 1
   Material = 2
   Body Force = 1
End

Body 2
   Name = "core"
   Equation = 1
   Material = 3
End

Body 3
   Name = "coil"
   Equation = 1
   Material = 1
End

Body 4
   Name = "inner_air_box"
   Equation = 1
   Material = 1
End

Body 5
   Name = "outer_air_box"
   Equation = 1
   Material = 1
End

Body Force 1
   Name = "Magnetization"
   Magnetization 1 = Real 0.0
   Magnetization 2 = Real 0.0
   Magnetization 3 = Real 979000
End

! ======================================================================!
!			Equations and Solvers				!
! ======================================================================!

Solver 1
   Equation = "MGDynamics"

   Variable = "A"

   Procedure = "MagnetoDynamics" "WhitneyAVSolver"
   Fix Input Current Density = Logical True

   Newton-Raphson Iteration = Logical True
   Nonlinear System Max Iterations = 30
   Nonlinear System Convergence Tolerance = 1e-6

   Linear System Symmetric = Logical True

   !Linear System Solver = "Iterative"
   Linear System Solver = "Direct"

   Linear System Preconditioning = None
   Linear System Convergence Tolerance = 1e-8
   Linear System Residual Output = 100
   Linear System Max Iterations = 5000
   Linear System Iterative Method = CG
   Steady State Convergence Tolerance = 1e-8

   Use Tree Gauge = Logical True

   Discontinuous Bodies = True

End

Solver 2
   Equation = "MGDynamicsCalc"
   Procedure = "MagnetoDynamics" "MagnetoDynamicsCalcFields"
   Linear System Symmetric = True
   Potential Variable = String "A"

   Calculate Magnetic Field Strength = Logical True
   Calculate Magnetic Vector Potential = Logical True
   Steady State Convergence Tolerance = 0

   !Linear System Solver = "Iterative"
   Linear System Solver = "Direct"

   Linear System Preconditioning = None
   Linear System Residual Output = 0
   Linear System Max Iterations = 5000
   Linear System Iterative Method = CG
   Steady State Convergence Tolerance = 1e-8
   Linear System Convergence Tolerance = 1.0e-8

   Use Tree Gauge = Logical True

   Discontinuous Bodies = True

End

Solver 3
  Exec Solver = after all
  Equation = "ResultOutput"
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
  Output File Name = "/home/rcrozier/build/fea_temp_files/elmer_vs_femm/"$filename
  Save Geometry Ids = Logical True
  Vector Field 1 = String Magnetic Field Strength
  Vector Field 2 = String Magnetic Flux Density
  Vector Field 3 = String Magnetic Vector Potential
  Potential Variable = String av
  Show Variables = Logical True
  Vtu format = Logical True

  Discontinuous Bodies = True

  Use Tree Gauge = Logical True

End


Equation 1
  Name = "Coupled Equations"
  Active Solvers(2) = 1 2
End


! ======================================================================!
!		Boundary Condition Section				!
! ======================================================================!

! ----- names for boundaries -----
!$ outer_bound = 1

Boundary Condition 1
  Name = "outer_boundary"
  A = Real 0.0
  A {e} = Real 0.0
End
and the solver output:

Code: Select all

ELMER SOLVER (v 8.2) STARTED AT: 2016/08/11 17:12:31
ParCommInit:  Initialize #PEs:            1
MAIN: 
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.
MAIN: Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi
MAIN: Version: 8.2, Compiled: 2016-08-11)
MAIN: =============================================================
MAIN: 
MAIN: 
MAIN: -------------------------------------
MAIN: Reading Model: case_Discontinuous Bodies_True.sif
Model Input:  Unlisted keyword: [use tree gauge] in section: [solver 1]
Model Input:  Unlisted keyword: [use tree gauge] in section: [solver 2]
Model Input:  Unlisted keyword: [use tree gauge] in section: [solver 3]
Model Input:  Unlisted keyword: [a] in section: [boundary condition 1]
Model Input:  Unlisted keyword: [a {e}] in section: [boundary condition 1]
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver_Init0]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_Init0]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_Init0]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamics_Dummy_Init0]
LoadMesh: Base mesh name: /home/rcrozier/build/fea_temp_files/elmer_vs_femm/elmer_vs_femm
LoadMesh: Performing node mapping
ReadTargetNames: Reading names info from file: /home/rcrozier/build/fea_temp_files/elmer_vs_femm/elmer_vs_femm/mesh.names
WARNING:: ReadTargetNames: Could not map name to Body nor BC: bnry7
LoadMesh: Minimum initial body index: 2
LoadMesh: Maximum initial body index: 6
LoadMesh: Minimum initial boundary index: 1
LoadMesh: Maximum initial boundary index: 7
LoadMesh: Elapsed time (CPU,REAL):    14.8800   15.9293 (s)
MeshStabParams: Computing stabilization parameters
MeshStabParams: Elapsed time (CPU,REAL):     0.6280    0.6291 (s)
MAIN: -------------------------------------
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver_Init]
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver_bulk]
Loading user function library: [MagnetoDynamics]...[WhitneyAVSolver]
CheckLinearSolverOptions: Setting > Linear System Direct Method < to:umfpack
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: mgdynamics...done.
OptimizeBandwidth: Half bandwidth without optimization: 2435850
OptimizeBandwidth: 
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 144668
OptimizeBandwidth: ---------------------------------------------------------
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_Init]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_bulk]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields]
CheckLinearSolverOptions: Setting > Linear System Direct Method < to:umfpack
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: mgdynamicscalc...done.
OptimizeBandwidth: Half bandwidth without optimization: 358649
OptimizeBandwidth: 
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 32118
OptimizeBandwidth: ---------------------------------------------------------
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_Init]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver_bulk]
Loading user function library: [ResultOutputSolve]...[ResultOutputSolver]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamics_Dummy_Init]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamics_Dummy_bulk]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamics_Dummy]
MAIN: 
MAIN: -------------------------------------
MAIN:  Steady state iteration:            1
MAIN: -------------------------------------
MAIN: 
SingleSolver: Attempting to call solver
SingleSolver: Solver Equation string is: mgdynamics
WhitneyAVSolver: Solving the AV equations with edge elements
OptimizeBandwidth: ---------------------------------------------------------
OptimizeBandwidth: Computing matrix structure for: mgdynamics...done.
OptimizeBandwidth: Half bandwidth without optimization: 358649
OptimizeBandwidth: 
OptimizeBandwidth: Bandwidth Optimization ...done.
OptimizeBandwidth: Half bandwidth after optimization: 32118
OptimizeBandwidth: ---------------------------------------------------------
DefUtils::DefaultDirichletBCs: Setting Dirichlet boundary conditions
SetDirichletBoundaries: Number of dofs set: 0
DefUtils::DefaultDirichletBCs: Dirichlet boundary conditions set
SolveSystem: Solution trivially zero!
DefUtils::DefaultDirichletBCs: Setting Dirichlet boundary conditions
SetDirichletBoundaries: Number of dofs set: 0
DefUtils::DefaultDirichletBCs: Dirichlet boundary conditions set
Segmentation fault
I have also now taken samples at more positions. Basically taking samples at the same radial distance on the positive and negative x and y axes. You can see the x and y directed fields are quite smooth and symmetric, but the z directed field is very spiky and not consistent. I also believe that the magnitude of the z directed field varies with the mesh density, but I need to do more tests to confirm this.
kataja
Posts: 74
Joined: 09 May 2014, 16:06
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by kataja »

Hi!

I don't think its fruitful to compare the vector potential because its not unique even though its integrals over surface edges are.

For the "discontinuous bodies" keyword to take effect, you should investigate the variable "Magnetic Flux Density e" instead of "magnetic flux density" (in solver 3).

Nice work by the way!

Cheers,
Juhani
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

kataja wrote:Hi!

I don't think its fruitful to compare the vector potential because its not unique even though its integrals over surface edges are.

For the "discontinuous bodies" keyword to take effect, you should investigate the variable "Magnetic Flux Density e" instead of "magnetic flux density" (in solver 3).

Nice work by the way!

Cheers,
Juhani
Thanks but I'm already comparing flux density (last plot was only flux density in fact). But also as I pointed out with my link to my other post vector potential is important to find flux linkage in a coil. Much easier to integrate vector potential around loop than flux through surface. ( sorry for brevity, this is from my phone)
crobar
Posts: 49
Joined: 30 Mar 2014, 14:50
Antispam: Yes

Re: Elmer Magnetics 3D comparison with 2D Axisymmetric Lumpy

Post by crobar »

Actually I reread your post, will try other key word, thanks, but still interested in vector pot
Post Reply