Smith Sphere

The smith chart is a nomogram used frequently in RF/Microwave Engineering. Since its inception it has been recognised that projecting the chart onto the reimen sphere [1].

[1]H. . Wheeler, “Reflection Charts Relating to Impedance Matching,” IEEE Transactions on Microwave Theory and Techniques, vol. 32, no. 9, pp. 1008–1021, Sep. 1984.


In [36]:
#from IPython.display import SVG
#SVG('pics/smith_sphere.svg')
from printer import Format

In [45]:
from ga import Ga
from sympy import *
Format()

(ga,er,ex,es) = Ga.build('e_r e_x e_s',g=[1,1,1])
(gaz,zr,zx) = Ga.build('z_r z_x',g=[1,1])

Bz = er^ex # impedance plance 
Bs = es^ex # reflection coefficient plane
Bx = er^es
I = ga.I()

def down(p, N):
    '''
    stereographically project a vector in G3 downto the bivector N
    '''
    n= -1*N.dual()
    return -(n^p)*(n-n*(n|p)).inv() 

def up(p):
    '''
    stereographically project a vector in G2 upto the space G3
    '''
    if (p^Bz).obj == 0:
        N = Bz
    elif  (p^Bs).obj == 0:
        N = Bs
        
    n = -N.dual()
    
    return   n + 2*(p*p + 1).inv()*(p-n)
    
a,b,c,z,s,n = [ga.mv(k,'vector') for k in ['a','b','c','z','s' ,'n']]


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-45-75793eef228a> in <module>()
      6 (gaz,zr,zx) = Ga.build('z_r z_x',g=[1,1])
      7 
----> 8 Bz = er^ex # impedance plance
      9 Bs = es^ex # reflection coefficient plane
     10 Bx = er^es

/home/brombo/Git Repositories/galgebra/galgebra/mv.pyc in __xor__(self, A)
    640             return A.Mul(self, A, op='^')
    641 
--> 642         if self.is_scalar():
    643             return self * A
    644 

/home/brombo/Git Repositories/galgebra/galgebra/mv.pyc in is_scalar(self)
    726 
    727     def is_scalar(self):
--> 728         grades = self.Ga.grades(self.obj)
    729         if len(grades) == 1 and grades[0] == 0:
    730             return True

/home/brombo/Git Repositories/galgebra/galgebra/ga.pyc in grades(self, A)
   1073         for blade in blades:
   1074             if blade != one:
-> 1075                 grade = self.blades_to_grades_dict[blade]
   1076                 if grade not in grade_lst:
   1077                     grade_lst.append(grade)

KeyError: e_r

Starting with an impedance vector $z$, defined by a vector in the impedance plane $B_z$, this vector has two scalar components ( $z^r$, $z^x$) known as resistance and reactance


In [38]:
Bz.dual()
Bz.is_zero()


Out[38]:
False

In [39]:
z = z.proj([er,ex])
z


Out[39]:
\begin{equation*} z^{r} e_{r} + z^{x} e_{x} \end{equation*}

stereographically up-projecting this onto the sphere to point $p$,


In [40]:
p = up(z)
p


Out[40]:
\begin{equation*} \frac{2 z^{r}}{{\left ( z^{r} \right )}^{2} + {\left ( z^{x} \right )}^{2} + 1} e_{r} + \frac{2 z^{x}}{{\left ( z^{r} \right )}^{2} + {\left ( z^{x} \right )}^{2} + 1} e_{x} + \frac{{\left ( z^{r} \right )}^{2} + {\left ( z^{x} \right )}^{2} - 1}{{\left ( z^{r} \right )}^{2} + {\left ( z^{x} \right )}^{2} + 1} e_{s} \end{equation*}

In [41]:
p.norm2()


Out[41]:
z__r**4/(z__r**4 + 2*z__r**2*z__x**2 + 2*z__r**2 + z__x**4 + 2*z__x**2 + 1) + 2*z__r**2*z__x**2/(z__r**4 + 2*z__r**2*z__x**2 + 2*z__r**2 + z__x**4 + 2*z__x**2 + 1) + 2*z__r**2/(z__r**4 + 2*z__r**2*z__x**2 + 2*z__r**2 + z__x**4 + 2*z__x**2 + 1) + z__x**4/(z__r**4 + 2*z__r**2*z__x**2 + 2*z__r**2 + z__x**4 + 2*z__x**2 + 1) + 2*z__x**2/(z__r**4 + 2*z__r**2*z__x**2 + 2*z__r**2 + z__x**4 + 2*z__x**2 + 1) + 1/(z__r**4 + 2*z__r**2*z__x**2 + 2*z__r**2 + z__x**4 + 2*z__x**2 + 1)

If we stereo-project this back onto the impedance plane


In [42]:
down(p, Bz)


Out[42]:
\begin{equation*} z^{r} e_{r} + z^{x} e_{x} \end{equation*}

In [43]:
down(p,Bs).simplify()


Out[43]:
\begin{equation*} \frac{2 z^{x}}{{\left ( z^{r} \right )}^{2} + 2 z^{r} + {\left ( z^{x} \right )}^{2} + 1} e_{x} + \frac{{\left ( z^{r} \right )}^{2} + {\left ( z^{x} \right )}^{2} - 1}{{\left ( z^{r} \right )}^{2} + 2 z^{r} + {\left ( z^{x} \right )}^{2} + 1} e_{s} \end{equation*}

In [44]:
(z-er)*(z+er).inv()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-44-f7cdd8a6bc54> in <module>()
----> 1 (z-er)*(z+er).inv()

/home/brombo/Git Repositories/galgebra/galgebra/mv.pyc in __sub__(self, A)
    366 
    367         if self.Ga.name != A.Ga.name:
--> 368             raise ValueError('In - operation Mv arguments are not from same geometric algebra')
    369 
    370         if isinstance(A, Dop):

ValueError: In - operation Mv arguments are not from same geometric algebra

In [ ]:
p

In [ ]:
R=((-pi/4)*Bx).exp()
R

In [ ]:
R*p*R.rev()

In [ ]:
down(R*p*R.rev(),Bz)

In [ ]:
#Fmt([R,R])

In [ ]:
#Fmt((R,p))

In [ ]: