Commit 6b674277 authored by Sebastian Pech's avatar Sebastian Pech
Browse files

Add tests for NaN check

parent da07006c
Pipeline #202 passed with stages
in 43 seconds
......@@ -208,6 +208,7 @@ subroutine deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gr
external DGESVD
A = 0.0_dp
do i = 1,NSURF
call random_number(perturbation)
d_alpha(i) = f_yield_value(i)/norm2(gradients(i,:))+perturbation*1.0e-5
......
......@@ -129,13 +129,14 @@ end subroutine matrix_tests
subroutine test_linear_dependence()
logical, dimension(NSURF) :: J_active, J_active_ind
logical :: success
real(dp) :: gradients(NSURF,6), f_yield_value(NSURF)
real(dp) :: gradients(NSURF,6), f_yield_value(NSURF), zero
integer :: i
logical, parameter :: t=.true.,f=.false.
J_active = .false.
J_active(1) = .true.
J_active(2) = .true.
J_active(3) = .true.
zero = 0.0_dp ! this is for testing Nan
gradients(1,:) = (/1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp/)
gradients(2,:) = (/0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp/)
......@@ -146,7 +147,7 @@ subroutine test_linear_dependence()
f_yield_value(3) = 1
call deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gradients, success)
call test("Linear dependence", all(J_active_ind .eqv. (/t, f, t, f, f, f, f, f/)))
call test("Linear dependence 1", all(J_active_ind .eqv. (/t, f, t, f, f, f, f, f/)))
gradients = 0.0_dp
do i = 1,6
......@@ -156,7 +157,7 @@ subroutine test_linear_dependence()
J_active(1:6) = .true.
call deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gradients, success)
call test("Linear dependence", all(J_active_ind .eqv. J_active))
call test("Linear dependence 2", all(J_active_ind .eqv. J_active))
gradients(4,:) = gradients(5,:)*0.1_dp + gradients(2,:)*0.2_dp
......@@ -165,7 +166,7 @@ subroutine test_linear_dependence()
f_yield_value = 1.0_dp
f_yield_value(4) = 0.0_dp
call deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gradients, success)
call test("Linear dependence", all(J_active_ind .eqv. (/t, t, t, f, t, t, f, f/)))
call test("Linear dependence 3", all(J_active_ind .eqv. (/t, t, t, f, t, t, f, f/)))
J_active = .false.
J_active(1:6) = .true.
......@@ -173,7 +174,7 @@ subroutine test_linear_dependence()
f_yield_value(2) = -1.0_dp
f_yield_value(4) = 0.0_dp
call deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gradients, success)
call test("Linear dependence", all(J_active_ind .eqv. (/t, f, t, t, t, t, f, f/)))
call test("Linear dependence 4", all(J_active_ind .eqv. (/t, f, t, t, t, t, f, f/)))
J_active = .false.
J_active(1:6) = .true.
......@@ -181,7 +182,11 @@ subroutine test_linear_dependence()
f_yield_value(1) = -1.0_dp
f_yield_value(4) = 0.0_dp
call deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gradients, success)
call test("Linear dependence", all(J_active_ind .eqv. (/f, t, t, f, t, t, f, f/)))
call test("Linear dependence 5", all(J_active_ind .eqv. (/f, t, t, f, t, t, f, f/)))
gradients = zero/zero
call deactivate_linear_depended(J_active_ind, J_active, f_yield_value, gradients, success)
call test("Linear dependence (NaN)", .not. success)
end subroutine test_linear_dependence
subroutine rexamples ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment