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

Commit

Permalink
Merge branch 'AdaptiveInteractionLoop' into DocumentationTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Sep 21, 2021
2 parents 7335412 + de11649 commit eddddc8
Show file tree
Hide file tree
Showing 40 changed files with 1,295 additions and 691 deletions.
37 changes: 25 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
SWIFTEST_MODULES = swiftest_globals.f90 \
swiftest_operators.f90 \
lambda_function.f90\
walltime_classes.f90 \
swiftest_classes.f90 \
fraggle_classes.f90 \
whm_classes.f90 \
rmvs_classes.f90 \
helio_classes.f90 \
symba_classes.f90 \
walltime_classes.f90 \
swiftest.f90


Expand Down Expand Up @@ -93,11 +93,6 @@ lib:
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make libdir
cd $(SWIFTEST_HOME)/src/drift; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make libdir
cd $(SWIFTEST_HOME)/src/gr; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
Expand Down Expand Up @@ -128,11 +123,6 @@ lib:
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make libdir
cd $(SWIFTEST_HOME)/src/orbel; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make libdir
cd $(SWIFTEST_HOME)/src/setup; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
Expand Down Expand Up @@ -168,6 +158,11 @@ lib:
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make libdir
cd $(SWIFTEST_HOME)/src/walltime; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make libdir

fast:
cd $(SWIFTEST_HOME)/src/fraggle; \
Expand All @@ -182,6 +177,24 @@ fast:
ln -s $(SWIFTEST_HOME)/Makefile .; \
make fastdir

cd $(SWIFTEST_HOME)/src/orbel; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make fastdir

cd $(SWIFTEST_HOME)/src/drift; \
rm -f Makefile.Defines Makefile; \
ln -s $(SWIFTEST_HOME)/Makefile.Defines .; \
ln -s $(SWIFTEST_HOME)/Makefile .; \
make fastdir

cd $(SWIFTEST_HOME)/src/helio; \
$(FORTRAN) $(FFASTFLAGS) -I$(SWIFTEST_HOME)/include -I$(NETCDF_FORTRAN_HOME)/include $(IMKL) -c helio_drift.f90; \
$(AR) rv $(SWIFTEST_HOME)/lib/libswiftest.a *.o *.smod; \
$(INSTALL_DATA) *.smod $(SWIFTEST_HOME)/include; \
rm -f *.o *.smod

cd $(SWIFTEST_HOME)/src/rmvs; \
$(FORTRAN) $(FFASTFLAGS) -I$(SWIFTEST_HOME)/include -I$(NETCDF_FORTRAN_HOME)/include $(IMKL) -c rmvs_encounter_check.f90; \
$(AR) rv $(SWIFTEST_HOME)/lib/libswiftest.a *.o *.smod; \
Expand All @@ -206,7 +219,6 @@ fastdir:
$(INSTALL_DATA) *.smod $(SWIFTEST_HOME)/include; \
rm -f *.o *.smod


drivers:
cd $(SWIFTEST_HOME)/src/main; \
rm -f Makefile.Defines Makefile; \
Expand Down Expand Up @@ -237,6 +249,7 @@ clean:
cd $(SWIFTEST_HOME)/src/tides; rm -f Makefile.Defines Makefile *.gc*
cd $(SWIFTEST_HOME)/src/user; rm -f Makefile.Defines Makefile *.gc*
cd $(SWIFTEST_HOME)/src/util; rm -f Makefile.Defines Makefile *.gc*
cd $(SWIFTEST_HOME)/src/walltime; rm -f Makefile.Defines Makefile *.gc*
cd $(SWIFTEST_HOME)/src/whm; rm -f Makefile.Defines Makefile *.gc*
cd $(SWIFTEST_HOME)/bin; rm -f swiftest_*
cd $(SWIFTEST_HOME)/bin; rm -f tool_*
Expand Down
10 changes: 5 additions & 5 deletions Makefile.Defines
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporari
GPRODUCTION = -O2 -ffree-line-length-none $(GPAR)


#FFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
#FFASTFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
FFLAGS = $(IPRODUCTION) $(STRICTREAL)
FFASTFLAGS = $(IPRODUCTION) -fp-model fast
#FFLAGS = $(IDEBUG) #$(SIMDVEC) $(PAR)
#FFASTFLAGS = $(IDEBUG) #$(SIMDVEC) $(PAR)
FFLAGS = $(IPRODUCTION) $(STRICTREAL) #$(ADVIXE_FLAGS)
FFASTFLAGS = $(IPRODUCTION) -fp-model fast #$(ADVIXE_FLAGS)
FORTRAN = ifort
AR = xiar

#FORTRAN = gfortran
#FFLAGS = $(GDEBUG) $(GMEM) $(GPAR)
#FFLAGS = $(GDEBUG) # $(GMEM) $(GPAR)
#FFLAGS = $(GPRODUCTION) -g -fbacktrace #-fcheck=all #-Wall AR = ar # DO NOT include in CFLAGS the "-c" option to compile object only
# this is done explicitly as needed in the Makefile

Expand Down
4 changes: 2 additions & 2 deletions examples/symba_mars_disk/param.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!Parameter file for the SyMBA-RINGMOONS test
T0 0.0
TSTOP 12000.0
TSTOP 1200.0
DT 600.0
CB_IN cb.in
PL_IN mars.in
Expand Down Expand Up @@ -31,4 +31,4 @@ MU2KG 1.0
DU2M 1.0
TU2S 1.0
SEED 2 3080983 2220830
FLATTEN_INTERACTIONS yes
INTERACTION_LOOPS ADAPTIVE
43 changes: 24 additions & 19 deletions src/drift/drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ module subroutine drift_all(mu, x, v, n, param, dt, lmask, iflag)
else
where(lmask(1:n)) dtp(1:n) = dt
end if
!$omp parallel do default(private) &
!$omp shared(n, lmask, mu, x, v, dtp, iflag)
do i = 1,n
!$omp simd
do i = 1, n
if (lmask(i)) call drift_one(mu(i), x(1,i), x(2,i), x(3,i), v(1,i), v(2,i), v(3,i), dtp(i), iflag(i))
end do
!$omp end parallel do
!$omp end simd

return
end subroutine drift_all


module pure elemental subroutine drift_one(mu, px, py, pz, vx, vy, vz, dt, iflag)
!$omp declare simd(drift_one)
!! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott
!!
!! Perform Danby drift for one body, redoing drift with smaller substeps if original accuracy is insufficient
Expand All @@ -104,27 +104,22 @@ module pure elemental subroutine drift_one(mu, px, py, pz, vx, vy, vz, dt, iflag
! Internals
integer(I4B) :: i
real(DP) :: dttmp
real(DP), dimension(NDIM) :: x, v

x = [px, py, pz]
v = [vx, vy, vz]

call drift_dan(mu, x(:), v(:), dt, iflag)
call drift_dan(mu, px, py, pz, vx, vy, vz, dt, iflag)
if (iflag /= 0) then
dttmp = 0.1_DP * dt
do i = 1, 10
call drift_dan(mu, x(:), v(:), dttmp, iflag)
call drift_dan(mu, px, py, pz, vx, vy, vz, dttmp, iflag)
if (iflag /= 0) exit
end do
end if
px = x(1); py = x(2); pz = x(3)
vx = v(1); vy = v(2); vz = v(3)

return
end subroutine drift_one


pure subroutine drift_dan(mu, x0, v0, dt0, iflag)
pure subroutine drift_dan(mu, px0, py0, pz0, vx0, vy0, vz0, dt0, iflag)
!$omp declare simd(drift_dan)
!! author: David A. Minton
!!
!! Perform Kepler drift, solving Kepler's equation in appropriate variables
Expand All @@ -134,14 +129,16 @@ pure subroutine drift_dan(mu, x0, v0, dt0, iflag)
implicit none
integer(I4B), intent(out) :: iflag
real(DP), intent(in) :: mu, dt0
real(DP), dimension(:), intent(inout) :: x0, v0
real(DP), intent(inout) :: px0, py0, pz0, vx0, vy0, vz0
real(DP) :: dt, f, g, fdot, gdot, c1, c2, c3, u, alpha, fp, r0
real(DP) :: v0s, a, asq, en, dm, ec, es, esq, xkep, fchk, s, c
real(DP), dimension(NDIM) :: x, v
real(DP), dimension(NDIM) :: x, v, x0, v0

! Executable code
iflag = 0
dt = dt0
x0 = [px0, py0, pz0]
v0 = [vx0, vy0, vz0]
r0 = sqrt(dot_product(x0(:), x0(:)))
v0s = dot_product(v0(:), v0(:))
u = dot_product(x0(:), v0(:))
Expand Down Expand Up @@ -172,8 +169,8 @@ pure subroutine drift_dan(mu, x0, v0, dt0, iflag)
gdot = (c - 1.0_DP) / fp + 1.0_DP
x(:) = x0(:) * f + v0(:) * g
v(:) = x0(:) * fdot + v0(:) * gdot
x0(:) = x(:)
v0(:) = v(:)
px0 = x(1); py0 = x(2); pz0 = x(3)
vx0 = v(1); vy0 = v(2); vz0 = v(3)
iflag = 0
return
end if
Expand All @@ -187,15 +184,16 @@ pure subroutine drift_dan(mu, x0, v0, dt0, iflag)
gdot = 1.0_DP - mu / fp * c2
x(:) = x0(:) * f + v0(:) * g
v(:) = x0(:) * fdot + v0(:) * gdot
x0(:) = x(:)
v0(:) = v(:)
px0 = x(1); py0 = x(2); pz0 = x(3)
vx0 = v(1); vy0 = v(2); vz0 = v(3)
end if

return
end subroutine drift_dan


pure subroutine drift_kepmd(dm, es, ec, x, s, c)
!$omp declare simd(drift_kepmd)
!! author: David A. Minton
!!
!! Solve Kepler's equation in difference form for an ellipse for small input dm and eccentricity
Expand Down Expand Up @@ -235,6 +233,7 @@ end subroutine drift_kepmd


pure subroutine drift_kepu(dt,r0,mu,alpha,u,fp,c1,c2,c3,iflag)
!$omp declare simd(drift_kepu)
!! author: David A. Minton
!!
!! Solve Kepler's equation in universal variables
Expand Down Expand Up @@ -263,6 +262,7 @@ end subroutine drift_kepu


pure subroutine drift_kepu_fchk(dt, r0, mu, alpha, u, s, f)
!$omp declare simd(drift_kepu_fchk)
!! author: David A. Minton
!!
!! Computes the value of f, the function whose root we are trying to find in universal variables
Expand All @@ -286,6 +286,7 @@ end subroutine drift_kepu_fchk


pure subroutine drift_kepu_guess(dt, r0, mu, alpha, u, s)
!$omp declare simd(drift_kepu_guess)
!! author: David A. Minton
!!
!! Compute initial guess for solving Kepler's equation using universal variables
Expand Down Expand Up @@ -324,6 +325,7 @@ end subroutine drift_kepu_guess


pure subroutine drift_kepu_lag(s, dt, r0, mu, alpha, u, fp, c1, c2, c3, iflag)
!$omp declare simd(drift_kepu_lag)
!! author: David A. Minton
!!
!! Solve Kepler's equation in universal variables using Laguerre's method
Expand Down Expand Up @@ -369,6 +371,7 @@ end subroutine drift_kepu_lag


pure subroutine drift_kepu_new(s, dt, r0, mu, alpha, u, fp, c1, c2, c3, iflag)
!$omp declare simd(drift_kepu_new)
!! author: David A. Minton
!!
!! Solve Kepler's equation in universal variables using Newton's method
Expand Down Expand Up @@ -411,6 +414,7 @@ end subroutine drift_kepu_new


pure subroutine drift_kepu_p3solve(dt, r0, mu, alpha, u, s, iflag)
!$omp declare simd(drift_kepu_p3solve)
!! author: David A. Minton
!!
!! Computes real root of cubic involved in setting initial guess for solving Kepler's equation in universal variables
Expand Down Expand Up @@ -455,6 +459,7 @@ end subroutine drift_kepu_p3solve


pure subroutine drift_kepu_stumpff(x, c0, c1, c2, c3)
!$omp declare simd(drift_kepu_stumpff)
!! author: David A. Minton
!!
!! Compute Stumpff functions needed for Kepler drift in universal variables
Expand Down
Loading

0 comments on commit eddddc8

Please sign in to comment.