(*  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 crosstalk with  three conductors over a ground      *)
(* However, in this case crosstalk between two conductors is examined        *)
(* with third conductor  moved away.                                         *)
(*                                                                           *)
(* Results closely match experimental results in the following               *)
(* Reference by Clayton Paul:                                                *)
(* Clayton R.Paul,"On the Superposition of Inductive and Capacitive Coupling *)
 (*  in Crosstalk-Prediction Models."                                         *)
(*  IEEE Transactions on Electromagnetic Compatibility,                      *)
(* Volume:EMC-24 Issue:3 Publication Year:1982                               *)















PI=3.14159265358979323846
NN=3   (* Number of conductors  *) (* Note permanent set to 3 since Per Unit Parameters based on 3 conductors *)

  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.705 (* Meters *)
x=0  (* NE *)

     x1=10

d=20
d3=40
h1=20.0

r1=0.406
h2=20 
x2=x1+d
r2=0.406
h3=100  (* Really trying out two conductor so large height and distance for third *)
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 = {10^4,2*10^4, 3*10^4, 4*10^4,5*10^4,6*10^4,8*10^4, 9*10^4,10^5,2*10^5, 3*10^5, 4*10^5,5*10^5,6*10^5,8*10^5, 9*10^5,10^6,2*10^6, 3*10^6, 4*10^6,5*10^6,6*10^6,8*10^6, 9*10^6,10^7}

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

  freq=  N[freqValues[[iii+1]]]; 
 
Vs={1,0,0};




 ZLoad ={{1,0,0},{0,1,0},{0,0,10^12}} ;
ZSource={{0,0,0},{0,1,0},{0,0,10^12}};

Print["Zload"];
 Print[ZLoad];
 
YLoad2=Inverse[ZLoad];
 
 Print["YLoad2"];
 Print[YLoad2];

 
 
 
xdet=Det[YLoad];
 
 
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;

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];


(*  GammaEigenVect= Eigenvectors[GammaSqr]
GammaEigenVectInv= Inverse[GammaEigenVect]
GammaSqrTest1=GammaEigenVect.GammaEigenVectInv
GammaSqrTest2=GammaEigenVect.gammaEigenVals.GammaEigenVectInv *)


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


CapGammaL=Inverse[Zly0+IdentityMatrix[NN]].(Zly0-IdentityMatrix[NN]);
exml=MatrixExp[(x-L)*gamma];
emgx=MatrixExp[(-1)*x*gamma];
emgL=MatrixExp[(-L)*gamma];
p1=(IdentityMatrix[NN]+exml.CapGammaL.exml);
p2=Inverse[(IdentityMatrix[NN]-emgL.CapGammaL.emgL)];
p3=p1.emgx.p2.Z0;
p4=(IdentityMatrix[NN]+emgL.CapGammaL.emgL);
p5=Inverse[(IdentityMatrix[NN]-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];
Vx2=Vx[[2]];
Vx2a=Abs[Vx2];
Vx23=Vx[[2]]-Vx[[3]];
Vx23a=Abs[Vx23];

Ratio1=Vx1a/Vx23a;

Print[freq];
Print[Vx2a];

AppendTo[transferFunction,Vx2a];
Print[transferFunction];


]  (* end for loop  *)



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

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

] (* End for loop *)
  ListLogLogPlot[plotPairs]   
 
(* From the Report by Ardalan, Riddle and Suh 1988         *)








(* From Clayton Paul 1982 ( See comments at beginning of Notebook )   *) 
 

(*  From this Mathematica Notebook (Ardalan, 2018) *)


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

|