FFsrcLink_resolution_from_and_to_ports Subroutine

public subroutine FFsrcLink_resolution_from_and_to_ports(me)

Arguments

Type IntentOptional Attributes Name
type(FFsrcLink_t), intent(inout) :: me

Calls

proc~~ffsrclink_resolution_from_and_to_ports~~CallsGraph proc~ffsrclink_resolution_from_and_to_ports FFsrcLink_resolution_from_and_to_ports proc~nusselt_correlation nusselt_t%nusselt_correlation proc~ffsrclink_resolution_from_and_to_ports->proc~nusselt_correlation proc~nusselt_correlation_der_pra nusselt_t%nusselt_correlation_der_Pra proc~ffsrclink_resolution_from_and_to_ports->proc~nusselt_correlation_der_pra proc~nusselt_correlation_der_re nusselt_t%nusselt_correlation_der_Re proc~ffsrclink_resolution_from_and_to_ports->proc~nusselt_correlation_der_re proc~nusselt_correlation_der_t nusselt_t%nusselt_correlation_der_T proc~ffsrclink_resolution_from_and_to_ports->proc~nusselt_correlation_der_t proc~nusselt_correlation_der_tother nusselt_t%nusselt_correlation_der_Tother proc~ffsrclink_resolution_from_and_to_ports->proc~nusselt_correlation_der_tother

Called by

proc~~ffsrclink_resolution_from_and_to_ports~~CalledByGraph proc~ffsrclink_resolution_from_and_to_ports FFsrcLink_resolution_from_and_to_ports proc~main_loop main_loop proc~main_loop->proc~ffsrclink_resolution_from_and_to_ports program~reims_p reims_p program~reims_p->proc~main_loop

Source Code

subroutine FFsrcLink_resolution_from_and_to_ports(me)
    type(FFsrcLink_t), intent(inout) :: me

    real(dp) :: Pra,Re,llambda,Nu,dNudRe,dNudPr,dNudTemp,dNudTother,HtExch,WetPerChan
    real(dp), dimension(Nb_VarC) :: dPrdUi,dRedUi,DerllambdadUi,DerNudUi,DerNudUiOther
    real(dp), dimension(2) :: TempP,Phi,AreaP,DiamP,Ht,TempOther
    real(dp), dimension(Nb_VarC,2) :: DerPhi,DerTempPdUi,DerHt,DerTempOtherdUiOther,DerHtDerOther
    real(dp), dimension(2) :: Sexch_Ene,Sexch_R
    real(dp), dimension(Nb_VarC,2) :: DerHtExchdUi,DerHtExchdUiOther,DerSexch_EnedUi,DerSexch_EnedOther
    real(dp), dimension(Nb_VarC,2) :: DerSexch_RdUi,DerSexch_RdOther
    integer :: k,i

    ! Only thermal exchanges between fluids are present in this routine

    WetPerChan = me%WetPerChan

    do i = 1, me%sizeNodes
      do k = 1, 2
        Pra              = me%lk(k,i)%p%Pra
        Re               = me%lk(k,i)%p%Re
        dPrdUi(:)        = me%lk(k,i)%p%dPrdUi(:)
        dRedUi(:)        = me%lk(k,i)%p%dRedUi(:)
        llambda          = me%lk(k,i)%p%llambda
        DerllambdadUi(:) = me%lk(k,i)%p%DerllambdadUi(:)
        TempP(k)         = me%lk(k,i)%p%TempP
        DerTempPdUi(:,k) = me%lk(k,i)%p%DerTempPdUi(:)
        Phi(k)           = me%lk(k,i)%p%Phi
        DerPhi(:,k)      = me%lk(k,i)%p%DerPhi(:)
        AreaP(k)         = me%lk(k,i)%p%AreaP
        DiamP(k)         = me%lk(k,i)%p%DiamP

        if(k==1) then
          TempOther(k)=me%lk(2,i)%p%TempP
          DerTempOtherdUiOther(:,k)=me%lk(2,i)%p%DerTempPdUi(:)
        else
          TempOther(k)=me%lk(1,i)%p%TempP
          DerTempOtherdUiOther(:,k)=me%lk(1,i)%p%DerTempPdUi(:)
        endif
        Nu=me%nuss%nusselt(Re,Pra,TempOther(k),TempP(k))
        Ht(k)=Nu*llambda/DiamP(k)

        dNudRe=me%nuss%nusselt_der_Re(Re,Pra,TempOther(k),TempP(k))
        dNudPr=me%nuss%nusselt_der_Pra(Re,Pra,TempOther(k),TempP(k))
        dNudTemp=me%nuss%nusselt_der_T(Re,Pra,TempOther(k),TempP(k))
        DerNudUi(:)=dNudRe*dRedUi(:)+dNudPr*dPrdUi(:)+dNudTemp*DerTempPdUi(:,k)
        DerHt(:,k)=(1.0_dp/DiamP(k))*(DerNudUi(:)*llambda+Nu*DerllambdadUi(:))

        dNudTother=me%nuss%nusselt_der_Tother(Re,Pra,TempOther(k),TempP(k))
        DerNudUiOther(:)=dNudTother*DerTempOtherdUiOther(:,k)
        DerHtDerOther(:,k)=DerNudUiOther(:)*llambda/DiamP(k)     
      enddo

      if (min(Ht(1), Ht(2)) < 1.0e-15_dp) then
        HtExch = 0.0_dp
        DerHtExchdUi = 0.0_dp
        DerHtExchdUiOther = 0.0_dp
      else
        HtExch=1.0_dp/(1.0_dp/Ht(1)+1.0_dp/Ht(2))
        do k = 1, 2
          DerHtExchdUi(:,k)=(DerHt(:,k)/(Ht(k)**2))/((1.0_dp/Ht(1)+1.0_dp/Ht(2))**2)
          DerHtExchdUiOther(:,k)=(DerHtDerOther(:,k)/(Ht(k)**2))/((1.0_dp/Ht(1)+1.0_dp/Ht(2))**2)
        enddo
      end if
      do k = 1, 2
        Sexch_Ene(k)=WetPerChan*HtExch*(TempOther(k)-TempP(k))/AreaP(k)

        DerSexch_EnedUi(:,k)=(WetPerChan/AreaP(k))*(DerHtExchdUi(:,k)*(TempOther(k)-TempP(k))-HtExch*DerTempPdUi(:,k))
        DerSexch_EnedOther(:,k)=(WetPerChan/AreaP(k))*(DerHtExchdUiOther(:,k)*(TempOther(k)-TempP(k))+&
                                HtExch*DerTempOtherdUiOther(:,k))

        if(R_Correction) then
          Sexch_R(k)=Sexch_Ene(k)*(1.0_dp+Phi(k))
          DerSexch_RdUi(:,k)=DerSexch_EnedUi(:,k)*(1.0_dp+Phi(k))+Sexch_Ene(k)*DerPhi(:,k)
          DerSexch_RdOther(:,k)=DerSexch_EnedOther(:,k)*(1.0_dp+Phi(k))
        else
          Sexch_R(k)=0.0_dp
          DerSexch_RdUi(:,k)=0.0_dp
          DerSexch_RdOther(:,k)=0.0_dp
        endif

        ! To pipe nodes
        me%lk(k,i)%p%rhs_Se=Sexch_Ene(k)
        me%lk(k,i)%p%rhs_Sr=Sexch_R(k)
        me%lk(k,i)%p%DerSe(:)=DerSexch_EnedUi(:,k)
        me%lk(k,i)%p%DerSr(:)=DerSexch_RdUi(:,k)
        ! Link part
        me%DerSedOther(:,k,i)=DerSexch_EnedOther(:,k)
        me%DerSrdOther(:,k,i)=DerSexch_RdOther(:,k)      
      enddo
    enddo
   
end subroutine FFsrcLink_resolution_from_and_to_ports