ubermag / help

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

Zeeman "func" error #198

Closed Ponsudana closed 2 years ago

Ponsudana commented 2 years ago

Hello Ubermag team,

I tried to define a circularly polarized field as expressed by, equation I got an error as "local variable 'mif' referenced before assignment" when defining both cos and sin function. When using the predefined sin function as func='sin', the OOMMF run was successful, but the field direction is different for the defined cos function. Field.zip Both the notebooks are attached and any comments on this will be helpful. Thank you, Regards, Ponsudana

lang-m commented 2 years ago

Hi @Ponsudana thanks for reporting your problems. You have discovered two bugs in oommfc when using multiple time-dependent fields (or currents) simultaneously.

Ponsudana commented 2 years ago

Hi @lang-m Thank you for your response. May I know when this bug will be fixed?

Ponsudana commented 2 years ago

Hello @lang-m Should I wait for the next updated ubermag version for this bug to be resolved? How can I run my programs without this error? Thank you,

lang-m commented 2 years ago

Hi @Ponsudana Please wait for the next release. We are already working on it and plan to finish the release by tomorrow evening. I'll send another message.

Ponsudana commented 2 years ago

Hi @lang-m Thank you for the update.

lang-m commented 2 years ago

@Ponsudana ubermag version 0.61.2 is now available on conda-forge (and PyPI).

Ponsudana commented 2 years ago

Hi @lang-m I've updated the ubermag version. Thank you so much for the quick update. Now, the Zeeman terms are defined correctly as per sin and cos functions. But, there is no change in the magnetization dynamics. I've attached my notebooks. Field_new.zip

Is something wrong with my program? While defining Zeeman, dt is the time steps in seconds. So, if I wish to drive the system for 1ns in 200 steps, dt=5ps. Is this correct definition for dt in mm.Zeeman(H=H1, func=cos_wave, dt=5e-12, name= 'zeeman1')?

lang-m commented 2 years ago

Hi @Ponsudana The definition of dt is independent of the number of timesteps used in the timedriver (and completely unrelated). It defines a "resolution" at which your function defining the time dependency is sampled (only those samples are then forwarded to OOMMF). Typically, you would use a (much) smaller value for dt. The value mostly depends on how fast your function is changing (as we internally numerically compute derivatives and the simulation works best if these derivative values do not become too big). Try maybe with a starting point around dt=1e-12 - dt=1e-13. A good indication for a too large value would be if your simulation gets stuck at some point during the time evolution.

In your notebook you have only defined system.energy but subsequently you run the TimeDriver. You have to also define system.dynamics if you want to use the TimeDriver.

Ponsudana commented 2 years ago

Hi @lang-m Thanks for the clear explanation about dt. I was focusing on energy terms and forgot to define the dynamics. Thanks for pointing that out.