1 #ifdef HAVE_STDLIB_H
2 #include <stdlib.h>
3 #endif
4 #include <stdio.h>
5 #include <math.h>
6 #include <errno.h>
7 #include "yagi.h"
8 #include <errno.h>
9
10
write_gain_at_various_angles(FILE * gain_fp,double angular_step,double pin,double normalised_f,double f,struct element_data * coordinates,struct FCOMPLEX * current,int elements,double design_f)11 void write_gain_at_various_angles(FILE *gain_fp, double angular_step, double pin, double normalised_f, double f, struct element_data *coordinates, struct FCOMPLEX *current, int elements, double design_f)
12 {
13 double theta, phi, gain_E_plane, gain_H_plane, E_plane_gain, H_plane_gain;
14 double peak_gain;
15 static int run_first_time=0;
16 fprintf(gain_fp,"# f(MHz) theta gain-E(dBi) G(E)-peak phi gain-H(dBi) G(H)-peak\n");
17 run_first_time=1;
18 gain(90.0,0,pin,normalised_f,coordinates, current, elements, &gain_E_plane, &peak_gain, f, design_f);
19 for(phi=-180;phi <=180.0;phi+=angular_step)
20 {
21 theta=90+phi; /* Just helps program a bit. I'm not saying it is!! */
22 /* compute gain(phi, 90) */
23
24 gain(90.0,phi+360,pin,normalised_f,coordinates, current, elements, &gain_E_plane, &gain_H_plane, f, design_f);
25
26 H_plane_gain=gain_H_plane;
27
28 theta=90+phi; /* Just helps program a bit. I'm not saying it is!! */
29 /* compute gain(theta,0) where thete =90-270 degrees */
30 gain(theta+360,0,pin,normalised_f,coordinates, current, elements, &gain_E_plane, &gain_H_plane, f, design_f);
31 E_plane_gain=gain_E_plane;
32 fprintf(gain_fp,"%10.4f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\n",f/1e6, theta, E_plane_gain, E_plane_gain-peak_gain, phi, H_plane_gain, H_plane_gain-peak_gain);
33 }
34
35 #ifdef DEBUG
36 if(errno)
37 {
38 fprintf(stderr,"Errno =%d in write_ga.c\n", errno);
39 exit(1);
40 }
41 #endif
42 }
43
44