coax.cpp 5.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*
 * coax.cpp - coaxial class implementation
 *
 * Copyright (C) 2001 Gopal Narayanan <gopal@astro.umass.edu>
 * Copyright (C) 2002 Claudio Girardi <claudio.girardi@ieee.org>
 * Copyright (C) 2005, 2006 Stefan Jahn <stefan@lkcc.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this package; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */


/*
 * coax.c - Puts up window for microstrip and
 * performs the associated calculations
 */


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
35
#include <cmath>
36

37 38 39
#include <units.h>
#include <transline.h>
#include <coax.h>
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239

COAX::COAX() : TRANSLINE()
{
    m_name = "Coax";
}


/*
 * get_coax_sub() - get and assign coax substrate parameters into coax
 * structure
 */
void COAX::get_coax_sub()
{
    er    = getProperty( EPSILONR_PRM );
    mur   = getProperty( MUR_PRM );
    murC  = getProperty( MURC_PRM );
    tand  = getProperty( TAND_PRM );
    sigma = 1.0 / getProperty( RHO_PRM );
}


/*
 * get_coax_comp() - get and assign coax component parameters into
 * coax structure
 */
void COAX::get_coax_comp()
{
    f = getProperty( FREQUENCY_PRM );
}


/*
 * get_coax_elec() - get and assign coax electrical parameters into
 * coax structure
 */
void COAX::get_coax_elec()
{
    Z0    = getProperty( Z0_PRM );
    ang_l = getProperty( ANG_L_PRM );
}


/*
 * get_coax_phys() - get and assign coax physical parameters into coax
 * structure
 */
void COAX::get_coax_phys()
{
    din  = getProperty( PHYS_DIAM_IN_PRM );
    dout = getProperty( PHYS_DIAM_OUT_PRM );
    l    = getProperty( PHYS_LEN_PRM );
}


double COAX::alphad_coax()
{
    double ad;

    ad = (M_PI / C0) * f * sqrt( er ) * tand;
    ad = ad * 20.0 / log( 10.0 );
    return ad;
}


double COAX::alphac_coax()
{
    double ac, Rs;

    Rs = sqrt( M_PI * f * murC * MU0 / sigma );
    ac = sqrt( er ) * ( ( (1 / din) + (1 / dout) ) / log( dout / din ) ) * (Rs / ZF0);
    ac = ac * 20.0 / log( 10.0 );
    return ac;
}


/*
 * analyze() - analysis function
 */
void COAX::analyze()
{
    double lambda_g;

    /* Get and assign substrate parameters */
    get_coax_sub();

    /* Get and assign component parameters */
    get_coax_comp();

    /* Get and assign physical parameters */
    get_coax_phys();

    if( din != 0.0 )
    {
        Z0 = ( ZF0 / 2 / M_PI / sqrt( er ) ) * log( dout / din );
    }

    lambda_g = ( C0 / (f) ) / sqrt( er * mur );
    /* calculate electrical angle */
    ang_l = (2.0 * M_PI * l) / lambda_g; /* in radians */

    setProperty( Z0_PRM, Z0 );
    setProperty( ANG_L_PRM, ang_l );

    show_results();
}


/*
 * synthesize() - synthesis function
 */
void COAX::synthesize()
{
    double lambda_g;

    /* Get and assign substrate parameters */
    get_coax_sub();

    /* Get and assign component parameters */
    get_coax_comp();

    /* Get and assign electrical parameters */
    get_coax_elec();

    /* Get and assign physical parameters */
    get_coax_phys();

    if( isSelected( PHYS_DIAM_IN_PRM ) )
    {
        /* solve for din */
        din = dout / exp( Z0 * sqrt( er ) / ZF0 * 2 * M_PI );
        setProperty( PHYS_DIAM_IN_PRM, din );
    }
    else if( isSelected( PHYS_DIAM_OUT_PRM ) )
    {
        /* solve for dout */
        dout = din * exp( Z0 * sqrt( er ) / ZF0 * 2 * M_PI );
        setProperty( PHYS_DIAM_OUT_PRM, dout );
    }

    lambda_g = ( C0 / (f) ) / sqrt( er * mur );
    /* calculate physical length */
    l = (lambda_g * ang_l) / (2.0 * M_PI); /* in m */
    setProperty( PHYS_LEN_PRM, l );

    show_results();
}


/*
 * show_results() - show results
 */
void COAX::show_results()
{
    double fc;
    short  m, n;
    char   text[256], txt[256];

    atten_dielectric = alphad_coax() * l;
    atten_cond = alphac_coax() * l;

    setResult( 0, er, "" );
    setResult( 1, atten_cond, "dB" );
    setResult( 2, atten_dielectric, "dB" );

    n  = 1;
    fc = C0 / (M_PI * (dout + din) / (double) n);
    if( fc > f )
        strcpy( text, "none" );
    else
    {
        strcpy( text, "H(1,1) " );
        m  = 2;
        fc = C0 / ( 2 * (dout - din) / (double) (m - 1) );
        while( (fc <= f) && (m<10) )
        {
            sprintf( txt, "H(n,%d) ", m );
            strcat( text, txt );
            m++;
            fc = C0 / ( 2 * (dout - din) / (double) (m - 1) );
        }
    }
    setResult( 3, text );

    m  = 1;
    fc = C0 / (2 * (dout - din) / (double) m);
    if( fc > f )
        strcpy( text, "none" );
    else
    {
        strcpy( text, "" );
        while( (fc <= f) && (m<10) )
        {
            sprintf( txt, "E(n,%d) ", m );
            strcat( text, txt );
            m++;
            fc = C0 / (2 * (dout - din) / (double) m);
        }
    }
    setResult( 4, text );
}