Add explosive release balance state
This commit is contained in:
@@ -40,6 +40,9 @@ contains
|
||||
explosive_ignition_material_id = 0
|
||||
explosive_ignition_x = 0.0_rk
|
||||
explosive_ignition_time = 0.0_rk
|
||||
explosive_release_mass_balance = 0.0_rk
|
||||
explosive_release_energy_balance = 0.0_rk
|
||||
explosive_release_momentum_balance = 0.0_rk
|
||||
explosive_dt_reaction = 0.0_rk
|
||||
end subroutine sph_explosive_clear_material_table
|
||||
|
||||
@@ -75,6 +78,9 @@ contains
|
||||
allocate(explosive_ignition_status(npart), &
|
||||
explosive_detonation_time(npart), &
|
||||
explosive_reaction_progress(npart), &
|
||||
explosive_initial_material_id(npart), &
|
||||
explosive_initial_mass(npart), &
|
||||
explosive_remaining_mass(npart), &
|
||||
explosive_released_mass(npart), &
|
||||
explosive_released_energy(npart), &
|
||||
explosive_released_momentum(SPH_NDIM,npart), stat=stat)
|
||||
@@ -90,6 +96,9 @@ contains
|
||||
if (allocated(explosive_ignition_status)) deallocate(explosive_ignition_status)
|
||||
if (allocated(explosive_detonation_time)) deallocate(explosive_detonation_time)
|
||||
if (allocated(explosive_reaction_progress)) deallocate(explosive_reaction_progress)
|
||||
if (allocated(explosive_initial_material_id)) deallocate(explosive_initial_material_id)
|
||||
if (allocated(explosive_initial_mass)) deallocate(explosive_initial_mass)
|
||||
if (allocated(explosive_remaining_mass)) deallocate(explosive_remaining_mass)
|
||||
if (allocated(explosive_released_mass)) deallocate(explosive_released_mass)
|
||||
if (allocated(explosive_released_energy)) deallocate(explosive_released_energy)
|
||||
if (allocated(explosive_released_momentum)) deallocate(explosive_released_momentum)
|
||||
@@ -99,9 +108,15 @@ contains
|
||||
if (allocated(explosive_ignition_status)) explosive_ignition_status = 0
|
||||
if (allocated(explosive_detonation_time)) explosive_detonation_time = 0.0_rk
|
||||
if (allocated(explosive_reaction_progress)) explosive_reaction_progress = 0.0_rk
|
||||
if (allocated(explosive_initial_material_id)) explosive_initial_material_id = 0
|
||||
if (allocated(explosive_initial_mass)) explosive_initial_mass = 0.0_rk
|
||||
if (allocated(explosive_remaining_mass)) explosive_remaining_mass = 0.0_rk
|
||||
if (allocated(explosive_released_mass)) explosive_released_mass = 0.0_rk
|
||||
if (allocated(explosive_released_energy)) explosive_released_energy = 0.0_rk
|
||||
if (allocated(explosive_released_momentum)) explosive_released_momentum = 0.0_rk
|
||||
explosive_release_mass_balance = 0.0_rk
|
||||
explosive_release_energy_balance = 0.0_rk
|
||||
explosive_release_momentum_balance = 0.0_rk
|
||||
end subroutine sph_explosive_clear_particle_state
|
||||
|
||||
subroutine sph_explosive_note_material(name, material_type_in)
|
||||
@@ -346,7 +361,11 @@ contains
|
||||
rho(i) = material_density(mat_index)
|
||||
if (mass(i) <= 0.0_rk) mass(i) = 1.0_rk
|
||||
volume(i) = mass(i) / rho(i)
|
||||
explosive_initial_material_id(i) = mat_index
|
||||
explosive_initial_mass(i) = mass(i)
|
||||
explosive_remaining_mass(i) = mass(i)
|
||||
end do
|
||||
call sph_explosive_update_release_balance()
|
||||
end subroutine sph_explosive_apply_initial_conditions
|
||||
|
||||
subroutine sph_explosive_advance(dt, time, ierr)
|
||||
@@ -387,10 +406,12 @@ contains
|
||||
if (lambda_target > 1.0_rk) lambda_target = 1.0_rk
|
||||
delta_lambda = lambda_target - lambda_old
|
||||
if (delta_lambda <= 0.0_rk) cycle
|
||||
release_mass = delta_lambda * mass(i)
|
||||
release_mass = delta_lambda * explosive_initial_mass(i)
|
||||
release_energy = release_mass * explosive_energy_per_mass(explosive_index)
|
||||
release_momentum = release_mass * v(:,i)
|
||||
explosive_reaction_progress(i) = lambda_target
|
||||
explosive_remaining_mass(i) = max(0.0_rk, &
|
||||
explosive_initial_mass(i) * (1.0_rk - lambda_target))
|
||||
explosive_released_mass(i) = explosive_released_mass(i) + release_mass
|
||||
explosive_released_energy(i) = explosive_released_energy(i) + release_energy
|
||||
explosive_released_momentum(:,i) = explosive_released_momentum(:,i) + &
|
||||
@@ -404,6 +425,7 @@ contains
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
end if
|
||||
end do
|
||||
call sph_explosive_update_release_balance()
|
||||
end subroutine sph_explosive_advance
|
||||
|
||||
real(rk) function sph_explosive_reaction_target(index, explosive_index, time)
|
||||
@@ -529,6 +551,7 @@ contains
|
||||
detonation_time_range = 0.0_rk
|
||||
first_value = .true.
|
||||
if (.not. allocated(explosive_reaction_progress)) return
|
||||
call sph_explosive_update_release_balance()
|
||||
do i = 1, npart
|
||||
if (.not. sph_explosive_is_tracked_particle(i)) cycle
|
||||
particle_count = particle_count + 1
|
||||
@@ -562,6 +585,57 @@ contains
|
||||
lambda_range(3) / real(particle_count, rk)
|
||||
end subroutine sph_explosive_get_summary
|
||||
|
||||
subroutine sph_explosive_update_release_balance()
|
||||
integer :: i
|
||||
integer :: explosive_index
|
||||
real(rk) :: expected_energy
|
||||
|
||||
explosive_release_mass_balance = 0.0_rk
|
||||
explosive_release_energy_balance = 0.0_rk
|
||||
explosive_release_momentum_balance = 0.0_rk
|
||||
if (.not. allocated(explosive_initial_mass)) return
|
||||
expected_energy = 0.0_rk
|
||||
do i = 1, npart
|
||||
if (.not. sph_explosive_is_tracked_particle(i)) cycle
|
||||
explosive_release_mass_balance(1) = explosive_release_mass_balance(1) + &
|
||||
explosive_initial_mass(i)
|
||||
explosive_release_mass_balance(2) = explosive_release_mass_balance(2) + &
|
||||
explosive_released_mass(i)
|
||||
explosive_release_mass_balance(3) = explosive_release_mass_balance(3) + &
|
||||
explosive_remaining_mass(i)
|
||||
explosive_release_energy_balance(1) = explosive_release_energy_balance(1) + &
|
||||
explosive_released_energy(i)
|
||||
explosive_release_momentum_balance = explosive_release_momentum_balance + &
|
||||
explosive_released_momentum(:,i)
|
||||
explosive_index = sph_explosive_table_index_by_material_id( &
|
||||
explosive_initial_material_id(i))
|
||||
if (explosive_index > 0) then
|
||||
expected_energy = expected_energy + explosive_released_mass(i) * &
|
||||
explosive_energy_per_mass(explosive_index)
|
||||
else
|
||||
expected_energy = expected_energy + explosive_released_energy(i)
|
||||
end if
|
||||
end do
|
||||
explosive_release_mass_balance(4) = explosive_release_mass_balance(1) - &
|
||||
explosive_release_mass_balance(2) - explosive_release_mass_balance(3)
|
||||
explosive_release_energy_balance(2) = explosive_release_energy_balance(1) - &
|
||||
expected_energy
|
||||
end subroutine sph_explosive_update_release_balance
|
||||
|
||||
subroutine sph_explosive_get_release_balance(mass_values, energy_values, &
|
||||
momentum_values, ierr)
|
||||
real(rk), intent(out) :: mass_values(4)
|
||||
real(rk), intent(out) :: energy_values(2)
|
||||
real(rk), intent(out) :: momentum_values(SPH_NDIM)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call sph_explosive_update_release_balance()
|
||||
mass_values = explosive_release_mass_balance
|
||||
energy_values = explosive_release_energy_balance
|
||||
momentum_values = explosive_release_momentum_balance
|
||||
ierr = SPH_SUCCESS
|
||||
end subroutine sph_explosive_get_release_balance
|
||||
|
||||
subroutine sph_explosive_set_default_ignition_point(ignition_x, &
|
||||
ignition_time, ierr)
|
||||
real(rk), intent(in) :: ignition_x(SPH_NDIM)
|
||||
|
||||
@@ -27,9 +27,15 @@ module sph_explosive_state
|
||||
integer, allocatable :: explosive_ignition_status(:)
|
||||
real(rk), allocatable :: explosive_detonation_time(:)
|
||||
real(rk), allocatable :: explosive_reaction_progress(:)
|
||||
integer, allocatable :: explosive_initial_material_id(:)
|
||||
real(rk), allocatable :: explosive_initial_mass(:)
|
||||
real(rk), allocatable :: explosive_remaining_mass(:)
|
||||
real(rk), allocatable :: explosive_released_mass(:)
|
||||
real(rk), allocatable :: explosive_released_energy(:)
|
||||
real(rk), allocatable :: explosive_released_momentum(:,:)
|
||||
real(rk) :: explosive_release_mass_balance(4) = 0.0_rk
|
||||
real(rk) :: explosive_release_energy_balance(2) = 0.0_rk
|
||||
real(rk) :: explosive_release_momentum_balance(SPH_NDIM) = 0.0_rk
|
||||
real(rk) :: explosive_dt_reaction = 0.0_rk
|
||||
|
||||
end module sph_explosive_state
|
||||
|
||||
Reference in New Issue
Block a user