Skip to content

Commit

Permalink
Fix sign of demagnetizing energy in the right place
Browse files Browse the repository at this point in the history
The previous commit changed the sign of the contribution of the volume
charges to the demagnetizing energy. It turns out the sign within the
expression was right to begin with. However, it relied on
Tet::interpolation(), which had the wrong sign. This error did not
affect the magnetization dynamics because that particular overload of
Tet::interpolation() is only used to compute the demagnetizing energy.

For sanity's sake, use the right sign in both places.
  • Loading branch information
edgar-bonet committed Jan 25, 2024
1 parent 24934f2 commit a8aad55
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tetra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ double Tet::demagEnergy(Eigen::Ref<Eigen::Matrix<double,DIM,NPI>> dudx,

for (int npi = 0; npi < NPI; npi++)
{ dens[npi] = (dudx(0,npi) + dudy(1,npi) + dudz(2,npi)) * phi[npi]; }
return 0.5*mu0*Ms*weight.dot(dens);
return -0.5*mu0*Ms*weight.dot(dens);
}

double Tet::zeemanEnergy(Tetra::prm const &param, Eigen::Ref<Eigen::Vector3d> const Hext,
Expand Down
2 changes: 1 addition & 1 deletion tetra.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class Tet : public element<N,NPI>
{
Eigen::Matrix<double,N,1> scalar_nod;
for (int i = 0; i < N; i++) scalar_nod(i) = getter(refNode[ind[i]]);
result = -scalar_nod.transpose() * eigen_a;
result = scalar_nod.transpose() * eigen_a;
}

/** interpolation for 3D vector field and a tensor : getter function is given as a parameter to
Expand Down

0 comments on commit a8aad55

Please sign in to comment.