|
@@ -9,6 +9,8 @@ import javax.swing.*;
|
|
|
|
|
|
import api.AddOn;
|
|
|
import classes.*;
|
|
|
+import org.nd4j.linalg.api.ndarray.INDArray;
|
|
|
+import org.nd4j.linalg.factory.Nd4j;
|
|
|
import ui.controller.Control;
|
|
|
import ui.controller.StorageProductionController;
|
|
|
|
|
@@ -250,7 +252,8 @@ public class controlAlgorithm implements AddOn {
|
|
|
println("No Power Plant in Model");
|
|
|
return;
|
|
|
}
|
|
|
- setDistanceToCalcResistance();
|
|
|
+ resistanceCalculator resistanceCalculator = new resistanceCalculator();
|
|
|
+ resistanceCalculator.setDistanceToCalcResistance(powerPlant);
|
|
|
blackstartRunningCounter = 0;
|
|
|
deactivateBlackstart();
|
|
|
control.getModel().setCurIteration(0);
|
|
@@ -298,7 +301,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ *
|
|
|
* @param curIteration
|
|
|
*/
|
|
|
private void blackstartMain(int curIteration) {
|
|
@@ -309,7 +312,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
control.getModel().setCurIteration(curIteration);
|
|
|
if (control.getSimManager().blackstartRunning()) {
|
|
|
- if (!blackstartAlgo(curIteration)) {
|
|
|
+ if (!blackstartAlgo()) {
|
|
|
// blackstart for this iteration was not successfull
|
|
|
deactivateBlackstart();
|
|
|
updateVisual();
|
|
@@ -352,11 +355,10 @@ public class controlAlgorithm implements AddOn {
|
|
|
* TODO: batterie modes wo nicht passiert? obwohl laden / entladen moeglich waere?
|
|
|
* TODO: batterie laden prios? entfernung?
|
|
|
*
|
|
|
- * @param curIteration
|
|
|
* @return true or false depending on whether the blackstart was successful for
|
|
|
* this iteration
|
|
|
*/
|
|
|
- private boolean blackstartAlgo(int curIteration) {
|
|
|
+ private boolean blackstartAlgo() {
|
|
|
if (currentRenewableProduction() < getPowerPlantBlackstartResistance()) {
|
|
|
// renewable energy production is not sufficient for the blackstart
|
|
|
if (SPC.currentPossibleStorageProduction() >= getPowerPlantBlackstartResistance()
|
|
@@ -395,75 +397,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
return storageElements;
|
|
|
}
|
|
|
|
|
|
- private void setDistanceToCalcResistance() {
|
|
|
-
|
|
|
- if (powerPlant != null) {
|
|
|
-// println("Powerplant Energy @"+powerPlant.getEnergyAtTimeStep(1));
|
|
|
-// println("" + getPowerplantProduction());
|
|
|
-
|
|
|
- // travers
|
|
|
- if (powerPlant.getConnectedTo().size() > 0) {
|
|
|
- for (CpsEdge edge : powerPlant.getConnectedTo()) {
|
|
|
-// println(edge.toString());
|
|
|
- if (powerPlant.getId() == edge.getA().getId()) {
|
|
|
- traversEdges(edge.getB(), powerPlant, calcEdgeLength(edge));
|
|
|
- } else {
|
|
|
- traversEdges(edge.getA(), powerPlant, calcEdgeLength(edge));
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- println("Nothing connected to powerplant");
|
|
|
- }
|
|
|
- } else {
|
|
|
- println("No powerplant connected");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void traversEdges(AbstractCpsObject currentObject, AbstractCpsObject last, double distance) {
|
|
|
- if (currentObject.getConnectedTo().size() > 1) { // recursive call for all edges
|
|
|
- for (CpsEdge edge : currentObject.getConnectedTo()) {
|
|
|
- if (currentObject.getId() == edge.getA().getId()) { // look at which way the edge points
|
|
|
- if (last.getId() != edge.getB().getId()) {
|
|
|
- traversEdges(edge.getB(), currentObject, distance + calcEdgeLength(edge));
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (last.getId() != edge.getA().getId()) {
|
|
|
- traversEdges(edge.getA(), currentObject, distance + calcEdgeLength(edge));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else { // at leaf
|
|
|
- for (HolonElement ele : ((HolonObject) currentObject).getElements()) {
|
|
|
- ele.setDistance(distance);
|
|
|
-// if (ele.getEleName().equals("Solar Panels")) {// TODO: das wollen wir ja so nicht
|
|
|
-// ele.setEnergyPerElement(5000);
|
|
|
-// ele.setEnergyPerElement(calcEnergyAfterResistance(ele.getEnergyPerElement(), distance));
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private double calcEdgeLength(CpsEdge edge) {
|
|
|
- Position aPos = edge.getA().getPosition();
|
|
|
- Position bPos = edge.getB().getPosition();
|
|
|
- double xDiff = Math.abs(aPos.x - bPos.x);
|
|
|
- double yDiff = Math.abs(aPos.y - bPos.y);
|
|
|
- return Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));
|
|
|
- }
|
|
|
-
|
|
|
- private float calcEnergyAfterResistance(float currentEnergy, double distance) {
|
|
|
- // 230v kupfer 30mm durchmesser
|
|
|
- int volatage = 230;
|
|
|
- int diameter = 30;
|
|
|
- // kupfer
|
|
|
- double specificMaterialResistance = 0.017;
|
|
|
- double blackstartResistance = Math.pow(volatage, 2) / getPowerPlantBlackstartResistance();
|
|
|
- double cableResistance = specificMaterialResistance * (distance / (0.25 * Math.PI * Math.pow(diameter, 2)));
|
|
|
- return (float) (1 - (cableResistance / (cableResistance + blackstartResistance))) * currentEnergy;
|
|
|
- }
|
|
|
-
|
|
|
- private void disableConsumers() {
|
|
|
+ private void disableConsumers() {
|
|
|
// TODO: disableBatteryLoading? will ich das wirklich?
|
|
|
// SPC.disableStorageProduction();
|
|
|
|