81 lines
3.2 KiB
Fortran
81 lines
3.2 KiB
Fortran
program test_solid_elastic_material
|
|
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_internal_energy
|
|
use sph_solid_material, only: sph_solid_elastic_constants, &
|
|
sph_solid_elastic_trial, sph_solid_von_mises, &
|
|
sph_solid_internal_energy_increment
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call check_elastic_helpers()
|
|
call check_elastic_particle_update()
|
|
|
|
contains
|
|
|
|
subroutine check_elastic_helpers()
|
|
real(rk) :: shear
|
|
real(rk) :: bulk
|
|
real(rk) :: wave_speed
|
|
real(rk) :: stress_old(6)
|
|
real(rk) :: stress_new(6)
|
|
real(rk) :: strain_inc(6)
|
|
real(rk) :: energy_inc
|
|
|
|
call sph_solid_elastic_constants(210.0e9_rk, 0.30_rk, 7850.0_rk, &
|
|
shear, bulk, wave_speed, ierr)
|
|
call assert_ok(ierr, 'elastic constants failed')
|
|
if (shear <= 0.0_rk .or. bulk <= 0.0_rk) call fail('elastic constants missing')
|
|
if (wave_speed <= 0.0_rk) call fail('elastic wave speed missing')
|
|
stress_old = 0.0_rk
|
|
strain_inc = 0.0_rk
|
|
strain_inc(1) = 1.0e-5_rk
|
|
call sph_solid_elastic_trial(stress_old, strain_inc, shear, bulk, stress_new, ierr)
|
|
call assert_ok(ierr, 'elastic trial failed')
|
|
if (stress_new(1) <= 0.0_rk) call fail('elastic stress update missing')
|
|
if (sph_solid_von_mises(stress_new) <= 0.0_rk) call fail('von Mises stress missing')
|
|
call sph_solid_internal_energy_increment(stress_old, stress_new, strain_inc, &
|
|
7850.0_rk, energy_inc, ierr)
|
|
call assert_ok(ierr, 'elastic energy increment failed')
|
|
if (energy_inc <= 0.0_rk) call fail('elastic internal energy increment missing')
|
|
end subroutine check_elastic_helpers
|
|
|
|
subroutine check_elastic_particle_update()
|
|
real(rk) :: strain_inc(6)
|
|
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for elastic particle update')
|
|
call sph_read_inp('tests/data/solid_elastic_minimal_050.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for elastic particle update')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for elastic particle update')
|
|
strain_inc = 0.0_rk
|
|
strain_inc(1) = 1.0e-5_rk
|
|
call sph_solid_update_particle_material(1, strain_inc, 1.0e-7_rk, ierr)
|
|
call assert_ok(ierr, 'elastic particle update failed')
|
|
if (solid_stress(1,1) <= 0.0_rk) call fail('particle elastic stress missing')
|
|
if (abs(solid_plastic_strain(1)) > 0.0_rk) call fail('elastic particle became plastic')
|
|
if (solid_internal_energy(1) <= 0.0_rk) call fail('particle elastic energy missing')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for elastic particle update')
|
|
end subroutine check_elastic_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_elastic_material
|