cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Find the area of hysteresis loops

SOLVED
Highlighted
Amethyst

Find the area of hysteresis loops

Hi,

 

I want to find the accumulative sum of the hysteresis loops. I wonder how can I do that?

 

hyst.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Find the area of hysteresis loops

Here is the file attached.

Actually its just a modification from the one I posted earlier with the other definition of "loop".

According the animated GIF: Mathcad can make animations using a system variable FRAME. I just used that to show the 15 loops and their area. Mathcad saves the  animation in an avi container using a very old and inefficient codec (this forum won't accept those files). I converted the AVI into an animated GIF using one of the many online converters available (https://www.onlineconverter.com/avi-to-gif).

Werner_E_0-1603855190012.png

 

View solution in original post

16 REPLIES 16
Highlighted

Re: Find the area of hysteresis loops

Point, please, this area on the plot!

Highlighted

Re: Find the area of hysteresis loops

Maybe this one?

Werner_E_0-1603798712433.png

 

Highlighted

Re: Find the area of hysteresis loops

The graph has several loops. I want to find the accumulative area of all the loops (i.e. the area of the first loop plus the second loop plus the third one and so on).

Highlighted

Re: Find the area of hysteresis loops

Can you separate those "loops"?

I mean, can you divide the data into multiple (how many) parts to show each loop separately?

Can you assure, that all loops are really closed? At least the outer one seems not to be closed.

 

EDIT: As I expected - also the inner loop (a very narrw one) is not closed! And when I look at the plot, it does not seem to me that either loop is really closed!

The main question would be how exactly you define "loop"!

At least three possible ways come to my mind.

I separated the segments according to the sign changes and even if we assume closed loops, you will have to decide what you would like to call a loop. Look at the picture below - at least two possibilities to define a "loop". The difference is highlighted in yellow.

Werner_E_0-1603819529561.png

 

So thes are the first two of my three possible definitions of "loop".

The third one seems to make more sense, even though I wouldn't call it a "loop" but rather a "cycle", as the curve always is open at the upper end.

Actually each cycle started at (0/somewhere above 0), the goes to the right, turns and goes to the left below zero and then again turns, runs to the right and "stops" somewhere above its starting point.
The last of this kind of circle could be seen in he picture of my last post (the one I highlighted the area).

If you call this cycle a loop, there are exactly 15 perfect and complete "loops" in your data set and calculating the areas when we close the loop by connecting the starting and the end point shouldn't be that difficult. The start and end points of those loops should be easy to find as they all seem to be at x=0 and so each "loop" would consist of three different curves: from start to the right, then to the left end and at last back to the right to its endpoint at x=0.

A "loop" would then look something like this:

Werner_E_0-1603819162844.png

 

 

Highlighted

Re: Find the area of hysteresis loops

I think you could close the loops by looking at the end points rather than the middle.  If you find the points where the next "Y" value is less than the previous you have the end of the advancing curve.  (This is actually the start of the "next loop".)  Denote this as Xr.  If you continue to follow the data until the next reversal (Y greater than the previous Y) you have the left (lower) end (Xl).  You then have the ends bound, and integration between the lower curve and upper its the area of one loop.  You would lose the beginning of the first loop and the unfinished last loop.

 

The data file (*.prn) as I unzip it is corrupt; an attempt to demonstrate that is currently beyond me.

Highlighted

Re: Find the area of hysteresis loops


@Fred_Kohlhepp wrote:

I think you could close the loops by looking at the end points rather than the middle. 


I don't think thats it that easy because the arcs which join at the left are not the same which join at the right.  Its rather kind of a spiral. Thats what I was trying to show in the first picture of my second post. What you suggest corresponds to the right plot of that pic.

I found the ends by looking where the x-values change direction 😉

I think that my last interpretation makes most sense because its consistent and also because that way the data consist of a number (15) of complete "loops". Its seems natural for me, that the data starts with a new loop and ends with another rather than starting in midst of a loop and ending before the loop has finished. 

BTW, I had no problems unzipping the archive including the data file.

For whatever it may be worth I rezipped the data file alone and attach it here

Highlighted

Re: Find the area of hysteresis loops

Thank you @Werner_E @Fred_Kohlhepp @DJF @ValeryOchkov for your valuable comments. 

To make it more clear, I have attached a picture from a paper (pic1) which schematically shows what I am trying to do. I am trying to calculate D for which I need the area for each cycle. If we ignore the first half cycle, each loop starts from and ends at the top right corner. Then, the next loop starts from and ends at the next right corner (which has higher X and Y values). 

I extracted two loops (or cycles) from the data (pic 2). I have to calculate the area of each cycle separately (i.e. the first one (pic 3) and the second one (pic 4)) to be able to calculate WD that is shown in (pic1).

 

Highlighted

Re: Find the area of hysteresis loops

So the interpretation you have in mind is the one on the right of my first picture in my second post, correct?

Thats also what Fred suggested.

This would mean:

1) we ignore some data at the end of each loop (corresponding to the green circle in the picture below)

2) we ignore the last quarter (not half) first loop (which is VERY tiny and small)

3) we ignore three quarters of the last, outer loop (shown in green in the following picture)

Or shall we "close" the outer loop by connecting the endpoint with the point at the upper right by a straight line?

Werner_E_0-1603831980419.png

 

It should not be that difficult to modify the sheet I posted earlier to reflect the different loop definition.
I also would not expect big differences in the result - which mainly depends on the handling of the incomplete outer loop.

 

Highlighted

Re: Find the area of hysteresis loops

Exactly, everything you have mentioned is correct.  Thumbs up.

Highlighted

Re: Find the area of hysteresis loops

Others have already asked the relevant questions.  To reach the end I think you have two basic methods.  

1.) Integrate the area between curves. (need mathematical representation)

2.) Shoelace theorem.  (using point data)

 

This thread might have some clues for the later.

https://community.ptc.com/t5/PTC-Mathcad/Ploting-an-elliptical-curve/m-p/619614#M186563

Highlighted

Re: Find the area of hysteresis loops

Here is my approach.

I settled on my third interpretation of loop/Cycle.

I also implemented two different ways to calculate the area, the first one uses a functional approach using linear interpolation and the second one is based on the trapezoid method (I guess its what DJF refers to as "shoelace")

Werner_E_0-1603826424025.png

 

 

Highlighted

Re: Find the area of hysteresis loops

The first loops are so tiny - they don't add anything worth mentioning to the total. The first two even give a negative area when calculated with the first method (linear interpolation functions). Not sure why, maybe numerical inaccuracies. I used the absolute value to be on the safe side 😉

But the last loop (where its still unclear we should use it by closing it in some way) of course is the most important one and it will double the result if it is used.

Hysteresis.gif

 

Highlighted

Re: Find the area of hysteresis loops

That's great @Werner_E. I wonder how you have made a gift out of it?

Would you mind attaching the files corresponding to these gifs?

The thing for the last loops is correct. Honestly, I had to continue the last loop. I cut the data just to not make it too big.

Highlighted

Re: Find the area of hysteresis loops

Here is the file attached.

Actually its just a modification from the one I posted earlier with the other definition of "loop".

According the animated GIF: Mathcad can make animations using a system variable FRAME. I just used that to show the 15 loops and their area. Mathcad saves the  animation in an avi container using a very old and inefficient codec (this forum won't accept those files). I converted the AVI into an animated GIF using one of the many online converters available (https://www.onlineconverter.com/avi-to-gif).

Werner_E_0-1603855190012.png

 

View solution in original post

Highlighted

Re: Find the area of hysteresis loops

Thank you @Werner_E . I just cannot understand what the functions delDup and GetLoops do? Would you explain these functions a bit?

Also, why do we need to stack(L1,reverse(L0)) in the AreaOfLoop2 function?

Highlighted

Re: Find the area of hysteresis loops

Admittedly the work slowly evolved and I didn't care to clean-up and straighten it.

 


@mzarrabi wrote:

Thank you @Werner_E . I just cannot understand what the functions delDup and GetLoops do? Would you explain these functions a bit?

Also, why do we need to stack(L1,reverse(L0)) in the AreaOfLoop2 function?


linear interpolation "linterp" threw an error as of the x-values not being in ascendent order. Even after using "csort" the error was thrown, which usually means that there are some duplicate x-values (maybe just equal wrt a certain threshold?). Thats why I wrote a function which removes rows with duplicate values in the first column of a matrix -> "delDup". So the procedure is to get the correct junk of data using submatrix, then sorting the matrix so column 0 is in ascending order (necessary for "linterp") with csort and then deleting rows with duplicate x-values using "delDup" (also to make "linterp" happy).

 

GetLoops calls "separate" (I am not good in naming functions) which just looks at the endpoints of the loops and returns a vector with the appropriate indices. The algorithm in "separate" triggers when the direction of the x-values changes. The first values until the first endpoint is coming are skipped.
So GetLoops now has a list of all endpoints of the loops. The first one (index 0) is right end, the next one a left end, etc. The number of complete loops is calculated and stored in n.

Now for all loops (numbering from 0 to n-1, I assume ORIGIN=0 throughout and did not bother making the functions ORIGIN-aware) the appropriate sub-matrices for the lower and the upper arc are created, using the indices provides by "separated".

The next step (the loop with k) was added to get rid of the excess data on the right of the upper arc. It looks like it has only cosmetic effect in plotting the arc, for the area this had very little effect at all. I am running through the x-values of the upper arc until they exceed the rightmost x-value of the lower arc. Then the new upperarc is created using submatrix.

GetLoops now returns a vector consisting of 2x1 vectors for every loop found. Every 2x1 matrix consist of the data for the upper and the lower arc.

 


Also, why do we need to stack(L1,reverse(L0)) in the AreaOfLoop2 function?


The algorithm used needs the data forming a continuous polygon and not jumping suddenly from a point from the far right end to one at the left end. L0 contains the upper arc with ascending x values. L1 contains the lower half, but also with ascending x-values. To make a continous polygon we need to reverse the order and then add the data to L1. So we have a polygon which starts at the left end, runs across the upper arc to the right and then back to the left following the lower arc.

Using stack(reverse(L[0)mL[1) what be more logical as it follows the direction the loops are presented in the original data set (starting at the right, following the lower arc to the left and then back on the upper arc). Interestingly if I change this, I get slightly different values for the area. This may be because the splitting into arcs maybe wasn't done correct enough by GetLoops. Maybe at the beginning or end there is a value missing or a value too much. Would make a more in depth examination of the data created and comparing with the original data necessary

.

I can't say which of the two area function would be nearer to the correct value, as both should yield the same result. After all because of the linear interpolation used, the numerical integral also can only give the very same results as the trapezoid method. As already written, I am not sure why the results differ - either numerical inaccuracies because of the very small values involved, or a flaw in the separation of the data??

 

Announcements