diff --git a/src/io/io.f90 b/src/io/io.f90 index 2b0ba4468..1bc9a63bb 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -136,6 +136,7 @@ module subroutine io_dump_particle_info(self, iu) write(iu, err = 667, iomsg = errmsg) self%particle_type write(iu, err = 667, iomsg = errmsg) self%origin_type write(iu, err = 667, iomsg = errmsg) self%origin_time + write(iu, err = 667, iomsg = errmsg) self%collision_id write(iu, err = 667, iomsg = errmsg) self%origin_xh(:) write(iu, err = 667, iomsg = errmsg) self%origin_vh(:) @@ -1725,6 +1726,7 @@ module subroutine io_read_in_particle_info(self, iu) read(iu, err = 667, iomsg = errmsg) self%particle_type read(iu, err = 667, iomsg = errmsg) self%origin_type read(iu, err = 667, iomsg = errmsg) self%origin_time + read(iu, err = 667, iomsg = errmsg) self%collision_id read(iu, err = 667, iomsg = errmsg) self%origin_xh(:) read(iu, err = 667, iomsg = errmsg) self%origin_vh(:) diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 6ffd3b2da..bc73837af 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -61,6 +61,7 @@ module swiftest_classes integer(I4B) :: status_varid !! NetCDF ID for the status variable integer(I4B) :: origin_type_varid !! NetCDF ID for the origin type integer(I4B) :: origin_time_varid !! NetCDF ID for the origin time + integer(I4B) :: collision_id_varid !! Netcdf ID for the origin collision ID integer(I4B) :: origin_xhx_varid !! NetCDF ID for the origin xh x component integer(I4B) :: origin_xhy_varid !! NetCDF ID for the origin xh y component integer(I4B) :: origin_xhz_varid !! NetCDF ID for the origin xh z component @@ -178,6 +179,7 @@ module swiftest_classes character(len=NAMELEN) :: particle_type !! String containing a description of the particle type (e.g. Central Body, Massive Body, Test Particle) character(len=NAMELEN) :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) real(DP) :: origin_time !! The time of the particle's formation + integer(I4B) :: collision_id !! The ID of the collision that formed the particle real(DP), dimension(NDIM) :: origin_xh !! The heliocentric distance vector at the time of the particle's formation real(DP), dimension(NDIM) :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation real(DP) :: discard_time !! The time of the particle's discard @@ -1643,7 +1645,7 @@ module subroutine util_set_mu_tp(self, cb) class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine util_set_mu_tp - module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, origin_xh, origin_vh, discard_time, discard_xh, discard_vh, discard_body_id) + module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, origin_xh, origin_vh, discard_time, discard_xh, discard_vh, discard_body_id) implicit none class(swiftest_particle_info), intent(inout) :: self character(len=*), intent(in), optional :: name !! Non-unique name @@ -1651,6 +1653,7 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig character(len=*), intent(in), optional :: status !! Particle status description: Active, Merged, Fragmented, etc. character(len=*), intent(in), optional :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) real(DP), intent(in), optional :: origin_time !! The time of the particle's formation + integer(I4B), intent(in), optional :: collision_id !! The ID fo the collision that formed the particle real(DP), dimension(:), intent(in), optional :: origin_xh !! The heliocentric distance vector at the time of the particle's formation real(DP), dimension(:), intent(in), optional :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation real(DP), intent(in), optional :: discard_time !! The time of the particle's discard diff --git a/src/modules/swiftest_globals.f90 b/src/modules/swiftest_globals.f90 index 37a1b3a2b..b530d08a0 100644 --- a/src/modules/swiftest_globals.f90 +++ b/src/modules/swiftest_globals.f90 @@ -185,6 +185,7 @@ module swiftest_globals character(*), parameter :: STATUS_VARNAME = "status" !! NetCDF name of the current status of the body variable (includes discard type) character(*), parameter :: ORIGIN_TYPE_VARNAME = "origin_type" !! NetCDF name of the origin type variable (Initial Conditions, Disruption, etc.) character(*), parameter :: ORIGIN_TIME_VARNAME = "origin_time" !! NetCDF name of the time of origin variable + character(*), parameter :: COLLISION_ID_VARNAME = "collision_id" !! NetCDF name of the collision id variable character(*), parameter :: ORIGIN_XHX_VARNAME = "origin_xhx" !! NetCDF name of the heliocentric position of the body at the time of origin x variable character(*), parameter :: ORIGIN_XHY_VARNAME = "origin_xhy" !! NetCDF name of the heliocentric position of the body at the time of origin y variable character(*), parameter :: ORIGIN_XHZ_VARNAME = "origin_xhz" !! NetCDF name of the heliocentric position of the body at the time of origin z variable diff --git a/src/netcdf/netcdf.f90 b/src/netcdf/netcdf.f90 index f36f370f4..b3ad67b16 100644 --- a/src/netcdf/netcdf.f90 +++ b/src/netcdf/netcdf.f90 @@ -164,7 +164,8 @@ module subroutine netcdf_initialize_output(self, param) call check( nf90_def_var(self%ncid, STATUS_VARNAME, NF90_CHAR, [self%str_dimid, self%id_dimid], self%status_varid) ) call check( nf90_def_var(self%ncid, ORIGIN_TYPE_VARNAME, NF90_CHAR, [self%str_dimid, self%id_dimid], self%origin_type_varid) ) - call check( nf90_def_var(self%ncid, ORIGIN_TIME_VARNAME, self%out_type, self%id_dimid, self%origin_time_varid) ) + call check( nf90_def_var(self%ncid, ORIGIN_TIME_VARNAME, self%out_type, self%id_dimid, self%collision_id_varid) ) + call check( nf90_def_var(self%ncid, COLLISION_ID_VARNAME, self%out_type, self%id_dimid, self%origin_time_varid) ) call check( nf90_def_var(self%ncid, ORIGIN_XHX_VARNAME, self%out_type, self%id_dimid, self%origin_xhx_varid) ) call check( nf90_def_var(self%ncid, ORIGIN_XHY_VARNAME, self%out_type, self%id_dimid, self%origin_xhy_varid) ) call check( nf90_def_var(self%ncid, ORIGIN_XHZ_VARNAME, self%out_type, self%id_dimid, self%origin_xhz_varid) ) @@ -280,6 +281,7 @@ module subroutine netcdf_open(self, param) call check( nf90_inq_varid(self%ncid, STATUS_VARNAME, self%status_varid)) call check( nf90_inq_varid(self%ncid, ORIGIN_TYPE_VARNAME, self%origin_type_varid)) call check( nf90_inq_varid(self%ncid, ORIGIN_TIME_VARNAME, self%origin_time_varid)) + call check( nf90_inq_varid(self%ncid, COLLISION_ID_VARNAME, self%collision_id_varid)) call check( nf90_inq_varid(self%ncid, ORIGIN_XHX_VARNAME, self%origin_xhx_varid)) call check( nf90_inq_varid(self%ncid, ORIGIN_XHY_VARNAME, self%origin_xhy_varid)) call check( nf90_inq_varid(self%ncid, ORIGIN_XHZ_VARNAME, self%origin_xhz_varid)) @@ -561,13 +563,14 @@ module subroutine netcdf_read_particle_info_base(self, iu, ind) strlen = len(trim(adjustl(self%info(i)%origin_type))) call check( nf90_get_var(iu%ncid, iu%origin_type_varid, self%info(i)%origin_type, start=[1, idslot], count=[strlen, 1]) ) - call check( nf90_get_var(iu%ncid, iu%origin_time_varid, self%info(i)%origin_time, start=[idslot]) ) - call check( nf90_get_var(iu%ncid, iu%origin_xhx_varid, self%info(i)%origin_xh(1), start=[idslot]) ) - call check( nf90_get_var(iu%ncid, iu%origin_xhy_varid, self%info(i)%origin_xh(2), start=[idslot]) ) - call check( nf90_get_var(iu%ncid, iu%origin_xhz_varid, self%info(i)%origin_xh(3), start=[idslot]) ) - call check( nf90_get_var(iu%ncid, iu%origin_vhx_varid, self%info(i)%origin_vh(1), start=[idslot]) ) - call check( nf90_get_var(iu%ncid, iu%origin_vhy_varid, self%info(i)%origin_vh(2), start=[idslot]) ) - call check( nf90_get_var(iu%ncid, iu%origin_vhz_varid, self%info(i)%origin_vh(3), start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%collision_id_varid, self%info(i)%collision_id, start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_time_varid, self%info(i)%origin_time, start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_xhx_varid, self%info(i)%origin_xh(1), start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_xhy_varid, self%info(i)%origin_xh(2), start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_xhz_varid, self%info(i)%origin_xh(3), start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_vhx_varid, self%info(i)%origin_vh(1), start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_vhy_varid, self%info(i)%origin_vh(2), start=[idslot]) ) + call check( nf90_get_var(iu%ncid, iu%origin_vhz_varid, self%info(i)%origin_vh(3), start=[idslot]) ) call check( nf90_get_var(iu%ncid, iu%discard_time_varid, self%info(i)%discard_time, start=[idslot]) ) call check( nf90_get_var(iu%ncid, iu%discard_xhx_varid, self%info(i)%discard_xh(1), start=[idslot]) ) @@ -805,13 +808,14 @@ module subroutine netcdf_write_particle_info_base(self, iu) call check( nf90_put_var(iu%ncid, iu%origin_type_varid, emptystr, start=[1, idslot], count=[NAMELEN, 1]) ) call check( nf90_put_var(iu%ncid, iu%origin_type_varid, charstring, start=[1, idslot], count=[strlen, 1]) ) - call check( nf90_put_var(iu%ncid, iu%origin_time_varid, self%info(j)%origin_time, start=[idslot]) ) - call check( nf90_put_var(iu%ncid, iu%origin_xhx_varid, self%info(j)%origin_xh(1), start=[idslot]) ) - call check( nf90_put_var(iu%ncid, iu%origin_xhy_varid, self%info(j)%origin_xh(2), start=[idslot]) ) - call check( nf90_put_var(iu%ncid, iu%origin_xhz_varid, self%info(j)%origin_xh(3), start=[idslot]) ) - call check( nf90_put_var(iu%ncid, iu%origin_vhx_varid, self%info(j)%origin_vh(1), start=[idslot]) ) - call check( nf90_put_var(iu%ncid, iu%origin_vhy_varid, self%info(j)%origin_vh(2), start=[idslot]) ) - call check( nf90_put_var(iu%ncid, iu%origin_vhz_varid, self%info(j)%origin_vh(3), start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%collision_id_varid, self%info(j)%collision_id, start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_time_varid, self%info(j)%origin_time, start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_xhx_varid, self%info(j)%origin_xh(1), start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_xhy_varid, self%info(j)%origin_xh(2), start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_xhz_varid, self%info(j)%origin_xh(3), start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_vhx_varid, self%info(j)%origin_vh(1), start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_vhy_varid, self%info(j)%origin_vh(2), start=[idslot]) ) + call check( nf90_put_var(iu%ncid, iu%origin_vhz_varid, self%info(j)%origin_vh(3), start=[idslot]) ) call check( nf90_put_var(iu%ncid, iu%discard_time_varid, self%info(j)%discard_time, start=[idslot]) ) call check( nf90_put_var(iu%ncid, iu%discard_xhx_varid, self%info(j)%discard_xh(1), start=[idslot]) ) diff --git a/src/setup/setup.f90 b/src/setup/setup.f90 index bd8930ae3..b8a47d782 100644 --- a/src/setup/setup.f90 +++ b/src/setup/setup.f90 @@ -161,12 +161,12 @@ module subroutine setup_initialize_particle_info_system(self, param) associate(cb => self%cb, pl => self%pl, npl => self%pl%nbody, tp => self%tp, ntp => self%tp%nbody) - call cb%info%set_value(particle_type=CB_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", origin_time=param%t0, origin_xh=[0.0_DP, 0.0_DP, 0.0_DP], origin_vh=[0.0_DP, 0.0_DP, 0.0_DP]) + call cb%info%set_value(particle_type=CB_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", origin_time=param%t0, origin_xh=[0.0_DP, 0.0_DP, 0.0_DP], origin_vh=[0.0_DP, 0.0_DP, 0.0_DP], collision_id=0) do i = 1, self%pl%nbody - call pl%info(i)%set_value(particle_type=PL_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", origin_time=param%t0, origin_xh=self%pl%xh(:,i), origin_vh=self%pl%vh(:,i)) + call pl%info(i)%set_value(particle_type=PL_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", origin_time=param%t0, origin_xh=self%pl%xh(:,i), origin_vh=self%pl%vh(:,i), collision_id=0) end do do i = 1, self%tp%nbody - call tp%info(i)%set_value(particle_type=TP_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", origin_time=param%t0, origin_xh=self%tp%xh(:,i), origin_vh=self%tp%vh(:,i)) + call tp%info(i)%set_value(particle_type=TP_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", origin_time=param%t0, origin_xh=self%tp%xh(:,i), origin_vh=self%tp%vh(:,i), collision_id=0) end do end associate @@ -277,6 +277,7 @@ module subroutine setup_body(self, n, param) particle_type = "UNKNOWN", & status = "INACTIVE", & origin_type = "UNKNOWN", & + collision_id = 0, & origin_time = -huge(1.0_DP), & origin_xh = [0.0_DP, 0.0_DP, 0.0_DP], & origin_vh = [0.0_DP, 0.0_DP, 0.0_DP], & diff --git a/src/util/util_copy.f90 b/src/util/util_copy.f90 index f271c1c2e..aba6f5b0e 100644 --- a/src/util/util_copy.f90 +++ b/src/util/util_copy.f90 @@ -44,6 +44,7 @@ module subroutine util_copy_particle_info(self, source) status = source%status, & origin_type = source%origin_type, & origin_time = source%origin_time, & + collision_id = source%collision_id, & origin_xh = source%origin_xh(:), & origin_vh = source%origin_vh(:), & discard_time = source%discard_time, & diff --git a/src/util/util_set.f90 b/src/util/util_set.f90 index b056d692c..98ee4f497 100644 --- a/src/util/util_set.f90 +++ b/src/util/util_set.f90 @@ -98,7 +98,7 @@ module subroutine util_set_mu_tp(self, cb) return end subroutine util_set_mu_tp - module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, origin_xh, origin_vh, discard_time, discard_xh, discard_vh, discard_body_id) + module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, origin_xh, origin_vh, discard_time, discard_xh, discard_vh, discard_body_id) !! author: David A. Minton !! !! Sets one or more values of the particle information metadata object @@ -110,6 +110,7 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig character(len=*), intent(in), optional :: status !! Particle status description: ACTIVE, MERGED, FRAGMENTED, etc. character(len=*), intent(in), optional :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) real(DP), intent(in), optional :: origin_time !! The time of the particle's formation + integer(I4B), intent(in), optional :: collision_id !! The ID fo the collision that formed the particle real(DP), dimension(:), intent(in), optional :: origin_xh !! The heliocentric distance vector at the time of the particle's formation real(DP), dimension(:), intent(in), optional :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation real(DP), intent(in), optional :: discard_time !! The time of the particle's discard @@ -138,6 +139,9 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig if (present(origin_time)) then self%origin_time = origin_time end if + if (present(collision_id)) then + self%collision_id = collision_id + end if if (present(origin_xh)) then self%origin_xh(:) = origin_xh(:) end if