Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computing Hr and Hz from Magnetic potential

  1. Aug 13, 2009 #1
    Hello everybody,

    My question to you is how can I compute the values of Hr and Hz given the value of A - the magnetic vector potential.

    The reason I seek this: I'm using the FEMM software to obtain the H values at points around a solenoid. The .ans file that FEMM creates has a huge list of numbers which I found to be the magnetic potential. FEMM manages to retrieve the values of Hr and Hz from this list of Magnetic potential values.

    Here's a sample of the .ans file:

    1.2085532825853653 4.0843637420137959 -3.9469544215389256e-005
    1.1273460445780257 4.3874332801995255 -7.8792243048921603e-006
    1.3411542731880106 3.7999999999999998 -7.0806330952824349e-005
    1.4562831499937583 4.2684393799265425 -3.0708797381233563e-005
    1.1000000000000001 4.7000000000000002 2.6544667022034454e-005
    1.4823341543420145 4.5759703098370341 8.5327589548402048e-006
    1.52112000238584 3.5429823025642291 -9.6872108040739851e-005

    The first column is the r value, the second the z value and the third is our A.

    I need to compute Hr and Hz (or Hx and Hy in the planar case) so that I can use Matlab directly on the .ans file that FEMM creates.

    Seems simple enough, but how do I do this? Can somebody point me to the formula, OR if you know FEMM well, can you explain the .ans file for me?


  2. jcsd
  3. Aug 14, 2009 #2


    User Avatar
    Science Advisor
    Gold Member

    The B field is the curl of the vector potential. You cannot calculate this directly from just given vector potential values. You could estimate the derivatives using finite-difference, but you would need to know the location of each vector potential point. I do not understand your results, A is a vector. Do you know only the magnitude and location of A, or do you know the direction and magnitude of A but not the location?
  4. Aug 14, 2009 #3

    Thanks for that. I was aware of the equation you mentioned, which was why I was confused as to how FEMM managed to compute the values of H/B from A given the data I've posted.

    To answer your query, the first number 2941 is the number of nodes in the mesh. Then, the first column is the r, the second column is the z, (or x and y) of the respective node, and the third column is the nodal value of magnetic potential - A in the case of a planar type model, [tex]\Phi[/tex] = 2*[tex]\pi[/tex]*r*A in the case of an axisymmetric problem.

    But, as it turns out,

    "... I’d also written a verbal explanation a while ago at http://www.femm.info/list/msg00360.html that’s still pretty much accurate.

    However, the information in the .ans file is nodal values of vector potential. The post processor does some work to get values of B and H from the vector potential—these quantities are not stored in the file. ..."

    to quote FEMM author David Meeker, who responded to an email I'd sent. Matlab, only calls on FEMM to pass the values of Hr and Hz by pointing to the .ans postprocess file. FEMM's postprocessor still does the computation by itself, using the values of A directly from the .ans file.

    Finally, to quote the author again,

    If you’re interested in reverse-engineering the solution file format, the best thing to do is just look at the source code that reads in the .ans file. If you download the source, the routine that does it is OnOpenDocument in FemmviewDoc.cpp, which lives in the femm subdirectory of the source code.

    For future reference, I will look at the file and update this post on how the computation is done.

    But if somebody knows how that could possibly be done, you could still suggest ideas here while I update you guys.
  5. Aug 14, 2009 #4


    User Avatar
    Science Advisor
    Gold Member

    Ahh, it is an FEM code. That complicates things then. Because in FEM, you would have a vector basis function that interpolates the value of the vector potential over the patch. What you have solved for is the signed magnitude of the vector potential that is interpolated over the patch. If you knew the basis function of a patch, you could take the curl of the basis function and apply the solved A to find the magnetic field over the patch.

    For example, in a method of moments solver, we use the RWG basis function on triangular patches. We solve for a single value for the current, but the current is defined as:

    [tex]\mathbf{J}_n = J_n \frac{L_n}{2A_n^\pm}\boldsymbol{\rho}^\pm(\mathbf{r})[/tex]

    What all this means is immaterial. It is suffice for you to know that the vector \rho is a vector that points from the vertex of our mesh triangle into the interior of the patch. This vector is the local current vector, we have only solved for a weight on this vector. So if we wanted to know the actual current, we would have to do more math to find the vector currents at the desired points on each mesh element. If we want to find the charge density on the element, we take the divergence of the current which is

    [tex] \nabla\cdot\mathbf{J_n } = \mp \frac{L_n}{A_n^\pm} [/tex]

    In a similar way we would take the curl of your basis function to find the associated B field. So having solved for the weights for the basis functions you see that you need to go even further to actually get the real vector potential or magnetic field values.
  6. Aug 14, 2009 #5
    Ok... wow. That helps a lot. Thanks. This is precisely the reason I post queries here.

    At this stage, I'm attempting to simply retrieve values of Hr & Hz that FEMM's solver generates into a .mat/.csv file - thus bypassing the solver result .ans file completely - using a Lua script (which is compiled into FEMM and is then much faster) and thankfully, for the moment at least, I don't need to work at the level of detail you seem good at. Will be taking my FEM classes next semester - for now, I'm content at just manipulating things at a higher level.

    Thanks again. Will keep you guys posted.
    Last edited: Aug 14, 2009
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Computing Hr and Hz from Magnetic potential