Skip to content

Commit

Permalink
new moddump that converts non-radiative dump to radiative dump
Browse files Browse the repository at this point in the history
  • Loading branch information
themikelau committed Apr 2, 2024
1 parent 99a7583 commit 8444d66
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
68 changes: 68 additions & 0 deletions src/utils/moddump_LTE_to_rad.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
!--------------------------------------------------------------------------!
! 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 moddump
!
! Convert non-radiation dump (assuming LTE, ieos=12) to radiation dump
!
! :References: None
!
! :Owner: Mike Lau
!
! :Runtime parameters: None
!
! :Dependencies: dim, eos, io, part
!
implicit none

contains

subroutine modify_dump(npart,npartoftype,massoftype,xyzh,vxyzu)
use units, only:unit_density,unit_opacity,unit_ergg
use dim, only:do_radiation
use io, only:fatal
use eos, only:gmw,gamma,X_in,Z_in
use eos_idealplusrad, only:get_idealplusrad_temp
use eos_mesa, only:init_eos_mesa
use part, only:igas,rad,iradxi,ikappa,rhoh,radprop,ithick
use radiation_utils, only:radiation_and_gas_temperature_equal,ugas_from_Tgas
use mesa_microphysics,only:get_kappa_mesa
integer, intent(inout) :: npart
integer, intent(inout) :: npartoftype(:)
real, intent(inout) :: massoftype(:)
real, intent(inout) :: xyzh(:,:),vxyzu(:,:)
integer :: i,ierr
real :: pmass,mu,rhoi,kappa_cgs,kapt,kapr,rho_cgs,ugasi,tempi,gamma_fixed

if (.not. do_radiation) call fatal("moddump_LTE_to_rad","Not compiled with radiation")

mu = gmw
gamma_fixed = 5/3. ! gamma should be exactly 5/3, because that is what ieos=12 assumes
gamma = gamma_fixed
print*,'Assuming gmw = ',mu,' and gamma=',gamma,'X = ',X_in,'Z = ',Z_in ! X and Z are only used for calculating opacity
call init_eos_mesa(X_in,Z_in,ierr)

pmass = massoftype(igas)
do i=1,npart
rhoi = rhoh(xyzh(4,i),pmass)
rho_cgs = rhoi*unit_density
call get_idealplusrad_temp(rho_cgs,vxyzu(4,i)*unit_ergg,mu,tempi,ierr)

! calculate u and xi
ugasi = ugas_from_Tgas(tempi,gamma,gmw)
vxyzu(4,i) = ugasi
rad(iradxi,i) = radiation_and_gas_temperature_equal(rhoi,ugasi,gamma,mu)

! calculate opacity
call get_kappa_mesa(rho_cgs,tempi,kappa_cgs,kapt,kapr)
radprop(ikappa,i) = kappa_cgs/unit_opacity
radprop(ithick,i) = 1.
enddo

end subroutine modify_dump

end module moddump

4 changes: 0 additions & 4 deletions src/utils/moddump_rad_to_LTE.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ subroutine modify_dump(npart,npartoftype,massoftype,xyzh,vxyzu)
vxyzu(4,i) = vxyzu(4,i) + rad(iradxi,i)
enddo

ieos = 12
gmw = 0.6 ! CHANGE MU HERE for writing into infile
print*,'mu has been changed to',gmw ! mu should not change from what was assumed with radiation

end subroutine modify_dump

end module moddump
Expand Down

0 comments on commit 8444d66

Please sign in to comment.