how can I use type engine.ScalarField as float64?

171 views
Skip to first unread message

Md. Abdus Sami Akanda

unread,
Jul 2, 2022, 4:53:44 PM7/2/22
to mumax2
Hello everyone,
I'm trying to get the square of the x component of m. For that I used the m.Comp(0) function and when I write:

mx = m.Comp(0);
m2 = mx*mx;
print(m2);

I get the following error:

: type mismatch: can not use type engine.ScalarField as float64

Is there any way that I can convert mx to float64?
Thanks.

Regards,
Md Abdus Sami Akanda
Khulna University
Khulna, Bangladesh

Josh Lauzier

unread,
Jul 2, 2022, 5:03:28 PM7/2/22
to mumax2
Hello,

m.comp(0) gives you the x component of m for each cell. So if m is a LxMxN array of 3-component vectors, m.comp(0) is an LxMxN array of 1 component vectors/scalars (just the x component).

If you want just the average, you want something like "m.comp(0).average()" instead. This should allow you to square it.

It's a bit confusing, if you try "print(m.comp(0))", it does the averaging implicitly for you, so really it's doing "print(m.comp(0).average())" to the command line instead. But you can see the full details if you "save(m.comp(0))".



Best,
Josh L.

Md. Abdus Sami Akanda

unread,
Jul 8, 2022, 3:59:45 PM7/8/22
to mumax2
Thank you so much. I was able to solve my issue.

Regards,
Md Abdus Sami Akanda

Reply all
Reply to author
Forward
0 new messages