Files
SPHLite/tests/module/test_explosive_water_gas_smoke.f90
T
2026-07-03 13:36:16 +08:00

57 lines
2.1 KiB
Fortran

program test_explosive_water_gas_smoke
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_run_explicit
use sph_database, only: water_mass, water_max_pressure, gas_particle_count, &
gas_volume, gas_max_pressure
use sph_explosive, only: sph_explosive_get_release_balance
implicit none
integer :: ierr
real(rk) :: mass_values(4)
real(rk) :: energy_values(2)
real(rk) :: momentum_values(3)
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed')
call sph_read_inp('tests/data/explosive_water_gas_mixed_041.inp', ierr)
call assert_ok(ierr, 'read mixed smoke failed')
call sph_build_model(ierr)
call assert_ok(ierr, 'build mixed smoke failed')
call sph_run_explicit(ierr)
call assert_ok(ierr, 'run mixed smoke failed')
if (water_mass <= 0.0_rk) call fail('Water summary vanished in mixed smoke')
if (water_max_pressure /= water_max_pressure) call fail('Water pressure is not finite')
if (gas_particle_count <= 0) call fail('Gas particles missing in mixed smoke')
if (gas_volume <= 0.0_rk) call fail('Gas volume mismatch in mixed smoke')
if (gas_max_pressure /= gas_max_pressure) call fail('Gas pressure is not finite')
call sph_explosive_get_release_balance(mass_values, energy_values, &
momentum_values, ierr)
call assert_ok(ierr, 'release balance query failed')
if (mass_values(2) <= 0.0_rk) call fail('Explosive did not release in mixed smoke')
if (mass_values(4) /= mass_values(4) .or. energy_values(2) /= energy_values(2)) then
call fail('release balance is not finite')
end if
momentum_values = momentum_values
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 fail(message)
character(len=*), intent(in) :: message
write(*, '(A)') trim(message)
stop 1
end subroutine fail
end program test_explosive_water_gas_smoke