Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tillotson cleanup and testing #609

Merged
merged 74 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4303043
(tillotson) added module and subroutines for tillotson eos
Ambionce Aug 7, 2024
7131412
merge
Ambionce Aug 7, 2024
ea43d24
(Tillotson) wrote psuedocode for EOS
Ambionce Aug 12, 2024
91c9f0d
(units) added earth radii to unit options
Ambionce Aug 12, 2024
9db149c
(units) added earth radii to unit options
Ambionce Aug 12, 2024
c8c7280
(tillotson) added psuedocode - tillotson eos parameters for basalt an…
Ambionce Aug 13, 2024
93466fa
(tillotson) compiled code and params for basalt from benz & asphaug 1999
Ambionce Aug 14, 2024
665fcb3
(tillotson) added initialise eos case 23 subroutine
Ambionce Aug 15, 2024
00c42fe
(tillotson) update init and read eos subroutines for case 23
Ambionce Aug 15, 2024
bf14df6
(tillotson) updated eos and readwrite infile to include case 23 eos
Ambionce Aug 15, 2024
03f8493
(tillotson) remove unit conversion from write options eos
Ambionce Aug 17, 2024
cd8df39
(setup_solarsystem) added mass of sun in binary system setup
Ambionce Aug 20, 2024
0a5f901
(setup_binary) removed hardcoded eos in subroutine
Ambionce Aug 20, 2024
19a988b
(tillotson) fixed units read-write functions and updated condensed-ev…
Ambionce Aug 21, 2024
14b9bc2
(tillotson) added calculation of temp to internal energy to eos subro…
Ambionce Sep 3, 2024
5063782
(solarsystem) included asteroid apophis into ephemeris and solarsyste…
Ambionce Sep 3, 2024
73c34cb
Merge remote-tracking branch 'origin' into Tillotson
Ambionce Sep 6, 2024
03b50a9
(tillotson) fix windows crap
Ambionce Sep 10, 2024
db69327
(solarsystem) initial change from multiple binary setups to single st…
Ambionce Sep 11, 2024
a7ad58f
(tillotson) update eos to include hybrid phase and fix greek paramete…
Ambionce Sep 13, 2024
40d7cb2
(tillotson) updated internal energy calculation
Ambionce Sep 13, 2024
fa0b709
(tillotson) updated pressure and energy conditional calculations
Ambionce Sep 16, 2024
4eec9e7
(tillotson) quadratic equation fix for internal energy subroutine
Ambionce Sep 18, 2024
211829a
(tillotson) in Makefile changed order for reading in cubicsolve
Ambionce Sep 18, 2024
3bf2555
(tillotson) update piecewise pressure and internal energy
Ambionce Sep 20, 2024
47d5663
(tillotson) add calc u from prho to testing suite
Ambionce Sep 24, 2024
56d18c4
Merge branch 'danieljprice:master' into Tillotson
AmberTilly Sep 24, 2024
e3091aa
(tillotson) removed unnecessary code
Ambionce Sep 24, 2024
6e4764f
(Tillotson) updated eos piecewise and testing of eos
Ambionce Oct 1, 2024
5034e52
(tillotson) fixed piecewise eos to within 1.E-12 tol
Ambionce Oct 4, 2024
f59bfd1
(tillotson) removed low energy cold expansion state as negative press…
Ambionce Oct 9, 2024
8318ad2
(tillotson) update set star utils and eos to ensure zero initial inte…
Ambionce Oct 13, 2024
b3ea73e
Merge branch 'danieljprice:master' into Tillotson
AmberTilly Dec 2, 2024
4ef899b
(solarsystem) new add_body routine, also set planet accretion radii f…
danieljprice Dec 15, 2024
b87588b
merge master->tillotson
danieljprice Dec 15, 2024
0936cc5
(tillotson) cleanup compiler warnings and unused functionality
danieljprice Dec 15, 2024
af519b0
(test_eos) cleanup of test_u_from_Prho; apply to as many eos types as…
danieljprice Dec 16, 2024
49643f1
(tillotson) cleanup/rewrite of tillotson eos routines
danieljprice Dec 16, 2024
feb54f5
(test_eos) added test_all routine to check for continuous pressure in…
danieljprice Dec 16, 2024
57c9f27
(test_eos) check eos is continuous with rho and u
danieljprice Dec 16, 2024
9e4087f
(tillotson) cleanup and further testing
danieljprice Dec 16, 2024
660e1dc
(test_eos) skip ieos=21,22 in continuity-of-pressure test
danieljprice Dec 16, 2024
9b37de2
[header-bot] updated file headers
danieljprice Dec 16, 2024
34cb52a
[space-bot] whitespace at end of lines removed
danieljprice Dec 16, 2024
60e64d2
[author-bot] updated AUTHORS file
danieljprice Dec 16, 2024
1a66e9c
[format-bot] end if -> endif; end do -> enddo; if( -> if (
danieljprice Dec 16, 2024
e1ff4e8
[indent-bot] standardised indentation
danieljprice Dec 16, 2024
a8e77a2
(docs) update documentation
danieljprice Dec 16, 2024
efb71b6
merge conflict fixed
danieljprice Dec 16, 2024
f4f35a6
(test_eos) fix test failure due to uninitialised variable
danieljprice Dec 18, 2024
a6be532
(tillotson) update docs with eos details
danieljprice Dec 18, 2024
77f10e6
(solarsystem) cleanup functionality into set_bodies module; add optio…
danieljprice Dec 18, 2024
ca78095
(checksetup) check for NaNs in sink particle arrays
danieljprice Dec 18, 2024
0231c97
(utils_dumpfiles) out of bounds error fixed if there are no SPH parti…
danieljprice Dec 18, 2024
ac0777a
(substep) do not call update_ptmass if nothing has been accreted; als…
danieljprice Dec 18, 2024
71f8203
(checksetup) seg fault fixed from apr stuff left in checksetup routine
danieljprice Dec 18, 2024
d2dc2bf
(solarsystem) working simulation of impending destruction
danieljprice Dec 18, 2024
f2847e5
(ephemeris) added setup for dwarf planets
danieljprice Dec 18, 2024
376a98e
(test_eos) compiler warning fixed
danieljprice Dec 18, 2024
f72d676
(solarsystem) add gravity, option for number of particles in body
danieljprice Dec 18, 2024
a3f0aec
(eos) added eos_requires_polyk routine instead of hardwiring eos opti…
danieljprice Dec 19, 2024
6110247
(setup) bug fixed in setup; use closepacked lattice; nptot no longer …
danieljprice Dec 19, 2024
7948ddc
(set_sphere) test failures fixed
danieljprice Dec 19, 2024
c003cb6
(test_ptmass) bug fix with previous fix for zero-mass sinks; tighten …
danieljprice Dec 20, 2024
8cdebf8
(test_ptmass) revert changes to tolerances
danieljprice Dec 20, 2024
02fd8ec
(eos) tillotson outputs pressure to dump file
danieljprice Dec 20, 2024
1854e41
(apr) bug fix with mpi_dens extent calculation; also make this a fata…
danieljprice Dec 20, 2024
542f401
(ptmass) fix test failure with MPI
danieljprice Dec 20, 2024
7d9ff16
(mpi) added bcast_mpi_logical routine
danieljprice Dec 20, 2024
ef9b449
(test_ptmass) BUG FIX with epot_sinksink causing test failure with MP…
danieljprice Dec 20, 2024
0ccbae3
(header) amend header to reflect collaborative authorship of Phantom
danieljprice Dec 20, 2024
ee1e177
(mpi) test failure fixed
danieljprice Dec 20, 2024
8905290
(mpi) hangs in testsuite with checks on single thread fixed
danieljprice Dec 20, 2024
34c4792
(build) build failures fixed
danieljprice Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(solarsystem) cleanup functionality into set_bodies module; add optio…
…ns for minor bodies, planets etc, add option for epoch when retrieving ephemeris, fix bugs in ephemeris read
danieljprice committed Dec 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 77f10e69aec6574ed47b202c92dadc558f134798
2 changes: 1 addition & 1 deletion build/Makefile_setups
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ endif
ifeq ($(SETUP), solarsystem)
# orbits of minor planets
ISOTHERMAL=yes
SETUPFILE=utils_ephemeris.f90 utils_mpc.f90 setup_solarsystem.f90
SETUPFILE=utils_ephemeris.f90 utils_mpc.f90 set_bodies.f90 setup_solarsystem.f90
KNOWN_SETUP=yes
DUST=yes
endif
212 changes: 212 additions & 0 deletions src/setup/set_bodies.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
!--------------------------------------------------------------------------!
! The Phantom Smoothed Particle Hydrodynamics code, by Daniel Price et al. !
! Copyright (c) 2007-2024 The Authors (see AUTHORS) !
! See LICENCE file for usage and distribution conditions !
! http://phantomsph.github.io/ !
!--------------------------------------------------------------------------!
module setbodies
!
! Setup asteroid orbits using data from the IAU Minor Planet Center
!
! :References: https://minorplanetcenter.net/data
!
! :Owner: Daniel Price
!
! :Dependencies: centreofmass, datautils, ephemeris, infile_utils, io, mpc,
! part, physcon, setbinary, timestep, units
!
implicit none
public :: set_minor_planets
public :: add_body,add_sun_and_planets

private

contains
!----------------------------------------------------------------
!+
! set up asteroids as a population of dust particles
!+
!----------------------------------------------------------------
subroutine set_minor_planets(npart,npartoftype,massoftype,xyzh,vxyzu,mtot,itype,sample_orbits)
use part, only:set_particle_type,nsinkproperties
use physcon, only:au
use units, only:udist
use datautils, only:find_datafile
use mpc, only:read_mpc,mpc_entry
use setbinary, only:set_binary
integer, intent(inout) :: npart,npartoftype(:)
real, intent(inout) :: xyzh(:,:),vxyzu(:,:),massoftype(:)
real, intent(in) :: mtot
integer, intent(in) :: itype
logical, intent(in), optional :: sample_orbits
integer :: nbodies,nsample,n,i,j,nptmass,ierr
real :: xyzmh_ptmass(nsinkproperties,2),vxyz_ptmass(3,2),hpart
character(len=120) :: filename
type(mpc_entry), allocatable :: dat(:)

nsample = 1
if (present(sample_orbits)) then
! can place many particles evenly sampling the orbit if desired
if (sample_orbits) nsample = 100
endif

nbodies = 0
filename = find_datafile('Distant.txt',url='https://www.minorplanetcenter.net/iau/MPCORB/')
call read_mpc(filename,nbodies,dat=dat)
print "(a,i0,a)",' read orbital data for ',nbodies,' minor planets'

n = 0
hpart = 10.*au/udist/nsample

do i=1,nbodies
!
! for each solar system object get the xyz positions from the orbital parameters
!
!print*,i,'aeiOwM=',dat(i)%a,dat(i)%ecc,dat(i)%inc,dat(i)%O,dat(i)%w,dat(i)%M
do j=1,nsample
nptmass = 0
n = n + 1
if (nsample==1) then
call set_binary(mtot,epsilon(0.),dat(i)%a,dat(i)%ecc,0.02,1.e-15,&
xyzmh_ptmass,vxyz_ptmass,nptmass,ierr,incl=dat(i)%inc,&
arg_peri=dat(i)%w,posang_ascnode=dat(i)%O,&
mean_anomaly=dat(i)%M,verbose=.false.)
else
call set_binary(mtot,epsilon(0.),dat(i)%a,dat(i)%ecc,0.02,1.e-15,&
xyzmh_ptmass,vxyz_ptmass,nptmass,ierr,incl=dat(i)%inc,&
arg_peri=dat(i)%w,posang_ascnode=dat(i)%O,&
f=360.*(n-1)/nsample,verbose=.false.)
endif
!
! now delete the point masses but set a dust particle as the secondary
!
xyzh(1:3,n) = xyzmh_ptmass(1:3,2)
xyzh(4,n) = hpart ! give a random length scale as the smoothing length
vxyzu(1:3,n) = vxyz_ptmass(1:3,2)
call set_particle_type(n,itype)
enddo

enddo
!
! set mass of all the minor bodies equal
!
print "(a)"
npart = npart + nbodies*nsample
npartoftype(itype) = npartoftype(itype) + nbodies*nsample
massoftype(itype) = 1.e-20

end subroutine set_minor_planets

!----------------------------------------------------------------
!+
! setup the solar system planets by querying their ephemeris
! from the JPL server
!+
!----------------------------------------------------------------
subroutine add_sun_and_planets(nptmass,xyzmh_ptmass,vxyz_ptmass,mtot,epoch)
integer, intent(inout) :: nptmass
real, intent(inout) :: xyzmh_ptmass(:,:),vxyz_ptmass(:,:)
real, intent(in) :: mtot
character(len=*), intent(in), optional :: epoch
integer, parameter :: nbodies = 10
character(len=*), parameter :: planet_name(nbodies) = &
(/'sun ',&
'mercury', &
'venus ', &
'earth ', &
'mars ', &
'jupiter', &
'saturn ', &
'uranus ', &
'neptune', &
'pluto '/) ! for nostalgia's sake
integer :: i

do i=1,nbodies
if (present(epoch)) then
call add_body(planet_name(i),nptmass,xyzmh_ptmass,vxyz_ptmass,mtot,epoch=epoch)
else
call add_body(planet_name(i),nptmass,xyzmh_ptmass,vxyz_ptmass,mtot)
endif
enddo

print*,' nptmass = ',nptmass

end subroutine add_sun_and_planets

!----------------------------------------------------------------
!+
! setup a body in the solar system by querying their ephemeris
! from the JPL server
!+
!----------------------------------------------------------------
subroutine add_body(body_name,nptmass,xyzmh_ptmass,vxyz_ptmass,mtot,epoch)
use ephemeris, only:get_ephemeris,nelem
use units, only:umass,udist
use physcon, only:gg,km,solarm,solarr,earthm,au
use setbinary, only:set_binary
use fileutils, only:lcase
character(len=*), intent(in) :: body_name
integer, intent(inout) :: nptmass
real, intent(inout) :: xyzmh_ptmass(:,:),vxyz_ptmass(:,:)
real, intent(in) :: mtot
character(len=*), intent(in), optional :: epoch
real :: elems(nelem)
real :: xyz_tmp(size(xyzmh_ptmass(:,1)),2),vxyz_tmp(3,2),gm_cgs
real :: mbody,rbody,a,e,inc,O,w,f
integer :: ierr,ntmp
logical :: got_elem(nelem)

if (trim(adjustl(lcase(body_name)))=='sun') then
!
! add the Sun, ideally would add here its motion
! around the solar system barycentre
!
nptmass = nptmass + 1
xyzmh_ptmass(:,nptmass) = 0.
xyzmh_ptmass(4,nptmass) = solarm/umass
xyzmh_ptmass(5,nptmass) = solarr/udist
vxyz_ptmass(:,nptmass) = 0.
return
endif

if (present(epoch)) then
elems = get_ephemeris(lcase(body_name),got_elem,ierr,epoch=epoch)
else
elems = get_ephemeris(lcase(body_name),got_elem,ierr)
endif
if (ierr > 0 .or. .not.any(got_elem)) then
print "(a)",' ERROR: could not read ephemeris data for '//body_name
return ! skip if error reading ephemeris file
endif
a = elems(1)*km/udist
e = elems(2)
inc = elems(3)
O = elems(4)
w = elems(5)
f = elems(6)
gm_cgs = elems(7)*km**3
mbody = (gm_cgs/gg)/umass
rbody = elems(8)*km/udist
print "(1x,a,1pg10.3)", ' m/msun = ',mbody*umass/solarm
print "(1x,a,1pg10.3)", ' m/mearth = ',mbody*umass/earthm
print "(1x,a,1pg10.4,a)", ' a = ',a*udist/au,' au'
print "(1x,a,1pg10.3,a)", ' radius = ',elems(8),' km'
print "(1x,a,1pg10.3,a)", ' density = ',elems(9),' g/cm^3'
ntmp = 0
call set_binary(mtot,0.,a,e,0.01,rbody,&
xyz_tmp,vxyz_tmp,ntmp,ierr,incl=inc,&
arg_peri=w,posang_ascnode=O,f=f,verbose=.false.)

! add a point mass for each body
nptmass = nptmass + 1
xyzmh_ptmass(1:3,nptmass) = xyz_tmp(:,2)
xyzmh_ptmass(4,nptmass) = mbody
xyzmh_ptmass(5,nptmass) = rbody
vxyz_ptmass(1:3,nptmass) = vxyz_tmp(:,2)
print "(1x,a,3(1x,1pg10.3))",' x = ',xyz_tmp(1:3,2)
print "(1x,a,3(1x,1pg10.3))",' v = ',vxyz_tmp(1:3,2)

end subroutine add_body

end module setbodies
Loading