(*  MultiConductor Modeling and Analysis                                     *)
(*  Copyright (C)2018 Sasan Ardalan                                          *)
(*  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 3 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 program.If not,see<http://www.gnu.org/licenses/>.        *)
(*  Author:Sasan Ardalan                                                     *)
(*  Date:December 8,2018                                                     *)
(*  http://www.radiocalc.com                                                 *)
(*                                                                           *)
(* The formulas for calculating the voltage at any point along a             *)
(* multiconductor system are derived in a report by Dr. Ardalan and          *)
(* Mike Riddle (Masters Electrical Engineering)   NC State University        *)
(* The Report is available at:                                               *)
(* http://www.radiocalc.com/MultiConductorCAD.html                           *)
(* Screen shots from above paper                                             *)
(* This Notebook studies three conductors over a ground with                 *)
(* crosstalk reduction at high currents.                                     *)
(*                                                                           *)
(* The results of this Mathematica Note Book match closely                   *)
(* the experimental and theoretical results in:                                              *)
(* Clayton R.Paul;Jack W.McKnight,"Prediction of Crosstalk Involving Twisted *)
(* Pairs of Wires-Part I:                                                    *)
 (*        A Transmission-Line Model for Twisted-Wire Pairs,"                 *)
(*  IEEE Transactions on Electromagnetic Compatibility                       *)
(*   EMC-21 Issue:2 Publication Year:1979                                    *)















 










PI=3.14159265358979323846

  MU =4*PI*1.0*10^(-7)
  EPS =1.0*10^(-9)/36/PI
 MUO2PI =2*1.0*10^(-7)
 RHO =1.72*10^(-6) (* ohms-cm copper *)
SIGMA =58*10^6 (* mho/m copper  *)
TINY =1.0*10^(-20)
epsr=1.0 


(************** STRUCTURE   *********)


L=4.572
x=L

     x1=10

d=20
d3=d
h1=20.0

r1=0.406
h2=20+0.8382
x2=x1+d
r2=0.406
h3=20-0.8382
x3=x1+d3
r3=0.406

Graphics[{Circle[{x1,h1},r1],Circle[{x2 ,h2},r2],Circle[{x3,h3},r3],{Dashed,Rectangle[{0,0.5},{40,0.6}]}},Axis->True,Frame->True]

(************** END STRUCTURE   *********)

(* Start Calculating per Specified Frequency in List    ****)
transferFunction ={}
freqValues = {100,1000,10000,100000,10^6,10^7,2*10^7, 3*10^7, 4*10^7,5*10^7,6*10^7,8*10^7, 9*10^7, 10^8}

For [iii=0, iii<Length[freqValues], iii++ ,

  freq=  N[freqValues[[iii+1]]]; 
(* Key Specifcation Resistance R   and R23        *****)

Vs={0,1,0};
R=50;
R23=50;
 
YLoad={{1/R,0,0},{0,1/R23,-1/R23},{0,-1/R23,1/R23}};

 
yLoadVal;
detYload=Det[YLoad];
detYloadVal;
(* ZLoad=Inverse[YLoad] *)

 
(* ZLoad ={{R,0,0},{0,10^12,R23},{0,R23,10^12}} ; *)
 
 
 

YSource111={{1/R,0,0},{0,1/50,0},{0,0,10^12}};
YLoad1={{1/R,0,0},{0,0,1/R23},{0,1/R23,0}};
ZSource111=Inverse[YSource];
 
ZSource2={{R,0,0},{0,0.0001,0},{0,0,0.0001}};
ZLoad1=Inverse[YLoad];


 

ZSource={{R,0,0},{0,0,0},{0,0,0}};


xdet=Det[YLoad];
(*ZSource={{R,0, 0},{0, 0.0,0},{0,0,0.0}}
*)







 

rw1=r1;
d1=x1;
 
rw2=r2;
d2=x2;
 
rw3=r3;
d3=x3;



 

l11=MUO2PI*Log[2.0*h1/rw1] ;
l22=MUO2PI*Log[2.0*h2/rw2] ;
l33=MUO2PI*Log[2.0*h3/rw3] ;
d12=Sqrt[(d1-d2)*(d1-d2)+(h1-h2)*(h1-h2)] ;
d12star=Sqrt [d12*d12+4.0*h1*h2] ;
l12=MUO2PI*Log[d12star/d12] ;
 d13=Sqrt[(d1-d3)*(d1-d3)+(h1-h3)*(h1-h3)] ;
d13star=Sqrt[d13*d13+4.0*h1*h3] ;
l13=MUO2PI*Log[d13star/d13] ;
 d23=Sqrt[(d2-d3)*(d2-d3)+(h2-h3)*(h2-h3)] ;
d23star=Sqrt[d23*d23+4.0*h2*h3] ;
 l23=MUO2PI*Log[d23star/d23]; 
LL={{l11,l12,l13},{l12,l22,l23},{l13,l23,l33}};
Cap=Inverse[LL];

Cap=MU*EPS*epsr*Cap;


omega=2*PI*freq;

wL=N[omega*LL];

wL=wL*I;

wC=N[omega*Cap];
wC=wC*I;

GammaSqr= wL.wC;   (* No Losses  Case *)
Print["GammaSqr=",GammaSqr];
gammaEigenVals= Eigenvalues[GammaSqr];
Print["gammaEigenVals=",gammaEigenVals];
 
Print["GammaSqr =",GammaSqr];

gammaEVect= Eigenvectors[GammaSqr];
gammaSqrEigenValues= Eigenvalues[GammaSqr];
Print["gamma2EigenVals=",gammaSqrEigenValues];
gammaSqrEigenValuesMatrix=DiagonalMatrix[gammaSqrEigenValues];
gamma=gammaEVect.Sqrt[gammaSqrEigenValuesMatrix].Inverse[gammaEVect];
Print["gamma=",gamma];
gammaEigenVals= Eigenvalues[gamma];
Print["gammaEigenVals=",gammaEigenVals];


Y0=Inverse[wL].gamma;
Z0=Inverse[Y0];
(* Zly0=ZLoad.Y0; *)
 


(* CapGammaL=Inverse[Zly0+IdentityMatrix[3]].(Zly0-IdentityMatrix[3]); *)
CapGammaL=Inverse[Y0+YLoad].(Y0-YLoad);
exml=MatrixExp[(x-L)*gamma];
emgx=MatrixExp[(-1)*x*gamma];
emgL=MatrixExp[(-L)*gamma];
p1=(IdentityMatrix[3]+exml.CapGammaL.exml);
p2=Inverse[(IdentityMatrix[3]-emgL.CapGammaL.emgL)];
p3=p1.emgx.p2.Z0;
p4=(IdentityMatrix[3]+emgL.CapGammaL.emgL);
p5=Inverse[(IdentityMatrix[3]-emgL.CapGammaL.emgL)];
p6=p4.p5;
p7 =ZSource+p6.Z0;
p8=Inverse[p7];
p9=p8.Vs;
Vx=p3.p9;
Vx1=Vx[[1]];
Vx1a=Abs[Vx1];
Vx23=Vx[[2]]-Vx[[3]];
Vx23a=Abs[Vx23];

Ratio1=Vx1a/Vx23a;

Print[freq];
Print[Vx1a];

AppendTo[transferFunction,Vx1a];
Print[transferFunction];


]  (* end for loop  *)



plotPairs={};
For [ii=0, ii<Length[freqValues], ii++ ,x=ii^2;

  freq=  freqValues[[ii+1]]; 
transferFuncValues=  transferFunction[[ii+1]]; 
AppendTo[plotPairs,{freq,transferFuncValues}];
Print  [freq*0.9] ;
 Print[x];

] (* End for loop *)
 ListLogLogPlot[plotPairs,Joined->True]

(*                                 *)
(*   From the Report by Riddle, Ardalan and Suh (1988)                *)

|