!************************************************************
!CÁLCULO DO COEFICIENTE DE ARRASTO DO TUBO-GUIA
!************************************************************
    
SUBROUTINE Cdtubo (Pi, Detb, Ditb, Ltb, Sref, Cdtb, Nt, M, Swetc)

INTEGER Nt
REAL*8 Sreftb, Pi, Detb, Ltb, Ditb, Swettb, Cdtb, Sref, Cdstag, A, B, M, Swetc 

IF (Nt==1) THEN
    
    !!MÉTODO BRENT-CANNON-CAPSTONE
    !Sreftb = Pi*Detb**2d0/4d0                            !Seção tranversal do tubo-guia (mm²)
    !Sreftb = Pi*Detb**2d0/4d0-Pi*Ditb**2d0/4d0          !Seção tranversal do tubo-guia (mm²)
    !Swettb = Pi*Detb*Ltb+Pi*Ditb*Ltb                     !Área em contato com o ar do tubo-guia (mm²)
    !Cdtb = (1.2d0*Sreftb+0.0045d0*Swettb)/Sref          !Coeficiente de arrasto do tubo-guia (mm²)
  
    !MÉTODO OPEN ROCKET
    Cdstag = 0.85d0*(1d0+M**2d0/4d0+M**4d0/40d0) !Coeficiente de pressão de estagnação
    A = 1.3d0-0.3d0*(Ltb/Detb)
    B = 1d0-Ltb/Detb
    Cdtb = (max(A,1d0)*Cdstag)*(Pi*Detb**2d0/4d0-Pi*Ditb**2d0/4d0*max(B,0d0))/Sref
    
ELSE
    Cdtb = 0
END IF

END SUBROUTINE Cdtubo