Magnetic field

General discussion about Elmer
Post Reply
JBERT
Posts: 6
Joined: 23 May 2022, 11:10
Antispam: Yes

Magnetic field

Post by JBERT »

Hello,

I'm discovering elmer and I'm trying to start a simulation to see magnetic field generated in a metallic case by a lightning in a lightning conductor.

I have built Elmer, ElmerGUI and ElmerPost on my Linux Devuan (testing) workstation and I have read a lot of documentation and I'm not sure I understand how Elmer runs.

In a first time, I have exported my case into a STL file from my CAO software (FreeCAD). In a second time, I have given this STL file to gmsh to obtain a new mesh file I can open with ElmerGUI
elmer.jpg
(200 KiB) Not downloaded yet
In a first time, I consider my case is in pure copper.

Now, I want to add a stimulus (lightning conductor with a 8/20µs wave) and I want to configure Elmer to run a simulation. I don't understand how to add lightning conductor. Should I add conductor in the mesh file (with my case) ? And if I have to add this conductor in mesh file, I have a dielectric support between conductor and case. I have tried to configure three bodies (case in pure copper, support in polyacrylic and conductor in steel) without success.

Help will be welcome.

Best regards,

JB
kevinarden
Posts: 2317
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Magnetic field

Post by kevinarden »

Doing magnetic field generally involves modeling the medium around the object (i.e. air) there are several mag cases located here
https://github.com/ElmerCSC/elmer-elmag

In addition to the tutorials on magnetic fields
https://www.nic.funet.fi/pub/sci/physic ... orials.pdf
JBERT
Posts: 6
Joined: 23 May 2022, 11:10
Antispam: Yes

Re: Magnetic field

Post by JBERT »

Thanks for this documentation. I have read this documentation before posting here.

With FreeCAD, I have exported all bodies (case itself, conductor and support):

Code: Select all

barreau.brep  fermeture_boitier.brep      support_cote_mur.brep
boitier.brep  joint_principal.brep        support_ecran.brep
capot.brep    support_cote_compteur.brep
I don't know Python, but I have modified an exemple I have found in elmer-elmag:

Code: Select all

#!/usr/bin/python3

import gmsh

mm = 1/1000 # FreeCAD (and ourselves) use mm, Elmer wants SI units (i.e. meters)

gmsh.initialize()
gmsh.model.add("Foudre")

gmsh.option.setNumber("Geometry.OCCScaling", mm)

(_, barreau) = gmsh.model.occ.importShapes("barreau.brep", highestDimOnly=True)[-1]
(_, capot) = gmsh.model.occ.importShapes("capot.brep", highestDimOnly=True)[-1]

# Air/Infinity
sphere = gmsh.model.occ.addSphere(0, 0, 0, 1000*mm)
[(_, air)], _ = gmsh.model.occ.cut([(3, sphere)], [(3, barreau), (3, capot)], removeObject=False, removeTool=False)

gmsh.model.occ.synchronize()

# Add named physical volumes and surfaces as
# GMSH "physical groups" for better readability.
# This allows ElmerGrid to know which parts of the
# model are actually required in the simulation
# plus these names can be referenced in your SIF
# file directly without having to deal with numbers.
gmsh.model.addPhysicalGroup(3, [air], 1)
gmsh.model.addPhysicalGroup(3, [capot], 2)
gmsh.model.addPhysicalGroup(3, [barreau], 3)

infinity = [ entity for [_, entity] in gmsh.model.getBoundary([(3, sphere)], oriented=False)]
gmsh.model.addPhysicalGroup(2, infinity, 4)
gmsh.model.removeEntities([(3, sphere)])

# GMSH uses the concept of "fields" to control
# mesh refinement. We create a denser mesh near
# the coil. Further away from the coil the mesh
# becomes gradually coarser.
#gmsh.model.mesh.field.add("Box", 1)
#gmsh.model.mesh.field.setNumber(1, "Thickness", 10*mm)
#gmsh.model.mesh.field.setNumber(1, "XMin", -20*mm)
#gmsh.model.mesh.field.setNumber(1, "XMax", 20*mm)
#gmsh.model.mesh.field.setNumber(1, "YMin", -25*mm)
#gmsh.model.mesh.field.setNumber(1, "YMax", 25*mm)
#gmsh.model.mesh.field.setNumber(1, "ZMin", -40*mm)
#gmsh.model.mesh.field.setNumber(1, "ZMax", 40*mm)
#gmsh.model.mesh.field.setNumber(1, "VIn", 3*mm)
#gmsh.model.mesh.field.setNumber(1, "VOut", 8*mm)
#gmsh.model.mesh.field.setAsBackgroundMesh(1)

# Disable default mesh refinement rules as we
# specified our own.
gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 0)
gmsh.option.setNumber("Mesh.MeshSizeFromPoints", 0)
gmsh.option.setNumber("Mesh.MeshSizeFromCurvature", 0)
gmsh.option.setNumber("Mesh.AngleToleranceFacetOverlap", 1e-8)

# Mesh Algorithm: Delaunay
gmsh.option.setNumber("Mesh.Algorithm", 5)
gmsh.model.mesh.generate(3)

# Export the Mesh
gmsh.write("sim.msh")
gmsh.finalize()
If I understand, I have to add all brep files. I only test with two shapes. In a first time, script aborted with an overlap error I have fixed with gmsh.option.setNumber("Mesh.AngleToleranceFacetOverlap", 1e-8). Now,I obtain another error:

Code: Select all

...
Info    : Done meshing 2D (Wall 1.31203s, CPU 1.304s)
Info    : Meshing 3D...
Info    : 3D Meshing 3 volumes with 1 connected component
Info    : Tetrahedrizing 2139 nodes...
Info    : Done tetrahedrizing 2147 nodes (Wall 0.0198999s, CPU 0.0199s)
Info    : Reconstructing mesh...
Info    :  - Creating surface mesh
Info    :  - Identifying boundary edges
Info    :  - Recovering boundary
Error   : Could not recover boundary mesh: error 2
Traceback (most recent call last):
  File "...././generate-mesh.py", line 60, in <module> gmsh.model.mesh.generate(3)
  File "/usr/lib/python3/dist-packages/gmsh.py", line 1523, in generate
    raise Exception(logger.getLastError())
Exception: Could not recover boundary mesh: error 2
I'm unable to fix.

I can upload on a server these files.

Best regards,

JB
kevinarden
Posts: 2317
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Magnetic field

Post by kevinarden »

You have modeling and meshing issue, not an Elmer issue. Have you looked at the modeling hints in
https://www.nic.funet.fi/pub/sci/physic ... dElmer.pdf

Not many use FreeCad with Elmer, but some do.

If you can put the FreeCad and brep files on a server I can take a look.
JBERT
Posts: 6
Joined: 23 May 2022, 11:10
Antispam: Yes

Re: Magnetic field

Post by JBERT »

Hello,
Modeling was done a long time ago.

Files are downloadable at https://www.systella.fr/elmer/

Best regards,

JB
kevinarden
Posts: 2317
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Magnetic field

Post by kevinarden »

The part is too complex for FEM meshing. Generally, in FEM detailed features are suppressed or removed, that do not impact the desired analysis. Things such as bolts, bolt holes, the threads, in the bolt holes. Too much detail for the mesher and won't impact the analysis. Recommend simplifying the geometry as much as possible.
part.PNG
(51.02 KiB) Not downloaded yet
Post Reply