mumax / 3

GPU-accelerated micromagnetic simulator
Other
447 stars 150 forks source link

Update magnetoelasticfield.cu #324

Closed marcrovi closed 1 year ago

marcrovi commented 1 year ago

The magnetoelastic energy is written as:

$$ E_{me} = B1(E{xx}m{x}^2 + E{yy}m{y}^2 + E{zz}m_{z}^2) + 2B2(E{xy}m{x}m{y}+E{xz}m{x}m{z}+E{yz}m{y}m{z}) $$

And the effective field is: $B{me} = -\nabla{m} E_{me}$ Therefore, for example, the effective field in $m_x$ would be:

$$ B_{me}^x = -2B1 E{xx}m_x + 2B2( E{xy}my + E_{xz} m_z) $$

The article: https://doi.org/10.12688/openreseurope.13302.1 on page 4, equation 3, explains how the model is implemented and in this GitHub link you can find the code: https://github.com/Fredericvdv/Magnetoelasticity_MuMax3/blob/eeb112dff216a4ae3267fc27fe67aa0e7ada6423/cuda/magnetoelasticfield.cu

In this repository effective field terms are calculated correctly:

            Bx[I] += -2.0f*(B1*m.x*Exx + B2*(m.y*Exy + m.z*Exz));
        By[I] += -2.0f*(B1*m.y*Eyy + B2*(m.x*Eyx + m.z*Eyz));
        Bz[I] += -2.0f*(B1*m.z*Ezz + B2*(m.x*Ezx + m.y*Ezy)); 

Where the 2.0f is multiplied by both B1 and B2. However, in the MuMax3 repository, I found:

        Bx[I] += -(2.0f*B1*m.x*Exx + B2*(m.y*Exy + m.z*Exz));
        By[I] += -(2.0f*B1*m.y*Eyy + B2*(m.x*Eyx + m.z*Eyz));
        Bz[I] += -(2.0f*B1*m.z*Ezz + B2*(m.x*Ezx + m.y*Ezy));

The parenthesis should be after the 2.0f.

This Pull Request is to address this issue.

JLeliaert commented 1 year ago

Closes #323

Well spotted. Thanks for fixing this!