diff --git a/src/com/powerdata/openpa/wirecable/PoleConstruction.java b/src/com/powerdata/openpa/wirecable/PoleConstruction.java new file mode 100644 index 0000000..c4251ee --- /dev/null +++ b/src/com/powerdata/openpa/wirecable/PoleConstruction.java @@ -0,0 +1,129 @@ +package com.powerdata.openpa.wirecable; + +import java.io.IOException; +import java.util.Arrays; + +import com.powerdata.openpa.tools.SimpleCSV; + +public class PoleConstruction +{ + + private SimpleCSV _pole; + private float [] _distance=new float[10]; + private String[] _sdistance; + private float distance_hor=0,distance_ver=0; + + + public PoleConstruction (String input_directory) throws IOException + { + _pole=new SimpleCSV(input_directory); + } + + private String[] getdata(String header) + { + return _pole.get(header); + + } + + private float pythagorus(float[] points) + { + distance_hor=points[0]-points[1]; + distance_ver=points[2]-points[3]; + //System.out.println("HOR DIS"+distance_hor+" VER_DIS"+distance_ver); + return (float) (Math.sqrt(distance_hor*distance_hor+ distance_ver*distance_ver)); + } + public float[] calcdistance (String header) + { + float[] points = new float[4]; + + _sdistance=_pole.get(header); + // System.out.println(Arrays.toString(_sdistance)); + Arrays.fill(_distance, (-1)); + + + + + + /** First one for start of horizontal point + * Second place for horizontal end + * Third place for start of vertical point + * Forth place for end of vertical point + * */ + + + try + { + // Calculating Dab + if (_sdistance[0].length() !=0 && _sdistance[2].length() !=0 ) + { + points[0]=Float.parseFloat(_sdistance[0]); + points[1]=Float.parseFloat(_sdistance[2]); + points[2]=Float.parseFloat(_sdistance[1]); + points[3]=Float.parseFloat(_sdistance[3]); + _distance[0]=pythagorus(points); + } + // Calculating Dan + if (_sdistance[0].length() !=0 && _sdistance[6].length() !=0 ) + { + points[0]=Float.parseFloat(_sdistance[0]); + points[1]=Float.parseFloat(_sdistance[6]); + points[2]=Float.parseFloat(_sdistance[1]); + points[3]=Float.parseFloat(_sdistance[7]); + _distance[3]=pythagorus(points); + } + // Calculating Dbc + if (_sdistance[2].length() !=0 && _sdistance[4].length() !=0 ) + { + points[0]=Float.parseFloat(_sdistance[2]); + points[1]=Float.parseFloat(_sdistance[4]); + points[2]=Float.parseFloat(_sdistance[3]); + points[3]=Float.parseFloat(_sdistance[5]); + _distance[1]=pythagorus(points); + } + // Calculating Dbn + if (_sdistance[2].length() !=0 && _sdistance[6].length() !=0 ) + { + points[0]=Float.parseFloat(_sdistance[2]); + points[1]=Float.parseFloat(_sdistance[6]); + points[2]=Float.parseFloat(_sdistance[3]); + points[3]=Float.parseFloat(_sdistance[7]); + _distance[4]=pythagorus(points); + } + // Calculating Dca + if (_sdistance[4].length() !=0 && _sdistance[0].length() !=0 ) + { + points[0]=Float.parseFloat(_sdistance[4]); + points[1]=Float.parseFloat(_sdistance[0]); + points[2]=Float.parseFloat(_sdistance[5]); + points[3]=Float.parseFloat(_sdistance[1]); + _distance[2]=pythagorus(points); + } + // Calculating Dcn + if (_sdistance[4].length() !=0 && _sdistance[6].length() !=0 ) + { + points[0]=Float.parseFloat(_sdistance[4]); + points[1]=Float.parseFloat(_sdistance[6]); + points[2]=Float.parseFloat(_sdistance[5]); + points[3]=Float.parseFloat(_sdistance[7]); + _distance[5]=pythagorus(points); + } + } + catch (Exception e) + { + System.out.println("Pole Construction Not Available"); + } + + return _distance; + } + + + + public static void main(String[] args) throws Exception + { + String input_directory="C:/Users/shamm/Dropbox/ASU/6bus/6bus/PoleConstruction.csv"; + PoleConstruction mat=new PoleConstruction(input_directory); + float[] res=mat.calcdistance("100"); + System.out.println(Arrays.toString(res)); + + } +} diff --git a/src/com/powerdata/openpa/wirecable/TransmissionLine.java b/src/com/powerdata/openpa/wirecable/TransmissionLine.java new file mode 100644 index 0000000..e4f94e1 --- /dev/null +++ b/src/com/powerdata/openpa/wirecable/TransmissionLine.java @@ -0,0 +1,183 @@ +package com.powerdata.openpa.wirecable; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +import com.powerdata.openpa.tools.Complex; + +public class TransmissionLine +{ + private PoleConstruction _pole; + private String _polecode; + //private WireParam _wire; + private float[] _wire; + private int[] _phase; + private float _length; + private float _real,_imag; + + private ArrayList ZKron=new ArrayList(); + + private Complex Znn=Complex.Zero; + private Complex Zs=Complex.Zero; + private Complex Zab=Complex.Zero; + private Complex Zbc=Complex.Zero; + private Complex Zca=Complex.Zero; + private Complex Zan=Complex.Zero; + private Complex Zbn=Complex.Zero; + private Complex Zcn=Complex.Zero; + + + + //public TransmissionLine(float length,int[] phase,WireParam wire,PoleConstruction pole,String polecode) + public TransmissionLine(float length,int[] phase,float[] wire,PoleConstruction pole,String polecode) + { + _pole=pole; + _wire=wire; + _length=length; + _phase=phase.clone(); + _polecode=polecode; + /**for (int i=0;i<4;i++) + { + ZMatrixThreeWire.add(i, Complex.Zero); + } + for (int i=0;i<3;i++) + { + ZMatrixNeutral.add(i, Complex.Zero); + }*/ + for (int i=0;i<6;i++) + { + ZKron.add(i, Complex.Zero); + } + + } + /** + * This following method calcualtes the KRON matrix + */ + public void setZMatrix() + { + Complex temp=Complex.Zero; + float[] geometry=_pole.calcdistance(_polecode); + //Zs=SelfImpedance(_wire.getR(),_wire.getGMR()); + Zs=SelfImpedance(_wire[1],_wire[0]); + Znn=SelfImpedance(_wire[3],_wire[2]); + + + if(geometry[0]>0) + Zab=MutualImpedance(geometry[0]); + if(geometry[1]>0) + Zbc=MutualImpedance(geometry[1]); + if(geometry[2]>0) + Zca=MutualImpedance(geometry[2]); + if(geometry[3]>0) + Zan=MutualImpedance(geometry[3]); + if(geometry[4]>0) + Zbn=MutualImpedance(geometry[4]); + if(geometry[5]>0) + Zcn=MutualImpedance(geometry[5]); + + if(_phase[0]==1) + { + temp=Zan.mult(Zan); + temp=temp.div(Znn); + temp=Zs.sub(temp); + ZKron.set(0, temp); + + if(_phase[1]==2) + { + temp=Zan.mult(Zbn); + temp=temp.div(Znn); + temp=Zab.sub(temp); + ZKron.set(3, temp); + } + } + + + + if(_phase[1]==2) + { + temp=Zbn.mult(Zbn); + temp=temp.div(Znn); + temp=Zs.sub(temp); + ZKron.set(1, temp); + + if(_phase[2]==3) + { + temp=Zbn.mult(Zcn); + temp=temp.div(Znn); + temp=Zbc.sub(temp); + ZKron.set(5, temp); + } + } + + + + if(_phase[2]==3) + { + temp=Zcn.mult(Zcn); + temp=temp.div(Znn); + temp=Zs.sub(temp); + ZKron.set(2, temp); + + if(_phase[0]==1) + { + temp=Zcn.mult(Zan); + temp=temp.div(Znn); + temp=Zca.sub(temp); + ZKron.set(4, temp); + } + } + System.out.println(); + + + } + + public ArrayList GetZMatrix() {return ZKron;} + + private Complex SelfImpedance (float r, float gmr) + { + _real=(float) (r+0.09530); + _imag=(float) (0.12134*(7.93402+Math.log(1/gmr))); + return (new Complex(_real,_imag)); + } + + + private Complex MutualImpedance (float distance) + { + _real=(float) 0.09530; + _imag=(float) (0.12134*(7.93402+Math.log(1/distance))); + return (new Complex(_real,_imag)); + } + + + + public static void main(String[] args) throws IOException + { + String input_directory="C:/Users/shamm/Dropbox/ASU/6bus/6bus/PoleConstruction.csv"; + String wire_directory="C:/Users/shamm/Dropbox/ASU/6bus/6bus/wireparam.csv"; + PoleConstruction pole=new PoleConstruction(input_directory); + WireParam wire=new WireParam(wire_directory); + int[] phase_ABCN={1,2,3}; // 1 2 3 corresponds to Phase A , Phase B, Phase C, if a specific phase is absent put zero + + TransmissionLine line01=new TransmissionLine(1000,phase_ABCN,wire.getwireparam("1"),pole,"500"); + // The pole class object is to be sent unless there is no way to figure out where is the input file located + line01.setZMatrix(); + ArrayList data=line01.GetZMatrix(); + + for(Complex z: data) + { + z.show(); + } + + //phase_ABCN[2]=0; + phase_ABCN[1]=0; + TransmissionLine line02=new TransmissionLine(1000,phase_ABCN,wire.getwireparam("1"),pole,"505AC"); + line02.setZMatrix(); + data=line02.GetZMatrix(); + + for(Complex z: data) + { + z.show(); + } + } +} diff --git a/src/com/powerdata/openpa/wirecable/WireParam.java b/src/com/powerdata/openpa/wirecable/WireParam.java new file mode 100644 index 0000000..a59ac04 --- /dev/null +++ b/src/com/powerdata/openpa/wirecable/WireParam.java @@ -0,0 +1,60 @@ +package com.powerdata.openpa.wirecable; + +import java.io.IOException; +import java.util.HashMap; + +import com.powerdata.openpa.tools.SimpleCSV; + +public class WireParam +{ + private float _gmr=0; + private float _r=0; + private float _gmrn=0; + private float _rn=0; + private SimpleCSV wireparam; + + public WireParam(double gmr,double r,double gmrn,double rn) + { + _gmr=(float) gmr; + _r=(float)r; + _gmrn=(float)gmrn; + _rn=(float)rn; + } + + public WireParam(String file_directory) throws IOException + { + wireparam=new SimpleCSV(file_directory); + + } + + + + public float getGMR() {return _gmr;} + public float getR() {return _r;} + + public float getGMRn() {return _gmrn;} + public float getRn() {return _rn;} + + public void setGMR(float gmr) {_gmr=gmr;} + public void setR(float r) {_r=r;} + + public void setGMRn(float gmrn) {_gmrn=gmrn;} + public void setRn(float rn) {_rn=rn;} + + public float[] getwireparam() + { + return new float[] {_gmr,_r,_gmrn,_rn}; + } + + public float[] getwireparam(String header) + { + return wireparam.getFloats(header); + } + + public static void main(String[] args) + { + + + } + +}