HHH_derivatives Subroutine

public subroutine HHH_derivatives(me, rostarIn, g, dRostardUin, deriv_wr_both_br)

Arguments

Type IntentOptional Attributes Name
type(circulator_t), intent(inout) :: me
real(kind=dp), intent(in) :: rostarIn
real(kind=dp), intent(in) :: g
real(kind=dp), intent(in), dimension(:) :: dRostardUin
type(derivatives_involving_both_branches_t), intent(inout) :: deriv_wr_both_br

Calls

proc~~hhh_derivatives~~CallsGraph proc~hhh_derivatives HHH_derivatives proc~jacobian_rot jacobian_roT proc~hhh_derivatives->proc~jacobian_rot proc~eos_terms eos_terms proc~jacobian_rot->proc~eos_terms proc~eos_e_terms eos_e_terms proc~eos_terms->proc~eos_e_terms proc~fill_f_terms fill_f_terms proc~eos_terms->proc~fill_f_terms proc~fill_e_tpart fill_e_Tpart proc~eos_e_terms->proc~fill_e_tpart proc~fill_ff_terms fill_ff_terms proc~eos_e_terms->proc~fill_ff_terms proc~fill_g_dreg_terms fill_g_Dreg_terms proc~fill_e_tpart->proc~fill_g_dreg_terms

Called by

proc~~hhh_derivatives~~CalledByGraph proc~hhh_derivatives HHH_derivatives proc~incoming_branch_cold_circulator incoming_branch_cold_circulator proc~incoming_branch_cold_circulator->proc~hhh_derivatives proc~circulator_resolution_from_and_to_ports circulator_resolution_from_and_to_ports proc~circulator_resolution_from_and_to_ports->proc~incoming_branch_cold_circulator proc~main_loop main_loop proc~main_loop->proc~circulator_resolution_from_and_to_ports program~reims_p reims_p program~reims_p->proc~main_loop

Source Code

subroutine HHH_derivatives(me,rostarIn,g,dRostardUin,deriv_wr_both_br)
      type(circulator_t), intent(inout) :: me
      real(dp), intent(in) :: rostarIn,g
      real(dp), dimension(:), intent(in) :: dRostardUin
      type(derivatives_involving_both_branches_t), intent(inout) :: deriv_wr_both_br

      real(dp) :: dPres,dHHHdPin,dHHHdPout,dHHHdRostarIn,eps,f_ro,Ro_a,Ro_b
      real(dp), dimension(Nb_VarC) :: dPindUin,dPoutdUout,df_ro_DUin,df_ro_DUout
      real(dp) :: kk, KKK, dedT, dPdT, HH, dPde

      if(me%SubType=="pump") then

        Ro_a=me%br(1)%p%Prim(Pri_ro)
        Ro_b=me%br(2)%p%Prim(Pri_ro)
        f_ro=(1.0_dp/Ro_a+1.0_dp/Ro_b)
        dPres=me%br(2)%p%Prim(Pri_P)-me%br(1)%p%Prim(Pri_P)

        df_ro_DUin(1)=-1.0_dp/(Ro_a**2)
        df_ro_DUin(2:4)=0.0_dp

        df_ro_DUout(1)=-1.0_dp/(Ro_b**2)
        df_ro_DUout(2:4)=0.0_dp

        if(R_Correction) then
          dPindUin(1)=-0.5_dp*(me%br(1)%p%Cons(Con_Qdm)**2)/(me%br(1)%p%Cons(Con_Mas)**2)
          dPindUin(2)=me%br(1)%p%Cons(Con_Qdm)/me%br(1)%p%Cons(Con_Mas)
          dPindUin(3)=-1.0_dp
          dPindUin(4)=1.0_dp
  
          dPoutdUout(1)=-0.5_dp*(me%br(2)%p%Cons(Con_Qdm)**2)/(me%br(2)%p%Cons(Con_Mas)**2)
          dPoutdUout(2)=me%br(2)%p%Cons(Con_Qdm)/me%br(2)%p%Cons(Con_Mas)
          dPoutdUout(3)=-1.0_dp
          dPoutdUout(4)=1.0_dp        
        else
          HH=me%br(1)%p%Prim(Pri_e)+me%br(1)%p%Prim(Pri_P)/me%br(1)%p%Prim(Pri_ro)+0.5_dp*me%br(1)%p%Prim(Pri_u)**2
          call jacobian_roT(me%br(1)%p%Prim(Pri_ro), me%br(1)%p%Prim(Pri_T), dedT, dPdT)
          dPde=dPdT/dedT
          kk=dPde/me%br(1)%p%Prim(Pri_ro)
          KKK=me%br(1)%p%Prim(Pri_c)**2+kk*(me%br(1)%p%Prim(Pri_u)**2-HH)
          dPindUin(1)=KKK
          dPindUin(2)=-kk*me%br(1)%p%Prim(Pri_u)
          dPindUin(3)=kk
          dPindUin(4)=0.0_dp
  
          HH=me%br(2)%p%Prim(Pri_e)+me%br(2)%p%Prim(Pri_P)/me%br(2)%p%Prim(Pri_ro)+0.5_dp*me%br(2)%p%Prim(Pri_u)**2
          call jacobian_roT(me%br(2)%p%Prim(Pri_ro), me%br(2)%p%Prim(Pri_T), dedT, dPdT)
          dPde=dPdT/dedT
          kk=dPde/me%br(2)%p%Prim(Pri_ro)
          KKK=me%br(2)%p%Prim(Pri_c)**2+kk*(me%br(2)%p%Prim(Pri_u)**2-HH)
          dPoutdUout(1)=KKK
          dPoutdUout(2)=-kk*me%br(2)%p%Prim(Pri_u)
          dPoutdUout(3)=kk
          dPoutdUout(4)=0.0_dp  
        endif

        deriv_wr_both_br%DerHHHdUin(:)=0.5_dp*(df_ro_DUin(:)*dPres+f_ro*(-dPindUin(:)))
        deriv_wr_both_br%DerHHHdUout(:)=0.5_dp*(df_ro_DUout(:)*dPres+f_ro*dPoutdUout(:))
        
      else if(me%SubType=="compressor") then

        eps=1.0e-3_dp
        dPres=me%br(2)%p%Prim(Pri_P)-me%br(1)%p%Prim(Pri_P)
  
        if(dPres<=0.0_dp) then
          deriv_wr_both_br%DerHHHdUin(:)=-(me%dp0/g)*dRostardUin(:)/(rostarIn**2)
          deriv_wr_both_br%DerHHHdUout(:)=0.0_dp
        else if(dPres>=me%dp0) then
          deriv_wr_both_br%DerHHHdUin(:)=-(eps*me%dp0/g)*dRostardUin(:)/(rostarIn**2)
          deriv_wr_both_br%DerHHHdUout(:)=0.0_dp
        else
          dHHHdPin=2.0_dp*(me%dp0/(rostarIn*g))*dPres/(me%dp0**2)
          dHHHdRostarIn=-(me%dp0/g)*(1.0_dp-(dPres/me%dp0)**2)/(rostarIn**2)
  
          dHHHdPout=-2.0_dp*(me%dp0/(rostarIn*g))*dPres/(me%dp0**2)
  
          if(R_Correction) then
            dPindUin(1)=-0.5_dp*(me%br(1)%p%Cons(Con_Qdm)**2)/(me%br(1)%p%Cons(Con_Mas)**2)
            dPindUin(2)=me%br(1)%p%Cons(Con_Qdm)/me%br(1)%p%Cons(Con_Mas)
            dPindUin(3)=-1.0_dp
            dPindUin(4)=1.0_dp
    
            dPoutdUout(1)=-0.5_dp*(me%br(2)%p%Cons(Con_Qdm)**2)/(me%br(2)%p%Cons(Con_Mas)**2)
            dPoutdUout(2)=me%br(2)%p%Cons(Con_Qdm)/me%br(2)%p%Cons(Con_Mas)
            dPoutdUout(3)=-1.0_dp
            dPoutdUout(4)=1.0_dp        
          else
            HH=me%br(1)%p%Prim(Pri_e)+me%br(1)%p%Prim(Pri_P)/me%br(1)%p%Prim(Pri_ro)+0.5_dp*me%br(1)%p%Prim(Pri_u)**2
            call jacobian_roT(me%br(1)%p%Prim(Pri_ro), me%br(1)%p%Prim(Pri_T), dedT, dPdT)
            dPde=dPdT/dedT
            kk=dPde/me%br(1)%p%Prim(Pri_ro)
            KKK=me%br(1)%p%Prim(Pri_c)**2+kk*(me%br(1)%p%Prim(Pri_u)**2-HH)
            dPindUin(1)=KKK
            dPindUin(2)=-kk*me%br(1)%p%Prim(Pri_u)
            dPindUin(3)=kk
            dPindUin(4)=0.0_dp
    
            HH=me%br(2)%p%Prim(Pri_e)+me%br(2)%p%Prim(Pri_P)/me%br(2)%p%Prim(Pri_ro)+0.5_dp*me%br(2)%p%Prim(Pri_u)**2
            call jacobian_roT(me%br(2)%p%Prim(Pri_ro), me%br(2)%p%Prim(Pri_T), dedT, dPdT)
            dPde=dPdT/dedT
            kk=dPde/me%br(2)%p%Prim(Pri_ro)
            KKK=me%br(2)%p%Prim(Pri_c)**2+kk*(me%br(2)%p%Prim(Pri_u)**2-HH)
            dPoutdUout(1)=KKK
            dPoutdUout(2)=-kk*me%br(2)%p%Prim(Pri_u)
            dPoutdUout(3)=kk
            dPoutdUout(4)=0.0_dp  
          endif
  
          deriv_wr_both_br%DerHHHdUin(:)=dHHHdPin*dPindUin(:)+dHHHdRostarIn*dRostardUin(:)
          deriv_wr_both_br%DerHHHdUout(:)=dHHHdPout*dPoutdUout(:)
        endif
      endif

end subroutine HHH_derivatives