Skip to main content
1-Visitor
March 1, 2014
Solved

Mathcad to calculate magnetization

  • March 1, 2014
  • 27 replies
  • 15655 views

Hi, everyone!

I am new here and I hope I've found the right place to ask my question.

I've been trying to simulate the magnetization process of a ferrimagnet using Mathcad. The theory behind this is quite simple - one writes down an energy expansion, there're three terms that signify how two magnetic moments interact with each and with magnetic field. Mathematically, one needs to minimize this energy with respect to the angles the magnetic moments make with the field and some symmetry direction of the crystal lattice. The minimization should be done for each magnetic field value, e.g., B = 0,1,2,...,20 T. Then, the total magnetization, Mtotal, can be calculated using the obtaines values of the angles.

I've prepared a Mathcad document for the simulation (see attachment). The program works but gives me an incorrect unphysical result. Could you take a look and possibly exlpain to me what I've done wrong?

Thank you in advance.

Regards,

Den

Best answer by AlanStevens

Is the attached any help? I'm not sure I've interpreted what you want correctly, but if I have, you need to note that the results are somewhat sensitive to the initial guesses.

Alan

27 replies

Werner_E
25-Diamond I
March 1, 2014

I don't see any result at all in the sheet you have posted and also I don't see any attempt to minize a function. You have defined some range variables which are not used at all (resp. have no efffect) and I guess the function dE() you defined isn't working as you expected. It will only return the derivation of E after Phi for B=60 in every case - the range has no effect. What should dE() return in your opinion?

And which expression is it you want to minimize?

1-Visitor
March 1, 2014

Yep, I didn't include any result because it takes too long for the program to arrive at it. Now I've included the plot I'm after - Mtotal(B). As you can see, it makes no sense.

In my opinion, dE() should return the energy minimized with respect to alpha and phi. I want to minimize the initial expression, that is, E(B,alpha,phi). I thought I minimized the E function by taking its derivatives and then finding their roots to be used for Mtotal... Should I have assumed a different approach? And how should I get the B range to have the desired effect?

Thank you.

Result.jpg

Werner_E
25-Diamond I
March 2, 2014

Denis Gorbunov wrote:

Yep, I didn't include any result because it takes too long for the program to arrive at it. Now I've included the plot I'm after - Mtotal(B). As you can see, it makes no sense.

Thats no surprise given the way the functions are defined.

In my opinion, dE() should return the energy minimized with respect to alpha and phi.

In what form? a vector? a 61x2 matrix ? What did you had in mind?

I want to minimize the initial expression, that is, E(B,alpha,phi).

Its a function in 3 variables, so you would need the derivatives wrt all 3. Also, how yould you cope with multiple (local) minima? And if you want the calculation being done for a constant B, I guess both partial derivates should be zero at the same time. I would suggest using either a solve block with Find() (using the two partial derivative) or one with Minimize().

I also don't understand why your function Mtotal should still be dependent on alpha and Phi and why you had setup ranges for those angles. f() and g() should already return the "optimal" values for those angles, as I think. Also f() and g() would not be dependent on alpha and Phi.

Werner_E
25-Diamond I
March 2, 2014

I had another look at my file and I noticed that Alan was right in that the parameter B, which is not optimized by minimize(), should be the last of the three, not the first.

I also added I third way to determine the minimum of E() (you already know that you can forget about the first one with the derivatives). Its a simple brute force algo which looks at each value in a grid of custom size and returns the angles which gives the minimum E-value. The results are (refrained from the first few values of B) pretty much the same as in Alan's sheet or with the second method in my sheet. We need a rather fine gridsize (grid>100) to avoid steps in the graph of Mtotal for higher B-values.

Anothe thing to mention: If we use minimize() we have to be very careful with constrains as those will give us wrong results with bad guess values.

I tend to call it a limitation of the numeric algoriothm rather than a bug.

MinimizeProblem.png

1-Visitor
March 2, 2014

Dear Werner,

Thank you for your Mathcad and .pdf files. I've made sure that using partial derivatives is not appropriate to my problem. The proof is that at some field values the magnetization decreases, whereas it should either increase or stay constant. However, when you used new guess values, the result you showed in the penultimate graph of Magnetization2_Werner file is definitely interesting. This is not what I expected but it is possible from the physics point of view. As I referred to Alan's example in the previous post, from this graph you get the parallel orientation of the magnetic moments in the lowest applied field.

In your example (magnetization3) where you use the same guess values for alpha and phi as Alan, you get the same expected result. Your third example where you use a grid algorithm yields the same result but seems less clear to me as I don't know how it works. But I am going to look into it.

Thank you for your help!

Regards,

Den

Werner_E
25-Diamond I
March 2, 2014

Your third example where you use a grid algorithm yields the same result but seems less clear to me as I don't know how it works. But I am going to look into it.

As its bruteforce its nothing special or complicated. E() is evaluated for a constant B (the argument of the function) for "all" values of alpha and Phi in the specified range (0..pi, -pi/2 .. pi/2) and the pair which yields the smallest E-value wins. This is done by two nested for-loops, but of course we cannot try ALL values so a grid of angle values is laid out, the denseness of that grid is controlled by the worksheet variable grid. If the grid is too coarse we may miss the real minimum and this seems to happen very easily for the higher values of B.

Find attached just for fun an animation showing the surface showing E depending on alpha and Phi as well as the minimum.