Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of all EnergySystems and Solar/SolarTech Components to C# #722

Merged
merged 27 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
27e46d8
migrated simple chiller
philipschulz Dec 29, 2021
3ad7dd0
migrated chiller time-resolved
philipschulz Dec 29, 2021
4ceb815
migrate simple heatpump
philipschulz Dec 29, 2021
9245f53
migrated heatpump COP
philipschulz Dec 29, 2021
4773fb5
migrated ASHP timeresolved, renamed simple heatpump to ASHP simple
philipschulz Dec 29, 2021
e8171b4
update NSI and build script
philipschulz Dec 30, 2021
3eed89c
migrated simple PV
philipschulz Dec 30, 2021
f0438a0
migrated PV orientation factor, GUI updates
philipschulz Dec 30, 2021
4b1b534
migrated noct pv
philipschulz Dec 30, 2021
4a8f4f8
migrated Simple solar thermal
philipschulz Dec 30, 2021
55ac822
migrated Solarthermal time resolved
philipschulz Dec 30, 2021
f3b499b
migrated SumOverTimePeriod
philipschulz Dec 31, 2021
eefe5e9
fixed item/list errors.
philipschulz Mar 8, 2022
d55c0b7
Added default values for PV component inputs
philipschulz Mar 8, 2022
d824b92
update PerformanceRatioReader, but still broken
philipschulz Mar 8, 2022
22649d2
updated Guids for GhEnergySystem and GhSolar Components for testing p…
philipschulz Mar 17, 2022
37dbc87
Added PerformanceRadio ValueList, automatically reads csv, Ratio read…
philipschulz Mar 17, 2022
d8a4f68
tested and fixed most GhEnergySystem and GhSolar components - still p…
philipschulz Mar 18, 2022
9122108
fixed unobstructed solar panel, added example for new SumOverTimePeri…
philipschulz Mar 24, 2022
a044dce
cleaned up simple_pv.gh
philipschulz Mar 31, 2022
04c41ba
cleaning up templates folder
christophwaibel Apr 4, 2022
14b28eb
Updating gh files in Testing folder
christophwaibel Apr 4, 2022
fd40493
removed ladybug template. replaced all honeybadger with c#, except in…
christophwaibel Apr 4, 2022
427c72b
PerformanceRatio csv gets compiled to json, redid PerformanceRatioLis…
philipschulz Apr 5, 2022
bc4a34c
updated gh templates with c# performance ratio reader and rebuilt ins…
christophwaibel Apr 6, 2022
6fa47f8
Merge branch 'master' into 697-migrate-honeybadger-components
christophwaibel Apr 6, 2022
8bdc75c
rebuilt installer after merge with master
christophwaibel Apr 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified setup/Setup_Hive.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions setup/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ echo Building Hive.Core...
cd %HIVE_DIR%\src\Hive.Core\
"%IPY%" "%HB%" epw_reader\Hive.Core.epw_reader.json
"%IPY%" "%HB%" sia380\Hive.Core.sia380.json
@REM "%IPY%" "%HB%" solar\Hive.Core.solar.json
"%IPY%" "%HB%" solar\Hive.Core.solar.json
"%IPY%" "%HB%" solar_tech\Hive.Core.solar_tech.json
@REM "%IPY%" "%HB%" combustion\Hive.Core.combustion.json
"%IPY%" "%HB%" combustion\Hive.Core.combustion.json
"%IPY%" "%HB%" cooling\Hive.Core.cooling.json
"%IPY%" "%HB%" heatpumps\Hive.Core.heatpumps.json
echo ...Done
Expand Down Expand Up @@ -58,7 +58,7 @@ cd %HIVE_DIR%\src\Hive.Core\
"%IPY%" "%HIVE_WIKI_PY%" sia380\Hive.Core.sia380.json
"%IPY%" "%HIVE_WIKI_PY%" solar\Hive.Core.solar.json
"%IPY%" "%HIVE_WIKI_PY%" solar_tech\Hive.Core.solar_tech.json
@REM "%IPY%" "%HIVE_WIKI_PY%" combustion\Hive.Core.combustion.json
"%IPY%" "%HIVE_WIKI_PY%" combustion\Hive.Core.combustion.json
"%IPY%" "%HIVE_WIKI_PY%" cooling\Hive.Core.cooling.json
"%IPY%" "%HIVE_WIKI_PY%" heatpumps\Hive.Core.heatpumps.json

Expand Down
4 changes: 2 additions & 2 deletions setup/hive.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ Section "Base Installation" Base_Installation_Section
File "..\src\Hive.Core\epw_reader\_build\Hive.Core.epw_reader.ghpy"
File "..\src\Hive.Core\sia380\_build\Hive.Core.sia380.ghpy"
File "..\src\Hive.Core\sia380\_build\Hive.Core.sia380.gha"
; File "..\src\Hive.Core\solar\_build\Hive.Core.solar.ghpy"
File "..\src\Hive.Core\solar\_build\Hive.Core.solar.ghpy"
File "..\src\Hive.Core\solar_tech\_build\Hive.Core.solar_tech.ghpy"
File "..\src\Hive.Core\solar_tech\_build\Hive.Core.solar_tech.gha"
; File "..\src\Hive.Core\combustion\_build\Hive.Core.combustion.ghpy"
File "..\src\Hive.Core\combustion\_build\Hive.Core.combustion.ghpy"
File "..\src\Hive.Core\cooling\_build\Hive.Core.cooling.ghpy"
File "..\src\Hive.Core\heatpumps\_build\Hive.Core.heatpumps.ghpy"

Expand Down
Binary file modified src/Hive.Core/solar_tech/simple_pv.gh
Binary file not shown.
94 changes: 94 additions & 0 deletions src/Hive.IO/Hive.IO/GhEnergySystems/GhASHPTimeResolved.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using Grasshopper.Kernel;
using System.Collections.Generic;
using System.Linq;

namespace Hive.IO.GhEnergySystems
{
public class GhASHPTimeResolved : GH_Component
{
//Calulating time resolved COP of Air-source heat pump and the electricity demand, given heating load

//Source: 10.1016/j.apenergy.2019.03.177 Eq. (A.7)

//COP_{HP,t} = pi_{HP,1} * exp[pi_{HP,2} * (T_supply - T_{amb,t}) +pi_{HP,3} * exp[pi_{HP,4} * (T_supply - T_{amb,t})]
//where T_supply is the supply temperature, T_{amb, t} is the ambient air temperature and pi_HP are parameters
//depending on the type of the HP.

//arguments:
// -pi_HP,1,2,3,4[-]
// - T_supply[°C]
// - T_amb,t[°C]
// - Q_th[kW]

//output:
//-x_el,t[kW]

public GhASHPTimeResolved() :
base("Air Source Heat Pump time resolved Energy System C#", "AshpTimeResolved",
"Calculates the time resolved Coefficient of Performance (COP) of an air source heat pump, as well as consumed electricity of the heat pump, to meet heating energy demand.",
"[hive]", "Energy Systems C#")
{
}

public override GH_Exposure Exposure => GH_Exposure.secondary;

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("Q_th", "Q_th", "Heating load, time resolved [kW]", GH_ParamAccess.list);
pManager.AddNumberParameter("T_supply", "T_supply", "Supply temperature of ASHP [°C]", GH_ParamAccess.item);
pManager.AddNumberParameter("T_amb,t", "T_amb,t", "Ambient air temperature, time resolved [°C]", GH_ParamAccess.list);
pManager.AddNumberParameter("PI_HP,1", "PI_1", "Technology parameter 1 for ASHP", GH_ParamAccess.item);
pManager.AddNumberParameter("PI_HP,2", "PI_2", "Technology parameter 2 for ASHP", GH_ParamAccess.item);
pManager.AddNumberParameter("PI_HP,3", "PI_3", "Technology parameter 3 for ASHP", GH_ParamAccess.item);
pManager.AddNumberParameter("PI_HP,4", "PI_4", "Technology parameter 4 for ASHP", GH_ParamAccess.item);
}

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("x_el", "x_el", "Electricity demand to fulfill heating load [kW]", GH_ParamAccess.list);
pManager.AddNumberParameter("COP", "COP", "COP of ASHP [-]", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
List<double> Q_th = new List<double>();
if (!DA.GetDataList(0, Q_th)) return;
double T_supply = 0.0;
if (!DA.GetData(1, ref T_supply)) return;
List<double> T_amb = new List<double>();
if (!DA.GetDataList(2, T_amb)) return;
double pi_1 = 0.0;
if (!DA.GetData(3, ref pi_1)) return;
double pi_2 = 0.0;
if (!DA.GetData(4, ref pi_2)) return;
double pi_3 = 0.0;
if (!DA.GetData(5, ref pi_3)) return;
double pi_4 = 0.0;
if (!DA.GetData(6, ref pi_4)) return;


var kelvin = 273.15;
var T_supply_kelvin = T_supply + kelvin;
var horizon = T_amb.Count < Q_th.Count ? T_amb.Count : Q_th.Count;

var x_el = new double[horizon];
var COP = new double[horizon];

foreach (var t in Enumerable.Range(0, horizon))
{
var T_amb_kelvin = T_amb[t] + kelvin;
COP[t] = pi_1 * Math.Exp(pi_2 * (T_supply_kelvin - T_amb_kelvin)) + pi_3 * Math.Exp(pi_4 * (T_supply_kelvin - T_amb_kelvin));
x_el[t] = Q_th[t] / COP[t];
}

DA.SetDataList(0, x_el);
DA.SetDataList(1, COP);

}

protected override System.Drawing.Bitmap Icon => Properties.Resources.EnergySystems_Heatpump_AirScource_TimeResult;

public override Guid ComponentGuid => new Guid("959a2b0b-c23d-4700-93af-b9301ce415b7");
}
}
7 changes: 3 additions & 4 deletions src/Hive.IO/Hive.IO/GhEnergySystems/GhBoilerSimple.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using System;
using Grasshopper.Kernel;

Expand All @@ -21,13 +20,13 @@ public class GhBoilerSimple : GH_Component
// - carbon emissions [kgCO2eq.]
/// </summary>
public GhBoilerSimple()
: base("Boiler Energy System", "BoilerSimple",
: base("Boiler Energy System C#", "BoilerSimple",
"Calculates total operating cost and carbon emissions of a boiler to meet heating loads.",
"[hive]", "Energy Systems")
"[hive]", "Energy Systems C#")
{
}

public override GH_Exposure Exposure => GH_Exposure.secondary;
public override GH_Exposure Exposure => GH_Exposure.primary;


protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
Expand Down
12 changes: 6 additions & 6 deletions src/Hive.IO/Hive.IO/GhEnergySystems/GhBoilerTimeResolved.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using System;
using System.Collections.Generic;
using Grasshopper.Kernel;
Expand All @@ -9,9 +8,9 @@ namespace Hive.IO.GhEnergySystems
public class GhBoilerTimeResolved : GH_Component
{
public GhBoilerTimeResolved()
: base("Boiler time resolved Energy System", "BoilerTimeResolved",
: base("Boiler time resolved Energy System C#", "BoilerTimeResolved",
"Calculates time resolved consumed fuel, operating cost and carbon emissions of a boiler to meet heating loads.",
"[hive]", "Energy Systems")
"[hive]", "Energy Systems C#")
{
}

Expand Down Expand Up @@ -51,16 +50,17 @@ protected override void SolveInstance(IGH_DataAccess DA)
var cost = new double[horizon];
var carbon = new double[horizon];
var gas_consumed = new double[horizon];

foreach (var t in Enumerable.Range(0, horizon))
{
gas_consumed[t] = heating_loads[t] * eta[t];
cost[t] = gas_consumed[t] * carrier_cost[t];
carbon[t] = gas_consumed[t] * carrier_emissions[t];
}

DA.SetData(0, gas_consumed);
DA.SetData(1, cost);
DA.SetData(2, carbon);
DA.SetDataList(0, gas_consumed);
DA.SetDataList(1, cost);
DA.SetDataList(2, carbon);
}


Expand Down
74 changes: 74 additions & 0 deletions src/Hive.IO/Hive.IO/GhEnergySystems/GhChillerSimple.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using Grasshopper.Kernel;

namespace Hive.IO.GhEnergySystems
{
public class GhChillerSimple : GH_Component
{
//
// Chiller (air con)
// Simple equation: electricity loads = cooling loads / COP
//
// arguments:
// - cooling loads [kWh]
// - COP [-]
// - electricity cost [CHF/kWh]
// - electricity emissions [kgCO2/kWh eq.]
//
// outputs:
// - electricity loads [kWh]
// - total cost [CHF]
// - total carbon [kgCO2]
//

public GhChillerSimple() :
base("Chiller Energy System C#", "ChillerSimple",
"Calculates total operating cost and carbon emissions of a chiller (split A/C) to meet cooling loads.",
"[hive]", "Energy Systems C#")
{
}

public override GH_Exposure Exposure => GH_Exposure.primary;

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("cooling_loads", "clg", "Cooling loads [kWh]", GH_ParamAccess.item);
pManager.AddNumberParameter("elec_cost", "cost", "Cost of electricity [CHF/kWh]", GH_ParamAccess.item);
pManager.AddNumberParameter("elec_emissions", "CO2", "Carbon emissions of electricity [kgCO2/kWheq.]", GH_ParamAccess.item);
pManager.AddNumberParameter("COP", "COP", "COP of chiller [-]", GH_ParamAccess.item);
}

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("elec", "elec", "Electricity loads from operating the chiller [kWh]", GH_ParamAccess.item);
pManager.AddNumberParameter("cost", "cost", "Total operation cost [CHF]", GH_ParamAccess.item);
pManager.AddNumberParameter("carbon", "carbon", "Total operation carbon emissions [kgCO2eq.]", GH_ParamAccess.item);
}

protected override void SolveInstance(IGH_DataAccess DA)
{

double cooling_loads = 0.0;
if (!DA.GetData(0, ref cooling_loads)) return;
double elec_cost = 0.0;
if (!DA.GetData(1, ref elec_cost)) return;
double elec_emissions = 0.0;
if (!DA.GetData(2, ref elec_emissions)) return;
double COP = 0.0;
if (!DA.GetData(3, ref COP)) return;

var elec_load = cooling_loads / COP;
var total_cost = elec_load * elec_cost;
var total_emissions = elec_load * elec_emissions;

DA.SetData(0, elec_load);
DA.SetData(1, total_cost);
DA.SetData(2, total_emissions);
}

protected override System.Drawing.Bitmap Icon => Properties.Resources.EnergySystems_Chiller_Simple;


public override Guid ComponentGuid => new Guid("442d18ba-ed3f-4f21-aa81-17b0fd331ec6");
}
}
97 changes: 97 additions & 0 deletions src/Hive.IO/Hive.IO/GhEnergySystems/GhChillerTimeResolved.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using Grasshopper.Kernel;
using System.Linq;

namespace Hive.IO.GhEnergySystems
{
public class GhChillerTimeResolved : GH_Component
{

//Chiller (air con), time resolved
//Eq. (A.8) from: 10.1016/j.apenergy.2019.03.177
//found in: 10.1016/j.energy.2004.08.004

//arguments:
// - cooling loads [kWh], time resolved
// - electricity cost [CHF/kWh], time resolved
// - electricity emissions [kgCO2/kWh eq.], time resolved
// - ambient temperature [°C], time resolved

//outputs (all time resolved):
// - electricity loads [kWh]
// - total cost [CHF]
// - total carbon [kgCO2]
// - COP of chiller [-]

public GhChillerTimeResolved() :
base("Chiller time resolved Energy System C#", "ChillerTimeResolved",
"Calculates time resolved operating cost and carbon emissions of a chiller (split A/C) to meet cooling loads.",
"[hive]", "Energy Systems C#")
{
}

public override GH_Exposure Exposure => GH_Exposure.secondary;

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("cooling_loads", "clg", "Cooling loads [kWh], time series", GH_ParamAccess.list);
pManager.AddNumberParameter("elec_cost", "cost", "Cost of electricity [CHF/kWh], time series", GH_ParamAccess.list);
pManager.AddNumberParameter("elec_emissions", "CO2", "Carbon emissions of electricity [kgCO2/kWh eq.], time series", GH_ParamAccess.list);
pManager.AddNumberParameter("temperature", "temp", "Ambient temperature at the inlet of the chiller [°C], time series", GH_ParamAccess.list);
}

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("elec", "elec", "Electricity loads from operating the chiller [kWh]", GH_ParamAccess.list);
pManager.AddNumberParameter("cost", "cost", "Total operation cost [CHF]", GH_ParamAccess.list);
pManager.AddNumberParameter("carbon", "carbon", "Total operation carbon emissions [kgCO2eq.]", GH_ParamAccess.list);
pManager.AddNumberParameter("COP", "COP", "Time resolved COP of the chiller [-]", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
List<double> cooling_loads = new List<double>();
if (!DA.GetDataList(0, cooling_loads)) return;
List<double> elec_cost = new List<double>();
if (!DA.GetDataList(1, elec_cost)) return;
List<double> elec_emissions = new List<double>();
if (!DA.GetDataList(2, elec_emissions)) return;
List<double> temperature = new List<double>();
if (!DA.GetDataList(3, temperature)) return;


// parameters from Eq. (A.8) in 10.1016/j.apenergy.2019.03.177
var ac_1 = 638.95;
var ac_2 = 4.238;
var ac_3 = 100.0;
var ac_4 = 3.534;

var horizon = new[] { cooling_loads.Count, elec_cost.Count, elec_emissions.Count, temperature.Count }.Min();

var elec_load = new double[horizon];
var total_cost = new double[horizon];
var total_emissions = new double[horizon];
var COP = new double[horizon];

foreach (var t in Enumerable.Range(0, horizon))
{
COP[t] = ((ac_1 - ac_2 * temperature[t]) / (ac_3 + ac_4 * temperature[t]));
elec_load[t] = cooling_loads[t] / COP[t];
total_cost[t] = elec_load[t] * elec_cost[t];
total_emissions[t] = elec_load[t] * elec_emissions[t];
}

DA.SetDataList(0, elec_load);
DA.SetDataList(1, total_cost);
DA.SetDataList(2, total_emissions);
DA.SetDataList(3, COP);
}

protected override System.Drawing.Bitmap Icon => Properties.Resources.EnergySystems_Chiller_TimeResult;

public override Guid ComponentGuid => new Guid("e6b97781-f103-41f2-b967-1254e8e9e220");
}
}


Loading