3D Magnetic Vector Potential Lagrange Gauge Penalization

Numerical methods and mathematical models of Elmer
Post Reply
lsouza
Posts: 4
Joined: 02 Jun 2020, 01:48
Antispam: Yes

3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by lsouza »

I am learning to use Elmer for magnetostatics in 3D. As an exercise, I setup a simple axisymmetric problem: a cylindrical magnet centered at the origin, which I can compare to FEMM.

One of my goals is to obtain a divergence-free potential. I am using the WhitneyAVSolver with Lagrange gauge. I have set the Lagrange gauge penalization coefficient [variable k in eq. (17.54) of the Elmer Models Manual] to different values, and expected the vector potential to change. I tried k = 1, 2, 10 and, finally 1e8. No change (except for small numerical perturbations) is observed. I have attached a figure comparing values of the z-component of the potential (on a grid in the x = 0 plane). The different lines correspond to different y coordinates. Notice that the change in Az from k = 1 to k=1e8 is nearly none (Az is between 1e-5 and 1, the difference is concentrated around 1e-9).

There are two other related issues. The Az in the plot changes with the coordinate z, an indication that the divergence is not zero. In addition, Az should be zero on this plane (horizontal and vertical components of the vector should be zero at any plane containing the symmetry axis z).

In summary: changing the Lagrange gauge penalization coefficient of the WhitneyAVSolver does not seem to have any meaningful effect on the vector potential.

I have attached a zip file with the sif file and the geometry. What am I doing wrong?

Thanks in advance.
Azchangek_eq_1_to_k_eq_1e8.jpg
Azchangek_eq_1_to_k_eq_1e8.jpg (48.28 KiB) Viewed 3505 times
Attachments
singlemag_air_sphere.zip
(4.63 KiB) Downloaded 235 times
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: 3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by raback »

Hi

Haven't used it much myself. Does it affects the results if you turn off the Piola transform?

Is there a special reason that you want to gauge your vector potential?

-Peter
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: 3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by kevinarden »

According to your geo file the model is built in mm, in the solver the units should be meters. Have you tried
Coordinate Scaling = 0.001

I think this geo file produces the same geometry
Attachments
mygeo.geo
(374 Bytes) Downloaded 237 times
mika
Posts: 230
Joined: 15 Sep 2009, 07:44

Re: 3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by mika »

Hi,

In the first place I would compare solutions obtained without a gauge condition (Use Lagrange Gauge = False) and with the parameter value k = 1 to see how the Lagrange multiplier formulation affects the vector potential. In exact arithmetic I would expect that the vector potential solution is the same for all positive constants k, while the scalar variable solution depends on k (if k differs from 1, consider what follows from the change of scalar variable V as V' = k V; the effect seems to be that the penalization term in the equation for the vector potential is just scaled by a factor 1/k in comparison with solving the problem with k = 1). An extreme value of k might cause perturbations due to ill-conditioning, but I think seeing no changes in the vector potential solution is indeed expected.

-- Mika
lsouza
Posts: 4
Joined: 02 Jun 2020, 01:48
Antispam: Yes

Re: 3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by lsouza »

First of all, thank you for the observations and questions.
(1) Peter,
(a) I have run cases without Piola transformation and have not seen any change.
(b) I used the gauge because of the information in the models manual: "possibility to seek a unique vector potential solution to the magnetostatics equations is included here as a special case via using the scalar variable to impose the divergence-free constraint on A"

(2) Kevinarden, my geo file is in millimeters and I change the node coordinates in mesh.nodes to meters ( I did it in Emacs). Your geo file produces the same geometry, but I have not used it. I like its simplicity (compare to the one I generated from a brep cad file)

(3) Mika, I have run cases (Piola transformation off) for k from 0.1 to 1e8. Following your suggestion, I also run one case without the Lagrange gauge.
I am posting one plot comparing results with Lagrange gauge penalty coefficient k=1 to the no Lagrange gauge case.
There is a slight increase in the difference (compared to k=1, k=1e8 posted before), but they are not numerically meaningful.

I have used the divergence solver to compute the divergence of the vector potential (divA), which is the quantity that should be reduceded by the Lagrange gauge. I am using, as measure, the square root of the sum of the squares of divA at all points in the rectangular region on the YZ plane indicated in the plot (a kind of total energy of divA). As the divergence decreases, I would expect this measure to decrease.
However, as you can see in the plot, there is no change in the total "energy" of divA. The red dot is for the case with no Lagrange gauge. Notice the small range of the vertical axis on this plot.

The analysis suggests that, at least for this particular problem, Lagrange gauge has no effect on the solution: no change in the vector potential and no reduction in its divergence.
case.sif
(5.91 KiB) Downloaded 234 times
Azchange_with_k=1_and_no_Lagf_gauge_no Piola.jpg
Azchange_with_k=1_and_no_Lagf_gauge_no Piola.jpg (46.93 KiB) Viewed 3476 times
rmsdivAchange.jpg
rmsdivAchange.jpg (25.14 KiB) Viewed 3476 times
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: 3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by raback »

Hi

The fact that no gauging can work uses the properties of the Krylov subspace of the iterative solvers, see
https://en.wikipedia.org/wiki/Krylov_subspace
Upon successful completion of the iterative solution for the particular Krylov method is therefore well defined. However, you cannot use direct solvers without an explicit gauge.

This feature could be useful for example when a) source is not divergence free and the augmented lagrangian relaxes the this condition or b) there are nonlinear iterations that may eventually pollute the vector potential making the null-space solution grow or c) you really-really want to compare the vector potential between some reference solution with the same gauging. These are deeply rooted issues and I'm not a mathematician myself....

-Peter
mika
Posts: 230
Joined: 15 Sep 2009, 07:44

Re: 3D Magnetic Vector Potential Lagrange Gauge Penalization

Post by mika »

lsouza wrote: 28 Jun 2020, 19:22 The analysis suggests that, at least for this particular problem, Lagrange gauge has no effect on the solution:
I would interpret this that by chance the standard solution doesn't have a significant component which could be represented in terms of a gradient field.

On the other hand, how do you compute div A? As A is approximated in terms of curl-conforming basis functions, I think div cannot be applied directly to A, so div A must be considered in weak sense. Might it be easiest to think that the approximation of the Laplacian of the scalar variable gives an indication of the size of div A, cf. the equation div A - k div grad V = 0? Postprocessing A to create a nodal approximation of A and then generating an approximation of div A might not be an ideal way. It seems that the standard divergence solver (DivergenceSolver) of Elmer cannot operate directly on a field approximated in terms of curl-conforming basis functions.

-- Mika
Post Reply