subroutine FFsrcLink_Prelax_resolution_from_and_to_ports(me)
type(FFsrcLink_t), intent(inout) :: me
real(dp), dimension(Nb_VarP,2) :: Pr
real(dp), dimension(Nb_VarC,2) :: Cs
real(dp), dimension(2) :: Kappak, rok, pk, rokstar, tkstar, rCorrkstar, ekstar, ckstar
real(dp), dimension(2) :: ukstar, Vitk, Area
real(dp) :: VitBar, hBar, pstar
real(dp) :: ccv,ccp,mmu,llambda,dPdT_Ro,hk,Phik,T_temp
integer :: k,i
do i = 1, me%sizeNodes
do k = 1, 2
Pr(:,k)=me%lk(k,i)%p%Prim(:)
Cs(:,k)=me%lk(k,i)%p%Cons(:)
Area(k)=me%lk(k,i)%p%AreaP
enddo
if(Pr(Pri_p,1)>=Pr(Pri_p,2)) then
VitBar=Pr(Pri_u,1)
if(R_Correction) then
hBar=Pr(Pri_R,1)/Pr(Pri_ro,1)
else
hBar=Pr(Pri_e,1)+Pr(Pri_p,1)/Pr(Pri_ro,1)
endif
else
VitBar=Pr(Pri_u,2)
if(R_Correction) then
hBar=Pr(Pri_R,2)/Pr(Pri_ro,2)
else
hBar=Pr(Pri_e,2)+Pr(Pri_p,2)/Pr(Pri_ro,2)
endif
endif
do k = 1, 2
call he_prop(Pr(Pri_ro,k),Pr(Pri_T,k),ccv,ccp,mmu,llambda,dPdT_Ro)
if (sim_error > 0) return
rok(k)=Pr(Pri_ro,k)
pk(k)=Pr(Pri_p,k)
if(R_Correction) then
hk=Pr(Pri_R,k)/Pr(Pri_ro,k)
else
hk=Pr(Pri_e,k)+Pr(Pri_p,k)/Pr(Pri_ro,k)
endif
Vitk(k)=Pr(Pri_u,k)
Phik=1.0_dp/(Pr(Pri_ro,k)*(ccv/dPdT_Ro))
Kappak(k)=Phik*((hBar-hk)+0.5_dp*((VitBar-Vitk(k))**2))/Area(k)+(Pr(Pri_c,k)**2)/Area(k)
enddo
pstar=0.5_dp*(pk(1)+pk(2))+0.5_dp*(pk(1)-pk(2))*(Kappak(2)-Kappak(1))/(Kappak(1)+Kappak(2))
do k = 1, 2
rokstar(k)=rok(k)+(pstar-pk(k))/(Area(k)*Kappak(k))
T_temp=T_roP(rokstar(k),pstar)
tkstar(k)=T_temp
call state_roT(rokstar(k), tkstar(k), rCorrkstar(k), Pstar, ekstar(k), ckstar(k))
ukstar(k)=Vitk(k)+(VitBar-Vitk(k))*(rokstar(k)-rok(k))/rok(k)
Pr(Pri_ro,k)=rokstar(k)
Pr(Pri_u,k)=ukstar(k)
Pr(Pri_p,k)=Pstar
Pr(Pri_e,k)=ekstar(k)
Pr(Pri_T,k)=tkstar(k)
Pr(Pri_c,k)=ckstar(k)
if(R_Correction) Pr(Pri_R,k)=rCorrkstar(k)
Cs(Con_Mas,k)=rokstar(k)
Cs(Con_Qdm,k)=rokstar(k)*ukstar(k)
Cs(Con_Ene,k)=rokstar(k)*(ekstar(k)+0.5_dp*(ukstar(k)**2))
if(R_Correction) Cs(Con_R,k)=rCorrkstar(k)
me%lk(k,i)%p%Prim(:)=Pr(:,k)
me%lk(k,i)%p%Cons(:)=Cs(:,k)
enddo
enddo
end subroutine FFsrcLink_Prelax_resolution_from_and_to_ports