House Heating: Compare Energy Consumption

Introduction

This example compares power consumption for heating homes in different geographic locations. It also compares two different scenarios for heating control.

Explore the available scenarios by evaluating each cell in order. Evaluation is done by selecting a cell and pressing Shift+Enter.

In order to get the full experience of this example, you need the following:

Wolfram SystemModeler; a free trial download is available at www.wolfram.com/system-modeler

The model that came in the same bundle as this notebook

For more information about Wolfram SystemModeler, visit www.wolfram.com/system-modeler.

Initialize

Define the model name:

mmodel="IndustryExamples.Energy.HouseHeating.HouseHeatingScenario";

Compare Locations

Compare the temperatures inside and outside houses located in Arizona and Illinois, USA.

Get Weather Data

Get weather data to use in the simulation from built-in data paclets:

tempsIL=WeatherData["Champaign","Temperature",{{2014,01,23}},TimeZone->-6]["Path"];

tempsAZ=WeatherData["Sun Lakes","Temperature",{{2014,01,23}},TimeZone->-7]["Path"];

Convert the data from a date format into seconds since start of measurement:

normlizeTime[tempData_]:=Transpose[{Part[tempData,All,1]-Part[tempData,1,1],QuantityMagnitude[Part[tempData,All,2],"DegreesCelsius"]}];

tempsILinSeconds=normlizeTime[tempsIL];

tempsAZinSeconds=normlizeTime[tempsAZ];

Verify the data:

ListPlot[{tempsILinSeconds,tempsAZinSeconds},Joined->True,AxesLabel->{"s","°C"}]

Export the data to tables to be read by the simulation:

temperatureModel=SystemModel[mmodel,<|"ParameterValues"-> {"outsideTemperature.AZTemperature.table"-> tempsAZinSeconds,"outsideTemperature.ILTemperature.table"-> tempsILinSeconds}|>];

Simulate

Define some options used in the plots:

heaterOnBackground={LightGray,Rectangle[{18000,-50},{32400,50}],Rectangle[{61200,-50},{82800,50}]};

hourMarks={Table[{s 3600,s},{s,0,24,2}],Automatic};

Simulate for Illinois (IL) and Arizona (AZ). Set the number of interpolation points lower for faster simulation:

simIL=SystemModelSimulate[temperatureModel,{0,86400}];

simAZ=SystemModelSimulate[temperatureModel,{0,54000},<|"ParameterValues"->{"locationSwitch"->True}|>];

Inside and outside temperatures in Champaign, IL during a day in January. The gray background indicates the time when the heating is on:

SystemModelPlot[simIL,{"averageTemperature1.y","outsideTemperature.y","thermostat.reference.k"},Prolog->heaterOnBackground,AxesLabel->{"Time","C"},Ticks->hourMarks,TargetUnits->{"Sec",Automatic}]

Inside and outside temperatures in Sun Lakes, AZ during a day in January:

SystemModelPlot[simAZ,{"averageTemperature1.y","outsideTemperature.y","thermostat.reference.k"},AxesLabel->{"Time","C"},Ticks->hourMarks,Prolog->heaterOnBackground,TargetUnits->{"Sec",Automatic}]

Electricity Usage and Cost

Prepare

Get the cost for electricity for a given day, for both Illinois and Arizona:

{costIL,costAZ}=WolframAlpha["Electricity cost Jan 23, 2011 Illinois, Arizona",{{"Result",1},"NumberData"}]/100

Radiator power output is set in the model:

QuantityVariable["radiatorPower","Power"]

powerPerRadiator=(QuantityVariable["radiatorPower", "Power"])/.Quiet[SystemModel[temperatureModel,"ParameterValues"] ]

Define a range of temperatures to simulate over:

temperatures=Range[19,24];

A function for computing the power used. It computes the power used by four radiators, when the radiators are switched on, and converts it to kWh:

powerUsed[simulation_]:=4 powerPerRadiator NIntegrate[Map[Boole,Through[simulation["timerCircuit.radiatorOn",t]]],{t,0,86400}]/3600/1000;

Simulate

Simulate over a range of temperatures, with the heating on all day, in Illinois:

simPowerAllDayIL=SystemModelSimulate[mmodel,{0,86400},<|"ParameterValues"->{"heatAllDay"->True,"thermostat.reference.k"->temperatures}|>];

Simulate with heating on only when someone is home:

simPowerWhenHomeIL=SystemModelSimulate[mmodel,{0,86400},<|"ParameterValues"->{"heatAllDay"->False,"thermostat.reference.k"->temperatures}|>];

Simulate the same scenarios in Arizona:

simPowerAllDayAZ=SystemModelSimulate[mmodel,{0,54000},<|"ParameterValues"->{"heatAllDay"->True,"thermostat.reference.k"->temperatures,"locationSwitch"->True}|>];

simPowerWhenHomeAZ=SystemModelSimulate[mmodel,{0,54000},<|"ParameterValues"->{"heatAllDay"->False,"thermostat.reference.k"->temperatures,"locationSwitch"->True}|>];

Calculate the power used for all the scenarios:

plotData[IL,power,allDay]=powerUsed[simPowerAllDayIL];
plotData[IL,power,whenHome]=powerUsed[simPowerWhenHomeIL];
plotData[AZ,power,allDay]=powerUsed[simPowerAllDayAZ];
plotData[AZ,power,whenHome]=powerUsed[simPowerWhenHomeAZ];

Calculate the cost for all the scenarios:

plotData[IL,cost,allDay]=plotData[IL,power,allDay]×costIL;
plotData[IL,cost,whenHome]=plotData[IL,power,whenHome]×costIL;
plotData[AZ,cost,allDay]=plotData[AZ,power,allDay]×costAZ;
plotData[AZ,cost,whenHome]=plotData[AZ,power,whenHome]×costAZ;

Analyze

Create an interactive interface to explore different scenarios. The x axis shows thermostat temperatures, and the two curves show Illinois and Arizona:

Manipulate[
ListPlot[{Tooltip[Transpose[{temperatures,plotData[IL,show,switch]}],IL],Tooltip[Transpose[{temperatures,plotData[AZ,show,switch]}],AZ]},Filling->Axis,Joined->True,PlotMarkers->Automatic,AxesLabel->{"C",Switch[show,power,"Watt",cost,"USD"]},PlotRange->{0,Switch[show,power,17,cost,1.8]}]
,{{show,cost,"calculate:"},{cost,power}},{{switch,allDay,"heating on:"},{allDay->"all day",whenHome->"when home"}},SaveDefinitions->True]

Retrieve the temperature curves for all the scenarios:

Do[
temperaturePlotData[IL,whenHome,t]=simPowerWhenHomeIL[[t-18]][{"averageTemperature1.y","outsideTemperature.y","thermostat.reference.k"},\[FormalT]];
temperaturePlotData[AZ,whenHome,t]=simPowerWhenHomeAZ[[t-18]][{"averageTemperature1.y","outsideTemperature.y","thermostat.reference.k"},\[FormalT]];
temperaturePlotData[IL,allDay,t]=simPowerAllDayIL[[t-18]][{"averageTemperature1.y","outsideTemperature.y","thermostat.reference.k"},\[FormalT]];
temperaturePlotData[AZ,allDay,t]=simPowerAllDayAZ[[t-18]][{"averageTemperature1.y","outsideTemperature.y","thermostat.reference.k"},\[FormalT]];
,{t,temperatures}]

Show the temperature variations over the day for a selected simulation:

Manipulate[Plot[Evaluate[temperaturePlotData[state,heating,temp]/.\[FormalT]->t],{t,0,If[state===AZ,54000,86400]},AxesLabel->{"Time","C"},Ticks->hourMarks],{{state,AZ,"state:"},{IL->"Illinois",AZ->"Arizona"}},{{heating,whenHome,"heating on:"},{allDay->"all day",whenHome->"when home"}},{{temp,19,"thermostat temperature:"},temperatures,SetterBar},SaveDefinitions->True]

Terms and Conditions of Use

This domain example is an informational resource made freely available by Wolfram Research.

Use of This Example

• You may not use this example for any purpose that is unlawful or dangerous.
• You assume total responsibility and risk for your use of this example.
• You may not present this example with any alteration to its trade dress, trademarks, or design.

License

All content in this bundle is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. By accessing the content or using it in any way, you accept and agree to be bound by the terms of this license. If you do not agree to these Terms of Use, you may not use this content. Wolfram Research reserves the right to change, modify, add to, or remove portions of these Terms of Use at any time without notice. Please refer back to www.wolfram.com for the latest Terms of Use.

A summary of the licensing terms can be found at:
http://creativecommons.org/licenses/by-nc-sa/3.0

The full legal code can be found at: 
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode