9
/* This routines finds the maximum sidelobe level in the antenna pattern,
10
outside the main beam. The fasteest one, find_max_sidelobe_fast is used by
11
optimise when seeing how clean the pattern is. Its not perfect, but its
14
The other one, find_max_sidelobe_slow is much more accurate, doing a good
15
job of finding the sidelobes, but takes longer to do. Hence its not
16
really suitable for optimisation, but its okay for 'output' where we dont
17
care too much about spped. */
19
extern double angular_stepsize_2,min_offset_from_peak;
24
#define STEP 1 /* anglur step in degrees */
26
double dB_down_from_peak(double x, double pin, struct element_data *coordinates, struct FCOMPLEX *current,int elements, double f, double design_f)
28
double ans,gain_H_plane,peak_gain, gain_at_x;
29
gain(90.0, 0.0, pin, f/design_f, coordinates, current, elements, &peak_gain, &gain_H_plane, f, design_f);
30
gain(x, 0.000, pin, f/design_f, coordinates, current, elements, &gain_at_x, &gain_H_plane, f, design_f);
31
ans=peak_gain-gain_at_x;
36
double find_max_sidelobe_slow(double gain, double pin,struct element_data *coordinates, struct FCOMPLEX *current, int elements, double frequency,double design_f)
38
double level,best=-1000.0,a=90.0,theta,max=1e8;
41
a+=STEP; /* Use 1 degree or similar step*/
42
level=dB_down_from_peak(a,pin,coordinates,current,elements,frequency,design_f);
50
}while(k==BETTER && a<=270.0);
52
for(theta=a; theta<270.01; theta+=STEP)
54
level=dB_down_from_peak(theta,pin,coordinates,current,elements,frequency,design_f);
65
double find_max_sidelobe_fast(double gain, double pin,struct element_data *coordinates, struct FCOMPLEX *current, int elements, double frequency,double design_f)
67
double angle=90.0,min_angle,min,max=270,three_dB_point,min_level=1000000.0;
68
double level, min_times;
71
if(min_offset_from_peak==0.0)
73
three_dB_point=sqrt(41000.0/(pow(10.0,gain/10.0)));
74
if(three_dB_point > 90.0)
77
min=90.0+(three_dB_point);
80
min=90.0+min_offset_from_peak;
81
if(angular_stepsize_2==0.0)
82
angular_stepsize_2=three_dB_point/30.0; /* step sixe to use - rough */
83
/* Since this is only an approximate quick method, you cant expect
84
supeurb accuracy - use _fast if you want that. I'll evaluate at
85
1/10th of the beamwidth, so if the 3dB beamwidth is estimated to be
86
40 deg, we will evualate every 4 deg. However, we need to evalate at
87
precise 270 degrees, otherwise its possible the max sidelobe will be
88
less than the FB, which is silly. To avoid this, I'll ensure its
89
evaluated at 270 deg, so the step size will be altered to do this. */
90
min_times=(max-min)/angular_stepsize_2;
91
N=(int) (min_times+1.0);
93
for(angle=min; angle <=max;angle+=(max-min)/N)
95
level=dB_down_from_peak(angle,pin,coordinates,current,elements,frequency,design_f);
102
/* printf("min=%.2f min_angle=%.2f angle=%.2f f=%f\n ",min_level,min_angle,angle,frequency); */