findT Subroutine

public subroutine findT(tpoint, Ypoint, fl)

Arguments

Type IntentOptional Attributes Name
double precision, intent(out) :: tpoint
double precision, intent(in) :: Ypoint
type(rc_fluid), intent(in) :: fl

Called by

proc~~findt~2~~CalledByGraph proc~findt~2 findT proc~cool_exact~2 cool_exact proc~cool_exact~2->proc~findt~2 proc~getvar_cooling_exact~2 getvar_cooling_exact proc~getvar_cooling_exact~2->proc~findt~2 proc~radiative_cooling_add_source~2 radiative_cooling_add_source proc~radiative_cooling_add_source~2->proc~cool_exact~2

Source Code

    subroutine findT (tpoint,Ypoint,fl)
    !  Fast search option to find correct temperature 
    !  from temporal evolution function. Only possible this way because T is a monotonously
    !  decreasing function for the interpolated tables
    !  Uses eq. A7 from Townsend 2009 for piecewise power laws
      

      double precision,intent(OUT)   :: tpoint
      double precision, intent(IN) :: Ypoint
      type(rc_fluid), intent(in) :: fl

      double precision :: factor
      integer :: jl,jc,jh,i

      if(Ypoint >= fl%Yc(1)) then
        tpoint = fl%tcoolmin
      else if (Ypoint == fl%Yc(fl%ncool)) then
        tpoint = fl%tcoolmax
      else
        jl=0
        jh=fl%ncool+1
        do
          if(jh-jl <= 1) exit
          jc=(jh+jl)/2
          if(Ypoint <= fl%Yc(jc)) then
            jl=jc
          else
            jh=jc
          end if
        end do
        ! Linear interpolation to obtain correct temperature
        tpoint = fl%tcool(jl)+ (Ypoint-fl%Yc(jl)) &
                * (fl%tcool(jl+1)-fl%tcool(jl)) &
                / (fl%Yc(jl+1)-fl%Yc(jl))
      end if

    end subroutine findT