Example #1
0
static void draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop, GdkRectangle *rcClip)
  {
	int Nix, Nix1 ;
  QCADClockingLayer *clocking_layer = QCAD_CLOCKING_LAYER (obj) ;
  QCADLayer *layer = QCAD_LAYER (obj) ;
  GdkGC *gc = NULL ;
  double potential ;
  GList *llItr = NULL ;
  double x, y;

  QCAD_DESIGN_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_CLOCKING_LAYER)))->draw (obj, dst, rop, rcClip) ;

  gc = gdk_gc_new (dst) ;
  gdk_gc_set_foreground (gc, clr_idx_to_clr_struct (RED)) ;
  gdk_gc_set_background (gc, clr_idx_to_clr_struct (RED)) ;
  gdk_gc_set_clip_rectangle (gc, rcClip) ;

  if (NULL != layer->lstObjs && clocking_layer->bDrawPotential)
    {
    GdkPixbuf *pb = NULL ;
    pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, clocking_layer->tile_size, clocking_layer->tile_size) ;
	
		for (Nix = 0; Nix < Nx; Nix++) {
			x = xmin+dx*Nix;
			for (Nix1 = 0; Nix1 < Ny; Nix1++) {
				y = ymin+dy*Nix1;
				potential = get_potential (x, y, clocking_layer->z_to_draw, Nx, Ny, Nz, dx, dy, dz, xmin, ymin)  ;
								
/*
				 
        if (fabs (potential) < clocking_layer->dExtremePotential / 100.0)
          {
          fprintf (stderr, "Potential too small - breaking out\n") ;
//          continue ;
          }
*/
        gdk_pixbuf_fill (pb,
          ((potential > 0) ? 0xFF000000 : 0x0000FF00) | (((int)((fabs (potential) / clocking_layer->dExtremePotential) * 128.0)) & 0xFF)) ;
//        fprintf (stderr, "opacity = %lf/%lf * 255\n", potential, clocking_layer->dExtremePotential) ;
				
        gdk_draw_pixbuf (dst, gc, pb, 0, 0, Nix * clocking_layer->tile_size,  Nix1 * clocking_layer->tile_size, clocking_layer->tile_size, clocking_layer->tile_size, GDK_RGB_DITHER_NONE, 0, 0) ;
		//gdk_draw_pixbuf (dst, gc, pb, 0, 0, Nix * clocking_layer->tile_size, Nix1 * clocking_layer->tile_size, clocking_layer->tile_size, clocking_layer->tile_size, GDK_RGB_DITHER_NONE, 0, 0) ;
				
//        gdk_draw_rectangle (dst, gc, TRUE, 
//          Nix * clocking_layer->tile_size + (clocking_layer->tile_size >> 1) - 2,
//          Nix1 * clocking_layer->tile_size + (clocking_layer->tile_size >> 1) - 2,
//          5, 5) ;
			}
		}
    g_object_unref (pb) ;
    }

  g_object_unref (gc) ;
	}
Example #2
0
void nemo_main()
{
    stream outstr;
    
    potential = get_potential(getparam("potname"),
                    getparam("potpars"), getparam("potfile"));
    rmin = getdparam("rmin");
    rmax = getdparam("rmax");
    rref = rmax;
    if (hasvalue("rref")) rref = getdparam("rref");
    Qkey = hasvalue("key");
    if (Qkey) key = getiparam("key");
    Qconstant = getbparam("constant");

    ndisk = getiparam("nbody");
    jz_sign = getiparam("sign");
    nmodel = getiparam("nmodel");
    totmass = getdparam("mass");
    offset = getdparam("phase") * PI / 180.0;    
    Qtest = getbparam("test");
    Quniform = getbparam("uniform");
    if (ABS(jz_sign) != 1) error("sign must be +1 or -1");

    Qlinear = hasvalue("k");
    if (Qlinear)
      SPk = getdparam("k");	/* corrected for rot counter clock wise */
    else if (hasvalue("pitch"))
      pitch = getdparam("pitch"); /* corrected for rot counter clock wise */
    else
      error("Either k= (linear) or pitch= (logarithmic) spiral indicator needed");
    
    init_xrandom(getparam("seed"));

    outstr = stropen(getparam("out"), "w");
    put_history(outstr);
    if (hasvalue("headline"))
	set_headline(getparam("headline"));
    setdensity();
    
    while (nmodel--) {
        testdisk(nmodel);
        writegalaxy(outstr);
    }
    strclose(outstr);
    free(disk);
}
Example #3
0
File: code.c Project: jobovy/nemo
startrun()
{
    string restfile, contfile;
    bool scanopt();
    proc get_potential();
    infile = getparam("in");			/* set I/O file names       */
    outfile = getparam("out");
    restfile = getparam("restart");
    contfile = getparam("continue");
    savefile = getparam("save");
    options = getparam("options");		/* set control options      */
    debug = getbparam("hdebug");
    if (debug)
	dprintf(0,"hdebug is turned on");
    nrigid = getiparam("nrigid");
    if (*contfile)	         		/* resume interrupted run   */
	restorestate(contfile);
    else if (*restfile) {	        	 /* resume w/ new parameters */
	restorestate(restfile);
	/* NOTE: someday, I will have a way to tell which, if any, of these *
	 * parameters are actually input from the command line, and only    *
	 * change them.  ANY NON-DEFAULT ARGS MUST BE SPECIFIED AT RESTART. */
	eps = getdparam("eps");			/*   get modified params    */
	tol = getdparam("tol");
	options = getparam("options");		/*   restorestate overwrite */
	fcells = getdparam("fcells");
	tstop = getdparam("tstop");
	freqout = getdparam("freqout");
	minor_freqout = getdparam("minor_freqout");
	if (scanopt(options, "new_tout")) {	/*   reset output times?    */
	    tout = tnow + 1 / freqout;		/*     offset from present  */
	    minor_tout = tnow + 1 / minor_freqout;
	}
    } else {					/* start new calculation    */
	if (*infile)	                 	/*   was data file given?   */
	    inputdata(infile);			/*     read inital data     */
	else {					/*   make initial conds?    */
	    nbody = getiparam("nbody");		/*     get nbody parameter  */
	    if (nbody < 1)			/*     is value absurd?     */
		error("startrun: absurd nbody\n");
	    init_xrandom(getparam("seed"));	/*     set random generator */
	    testdata(getbparam("cencon"));	/*     make test model      */
	}
	freq = getdparam("freq");		/*   get various parameters */
	eps = getdparam("eps");
	tol = getdparam("tol");
	fcells = getdparam("fcells");
	tstop = getdparam("tstop");
	freqout = getdparam("freqout");
	minor_freqout = getdparam("minor_freqout");
	nstep = 0;				/*   start counting steps   */
	minor_tout = tout = tnow;		/*   schedule first output  */
	SETVS(rmin, -2.0);			/*   init box scaling       */
	rsize = -2.0 * rmin[0];
    }
    contfile = getparam("potname");
    if (*contfile) {
        extpot = get_potential(contfile, 
                    getparam("potpars"),getparam("potfile"));
    }
}
Example #4
0
int main(int argc, char **argv){
  
  /*positions of all particles*/
  FLOAT *x;
  FLOAT *y;
  FLOAT *z;
  
  /*velocities of all particles*/
  FLOAT *v_x;
  FLOAT *v_y;
  FLOAT *v_z;

  /*accelerations of all particles*/
  FLOAT *a_x;
  FLOAT *a_y;
  FLOAT *a_z;
    
/*terms for runge-kutta*/
  
  FLOAT *a_x_old;
  FLOAT *a_y_old;
  FLOAT *a_z_old;
    
    
  FLOAT  *k_1_x;
  FLOAT  *k_1_y;
  FLOAT  *k_1_z;
    
  FLOAT  *k_1_v_x;
  FLOAT  *k_1_v_y;
  FLOAT  *k_1_v_z;
    
  FLOAT  *k_2_x;
  FLOAT  *k_2_y;
  FLOAT  *k_2_z;
    
  FLOAT  *k_2_v_x;
  FLOAT  *k_2_v_y;
  FLOAT  *k_2_v_z;
    
  FLOAT  *k_3_x;
  FLOAT  *k_3_y;
  FLOAT  *k_3_z;

  FLOAT  *k_3_v_x;
  FLOAT  *k_3_v_y;
  FLOAT  *k_3_v_z;
    
  FLOAT  *k_4_x;
  FLOAT  *k_4_y;
  FLOAT  *k_4_z;
    
  FLOAT  *k_4_v_x;
  FLOAT  *k_4_v_y;
  FLOAT  *k_4_v_z;
    
  FLOAT *xtemp;
  FLOAT *ytemp;
  FLOAT *ztemp;
  FLOAT *v_xtemp;
  FLOAT *v_ytemp;
  FLOAT *v_ztemp;
  FLOAT *a_xtemp;
  FLOAT *a_ytemp;
  FLOAT *a_ztemp;
    
    
  /*masses*/
  FLOAT *mass;

  /*timestep variables*/
  FLOAT h= 0.001;
  int n_steps = (int)(100/h);
  int n_points = 3;
  FLOAT radius = 100.0;
  FLOAT unit_mass = 1.0; 
  FLOAT vel_initial = sqrt((11.0/3.0) * G_GRAV * unit_mass / (sqrt(3.0)*radius));
  FLOAT kinetic;
  FLOAT potential;
  int i,j,k;
  
  /*memory allocation*/
  x = get_memory(n_points);
  y = get_memory(n_points);
  z = get_memory(n_points);
  v_x = get_memory(n_points);
  v_y = get_memory(n_points);
  v_z = get_memory(n_points);
  a_x = get_memory(n_points);
  a_y = get_memory(n_points);
  a_z = get_memory(n_points);
  mass = get_memory(n_points);
  k_1_x = get_memory(n_points);
  k_1_y = get_memory(n_points);
  k_1_z = get_memory(n_points);
  k_1_v_x = get_memory(n_points);
  k_1_v_y = get_memory(n_points);
  k_1_v_z = get_memory(n_points);
  k_2_x = get_memory(n_points);
  k_2_y = get_memory(n_points);
  k_2_z = get_memory(n_points);
  k_2_v_x = get_memory(n_points);
  k_2_v_y = get_memory(n_points);
  k_2_v_z = get_memory(n_points);
  k_3_x = get_memory(n_points);
  k_3_y = get_memory(n_points);
  k_3_z = get_memory(n_points);
  k_3_v_x = get_memory(n_points);
  k_3_v_y = get_memory(n_points);
  k_3_v_z = get_memory(n_points);
  k_4_x = get_memory(n_points);
  k_4_y = get_memory(n_points);
  k_4_z = get_memory(n_points);
  k_4_v_x = get_memory(n_points);
  k_4_v_y = get_memory(n_points);
  k_4_v_z = get_memory(n_points);
  xtemp = get_memory(n_points);
  ytemp = get_memory(n_points);
  ztemp = get_memory(n_points);
  v_xtemp = get_memory(n_points);
  v_ytemp = get_memory(n_points);
  v_ztemp = get_memory(n_points);
  a_xtemp = get_memory(n_points);
  a_ytemp = get_memory(n_points);
  a_ztemp = get_memory(n_points);

  initialize_pos(x,y,z, n_points, radius);
  initialize_vel(v_x,v_y,v_z, n_points, vel_initial, radius);
  initialize_mass(mass, n_points, unit_mass);

  /*implementation of a second order runge kutta integration*/
    
    FILE *in;
    in = fopen("3cuerpos.dat","w");
    
  for(i=0;i<n_steps;i++){
      
      a_x_old = a_x;
      a_y_old = a_y;
      a_z_old = a_z;
      
    get_acceleration(a_x, a_y, a_z, x, y, z, mass, n_points);
    for(j=0;j<n_points;j++){

        k_1_x[j] = v_x[j];
        k_1_y[j] = v_y[j];
        k_1_z[j] = v_z[j];
        
        k_1_v_x[j] = a_x[j];
        k_1_v_y[j] = a_y[j];
        k_1_v_z[j] = a_z[j];
        
        
        //FIRST STEP
        
        xtemp[j] = x[j] + (h/2.0)*k_1_x[j];
        ytemp[j] = y[j] + (h/2.0)*k_1_y[j];
        ztemp[j] = z[j] + (h/2.0)*k_1_z[j];
        
        v_xtemp[j] = v_x[j] + (h/2.0)*k_1_v_x[j];
        v_ytemp[j] = v_y[j] + (h/2.0)*k_1_v_y[j];
        v_ztemp[j] = v_z[j] + (h/2.0)*k_1_v_z[j];
        
        k_2_x[j] = v_xtemp[j];
        k_2_y[j] = v_ytemp[j];
        k_2_z[j] = v_ztemp[j];
        
    }
      
      get_acceleration(a_xtemp,a_ytemp,a_ztemp,xtemp,ytemp,ztemp, mass, n_points);
      
      for(j=0;j<n_points;j++){
        
        k_2_v_x[j] = a_xtemp[j];
        k_2_v_y[j] = a_ytemp[j];
        k_2_v_z[j] = a_ztemp[j];
        
          
        //SECOND STEP
        
        xtemp[j] = x[j] + (h/2.0)*k_2_x[j];
        ytemp[j] = y[j] + (h/2.0)*k_2_y[j];
        ztemp[j] = z[j] + (h/2.0)*k_2_z[j];
          
        v_xtemp[j] = v_x[j] + (h/2.0)*k_2_v_x[j];
        v_ytemp[j] = v_y[j] + (h/2.0)*k_2_v_y[j];
        v_ztemp[j] = v_z[j] + (h/2.0)*k_2_v_z[j];
          
        k_3_x[j] = v_xtemp[j];
        k_3_y[j] = v_ytemp[j];
        k_3_z[j] = v_ztemp[j];
          
        }
      
      get_acceleration(a_xtemp,a_ytemp,a_ztemp,xtemp,ytemp,ztemp, mass, n_points);
      
      for(j=0;j<n_points;j++){
          
          k_3_v_x[j] = a_xtemp[j];
          k_3_v_y[j] = a_ytemp[j];
          k_3_v_z[j] = a_ztemp[j];
          
          
          //THIRD STEP
          
          xtemp[j] = x[j] + h*k_3_x[j];
          ytemp[j] = y[j] + h*k_3_y[j];
          ztemp[j] = z[j] + h*k_3_z[j];
          
          v_xtemp[j] = v_x[j] + h*k_3_v_x[j];
          v_ytemp[j] = v_y[j] + h*k_3_v_y[j];
          v_ztemp[j] = v_z[j] + h*k_3_v_z[j];
          
          k_4_x[j] = v_xtemp[j];
          k_4_y[j] = v_ytemp[j];
          k_4_z[j] = v_ztemp[j];
          
      }
      
      get_acceleration(a_xtemp,a_ytemp,a_ztemp,xtemp,ytemp,ztemp, mass, n_points);
      
      for(j=0;j<n_points;j++){
          
          k_4_v_x[j] = a_xtemp[j];
          k_4_v_y[j] = a_ytemp[j];
          k_4_v_z[j] = a_ztemp[j];
          
          
          //FOURTH STEP
          
          x[j] = x[j] + h*(1.0/6.0)*(k_1_x[j]+2*k_2_x[j]+2*k_3_x[j]+k_4_x[j]);
          y[j] = y[j] + h*(1.0/6.0)*(k_1_y[j]+2*k_2_y[j]+2*k_3_y[j]+k_4_y[j]);
          z[j] = z[j] + h*(1.0/6.0)*(k_1_z[j]+2*k_2_z[j]+2*k_3_z[j]+k_4_z[j]);
          
          v_x[j] = v_x[j] + h*(1.0/6.0)*(k_1_v_x[j]+2*k_2_v_x[j]+2*k_3_v_x[j]+k_4_v_x[j]);
          v_y[j] = v_y[j] + h*(1.0/6.0)*(k_1_v_y[j]+2*k_2_v_y[j]+2*k_3_v_y[j]+k_4_v_y[j]);
          v_z[j] = v_z[j] + h*(1.0/6.0)*(k_1_v_z[j]+2*k_2_v_z[j]+2*k_3_v_z[j]+k_4_v_z[j]);
      }
      for(k=0;k<n_points;k++){
          fprintf(in," %f %f %f ", x[k], y[k], z[k]);
      }
      kinetic = get_kinetic(x, y, z, v_x, v_y, v_z, a_x, a_y, a_z, mass, n_points);
      potential = get_potential(x, y, z, v_x, v_y, v_z, a_x, a_y, a_z, mass, n_points);
      fprintf(in,"%f %f \n",kinetic, potential);
  }
    fclose(in);
    
}
Example #5
0
void nemo_main()
{
    int    i, dir, nrad, npots=0, ltype, ndim = NDIM, nx, ny, ns, ndat, nret;
    int    cols[4], n, idx, idx_max;
    real   pmax, symsize, rr, omk_max = 0.0, omk_rmax;
    real   rad[MAXPT], *vel, *vel1, *vel2, *vel3, *vel4, *curve;
    real   *ome, *kap, *opk, *omk, r0l[MAXPT+2], omega, *f;
    real   inrad[MAXPT], invel[MAXPT], inrade[MAXPT], invele[MAXPT];
    double pos[3], acc[3], pot, time = 0.0;
/*    char   *fmt, s[20], pfmt[256];    */
    char   headline[256], fmt1[80];
    string axis, mode, infile, plotlabel;
    stream instr;
    bool   Qtab, Qplot, Qome, Qvel, Qlv, Qin, QoILR;

    mode = getparam("mode");
    n = getiparam("n");
    plotlabel = getparam("headline");
    sprintf(fmt1,"%s ",getparam("format"));
    Qome = (*mode == 'o');      /*  options are: velocity|omega|lv */
    Qlv = (*mode == 'l');
    Qvel = (*mode == 'v');
    Qtab = getbparam("tab");
    Qplot = getbparam("plot");
    infile = getparam("in");
    Qin =  (*infile != 0);
    if (Qin) {
        nret = nemoinpi(getparam("cols"),cols,4);
        if (nret<0 || nret > 4) error("cols= requires 4 numbers");
        for (i=nret; i<4; i++)
            cols[i] = 0;
        instr = stropen(infile,"r");
        ndat = read_table(instr,MAXPT,inrad,invel,inrade,invele,cols);
        strclose(instr);
    }
    
    mypot1 = get_potential(getparam("name1"),getparam("pars1"),getparam("file1"));
    omega = get_pattern();
    dprintf(0,"Pattern speed: %f\n",omega);
    mypot2 = get_potential(getparam("name2"),getparam("pars2"),getparam("file2"));
    mypot3 = get_potential(getparam("name3"),getparam("pars3"),getparam("file3"));
    mypot4 = get_potential(getparam("name4"),getparam("pars4"),getparam("file4"));
    headline[0] = '\0';         /* accumulate headline */
    if (mypot1) {
        strcat(headline,getparam("name1"));
        strcat(headline,"(");
        strcat(headline,getparam("pars1"));
        strcat(headline,")");
        npots++;
    } 
    if (mypot2) {
        strcat(headline,getparam("name2"));
        strcat(headline,"(");
        strcat(headline,getparam("pars2"));
        strcat(headline,") ");
        npots++;
    }
    if (mypot3) {
        strcat(headline,getparam("name3"));
        strcat(headline,"(");
        strcat(headline,getparam("pars3"));
        strcat(headline,") ");
        npots++;
    }
    if (mypot4) {
        strcat(headline,getparam("name4"));
        strcat(headline,"(");
        strcat(headline,getparam("pars4"));
        strcat(headline,")");
        npots++;
    }

    nrad = nemoinpr(getparam("radii"),rad,MAXPT);   /* get radii */
    if (nrad <= 0)
        warning("Using %d radii is not very productive",nrad);
    vel  = (real *) allocate(sizeof(real) * nrad);  /* allocate stuff */
    vel1 = (real *) allocate(sizeof(real) * nrad);
    vel2 = (real *) allocate(sizeof(real) * nrad);
    vel3 = (real *) allocate(sizeof(real) * nrad);
    vel4 = (real *) allocate(sizeof(real) * nrad);
    if (Qome) {
        ome = (real *) allocate(4 * sizeof(real) * nrad);  /* plus spline */
        kap = (real *) allocate(sizeof(real) * nrad);
        opk = (real *) allocate(sizeof(real) * nrad);
        omk = (real *) allocate(sizeof(real) * nrad);
    } 

    axis = getparam("axis");
    dir = 0;
    if (*axis == 'x') dir=0;
    if (*axis == 'y') dir=1;
    if (*axis == 'z') dir=2;
    if (dir>NDIM) error("Axis %s not supported in NDIM=%d",axis,NDIM);

    pmax = 0.0;

    for (i=0; i<nrad; i++) {            /* loop to compute */
        CLRV(pos);                      /* clear positions */
        pos[dir] = rad[i];              /* set the right axis */
        vel[i] = 0.0;
        if (mypot1) {
            CLRV(acc);
            (*mypot1) (&ndim,pos,acc,&pot,&time);
            vel1[i] = -rad[i] * acc[dir];
            vel[i] += vel1[i];
            vel1[i] = sqrt(vel1[i]);        
        }
        if (mypot2) {
            CLRV(acc);
            (*mypot2) (&ndim,pos,acc,&pot,&time);
            vel2[i] = -rad[i] * acc[dir];
            vel[i] += vel2[i];
	    vel2[i] = sqrt(vel2[i]);        
        }
        if (mypot3) {
            CLRV(acc);
            (*mypot3) (&ndim,pos,acc,&pot,&time);
            vel3[i] = -rad[i] * acc[dir];
            vel[i] += vel3[i];
	    vel3[i] = sqrt(vel3[i]);        
        }
        if (mypot4) {
            CLRV(acc);
            (*mypot4) (&ndim,pos,acc,&pot,&time);
            vel4[i] = -rad[i] * acc[dir];
            vel[i] += vel4[i];
            vel4[i] = sqrt(vel4[i]);        
        }
        vel[i]  = sqrt(vel[i]);        
    }
    if (Qome) {
	lindblad(nrad,rad,vel,ome,kap,opk,omk,n);
        if (omega> 0.0) {                               /* compute resonances */
            f = opk;
            idx = nrad-1;
            if (omega < f[idx]) {
                warning("Radii not far enough out for OLR: %g",f[idx]);
                f = ome;
                if (omega < f[idx]) {
                    warning("Radii not far enough out for CR: %g",f[idx]);
                    f = omk;
                }
            }
            QoILR = FALSE;
            for(; idx>0; idx--) {
                if (omk[idx] > omk_max) {
                    idx_max = idx;
                    omk_max = omk[idx];
                }
                if (f==omk) {
                    if (QoILR) {
                        if (omega < f[idx]) continue;
                    } else {
                        if (omega > f[idx]) continue;
                    }
                } else {
                    if (omega > f[idx]) continue;
                }
                
                /* found a resonance: */

                rr = rad[idx] + (rad[idx+1]-rad[idx])*
                                (omega-f[idx])/(f[idx+1]-f[idx]);
                if (f == omk) {
#if 0                    
                    if (QoILR) {
                        dprintf(0,"iILR: %g\n",rr);
                        break;
                    } else {
                        dprintf(0,"oILR: %g\n",rr);
                        QoILR = TRUE;
                    }
#endif                    
                } else if (f == ome) {
                    dprintf(0,"CR: %g\n",rr);
                    f = omk;
                } else if (f == opk) {
                    dprintf(0,"OLR: %g\n",rr);
                    f = ome;
                } else
                    error("impossble resonance");
            }
            peak(nrad,rad,omk,idx_max,1, &omk_rmax, &omk_max);
            dprintf(0,"OMK_max: %g\n",omk_max);
            dprintf(0,"OMK_rmax: %g\n",omk_rmax);

            if (omega < omk_max) {			/* search for ILR */
            	for (idx=idx_max; idx<nrad; idx++) {
                    if (omega > omk[idx]) {
                        rr = rad[idx-1] + (rad[idx]-rad[idx-1])*
                                (omega-f[idx-1])/(f[idx]-f[idx-1]);
                        dprintf(0,"oILR: %g\n",rr);
                        break;
                    }
            	}
                for (idx=idx_max; idx>0; idx--) {
                    if (omega > omk[idx]) {
                        rr = rad[idx] + (rad[idx+1]-rad[idx])*
                               (omega-f[idx])/(f[idx+1]-f[idx]);
                        dprintf(0,"iILR: %g\n",rr);
                        break;
                    }
            	}
            }
        }
    }
    for (i=0; i<nrad; i++) {                            /* loop to print */
        if (Qtab) {
	  printf(fmt1,rad[i]);
	  printf(fmt1,vel[i]);
	}
	if (Qtab && npots>1 && !Qome) {
	    if (mypot1) printf(fmt1,vel1[i]);
	    if (mypot2) printf(fmt1,vel2[i]);
	    if (mypot3) printf(fmt1,vel3[i]);
	    if (mypot4) printf(fmt1,vel4[i]);
        }
        if (Qtab && Qome) {
	  printf(fmt1,ome[i]);
	  printf(fmt1,kap[i]);
	  printf(fmt1,opk[i]);
	  printf(fmt1,omk[i]);
	}
	if (Qtab) printf("\n");
        if (Qome)
            pmax = MAX(pmax,opk[i]);
        else
            pmax = MAX(pmax,vel[i]);
    }
    if (Qin && Qvel) 
        goodness(nrad,rad,vel,ndat,inrad,invel,(cols[3]>0?invele:NULL));
    if (Qplot) {
        plinit("***",0.0,20.0,0.0,20.0);                /* open device */
        nx = nemoinpr(getparam("xrange"),xplot,2);      /* get xrange in plot */
        switch(nx) {
         case 0:
            xplot[0] = rad[0];
         case 1:
            xplot[1] = rad[nrad-1];
            break;
         case 2:
            break;
         default:
            warning("xrange= only accepts two values");
            break;
        }
        ny = nemoinpr(getparam("yrange"),yplot,2);      /* get yrange in plot */
        switch(ny) {
         case 0:
            yplot[0] = 0.0;
            yplot[1] = 1.1 * pmax;      /* extra 10% for egde */
            break;
         case 1:
            yplot[1] = 1.1 * pmax;      /* extra 10% for egde */
            break;
         case 2:
            break;
         default:
            warning("yrange= only accepts two values");
            break;
        }
        xaxis ( 2.0, 2.0, 16.0, xplot, -7, xtrans, "R");    /* plot axes */
        xaxis ( 2.0,18.0, 16.0, xplot, -7, xtrans, NULL);
        if (Qome)
            yaxis ( 2.0, 2.0, 16.0, yplot, -7, ytrans, "[V/R]");
        else
            yaxis ( 2.0, 2.0, 16.0, yplot, -7, ytrans, "V");
        yaxis (18.0, 2.0, 16.0, yplot, -7, ytrans, NULL);
        if (*plotlabel)
            pltext(plotlabel,2.0,18.5,0.5,0.0);
        else
            pltext(headline,2.0,18.5,0.35,0.0);
        if (*plotmsg)
            pltext(plotmsg,8.0,2.5,0.25,0.0);

        curve = (Qome ? ome : vel);            /* assign first curve */
        plltype(3,1);                                 /* thick solid line */
        plmove(xtrans(rad[0]),ytrans(curve[0]));
        for (i=1; i<nrad; i++)
            plline(xtrans(rad[i]),ytrans(curve[i]));
        if (Qome) {                   /* if Lindblad - plot omk, opk */
            plltype(1,1);                      /* all regular solid lines */
            plmove(xtrans(rad[0]), ytrans(omk[0]));
            for (i=1; i<nrad; i++)
                plline(xtrans(rad[i]),ytrans(omk[i]));
            plmove(xtrans(rad[0]), ytrans(opk[0]));
            for (i=1; i<nrad; i++)
                plline(xtrans(rad[i]),ytrans(opk[i]));
        } else if (npots>1) {            /* if velocity and > 1 component */
            ltype = 1;
            if (mypot1) {
                plltype(1,++ltype);
                plmove(xtrans(rad[0]),ytrans(vel1[0]));
                for (i=1; i<nrad; i++)
                    plline(xtrans(rad[i]),ytrans(vel1[i]));
            }
            if (mypot2) {
                plltype(1,++ltype);
                plmove(xtrans(rad[0]),ytrans(vel2[0]));
                for (i=1; i<nrad; i++)
                    plline(xtrans(rad[i]),ytrans(vel2[i]));
            }
            if (mypot3) {
                plltype(1,++ltype);
                plmove(xtrans(rad[0]),ytrans(vel2[0]));
                for (i=1; i<nrad; i++)
                    plline(xtrans(rad[i]),ytrans(vel3[i]));
            }
            if (mypot4) {
                plltype(1,++ltype);
                plmove(xtrans(rad[0]),ytrans(vel2[0]));
                for (i=1; i<nrad; i++)
                    plline(xtrans(rad[i]),ytrans(vel4[i]));
            }
        }
	plltype(1,1); 
        symsize = 0.1;
        if (Qin && Qvel) {           /* if input file with velocities */
            for (i=0; i<ndat; i++)
                plbox(xtrans(inrad[i]),ytrans(invel[i]),symsize);
            if (cols[3]>0) {        /* if error bars in radius */
                for (i=0; i<ndat; i++) {
                    plmove(xtrans(inrad[i]-inrade[i]),ytrans(invel[i]));
                    plline(xtrans(inrad[i]+inrade[i]),ytrans(invel[i]));
                }
            }
            if (cols[4]>0) {        /* if error bars in velocity */
                for (i=0; i<ndat; i++) {
                    plmove(xtrans(inrad[i]),ytrans(invel[i]-invele[i]));
                    plline(xtrans(inrad[i]),ytrans(invel[i]+invele[i]));
                }
            }
        } else if (Qin && Qome) {       /* if input file with omega */
            for (i=0; i<ndat; i++)
                plbox(xtrans(inrad[i]),ytrans(invel[i]/inrad[i]),symsize);
        }
        plstop();
    }  /* if plot vel/ome */
    if (Qlv) {
        ns = nemoinpr(getparam("r0l"),r0l,MAXPT+2) - 2;
        if (ns < 0)
            error("r0l= needs at least two values: r0 and l");
        else if (ns==0)
            warning("r0l= no lv-radii array supplied");
        lv(nrad,rad,vel,r0l[0],r0l[1],ns,&r0l[2]);
    }
}