Complete Explosive 0.4.0 gate

This commit is contained in:
Codex
2026-07-03 12:53:34 +08:00
parent 187af844d1
commit d4c8c39253
25 changed files with 1118 additions and 288 deletions
+78
View File
@@ -0,0 +1,78 @@
program test_input_explosive
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_database, only: npart, particle_phase, rho, volume, mass, &
SPH_PHASE_EXPLOSIVE
use sph_gas, only: gas_material_count, gas_material_eos_defined
use sph_explosive_state, only: EXPLOSIVE_CONVERSION_PHASE, &
explosive_material_count, explosive_material_name, &
explosive_control_defined, explosive_product_material_id, &
explosive_density0, explosive_detonation_velocity, &
explosive_energy_per_mass, explosive_burn_time, &
explosive_conversion_mode, explosive_ignition_count, explosive_ignition_x
implicit none
integer :: ierr
integer :: warnings
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed')
call sph_read_inp('tests/data/explosive_section_040.inp', ierr)
call assert_ok(ierr, 'read Explosive input failed')
call sph_build_model(ierr)
call assert_ok(ierr, 'build Explosive input failed')
call sph_get_input_warning_count(warnings, ierr)
call assert_ok(ierr, 'warning count failed')
if (warnings > 1) call fail('unexpected Explosive input warning count')
if (npart /= 4) call fail('Explosive particle count mismatch')
if (any(particle_phase(1:4) /= SPH_PHASE_EXPLOSIVE)) then
call fail('Explosive particle phase mismatch')
end if
if (explosive_material_count /= 1) call fail('Explosive material count mismatch')
if (trim(explosive_material_name(1)) /= 'PBX') call fail('Explosive material name mismatch')
if (.not. explosive_control_defined(1)) call fail('Explosive control missing')
if (explosive_product_material_id(1) /= 2) call fail('Explosive product material mismatch')
if (explosive_conversion_mode(1) /= EXPLOSIVE_CONVERSION_PHASE) then
call fail('Explosive conversion mode mismatch')
end if
call assert_close(explosive_density0(1), 1750.0_rk, 'Explosive density mismatch')
call assert_close(explosive_detonation_velocity(1), 7600.0_rk, 'Explosive D mismatch')
call assert_close(explosive_energy_per_mass(1), 5.0e6_rk, 'Explosive energy mismatch')
call assert_close(explosive_burn_time(1), 5.0e-7_rk, 'Explosive burn mismatch')
if (explosive_ignition_count /= 1) call fail('Explosive ignition count mismatch')
call assert_close(explosive_ignition_x(1,1), 0.0_rk, 'Explosive ignition mismatch')
if (gas_material_count /= 1 .or. .not. gas_material_eos_defined(1)) then
call fail('Explosive product Gas EOS missing')
end if
call assert_close(rho(1), 1750.0_rk, 'Explosive rho initialization mismatch')
call assert_close(volume(1), mass(1) / rho(1), 'Explosive volume mismatch')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed')
contains
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) call fail(message)
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