function [Ct,CtoverJ2,Cp,CpoverJ2]=ThrustCoef2(Vtrueknots,Hpress,RPM,TempDegR,Thrust1engine,BHPmax,Din,C)
% This version uses a different way to compute altitude performance
% function [Ct,CtoverJ2,Cp,CpoverJ2]=ThrustCoef2(Vtrueknots,Hpress,RPM,TempDegR,Thrust1engine,BHPmax,Din,C)
% Function to compute PER ENGINE thrust and power coefficients.
%
% INPUTS
% Vtrueknots, Hpress, RPM, TempDegR, Thrust1engine can be vectors of the same size
% Vtrueknots, knots 
% Hpress, ft 
% RPM is engine revolutions per minute of the propeller
% TempDegR is the Outside air temperature (degR) of the engine.
% Thrust1engine in lbf. per engine. 
% BHPmax=max BHP per engine
% Typically BHPmax=300 hp
% Din in propeller diameter in inches
%      Typically for Nblades=2 for 2-bladed prop, Din=78 inches)
%                for Nblades=3 for 3-bladed prop, Din=76 inches)
% C in an input (typically C=.12)
% OUTPUTS
% Ct, Ct over J^2, Cp, Cp over J^2
% Notes
% Total thrust for two engines is twice the input value.
% This version Gagg-Farrar Rule for engine horsepower

	
% Get atmospheric pressure for the given pressure altitude.
[tempDegR,press,rho,Hgeopvector]=atmosphere4(Hpress,0);
% Compute density for given temperature (Temp) and pressure (press).
% rho=press./(1716.55*Temp);     % <<<<<<<<<<<<< OLD METHOD
sigma=rho/0.00237691267925741;
%C=.12; % C in an input
phi=(sigma-C)/(1-C);  % altitude drop-off factor
phiT=sqrt(tempDegR./TempDegR);
BHP=BHPmax*phi.*phiT; % Compute hp from altitude drop-off factor (Gagg-Farrar Rule)
% The above method uses the sigma from the standard atmosphere (as a
% function of Hp)
% and does a separate temperature correction
% This was not what I understood to be
% the correct interpretation of the Gagg-Farrar Rule, but it certainly
% appears to work better then my original interpretation which
% involved computing rho as a funtion of actual temperature and pressure.
Dft=Din/12; 
Vtruefps=Vtrueknots*1.687808;  % Convert knots to ft/sec

n=RPM/60; % Convert RPM to rev per sec
Cp=550*BHP./(rho.*n.^3*Dft^5);  % Find power coef.
J=Vtruefps./(n*Dft); % Find advance ratio
CpoverJ2=Cp./(J.*J);  % Cp/J^2

Ct=Thrust1engine./(rho.*n.^2*Dft^4); % Compute thrust coef.
CtoverJ2=Ct./(J.*J);    % Ct/J^2
