<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Ideal T-junction
In this notebook, We derive the scattering parameters of an ideal 3-nodes junction, as illustrated in the figure below. 
<img src="./figures/Tjunction.png" width=300 />
Assumptions
We are making the following assumptions, derived from Kirchhoff's laws
Step1:  Exemple 
Step2:  Passivity test
Does the scattering matrix is passive, ie. does $S.S^H=1$ ?
<ASSISTANT_TASK:>
Python Code:
%pylab inline
from __future__ import division # avoid integer division if used with Python2.
def Z_par(Zj, Zk):
    return( Zj*Zk / (Zj + Zk))
def Sii(Zi, Zj, Zk):
    Zjk = Z_par(Zj, Zk)
    Sii = (Zjk - Zi)/(Zjk + Zi)
    return(Sii)
    
def Sji(Zi, Zj, Zk):
    Zjk = Z_par(Zj, Zk)
    Sji = sqrt(Zi)/sqrt(Zj)*2*Zjk / (Zjk + Zi) 
    return(Sji)
    
def get_S(Z0,Z1,Z2):
    S = np.zeros((3,3))
    S[0,0] = Sii(Z0, Z1, Z2)
    S[1,1] = Sii(Z1, Z2, Z0)
    S[2,2] = Sii(Z2, Z0, Z1)
    
    S[1,0] = Sji(Z0, Z1, Z2)
    S[2,0] = Sji(Z0, Z2, Z1)
    S[2,1] = Sji(Z1, Z2, Z0)
    S[0,1] = Sji(Z1, Z0, Z2)
    S[0,2] = Sji(Z2, Z0, Z1)
    S[1,2] = Sji(Z2, Z1, Z0)
    return(S)
Explanation: Ideal T-junction
In this notebook, We derive the scattering parameters of an ideal 3-nodes junction, as illustrated in the figure below. 
<img src="./figures/Tjunction.png" width=300 />
Assumptions
We are making the following assumptions, derived from Kirchhoff's laws:
$V_0 = V_1 = V_2 = V$
$I_0 + I_1 + I_2 = 0$
We have also the definitions of the power waves in terms of total voltage and current:
$a_i = \frac{1}{2\sqrt{Z_i}} \left(V_i + Z_i I_i \right) $
$b_i = \frac{1}{2\sqrt{Z_i}} \left(V_i - Z_i I_i \right) $
and inversely
$V_i = \sqrt{Z_i} \left( a_i + b_i \right)$
$I_i = \frac{1}{\sqrt{Z_i}} \left( a_i - b_i\right )$
$S_{ii}$ terms
By definition :
$$ S_{ii} = \left. \frac{b_i}{a_i}\right|_{a_j=a_k=0}$$
From the definitions of the power waves:
$$S_{ii} = \frac{V_i - Z_i I_i}{V_i + Z_i I_i}$$ 
Since the voltages are equal and since $a_j=a_k=0$ as stated above, we have :
$ V_j = V_i \rightarrow \sqrt{Z_j} b_j = \sqrt{Z_i} \left(a_i + b_i\right)$
$ V_k = V_i \rightarrow \sqrt{Z_k} b_k = \sqrt{Z_i} \left(a_i + b_i\right)$
from which we deduce :
$b_j = \sqrt{\frac{Z_i}{Z_j}} \left(a_i + b_i\right)$
$b_k = \sqrt{\frac{Z_i}{Z_k}} \left(a_i + b_i\right)$
Using node's assumption :
$$I_i = - I_j - I_k =  \frac{1}{\sqrt{Z_j}} b_j + \frac{1}{\sqrt{Z_k}} b_k $$
ie
$$I_i = \sqrt{Z_i} \left(a_i + b_i\right) \left( \frac{1}{Z_j}   + \frac{1}{Z_k}\right)$$
The scattering parameter is thus:
$$ S_{ii} = \frac{1 - Z_i \left( \frac{1}{Z_j}   + \frac{1}{Z_k} \right)}{1 + Z_i \left( \frac{1}{Z_j}   + \frac{1}{Z_k} \right)} $$
or, with $Z_j \parallel Z_k - Z_i = Z_j Z_k/(Z_j + Z_k)$ :
$$S_{ii} =  \boxed{\displaystyle \frac{Z_j \parallel Z_k - Z_i}{Z_j \parallel Z_k + Z_i}}$$
From the above equation, one can see that having $Z_i = Z_j \parallel Z_k$ leads to match the port $i$.
$S_{ji}$ terms
$$S_{ji} = \left. \frac{\sqrt{Z_i}}{\sqrt{Z_j}} \frac{V_j - Z_j I_j}{V_i + Z_i I_i} \right|_{a_j=a_k=0}$$ 
Since the voltages are equal and since $a_j=a_k=0$ as stated above, we have :
$ V_j = V_i \rightarrow \sqrt{Z_j} b_j = \sqrt{Z_i} \left(a_i + b_i\right)$
$ V_k = V_i \rightarrow \sqrt{Z_k} b_k = \sqrt{Z_i} \left(a_i + b_i\right)$
from which we deduce :
$b_j = \sqrt{\frac{Z_i}{Z_j}} \left(a_i + b_i\right)$
$b_k = \sqrt{\frac{Z_i}{Z_k}} \left(a_i + b_i\right)$
Using node's assumption :
$$I_i = - I_j - I_k =  \frac{1}{\sqrt{Z_j}} b_j + \frac{1}{\sqrt{Z_k}} b_k $$
ie
$$I_i = \sqrt{Z_i} \left(a_i + b_i\right) \left( \frac{1}{Z_j}   + \frac{1}{Z_k}\right) = \frac{\sqrt{Z_i} \left(a_i + b_i\right)}{Z_j \parallel Z_k}   $$
$$S_{ji} = \frac{\sqrt{Z_i}}{\sqrt{Z_j}} \frac{V_j - Z_j I_j}
{\sqrt{Z_i} \left(a_i + b_i\right) \left(1 +  \frac{Z_i}{Z_j \parallel Z_k} \right)} $$ 
The scattering parameter is thus:
$$ S_{ji} =  \frac{\sqrt{Z_i}}{\sqrt{Z_j}} \frac{\sqrt{Z_i} \left(a_i + b_i\right) - Z_j I_j }{\sqrt{Z_i}(a_i+b_i) \left(1 +  \frac{Z_i}{Z_j \parallel Z_k} \right)}
$$
$$ S_{ji} =  \frac{\sqrt{Z_i}}{\sqrt{Z_j}} \frac{\sqrt{Z_i} \left(a_i + b_i\right) + \sqrt{Z_j} b_j }{\sqrt{Z_i}(a_i+b_i) \left(1 +  \frac{Z_i}{Z_j \parallel Z_k} \right)}
$$
which can be simplified from voltage relationships : 
$$ \boxed{S_{ji} =  \displaystyle \frac{\sqrt{Z_i}}{\sqrt{Z_j}} \frac{2 Z_j \parallel Z_k}{Z_j \parallel Z_k +  Z_i }}
$$
Numerical implementation
End of explanation
S=get_S(Z0=6, Z1=24, Z2=24)
print(S)
Explanation: Exemple : Zin=6 Ohm, and 24 Ohm for output ports
End of explanation
SdotSH=S.dot(S.conj().T) # or: np.dot(S, np.transpose(np.conjugate(S)))
print(SdotSH)
np.allclose(SdotSH, np.eye(3))
Explanation: Passivity test
Does the scattering matrix is passive, ie. does $S.S^H=1$ ?
End of explanation
<END_TASK>