Attachment 'in01.c'

Download

   1 // in01.c  incline
   2 //
   3 // gcc -o in01 in01.c -lm
   4 
   5 #define  NAME   "in01"
   6 #define  CMD    "in"          //          tmp.dat -> tmp.png
   7 
   8 #define  SANGLE     20.0      // degrees  Ground start angle
   9 #define  ZTOP    80000.0      // m        Top altitude
  10 #define  DX          0.1      // m        Increment
  11 #define  MS         10.0      // kg       Sheath mass
  12 #define  MRTOP       3.0      // kg       Rotor mass
  13 #define  VRTOP   14000.0      // m/s      Rotor speed at top  (reference)
  14 #define  VRBOT   14055.2537   // km/s     Rotor speed at surface
  15 
  16 // cables
  17 #define  Z0      20000.0      // m        Cable "start" height
  18 #define  HC      80000.0      // m        Support height
  19 #define  ANGLE      45.0      //          Side Angle
  20 
  21 #define  RE    6378000.0      // m        Earth Radius
  22 #define  AG0         9.81     // m/s2     Gravity at surface
  23 
  24 #define  PI 3.14159265 
  25 
  26 #include <math.h>
  27 #include <string.h>
  28 #include <stdio.h>
  29 #include <stdlib.h>
  30 
  31 //-----------------------------------------------------------------
  32 int main() {
  33 
  34    FILE    *datfile                     ; //
  35    char    gnuplot[200]                 ; //
  36    char    filename[80]                 ; //
  37 
  38    int     points= 0                    ;
  39    double  dzdx0 = tan( PI*SANGLE/180.0);
  40    double  cang  = cos( PI/4.0 )        ; // 45 degrees cable angle
  41    double  ag    = AG0                  ; // gravity
  42    double  ms    = MS                   ;
  43    double  dx    = DX                   ;
  44    double  dz                           ;
  45    double  x     = 0.0                  ;
  46    double  z     = 0.0                  ;
  47    double  kx    = 0.0                  ;
  48    double  kz    = 0.0                  ;
  49    double  vr    = VRBOT                ;
  50    double  dzdx  = dzdx0                ;
  51    double  dzdx1                        ;
  52    double  dzdx2                        ;
  53    double  mrbot = MRTOP*VRTOP/vr       ;
  54    double  mr    = mrbot                ;
  55    double  tmp                          ;
  56    double  gz                           ;
  57    double  angle                        ; // force angle radians
  58    double  dangle                       ; // force angle degrees
  59    double  force                        ; // force kiloNewtons
  60    double  forcex                       ; // horizontal force kiloNewtons
  61    double  forcez                       ; // vertical   force kiloNewtons
  62    double  forcec                       ; // cable      force kiloNewtons
  63    double  forces                       ; // station    force kiloNewtons
  64    double  smass                        ; // station mass metric tons
  65    double  cmass                        ; // main cable mass metric tons
  66    double  cinc = 0.0                   ; // incline cable mass
  67 
  68    // --------------------------------------------------------------------
  69 
  70    datfile = fopen( "tmp.dat", "wb" );
  71 
  72    while( z < ZTOP ) {
  73       tmp   = 1.0/( 1.0 + z/RE )       ;
  74       ag    = AG0*tmp*tmp              ;
  75       mr    = MRTOP*VRTOP/vr           ;
  76 
  77       gz    = sqrt(exp(2.0*(z+Z0)/HC)-1.0)/cang ;
  78 
  79       dzdx1 = 1.0 + dzdx*dzdx          ;
  80       dzdx2 = dzdx1/(RE+z)
  81             - ag*(ms+mr)*dzdx1*dzdx1
  82 	    / (mr*vr*vr*(1.0-gz*dzdx)) ;
  83       dzdx += dzdx2 *dx                ;
  84       dz    = dzdx * dx                ;
  85       vr   -= ag*dz/vr                 ; 
  86       z    += dz                       ;
  87       x    += dx                       ;
  88       cinc += (dz*ms/cang)
  89             * (  sqrt(exp(2.0*(z+Z0)/HC)-1.0)
  90                - sqrt(exp(2.0*Z0/HC)-1.0) ) ; // cable mass kg
  91 
  92       kx    = 0.001*x                  ;
  93       kz    = 0.001*z                  ;
  94      
  95 
  96       if( ((points++)%5000) == 0 ) {
  97          fprintf( datfile, "%14.4f%14.4f\n", kx, kz ) ;
  98       }
  99    }
 100    fprintf( datfile, "%14.4f%14.4f\n", kx, kz ) ;
 101    fclose( datfile );
 102 
 103    printf( "--------------------------------------------------\n"     );
 104 
 105    angle  = atan( dzdx0 )                                 ; // radians
 106    dangle = (180.0/PI)*angle                              ; // degrees
 107    force  = 2*mrbot*VRBOT*VRBOT*sin(0.5*angle)/1000.0     ; // kiloNewtons
 108    forcez = force * cos( 0.5*angle )                      ; //
 109    forcex = force * sin( 0.5*angle )                      ; //
 110     
 111    printf( "             bottom slope =%11.4f vert/horiz\n" ,  dzdx0 );
 112    printf( "             bottom angle =%11.4f degrees\n"    , dangle );
 113    printf( "             bottom force =%11.0f kiloNewtons\n",  force );
 114    printf( "    bottom force vertical =%11.0f kiloNewtons\n", forcez );
 115    printf( "  bottom force horizontal =%11.0f kiloNewtons\n", forcex );
 116    printf( "      bottom mass density =%11.4f kg/meter\n"   ,  mrbot );
 117    printf( "          bottom velocity =%11.4f meter/sec\n"  ,  VRBOT );
 118    printf( "           bottom gravity =%11.4f meter^2/sec\n",    AG0 );
 119    printf( "--------------------------------------------------\n"    );
 120 
 121    angle  = atan( dzdx )                                  ; // radians
 122    dangle = (180.0/PI)*angle                              ; // degrees
 123    force  = 2*mr*vr*vr*sin(0.5*angle)/1000.0              ; // kiloNewtons
 124    forcez = force * cos( 0.5*angle )                      ; //
 125    forcex = force * sin( 0.5*angle )                      ; //
 126    forcec = forcex * sqrt( 1.0 + gz*gz )                  ; // cable force kN
 127    forces = forcez-gz*forcex                              ; // station support
 128    smass  = forces/ag                                     ; // station mass tons
 129    cmass  = (forcex/(ag*cang))
 130           * (  sqrt(exp(2.0*(ZTOP+Z0)/HC)-1.0)
 131              - sqrt(exp(2.0*Z0/HC)-1.0) )                 ; // cable mass tons
 132    cinc  /= 1000.0                                        ; // incline cable tons
 133 
 134    printf( "      horizontal distance =%11.4f kilometers\n" ,     kx );
 135    printf( "        vertical distance =%11.4f kilometers\n" ,     kz );
 136    printf( "                top slope =%11.4f vert/horiz\n" ,   dzdx );
 137    printf( "                top angle =%11.4f degrees\n"    , dangle );
 138    printf( "                top force =%11.0f kiloNewtons\n",  force );
 139    printf( "       top force vertical =%11.0f kiloNewtons\n", forcez );
 140    printf( "     top force horizontal =%11.0f kiloNewtons\n", forcex );
 141    printf( "         top mass density =%11.4f kg/meter\n"   ,     mr );
 142    printf( "             top velocity =%11.4f meter/sec\n"  ,     vr );
 143    printf( "              top gravity =%11.4f meter^2/sec\n",     ag );
 144    printf( "--------------------------------------------------\n"    );
 145    printf( "     cable force ratio gz =%11.4f vert/horiz\n" ,     gz );
 146    printf( "    top cable axial force =%11.4f kiloNewtons\n", forcec );
 147    printf( "    station support force =%11.4f kiloNewtons\n", forces );
 148    printf( "  station + elevator mass =%11.4f metric tons\n", smass  );
 149    printf( " main diagonal cable mass =%11.4f metric tons\n", cmass  );
 150    printf( "       incline cable mass =%11.4f metric tons\n", cinc   );
 151    printf( "--------------------------------------------------\n"    );
 152 
 153    sprintf( gnuplot, "/usr/local/bin/gp %s.cmd", CMD );
 154    system( gnuplot );
 155 
 156    sprintf( filename, "%s.png", NAME );
 157    rename( "tmp.png", filename );
 158 
 159    return(0);
 160 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-07-22 00:31:50, 1.7 KB) [[attachment:in.cmd]]
  • [get | view] (2009-07-22 00:31:27, 7.0 KB) [[attachment:in01.c]]
  • [get | view] (2009-07-22 00:31:42, 8.9 KB) [[attachment:in01.png]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.