ubermag / help

Repository for raising issues and requesting help on Ubermag
BSD 2-Clause "Simplified" License
11 stars 3 forks source link

Mumax3c HysteresisDriver #214

Open samjrholt opened 2 years ago

samjrholt commented 2 years ago

Originally posted by @SeregaKR in https://github.com/ubermag/help/issues/208#issuecomment-1188937440

Hello again.

I'm checking documentation about making hysteresis loops. It seems that the mumax3c module doesn't have this function from the box yet. It's possible to do this now in a roundabout way by setting Zeeman energy directly and doing minimize and relax functions afterward. But this is not described in examples and docs very well. The code below shows how I tried implementing it (I needed only the Bx component changed). The code is only for the virgin curve. But now, each step generates 2 files for each field (minimize and relax) which is a bit too much.

Bmin = -1e6
Bmax =  1e6
Bstep = 1e-2

md = mc.MinDriver()
rd = mc.RelaxDriver()

for B in range(0, Bmax+Bstep,Bstep):
    system.energy.zeeman.H = (B, 0, 0)
    rd.drive(system)
    md.drive(system)

and then the same can be done for the downward and upward curves. The corresponding code in mumax3 is also attached for reference.

Bmin := -1e6
Bmax :=  1e6
Bstep := 1e-2

for B:=0.0; B<=Bmax; B+=Bstep{
    B_ext = vector(B, 0, 0)
    minimize()
    relax()
    save(m_full)
    tablesave()
}

I hope that in the future, HysteresisDriver will be implemented from the box for mumax3. It took me an embarrassingly long time to find that you can set system.energy.zeeman.H

samjrholt commented 2 years ago

Hi @SeregaKR, you are correct that mumax3c does not have a HysteresisDriver implemented. In the near future we were not looking to add this functionality as we are now trying to cover this in different ways which gives the users more control, for example in mag2exp. There is documentation on how to create a virgin hysteresis curve in the mag2exp documentation. https://ubermag.github.io/documentation/notebooks/mag2exp/DC_magnetometry.html

However, if you still feel there is a need for a HysteresisDriver in mumax3c then we can talk about the best ways to implement this. Thank you for attaching the Mumax3 code for this.

SeregaKR commented 2 years ago

@samjrholt, thank you for the reference - I will try using it. I suggested implementing this for consistency purposes. The oomfc has HysteresisDriver, but mumax3c does not. So if you want to switch from one engine to another, you need to change your approach, e.g., using mag2exp or the code I wrote above. But in the second case, you then need to go through all the steps and merge output for the minimize and relax functions. I believe we can do it by using this << binary operator.

lang-m commented 2 years ago

Hi @SeregaKR thanks for bringing this up and for providing some code that can solve it. The consistency issue - running the same notebook with just changing the import line for the calculator (currently oommfc or mumax3c) - that you broad up in your last comment is a good point. There will always be some very package-specific details in the different calculators that we cannot really abstract away. However, the HysteresisDriver is quite general so we will have an internal discussion about supporting it inside mumax3c. Actually adding it might however take some time as we only have limited capacity.