Harden explosive input coverage
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
program test_input_explosive_multimaterial
|
||||
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, sph_get_input_warning_count
|
||||
use sph_explosive_state, only: EXPLOSIVE_CONVERSION_PHASE, &
|
||||
EXPLOSIVE_CONVERSION_SOURCE, explosive_material_count, &
|
||||
explosive_product_material_id, explosive_detonation_velocity, &
|
||||
explosive_energy_per_mass, explosive_burn_time, &
|
||||
explosive_conversion_mode
|
||||
implicit none
|
||||
|
||||
call assert_multimaterial_controls()
|
||||
call assert_shared_product_material()
|
||||
call assert_product_missing_eos_error()
|
||||
call assert_unbound_material_warning()
|
||||
|
||||
contains
|
||||
|
||||
subroutine assert_multimaterial_controls()
|
||||
integer :: ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize multimaterial failed')
|
||||
call sph_read_inp('tests/data/explosive_multimaterial_041.inp', ierr)
|
||||
call assert_ok(ierr, 'read multimaterial failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build multimaterial failed')
|
||||
if (explosive_material_count /= 2) call fail('explosive material count mismatch')
|
||||
call assert_close(explosive_detonation_velocity(1), 6900.0_rk, &
|
||||
'first detonation velocity mismatch')
|
||||
call assert_close(explosive_detonation_velocity(2), 7600.0_rk, &
|
||||
'second detonation velocity mismatch')
|
||||
call assert_close(explosive_energy_per_mass(1), 4.2e6_rk, &
|
||||
'first energy mismatch')
|
||||
call assert_close(explosive_energy_per_mass(2), 5.0e6_rk, &
|
||||
'second energy mismatch')
|
||||
call assert_close(explosive_burn_time(1), 1.0e-7_rk, &
|
||||
'first burn time mismatch')
|
||||
call assert_close(explosive_burn_time(2), 2.0e-7_rk, &
|
||||
'second burn time mismatch')
|
||||
if (explosive_conversion_mode(1) /= EXPLOSIVE_CONVERSION_SOURCE) then
|
||||
call fail('first conversion mode mismatch')
|
||||
end if
|
||||
if (explosive_conversion_mode(2) /= EXPLOSIVE_CONVERSION_PHASE) then
|
||||
call fail('second conversion mode mismatch')
|
||||
end if
|
||||
if (explosive_product_material_id(1) == explosive_product_material_id(2)) then
|
||||
call fail('different product material mapping mismatch')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize multimaterial failed')
|
||||
end subroutine assert_multimaterial_controls
|
||||
|
||||
subroutine assert_shared_product_material()
|
||||
integer :: ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize shared product failed')
|
||||
call sph_read_inp('tests/data/explosive_multi_ignition_cross_material_041.inp', &
|
||||
ierr)
|
||||
call assert_ok(ierr, 'read shared product failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build shared product failed')
|
||||
if (explosive_material_count /= 2) call fail('shared product material count mismatch')
|
||||
if (explosive_product_material_id(1) /= explosive_product_material_id(2)) then
|
||||
call fail('same product material mapping mismatch')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize shared product failed')
|
||||
end subroutine assert_shared_product_material
|
||||
|
||||
subroutine assert_product_missing_eos_error()
|
||||
integer :: ierr
|
||||
integer :: final_ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize missing EOS failed')
|
||||
call sph_read_inp('tests/data/explosive_product_missing_eos_040.inp', ierr)
|
||||
if (ierr == SPH_SUCCESS) call sph_build_model(ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('product Gas missing EOS passed')
|
||||
call sph_finalize(final_ierr)
|
||||
call assert_ok(final_ierr, 'finalize missing EOS failed')
|
||||
end subroutine assert_product_missing_eos_error
|
||||
|
||||
subroutine assert_unbound_material_warning()
|
||||
integer :: ierr
|
||||
integer :: warnings
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize unbound material failed')
|
||||
call sph_read_inp('tests/data/explosive_unbound_material_warning_041.inp', ierr)
|
||||
call assert_ok(ierr, 'read unbound material failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build unbound material failed')
|
||||
call sph_get_input_warning_count(warnings, ierr)
|
||||
call assert_ok(ierr, 'warning query failed')
|
||||
if (warnings < 1) call fail('unbound Explosive material warning mismatch')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize unbound material failed')
|
||||
end subroutine assert_unbound_material_warning
|
||||
|
||||
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 assert_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual
|
||||
real(rk), intent(in) :: expected
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (abs(actual - expected) > 1.0e-10_rk * max(1.0_rk, abs(expected))) then
|
||||
call fail(message)
|
||||
end if
|
||||
end subroutine assert_close
|
||||
|
||||
subroutine fail(message)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
write(*, '(A)') trim(message)
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_input_explosive_multimaterial
|
||||
Reference in New Issue
Block a user