Browse Source

high and low voltage cables now understande different diameters and resistances

David Heck 5 năm trước cách đây
mục cha
commit
c79201876b

+ 1 - 1
src/blackstart/controlAlgorithm.java

@@ -219,7 +219,7 @@ public class controlAlgorithm implements AddOn {
 				println("No Power Plant in Model");
 				return;
 			}
-			resistanceCalculator resistanceCalculator = new resistanceCalculator(230, 20000, 30, 0.017);//TODO
+			resistanceCalculator resistanceCalculator = new resistanceCalculator(230, 20000, 30, 30,0.017, 0.017);//TODO
 			resistanceCalculator.setDistancesToCalcResistance(powerplant);
 			blackstartRunningCounter = 0;
 			deactivateBlackstart();

+ 1 - 1
src/classes/StorageElement.java

@@ -34,7 +34,7 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
 		this.capacity = capacity * 60;// we save in watts per minute for ease of use
 		this.status = Mode.STANDBY;
 		this.chargingRatio = 0;
-		this.resistanceCalculator = new resistanceCalculator(230, 20000, 30, 0.017);//TODO
+		this.resistanceCalculator = new resistanceCalculator(230, 20000,30, 30, 0.017, 0.017);//TODO
 	}
 
 	public float getEnergyPerElement() {

+ 21 - 11
src/classes/resistanceCalculator.java

@@ -10,16 +10,24 @@ public class resistanceCalculator {
     private int highVoltage;
 
     @Expose
-    private int diameter;
+    private int lowDiameter;
+    
+    @Expose
+    private  int highDiameter;
+
+    @Expose
+    private double lowSpecificMaterialResistance;
 
     @Expose
-    private double specificMaterialResistance;
+    private double highSpecificMaterialResistance;
 
-    public resistanceCalculator(int lowVoltage, int highVoltage, int diameter, double specificMaterialResistance){
+    public resistanceCalculator(int lowVoltage, int highVoltage, int lowDiameter, int highDiameter, double lowSpecificMaterialResistance, double highSpecificMaterialResistance){
         this.lowVoltage = lowVoltage;
         this.highVoltage = highVoltage;
-        this.diameter = diameter;
-        this.specificMaterialResistance = specificMaterialResistance;
+        this.lowDiameter = lowDiameter;
+        this.highDiameter = highDiameter;
+        this.lowSpecificMaterialResistance = lowSpecificMaterialResistance;
+        this.highSpecificMaterialResistance = highSpecificMaterialResistance;
     }
 
     public void setDistancesToCalcResistance(HolonObject powerPlant) {
@@ -72,12 +80,13 @@ public class resistanceCalculator {
     }
 
     float calcEnergyAfterResistance(float currentEnergy, double lowDistance, double highDistance, float energyRequiredForPowerplantBlackstart){
-        double energyAfterLowVoltage = calcEnergyAfterPartOfGrid(currentEnergy, lowVoltage, lowDistance, energyRequiredForPowerplantBlackstart);
+        double energyAfterLowVoltage = calcEnergyAfterPartOfGrid(currentEnergy, lowVoltage, lowDistance, lowSpecificMaterialResistance, lowDiameter, energyRequiredForPowerplantBlackstart);
         energyAfterLowVoltage = (0.98 * energyAfterLowVoltage); //transfomer loses
-        return (float) calcEnergyAfterPartOfGrid(energyAfterLowVoltage, highVoltage, highDistance, energyRequiredForPowerplantBlackstart);
+        return (float) calcEnergyAfterPartOfGrid(energyAfterLowVoltage, highVoltage, highDistance, highSpecificMaterialResistance, highDiameter, energyRequiredForPowerplantBlackstart);
     }
 
-    private double calcEnergyAfterPartOfGrid(double currentEnergy, int voltage, double distance, float energyRequiredForPowerplantBlackstart){
+    private double calcEnergyAfterPartOfGrid(double currentEnergy, int voltage, double distance,
+                                             double specificMaterialResistance, int diameter, float energyRequiredForPowerplantBlackstart){
         double blackstartResistance = blackstartResistance(voltage, energyRequiredForPowerplantBlackstart);
         double cableResistance = cableResistance(specificMaterialResistance, distance, diameter);
         return (1 - (cableResistance / (cableResistance + blackstartResistance))) * currentEnergy;
@@ -92,12 +101,13 @@ public class resistanceCalculator {
     }
 
     float calcEnergyNeededForCertainEnergyAfterResistance(float energyWanted, double lowDistance, double highDistance, float energyRequiredForPowerplantBlackstart){
-        double energyBeforeHighVoltage = calcEnergyNeededBeforePartOfGrid(energyWanted, highVoltage, highDistance,energyRequiredForPowerplantBlackstart);
+        double energyBeforeHighVoltage = calcEnergyNeededBeforePartOfGrid(energyWanted, highVoltage, highDistance, highSpecificMaterialResistance, highDiameter, energyRequiredForPowerplantBlackstart);
         energyBeforeHighVoltage = 1.02 * energyBeforeHighVoltage;
-        return (float) calcEnergyNeededBeforePartOfGrid(energyBeforeHighVoltage, lowVoltage, lowDistance, energyRequiredForPowerplantBlackstart);
+        return (float) calcEnergyNeededBeforePartOfGrid(energyBeforeHighVoltage, lowVoltage, lowDistance, lowSpecificMaterialResistance, lowDiameter, energyRequiredForPowerplantBlackstart);
     }
 
-    private double calcEnergyNeededBeforePartOfGrid(double energyWanted, int voltage, double distance, float energyRequiredForPowerplantBlackstart){
+    private double calcEnergyNeededBeforePartOfGrid(double energyWanted, int voltage, double distance,
+                                                    double specificMaterialResistance, int diameter, float energyRequiredForPowerplantBlackstart){
         double blackstartResistance = blackstartResistance(voltage, energyRequiredForPowerplantBlackstart);
         double cableResistance = cableResistance(specificMaterialResistance, distance, diameter);
         return (energyWanted / (1 - (cableResistance / (cableResistance + blackstartResistance))));