Hi,
The anisotropy is being applied.
A couple things:
Briefly running your script with relax, your magnetization is in-plane. This means the demag field/shape anisotropy and external is stronger than your out-of-plane anisotropy, and pulls your initialized magnetization in-plane. The magnetocrystalline anisotropy field goes as 2*K/Msat (u dot m) u, where u is the anisotropy direction, and m is the magnetization direction. When m is in plane and u is (0,0,1), u dot m is 0; the dot product is of two perpendicular vectors. (This does not mean it is not being applied, just that it is strongest when m and u are parallel or anti-parallel, and weakest/0 when they are perpendicular)
Second, in the run case, it will still be pulled in-plane, but you are probably not running long enough for the magnetization to shift from your initial state (out of plane) to in-plane. To get to equilibrium with run() can take quite a long time (i would also recommend using a larger alpha, to damp out the transient behavior faster. If you're just doing hysteresis you don't care about the transient behavior). The fact that run takes so long to get to equilibrium is why it is suggested to use relax/minimize for hysteresis loops.
I would also double check your settings- if you view your magnetization, it is bouncing around like crazy at each field step, in a way that isn't evident just from printing out.
Last, you are likely running into symmetry issues, you can find discussions on this in
previous discussions. You will likely want to break this (the previously mentioned magnetization bouncing around is likely tied to not getting to equilibrium and also this symmetry confusing the solver).
Best,
Josh L.