import scipy.optimize as opt import numpy as np import pum.algorithms as alg from pum.lines import * a = 7 * const.milli b = 3.04 * const.milli c = 0 print 'Z coax: {}' .format( coax_z( a, b, 1, 1)) print 'Z skew: {}' .format( skew_coax_z( c, a, b, 1, 1)) print 'Z error {}' .format( (coax_z( a, b, 1, 1) - skew_coax_z( c, a, b, 1, 1)) / coax_z( a, b, 1, 1) * 100) def analytical( a, b, mu_r, epsilon_r): d = coax_z(a, b, mu_r, epsilon_r) - 5 k = 59.952 * np.sqrt(mu_r/epsilon_r) return np.sqrt( (( a*a) - ( 2*a*b*np.cosh(d/k)) + ( b*b)) / 4) def find_coax( c): return skew_coax_z( c, a, b, 1, 1) - coax_z( a, b, 1, 1) + 5 c = opt.newton( find_coax, 0.8 * const.milli); my_c = alg.newton_raphson( find_coax, 0, 2 * const.milli, tol=1e-10) print 'analytical shift {} mm' .format( analytical( a, b, 1, 1) / const.milli) print 'numerical shift {} mm' .format( c / const.milli) print 'Z skewed: {}' .format( skew_coax_z( c, a, b, 1, 1)) print 'shift my newt: {} mm' .format( my_c / const.milli) print 'my error: {}' .format( np.abs( my_c - c))
import scipy.constants as const import scipy.optimize as opt import numpy as np import pum.algorithms as alg from pum.lines import * b = 9 * const.milli eps = 2.04 mu = 1 def find_z( d, mu, eps): return cylindrical_flat( d, b, mu, eps) - 30 my_d = alg.newton_raphson( find_z, 0.01 * const.milli, 3.99 * const.milli, tol=1e-10, args = ( 1, 1)) d = opt.newton( find_z, my_d, args = ( 1, 1)); print 'py d = {} mm' .format( d / const.milli) print 'my d = {} mm' .format( my_d / const.milli) z0 = cylindrical_flat( my_d, b, 1, 1) z1 = cylindrical_flat( my_d, b, mu, eps) print 'Z(mu_r = 1; eps_r = 1) = {}' .format( z0) print 'Z(mu_r = 2.04; eps_r = 1) = {}' .format( z1) print 'Z change = {}' .format(z1 - z0)
f0 = 1.35 * const.giga R = 1 y1 = np.sqrt( 10 ** ( - C / 10)) y2 = np.sqrt( 1 - ( y1 ** 2)) Z1 = Z0 / y1 Z2 = Z0 / y2 print( 'y1 = {}; y2 = {}; Z1 = {}; Z2 = {}' .format( y1, y2, Z1, Z2)) def find_w1( w): return microstrip( w, t, h, f0, mu, eps) - Z1 def find_w2( w): return microstrip( w, t, h, f0, mu, eps) - Z2 w1 = alg.newton_raphson( find_w1, 0.5 * const.milli, 2 * const.milli, (), tol=1e-10) w2 = alg.newton_raphson( find_w2, 0.5 * const.milli, 2 * const.milli, (), 1e-10) print( 'w1 = {}; w2 = {}' .format( w1 / const.milli, w2 / const.milli)) print( 'spr') print( 'Z1 = {}; Z2 = {}' \ .format( microstrip( w1, t, h, f0, mu, eps), \ microstrip( w2, t, h, f0, mu, eps))) f = f0 epsilon = eps u = w1 / h if t != 0: du = ( t / ( 2 * const.pi * h)) * np.log( 1 + ( ( 4 * np.exp(1) * h) / ( t * ( ( 1 / np.tanh( np.sqrt( 6.517 * u)))**2)))) * ( 1 + ( 1 / np.cosh( np.sqrt( epsilon - 1)))) u += du a = 1 + ( ( 1 / 49) * np.log( ( ( u**4) + ( ( u / 52)**2)) / ( ( u**4) + 0.432))) + ( ( 1 / 18.7) * np.log( 1 + ( ( u / 18.1)**3)))
k = 1/ np.sqrt( 10 ** ( C / 10) - 1) print( 'k = {}' .format( k)) Z1 = Z0 / k Z2 = Z0 * np.sqrt( R / ( 1 + ( k ** 2))) Z3 = Z0 * R / k print( 'Z1 = {}; Z2 = {}; Z3 = {}' .format( Z1, Z2, Z3)) def find_w1( w): return microstrip( w, t, h, f0, mu, eps) - Z1 def find_w2( w): return microstrip( w, t, h, f0, mu, eps) - Z2 def find_w3( w): return microstrip( w, t, h, f0, mu, eps) - Z3 w1 = alg.newton_raphson( find_w1, 1 * const.milli, 3 * const.milli, (), tol=1e-10) w2 = alg.newton_raphson( find_w2, 3 * const.milli, 5 * const.milli, (), 1e-10) w3 = alg.newton_raphson( find_w3, 1 * const.milli, 3 * const.milli, (), 1e-10) print( 'w1 = {}; w2 = {}; w3 = {}' .format( w1 / const.milli, w2 / const.milli, w3 / const.milli)) print( 'spr') print( 'Z1 = {}; Z2 = {}; Z3 = {}' \ .format( microstrip( w1, t, h, f0, mu, eps), \ microstrip( w2, t, h, f0, mu, eps), \ microstrip( w3, t, h, f0, mu, eps))) f = f0 epsilon = eps u = w1 / h if t != 0: du = ( t / ( 2 * const.pi * h)) * np.log( 1 + ( ( 4 * np.exp(1) * h) / ( t * ( ( 1 / np.tanh( np.sqrt( 6.517 * u)))**2)))) * ( 1 + ( 1 / np.cosh( np.sqrt( epsilon - 1))))