Skip to content

Commit

Permalink
choose more realistic margins for the single precision test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Puerling committed Sep 12, 2024
1 parent c4ab1e4 commit ee2e68f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions core/test/test_anisotropy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#endif

#ifdef SPIRIT_SCALAR_TYPE_DOUBLE
[[maybe_unused]] constexpr scalar epsilon_2 = 1e-10;
[[maybe_unused]] constexpr scalar epsilon_3 = 1e-12;
[[maybe_unused]] constexpr scalar epsilon_4 = 1e-12;
[[maybe_unused]] constexpr scalar epsilon_5 = 1e-6;
[[maybe_unused]] constexpr scalar epsilon_6 = 1e-7;
[[maybe_unused]] constexpr scalar epsilon_2 = 1e-5;
[[maybe_unused]] constexpr scalar epsilon_3 = 1e-6;
[[maybe_unused]] constexpr scalar epsilon_4 = 1e-7;
[[maybe_unused]] constexpr scalar epsilon_5 = 1e-8;
[[maybe_unused]] constexpr scalar epsilon_6 = 1e-9;
#else
[[maybe_unused]] constexpr scalar epsilon_2 = 1e-2;
[[maybe_unused]] constexpr scalar epsilon_3 = 1e-3;
Expand Down Expand Up @@ -313,6 +313,8 @@ TEST_CASE( "Biaxial anisotropy", "[anisotropy]" )

SECTION( "Engine: Check results of the energy calculations" )
{
using std::sin, std::cos;

const auto test = [&state, &interaction,
&term_info]( const int idx, const scalar theta, const scalar phi, const auto &... terms )
{
Expand Down Expand Up @@ -348,7 +350,8 @@ TEST_CASE( "Biaxial anisotropy", "[anisotropy]" )
INFO( "Total Energy:" )
INFO( "trial: " << idx << ", theta=" << theta << ", phi=" << phi );
INFO( term_info( terms... ) );
REQUIRE_THAT( interaction->Energy( spins ), WithinAbs( state->nos * ref_energy, epsilon_5 ) );
REQUIRE_THAT(
interaction->Energy( spins ) / static_cast<scalar>( state->nos ), WithinAbs( ref_energy, epsilon_3 ) );

vectorfield gradient( state->nos, Vector3::Zero() );
interaction->Gradient( spins, gradient );
Expand Down
2 changes: 1 addition & 1 deletion core/test/test_manifoldmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TEST_CASE( "Manifold operations", "[manifold]" )
scalar proj_prev = Engine::Vectormath::dot( v1, v3 );
REQUIRE_THAT( Engine::Vectormath::dot( v1, v3 ), WithinAbs( proj_prev, 1e-12 ) );
Engine::Manifoldmath::invert_orthogonal( v1, v2 );
REQUIRE_THAT( Engine::Vectormath::dot( v1, v3 ), WithinAbs( -proj_prev, epsilon_6 ) );
REQUIRE_THAT( Engine::Vectormath::dot( v1, v3 ), WithinAbs( -proj_prev, epsilon_5 ) );
}

SECTION( "Projection: tangetial" )
Expand Down
2 changes: 1 addition & 1 deletion core/test/test_physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ TEST_CASE( "Dipole-Dipole Interaction", "[physics]" )
INFO( "i = " << i << ", epsilon = " << epsilon_2 << "\n" );
INFO( "Gradient (FD) = " << grad_fft_fd[i].transpose() << "\n" );
INFO( "Gradient = " << grad_fft[i].transpose() << "\n" );
REQUIRE( grad_fft_fd[i].isApprox( grad_fft[i], epsilon_2 ) );
REQUIRE_THAT( ( grad_fft_fd[i] - grad_fft[i] ).norm(), WithinAbs( 0, epsilon_2 ) );
}
}
// Direct (cutoff) gradient and energy
Expand Down

0 comments on commit ee2e68f

Please sign in to comment.