Formulation { //port i // Electric field formulation For i In {1:#Sur_UNIFPORT_N_N_List()} { Name cFormulation ; Type FemEquation; Quantity { { Name e; Type Local; NameOfSpace Hcurl_e; } { Name hs; Type Local; NameOfSpace Hcurl_hs; } For j In {1:#Sur_UNIFPORT_N_N_List()} { Name voltage_port~{j}; Type Local; NameOfSpace Hgrad_port~{j};} { Name U_port~{j}; Type Global; NameOfSpace Hgrad_port~{j}[U_port~{j}];} { Name G_port~{j}; Type Global; NameOfSpace Hgrad_port~{j}[G_port~{j}];} { Name LoadCurrent_port~{j}; Type Global; NameOfSpace Hgrad_port~{j}[LoadCurrent_port~{j}];} For k In {1:#Sur_UNIFPORT_N_N_List()} { Name voltage_portSS~{j}~{k}; Type Local; NameOfSpace Hgrad_portSS~{j}~{k};} { Name U_port~{j}~{k}; Type Global; NameOfSpace Hgrad_portSS~{j}~{k}[U_port~{j}~{k}];} If (j==k) { Name G_port~{j}~{k}; Type Global; NameOfSpace Hgrad_portSS~{j}~{k}[G_port~{j}~{k}];} EndIf EndFor EndFor } Equation { Galerkin { [ nu[] * nu0 * Dof{d e} , {d e} ]; In Region[{non_conducting_domain, open_air_domain}]; Integration I1; Jacobian JVol; } Galerkin { [- (2*Pi* $Time*FreqFactor)^2 * epsilon[] * Complex[1, -tan_delta[]] * eps0 * Dof{e} , {e} ]; In Region[{non_conducting_domain, open_air_domain}]; Integration I1; Jacobian JVol; } // Conductive Boundary // roughness of copper represented by a factor of sigma : 1+( 2/Pi )*Atan( 1.4(height/skin_depth])^2 ) // skin_depth = Sqrt(1/(2*Pi*sigma[]*Freq*Pi*mu0)), usign vacuum permeability for usual materials. Galerkin { [ - Complex[0,1] * (2*Pi* $Time*FreqFactor) * Complex[1,1] * Sqrt[ 2 * (1+(2/Pi)*Atan[1.4*(height[]/Sqrt[1/(2*Pi*sigma[]*$Time*Pi*mu0)])^2])* sigma[] * nu[] * nu0 / (2*Pi* $Time*FreqFactor)] * ( Normal[] /\ Dof{e} ) /\ Normal[] , {e} ]; In Sur_CONDUCTOR; Integration I1; Jacobian JSur; } // Silver Muller condition Galerkin { [ Complex[0,1] * (2*Pi* $Time*FreqFactor) * Sqrt[eps0*nu0] * ( Normal[] /\ Dof{e} ) /\ Normal[] , {e} ]; In Sur_RB; Integration I1; Jacobian JSur; } // port excitation on each port {i} to get Snn parameters Galerkin { [ - Complex[0,1] * (2*Pi* $Time*FreqFactor) *2*volt[]*gap[]/area[] /impedance[] * ( Normal[] /\ Vector[eDirX[], eDirY[], eDirZ[]]) /\ Normal[] , {e} ]; In Region[{Sur_UNIFPORT_N~{i}}] ; Integration I1; Jacobian JSur; } Galerkin { [ Complex[0,1] * (2*Pi* $Time*FreqFactor) * gap[]^2/area[] /impedance[] * ( Normal[] /\ Dof{e} ) /\ Normal[] , {e} ]; In Region[{Sur_UNIFPORT_N~{i}}] ; Integration I1; Jacobian JSur; } Galerkin { [ - Complex[0,1] * (2*Pi* $Time*FreqFactor) * 2*volt[] / (2 * Pi * impedance[]) / ( Norm[XYZ[] - Vector[centroidX[], centroidY[], centroidZ[]]] ) * (Normal[] /\ Unit[XYZ[] - Vector[centroidX[], centroidY[], centroidZ[]]]) /\ Normal[] , {e} ]; In Sur_COAXPORT; Integration I1; Jacobian JSur; } Galerkin { [ Complex[0,1] * (2*Pi* $Time*FreqFactor) * Log[radius_out[]/radius_in[]]/ (2 * Pi * impedance[])* ( Normal[] /\ Dof{e} ) /\ Normal[] , {e} ]; In Sur_COAXPORT; Integration I1; Jacobian JSur; } // magnetic field on surfaces Galerkin { [ Dof{hs} , {hs} ]; In ElementsOf[{non_conducting_domain, open_air_domain}, OnOneSideOf {Sur_UNIFPORT_N, Sur_COAXPORT, Sur_CONDUCTOR, Sur_PEC, Sur_INTERFACE}]; Integration I2; Jacobian JVol; } Galerkin { [ - Complex[0,1]*nu[]*nu0*Dof{d e}/(2*Pi*$Time*FreqFactor), {hs} ] ; In ElementsOf[{non_conducting_domain, open_air_domain}, OnOneSideOf {Sur_UNIFPORT_N, Sur_COAXPORT, Sur_CONDUCTOR, Sur_PEC, Sur_INTERFACE}]; Integration I2; Jacobian JVol; } // Get voltages and reflection coefficient on ports for S parameters For j In {1:#Sur_UNIFPORT_N_N_List()} Galerkin { [- Dof{e} * Vector[eDirX[], eDirY[], eDirZ[]] * gap[] / area[] , {voltage_portSS~{j}~{i}}]; In Region[{Sur_UNIFPORT_N~{j}}]; Integration I1; Jacobian JSur; } GlobalTerm { [Dof{U_port~{j}~{i}}, {U_port~{j}~{i}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} If (i==j) GlobalTerm { [(Dof{G_port~{j}~{i}})/volt[], {G_port~{j}~{i}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} GlobalTerm { [1, {G_port~{j}~{i}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} EndIf EndFor For j In {i:#Sur_UNIFPORT_N_N_List()} If (i!=j) For k In {i:#Sur_UNIFPORT_N_N_List()} GlobalTerm { [Dof{U_port~{k}~{j}}, {U_port~{k}~{j}}]; In Region[{Sur_UNIFPORT_N~{k}, Sur_COAXPORT}];} EndFor EndIf EndFor //global voltage on port from electric field port j For j In {1:#Sur_UNIFPORT_N_N_List()} Galerkin { [- Dof{e} * Vector[eDirX[], eDirY[], eDirZ[]] * gap[] / area[] , {voltage_port~{j}}]; In Region[{Sur_UNIFPORT_N~{j}}]; Integration I1; Jacobian JSur; } Galerkin { [- Dof{e} * CrossProduct[Normal[], CrossProduct[Unit[XYZ[] - Vector[centroidX[], centroidY[], centroidZ[]]], Normal[] ] ] / (2 * Pi * Norm[XYZ[] - Vector[centroidX[], centroidY[], centroidZ[]]]) , {voltage_port~{j}} ]; In Sur_COAXPORT; Integration I1; Jacobian JSur; } //calutaing load voltage port j GlobalTerm { [Dof{U_port~{j}}, {U_port~{j}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} // calcualting gamma port j GlobalTerm { [(Dof{G_port~{j}})/volt[], {G_port~{j}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} GlobalTerm { [1, {G_port~{j}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} // calculating loadCurrent j GlobalTerm { [-(Dof{LoadCurrent_port~{j}})/volt[], {LoadCurrent_port~{j}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} GlobalTerm { [2*volt[]/impedance[], {LoadCurrent_port~{j}}]; In Region[{Sur_UNIFPORT_N~{j}, Sur_COAXPORT}];} EndFor } } EndFor }