Creating a boundary condition within an object, i.e. to measure flux

Mesh generators, CAD programs, and other tools
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi Rich,

based on your example, changed some naming to fit my .sif, did some flux measurement tests. Complete project is attached below, with 'make' (defaults to 16 CORES for fine mesh). Thing to explore is which per-conditioners would in this case improve the convergence speed. With BiCGStabL polynomial degrees higher than 5 internal error arises. But this is not the major issue now.

The two flux measurement areas of the Torus appear to be symmetrical (also reported by Elmer and is ofc slightly mesh dependent), however calculating the average should, according to the orientation (also a good question how to define orientation of a surface), provide either double value so around 0.07 T or ->0 T, but it's just something.

It is also unclear to me how to report average flux for each boundary separately; now I've done more runs to enable one, or the other, or both, and the last I've changed mesh grid to finest (12 from curvatures, in .geo.opt currently in the zip project).

Expected flux density in this core with u_r = 3000 and wire current of 1.256 A should be ~0.037 T

Code: Select all

Variables in columns of matrix: results/coreWire.dat
   1: simulation: cpu time (s)
   2: simulation: real time (s)
   3: res: eddy current power
   4: res: electromagnetic field energy
   5: res: magnetic flux average
   6: res: magnetic flux density average
   7: res: magnetic flux area

   2.052951300000E+001   1.744762611389E+001   5.964347131448E-004   7.683346874482E-007  -1.574121712043E-007  -2.915040207464E-003   5.400000000045E-005
   2.155061100000E+001   1.811320304871E+001   5.964347146686E-004   7.692430960868E-007   5.177143995973E-007   1.917460739233E-002   2.700000000023E-005
   2.167175200000E+001   1.824741506577E+001   5.964347146686E-004   7.692430960868E-007   5.177143995973E-007   1.917460739233E-002   2.700000000023E-005
   2.172054300000E+001   1.825896120071E+001   5.964347146686E-004   7.692430960868E-007  -1.575314886442E-007  -2.917249789682E-003   5.400000000045E-005
   2.181652600000E+001   1.827390098572E+001   5.964347146686E-004   7.692430960868E-007  -6.752458882415E-007  -2.500910697170E-002   2.700000000023E-005
   2.193741600000E+001   1.868077683449E+001   5.964347146686E-004   7.692430960868E-007  -1.575314886442E-007  -2.917249789682E-003   5.400000000045E-005
   5.879800900000E+001   4.814381885529E+001   5.964347154959E-004   7.697399605983E-007  -1.575966774580E-007  -2.918456989939E-003   5.400000000045E-005
   1.719310000000E+001   1.474894309044E+001   5.964347148393E-004   7.693471671225E-007  -1.575451448709E-007  -2.917502682770E-003   5.400000000045E-005
   1.730557200000E+001   1.490097379684E+001   5.964347148393E-004   7.693471671225E-007  -1.575451448709E-007  -2.917502682770E-003   5.400000000045E-005
   8.483373020000E+002   7.520740270615E+002   6.236439989278E-004   8.431919786786E-007  -2.571142490298E-007  -4.599135063742E-003   5.590491374276E-005

Any suggestion?

Uros
Attachments
coreWire.zip
(8.51 KiB) Downloaded 67 times
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello Uros,

Wow, your work looks great. I don't think I can help much more.

On the other hand, maybe take a look at this case?

https://github.com/ElmerCSC/elmer-elmag ... ndWindings
which contains this:
Solver 5
! Exec Solver = Never
Equation = "SaveScalars"
Procedure = "SaveData" "SaveScalars"
Filename = coupled.dat

Variable 1 = Magnetic Flux Density 1
Operator 1 = int mean
Variable 2 = Magnetic Flux Density 2
Operator 2 = int mean
Variable 3 = Magnetic Flux Density 3
Operator 3 = int mean

Variable 4 = Magnetic Field Strength 1
Operator 4 = int mean
Variable 5 = Magnetic Field Strength 2
Operator 5 = int mean
Variable 6 = Magnetic Field Strength 3
Operator 6 = int mean
End
and this:
Boundary Condition 4
Name = "Aplus"
Electric Current Density = 50700.0
AV {e} = real 0
Save Scalars = Logical True
End
Rich.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Well, that suggestion didn't seem to be helpful:
SaveScalars: Saving scalar values of various kinds
WARNING:: SaveScalars: Requested variable does not exist: magnetic flux density 1
WARNING:: SaveScalars: Requested variable does not exist: magnetic flux density 2
WARNING:: SaveScalars: Requested variable does not exist: magnetic flux density 3
WARNING:: SaveScalars: Requested variable does not exist: magnetic field strength 1
WARNING:: SaveScalars: Requested variable does not exist: magnetic field strength 2
WARNING:: SaveScalars: Requested variable does not exist: magnetic field strength 3
Changing to 'magnetic flux density e' and 'magnetic field strength e' produces output.

Rich.
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi,

It seems like the Flux Average does not work or needs additional treatment, but changing it to your example it works, so adding the Save Scalars:

Code: Select all

Boundary Condition 4
  Name = "Core Flux 1"
  !Magnetic Flux Average = Logical True
  Save Scalars = Logical True
End

Boundary Condition 5
  Name = "Core Flux 2"
  !Magnetic Flux Average = Logical True
  Save Scalars = Logical True
End
and then modified the Save Scalars Solver:

Code: Select all

Solver 3
  Exec Solver = After Timestep
  Equation = MGSaveCalc
  Procedure = "SaveData" "SaveScalars"
  Filename = "coreWire.dat"
  File Append = Logical True
  !Parallel Reduce = True

  Variable 1 = Magnetic Flux Density 1
  Operator 1 = boundary int mean
  Variable 2 = Magnetic Flux Density 2
  Operator 2 = boundary int mean
  Variable 3 = Magnetic Flux Density 3
  Operator 3 = boundary int mean
End
Then I've reduced the mesh significantly to run a single instance for a test, as parallel int mean isn't supported:

Code: Select all

Variables in columns of matrix: results/coreWire.dat
   1: boundary int mean: magnetic flux density 1 over bc 4
   2: boundary int mean:  over bc 5
   3: boundary int mean: magnetic flux density 2 over bc 4
   4: boundary int mean:  over bc 5
   5: boundary int mean: magnetic flux density 3 over bc 4
   6: boundary int mean:  over bc 5
   7: simulation: cpu time (s)
   8: simulation: real time (s)
   9: res: eddy current power
  10: res: electromagnetic field energy

3.175592815362E-005  -2.410997224010E-005  -3.150545260326E-002   3.122361567745E-002  -2.370580903005E-005   4.799689332867E-005   4.760921600000E+001   3.958831095695E+001   5.964346891393E-004   7.688895868302E-007
The majority of the field is on Y axis and the signs are correct (BC 4 is on the right and BC 5 on the left --- BCs are not really "seen" from paraview screen shot). Parallel run comes to the same numbers just split across files.
field.png
(719.26 KiB) Not downloaded yet
Thank you for help. It's getting better and better.

Sometimes it is hard to "know" which variables are available, and at least I didn't notice any "variable list dumper" and their meanings, despite those dumped into the vtu file.

Uros.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Attached is an archive with a simplified model of the core over wire model.

The simpler elmergrid model is designed to be used in a consistency test, to test the PlatiseFerroModel.F90 function. If needed, the function can be compiled into an so/dll using elmerf90.

The mesh is generated by Elmergrid with the command 'Elmergrid 1 2 coreWire4 -autoclean'. The included coreWire4.sif can be run with the command 'Elmersolver coreWire4.sif'.

Here is a screenshot from ElmerVTK showing the 'Magnetic Flux Density Abs':
flux-density.png
flux-density.png (165.59 KiB) Viewed 1092 times
This is a coarse mesh model, which is useful as a consistency test. This model runs in about 40 seconds on my laptop.

Rich.
Attachments
consistency-test.zip
(68.7 KiB) Downloaded 59 times
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi,

Super.

I am trying to get a better internal homogeneity in order to obtain better average calc of the core flux; so have added a "skin" layer to your original .geo. The result in paraview is good, but have problems with the SaveData; results are all zero, even though boundary conditions are there, all valid.
SetFactory("OpenCASCADE");

Cylinder(1) = {0, 0, -0.15, 0, 0, 0.3, 0.100, 2*Pi};
Cylinder(2) = {0, 0, -0.15, 0, 0, 0.3, 0.002, 2*Pi};
Torus(3) = {0, 0, 0, 0.02, 0.003, Pi};

Rotate {{0, 0, 1}, {0, 0, 0}, Pi} {
Duplicata { Volume{3}; }
}

BooleanFragments{ Volume{1}; Delete; }{ Volume{2,3,4}; Delete; }

// Add skin to the core
Torus(6) = {0, 0, 0, 0.02, 0.0035, 2*Pi};

Coherence;

Physical Surface("Sky", 16) = {14, 15, 16};
Physical Surface("Wire End 1", 17) = {5};
Physical Surface("Wire End 2", 18) = {6};
Physical Surface("Wire Surface", 19) = {4};
Physical Surface("Core Surface", 20) = {11, 10};
Physical Surface("Core Skin Surface", 21) = {17};
Physical Surface("Core Flux 1", 22) = {12};
Physical Surface("Core Flux 2", 23) = {13};

Physical Volume("Air", 23) = {5};
Physical Volume("Wire", 24) = {2};
Physical Volume("Core", 25) = {3, 4};
Physical Volume("CoreSkin", 26) = {6};
and in .sif add the body with the same material as of the core, it will act as transition layer between the air and the core. Also simulation speeds up significantly.

Code: Select all

Body 4
  Name = "CoreSkin"
  Equation = 1
  Material = 3
End
Any idea why calcs are all zero?

With the PlatiseFerroModel the 10: res: electromagnetic field energy is Infinity which has some valid power (value) with Cubic interpolation.

Uros.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello,

Looking at the geo, I don't see any additional Boolean operations. Just adding another torus on top of the other 3d objects without some kind of cutting operation shouldn't work.

Here is the torus and wire using the existing geo file, notice that it doesn't look very smooth or uniform. Just visually, it looks like it may have a hard time calculating a uniform magnetic flux.
torus-simple.png
torus-simple.png (187.76 KiB) Viewed 1079 times
To control the elements at the surface of the existing torus, I would add this statement to the bottom of the geo file:
Mesh.MeshSizeFromCurvature = 12;
This will tell the mesher to look at curved items, such as the wire and the torus, and to add 12 elements around the circumference of the item. Try different values, such as 12, 18, 24, or any other pleasing value. This will control the number of nodes and elements, mostly right at the wire and torus. If you notice, it will decrease the number of elements right at the torus cross section boundary and increase the number of elements around the torus.

Another suggestion, also add this statement near the above statement:
Mesh.OptimizeNetgen = 1;


Sometimes the extra optimization pass helps reduce illegal tets.

Here is the torus and wire with curvature set to 12:
torus-curve-12.png
torus-curve-12.png (290.22 KiB) Viewed 1079 times
Rich.
coreWire.geo
(784 Bytes) Downloaded 64 times
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Hi Rich,

For the grid density am using it in the .opt file, that is/was attached besides the coreWire example.

Going back to the "skin"; with the Coherence I get a nice "skin" looking at gmsh and loading back the msh file, also attached below, and also in the resulting paraview I can see a nice field within the skin, so I it does not look like we have a geo issue here.

Within the ElmerGUI I do not see an option to select a body volume only, and there is no clipping.

Image

Uros

PS: do not know how to add image from attachment
Attachments
field-with-skin.png
(367.91 KiB) Not downloaded yet
coreWire-with-skin.zip
(46 KiB) Downloaded 60 times
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by Rich_B »

Hello Uros,

I used the .opt file once, it changed all my settings for gmsh, very invasive. I had to find where gmsh stores all options and deleted the options file to reset. Just a suggestion, but putting all your meshing options directly in the geo file makes it portable. Good to hear that your settings make for a smooth looking mesh.

To place an image inline in the forum post, the image must be 640 pixels wide, or less, then click on the place inline button.

Rich.

Edit: I used the .opt file once, by opening it in the gmsh gui, which loaded all the settings and stored them as defaults. Running gmsh from the command line showed that gmsh opened the .opt file, then loaded the .geo file, without storing the .opt settings. The generated .msh file was about 9 MB, and the wire and core were smoothly meshed.
uplatise
Posts: 15
Joined: 11 Oct 2022, 00:10
Antispam: Yes
Contact:

Re: Creating a boundary condition within an object, i.e. to measure flux

Post by uplatise »

Thank you for tips. Let's try the last image, with added skin to the core:
field-with-skin.png
field-with-skin.png (165.57 KiB) Viewed 1061 times
So the main Q is still why SaveData is showing zeros ...
Post Reply