Skip to content

Commit

Permalink
Forward vs. backward integration;
Browse files Browse the repository at this point in the history
including Yarkovsky and YORP^1 effects.
Convergence of orbits.
Close encounters for collisional probability computations (Dahlgren 1998).

^1 YORP is NOT easily reversible due to asymptotic states!
  • Loading branch information
miroslavbroz committed Sep 7, 2023
1 parent 0e6e458 commit 78cfb9c
Show file tree
Hide file tree
Showing 19 changed files with 2,336 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ main/swift_rmvs4_fp_ye_yorp
main/swift_rmvs3_fp_ye_yorp
main/swift_mvs2_fp_ye_yorp
main/swift_mvs2_fp2
main/swift_mvs2_converg
main/swift_mvs2_converg2
main/swift_rmvs3_dahlgren
main/swift_rmvs3_dahlgren2
libswift/libswift.a

23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ opt = -O3 -g -pg
lib = -lswift -L.

obj = \
converg/converg.o \
converg/converg2.o \
converg/quicksort.o \
dahlgren/dahlgren.o \
dahlgren/dahlgren2.o \
io/io_close.o \
io/io_write_frame_r8_IO.o \
io/io_write_hdr_r8.o \
Expand Down Expand Up @@ -133,7 +138,11 @@ all: \
main/swift_rmvs4_fp_ye_yorp \
main/swift_rmvs3_fp_ye_yorp \
main/swift_mvs2_fp_ye_yorp \
main/swift_mvs2_fp2
main/swift_mvs2_fp2 \
main/swift_mvs2_converg \
main/swift_mvs2_converg2 \
main/swift_rmvs3_dahlgren \
main/swift_rmvs3_dahlgren2 \

main/swift_rmvs4_fp_ye_yorp: main/swift_rmvs4_fp_ye_yorp.f libswift.a $(obj) $(objc) $(inc)
$(f77) $(opt) $(obj) $(objc) -o $@ $< $(lib)
Expand All @@ -147,6 +156,18 @@ main/swift_mvs2_fp_ye_yorp: main/swift_mvs2_fp_ye_yorp.f libswift.a $(obj) $(obj
main/swift_mvs2_fp2: main/swift_mvs2_fp2.f libswift.a filter2 $(obj) $(objc) $(inc)
$(f77) $(opt) $(obj) $(objc) -o $@ $< $(lib)

main/swift_mvs2_converg: main/swift_mvs2_converg.f libswift.a $(obj) $(objc) $(inc)
$(f77) $(opt) $(obj) $(objc) -o $@ $< $(lib)

main/swift_mvs2_converg2: main/swift_mvs2_converg2.f libswift.a $(obj) $(objc) $(inc)
$(f77) $(opt) $(obj) $(objc) -o $@ $< $(lib)

main/swift_rmvs3_dahlgren: main/swift_rmvs3_dahlgren.f libswift.a $(obj) $(objc) $(inc)
$(f77) $(opt) $(obj) $(objc) -o $@ $< $(lib)

main/swift_rmvs3_dahlgren2: main/swift_rmvs3_dahlgren2.f libswift.a $(obj) $(objc) $(inc)
$(f77) $(opt) $(obj) $(objc) -o $@ $< $(lib)

$(obj) : %.o:%.f $(inc)
$(f77) $(opt) -c -o $@ $<

Expand Down
183 changes: 183 additions & 0 deletions converg/converg.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
c converg.f
c Check convergence of orbits wrt. particle "wrt".
c Miroslav Broz ([email protected]), Jun 26th 2021

subroutine converg(time,ntp,mass1,xht,yht,zht,vxht,vyht,vzht,
: istat,iu)

include "../swift.inc"

real*8 day, au
parameter(day = 86400.d0)
parameter(au = 149597870700.d0)

c input
real*8 time
real*8 mass1
integer ntp
real*8 xht(ntp),yht(ntp),zht(ntp)
real*8 vxht(ntp),vyht(ntp),vzht(ntp)
integer istat(ntp)
integer iu

c internal
integer i,j,k,ialpha
real*8 a(NTPMAX),e(NTPMAX),inc(NTPMAX),capom(NTPMAX),
: omega(NTPMAX),capm(NTPMAX)
real*8 Dv(NTPMAX),Dvori(NTPMAX)
real*8 amean,n,DOmega,Dvarpi,val
real*8 Dvmed,Dvmin,Dvmax
integer iub,iuc,ierr
save iub
logical regular(NTPMAX)
save regular

c functions
real*8 f360,median,min2,max2

integer i1st
save i1st
data i1st /1/

integer wrt,what
real*8 vlimit,t1,t2
save wrt,what,vlimit,t1,t2

c read parameters
if (i1st.eq.1) then
write(*,*) 'Enter with-respect-to body : '
read(*,*) wrt
write(*,*) 'Enter what body : '
read(*,*) what
write(*,*) 'Enter velocity limit in m/s : '
read(*,*) vlimit
write(*,*) 'Enter time span t1, t2 : '
read(*,*) t1,t2

write(*,*) 'wrt = ', wrt
write(*,*) 'what = ', what
write(*,*) 'vlimit = ', vlimit
write(*,*) 't1 = ', t1
write(*,*) 't2 = ', t2

open(unit=iu, file="converg.out", status="unknown")
write(iu,*) '# t Dvmed Dvmin Dvmax Dv(', what, ') j '
write(iu,*) '# [My] [m/s] [m/s] [m/s] [m/s] []'

iub=105
open(unit=iub, file="converg.tmp", status="unknown")
write(iub,*) '# id t Dv(i)'
write(iub,*) '# [] [My] [m/s]'

iuc=110
open(unit=iuc, file="regular.lst", status="old")
do i = 1,ntp
read(iuc,*,iostat=ierr) j,regular(i)
if ((ierr.ne.0).or.(j.ne.i)) then
write(*,*) 'Error reading regular.lst.'
stop
endif
write(*,*) i,regular(i)
enddo
close(iuc)

i1st=0
endif

c check convergence
if (istat(1).ne.0) then
write(*,*) 'converg.f: Warning, test particle 1 not present!'
return
endif

do i = 1,ntp
if (istat(i).eq.0) then
call orbel_xv2el(xht(i),yht(i),zht(i),vxht(i),vyht(i),
& vzht(i),mass1,ialpha,a(i),e(i),inc(i),capom(i),omega(i),
& capm(i))
endif
enddo

j = 0
k = wrt
do i = 1,ntp
if ((i.ne.k).and.(istat(i).eq.0).and.(regular(i))) then
amean = 0.5d0*(a(i)+a(k))
n = sqrt(mass1/amean**3)
DOmega = f360(capom(i)-capom(k))
Dvarpi = f360(capom(i)+omega(i)-(capom(k)+omega(k)))
val = n*amean*sqrt((sin(inc(i))*DOmega)**2+(e(i)*Dvarpi)**2)
j = j+1
Dv(j) = val
Dvori(j) = val
endif
enddo

Dvmed = median(j, Dv)
Dvmin = Dv(1)
Dvmax = Dv(j)

if (Dvmed.lt.vlimit/(au/day)) then
write(iu,*) time/365.25d6, Dvmed*(au/day), Dvmin*(au/day),
: Dvmax*(au/day), Dvori(what)*(au/day), j
endif

if ((time.gt.t1).and.(time.lt.t2)) then
do i = 1,j
write(iub,*) i, time/365.25d6, Dvori(i)*(au/day)
enddo
write(iub,*)
endif

return
end


real*8 function f360(x)
include '../swift.inc'
real*8 x
if (x.lt.-PI) then
x = x + TWOPI
else if (x.gt.PI) then
x = x - TWOPI
endif
f360 = x
return
end

real*8 function median(n, x)
implicit none
integer n
real*8 x(n)
real*8 y(n)
real*8 median_and_sort
integer i
do i = 1,n
y(i) = x(i)
enddo
median = median_and_sort(n, y)
return
end

real*8 function median_and_sort(n, x)
implicit none
integer n
real*8 x(n)
integer j
real*8 s
if (n.eq.0) then
median_and_sort = -1.d0
return
endif
call quicksort(n, x)
j = int(n/2.d0)
if (mod(n, 2).eq.0) then
s = 0.5d0*(x(j)+x(j-1))
else
s = x(j)
endif
median_and_sort = s
return
end


Loading

0 comments on commit 78cfb9c

Please sign in to comment.