Pārlūkot izejas kodu

Override in per-unit system implemented

Henrik Kunzelmann 3 gadi atpakaļ
vecāks
revīzija
b70a3efe23

+ 22 - 0
src/classes/Edge.java

@@ -20,6 +20,8 @@ public class Edge {
     @Expose
     private float realLength = 1;
     @Expose
+    private boolean overrideInPerUnit = false;
+    @Expose
     private float overrideResistance = 0;
     @Expose
     private float overrideReactance = 0;
@@ -49,6 +51,10 @@ public class Edge {
         return realLength;
     }
 
+    public boolean getOverrideInPerUnit() {
+        return overrideInPerUnit;
+    }
+
     public float getOverrideResistance() {
         return overrideResistance;
     }
@@ -123,6 +129,22 @@ public class Edge {
         this.realLength = realLength;
     }
 
+    public void setOverrideInPerUnit(boolean overrideInPerUnit) {
+        this.overrideInPerUnit = overrideInPerUnit;
+    }
+
+    public void setOverrideResistance(float overrideResistance) {
+        this.overrideResistance = overrideResistance;
+    }
+
+    public void setOverrideReactance(float overrideReactance) {
+        this.overrideReactance = overrideReactance;
+    }
+
+    public void setOverrideShuntSusceptance(float overrideShuntSusceptance) {
+        this.overrideShuntSusceptance = overrideShuntSusceptance;
+    }
+
     /**
      * Getter for the Source.
      *

+ 14 - 6
src/holeg/HolegPowerFlow.java

@@ -97,6 +97,7 @@ public class HolegPowerFlow {
                         // Notify main thread that we are done
                         semaphore.release();
                     });
+                    jobs[jobID].setName("Solver Job " + Long.toHexString(jobs[jobID].getId()));
                 }
 
                 // Check if we should have stopped
@@ -276,12 +277,14 @@ public class HolegPowerFlow {
         // Convert from grid to power flow objects
         for (GridNode node : grid.getNodes())
             createGridNode(buses, node);
-        for (GridEdge edge : grid.getEdges())
-            createGridLine(grid, lines, edge);
 
         // Scale voltages and scale power
         double scaleVoltage = 1.0 / 230.0;
         double scalePower = scalePower(buses);
+        double scaleResistance = 1.0 / ((scaleVoltage * scaleVoltage) / scalePower);
+
+        for (GridEdge edge : grid.getEdges())
+            createGridLine(grid, lines, edge, scaleResistance);
 
         // Find position for slack node
         addSlackNode(buses, lines, tryCount, settings);
@@ -319,19 +322,24 @@ public class HolegPowerFlow {
         buses.add(bus);
     }
 
-    private void createGridLine(Grid grid, List<Line> lines, GridEdge edge) {
+    private void createGridLine(Grid grid, List<Line> lines, GridEdge edge, double scaleResistance) {
         Line line = new Line();
         line.tag = edge;
         if (ComplexNumber.isNullOrZero(edge.getOverrideImpedance())) {
             // Calculate values for line based on sample datasheet
-            line.R = 0.000194 * edge.getLengthKilometers();
-            line.X = 0.000592 * edge.getLengthKilometers();
-            line.B_2 = 0.000528;
+            line.R = 0.00642 * edge.getLengthKilometers() * scaleResistance;
+            line.X = 0.0083 * edge.getLengthKilometers() * scaleResistance;
+            line.B_2 = (0.0001 * edge.getLengthKilometers()) / scaleResistance;
         }
         else {
             line.R = edge.getOverrideImpedance().real;
             line.X = edge.getOverrideImpedance().imaginary;
             line.B_2 = edge.getOverrideShuntSusceptance();
+            if (!edge.getOverrideInPerUnit()) {
+                line.R *= scaleResistance;
+                line.X *= scaleResistance;
+                line.B_2 *= scaleResistance;
+            }
         }
         line.a = 1;
 

+ 2 - 0
src/holeg/model/GridComparator.java

@@ -101,6 +101,8 @@ public class GridComparator {
         if (a == null || b == null)
             return false;
 
+        if (a.getOverrideInPerUnit() != b.getOverrideInPerUnit())
+            return false;
         if (a.getLengthKilometers() != b.getLengthKilometers())
             return false;
         if (!ComplexNumber.equals(a.getOverrideImpedance(), b.getOverrideImpedance()))

+ 1 - 0
src/holeg/model/GridEdge.java

@@ -7,6 +7,7 @@ public interface GridEdge {
     GridNode getTo();
 
     double getLengthKilometers();
+    boolean getOverrideInPerUnit();
     ComplexNumber getOverrideImpedance();
     double getOverrideShuntSusceptance();
 

+ 1 - 0
src/holeg/model/GridNode.java

@@ -9,6 +9,7 @@ public interface GridNode {
 
     NodeType getTypeByDesign();
     NodeType getTypeSolved();
+    double getVoltage();
     ComplexNumber getPowerConsumption();
     ComplexNumber getPowerGeneration();
     Object getTag();

+ 6 - 0
src/holeg/simple_grid/SimpleGridEdge.java

@@ -9,6 +9,7 @@ public class SimpleGridEdge implements GridEdge {
     public SimpleGridNode from;
     public SimpleGridNode to;
     public double lengthKilometers = 1;
+    public boolean overrideInPerUnit = false;
     public ComplexNumber overrideImpedance = null;
     public double overrideShuntSusceptance = 0;
     public double current = 0;
@@ -31,6 +32,11 @@ public class SimpleGridEdge implements GridEdge {
         return lengthKilometers;
     }
 
+    @Override
+    public boolean getOverrideInPerUnit() {
+        return overrideInPerUnit;
+    }
+
     @Override
     public ComplexNumber getOverrideImpedance() {
         return overrideImpedance;

+ 5 - 0
src/holeg/simple_grid/SimpleGridNode.java

@@ -34,6 +34,11 @@ public class SimpleGridNode implements GridNode {
         return edges;
     }
 
+    @Override
+    public double getVoltage() {
+        return voltage;
+    }
+
     @Override
     public ComplexNumber getPowerConsumption() {
         return powerConsumption;

+ 8 - 0
src/ui/controller/UpdateController.java

@@ -451,12 +451,20 @@ public class UpdateController {
             Object[] tempStatus = {"Length", model.getSelectedEdge().getLength() };
             model.getPropertyTable().addRow(tempStatus);
 			model.getPropertyTable().addRow(new Object[]{"Real length in km", model.getSelectedEdge().getRealLength()});
+			model.getPropertyTable().addRow(new Object[]{"Override in per unit", model.getSelectedEdge().getOverrideInPerUnit()});
+			model.getPropertyTable().addRow(new Object[]{"Override resistance", model.getSelectedEdge().getOverrideResistance()});
+			model.getPropertyTable().addRow(new Object[]{"Override reactance", model.getSelectedEdge().getOverrideReactance()});
+			model.getPropertyTable().addRow(new Object[]{"Override shunt susceptance", model.getSelectedEdge().getOverrideShuntSusceptance()});
             // For edges, the only possible editable cell is the max
 			// flow
 			model.getPropertyTable().setCellEditable(0, 1, false);
 			model.getPropertyTable().setCellEditable(2, 1, true);
 			model.getPropertyTable().setCellEditable(3, 1, false);
 			model.getPropertyTable().setCellEditable(4, 1, true);
+			model.getPropertyTable().setCellEditable(5, 1, true);
+			model.getPropertyTable().setCellEditable(6, 1, true);
+			model.getPropertyTable().setCellEditable(7, 1, true);
+			model.getPropertyTable().setCellEditable(8, 1, true);
 		} else if (getActualCps() == null) {
 			deleteRows(model.getSingleTable());
 			deleteRows(model.getMultiTable());

+ 27 - 1
src/ui/view/GUI.java

@@ -1685,6 +1685,31 @@ public class GUI implements CategoryListener {
 						controller.calculateStateAndVisualForCurrentTimeStep();
 					}
 				}
+				else if (selValueYBool == 5) {
+					model.getSelectedEdge().setOverrideInPerUnit((boolean) btemp);
+					controller.calculateStateAndVisualForCurrentTimeStep();
+				}
+				else if (selValueY == 6) {
+					float value = Float.parseFloat(temp.toString());
+					if (value >= 0) {
+						model.getSelectedEdge().setOverrideResistance(value);
+						controller.calculateStateAndVisualForCurrentTimeStep();
+					}
+				}
+				else if (selValueY == 7) {
+					float value = Float.parseFloat(temp.toString());
+					if (value >= 0) {
+						model.getSelectedEdge().setOverrideReactance(value);
+						controller.calculateStateAndVisualForCurrentTimeStep();
+					}
+				}
+				else if (selValueY == 8) {
+					float value = Float.parseFloat(temp.toString());
+					if (value >= 0) {
+						model.getSelectedEdge().setOverrideShuntSusceptance(value);
+						controller.calculateStateAndVisualForCurrentTimeStep();
+					}
+				}
 				// Status edition through a check box
 				if (selValueYBool == 3) {
 					Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
@@ -2271,6 +2296,7 @@ public class GUI implements CategoryListener {
 			elementGraph.setText(Languages.getLanguage()[25]);
 			canvas.tempCps = null;
 			canvas.repaint();
+			controller.calculateStateAndVisualForCurrentTimeStep();
 			IdCounter.resetCounter();
 			IdCounterElem.resetCounter();
 		});
@@ -2744,7 +2770,7 @@ public class GUI implements CategoryListener {
 	 *
 	 * @return the Frame
 	 */
-	JFrame getFrmCyberPhysical() {
+	public JFrame getFrmCyberPhysical() {
 		return holegJFrame;
 	}