|
@@ -9,8 +9,6 @@ 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;
|
|
|
|
|
@@ -27,9 +25,9 @@ public class controlAlgorithm implements AddOn {
|
|
|
private Thread runThread;
|
|
|
|
|
|
// Blackstart Resistance in Watt
|
|
|
- private HolonObject powerPlant;
|
|
|
+ private HolonObject powerplant;
|
|
|
|
|
|
- private TextField blackstartResistanceTextfield;
|
|
|
+ private TextField blackstartEnergyrequierementTextfield;
|
|
|
private TextField blackstartSuccessTimeTextfield;
|
|
|
private TextField powerplantMaxOutputTextfield;
|
|
|
private TextField blackstartStartTimeTextfield;
|
|
@@ -79,13 +77,13 @@ public class controlAlgorithm implements AddOn {
|
|
|
JPanel parameterPanel = new JPanel(null);
|
|
|
parameterPanel.setPreferredSize(new Dimension(510, 300));
|
|
|
|
|
|
- blackstartResistanceTextfield = new TextField("5000000");
|
|
|
- blackstartResistanceTextfield.setBounds(10, 10, 170, 20);
|
|
|
- parameterPanel.add(blackstartResistanceTextfield);
|
|
|
+ blackstartEnergyrequierementTextfield = new TextField("5000000");
|
|
|
+ blackstartEnergyrequierementTextfield.setBounds(10, 10, 170, 20);
|
|
|
+ parameterPanel.add(blackstartEnergyrequierementTextfield);
|
|
|
|
|
|
- JLabel blackstartResistanceLabel = new JLabel("Blackstart resistance in Watt");
|
|
|
- blackstartResistanceLabel.setBounds(185, 10, 300, 20);
|
|
|
- parameterPanel.add(blackstartResistanceLabel);
|
|
|
+ JLabel blackstartEnergyrequierementLabel = new JLabel("Blackstart Energyrequirement in Watt");
|
|
|
+ blackstartEnergyrequierementLabel.setBounds(185, 10, 300, 20);
|
|
|
+ parameterPanel.add(blackstartEnergyrequierementLabel);
|
|
|
|
|
|
blackstartSuccessTimeTextfield = new TextField("30");
|
|
|
blackstartSuccessTimeTextfield.setBounds(10, 35, 170, 20);
|
|
@@ -242,18 +240,17 @@ public class controlAlgorithm implements AddOn {
|
|
|
private void initAlgo() {
|
|
|
try {
|
|
|
// init
|
|
|
- SPC = new StorageProductionController(getStorageElements());// DANGER DONT GIVE NULL
|
|
|
-// control.getModel().setStorageProductionController();
|
|
|
-// SPC = control.getModel().getStorageProductionController();
|
|
|
renewableProducers = getRenewableProducers();
|
|
|
consumers = getConsumers();
|
|
|
- powerPlant = control.getSimManager().getPowerPlant();// DANGER DONT GIVE NULL
|
|
|
- if(powerPlant == null){
|
|
|
+ powerplant = control.getSimManager().getPowerplant();// DANGER DONT GIVE NULL
|
|
|
+ setPowerPlantBlackstartResistance(-Float.parseFloat(blackstartEnergyrequierementTextfield.getText()));
|
|
|
+ SPC = new StorageProductionController(getStorageElements(), getEnergyRequiredForPowerplantBlackstart());// DANGER DONT GIVE NULL
|
|
|
+ if(powerplant == null){
|
|
|
println("No Power Plant in Model");
|
|
|
return;
|
|
|
}
|
|
|
- resistanceCalculator resistanceCalculator = new resistanceCalculator();
|
|
|
- resistanceCalculator.setDistanceToCalcResistance(powerPlant);
|
|
|
+ resistanceCalculator resistanceCalculator = new resistanceCalculator(control.getModel());
|
|
|
+ resistanceCalculator.setDistanceToCalcResistance(powerplant);
|
|
|
blackstartRunningCounter = 0;
|
|
|
deactivateBlackstart();
|
|
|
control.getModel().setCurIteration(0);
|
|
@@ -267,7 +264,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
/////////
|
|
|
|
|
|
// Get parameters from textfields
|
|
|
- setPowerPlantBlackstartResistance(-Float.parseFloat(blackstartResistanceTextfield.getText()));
|
|
|
+ setPowerPlantBlackstartResistance(-Float.parseFloat(blackstartEnergyrequierementTextfield.getText()));
|
|
|
blackstartSuccessTime = Integer.parseInt(blackstartSuccessTimeTextfield.getText());
|
|
|
powerplantMaxOutput = Float.parseFloat(powerplantMaxOutputTextfield.getText());
|
|
|
blackstartStartTime = Integer.parseInt(blackstartStartTimeTextfield.getText());
|
|
@@ -347,12 +344,12 @@ public class controlAlgorithm implements AddOn {
|
|
|
* this iteration
|
|
|
*/
|
|
|
private boolean blackstartAlgo() {
|
|
|
- if (currentRenewableProduction() < getPowerPlantBlackstartResistance()) {
|
|
|
+ if (currentRenewableProduction() < getEnergyRequiredForPowerplantBlackstart()) {
|
|
|
// renewable energy production is not sufficient for the blackstart
|
|
|
- if (SPC.currentPossibleStorageProduction() >= getPowerPlantBlackstartResistance()
|
|
|
+ if (SPC.currentPossibleStorageProduction() >= getEnergyRequiredForPowerplantBlackstart()
|
|
|
- currentRenewableProduction()) {// is there currently enough power available from storage?
|
|
|
SPC.disableStorageDischarging(-1);// emergency fix
|
|
|
- SPC.enableStorageDischarging(getPowerPlantBlackstartResistance() - currentRenewableProduction());
|
|
|
+ SPC.enableStorageDischarging(getEnergyRequiredForPowerplantBlackstart() - currentRenewableProduction());
|
|
|
rampUpPowerplant();
|
|
|
enableConsumers(getPowerplantProduction());
|
|
|
return true;
|
|
@@ -367,7 +364,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
// renewable energy production is sufficient for the blackstart
|
|
|
rampUpPowerplant();
|
|
|
enableConsumers(
|
|
|
- currentRenewableProduction() - getPowerPlantBlackstartResistance() + getPowerplantProduction());
|
|
|
+ currentRenewableProduction() - getEnergyRequiredForPowerplantBlackstart() + getPowerplantProduction());
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -401,7 +398,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
private void enableConsumers(float energyAvailable) {
|
|
|
println("currenctrenewable: " + currentRenewableProduction());
|
|
|
println("currenctpossiblestorage: " + SPC.currentPossibleStorageProduction());
|
|
|
- println("blackstart resi: " + getPowerPlantBlackstartResistance());
|
|
|
+ println("blackstart resi: " + getEnergyRequiredForPowerplantBlackstart());
|
|
|
println("current pp production: " + getPowerplantProduction());
|
|
|
println("energy available for consumers" + energyAvailable);
|
|
|
|
|
@@ -458,7 +455,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
|
|
|
private void rampUpPowerplant() {
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Power")) {
|
|
|
ele.setEnergyPerElement(ele.getEnergyPerElement() + powerplantMaxOutput / blackstartSuccessTime);
|
|
|
}
|
|
@@ -467,7 +464,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
|
|
|
private float getPowerplantProduction() {
|
|
|
float totalProduction = 0;
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Power")) {
|
|
|
totalProduction = ele.getEnergyPerElement();
|
|
|
}
|
|
@@ -476,15 +473,15 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
|
|
|
private void setPowerplantProduction(float power) {
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Power")) {
|
|
|
ele.setEnergyPerElement(power);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private float getPowerPlantBlackstartResistance() {
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ private float getEnergyRequiredForPowerplantBlackstart() {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Blackstart")) {
|
|
|
return -ele.getEnergyPerElement();
|
|
|
}
|
|
@@ -493,7 +490,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
|
|
|
private void setPowerPlantBlackstartResistance(float resistance) {
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Blackstart")) {
|
|
|
ele.setEnergyPerElement(resistance);
|
|
|
}
|
|
@@ -501,7 +498,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
|
|
|
private void activateBlackstart() {
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Blackstart")) {
|
|
|
ele.setActive(true);
|
|
|
}
|
|
@@ -509,7 +506,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
}
|
|
|
|
|
|
private void deactivateBlackstart() {
|
|
|
- for (HolonElement ele : powerPlant.getElements()) {
|
|
|
+ for (HolonElement ele : powerplant.getElements()) {
|
|
|
if (ele.getEleName().equals("Blackstart")) {
|
|
|
ele.setActive(false);
|
|
|
}
|