diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2025-02-10 15:25:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-10 15:25:26 +0100 |
| commit | 20d8587552840c0379e35f70dad05c46de439122 (patch) | |
| tree | 27772bb50b3c23d0965846b80c9b2fbe421dc940 /opendc-simulator | |
| parent | 2a0f78cd550b2187341b7c0c2ca443c27ef44bb1 (diff) | |
added embodied carbon (#303)
Diffstat (limited to 'opendc-simulator')
| -rw-r--r-- | opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/batteries/SimBattery.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/batteries/SimBattery.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/batteries/SimBattery.java index d229d4b5..f09cbcee 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/batteries/SimBattery.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/batteries/SimBattery.java @@ -49,6 +49,12 @@ public class SimBattery extends FlowNode implements FlowConsumer, FlowSupplier { private final String name; private final String clusterName; + private final Double embodiedCarbonRate; // The rate of carbon emissions per millisecond + private Double embodiedCarbonEmission = 0.0; + + public Double getEmbodiedCarbonEmission() { + return embodiedCarbonEmission; + } public String getName() { return name; @@ -112,9 +118,16 @@ public class SimBattery extends FlowNode implements FlowConsumer, FlowSupplier { } /** - * Construct a new {@link FlowNode} instance. + * Construct a new {@link SimBattery} instance. * - * @param parentGraph The {@link FlowGraph} this stage belongs to. + * @param parentGraph The {@link FlowGraph} instance this battery is part of. + * @param capacity The capacity of the battery in kWh. + * @param chargingSpeed The charging speed of the battery in J. + * @param initialCharge The initial charge of the battery in kWh. + * @param name The name of the battery. + * @param clusterName The name of the cluster the battery is part of. + * @param totalEmbodiedCarbon The total embodied carbon used to manufacture the battery in kg. + * @param expectedLifeTime The expected lifetime of the battery in years. */ public SimBattery( FlowGraph parentGraph, @@ -122,15 +135,21 @@ public class SimBattery extends FlowNode implements FlowConsumer, FlowSupplier { double chargingSpeed, double initialCharge, String name, - String clusterName) { + String clusterName, + Double totalEmbodiedCarbon, + Double expectedLifeTime) { super(parentGraph); - this.capacity = capacity; + this.capacity = capacity * 3600000; this.chargingSpeed = chargingSpeed; - this.charge = initialCharge; + this.charge = initialCharge * 3600000; this.name = name; this.clusterName = clusterName; + + // TODO: maybe change this to days instead of years? + this.embodiedCarbonRate = + (totalEmbodiedCarbon * 1000) / (expectedLifeTime * 365.0 * 24.0 * 60.0 * 60.0 * 1000.0); } public void close() { @@ -188,6 +207,8 @@ public class SimBattery extends FlowNode implements FlowConsumer, FlowSupplier { long passedTime = now - lastUpdate; + this.embodiedCarbonEmission += this.embodiedCarbonRate * passedTime; + this.updateCharge(passedTime); if (passedTime > 0) { double energyUsage = (this.outgoingSupply * passedTime * 0.001); |
