Non-linear time-dependent external magnetic field

235 views
Skip to first unread message

Haowen Ren

unread,
Nov 10, 2023, 12:19:51 AM11/10/23
to mumax2
Hello All,

I am doing some simulations that need applied an external field following specific scale with time. 

I was using the command Bext.Add(LoadFile("B_profile.ovf"), sin(2*pi*f*t)). This works great for the field that follows a periodic function. However, I want to apply a field that follows a waveform with any customized time vs Bext_scale as shown below. I tried many times but failed to do so. 

Is there a any way to apply a known waveform in mumax? Do I need to change the script in the package to do so?  If not possible, what is the reason behind this issue? Thank you!

Best Regards,
Harry

Screenshot 2023-11-09 182437.png

Josh Lauzier

unread,
Nov 10, 2023, 2:27:01 AM11/10/23
to mumax2
Hi,

Ideally, it would be easiest if you could build up your waveform in terms of known analytic functions. Mumax has a few functions build in besides just the periodic functions (like the heaviside function). You can also chop up your run() commands, and do each part piecewise. However, this will still be fairly limited.

However, if you need the full flexibility of any custom waveform, you would need an interpolation function, as described by Joo-von Kim here: https://groups.google.com/g/mumax2/c/gl5TFSLwN0Q/m/-u2t8nL0AAAJ


Best.
Josh L.

Haowen Ren

unread,
Nov 12, 2023, 12:20:36 AM11/12/23
to mumax2
Hello Josh,

Thanks for the informative suggestions! I think I could do it by chopping and run as it is the easiest way to do so. 

I found the Joo-von's post is super helpful as we can use the golang to implement time-dependent customized function. However, I have never tried to run mumax using golang itself. Is it similar to how to define function in python? Like "def function(t,a,b): return y=a*t+b", and then include this function in B_ext.Add( LoadFile("Bprofile.ovf")  , function(t))? It would be great if you could provide an example of how to implement a function via golang. Thank you!

Best,
Haowen

Josh Lauzier

unread,
Nov 12, 2023, 5:11:28 AM11/12/23
to mumax2
Hi,

It would be very similar to defining a function in python, just following Golang syntax. You'd probably also have to recompile mumax to get it to recognize the function. I don't think you would need to run mumax using a go input file (this can be done, but it is very complicated and not well documented). You'd just need the extra function and recompiling mumax, and otherwise you can run mumax as normal.

Unfortunately, I don't have a good example, I haven't had to do it myself yet. A good starting spot might be to look at the mumax source code, and look at the sinc function or the heaviside function (they are defined in the stdlib.go file). They were defined by mumax, they're not standard mathematical functions in Golangs math library. Your custom function would be similar. Yours would be a bit more complicated than that since you would need some sort of sensible interpolation scheme. But otherwise you should be able to pretty much copy the sinc function nearly exactly, in terms of formatting, where to place it in the source code, etc.

That said, chopping it up is almost certainly going to be easier. I would only bother with the interpolation function if you have no feasible alternative.

Best,
Josh L.

Reply all
Reply to author
Forward
0 new messages