From 34503277516adcf5d1f1cb39ae13ccccfb05b0e0 Mon Sep 17 00:00:00 2001 From: Caitlyn Hardiman Date: Mon, 14 Mar 2022 16:12:53 +1100 Subject: [PATCH] Law et al. 2021 stratified equation of state --- src/main/eos.F90 | 132 +++++++++++++++++++++++---- src/main/options.f90 | 2 +- src/main/readwrite_dumps_fortran.F90 | 47 ++-------- src/main/units.f90 | 14 ++- src/setup/set_disc.F90 | 4 +- src/setup/setup_disc.f90 | 85 ++++++++++++++--- 6 files changed, 211 insertions(+), 73 deletions(-) diff --git a/src/main/eos.F90 b/src/main/eos.F90 index 6dc4793c5..88d4e122f 100644 --- a/src/main/eos.F90 +++ b/src/main/eos.F90 @@ -43,12 +43,11 @@ module eos implicit none integer, parameter, public :: maxeos = 20 real, public :: polyk, polyk2, gamma - real, public :: qfacdisc + real, public :: qfacdisc = 0.75, qfacdisc2 = 0.75 logical, parameter, public :: use_entropy = .false. logical, public :: extract_eos_from_hdr = .false. - integer, public :: isink = 0 + integer, public :: isink = 0. - data qfacdisc /0.75/ public :: equationofstate,setpolyk,eosinfo,utherm,en_from_utherm,get_mean_molecular_weight public :: get_spsound,get_temperature,get_temperature_from_ponrho,eos_is_non_ideal,eos_outputs_mu @@ -58,6 +57,7 @@ module eos public :: calc_rec_ene,calc_temp_and_ene,entropy,get_rho_from_p_s public :: init_eos,finish_eos,write_options_eos,read_options_eos public :: print_eos_to_file + public :: write_headeropts_eos, read_headeropts_eos private @@ -82,6 +82,14 @@ module eos ierr_units_not_set = 3, & ierr_isink_not_set = 4 +! +! 2D temperature structure fit parameters for HD 163296 +! +real, public :: z0 = 1. +real, public :: alpha_z = 3.01 +real, public :: beta_z = 0.42 + + contains !---------------------------------------------------------------- @@ -108,11 +116,12 @@ subroutine equationofstate(eos_type,ponrhoi,spsoundi,rhoi,xi,yi,zi,eni,tempi,gam real, intent(inout), optional :: eni real, intent(inout), optional :: tempi,mu_local real, intent(in) , optional :: gamma_local,Xlocal,Zlocal - real :: r,omega,bigH,polyk_new,r1,r2 + real :: r1,r2 real :: gammai,temperaturei,mui,imui,X_i,Z_i real :: cgsrhoi,cgseni,cgspresi,presi,gam1,cgsspsoundi integer :: ierr real :: uthermconst + real :: zq,cs2atm,cs2mid,cs2 #ifdef GR real :: enthi,pondensi ! Check to see if adiabatic equation of state is being used. @@ -207,21 +216,15 @@ subroutine equationofstate(eos_type,ponrhoi,spsoundi,rhoi,xi,yi,zi,eni,tempi,gam case(7) ! !-- z-dependent locally isothermal eos -! - r = sqrt(xi**2 + yi**2 + zi**2) - omega = r**(-1.5) - bigH = (sqrt(polyk)*r**(-qfacdisc))/omega - - if (abs(zi) <= bigH) then - polyk_new = polyk - elseif (abs(zi) <= 2.0*bigH) then - polyk_new = polyk*(1.0+99.0*(abs(zi)-bigH)) - else - polyk_new = 100.0*polyk - endif - - ponrhoi = polyk_new*(xi**2 + yi**2 + zi**2)**(-qfacdisc) - spsoundi = sqrt(ponrhoi) + r2 = xi**2 + yi**2 + cs2mid = polyk * r2**(-qfacdisc) + cs2atm = polyk2 * r2**(-qfacdisc2) + zq = z0 * r2**(0.5*beta_z) + + ! modified equation 6 from Law et al. (2021) + cs2 = (cs2mid**4 + 0.5*(1 + tanh((zi - alpha_z*zq)/zq))*cs2atm**4)**(1./4.) + ponrhoi = cs2 + spsoundi = sqrt(cs2) if (present(tempi)) tempi = temperature_coef*mui*ponrhoi case(8) @@ -1129,4 +1132,95 @@ real function get_mean_molecular_weight(XX,ZZ) result(mu) end function get_mean_molecular_weight +!----------------------------------------------------------------------- +!+ +! write relevant options to the header of the dump file +!+ +!----------------------------------------------------------------------- +subroutine write_headeropts_eos(ieos,hdr,ierr) + use dump_utils, only:dump_h,add_to_rheader,add_to_iheader + integer, intent(in) :: ieos + type(dump_h), intent(inout) :: hdr + integer, intent(out) :: ierr + + call add_to_iheader(isink,'isink',hdr,ierr) + call add_to_rheader(gamma,'gamma',hdr,ierr) + call add_to_rheader(1.5*polyk,'RK2',hdr,ierr) + call add_to_rheader(polyk2,'polyk2',hdr,ierr) + call add_to_rheader(qfacdisc,'qfacdisc',hdr,ierr) + call add_to_rheader(qfacdisc2,'qfacdisc2',hdr,ierr) + + if (ieos==7) then + call add_to_rheader(alpha_z,'alpha_z',hdr,ierr) + call add_to_rheader(beta_z,'beta_z',hdr,ierr) + call add_to_rheader(z0,'z0',hdr,ierr) + + endif + +end subroutine write_headeropts_eos + +!----------------------------------------------------------------------- +!+ +! read relevant options from the header of the dump file +!+ +!----------------------------------------------------------------------- +subroutine read_headeropts_eos(ieos,hdr,ierr) + use dump_utils, only:dump_h, extract + use io, only:iprint,id,master + use dim, only:use_krome,maxvxyzu + integer, intent(in) :: ieos + type(dump_h), intent(in) :: hdr + integer, intent(out) :: ierr + real :: RK2 + + + call extract('gamma',gamma,hdr,ierr) + call extract('RK2',rk2,hdr,ierr) + polyk = 2./3.*rk2 + if (id==master) then + if (maxvxyzu >= 4) then + if (use_krome) then + write(iprint,*) 'KROME eos: initial gamma = 1.666667' + else + write(iprint,*) 'adiabatic eos: gamma = ',gamma + endif + else + write(iprint,*) 'setting isothermal sound speed^2 (polyk) = ',polyk,' gamma = ',gamma + if (polyk <= tiny(polyk)) write(iprint,*) 'WARNING! sound speed zero in dump!, polyk = ',polyk + endif + endif + call extract('polyk2',polyk2,hdr,ierr) + call extract('qfacdisc',qfacdisc,hdr,ierr) + call extract('qfacdisc2',qfacdisc2,hdr,ierr) + call extract('isink',isink,hdr,ierr) + + if (abs(gamma-1.) > tiny(gamma) .and. maxvxyzu < 4) then + write(*,*) 'WARNING! compiled for isothermal equation of state but gamma /= 1, gamma=',gamma + endif + + ierr = 0 + if (ieos==3 .or. ieos==6 .or. ieos==7) then + if (qfacdisc <= tiny(qfacdisc)) then + write(iprint,*) 'ERROR: qfacdisc <= 0' + ierr = 2 + else + write(iprint,*) 'qfacdisc = ',qfacdisc + endif + endif + + if (ieos==7) then + call extract('alpha_z',alpha_z,hdr,ierr) + call extract('beta_z', beta_z, hdr,ierr) + call extract('z0',z0,hdr,ierr) + if (qfacdisc2 <= tiny(qfacdisc2)) then + write(iprint,*) 'ERROR: qfacdisc2 <= 0' + ierr = 2 + else + write(iprint,*) 'qfacdisc2 = ',qfacdisc2 + endif + endif + +end subroutine read_headeropts_eos + + end module eos diff --git a/src/main/options.f90 b/src/main/options.f90 index 2124685ce..c5d672870 100644 --- a/src/main/options.f90 +++ b/src/main/options.f90 @@ -104,7 +104,7 @@ subroutine set_default_options ipdv_heating = 1 iresistive_heating = 1 icooling = 0 - polyk2 = 0 ! only used for ieos=8 + polyk2 = 0. ! only used for ieos=8 ! artificial viscosity if (maxalpha>0 .and. maxalpha==maxp) then diff --git a/src/main/readwrite_dumps_fortran.F90 b/src/main/readwrite_dumps_fortran.F90 index c7e23f8d0..2b5f0f83e 100644 --- a/src/main/readwrite_dumps_fortran.F90 +++ b/src/main/readwrite_dumps_fortran.F90 @@ -1492,7 +1492,7 @@ end subroutine unfill_header !+ !------------------------------------------------------------------- subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,ierr) - use eos, only:polyk,gamma,polyk2,qfacdisc,isink + use eos, only:write_headeropts_eos,polyk2 use options, only:tolh,alpha,alphau,alphaB,iexternalforce,ieos use part, only:massoftype,hfact,Bextx,Bexty,Bextz,ndustsmall,ndustlarge,& idust,grainsize,graindens,ndusttypes @@ -1519,7 +1519,6 @@ subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,i call add_to_iheader(maxtypes,'ntypes',hdr,ierr) call add_to_iheader(int(npartoftypetot(1:maxtypes)),'npartoftype',hdr,ierr) call add_to_iheader(nblocks,'nblocks',hdr,ierr) - call add_to_iheader(isink,'isink',hdr,ierr) call add_to_iheader(nptmass,'nptmass',hdr,ierr) call add_to_iheader(ndustlarge,'ndustlarge',hdr,ierr) call add_to_iheader(ndustsmall,'ndustsmall',hdr,ierr) @@ -1536,6 +1535,7 @@ subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,i ! int*4 call add_to_header(iexternalforce,'iexternalforce',hdr,ierr) call add_to_header(ieos,'ieos',hdr,ierr) + call write_headeropts_eos(ieos,hdr,ierr) ! default real variables call add_to_rheader(t,'time',hdr,ierr) @@ -1545,9 +1545,7 @@ subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,i else call add_to_rheader(dtmax, 'dtmax0',hdr,ierr) endif - call add_to_rheader(gamma,'gamma',hdr,ierr) call add_to_rheader(rhozero,'rhozero',hdr,ierr) - call add_to_rheader(1.5*polyk,'RK2',hdr,ierr) if (sphNGdump) then ! number = 23 call add_to_rheader(0.,'escaptot',hdr,ierr) call add_to_rheader(0.,'tkin',hdr,ierr) @@ -1575,8 +1573,6 @@ subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,i call add_to_rheader(alpha,'alpha',hdr,ierr) call add_to_rheader(alphau,'alphau',hdr,ierr) call add_to_rheader(alphaB,'alphaB',hdr,ierr) - call add_to_rheader(polyk2,'polyk2',hdr,ierr) - call add_to_rheader(qfacdisc,'qfacdisc',hdr,ierr) call add_to_rheader(massoftype,'massoftype',hdr,ierr) ! array call add_to_rheader(Bextx,'Bextx',hdr,ierr) call add_to_rheader(Bexty,'Bexty',hdr,ierr) @@ -1626,7 +1622,7 @@ subroutine unfill_rheader(hdr,phantomdump,ntypesinfile,nptmass,& tfile,hfactfile,alphafile,iprint,ierr) use io, only:id,master use dim, only:maxvxyzu,use_dust,use_dustgrowth,use_krome - use eos, only:polyk,gamma,polyk2,qfacdisc,extract_eos_from_hdr + use eos, only:extract_eos_from_hdr, read_headeropts_eos use options, only:ieos,iexternalforce use part, only:massoftype,Bextx,Bexty,Bextz,mhd,periodic,& maxtypes,grainsize,graindens,ndusttypes @@ -1646,7 +1642,7 @@ subroutine unfill_rheader(hdr,phantomdump,ntypesinfile,nptmass,& integer, parameter :: lu = 173 integer :: ierrs(10),iextern_in_file - real :: rk2,xmini,xmaxi,ymini,ymaxi,zmini,zmaxi,dtmaxi + real :: xmini,xmaxi,ymini,ymaxi,zmini,zmaxi,dtmaxi real :: alphaufile,alphaBfile,C_courfile,C_forcefile,tolhfile logical :: iexist @@ -1655,23 +1651,7 @@ subroutine unfill_rheader(hdr,phantomdump,ntypesinfile,nptmass,& if (ierr/=0) call extract('gt',tfile,hdr,ierr) ! this is sphNG's label for time call extract('dtmax',dtmaxi,hdr,ierr) call extract('dtmax0',dtmax0,hdr,ierr) - call extract('gamma',gamma,hdr,ierr) call extract('rhozero',rhozero,hdr,ierr) - call extract('RK2',rk2,hdr,ierr) - polyk = 2./3.*rk2 - if (id==master) then - if (maxvxyzu >= 4) then - if (use_krome) then - write(iprint,*) 'KROME eos: initial gamma = 1.666667' - else - write(iprint,*) 'adiabatic eos: gamma = ',gamma - endif - else - write(iprint,*) 'setting isothermal sound speed^2 (polyk) = ',polyk,' gamma = ',gamma - if (polyk <= tiny(polyk)) write(iprint,*) 'WARNING! sound speed zero in dump!, polyk = ',polyk - endif - endif - Bextx = 0. Bexty = 0. Bextz = 0. @@ -1689,17 +1669,9 @@ subroutine unfill_rheader(hdr,phantomdump,ntypesinfile,nptmass,& if (mhd) then call extract('alphaB',alphaBfile,hdr,ierr) endif - call extract('polyk2',polyk2,hdr,ierr) - call extract('qfacdisc',qfacdisc,hdr,ierr) + if (extract_eos_from_hdr) call extract('ieos',ieos,hdr,ierr) - if (ieos==3) then - if (qfacdisc <= tiny(qfacdisc)) then - write(iprint,*) 'ERROR: qfacdisc <= 0' - ierr = 2 - else - write(iprint,*) 'qfacdisc = ',qfacdisc - endif - endif + call extract('massoftype',massoftype(1:ntypesinfile),hdr,ierr) if (ierr /= 0) then write(*,*) '*** ERROR reading massoftype from dump header ***' @@ -1716,10 +1688,11 @@ subroutine unfill_rheader(hdr,phantomdump,ntypesinfile,nptmass,& endif else massoftype(1) = 0. - polyk2 = 0. hfactfile = 0. endif + call read_headeropts_eos(ieos,hdr,ierr) + if (periodic) then call extract('xmin',xmini,hdr,ierrs(1)) call extract('xmax',xmaxi,hdr,ierrs(2)) @@ -1772,9 +1745,7 @@ subroutine unfill_rheader(hdr,phantomdump,ntypesinfile,nptmass,& write(*,*) 'ERROR reading values to verify conservation laws. Resetting initial values.' get_conserv = 1.0 endif - if (abs(gamma-1.) > tiny(gamma) .and. maxvxyzu < 4) then - write(*,*) 'WARNING! compiled for isothermal equation of state but gamma /= 1, gamma=',gamma - endif + !--pull grain size and density arrays if they are in the header !-- i.e. if dustgrowth is not ON diff --git a/src/main/units.f90 b/src/main/units.f90 index d1b876ad8..6db02a8aa 100644 --- a/src/main/units.f90 +++ b/src/main/units.f90 @@ -30,7 +30,7 @@ module units real(kind=8), public :: unit_ergg, unit_energ, unit_opacity public :: set_units, set_units_extra, print_units - public :: get_G_code, get_c_code, get_radconst_code + public :: get_G_code, get_c_code, get_radconst_code, get_kbmh_code public :: c_is_unity, G_is_unity, in_geometric_units contains @@ -304,6 +304,18 @@ real(kind=8) function get_radconst_code() result(radconst_code) radconst_code = radconst/unit_energ*udist**3 end function get_radconst_code +!--------------------------------------------------------------------------- +!+ +! speed of light in code units +!+ +!--------------------------------------------------------------------------- +real(kind=8) function get_kbmh_code() result(kbmh_code) + use physcon, only:kb_on_mh + + kbmh_code = kb_on_mh/unit_velocity**2 + +end function get_kbmh_code + !--------------------------------------------------------------------------- !+ ! whether or not the Gravitational constant is unity in code units diff --git a/src/setup/set_disc.F90 b/src/setup/set_disc.F90 index 4a189e0cc..46ae5497e 100644 --- a/src/setup/set_disc.F90 +++ b/src/setup/set_disc.F90 @@ -940,9 +940,9 @@ subroutine write_discinfo(iunit,R_in,R_out,R_ref,Q,npart,sigmaprofile, & !--print some of these diagnostics in more useful form if (itype == igas) then if (T_ref < 1.0d3) then - write(iunit,"(a,f5.1,a,f5.1,a,f4.1,a,/)") '# Temperature profile = ',T_ref,'K (R/',R_ref,')^(',-2.*q_index,')' + write(iunit,"(a,f5.1,a,f5.1,a,f5.2,a,/)") '# Temperature profile = ',T_ref,'K (R/',R_ref,')^(',-2.*q_index,')' else - write(iunit,"(a,es9.2,a,f5.1,a,f4.1,a,/)") '# Temperature profile = ',T_ref,'K (R/',R_ref,')^(',-2.*q_index,')' + write(iunit,"(a,es9.2,a,f5.1,a,f5.2,a,/)") '# Temperature profile = ',T_ref,'K (R/',R_ref,')^(',-2.*q_index,')' endif endif if (sigmaprofile==0) then diff --git a/src/setup/setup_disc.f90 b/src/setup/setup_disc.f90 index 56aae271f..becd2fc24 100644 --- a/src/setup/setup_disc.f90 +++ b/src/setup/setup_disc.f90 @@ -68,6 +68,7 @@ module setup ! - subst : *star to substitute* ! - surface_force : *model m1 as planet with surface* ! - use_mcfost : *use the mcfost library* +! - discstrat : *stratify disc? (0=no,1=yes)* ! ! :Dependencies: centreofmass, dim, dust, eos, extern_binary, ! extern_corotate, extern_lensethirring, externalforces, fileutils, @@ -122,6 +123,10 @@ module setup real :: bhspin,bhspinangle logical :: einst_prec + !--stratification + real :: temp_atm0,temp_mid0 + real :: z0_ref + !--discs integer, parameter :: maxdiscs = 4 @@ -172,8 +177,8 @@ module setup character(len=*), dimension(maxplanets), parameter :: planets = & (/'1','2','3','4','5','6','7','8','9' /) - logical :: questplanets - integer :: nplanets,setplanets + logical :: questplanets,istratify + integer :: nplanets,setplanets, discstrat real :: mplanet(maxplanets),rplanet(maxplanets) real :: accrplanet(maxplanets),inclplan(maxplanets) real :: period_planet_longest @@ -239,15 +244,15 @@ subroutine setpart(id,npart,npartoftype,xyzh,massoftype,vxyzu,polyk,gamma,hfact, !--compute number of discs based on setup options call number_of_discs() + !--setup central object(s), i.e. sink particle(s) or potential + call setup_central_objects() + !--setup equation of state call equation_of_state(gamma) !--set surface density profile based on setup options call surface_density_profile() - !--setup central object(s), i.e. sink particle(s) or potential - call setup_central_objects() - !--setup grain size distribution call setup_dust_grain_distribution() @@ -425,6 +430,13 @@ subroutine set_default_options() accrplanet = 0.25 inclplan = 0. + !--stratification + istratify = .false. + discstrat = 0 + temp_mid0 = 24. + temp_atm0 = 63. + z0_ref = 9. + !--simulation time deltat = 0.1 norbits = 100 @@ -551,10 +563,11 @@ end subroutine number_of_discs ! !-------------------------------------------------------------------------- subroutine equation_of_state(gamma) - use eos, only:isink,qfacdisc + use eos, only:isink,qfacdisc,qfacdisc2,polyk2,beta_z,z0 use options, only:ieos,icooling use options, only:nfulldump,alphau,ipdv_heating,ishock_heating real, intent(out) :: gamma + real :: H_R_atm, cs logical :: is_isothermal integer :: i @@ -609,9 +622,18 @@ subroutine equation_of_state(gamma) ieos = 6 print "(/,a)",' setting ieos=6 for locally isothermal disc around sink' else - ieos = 3 + if (discstrat > 0) then + ieos = 7 + print "(/,a)",' setting ieos=7 for locally isothermal disc with stratification' + call temp_to_HR(temp_mid0,H_R(onlydisc),R_ref(onlydisc),mcentral,cs) + call temp_to_HR(temp_atm0,H_R_atm,R_ref(onlydisc),mcentral,cs) + polyk2 = (cs*(1./R_ref(onlydisc))**qfacdisc2)**2 + z0 = z0_ref/R_ref(onlydisc)**beta_z + else + ieos = 3 + print "(/,a)",' setting ieos=3 for locally isothermal disc around origin' + end if isink = 0 ! In the case isink==3, to be generalized - print "(/,a)",' setting ieos=3 for locally isothermal disc around origin' endif qfacdisc = qindex(onlydisc) endif @@ -2055,6 +2077,7 @@ end subroutine setup_interactive ! !-------------------------------------------------------------------------- subroutine write_setupfile(filename) + use eos, only:alpha_z,beta_z,qfacdisc2 use infile_utils, only:write_inopt use set_dust_options, only:write_dust_setup_options character(len=*), intent(in) :: filename @@ -2284,11 +2307,11 @@ subroutine write_setupfile(filename) case (4) call write_inopt(Q_min(i),'Q_min'//trim(disclabel),'minimum Toomre Q',iunit) end select - call write_inopt(pindex(i),'pindex'//trim(disclabel),'p index',iunit) - call write_inopt(qindex(i),'qindex'//trim(disclabel),'q index',iunit) + call write_inopt(pindex(i),'pindex'//trim(disclabel),'power law index of surface density sig=sig0*r^-p',iunit) + call write_inopt(qindex(i),'qindex'//trim(disclabel),'power law index of sound speed cs=cs0*r^-q',iunit) call write_inopt(posangl(i),'posangl'//trim(disclabel),'position angle (deg)',iunit) call write_inopt(incl(i),'incl'//trim(disclabel),'inclination (deg)',iunit) - call write_inopt(H_R(i),'H_R'//trim(disclabel),'H/R at R=R_ref',iunit) + if (discstrat == 0) call write_inopt(H_R(i),'H_R'//trim(disclabel),'H/R at R=R_ref',iunit) if (iwarp(i)) then call write_inopt(R_warp(i),'R_warp'//trim(disclabel),'warp radius',iunit) call write_inopt(H_warp(i),'H_warp'//trim(disclabel),'warp smoothing length',iunit) @@ -2343,6 +2366,18 @@ subroutine write_setupfile(filename) call write_inopt(accrplanet(i),'accrplanet'//trim(planets(i)),'planet accretion radius (in Hill radius)',iunit) enddo endif + ! stratification + write(iunit,"(/,a)") '# thermal stratification' + call write_inopt(discstrat,'discstrat','stratify disc? (0=no,1=yes)',iunit) + if (discstrat==1) then + call write_inopt(z0_ref,'z0', 'z scaling factor',iunit) + call write_inopt(alpha_z,'alpha_z', 'height of transition in tanh vertical temperature profile',iunit) + call write_inopt(beta_z,'beta_z', 'variation in transition height over radius',iunit) + call write_inopt(temp_mid0,'temp_mid0', 'midplane temperature scaling factor',iunit) + call write_inopt(temp_atm0,'temp_atm0', 'atmosphere temperature scaling factor',iunit) + call write_inopt(qfacdisc2,'qatm', 'sound speed power law index of atmosphere',iunit) + + endif !--timestepping write(iunit,"(/,a)") '# timestepping' if (setplanets==1) then @@ -2376,6 +2411,7 @@ end subroutine write_setupfile ! !-------------------------------------------------------------------------- subroutine read_setupfile(filename,ierr) + use eos, only:alpha_z,beta_z,qfacdisc2 use dust, only:ilimitdustflux use infile_utils, only:open_db_from_file,inopts,read_inopt,close_db use set_dust_options, only:read_dust_setup_options,ilimitdustfluxinp @@ -2509,6 +2545,16 @@ subroutine read_setupfile(filename,ierr) end select end select + call read_inopt(discstrat,'discstrat',db,errcount=nerr) + if (discstrat==1) then + call read_inopt(z0_ref,'z0',db,errcount=nerr) + call read_inopt(alpha_z,'alpha_z',db,errcount=nerr) + call read_inopt(beta_z,'beta_z',db,errcount=nerr) + call read_inopt(temp_mid0,'temp_mid0',db,errcount=nerr) + call read_inopt(temp_atm0,'temp_atm0',db,errcount=nerr) + call read_inopt(qfacdisc2,'qatm',db,errcount=nerr) + endif + !--dust if (use_dust) then call read_dust_setup_options(db,nerr) @@ -2599,7 +2645,7 @@ subroutine read_setupfile(filename,ierr) call read_inopt(qindex(i),'qindex'//trim(disclabel),db,errcount=nerr) call read_inopt(posangl(i),'posangl'//trim(disclabel),db,min=0.,max=360.,errcount=nerr) call read_inopt(incl(i),'incl'//trim(disclabel),db,min=0.,max=180.,errcount=nerr) - call read_inopt(H_R(i),'H_R'//trim(disclabel),db,min=0.,errcount=nerr) + if (discstrat == 0) call read_inopt(H_R(i),'H_R'//trim(disclabel),db,min=0.,errcount=nerr) call read_inopt(iwarp(i),'iwarp'//trim(disclabel),db,errcount=nerr) if (iwarp(i)) then call read_inopt(R_warp(i),'R_warp'//trim(disclabel),db,min=0.,errcount=nerr) @@ -2830,4 +2876,19 @@ subroutine make_corotate(xyzh,vxyzu,a0,Mstar,npart,npart_disc) end subroutine make_corotate + +subroutine temp_to_HR(temp,H_R,radius,M,cs) + use units, only:get_kbmh_code + use eos, only:gmw + real, intent(in) :: temp,radius,M + real, intent(out) :: H_R,cs + real :: omega + + cs = sqrt(temp*get_kbmh_code()/gmw) + omega = sqrt(M/radius**3) + H_R = cs/(omega*radius) + + +end subroutine temp_to_HR + end module setup