8
/* better.c This function compares new and old performance of a yagi to see if
11
extern double vswr, Zo;
12
extern struct performance_data max;
14
int is_it_better(int criteria,struct performance_data n, struct performance_data o)
16
double resistance_error;
17
struct FCOMPLEX zi_new, zi_old;
19
resistance_error=fabs(n.r - Zo) - fabs( o.r - Zo );
24
/* printf("o=%.3lfdBi %.3f dB %.4f:1\n", o.gain, o.fb, o.swr);
25
printf("n=%.3lfdBi %.3f dB %.4f:1\n\n", n.gain, n.fb, n.swr); */
26
/* If the user add REASONABLE to the 'better' argument, the program
27
will make some intelligent guesses about whats a reasonale antenna. This
28
could for example avoid ignoring an antenna with 20dB gain but 1.02:1
29
vswr, in favour of 15dB gain but 1.01 vswr. Usually we would consider
30
(all other things equal) the former antenna better. Hence we wont
31
bother optimising beyond these */
33
if( (criteria & REASONABLE) == REASONABLE)
35
if( (n.fb > max.fb) && (n.fb < o.fb))
38
if( (fabs(n.r-Zo) < max.r) &&
39
( fabs(n.r-Zo) > fabs(o.r-Zo) ) )
44
if( (n.swr < max.swr) && (n.swr > o.swr) )
47
if( (fabs(n.x) < max.x) &&
48
fabs(n.x) > fabs(o.x) )
51
if( (n.sidelobe > max.sidelobe) && (n.sidelobe < o.sidelobe) )
52
n.sidelobe=o.sidelobe;
54
if( (criteria & GAIN) == GAIN)
59
if( (criteria & FB) == FB)
64
if( (criteria & RESISTANCE) == RESISTANCE)
66
resistance_error=fabs(n.r-Zo)-fabs(o.r-Zo);
67
if(resistance_error > 0.0)
70
if( (criteria & REACTANCE) == REACTANCE)
72
if(fabs(n.x) > fabs(o.x))
75
if( (criteria & VSWR) == VSWR)
80
if((criteria & SIDE_LOBE_LEVEL) == SIDE_LOBE_LEVEL)
82
if(n.sidelobe < o.sidelobe)
88
fprintf(stderr,"Errno =%d in better.c\n", errno);