#include #include #include #include /* This defines how small segments to use in the produced NEC2 code */ #define radialsegments 5 #define cornersegments 3 #define helixsegments 15 /* This is the length of the feedpoint */ #define epsilon 10 /* Mmmmm... pi */ #define pi 3.14159265359 typedef struct { double H; //height double D; //diameter double R; //angle radius double turns; //number of turns double offset; //distance from origin double Theta; //initial theta angle double wire; //radius of wire char feed; //O=open, S=short, T=terminated to 50 ohms int feedpoint; //tag of feed segment } helix; void make_helix(FILE *, helix); int ITG=1; int feedpointhack; int main(int argc, char*argv[]) { FILE *infile; FILE *outfile; int i, n, feed=0; helix *h; double fstart, fstop, fstep; if(argc!=3) { printf("Usage: helix2nec \n"); exit(1); } if((infile=fopen(argv[1],"r"))==NULL) { printf("Could not open input file %s\n",argv[1]); exit(1); } if((outfile=fopen(argv[2],"w"))==NULL) { printf("Could not open output file %s\n",argv[2]); exit(1); } // Parse the input file if(fscanf(infile, "%d", &n)!=1) { printf("Error in input file %s (number of helices)\n",argv[1]); exit(1); } if((h=(helix*)malloc(2*n*sizeof(helix)))==NULL) { printf("Error allocating memory for %d helices\n",n); exit(1); } fprintf(outfile, "CM NEC2 Input File produced by helix2nec\n"); fprintf(outfile, "CM Parameters:\n"); for(i=0;i1) { printf("Too many feed helices in model!!!\n"); exit(1); } // Frequency specification if(fscanf(infile, "%lf %lf %lf", &fstart, &fstop, &fstep)!=3) { printf("Error in input file %s, (frequency)\n", argv[1]); exit(1); } fprintf(outfile, "CM %.5E - %.5E MHz in %.5E MHz steps\n", fstart, fstop, fstep); fprintf(outfile, "CE\n"); // do the helices for(i=0;i