Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 22, 2022
1 parent c0955c8 commit 12f3f53
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 110 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ SET(FAST_MATH_FILES
${SRC}/symba/symba_module.f90
${SRC}/fraggle/fraggle_module.f90
${SRC}/collision/collision_check.f90
${SRC}/collision/collision_generate.f90
${SRC}/collision/collision_io.f90
${SRC}/collision/collision_model.f90
${SRC}/collision/collision_regime.f90
${SRC}/collision/collision_resolve.f90
${SRC}/collision/collision_setup.f90
Expand Down
2 changes: 1 addition & 1 deletion src/collision/collision_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ module subroutine collision_check_pltp(self, system, param, t, dt, irec, lany_co
write(message, *) "Particle " // trim(adjustl(tp%info(j)%name)) // " (" // trim(adjustl(idstrj)) // ")" &
// " collided with massive body " // trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstri)) // ")" &
// " at t = " // trim(adjustl(timestr))
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, message)
!call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, message)
end if
end do

Expand Down
14 changes: 7 additions & 7 deletions src/collision/collision_resolve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -669,13 +669,13 @@ module subroutine collision_resolve_plpl(self, system, param, t, dt, irec)

do
write(timestr,*) t
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "")
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "***********************************************************" // &
"***********************************************************")
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "Collision between massive bodies detected at time t = " // &
trim(adjustl(timestr)))
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "***********************************************************" // &
"***********************************************************")
! call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "")
! call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "***********************************************************" // &
! "***********************************************************")
! call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "Collision between massive bodies detected at time t = " // &
! trim(adjustl(timestr)))
! call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "***********************************************************" // &
! "***********************************************************")
allocate(tmp_param, source=param)

call collision_resolve_list(plpl_collision, system, param, t)
Expand Down
22 changes: 12 additions & 10 deletions src/fraggle/fraggle_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,22 @@ module subroutine fraggle_set_natural_scale_factors(self)
class(fraggle_system), intent(inout) :: self !! Fraggle collision system object
end subroutine fraggle_set_natural_scale_factors

module function fraggle_resolve_disruption(system, param, t) result(status)
module function fraggle_resolve_disruption(collision_system, nbody_system, param, t) result(status)
implicit none
class(swiftest_nbody_system), intent(inout) :: system !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
integer(I4B) :: status !! Status flag assigned to this outcome
class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object
class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
integer(I4B) :: status !! Status flag assigned to this outcome
end function fraggle_resolve_disruption

module function fraggle_resolve_hitandrun(system, param, t) result(status)
module function fraggle_resolve_hitandrun(collision_system, nbody_system, param, t) result(status)
implicit none
class(swiftest_nbody_system), intent(inout) :: system !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
integer(I4B) :: status !! Status flag assigned to this outcome
class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object
class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
integer(I4B) :: status !! Status flag assigned to this outcome
end function fraggle_resolve_hitandrun

module subroutine fraggle_set_original_scale_factors(self)
Expand Down
165 changes: 74 additions & 91 deletions src/fraggle/fraggle_resolve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
use symba
contains

module function fraggle_resolve_disruption(system, param, t) result(status)
module function fraggle_resolve_disruption(collision_system, nbody_system, param, t) result(status)
!! author: Jennifer L.L. Pouplin, Carlisle A. Wishard, and David A. Minton
!!
!! Create the fragments resulting from a non-catastrophic disruption collision
!!
implicit none
! Arguments
class(swiftest_nbody_system), intent(inout) :: system !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
class(fraggle_system), intent(inout) :: collision_system
class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
! Result
integer(I4B) :: status !! Status flag assigned to this outcome
! Internals
Expand All @@ -30,105 +31,92 @@ module function fraggle_resolve_disruption(system, param, t) result(status)
character(len=STRMAX) :: message
real(DP) :: dpe

select type(system)
class is (swiftest_nbody_system)
select type(param)
class is (swiftest_parameters)
select type(before => system%collision_system%before)
class is (swiftest_nbody_system)
select type(after => system%collision_system%after)
class is (swiftest_nbody_system)

associate(collision_system => system%collision_system, impactors => system%collision_system%impactors, fragments => system%collision_system%fragments)
associate(impactors => collision_system%impactors, fragments => collision_system%fragments, pl => nbody_system%pl)
select case(impactors%regime)
case(COLLRESOLVE_REGIME_DISRUPTION)
message = "Disruption between"
case(COLLRESOLVE_REGIME_SUPERCATASTROPHIC)
message = "Supercatastrophic disruption between"
end select
call collision_resolve_collider_message(nbody_system%pl, impactors%id, message)
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, message)

! Collisional fragments will be uniformly distributed around the pre-impact barycenter
call collision_system%set_mass_dist(param)

! Generate the position and velocity distributions of the fragments
call fraggle_generate_fragments(collision_system, nbody_system, param, lfailure)

dpe = collision_system%pe(2) - collision_system%pe(1)
nbody_system%Ecollisions = nbody_system%Ecollisions - dpe
nbody_system%Euntracked = nbody_system%Euntracked + dpe

if (lfailure) then
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "No fragment solution found, so treat as a pure hit-and-run")
status = ACTIVE
nfrag = 0
pl%status(impactors%id(:)) = status
pl%ldiscard(impactors%id(:)) = .false.
pl%lcollision(impactors%id(:)) = .false.
select type(before => collision_system%before)
class is (swiftest_nbody_system)
select type(after => collision_system%after)
class is (swiftest_nbody_system)
allocate(after%pl, source=before%pl) ! Be sure to save the pl so that snapshots still work
end select
end select
else
! Populate the list of new bodies
nfrag = fragments%nbody
write(message, *) nfrag
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "Generating " // trim(adjustl(message)) // " fragments")
select case(impactors%regime)
case(COLLRESOLVE_REGIME_DISRUPTION)
message = "Disruption between"
status = DISRUPTED
ibiggest = impactors%id(maxloc(pl%Gmass(impactors%id(:)), dim=1))
fragments%id(1) = pl%id(ibiggest)
fragments%id(2:nfrag) = [(i, i = param%maxid + 1, param%maxid + nfrag - 1)]
param%maxid = fragments%id(nfrag)
case(COLLRESOLVE_REGIME_SUPERCATASTROPHIC)
message = "Supercatastrophic disruption between"
status = SUPERCATASTROPHIC
fragments%id(1:nfrag) = [(i, i = param%maxid + 1, param%maxid + nfrag)]
param%maxid = fragments%id(nfrag)
end select
call collision_resolve_collider_message(system%pl, impactors%id, message)
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, message)

! Collisional fragments will be uniformly distributed around the pre-impact barycenter
call collision_system%set_mass_dist(param)

! Generate the position and velocity distributions of the fragments
call fraggle_generate_fragments(collision_system, nbody_system, param, lfailure)

dpe = collision_system%pe(2) - collision_system%pe(1)
system%Ecollisions = system%Ecollisions - dpe
system%Euntracked = system%Euntracked + dpe

if (lfailure) then
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "No fragment solution found, so treat as a pure hit-and-run")
status = ACTIVE
nfrag = 0
select type(pl => system%pl)
class is (swiftest_pl)
pl%status(impactors%id(:)) = status
pl%ldiscard(impactors%id(:)) = .false.
pl%lcollision(impactors%id(:)) = .false.
end select
allocate(after%pl, source=before%pl) ! Be sure to save the pl so that snapshots still work
else
! Populate the list of new bodies
nfrag = fragments%nbody
write(message, *) nfrag
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "Generating " // trim(adjustl(message)) // " fragments")
select case(impactors%regime)
case(COLLRESOLVE_REGIME_DISRUPTION)
status = DISRUPTED
ibiggest = impactors%id(maxloc(system%pl%Gmass(impactors%id(:)), dim=1))
fragments%id(1) = system%pl%id(ibiggest)
fragments%id(2:nfrag) = [(i, i = param%maxid + 1, param%maxid + nfrag - 1)]
param%maxid = fragments%id(nfrag)
case(COLLRESOLVE_REGIME_SUPERCATASTROPHIC)
status = SUPERCATASTROPHIC
fragments%id(1:nfrag) = [(i, i = param%maxid + 1, param%maxid + nfrag)]
param%maxid = fragments%id(nfrag)
end select

call collision_resolve_mergeaddsub(system, param, t, status)
end if
end associate
end select
end select
end select
end select
call collision_resolve_mergeaddsub(nbody_system, param, t, status)
end if
end associate

return
end function fraggle_resolve_disruption


module function fraggle_resolve_hitandrun(system, param, t) result(status)
module function fraggle_resolve_hitandrun(collision_system, nbody_system, param, t) result(status)
!! author: Jennifer L.L. Pouplin, Carlisle A. Wishard, and David A. Minton
!!
!! Create the fragments resulting from a non-catastrophic hit-and-run collision
!!
implicit none
! Arguments
class(swiftest_nbody_system), intent(inout) :: system !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object
class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
! Result
integer(I4B) :: status !! Status flag assigned to this outcom
integer(I4B) :: status !! Status flag assigned to this outcome
! Internals
integer(I4B) :: i, ibiggest, nfrag, jtarg, jproj
logical :: lpure
character(len=STRMAX) :: message
real(DP) :: dpe

select type(system)
select type(before => collision_system%before)
class is (swiftest_nbody_system)
select type(param)
class is (swiftest_parameters)
select type(before => system%collision_system%before)
select type(after => collision_system%after)
class is (swiftest_nbody_system)
select type(after => system%collision_system%after)
class is (swiftest_nbody_system)
associate(collision_system => system%collision_system, impactors => system%collision_system%impactors, fragments => system%collision_system%fragments)
associate(impactors => collision_system%impactors, fragments => collision_system%fragments, pl => nbody_system%pl)
message = "Hit and run between"
call collision_resolve_collider_message(system%pl, impactors%id, message)
call collision_resolve_collider_message(nbody_system%pl, impactors%id, message)
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, trim(adjustl(message)))

if (impactors%mass(1) > impactors%mass(2)) then
Expand All @@ -148,11 +136,11 @@ module function fraggle_resolve_hitandrun(system, param, t) result(status)
call collision_system%set_mass_dist(param)

! Generate the position and velocity distributions of the fragments
call collision_system%generate(system, param, lpure)
call fraggle_generate_fragments(collision_system, nbody_system, param, lpure)

dpe = collision_system%pe(2) - collision_system%pe(1)
system%Ecollisions = system%Ecollisions - dpe
system%Euntracked = system%Euntracked + dpe
nbody_system%Ecollisions = nbody_system%Ecollisions - dpe
nbody_system%Euntracked = nbody_system%Euntracked + dpe

if (lpure) then
call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "Should have been a pure hit and run instead")
Expand All @@ -165,26 +153,21 @@ module function fraggle_resolve_hitandrun(system, param, t) result(status)
end if
if (lpure) then ! Reset these bodies back to being active so that nothing further is done to them
status = HIT_AND_RUN_PURE
select type(pl => system%pl)
class is (symba_pl)
pl%status(impactors%id(:)) = ACTIVE
pl%ldiscard(impactors%id(:)) = .false.
pl%lcollision(impactors%id(:)) = .false.
end select
pl%status(impactors%id(:)) = ACTIVE
pl%ldiscard(impactors%id(:)) = .false.
pl%lcollision(impactors%id(:)) = .false.
allocate(after%pl, source=before%pl) ! Be sure to save the pl so that snapshots still work
else
ibiggest = impactors%id(maxloc(system%pl%Gmass(impactors%id(:)), dim=1))
fragments%id(1) = system%pl%id(ibiggest)
ibiggest = impactors%id(maxloc(pl%Gmass(impactors%id(:)), dim=1))
fragments%id(1) = pl%id(ibiggest)
fragments%id(2:nfrag) = [(i, i = param%maxid + 1, param%maxid + nfrag - 1)]
param%maxid = fragments%id(nfrag)
status = HIT_AND_RUN_DISRUPT
call collision_resolve_mergeaddsub(system, param, t, status)
call collision_resolve_mergeaddsub(nbody_system, param, t, status)
end if
end associate
end select
end select
end select
end select


return
Expand Down

0 comments on commit 12f3f53

Please sign in to comment.