From c0955c81d6317790ee885d1bbdfff6a4a522c104 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Wed, 21 Dec 2022 19:46:27 -0500 Subject: [PATCH] Cleanup --- src/CMakeLists.txt | 2 +- src/collision/collision_generate.f90 | 43 +++++++++++---------- src/collision/collision_module.f90 | 51 ++++++++++++------------ src/collision/collision_resolve.f90 | 2 +- src/fraggle/fraggle_generate.f90 | 58 ++++++++++++++-------------- src/fraggle/fraggle_module.f90 | 39 ++++++++++--------- src/fraggle/fraggle_resolve.f90 | 13 ++++--- src/fraggle/fraggle_set.f90 | 4 +- src/fraggle/fraggle_util.f90 | 6 +-- src/swiftest/swiftest_module.f90 | 1 - 10 files changed, 111 insertions(+), 108 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cb9f6228..4f7c53667 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,6 @@ SET(FAST_MATH_FILES ${SRC}/misc/minimizer_module.f90 ${SRC}/encounter/encounter_module.f90 ${SRC}/collision/collision_module.f90 - ${SRC}/fraggle/fraggle_module.f90 ${SRC}/operator/operator_module.f90 ${SRC}/walltime/walltime_module.f90 ${SRC}/swiftest/swiftest_module.f90 @@ -39,6 +38,7 @@ SET(FAST_MATH_FILES ${SRC}/rmvs/rmvs_module.f90 ${SRC}/helio/helio_module.f90 ${SRC}/symba/symba_module.f90 + ${SRC}/fraggle/fraggle_module.f90 ${SRC}/collision/collision_check.f90 ${SRC}/collision/collision_io.f90 ${SRC}/collision/collision_model.f90 diff --git a/src/collision/collision_generate.f90 b/src/collision/collision_generate.f90 index 578f3ad58..a849f69dc 100644 --- a/src/collision/collision_generate.f90 +++ b/src/collision/collision_generate.f90 @@ -12,28 +12,29 @@ use swiftest contains - module subroutine collision_generate_merge_system(self, system, param, t) - implicit none - class(collision_merge), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision - end subroutine collision_generate_merge_system - module subroutine collision_generate_bounce_system(self, system, param, t) - implicit none - class(collision_bounce), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision - end subroutine collision_generate_bounce_system + module subroutine collision_generate_merge_system(self, nbody_system, param, t) + implicit none + class(collision_merge), intent(inout) :: self !! Merge fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision + end subroutine collision_generate_merge_system - module subroutine collision_generate_simple_system(self, system, param, t) - implicit none - class(collision_simple), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision - end subroutine collision_generate_simple_system + module subroutine collision_generate_bounce_system(self, nbody_system, param, t) + implicit none + class(collision_bounce), intent(inout) :: self !! Bounce fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision + end subroutine collision_generate_bounce_system + + module subroutine collision_generate_simple_system(self, nbody_system, param, t) + implicit none + class(collision_simple), intent(inout) :: self !! Simple fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision + end subroutine collision_generate_simple_system end submodule s_collision_model \ No newline at end of file diff --git a/src/collision/collision_module.f90 b/src/collision/collision_module.f90 index 408fdfd7b..77c5552fd 100644 --- a/src/collision/collision_module.f90 +++ b/src/collision/collision_module.f90 @@ -124,8 +124,6 @@ module collision real(DP), dimension(2) :: pe !! Before/after potential energy real(DP), dimension(2) :: Etot !! Before/after total system energy contains - procedure(abstract_generate_fragments), deferred :: generate_fragments !! Generates a system of fragments depending on collision model - procedure :: set_mass_dist => abstract_set_mass_dist !! Sets the distribution of mass among the fragments depending on the regime type procedure :: setup => collision_setup_system !! Initializer for the encounter collision system and the before/after snapshots procedure :: setup_impactors => collision_setup_impactors_system !! Initializer for the impactors for the encounter collision system. Deallocates old impactors before creating new ones procedure :: setup_fragments => collision_setup_fragments_system !! Initializer for the fragments of the collision system. @@ -134,23 +132,24 @@ module collision procedure :: get_energy_and_momentum => collision_util_get_energy_momentum !! Calculates total system energy in either the pre-collision outcome state (lbefore = .true.) or the post-collision outcome state (lbefore = .false.) procedure :: reset => collision_util_reset_system !! Deallocates all allocatables procedure :: set_coordinate_system => collision_util_set_coordinate_system !! Sets the coordinate system of the collisional system + procedure(abstract_generate_system), deferred :: generate !! Generates a system of fragments depending on collision model end type collision_system type, extends(collision_system) :: collision_merge contains - procedure :: generate_fragments => collision_generate_merge_system !! Merges the impactors to make a single final body + procedure :: generate => collision_generate_merge_system !! Merges the impactors to make a single final body final :: collision_final_merge_system !! Finalizer will deallocate all allocatables end type collision_merge type, extends(collision_system) :: collision_bounce contains - procedure :: generate_fragments => collision_generate_bounce_system !! If a collision would result in a disruption, "bounce" the bodies instead. + procedure :: generate => collision_generate_bounce_system !! If a collision would result in a disruption, "bounce" the bodies instead. final :: collision_final_bounce_system !! Finalizer will deallocate all allocatables end type collision_bounce type, extends(collision_system) :: collision_simple contains - procedure :: generate_fragments => collision_generate_simple_system !! If a collision would result in a disruption [TODO: SOMETHING LIKE CHAMBERS 2012] + procedure :: generate => collision_generate_simple_system !! If a collision would result in a disruption [TODO: SOMETHING LIKE CHAMBERS 2012] final :: collision_final_simple_system !! Finalizer will deallocate all allocatables end type collision_simple @@ -198,14 +197,14 @@ module collision abstract interface - subroutine abstract_generate_fragments(self, system, param, t) + subroutine abstract_generate_system(self, nbody_system, param, t) import collision_system, base_nbody_system, base_parameters, DP implicit none - class(collision_system), intent(inout) :: self !! Collision system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision - end subroutine abstract_generate_fragments + class(collision_system), intent(inout) :: self !! Collision system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision + end subroutine abstract_generate_system subroutine abstract_set_mass_dist(self, param) import collision_system, base_parameters @@ -218,28 +217,28 @@ end subroutine abstract_set_mass_dist interface - module subroutine collision_generate_merge_system(self, system, param, t) + module subroutine collision_generate_merge_system(self, nbody_system, param, t) implicit none - class(collision_merge), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision + class(collision_merge), intent(inout) :: self !! Merge fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision end subroutine collision_generate_merge_system - module subroutine collision_generate_bounce_system(self, system, param, t) + module subroutine collision_generate_bounce_system(self, nbody_system, param, t) implicit none - class(collision_bounce), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision + class(collision_bounce), intent(inout) :: self !! Bounce fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision end subroutine collision_generate_bounce_system - module subroutine collision_generate_simple_system(self, system, param, t) + module subroutine collision_generate_simple_system(self, nbody_system, param, t) implicit none - class(collision_simple), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! The time of the collision + class(collision_simple), intent(inout) :: self !! Simple fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! The time of the collision end subroutine collision_generate_simple_system module subroutine collision_netcdf_io_dump(self, param) diff --git a/src/collision/collision_resolve.f90 b/src/collision/collision_resolve.f90 index 0edde0e3e..51789cc10 100644 --- a/src/collision/collision_resolve.f90 +++ b/src/collision/collision_resolve.f90 @@ -619,7 +619,7 @@ subroutine collision_resolve_list(plpl_collision , system, param, t) call impactors%get_regime(system, param) call collision_history%take_snapshot(param,system, t, "before") - call collision_system%generate_fragments(system, param, t) + call collision_system%generate(system, param, t) call collision_history%take_snapshot(param,system, t, "after") call impactors%reset() diff --git a/src/fraggle/fraggle_generate.f90 b/src/fraggle/fraggle_generate.f90 index 16f93b652..5cad2a3a9 100644 --- a/src/fraggle/fraggle_generate.f90 +++ b/src/fraggle/fraggle_generate.f90 @@ -18,27 +18,27 @@ contains - module subroutine fraggle_generate_system(self, system, param, t) + module subroutine fraggle_generate_system(self, nbody_system, param, t) implicit none - class(fraggle_system), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object + class(fraggle_system), intent(inout) :: self !! Fraggle fragment nbody_system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody nbody_system object class(base_parameters), intent(inout) :: param !! Current run configuration parameters real(DP), intent(in) :: t !! The time of the collision ! Internals integer(I4B) :: i - select type(system) + select type(nbody_system) class is (swiftest_nbody_system) select type(param) class is (swiftest_parameters) - associate(impactors => self%impactors, plpl_collision => system%plpl_collision) + associate(impactors => self%impactors, plpl_collision => nbody_system%plpl_collision) select case (impactors%regime) case (COLLRESOLVE_REGIME_DISRUPTION, COLLRESOLVE_REGIME_SUPERCATASTROPHIC) - plpl_collision%status(i) = fraggle_resolve_disruption(system, param, t) + plpl_collision%status(i) = fraggle_resolve_disruption(nbody_system, param, t) case (COLLRESOLVE_REGIME_HIT_AND_RUN) - plpl_collision%status(i) = fraggle_resolve_hitandrun(system, param, t) + plpl_collision%status(i) = fraggle_resolve_hitandrun(nbody_system, param, t) case (COLLRESOLVE_REGIME_MERGE, COLLRESOLVE_REGIME_GRAZE_AND_MERGE) - plpl_collision%status(i) = collision_resolve_merge(system, param, t) + plpl_collision%status(i) = collision_resolve_merge(nbody_system, param, t) case default write(*,*) "Error in swiftest_collision, unrecognized collision regime" call util_exit(FAILURE) @@ -50,17 +50,17 @@ module subroutine fraggle_generate_system(self, system, param, t) end subroutine fraggle_generate_system - subroutine fraggle_generate_fragments(self, system, param, lfailure) + module subroutine fraggle_generate_fragments(collision_system, nbody_system, param, lfailure) !! Author: Jennifer L.L. Pouplin, Carlisle A. Wishard, and David A. Minton !! - !! Generates a system of fragments in barycentric coordinates that conserves energy and momentum. + !! Generates a nbody_system of fragments in barycentric coordinates that conserves energy and momentum. use, intrinsic :: ieee_exceptions implicit none ! Arguments - class(fraggle_system), intent(inout) :: self !! Fraggle system object the outputs will be the fragmentation - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - logical, intent(out) :: lfailure !! Answers the question: Should this have been a merger instead? + class(fraggle_system), intent(inout) :: collision_system !! Fraggle nbody_system object the outputs will be the fragmentation + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody nbody_system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + logical, intent(out) :: lfailure !! Answers the question: Should this have been a merger instead? ! Internals integer(I4B) :: i integer(I4B) :: try @@ -78,13 +78,13 @@ subroutine fraggle_generate_fragments(self, system, param, lfailure) fpe_quiet_modes(:) = .false. call ieee_set_halting_mode(IEEE_ALL,fpe_quiet_modes) - select type(system) + select type(nbody_system) class is (swiftest_nbody_system) select type(param) class is (swiftest_parameters) - select type(fragments => self%fragments) + select type(fragments => collision_system%fragments) class is (fraggle_fragments(*)) - associate(collision_system => self, impactors => self%impactors, nfrag => fragments%nbody, pl => system%pl) + associate(impactors => collision_system%impactors, nfrag => fragments%nbody, pl => nbody_system%pl) write(message,*) nfrag call swiftest_io_log_one_message(FRAGGLE_LOG_OUT, "Fraggle generating " // trim(adjustl(message)) // " fragments.") @@ -110,8 +110,8 @@ subroutine fraggle_generate_fragments(self, system, param, lfailure) call fragments%reset() - ! Calculate the initial energy of the system without the collisional family - call collision_system%get_energy_and_momentum(system, param, lbefore=.true.) + ! Calculate the initial energy of the nbody_system without the collisional family + call collision_system%get_energy_and_momentum(nbody_system, param, lbefore=.true.) ! Start out the fragments close to the initial separation distance. This will be increased if there is any overlap or we fail to find a solution r_max_start = 1.2_DP * .mag.(impactors%rb(:,2) - impactors%rb(:,1)) @@ -132,12 +132,12 @@ subroutine fraggle_generate_fragments(self, system, param, lfailure) call fraggle_generate_pos_vec(collision_system, r_max_start) call collision_system%set_coordinate_system() - ! Initial velocity guess will be the barycentric velocity of the colliding system so that the budgets are based on the much smaller collisional-frame velocities + ! Initial velocity guess will be the barycentric velocity of the colliding nbody_system so that the budgets are based on the much smaller collisional-frame velocities do concurrent (i = 1:nfrag) fragments%vb(:, i) = impactors%vbcom(:) end do - call collision_system%get_energy_and_momentum(system, param, lbefore=.false.) + call collision_system%get_energy_and_momentum(nbody_system, param, lbefore=.false.) call collision_system%set_budgets() call fraggle_generate_spins(collision_system, f_spin, lfailure) @@ -158,7 +158,7 @@ subroutine fraggle_generate_fragments(self, system, param, lfailure) cycle end if - call collision_system%get_energy_and_momentum(system, param, lbefore=.false.) + call collision_system%get_energy_and_momentum(nbody_system, param, lbefore=.false.) dEtot = collision_system%Etot(2) - collision_system%Etot(1) dLmag = .mag. (collision_system%Ltot(:,2) - collision_system%Ltot(:,1)) exit @@ -218,7 +218,7 @@ subroutine fraggle_generate_pos_vec(collision_system, r_max_start) !! The initial positions do not conserve energy or momentum, so these need to be adjusted later. implicit none ! Arguments - class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object + class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision nbody_system object real(DP), intent(in) :: r_max_start !! Initial guess for the starting maximum radial distance of fragments ! Internals real(DP) :: dis, rad, r_max, fdistort @@ -301,7 +301,7 @@ subroutine fraggle_generate_spins(collision_system, f_spin, lfailure) !! A failure will trigger a restructuring of the fragments so we will try new values of the radial position distribution. implicit none ! Arguments - class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object + class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision nbody_system object real(DP), intent(in) :: f_spin !! Fraction of energy or momentum that goes into spin (whichever gives the lowest kinetic energy) logical, intent(out) :: lfailure !! Logical flag indicating whether this step fails or succeeds! ! Internals @@ -398,7 +398,7 @@ subroutine fraggle_generate_tan_vel(collision_system, lfailure) !! A failure will trigger a restructuring of the fragments so we will try new values of the radial position distribution. implicit none ! Arguments - class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object + class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision nbody_system object logical, intent(out) :: lfailure !! Logical flag indicating whether this step fails or succeeds ! Internals integer(I4B) :: i, try @@ -428,7 +428,7 @@ subroutine fraggle_generate_tan_vel(collision_system, lfailure) end do fragments%v_t_mag(:) = v_t_initial - ! Find the local kinetic energy minimum for the system that conserves linear and angular momentum + ! Find the local kinetic energy minimum for the nbody_system that conserves linear and angular momentum objective_function = lambda_obj(tangential_objective_function, lfailure) tol = TOL_INIT @@ -445,7 +445,7 @@ subroutine fraggle_generate_tan_vel(collision_system, lfailure) end do fragments%v_t_mag(1:nfrag) = solve_fragment_tan_vel(v_t_mag_input=v_t_initial(7:nfrag), lfailure=lfailure) - ! Perform one final shift of the radial velocity vectors to align with the center of mass of the collisional system (the origin) + ! Perform one final shift of the radial velocity vectors to align with the center of mass of the collisional nbody_system (the origin) fragments%vb(:,1:nfrag) = fraggle_util_vmag_to_vb(fragments%v_r_mag(1:nfrag), fragments%v_r_unit(:,1:nfrag), fragments%v_t_mag(1:nfrag), & fragments%v_t_unit(:,1:nfrag), fragments%mass(1:nfrag), impactors%vbcom(:)) do concurrent (i = 1:nfrag) @@ -582,7 +582,7 @@ subroutine fraggle_generate_rad_vel(collision_system, lfailure) !! Adjust the fragment velocities to set the fragment orbital kinetic energy. This will minimize the difference between the fragment kinetic energy and the energy budget implicit none ! Arguments - class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision system object + class(fraggle_system), intent(inout) :: collision_system !! Fraggle collision nbody_system object logical, intent(out) :: lfailure !! Logical flag indicating whether this step fails or succeeds! ! Internals real(DP), parameter :: TOL_MIN = FRAGGLE_ETOL ! This needs to be more accurate than the tangential step, as we are trying to minimize the total residual energy @@ -626,7 +626,7 @@ subroutine fraggle_generate_rad_vel(collision_system, lfailure) v_r_initial(:) = v_r_initial(:) * vnoise(:) end do - ! Shift the radial velocity vectors to align with the center of mass of the collisional system (the origin) + ! Shift the radial velocity vectors to align with the center of mass of the collisional nbody_system (the origin) fragments%ke_orbit = 0.0_DP fragments%ke_spin = 0.0_DP fragments%vb(:,1:nfrag) = fraggle_util_vmag_to_vb(fragments%v_r_mag(1:nfrag), fragments%v_r_unit(:,1:nfrag), & diff --git a/src/fraggle/fraggle_module.f90 b/src/fraggle/fraggle_module.f90 index df4f402cf..da9dcaf6d 100644 --- a/src/fraggle/fraggle_module.f90 +++ b/src/fraggle/fraggle_module.f90 @@ -11,10 +11,7 @@ module fraggle !! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott !! !! Definition of classes and methods specific to Fraggle: *Fragment* *g*eneration that conserves angular momentum (*L*) and energy (*E*) - use globals - use base - use encounter - use collision + use swiftest implicit none public @@ -51,7 +48,7 @@ module fraggle real(DP) :: Escale = 1.0_DP !! Energy scale factor (a convenience unit that is derived from dscale, tscale, and mscale) real(DP) :: Lscale = 1.0_DP !! Angular momentum scale factor (a convenience unit that is derived from dscale, tscale, and mscale) contains - procedure :: generate_fragments => fraggle_generate_system !! Generates a system of fragments in barycentric coordinates that conserves energy and momentum. + procedure :: generate => fraggle_generate_system !! Generates a system of fragments in barycentric coordinates that conserves energy and momentum. procedure :: set_budgets => fraggle_set_budgets !! Sets the energy and momentum budgets of the fragments based on the collider value procedure :: set_mass_dist => fraggle_set_mass_dist !! Sets the distribution of mass among the fragments depending on the regime type procedure :: set_natural_scale => fraggle_set_natural_scale_factors !! Scales dimenional quantities to ~O(1) with respect to the collisional system. @@ -65,12 +62,20 @@ module fraggle interface - module subroutine fraggle_generate_system(self, system, param, t) + module subroutine fraggle_generate_fragments(collision_system, nbody_system, param, lfailure) implicit none - class(fraggle_system), intent(inout) :: self !! Fraggle fragment system object - class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! Time of collision + class(fraggle_system), intent(inout) :: collision_system !! Fraggle system object the outputs will be the fragmentation + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + logical, intent(out) :: lfailure !! Answers the question: Should this have been a merger instead? + end subroutine fraggle_generate_fragments + + module subroutine fraggle_generate_system(self, nbody_system, param, t) + implicit none + class(fraggle_system), intent(inout) :: self !! Fraggle fragment system object + class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + class(base_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Time of collision end subroutine fraggle_generate_system module subroutine fraggle_io_log_regime(collision_system) @@ -86,7 +91,7 @@ end subroutine fraggle_set_budgets module subroutine fraggle_set_mass_dist(self, param) implicit none class(fraggle_system), intent(inout) :: self !! Fraggle collision system object - class(base_parameters), intent(in) :: param !! Current Swiftest run configuration parameters + class(swiftest_parameters), intent(in) :: param !! Current Swiftest run configuration parameters end subroutine fraggle_set_mass_dist module subroutine fraggle_set_natural_scale_factors(self) @@ -96,16 +101,16 @@ end subroutine fraggle_set_natural_scale_factors module function fraggle_resolve_disruption(system, param, t) result(status) implicit none - class(base_nbody_system), intent(inout) :: system !! SyMBA nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions + 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 end function fraggle_resolve_disruption module function fraggle_resolve_hitandrun(system, param, t) result(status) implicit none - class(base_nbody_system), intent(inout) :: system !! SyMBA nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions + 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 end function fraggle_resolve_hitandrun @@ -127,9 +132,8 @@ module subroutine fraggle_util_get_angular_momentum(self) end subroutine fraggle_util_get_angular_momentum module subroutine fraggle_util_construct_temporary_system(self, nbody_system, param, tmpsys, tmpparam) - use base, only : base_nbody_system, base_parameters implicit none - class(fraggle_system), intent(inout) :: self !! Fraggle collision system object + class(fraggle_system), intent(inout) :: self !! Fraggle collision system object class(base_nbody_system), intent(in) :: nbody_system !! Original swiftest nbody system object class(base_parameters), intent(in) :: param !! Current swiftest run configuration parameters class(base_nbody_system), allocatable, intent(out) :: tmpsys !! Output temporary swiftest nbody system object @@ -178,7 +182,6 @@ end function fraggle_util_vmag_to_vb end interface contains - subroutine fraggle_final_fragments(self) diff --git a/src/fraggle/fraggle_resolve.f90 b/src/fraggle/fraggle_resolve.f90 index e2cb6677b..0bf3017a6 100644 --- a/src/fraggle/fraggle_resolve.f90 +++ b/src/fraggle/fraggle_resolve.f90 @@ -19,8 +19,8 @@ module function fraggle_resolve_disruption(system, param, t) result(status) !! implicit none ! Arguments - class(base_nbody_system), intent(inout) :: system !! SyMBA nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions + 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 ! Result integer(I4B) :: status !! Status flag assigned to this outcome @@ -38,6 +38,7 @@ module function fraggle_resolve_disruption(system, param, t) result(status) 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) select case(impactors%regime) case(COLLRESOLVE_REGIME_DISRUPTION) @@ -52,7 +53,7 @@ module function fraggle_resolve_disruption(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_fragments(system, param, lfailure) + call fraggle_generate_fragments(collision_system, nbody_system, param, lfailure) dpe = collision_system%pe(2) - collision_system%pe(1) system%Ecollisions = system%Ecollisions - dpe @@ -106,8 +107,8 @@ module function fraggle_resolve_hitandrun(system, param, t) result(status) !! implicit none ! Arguments - class(base_nbody_system), intent(inout) :: system !! SyMBA nbody system object - class(base_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions + 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 ! Result integer(I4B) :: status !! Status flag assigned to this outcom @@ -147,7 +148,7 @@ 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_fragments(system, param, lpure) + call collision_system%generate(system, param, lpure) dpe = collision_system%pe(2) - collision_system%pe(1) system%Ecollisions = system%Ecollisions - dpe diff --git a/src/fraggle/fraggle_set.f90 b/src/fraggle/fraggle_set.f90 index 42c7e4500..d466db871 100644 --- a/src/fraggle/fraggle_set.f90 +++ b/src/fraggle/fraggle_set.f90 @@ -49,7 +49,7 @@ module subroutine fraggle_set_mass_dist(self, param) implicit none ! Arguments class(fraggle_system), intent(inout) :: self !! Fraggle collision system object - class(base_parameters), intent(in) :: param !! Current Swiftest run configuration parameters + class(swiftest_parameters), intent(in) :: param !! Current Swiftest run configuration parameters ! Internals integer(I4B) :: i, jproj, jtarg, nfrag, istart real(DP), dimension(2) :: volume @@ -85,7 +85,7 @@ module subroutine fraggle_set_mass_dist(self, param) ! Check to see if our size distribution would give us a smaller number of fragments than the maximum number select type(param) - class is (base_parameters) + class is (swiftest_parameters) min_mfrag = (param%min_GMfrag / param%GU) ! The number of fragments we generate is bracked by the minimum required by fraggle_generate (7) and the ! maximum set by the NFRAG_SIZE_MULTIPLIER which limits the total number of fragments to prevent the nbody diff --git a/src/fraggle/fraggle_util.f90 b/src/fraggle/fraggle_util.f90 index e0303f996..b8f6ef57d 100644 --- a/src/fraggle/fraggle_util.f90 +++ b/src/fraggle/fraggle_util.f90 @@ -42,13 +42,13 @@ module subroutine fraggle_util_construct_temporary_system(self, nbody_system, pa !! Constructs a temporary internal system consisting of active bodies and additional fragments. This internal temporary system is used to calculate system energy with and without fragments implicit none ! Arguments - class(fraggle_system), intent(inout) :: self !! Fraggle collision system object + class(fraggle_system), intent(inout) :: self !! Fraggle collision system object class(base_nbody_system), intent(in) :: nbody_system !! Original swiftest nbody system object class(base_parameters), intent(in) :: param !! Current swiftest run configuration parameters class(base_nbody_system), allocatable, intent(out) :: tmpsys !! Output temporary swiftest nbody system object class(base_parameters), allocatable, intent(out) :: tmpparam !! Output temporary configuration run parameters - call self%collision_system%construct_temporary_system(nbody_system, param, tmpsys, tmpparam) + call collision_util_construct_temporary_system(self, nbody_system, param, tmpsys, tmpparam) select type(tmpsys) class is (swiftest_nbody_system) @@ -106,7 +106,7 @@ module subroutine fraggle_util_reset_system(self) self%Escale = 1.0_DP self%Lscale = 1.0_DP - call self%collision_system%reset() + call collision_util_reset_system(self) return end subroutine fraggle_util_reset_system diff --git a/src/swiftest/swiftest_module.f90 b/src/swiftest/swiftest_module.f90 index ff58cf9ac..34ddefcdb 100644 --- a/src/swiftest/swiftest_module.f90 +++ b/src/swiftest/swiftest_module.f90 @@ -39,7 +39,6 @@ module swiftest use base use encounter use collision - use fraggle use walltime use io_progress_bar use netcdf_io