Skip to content

Commit

Permalink
Merge pull request #652 from architecture-building-systems/537-amrplo…
Browse files Browse the repository at this point in the history
…t-online

Make AmrPlot online + other improvements to visualiser
  • Loading branch information
christophwaibel authored Oct 4, 2021
2 parents 82353f4 + a9a2672 commit 13c9def
Show file tree
Hide file tree
Showing 43 changed files with 1,915 additions and 920 deletions.
Binary file modified GrasshopperExamples/LectureExercises/EaCS3_E04_Hive_Template.gh
Binary file not shown.
Binary file modified setup/Setup_Hive.exe
Binary file not shown.
26 changes: 14 additions & 12 deletions src/Hive.IO/Hive.IO/Building/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,25 @@ public double TotalCost
/// Specific CO2 emissions [kgCO2eq./m^2]
/// </summary>
[JsonProperty]
public double SpecificCo2 { get; protected set; }
public double SpecificEmissions { get; protected set; }

private double? _totalCo2 = null;
private double? _totalEmissions = null;

[JsonProperty]
public double TotalCo2
public double TotalEmissions
{
get
{
if (_totalCo2 == null)
_totalCo2 = this.SpecificCo2 * this.Area;
if (_totalEmissions == null)
_totalEmissions = this.SpecificEmissions * this.Area;

return (double) _totalCo2;
return (double) _totalEmissions;
}
private set => _totalCo2 = value;
private set => _totalEmissions = value;
}

public double Lifetime => Misc.DefaultBuildingLifetime; // hard coded for now!

/// <summary>
/// Total surface area of this component, in [sqm]
/// </summary>
Expand Down Expand Up @@ -137,7 +139,7 @@ public virtual void ApplySia2024Construction(Sia2024Record siaRoom)
UValue = siaRoom.UValueOpaque,
Capacitance = siaRoom.CapacitancePerFloorArea
};
this.SpecificCo2 = siaRoom.OpaqueEmissions;
this.SpecificEmissions = siaRoom.OpaqueEmissions;
this.SpecificCost = siaRoom.OpaqueCost;
this.Construction = opaqueConstruction;
}
Expand Down Expand Up @@ -168,7 +170,7 @@ public override void ApplySia2024Construction(Sia2024Record siaRoom)
UValue = siaRoom.UValueTransparent,
Transmissivity = siaRoom.GValue
};
base.SpecificCo2 = siaRoom.TransparentEmissions;
base.SpecificEmissions = siaRoom.TransparentEmissions;
base.SpecificCost = siaRoom.TransparentCost;
base.Construction = transparentConstruction;
}
Expand Down Expand Up @@ -198,7 +200,7 @@ public override void ApplySia2024Construction(Sia2024Record siaRoom)
UValue = siaRoom.UValueWalls,
Capacitance = siaRoom.CapacityWalls
};
this.SpecificCo2 = siaRoom.EmissionsWalls;
this.SpecificEmissions = siaRoom.EmissionsWalls;
this.SpecificCost = siaRoom.CostWalls;
this.Construction = opaqueConstruction;
}
Expand Down Expand Up @@ -227,7 +229,7 @@ public override void ApplySia2024Construction(Sia2024Record siaRoom)
UValue = siaRoom.UValueRoofs,
Capacitance = siaRoom.CapacityRoofs
};
this.SpecificCo2 = siaRoom.EmissionsRoofs;
this.SpecificEmissions = siaRoom.EmissionsRoofs;
this.SpecificCost = siaRoom.CostRoofs;
this.Construction = opaqueConstruction;
}
Expand Down Expand Up @@ -257,7 +259,7 @@ public override void ApplySia2024Construction(Sia2024Record siaRoom)
UValue = siaRoom.UValueFloors,
Capacitance = siaRoom.CapacityFloors
};
this.SpecificCo2 = siaRoom.EmissionsFloors;
this.SpecificEmissions = siaRoom.EmissionsFloors;
this.SpecificCost = siaRoom.CostFloors;
this.Construction = opaqueConstruction;
}
Expand Down
106 changes: 60 additions & 46 deletions src/Hive.IO/Hive.IO/EnergySystems/Carrier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,15 @@ public enum EnergyUnit
KiloWattHours
}

private double[] _monthlyAverageEnergy;
private double[] _energyMonthlyAverage;

private double[] _emissionsMonthly;

private double[] _monthlyCumulativeEmissions;
private double[] _costMonthly;

private double[] _energyMonthly;

private double[] _monthlyCumulativeEnergy;


private double[] _monthlyTemperature;
private double[] _temperatureMonthly;

[JsonConstructor]
protected Carrier()
Expand Down Expand Up @@ -262,45 +261,45 @@ protected Carrier(int horizon, EnergyUnit unit, double[] energy, double[] energy
// energy could be free, e.g. air, in which case energyCost == null
if (energyPrice != null && energyPrice.Length != 0)
{
EnergyPrice = new double[energyPrice.Length];
energyPrice.CopyTo(EnergyPrice, 0);
SpecificCost = new double[energyPrice.Length];
energyPrice.CopyTo(SpecificCost, 0);
}
else
{
EnergyPrice = new double[horizon].Select(x => 0.0).ToArray();
SpecificCost = new double[horizon].Select(x => 0.0).ToArray();
}

// energy could have zero emissions, e.g. air or solar, in which case ghgEmissions == null
if (ghgEmissionsFactor != null && ghgEmissionsFactor.Length != 0)
{
GhgEmissionsFactor = new double[ghgEmissionsFactor.Length];
ghgEmissionsFactor.CopyTo(GhgEmissionsFactor, 0);
SpecificEmissions = new double[ghgEmissionsFactor.Length];
ghgEmissionsFactor.CopyTo(SpecificEmissions, 0);
}
else
{
GhgEmissionsFactor = new double[horizon].Select(x => 0.0).ToArray();
SpecificEmissions = new double[horizon].Select(x => 0.0).ToArray();
}

if (Energy != null && EnergyPrice != null && Energy.Length == EnergyPrice.Length)
if (Energy != null && SpecificCost != null && Energy.Length == SpecificCost.Length)
{
var _horizon = Energy.Length;
TotalEnergyCost = new double[_horizon];
for (var t = 0; t < _horizon; t++) TotalEnergyCost[t] = Energy[t] * EnergyPrice[t];
TotalCost = new double[_horizon];
for (var t = 0; t < _horizon; t++) TotalCost[t] = Energy[t] * SpecificCost[t];
}
else
{
TotalEnergyCost = new double[horizon].Select(x => 0.0).ToArray();
TotalCost = new double[horizon].Select(x => 0.0).ToArray();
}

if (Energy != null && GhgEmissionsFactor != null && Energy.Length == GhgEmissionsFactor.Length)
if (Energy != null && SpecificEmissions != null && Energy.Length == SpecificEmissions.Length)
{
var _horizon = Energy.Length;
TotalGhgEmissions = new double[_horizon];
for (var t = 0; t < _horizon; t++) TotalGhgEmissions[t] = Energy[t] * GhgEmissionsFactor[t];
TotalEmissions = new double[_horizon];
for (var t = 0; t < _horizon; t++) TotalEmissions[t] = Energy[t] * SpecificEmissions[t];
}
else
{
TotalGhgEmissions = new double[horizon].Select(x => 0.0).ToArray();
TotalEmissions = new double[horizon].Select(x => 0.0).ToArray();
}
}

Expand Down Expand Up @@ -330,19 +329,21 @@ protected Carrier(int horizon, EnergyUnit unit, double[] energy, double[] energy
/// Time series with cost coefficients per this.Unit
/// </summary>
[JsonProperty]
public double[] EnergyPrice { get; protected set; }

[JsonProperty]
public double[] TotalEnergyCost { get; protected set; }
public double[] SpecificCost { get; protected set; }

[JsonProperty]
public double[] TotalCost { get; protected set; }
/// <summary>
/// Time series of Greenhouse gas emissions in kgCO2eq/this.Unit
/// </summary>
[JsonProperty]
public double[] GhgEmissionsFactor { get; protected set; }
public double[] SpecificEmissions { get; protected set; }

/// <summary>
/// Time series of Greenhouse gas emissions in kgCO2eq
/// </summary>
[JsonProperty]
public double[] TotalGhgEmissions { get; protected set; }
public double[] TotalEmissions { get; protected set; }


[JsonProperty]
Expand All @@ -356,51 +357,64 @@ protected Carrier(int horizon, EnergyUnit unit, double[] energy, double[] energy
public double[] Temperature { get; protected set; }

[JsonProperty]
public double[] MonthlyCumulativeEmissions
public double[] EmissionsMonthly
{
get
{
if (_emissionsMonthly == null)
_emissionsMonthly = Misc.GetCumulativeMonthlyValue(TotalEmissions);
return _emissionsMonthly;
}
private set => _emissionsMonthly = value;
}


[JsonProperty]
public double[] CostMonthlyCumulative
{
get
{
if (_monthlyCumulativeEmissions == null)
_monthlyCumulativeEmissions = Misc.GetCumulativeMonthlyValue(TotalGhgEmissions);
return _monthlyCumulativeEmissions;
if (_costMonthly == null)
_costMonthly = Misc.GetCumulativeMonthlyValue(TotalCost);
return _costMonthly;
}
private set => _monthlyCumulativeEmissions = value;
private set => _costMonthly = value;
}

[JsonProperty]
public double[] MonthlyCumulativeEnergy
public double[] EnergyMonthlyCumulative
{
get
{
if (_monthlyCumulativeEnergy == null)
_monthlyCumulativeEnergy = Misc.GetCumulativeMonthlyValue(Energy);
return _monthlyCumulativeEnergy;
if (_energyMonthly == null)
_energyMonthly = Misc.GetCumulativeMonthlyValue(Energy);
return _energyMonthly;
}
private set => _monthlyCumulativeEmissions = value;
private set => _energyMonthly = value;
}

[JsonProperty]
public double[] MonthlyAverageEnergy
public double[] EnergyMonthlyAverage
{
get
{
if (_monthlyAverageEnergy == null)
_monthlyAverageEnergy = Misc.GetAverageMonthlyValue(Energy);
return _monthlyAverageEnergy;
if (_energyMonthlyAverage == null)
_energyMonthlyAverage = Misc.GetAverageMonthlyValue(Energy);
return _energyMonthlyAverage;
}
private set => _monthlyAverageEnergy = value;
private set => _energyMonthlyAverage = value;
}

[JsonProperty]
public double[] MonthlyTemperature
public double[] TemperatureMonthly
{
get
{
if (_monthlyTemperature == null)
_monthlyTemperature = Misc.GetAverageMonthlyValue(Temperature);
return _monthlyTemperature;
if (_temperatureMonthly == null)
_temperatureMonthly = Misc.GetAverageMonthlyValue(Temperature);
return _temperatureMonthly;
}
private set => _monthlyTemperature = value;
private set => _temperatureMonthly = value;
}
}
}
28 changes: 14 additions & 14 deletions src/Hive.IO/Hive.IO/EnergySystems/CombustionTech.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace Hive.IO.EnergySystems
{
public abstract class CombustionTech : ConversionTech
{
protected CombustionTech(double investmentCost, double embodiedGhg, double capacity, bool isHeating, bool isElectric)
: base(investmentCost, embodiedGhg, capacity, "kW", isHeating, false, isElectric)
protected CombustionTech(double investmentCost, double embodiedGhg, double lifetime, double capacity, bool isHeating, bool isElectric)
: base(investmentCost, embodiedGhg, lifetime, capacity, "kW", isHeating, false, isElectric)
{
}
}
Expand All @@ -14,8 +14,8 @@ protected CombustionTech(double investmentCost, double embodiedGhg, double capac
public class GasBoiler : CombustionTech
{
public double Efficiency { get; private set; }
public GasBoiler(double investmentCost, double embodiedGhg, double capacity, double efficiency)
: base(investmentCost, embodiedGhg, capacity, true, false)
public GasBoiler(double investmentCost, double embodiedGhg, double lifetime, double capacity, double efficiency)
: base(investmentCost, embodiedGhg, lifetime, capacity, true, false)
{
this.Efficiency = efficiency;
base.Name = "GasBoiler";
Expand All @@ -36,13 +36,13 @@ public void SetInputOutput(Gas gasInput, double[] heatingGenerated, double[] sup
}
if (horizon == Misc.MonthsPerYear)
{
gasPrice = Misc.GetAverageMonthlyValue(gasInput.EnergyPrice);
gasEmissionsFactor = Misc.GetAverageMonthlyValue(gasInput.GhgEmissionsFactor);
gasPrice = Misc.GetAverageMonthlyValue(gasInput.SpecificCost);
gasEmissionsFactor = Misc.GetAverageMonthlyValue(gasInput.SpecificEmissions);
}
else
{
gasPrice = gasInput.EnergyPrice;
gasEmissionsFactor = gasInput.GhgEmissionsFactor;
gasPrice = gasInput.SpecificCost;
gasEmissionsFactor = gasInput.SpecificEmissions;
}

base.InputCarrier = new Gas(horizon, gasConsumed, gasPrice, gasEmissionsFactor, gasInput.PrimaryEnergyFactor); // infused with how much gas is consumed. input Gas carrier has no Energy information
Expand All @@ -57,8 +57,8 @@ public class CombinedHeatPower : CombustionTech
{
public double HeatToPowerRatio { get; private set; }
public double ElectricEfficiency { get; private set; }
public CombinedHeatPower(double investmentCost, double embodiedGhg, double capacityElectric, double heatToPowerRatio, double electricEfficiency)
: base(investmentCost, embodiedGhg, capacityElectric, true, true)
public CombinedHeatPower(double investmentCost, double embodiedGhg, double lifetime, double capacityElectric, double heatToPowerRatio, double electricEfficiency)
: base(investmentCost, lifetime, embodiedGhg, capacityElectric, true, true)
{
this.HeatToPowerRatio = heatToPowerRatio;
this.ElectricEfficiency = electricEfficiency;
Expand Down Expand Up @@ -93,13 +93,13 @@ public void SetInputOutput(Gas gasInput, double [] energyGenerated, double [] su

if (horizon == Misc.MonthsPerYear)
{
gasPrice = Misc.GetAverageMonthlyValue(gasInput.EnergyPrice);
gasEmissionsFactor = Misc.GetAverageMonthlyValue(gasInput.GhgEmissionsFactor);
gasPrice = Misc.GetAverageMonthlyValue(gasInput.SpecificCost);
gasEmissionsFactor = Misc.GetAverageMonthlyValue(gasInput.SpecificEmissions);
}
else
{
gasPrice = gasInput.EnergyPrice;
gasEmissionsFactor = gasInput.GhgEmissionsFactor;
gasPrice = gasInput.SpecificCost;
gasEmissionsFactor = gasInput.SpecificEmissions;
}

base.InputCarrier = new Gas(horizon, gasConsumed, gasPrice, gasEmissionsFactor, Misc.PEFNaturalGas); // infused with how much gas is consumed. input Gas carrier has no Energy information
Expand Down
Loading

0 comments on commit 13c9def

Please sign in to comment.