121 lines
4.0 KiB
Fortran
121 lines
4.0 KiB
Fortran
program test_strength_reduction
|
|
use fem_precision
|
|
use fem_error
|
|
use fem_strength_reduction
|
|
implicit none
|
|
|
|
real(rk), parameter :: TOL = 1.0e-10_rk
|
|
real(rk) :: phi0
|
|
real(rk) :: psi0
|
|
integer :: ierr
|
|
|
|
phi0 = 30.0_rk * acos(-ONE) / 180.0_rk
|
|
psi0 = 6.0_rk * acos(-ONE) / 180.0_rk
|
|
|
|
call check_param_reduction(phi0, psi0, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(1)
|
|
call check_bracket(ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(2)
|
|
call check_metric(ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(3)
|
|
|
|
contains
|
|
|
|
subroutine check_param_reduction(phi0, psi0, ierr)
|
|
real(rk), intent(in) :: phi0
|
|
real(rk), intent(in) :: psi0
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: phi
|
|
real(rk) :: cohesion
|
|
real(rk) :: dilation
|
|
real(rk) :: tension
|
|
|
|
call sr_reduce_mc_params(phi0, 20.0_rk, psi0, 4.0_rk, 2.0_rk, &
|
|
phi, cohesion, dilation, tension, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (abs(phi - atan(tan(phi0) / 2.0_rk)) .gt. TOL) call fail(10)
|
|
if (abs(dilation - atan(tan(psi0) / 2.0_rk)) .gt. TOL) call fail(11)
|
|
if (abs(cohesion - 10.0_rk) .gt. TOL) call fail(12)
|
|
if (abs(tension - 2.0_rk) .gt. TOL) call fail(13)
|
|
|
|
call sr_reduce_mc_params(phi0, 20.0_rk, psi0, 4.0_rk, ZERO, &
|
|
phi, cohesion, dilation, tension, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(14)
|
|
ierr = FEM_SUCCESS
|
|
end subroutine check_param_reduction
|
|
|
|
subroutine check_bracket(ierr)
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: lower
|
|
real(rk) :: upper
|
|
real(rk) :: next_factor
|
|
integer :: status
|
|
|
|
lower = ZERO
|
|
upper = ZERO
|
|
call sr_next_factor(lower, upper, next_factor, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (status .ne. SR_STATUS_SEARCHING) call fail(30)
|
|
if (abs(next_factor - ONE) .gt. TOL) call fail(31)
|
|
|
|
call sr_update_bracket(ONE, .true., lower, upper, next_factor, &
|
|
1.0e-4_rk, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (abs(lower - ONE) .gt. TOL) call fail(32)
|
|
if (abs(upper) .gt. TOL) call fail(33)
|
|
if (next_factor .le. ONE) call fail(34)
|
|
|
|
call sr_update_bracket(1.6_rk, .false., lower, upper, next_factor, &
|
|
1.0e-4_rk, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (status .ne. SR_STATUS_BRACKETED) call fail(35)
|
|
if (abs(next_factor - 1.3_rk) .gt. TOL) call fail(36)
|
|
|
|
call sr_update_bracket(1.299_rk, .true., lower, upper, next_factor, &
|
|
1.0e-3_rk, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (status .ne. SR_STATUS_BRACKETED) call fail(371)
|
|
|
|
call sr_update_bracket(1.30001_rk, .false., lower, upper, next_factor, &
|
|
1.0e-3_rk, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (status .ne. SR_STATUS_CONVERGED) call fail(37)
|
|
if (next_factor .le. lower .or. next_factor .ge. upper) call fail(38)
|
|
end subroutine check_bracket
|
|
|
|
subroutine check_metric(ierr)
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: metric
|
|
logical :: unstable
|
|
|
|
call sr_instability_metric(0.1_rk, 0.5_rk, 0.2_rk, .false., &
|
|
metric, unstable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (unstable) call fail(50)
|
|
if (metric .le. ZERO) call fail(51)
|
|
|
|
call sr_instability_metric(1.5_rk, 0.5_rk, 0.2_rk, .false., &
|
|
metric, unstable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (.not. unstable) call fail(52)
|
|
|
|
call sr_instability_metric(0.1_rk, 0.5_rk, 0.96_rk, .false., &
|
|
metric, unstable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (.not. unstable) call fail(53)
|
|
|
|
call sr_instability_metric(0.1_rk, 0.5_rk, 0.2_rk, .true., &
|
|
metric, unstable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (.not. unstable) call fail(54)
|
|
end subroutine check_metric
|
|
|
|
subroutine fail(code)
|
|
integer, intent(in) :: code
|
|
|
|
write(*,*) 'test_strength_reduction failed:', code
|
|
stop 1
|
|
end subroutine fail
|
|
|
|
end program test_strength_reduction
|