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
(tillotson) update piecewise pressure and internal energy
Ambionce committed Sep 20, 2024
commit 3bf2555d9e1448bd42e7f498dc5d58eff33ceb2c
178 changes: 70 additions & 108 deletions src/main/eos_tillotson.f90
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ module eos_tillotson
implicit none
real :: rho0 = 2.7 ! g/cm^3 zero-pressure density (Basalt) from Benz & Asphaug 1999
! aparam, bparam, A, B, energy0 material-dependent Tillotson parameters (Basalt)
real :: pressure = 0. ! THIS COULD WORK
real :: aparam = 0.5 , bparam = 1.5 , alpha = 5. , beta = 5.
real :: A = 2.67e11 , B = 2.67e11 ! erg/cm^3
real :: u0 = 4.87e12 ! erg/g
@@ -29,7 +30,6 @@ module eos_tillotson
real :: rho_iv = 2.57 ! g/cm^3 incipient vaporisation density of gabbroic anorthosite lpp from Ahrens and Okeefe (1977) table 1
! real :: rho_cv = 8.47 ! g/cm^3 complete vaporisation density of gabbroic anorthosite lpp from Ahrens and Okeefe (1977) table 2
private :: rho0, aparam, bparam, A, B, alpha, beta, u0, rho_iv, u_iv, u_cv
! private :: quadratic_eq
! private :: spsoundmin, spsound2, spsound3, pressure2, pressure3
! private :: expterm, expterm2, sqrtterm, sqrtterm1, sqrtterm2

@@ -49,24 +49,24 @@ end subroutine init_eos_tillotson
subroutine equationofstate_tillotson(rho,u,pressure,spsound,gamma)
real, intent(in) :: rho,u
real, intent(out) :: pressure, spsound, gamma
real :: eta, mu, neu, omega, spsoundmin, spsound2, spsound2h, spsound3, pressure2, pressure3
real :: eta, mu_t, neu, omega, spsoundmin, spsound2, spsoundh, spsound2h, spsound3, pressure2, pressure3

eta = rho / rho0
mu = eta - 1.
mu_t = eta - 1.
neu = (1. / eta) - 1. ! Kegerreis et al. 2020
omega = (u / (u0*eta**2)) + 1.
spsoundmin = sqrt(A / rho) ! wave speed estimate
! gamma = 2./3.

! Brundage 2013 eq (2) cold expanded and compressed states
pressure2 = (( aparam + ( bparam / omega ) ) * rho*u) + A*mu + B*mu**2
pressure2 = (( aparam + ( bparam / omega ) ) * rho*u) + A*mu_t + B*mu_t**2
if (pressure2 <= 0.) then
pressure2 = 0.
endif

! Brundage 2013 eq (3) completely vaporised
pressure3 = (aparam*rho*u) + ( ((bparam*rho*u)/omega) + &
A*mu*exp(-beta*neu)) * exp(-alpha*(neu**2))
A*mu_t*exp(-beta*neu)) * exp(-alpha*(neu**2))
if (pressure3 <= 0.) then
pressure3 = 0.
endif
@@ -81,7 +81,7 @@ subroutine equationofstate_tillotson(rho,u,pressure,spsound,gamma)

spsound3 = sqrt( (pressure3/rho)*( 1. + aparam + ((bparam / omega )*exp(-alpha*(neu**2)))) + &
( ((bparam*rho*u)/((omega**2)*(eta**2))) * ((1. /(u0*rho))*((2.*u) - (pressure3/rho)) &
+ ((2.*alpha*neu*omega)/rho0)) + ((A/rho0)*(1. + (mu/eta**2)*((beta*2.*alpha*neu) - eta))) &
+ ((2.*alpha*neu*omega)/rho0)) + ((A/rho0)*(1. + (mu_t/eta**2)*((beta*2.*alpha*neu) - eta))) &
* exp(-beta*neu) )*exp(-alpha*(neu**2)) )
if (spsound3 < spsoundmin) then
spsound3 = spsoundmin
@@ -94,29 +94,59 @@ subroutine equationofstate_tillotson(rho,u,pressure,spsound,gamma)
spsound2h = spsoundmin
endif

if (rho >= rho0) then ! compressed state
pressure = pressure2
spsound = spsound2
else ! rho < rho0
if (u >= u_cv) then ! vaporised expanded state
pressure = pressure3
spsound = spsound3
! need to check rho ~0 and u >> u_cv (zero density becomes pressure = rho*gamma*u fermi, gamma = 2/3)
else ! u < u_cv
if (rho >= rho_iv) then
if (u > u_iv) then ! Hybrid state
pressure = ( (u - u_iv)*pressure3 + (u_cv - u)*pressure2 ) / (u_cv - u_iv)
spsound = sqrt(( ((u-u_iv)*(spsound3)**2) + ((u_cv-u)*(spsound2)**2) ) / (u_cv - u_iv))
else ! u <= u_iv cold expanded
if (rho < rho0) then
if (rho >= rho_iv) then ! u <= u_iv cold expanded
if (u < u_cv) then ! hybrid state
pressure = pressure2
spsound = spsound2
elseif (u > u_iv) then ! hybrid state
pressure = ( (u - u_iv)*pressure3 + (u_cv - u)*pressure2 ) / (u_cv - u_iv)
spsoundh = sqrt(( ((u-u_iv)*(spsound3)**2) + ((u_cv-u)*(spsound2)**2) ) / (u_cv - u_iv))
if (spsoundh < spsoundmin) then
spsound = spsoundmin
endif
else ! rho < rho_iv Low energy state
pressure = pressure2 - (B*mu**2)
spsound = spsound2h
else ! (u >= u_cv) vaporised expanded state
pressure = pressure3
spsound = spsound3
endif
else ! (rho < rho_iv) then (u <u_cv) low energy expansion state
pressure = pressure2 - (B*mu_t**2)
spsound = spsound2h
endif
endif
else ! (rho >= rho0) compressed state
pressure = pressure2
spsound = spsound2
endif

! else ! (rho >= rho0) compressed state
! pressure = pressure2
! spsound = spsound2
! endif

! if (rho >= rho0) then ! compressed state
! pressure = pressure2
! spsound = spsound2
! else ! rho < rho0
! if (u >= u_cv) then ! vaporised expanded state
! pressure = pressure3
! spsound = spsound3
! ! need to check rho ~0 and u >> u_cv (zero density becomes pressure = rho*gamma*u fermi, gamma = 2/3)
! else ! u < u_cv
! ! if (rho >= rho_iv) then
! if (u > u_iv) then ! Hybrid state
! pressure = ( (u - u_iv)*pressure3 + (u_cv - u)*pressure2 ) / (u_cv - u_iv)
! spsound = sqrt(( ((u-u_iv)*(spsound3)**2) + ((u_cv-u)*(spsound2)**2) ) / (u_cv - u_iv))
! else ! u <= u_iv cold expanded
! pressure = pressure2
! spsound = spsound2
! endif
! ! else ! rho < rho_iv Low energy state
! ! pressure = pressure2 - (B*mu_t**2)
! ! spsound = spsound2h
! ! endif
! endif
! endif
! ! print*,' INSIDE EOS: rho ',rho,' u ',u,' OUT pres ',pressure

end subroutine equationofstate_tillotson

@@ -128,7 +158,7 @@ end subroutine equationofstate_tillotson
subroutine eos_info_tillotson(iprint)
integer, intent(in) :: iprint

write(iprint,"(/,a)") ' Tillotson EoS'
write(iprint,"(/,a)") ' Tillotson EoS',pressure

end subroutine eos_info_tillotson

@@ -142,83 +172,45 @@ subroutine calc_uT_from_rhoP_tillotson(rho,pres,temp,u,ierr)
real, intent(in) :: rho,pres
real, intent(out) :: temp,u
integer, intent(out) :: ierr
real :: eta, mu, neu, omega, expterm, expterm2, u1, u2, X, Y, quada, quadb, quadc
real :: eta, mu_t, neu, omega, expterm, expterm2, X, quada, quadb, quadc
real :: usol(3)
integer :: nsol

eta = rho / rho0
mu = eta - 1.
mu_t = eta - 1.
neu = (1. / eta) - 1. ! Kegerreis et al. 2020
omega = (u / (u0*eta**2) + 1.)
expterm2 = exp(-alpha*(neu**2))
expterm = exp(-beta*neu)

if (rho >= rho0) then ! compressed state
quada = 1.
X = (pres - (A*mu) - (B*(mu**2)))/rho
quadb = -((X-(aparam*u0*(eta**2))-(bparam*u0*(eta**2))) / aparam)
X = (pres - (A*mu_t) - (B*(mu_t**2)))/rho
quadb = ((-X/aparam)+(u0*(eta**2))+((bparam*u0*(eta**2))/aparam))
quadc = -((u0*(eta**2)*X)/aparam)
call cubicsolve(0.,quada,quadb,quadc,usol,nsol)
! call quadratic_eq(quada,quadb,quadc,u1,u2)
! if (u2 <= 0.) then
! u2 = 0.
! elseif (u2 == u1) then
! u = u1
! elseif (u2 > u1) then
! u = u1
! endif

! u = (((1./aparam)-(1./bparam))*(-A*mu - B*(mu**2))/ &
! (rho*(1. - ((-A*mu - B*(mu**2)+pres)/(bparam*(eta**2)*u0*rho)))))
! u = (mu*(eta**2)*u0*(aparam-bparam)*(A+(B*mu))) / &
! (aparam*(A*mu+bparam*(eta**2)*u0*rho+B*(mu**2)-pres))
u = maxval(usol(1:nsol))
elseif (rho >= rho_iv) then ! cold expanded
quada = 1.
X = (pres - (A*mu) - (B*(mu**2)))/rho
quadb = -((X-(aparam*u0*(eta**2))-(bparam*u0*(eta**2))) / aparam)
X = (pres - (A*mu_t) - (B*(mu_t**2)))/rho
quadb = ((-X/aparam)+(u0*(eta**2))+((bparam*u0*(eta**2))/aparam))
quadc = -((u0*(eta**2)*X)/aparam)
call cubicsolve(0.,quada,quadb,quadc,usol,nsol)
! call quadratic_eq(quada,quadb,quadc,u1,u2)
! if (u2 <= 0.) then
! u2 = 0.
! elseif (u2 == u1) then
! u = u1
! elseif (u2 > u1) then
! u = u1
! endif
! u = (((1./aparam)-(1./bparam))*(-A*mu - B*(mu**2))/ &
! (rho*(1. - ((-A*mu - B*(mu**2)+pres)/(bparam*(eta**2)*u0*rho)))))
! u = (mu*(eta**2)*u0*(aparam-bparam)*(A+(B*mu))) / &
! (aparam*(A*mu+bparam*(eta**2)*u0*rho+B*(mu**2)-pres))
u = maxval(usol(1:nsol))
elseif (rho < rho_iv) then ! rho < rho_iv Low energy state
quada = 1.
X = (pres - (A*mu))/rho
quadb = -((X-(aparam*u0*(eta**2))-(bparam*u0*(eta**2))) / aparam)
X = (pres - (A*mu_t))/rho
quadb = ((-X/aparam)+(u0*(eta**2))+((bparam*u0*(eta**2))/aparam))
quadc = -((u0*(eta**2)*X)/aparam)
call cubicsolve(0.,quada,quadb,quadc,usol,nsol)
! call quadratic_eq(quada,quadb,quadc,u1,u2)
! if (u2 <= 0.) then
! u2 = 0.
! elseif (u2 == u1) then
! u = u1
! elseif (u2 > u1) then
! u = u1
! endif
! u = ((-A*mu*((1./aparam)-(1./bparam))) /&
! (rho*(1.-((pres-A*mu)/(bparam*(eta**2)*u0*rho)))))
! u = (A*mu*(eta**2)*u0*(aparam-bparam)) / &
! (aparam*(A*mu+bparam*(eta**2)*u0*rho-pres))
u = maxval(usol(1:nsol))
else ! rho < rho0 vaporised expanded state
quada = 1.
X = (aparam*rho)/(expterm2)
quadb = ((bparam*rho*u0*(eta**2))+((aparam*rho*u0*(eta**2))/expterm2)+(A*mu*expterm)-(pres/(expterm2)))/X
quadc = ((A*mu*expterm*u0*(eta**2)) -((pres*u0*(eta**2))/expterm2))/X
X = (pres - (A*mu_t*expterm*expterm2))/rho
quadb = ((bparam*u0*(eta**2)*expterm2)/aparam)+((u0*(eta**2)))-(X/aparam)
quadc = -((X*u0*(eta**2))/aparam)
call cubicsolve(0.,quada,quadb,quadc,usol,nsol)
!call quadratic_eq(quada,quadb,quadc,u1,u2)
u = maxval(usol(1:nsol))
! u = ((eta**2)*u0*(bparam-aparam)*(pres-A*mu*expterm*expterm2) ) / &
! (aparam*rho*(A*mu*expterm + bparam*(eta**2)*u0 - pres))
! need to check rho ~0 and u >> u_cv (zero density becomes u = pres / (rho*gamma) fermi, gamma = 2/3)
endif

temp = 300.
@@ -227,40 +219,10 @@ subroutine calc_uT_from_rhoP_tillotson(rho,pres,temp,u,ierr)
u = 0.
ierr = 1
endif
! print*,' INSIDE EOS: rho ',rho,' pres ',pres,' OUT u ',u

end subroutine calc_uT_from_rhoP_tillotson

!-----------------------------------------------------------------------
!+
! calc quadratic for internal energy
!+
!-----------------------------------------------------------------------
! function quadratic_eq(a,b,c,x1,x2)
! real, intent(in) :: a,b,c
! real, intent(out) :: x1,x2
! real :: dis, sqrt_val

! dis = (b**2) - (4. * a * c) ! calc discriminant using formula
! sqrt_val = sqrt(abs(dis))

! if (dis > 0) then ! check discriminant
! ! real and different roots
! x1 = (-b + sqrt_val)/(2 * a)
! x2 = (-b - sqrt_val)/(2 * a)

! elseif (dis == 0) then
! ! real and same roots
! x1 = -b / (2. * a)
! x2 = x1

! else ! if discriminant < 0
! Complex Roots
! print(- b / (2 * a), + i, sqrt_val / (2 * a))
! print(- b / (2 * a), - i, sqrt_val / (2 * a))
! endif

! end function quadratic_eq

!-----------------------------------------------------------------------
!+
! reads equation of state options from the input file