Browse Source

renewables now consider cable resistancees, gui voltage and renwable power setters

David Heck 4 years ago
parent
commit
dc0bb766b6
3 changed files with 59 additions and 20 deletions
  1. 48 19
      src/blackstart/controlAlgorithm.java
  2. 1 1
      src/classes/resistanceCalculator.java
  3. 10 0
      src/ui/model/Model.java

+ 48 - 19
src/blackstart/controlAlgorithm.java

@@ -32,6 +32,7 @@ public class controlAlgorithm implements AddOn {
 	private TextField waitBetweenIterations;
 	private TextField lowVolatageTextfield;
 	private TextField highVolatageTextfield;
+	private TextField renewableTextfield;
 
 	private int blackstartSuccessTime;
 	private int blackstartStartTime;
@@ -59,7 +60,7 @@ public class controlAlgorithm implements AddOn {
 		JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createOptionPanel(), scrollPane);
 		splitPane.setResizeWeight(0.0);
 		content.add(splitPane, BorderLayout.CENTER);
-		content.setPreferredSize(new Dimension(800, 800));
+		content.setPreferredSize(new Dimension(1000, 800));
 	}
 
 	public JPanel createOptionPanel() {
@@ -131,22 +132,30 @@ public class controlAlgorithm implements AddOn {
 		waitBetweenIterationsLabel.setBounds(110, 205, 300, 20);
 		parameterPanel.add(waitBetweenIterationsLabel);
 
-//		////////collums
-//		lowVolatageTextfield = new TextField("230");
-//		lowVolatageTextfield.setBounds(425, 10, 95, 20);
-//		parameterPanel.add(lowVolatageTextfield);
-//
-//		JLabel lowVolatageLabel = new JLabel("low voltage in volt");
-//		lowVolatageLabel.setBounds(530, 10, 300, 20);
-//		parameterPanel.add(lowVolatageLabel);
-//
-//		highVolatageTextfield = new TextField("20000");
-//		highVolatageTextfield.setBounds(425, 35, 95, 20);
-//		parameterPanel.add(highVolatageTextfield);
-//
-//		JLabel highVolatageLabel = new JLabel("high voltage in volt");
-//		highVolatageLabel.setBounds(530, 35, 300, 20);
-//		parameterPanel.add(highVolatageLabel);
+		////////collums
+		lowVolatageTextfield = new TextField("230");
+		lowVolatageTextfield.setBounds(425, 10, 95, 20);
+		parameterPanel.add(lowVolatageTextfield);
+
+		JLabel lowVolatageLabel = new JLabel("low voltage in volt");
+		lowVolatageLabel.setBounds(530, 10, 300, 20);
+		parameterPanel.add(lowVolatageLabel);
+
+		highVolatageTextfield = new TextField("20000");
+		highVolatageTextfield.setBounds(425, 35, 95, 20);
+		parameterPanel.add(highVolatageTextfield);
+
+		JLabel highVolatageLabel = new JLabel("high voltage in volt");
+		highVolatageLabel.setBounds(530, 35, 300, 20);
+		parameterPanel.add(highVolatageLabel);
+
+		renewableTextfield = new TextField("300");
+		renewableTextfield.setBounds(425, 60, 95, 20);
+		parameterPanel.add(renewableTextfield);
+
+		JLabel renewableLabel = new JLabel("renewable power per element in watt");
+		renewableLabel.setBounds(530, 60, 300, 20);
+		parameterPanel.add(renewableLabel);
 
 		return parameterPanel;
 	}
@@ -219,14 +228,19 @@ public class controlAlgorithm implements AddOn {
 				println("No Power Plant in Model");
 				return;
 			}
-			resistanceCalculator resistanceCalculator = new resistanceCalculator(230, 20000, 30, 30,0.017, 0.017);//TODO
-			resistanceCalculator.setDistancesToCalcResistance(powerplant);
+			control.getModel().setResistanceCalculator(new resistanceCalculator(
+					Integer.parseInt(lowVolatageTextfield.getText()),
+					Integer.parseInt(highVolatageTextfield.getText()),
+					30, 30,0.017, 0.017));
+			control.getModel().getResistanceCalculator().setDistancesToCalcResistance(powerplant);
+
 			blackstartRunningCounter = 0;
 			deactivateBlackstart();
 			control.getModel().setCurIteration(0);
 
 			// prepare model
 			/////////
+			setRenewableElements(Float.parseFloat(renewableTextfield.getText()));
 			disablePowerplantProduction();
 			enableAllConsumers();
 			SPC.setAllStorageToStandy();
@@ -404,6 +418,21 @@ public class controlAlgorithm implements AddOn {
 		}
 	}
 
+	private void setRenewableElements(float energy){
+		for (HolonObject house : renewableProducers) {
+			for (HolonElement ele : house.getElements()) {
+				if (ele.getEleName().equals("Solar Panels")) {// TODO: hier muss noch mehr dazu
+					ele.setEnergyPerElement(
+							control.getModel().getResistanceCalculator().calcEnergyAfterResistance(
+									energy,
+									ele.getLowDistance(),
+									ele.getHighDistance(),
+									getEnergyRequiredForPowerplantBlackstart()));
+				}
+			}
+		}
+	}
+
 	private float currentRenewableProduction() {
 		float production = 0;
 		for (HolonObject house : renewableProducers) {

+ 1 - 1
src/classes/resistanceCalculator.java

@@ -79,7 +79,7 @@ public class resistanceCalculator {
         return Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));
     }
 
-    float calcEnergyAfterResistance(float currentEnergy, double lowDistance, double highDistance, float energyRequiredForPowerplantBlackstart){
+    public float calcEnergyAfterResistance(float currentEnergy, double lowDistance, double highDistance, float energyRequiredForPowerplantBlackstart){
         double energyAfterLowVoltage = calcEnergyAfterPartOfGrid(currentEnergy, lowVoltage, lowDistance, lowSpecificMaterialResistance, lowDiameter, energyRequiredForPowerplantBlackstart);
         energyAfterLowVoltage = (0.98 * energyAfterLowVoltage); //transfomer loses
         return (float) calcEnergyAfterPartOfGrid(energyAfterLowVoltage, highVoltage, highDistance, highSpecificMaterialResistance, highDiameter, energyRequiredForPowerplantBlackstart);

+ 10 - 0
src/ui/model/Model.java

@@ -77,6 +77,8 @@ public class Model {
     private boolean showSupplyBars = true;
     //TODO:
     private int iterations=100;
+
+    private resistanceCalculator resistanceCalculator;
     
     /**
 	 * All implemented FairnessModels:<br>
@@ -1103,4 +1105,12 @@ public class Model {
 			else if(aCps instanceof HolonSwitch)switchsOnCanvas.add((HolonSwitch) aCps);
 		}
 	}
+
+    public void setResistanceCalculator(resistanceCalculator resistanceCalculator) {
+        this.resistanceCalculator = resistanceCalculator;
+    }
+
+    public classes.resistanceCalculator getResistanceCalculator() {
+        return resistanceCalculator;
+    }
 }