67 lines
2.9 KiB
Fortran
67 lines
2.9 KiB
Fortran
program test_gas_state
|
|
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_database, only: particle_phase, rho, pressure, internal_energy, &
|
|
temperature, mass, volume, h, SPH_PHASE_WATER, SPH_PHASE_GAS
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call check_gas_initial_state()
|
|
call check_mixed_state_isolation()
|
|
|
|
contains
|
|
|
|
subroutine check_gas_initial_state()
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for Gas state')
|
|
call sph_read_inp('tests/data/gas_ideal_minimal_030.inp', ierr)
|
|
call assert_ok(ierr, 'Gas state input read failed')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'Gas state build failed')
|
|
if (particle_phase(1) /= SPH_PHASE_GAS) call fail('Gas phase was not initialized')
|
|
if (abs(rho(1) - 1.2_rk) > 1.0e-12_rk) call fail('Gas rho mismatch')
|
|
if (abs(pressure(1) - 0.96_rk) > 1.0e-12_rk) call fail('Gas pressure mismatch')
|
|
if (abs(internal_energy(1) - 2.0_rk) > 1.0e-12_rk) call fail('Gas internal energy mismatch')
|
|
if (abs(temperature(1) - 293.15_rk) > 1.0e-12_rk) call fail('Gas temperature mismatch')
|
|
if (abs(mass(1) - 0.01_rk) > 1.0e-12_rk) call fail('Gas mass mismatch')
|
|
if (abs(volume(1) - 0.008_rk) > 1.0e-12_rk) call fail('Gas volume mismatch')
|
|
if (abs(h(1) - 0.15_rk) > 1.0e-12_rk) call fail('Gas h mismatch')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for Gas state')
|
|
end subroutine check_gas_initial_state
|
|
|
|
subroutine check_mixed_state_isolation()
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for mixed state')
|
|
call sph_read_inp('tests/data/water_gas_mixed_030.inp', ierr)
|
|
call assert_ok(ierr, 'mixed state input read failed')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'mixed state build failed')
|
|
if (particle_phase(1) /= SPH_PHASE_WATER) call fail('mixed Water phase mismatch')
|
|
if (particle_phase(3) /= SPH_PHASE_GAS) call fail('mixed Gas phase mismatch')
|
|
if (abs(rho(1) - 1000.0_rk) > 1.0e-12_rk) call fail('Water rho was overwritten')
|
|
if (abs(pressure(1)) > 1.0e-12_rk) call fail('Water pressure was overwritten')
|
|
if (abs(rho(3) - 1.2_rk) > 1.0e-12_rk) call fail('Gas rho in mixed input mismatch')
|
|
if (abs(pressure(3) - 0.96_rk) > 1.0e-12_rk) call fail('Gas pressure in mixed input mismatch')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for mixed state')
|
|
end subroutine check_mixed_state_isolation
|
|
|
|
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_gas_state
|