Files
SPHLite/tests/module/test_solid_johnson_cook_flow.f90
2026-07-03 15:05:43 +08:00

81 lines
3.5 KiB
Fortran

program test_solid_johnson_cook_flow
use sph_precision, only: rk
use sph_error, only: SPH_SUCCESS
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
use sph_solid, only: sph_solid_update_particle_material
use sph_solid_state, only: solid_stress, solid_plastic_strain, &
solid_plastic_strain_rate, solid_temperature, solid_temperature_rise_factor
use sph_solid_material, only: sph_solid_jc_flow_stress, sph_solid_von_mises
implicit none
integer :: ierr
call check_johnson_cook_flow_helpers()
call check_johnson_cook_particle_update()
contains
subroutine check_johnson_cook_flow_helpers()
real(rk) :: flow_static
real(rk) :: flow_hardened
call sph_solid_jc_flow_stress(792.0e6_rk, 510.0e6_rk, 0.26_rk, &
0.014_rk, 1.03_rk, 1.0_rk, 293.0_rk, 1793.0_rk, &
0.0_rk, 0.0_rk, 293.0_rk, flow_static, ierr)
call assert_ok(ierr, 'Johnson-Cook static flow failed')
call sph_solid_jc_flow_stress(792.0e6_rk, 510.0e6_rk, 0.26_rk, &
0.014_rk, 1.03_rk, 1.0_rk, 293.0_rk, 1793.0_rk, &
0.10_rk, 100.0_rk, 293.0_rk, flow_hardened, ierr)
call assert_ok(ierr, 'Johnson-Cook hardened flow failed')
if (flow_static <= 0.0_rk) call fail('Johnson-Cook static flow missing')
if (flow_hardened <= flow_static) call fail('Johnson-Cook hardening/rate term missing')
call sph_solid_jc_flow_stress(792.0e6_rk, 510.0e6_rk, 0.26_rk, &
0.014_rk, 1.03_rk, 0.0_rk, 293.0_rk, 1793.0_rk, &
0.0_rk, 1.0_rk, 293.0_rk, flow_static, ierr)
if (ierr == SPH_SUCCESS) call fail('invalid Johnson-Cook epsdot0 was accepted')
call sph_solid_jc_flow_stress(792.0e6_rk, 510.0e6_rk, 0.26_rk, &
0.014_rk, 1.03_rk, 1.0_rk, 293.0_rk, 293.0_rk, &
0.0_rk, 1.0_rk, 293.0_rk, flow_static, ierr)
if (ierr == SPH_SUCCESS) call fail('invalid Johnson-Cook temperature range was accepted')
end subroutine check_johnson_cook_flow_helpers
subroutine check_johnson_cook_particle_update()
real(rk) :: strain_inc(6)
real(rk) :: temp_before
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for Johnson-Cook update')
call sph_read_inp('tests/data/solid_johnson_cook_failure_050.inp', ierr)
call assert_ok(ierr, 'read failed for Johnson-Cook update')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for Johnson-Cook update')
solid_temperature_rise_factor(1) = 1.0e-6_rk
temp_before = solid_temperature(1)
strain_inc = 0.0_rk
strain_inc(4) = 2.0e-2_rk
call sph_solid_update_particle_material(1, strain_inc, 1.0e-6_rk, ierr)
call assert_ok(ierr, 'Johnson-Cook particle update failed')
if (solid_plastic_strain(1) <= 0.0_rk) call fail('plastic strain was not updated')
if (solid_plastic_strain_rate(1) <= 0.0_rk) call fail('plastic strain rate was not updated')
if (sph_solid_von_mises(solid_stress(:,1)) <= 0.0_rk) call fail('plastic stress missing')
if (solid_temperature(1) <= temp_before) call fail('plastic temperature did not increase')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for Johnson-Cook update')
end subroutine check_johnson_cook_particle_update
subroutine assert_ok(ierr_value, message)
integer, intent(in) :: ierr_value
character(len=*), intent(in) :: message
if (ierr_value /= SPH_SUCCESS) call fail(message)
end subroutine assert_ok
subroutine fail(message)
character(len=*), intent(in) :: message
write(*, '(A)') trim(message)
stop 1
end subroutine fail
end program test_solid_johnson_cook_flow