~ubuntu-branches/ubuntu/precise/yagiuda/precise

« back to all changes in this revision

Viewing changes to .pc/debian-changes-1.19-6.2/src/test2.c

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2010-08-25 22:19:13 UTC
  • Revision ID: james.westby@ubuntu.com-20100825221913-lgc7yuj3f7nqugpm
Tags: 1.19-7
* QA upload
* Source format 3.0 (quilt)
* patch optopt-declaration: fix declaration of optopt (closes: 593486).
  Thanks a lot to Jakub Wilk <jwilk@debian.org> for the patch!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
9
extern int errno;
 
10
 
 
11
int main(int argc, char **argv)
 
12
{
 
13
        double r,x,d;
 
14
        for(d=0.0000001;d<=1;d+=0.02)
 
15
        {
 
16
                z21(1.0,d,0.5, &r, &x);
 
17
                printf("%f %f %f %f \n", d,r,x, sqrt(r*r+x*x));
 
18
        }
 
19
        exit(0);
 
20
}
 
21
 
 
22
/* To find the mutual impedance between to arbitary length, thin elements
 
23
I used the equations on Krauss, Antennas, McGraw Hill, 1988, pp426 and
 
24
427. Original work from Brown and King, 'High Frequency Models in Antenna
 
25
Investigations', Proc IRE, vol 22, pp457-480, April 1934*/
 
26
void z21(double lamda, double d, double l, double *r21, double *x21)
 
27
{
 
28
 
 
29
        double  b, cos_bl, sin_bl, sin_bl_over_2, cos_bl_over_2, c, s ;
 
30
        double t1, t2, t3, t4;
 
31
        double si_t1, ci_t1, si_t4, ci_t4, ci_bd, si_bd;
 
32
        double ci_t2, si_t2, ci_t3, si_t3;
 
33
 
 
34
        b=M_PI*2/lamda;
 
35
        t1=b*(sqrt(d*d+l*l)+l);
 
36
        t2=0.5*b*(sqrt(4*d*d+l*l)-l);
 
37
        t3=0.5*b*(sqrt(4*d*d+l*l)+l);
 
38
        t4=b*(sqrt(d*d+l*l)-l);
 
39
        /* To save findinding the same slow trigometric and ever slower
 
40
        si and ci functions, I'll just look them up once */
 
41
        cos_bl=cos(b*l);
 
42
        sin_bl=sin(b*l);
 
43
        sin_bl_over_2=sin(b*l/2);
 
44
        cos_bl_over_2=cos(b*l/2);
 
45
        s=sin_bl_over_2*sin_bl_over_2;
 
46
        c=cos_bl_over_2*cos_bl_over_2;
 
47
 
 
48
        cisi(t1, &ci_t1, &si_t1);
 
49
        cisi(t2,&ci_t2, &si_t2);
 
50
        cisi(t3,&ci_t3, &si_t3);
 
51
        cisi(t4, &ci_t4, &si_t4);
 
52
        cisi(b*d,&ci_bd, &si_bd);
 
53
        /* Real part of mutual impedance, computed as equation on page
 
54
        426 of Kraus */
 
55
        *r21=(30/s)*(2*(2+cos_bl)*ci_bd
 
56
        -4*c*( ci_t2 + ci_t3 )
 
57
        +cos_bl*( ci_t4 + ci_t1 )
 
58
        +sin_bl* ( si_t1 - si_t4 -2*si_t3 +2*si_t2 ) );
 
59
 
 
60
        /* Imaginary part of mutual impedance, computed as equation on page
 
61
        427 of Kraus */
 
62
        *x21=(30/s)*(-2*(2+cos_bl)*si_bd
 
63
        +4*c*( si_t2 + si_t3 )
 
64
        -cos_bl*( si_t4 + si_t1 )
 
65
        +sin_bl* ( ci_t1 - ci_t4 -2*ci_t3 +2*ci_t2 ) );
 
66
#ifdef DEBUG
 
67
        if(errno)
 
68
        {
 
69
                fprintf(stderr,"Errno =%d in  z21() mutual.c\n", errno);
 
70
                exit(1);
 
71
        }
 
72
#endif
 
73
}  
 
74
 
 
75
double ci(double x)                     /* cosine integral */
 
76
{
 
77
        double null, result;
 
78
 
 
79
        cisi(x, &result, &null);
 
80
        return(result);
 
81
}