program test_explosive_release_source 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_advance_explicit use sph_database, only: mass, particle_phase, SPH_PHASE_EXPLOSIVE use sph_gas, only: sph_gas_get_source_summary use sph_explosive_state, only: explosive_released_mass, explosive_released_energy implicit none integer :: ierr real(rk) :: gas_mass_before real(rk) :: source_mass real(rk) :: source_energy real(rk) :: source_momentum(3) call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed') call sph_read_inp('tests/data/explosive_conversion_source_040.inp', ierr) call assert_ok(ierr, 'read source conversion failed') call sph_build_model(ierr) call assert_ok(ierr, 'build source conversion failed') gas_mass_before = mass(4) call sph_advance_explicit(1.0e-7_rk, ierr) call assert_ok(ierr, 'source conversion advance failed') if (particle_phase(1) /= SPH_PHASE_EXPLOSIVE) call fail('SOURCE conversion changed phase') if (explosive_released_mass(1) <= 0.0_rk) call fail('Explosive source mass not released') if (explosive_released_energy(1) <= 0.0_rk) call fail('Explosive source energy not released') call sph_gas_get_source_summary(source_mass, source_momentum, source_energy, ierr) call assert_ok(ierr, 'Gas source summary failed') if (source_mass <= 0.0_rk .or. source_energy <= 0.0_rk) then call fail('Explosive source was not injected into Gas') end if if (mass(4) <= gas_mass_before) call fail('Gas mass did not receive source update') 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_release_source