Skip to content

Commit

Permalink
hotfix. KPI for cost was missing
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwaibel committed Oct 14, 2020
1 parent 2347e08 commit 5cc08d3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
20 changes: 17 additions & 3 deletions src/Hive.IO/Hive.IO/Building/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@ public abstract class Component
/// Total Cost in [Currency]
/// </summary>
[JsonProperty]
public double Cost { get; protected set; }
public double SpecificCost { get; protected set; }

private double? _totalCost = null;

[JsonProperty]
public double TotalCost

This comment has been minimized.

Copy link
@christophwaibel

christophwaibel Oct 15, 2020

Author Contributor

@daren-thomas :
public double TotalCost => this.SpecificCost * this.Area; // such a simple calc that it's prolly even faster than the get if blabla

{
get
{
if (_totalCost == null)
_totalCost = this.SpecificCost * this.Area;

return (double) _totalCost;
}
private set => _totalCost = value;
}

/// <summary>
/// Specific CO2 emissions [kgCO2eq./m^2]
Expand Down Expand Up @@ -123,7 +137,7 @@ public virtual void ApplySia2024Construction(Sia2024Record siaRoom)
UValue = siaRoom.UValueOpaque
};
this.SpecificCo2 = siaRoom.OpaqueEmissions;
this.Cost = siaRoom.OpaqueCost;
this.SpecificCost = siaRoom.OpaqueCost;
this.Construction = opaqueConstruction;
}
}
Expand Down Expand Up @@ -154,7 +168,7 @@ public override void ApplySia2024Construction(Sia2024Record siaRoom)
Transmissivity = siaRoom.GValue
};
base.SpecificCo2 = siaRoom.TransparentEmissions;
base.Cost = siaRoom.TransparentCost;
base.SpecificCost = siaRoom.TransparentCost;
base.Construction = transparentConstruction;
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/Hive.IO/Hive.IO/Results/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public class Results

#endregion

#region Total Costs
[JsonProperty]
public double TotalConstructionCost { get; private set; }
#endregion

#region Zone-wise loads
[JsonProperty]
Expand Down Expand Up @@ -279,6 +283,7 @@ public Results(Building.Building building, List<ConversionTech> conversionTech,
{
this.TotalFloorArea = GetTotalFloorArea(building);
this.TotalEmbodiedConstructionEmissions = GetTotalEmbodiedConstructionEmissions(building);
this.TotalConstructionCost = GetTotalConstructionCost(building);

this.TotalFinalHeatingMonthly = GetTotalMonthlyFinalLoads(building, "heating");
this.TotalFinalDomesticHotWaterMonthly = GetTotalMonthlyFinalLoads(building, "dhw");
Expand Down Expand Up @@ -655,6 +660,15 @@ public static double GetTotalEmbodiedConstructionEmissions(Building.Building bui
return totalCo2;
}

public static double GetTotalConstructionCost(Building.Building building)
{
double totalCost = 0.0;
foreach (var zone in building.Zones)
foreach (var component in zone.SurfaceComponents)
totalCost += component.TotalCost;
return totalCost;
}

public static double[] GetTotalMonthlyFinalLoads(Building.Building building, string loadType)
{
double[] totalLoads = new double[Misc.MonthsPerYear];
Expand Down
16 changes: 8 additions & 8 deletions src/Hive.IO/Hive.IO/Results/ResultsPlotting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public double[] EmbodiedEmissionsBuildingsMonthly(bool normalized)
public double[] EmbodiedEmissionsSystemsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 200.0;
double dummy = 0.0;
double[] result = new double[12].Select(r => dummy).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;
}
Expand All @@ -47,7 +47,7 @@ public double[] EmbodiedEmissionsSystemsMonthly(bool normalized)
public double[] OperationEmissionsBuildingsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 300.0;
double dummy = 0.0;
double[] result = new double[12].Select(r => dummy).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;

Expand All @@ -57,7 +57,7 @@ public double[] OperationEmissionsBuildingsMonthly(bool normalized)
public double[] OperationEmissionsSystemsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 400.0;
double dummy = 0.0;
double[] result = new double[12].Select(r => dummy).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;
}
Expand All @@ -77,8 +77,8 @@ public double TotalEmissions(bool normalized) =>
public double[] EmbodiedCostsBuildingsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 110.0;
double[] result = new double[12].Select(r => dummy).ToArray();
double totalContructionCosts = this.Results.TotalConstructionCost;
double[] result = new double[Misc.MonthsPerYear].Select(r => totalContructionCosts / Misc.MonthsPerYear).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;
}

Expand All @@ -87,7 +87,7 @@ public double[] EmbodiedCostsBuildingsMonthly(bool normalized)
public double[] EmbodiedCostsSystemsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 220.0;
double dummy = 0.0;
double[] result = new double[12].Select(r => dummy).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;
}
Expand All @@ -96,7 +96,7 @@ public double[] EmbodiedCostsSystemsMonthly(bool normalized)
public double[] OperationCostsBuildingsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 330.0;
double dummy = 0.0;
double[] result = new double[12].Select(r => dummy).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;

Expand All @@ -105,7 +105,7 @@ public double[] OperationCostsBuildingsMonthly(bool normalized)
public double[] OperationCostsSystemsMonthly(bool normalized)
{
// FIXME: plug in real values here...
double dummy = 440.0;
double dummy = 0.0;
double[] result = new double[12].Select(r => dummy).ToArray();
return normalized ? result.Select(r => r / TotalFloorArea).ToArray() : result;

Expand Down

0 comments on commit 5cc08d3

Please sign in to comment.