ECF Source Code

Bruce Bowling bowling at cebaf.gov
Fri Mar 3 00:02:56 GMT 1995


Some people have asked for this, so here it is.  The following
non-ANSI "C" code will take horsepower readings and convert
them to standard conditions (60 deg F, 29.92 "Hg, 0% humidity,
and at sea-level).  This is useful for comparing HP figures
that are listed at non-standard-corrected values.  It is
also fun to play with to see how much the environment changes
a given power (like humidity and elevation).

To use, just compile it (I leave this step to you), and run.

- Bruce

-----------------------------------------------------
<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----------------------------------------------------
               Bruce A. Bowling
  Staff Scientist - Instrumentation and Controls
 The Continuous Electron Beam Accelerator Facility
    12000 Jefferson Ave - Newport News, VA 23602
                 (804) 249-7240
               bowling at cebaf.gov
-----------------------------------------------------
<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----------------------------------------------------



---------CUT-------CUT------CUT------CUT-----CUT------

/* To compile on most Unix machines:                */
/*      cc -o ect ect.c -lm                         */
/*      (-lm is the math library for sqrt()         */


#include <math.h>
#include <stdio.h>

/* Calculate Environmental Correction Factor (ECF)  */
/* Standard Correction                              */
/* Definitions of Varibles                          */
/*  temp -> Test temperature in degrees F           */
/*  bpress -> Test Barometric pressure in inches HG */
/*  humid -> Relative humidity in percent           */
/*  elev -> Altitude in feet                        */
/*             B. Bowling 1993                      */

float ecf(temp, bpress, humid, elev)
float temp, bpress, humid, elev;
{
	float tcorr, xk, bpc, vp, phcorr, cf;

       /* Temperature correction (derate about 1% for every 10 deg increase) */
       tcorr = sqrt((459.7+temp)/519.7);

       /* Correct barometric pressure for local elevation */
       xk = 1.6e06*(1.+.0022222*(temp-32.));
       bpc = -((30.48*elev-xk)/(30.48*elev+xk))*bpress;

       /* Calculate saturated vapor pressure */
       vp = (humid/100.)*((((1.54854e-08*temp-9.76951e-07)*temp+
        1.26819e-04)*temp+3.85377e-04)*temp+5.38397e-02);

       phcorr = 29.92/(bpc-vp);  /* Pressure+humidity correction */
       cf = tcorr*phcorr;  /* Total correction */

       return(cf);
}



/* Correct Horsepower to Standard Conditions        */
/* Definitions of Varibles                          */
/*  hp_uncorr -> uncorrected horsepower             */
/*  ecf_value -> environmental correction           */
/*  stroke -> engine stroke in inches               */
/*  cid -> cubic inch displacement                  */
/*  rpm -> revolutions per minute                   */
/*             B. Bowling 1993                      */

float correct_HP(hp_uncorr, ecf_value, stroke, cid, rpm)
float hp_uncorr, ecf_value, stroke, cid, rpm;
{
      float pspeed, fhp, hpcorr;

      /* Piston Speed in in/min */
      pspeed = stroke * rpm / 6.0;  

      /* Friction Horsepower */
      fhp = 9.66083e-02+(1.04731e-05+1.13813e-08*pspeed)*pspeed;
      fhp = cid * fhp * rpm / 5252.1;

      hpcorr=(hp_uncorr - (ecf_value - 1.0) * fhp) / ecf_value;
      if(hpcorr < 0.0) hpcorr = 0.0; /* Cannot allow negative */

      return(hpcorr);
}


/* Test routine */
/* Bowling '95  */
void main()
{
      float temp_in, bpress_in, humid_in, elev_in;
      float stroke_in, cid_in, rpm_in;
      float ecf_gen;
      float hp_in, hp_out;

      printf("=== HP Standard Correction - By Bowling ===\n\n");

      /* Enter inputs for ECT computation */
      printf("Enter test temperature (degrees F): "); fflush(stdout);
      scanf("%f", &temp_in);
      printf("Enter test barometric pressure (inches HG): "); fflush(stdout);
      scanf("%f", &bpress_in);
      printf("Enter test humidity in percent: "); fflush(stdout);
      scanf("%f", &humid_in);
      printf("Enter test altitude (feet): "); fflush(stdout);
      scanf("%f", &elev_in);

      /* Generate Enviromental Correction Factor */
      ecf_gen = ecf(temp_in, bpress_in, humid_in, elev_in);
      printf("** Computed Correction Factor -> %f\n", ecf_gen);

      /* Enter engine-specific values */
      printf("Enter engine stroke (inches): "); fflush(stdout);
      scanf("%f", &stroke_in);
      printf("Enter engine cid in in3: "); fflush(stdout);
      scanf("%f", &cid_in);

      /* Loop continuously over all desired corrections to perform */
      /* Enter a zero for RPM or HP to exit                        */
      while(1)
      {
            printf("--------- HP Correction --------------\n");
            printf("Enter engine rpm: "); fflush(stdout);
            scanf("%f", &rpm_in);
            if(rpm_in <= 0.0) exit(0);
            printf("Enter engine horsepower: "); fflush(stdout);
            scanf("%f", &hp_in);
            if(hp_in <= 0.0) exit(0);

            hp_out = correct_HP(hp_in, ecf_gen, stroke_in, cid_in, rpm_in);
            printf("** Computed Corrected Horsepower -> %f **\n", hp_out);
      }
}



More information about the Diy_efi mailing list