# Energy balance in Stuttgart

## Question

What are the amounts of energy produced, consumed, imported, and exported in Stuttgart?

 ``` ## This code was tun from page [[Energy balance in Stuttgart#Answer]] library(OpasnetUtils) library(ggplot2) N <- 10 objects.latest("Op_en5141", code_name = "initiate") balance <- Ovariable("balance", ddata = "Op_en5815.equations") nonlinearity <- Ovariable("nonlinearity", ddata = "Op_en5141", subset = "No nonlinearities") directinput <- Ovariable("directinput", ddata = "Op_en5141", subset = "No modelled upstream variables") energy.balance <- EvalOutput(energy.balance) oprint(summary(energy.balance)) ggplot(energy.balance@output, aes_string(x = "energybalanceVars", y = "energy.balanceResult")) + #, fill = "Year")) + geom_boxplot() + facet_wrap(~Year, ncol = 1) + theme_grey(base_size = 24) + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust= 0.2)) ```

## Rationale

There are several energy transformations that each describe a specific process of energy production or use. Per unit activity, there is a constant amount of different inputs and outputs into and from this process, respectively. These unit processes are used for Stuttgart in such a way that one critical input or output from each relevant energy transformation is listed here; all other inputs and outputs logically follow from the nature of the transformation process.

### Data

Equations(GWh /a?)
ObsYearEquationDummyDescription
12008STP renewable energy + STP electricity = STP local heating1Balance Solar Thermal Pump. In energy balance, inputs and outputs cancel out
22008STP electricity = 0.363636364*STP renewable energy1Fraction STP renewable energy. Amount of electricity is used as comparison for renewable energy. 8/22 Electricity divided by renewable energy
32008CHP gas + CHP renewable energy + CHP mineral oil = CHP local heating + CHP electricity + CHP loss1Balance CHP Plants. In energy balance, inputs and outputs cancel out
42008CHP renewable energy + CHP mineral oil = 0.564814815*CHP gas1Fraction CHP gas. Sum of other fuels is used as comparison for gas. (108+14)/216 Others divided by gas
52008CHP gas + CHP mineral oil = 2.12962963*CHP renewable energy1Sum of other fuels is used as comparison for renewable energy. Fraction CHP renewable energy. (216+14)/108 Others divided by renewable energy
62008CHP electricity + CHP loss = 1.770491803*CHP local heating1Fraction CHP local heating. Sum of other outputs is used as comparison for local heating. (84+132)/122 Others divided by local heating.
72008CHP local heating + CHP loss = 3.023809524*CHP electricity1Fraction CHP electricity. Sum of other outputs is used as comparison for electricity. (122+132)/84 Others divided by electricity
82008WWP renewable energy = WWP electricity1Balance Water, Wind, Photovlotaics. In energy balance, inputs and outputs cancel out
92008TPP electricity input + TPP mineral oil + TPP gas = TPP local heating + TPP electricity output + TPP loss1Balance Thermal Power Plant Pfaffenwald. In energy balance, inputs and outputs cancel out
102008TPP mineral oil + TPP gas = 23.33333333*TPP electricity input1Fraction TPP electricity input. Sum of other fuels is used as comparison for electricity input. (43+167)/9 Others divided by electricity input
112008TPP electricity input + TPP gas = 4.093023256*TPP mineral oil1Fraction TPP mineral oil. Sum of other fuels is used as comparison for mineral oil. (9+167)/43 Others divided by mineral oil
122008TPP electricity output + TPP loss = 0.335365854*TPP local heating1Fraction TPP local heating. Sum of other outputs is used as comparison for local heating. (50+5)/164 Others divided by local heating
132008TPP local heating +TPP loss = 3.38*TPP electricity output1Fraction TPP electricity output. Sum of other outputs is used as comparison for electricity. (164+5)/50 Others divided by electricity
142008TPE waste + TPE gas + TPE coal + TPE mineral oil = TPE electricity + TPE district heating + TPE loss1Balance Thermal Power Plant EVU. In energy balance, inputs and outputs cancel out
152008TPE gas + TPE coal + TPE mineral oil = 1.04973357*TPE waste1Fraction TPE waste. Sum of other fuels is used as comparison for waste. (162+1019+1)/1126 Others divided by waste
162008TPE waste + TPE coal + TPE mineral oil = 13.24691358*TPE gas1Fraction TPE gas. Sum of other fuels is used as comparison for gas. (1126+1019+1)/162 Others divided by gas
172008TPE waste + TPE gas + TPE mineral oil = 1.264965653*TPE coal1Fraction TPE coal. Sum of other fuels is used as comparison for coal. (1126+162+1)/1019 Others divided by coal
182008TPE district heating + TPE loss = 5.089709763*TPE electricity1Fraction TPE electricity. Sum of other outputs is used as comparison for electricity. (1101+828)/379 Others divided by electricity
192008TPE electricity + TPE loss = 1.096276113*TPE district heating1Fraction TPE district heating. Sum of other outputs is used as comparison for district heating. (379 +828)/1101 Others divided by district heating
202008Ind gas = Ind electricity + Ind loss1Balance Industrial Plants. In energy balance, inputs and outputs cancel out
212008Ind electricity = 0.533333333*Ind loss1Fraction Ind loss. Amount of district heating is used as comparison for loss. 8/15 district heating per loss
222008STP local heating = 0.245901639*CHP local heating1Fraction local heating producers. CHP local heating production is used as reference. 30/122 STP local heating divided by CHP local heating
232008Ind electricity = 0.007266122*CHP electricity1Fraction electricity producers 1. 8/1101 Ind electricity divided by TPE district heating CORRECTED
242008WWP electricity = 0.797619048*CHP electricity1Fraction electricity producers 2. CHP electricity production is used as reference. 67/84 WWP electricity divided by CHP electricity
252008TPP electricity output = 0.595238095*CHP electricity1Fraction electricity producers 3. CHP electricity production is used as reference. 50/84 TPP electricity divided by CHP electricity
262008TPE electricity = 4.511904762*CHP electricity1Fraction electricity producers 4. CHP electricity production is used as reference. 379/84 TPE electricity divided by CHP electricity
272008Loss local heating = 0.041139241*STP local heating + 0.041139241*CHP local heating + 0.041139241*TPP local heating1Transmission loss local heating. Known loss divided by production. 13/(30+122+164)
282008Loss electricity = 0.221088435*CHP electricity + 0.221088435*WWP electricity + 0.221088435*TPP electricity output + 0.221088435*TPE electricity + 0.221088435*Ind electricity1Transmission loss electricity. Known loss divided by production. 130/(84+67+50+379+8)
292008Loss district heating = 0.109900091*TPE district heating1Transmission loss district heating. Known loss divided by production. 121/1101
302008CES local heating = 0.366666667*STP local heating1Consumption in the Energy Sector local heating. STP local heating is used as reference. 11/30
312008CES electricity = 1.392857143*CHP electricity1Consumption in the Energy Sector electricity. CHP electricity is used as reference. 117/84
322008V renewable energy = 0.272727273*STP renewable energy1Vorketten renewable energy. STP renewable energy is used as reference. 6/22
332008V coal = 0.103042198*TPE coal1Vorketten coal. TPE coal is used as reference. 105/1019
342008V electricity = 17.79683377*TPE electricity1Vorketten electricity. TPE electricity is used as reference. 6745/379
352008V gas = 2.027777778*CHP gas1Vorketten gas. CHP gas is used as reference. 438/216
362008V mineral oil = 12.3255814*TPP mineral oil1Vorketten mineral oil. TPP mineral oil is used as reference. 530/43
372008Bought electricity + CHP electricity + WWP electricity + TPP electricity output + TPE electricity + Ind electricity = STP electricity + TPP electricity input + Loss electricity + CES electricity + V electricity + Cons Ind electricity + Cons Traffic electricity + Cons Home electricity + Cons Commerce electricity1Electricity use balance. In energy balance, inputs and outputs cancel out
382008STP local heating + CHP local heating + TPP local heating = Loss local heating + CES local heating + Cons Ind local heating + Cons Home local heating + Cons Commerce local heating1Local heating balance. In energy balance, inputs and outputs cancel out
392008Bought district heating + TPE district heating = Loss district heating + Cons Ind district heating + Cons Home district heating + Cons Commerce district heating1District heating balance. In energy balance, inputs and outputs cancel out
402008Cons Ind electricity = 22571Consumed electricity industry
412008Cons Traffic electricity = 2241Consumed electricity traffic
422008Cons Home electricity = 10771Consumed electricity households
432008Cons Commerce electricity = 6951Consumed electricity commerce
442008Cons Ind local heating = 351Consumed local heating industry
452008Cons Home local heating = 541Consumed local heating households
462008Cons Commerce local heating = 2031Consumed local heating commerce
472008Cons Ind district heating = 5131Consumed districit heating industry
482008Cons Home district heating = 351Consumed districit heating households
492008Cons Commerce district heating = 8511Consumed districit heating commerce
502010STP renewable energy + STP electricity = STP local heating1Balance Solar Thermal Pump. In energy balance, inputs and outputs cancel out
512010STP electricity = 0.352941176*STP renewable energy1Fraction STP renewable energy. Amount of electricity is used as comparison for renewable energy. 12/34 Electricity divided by renewable energy
522010CHP gas + CHP renewable energy + CHP mineral oil = CHP local heating + CHP electricity + CHP loss1Balance CHP Plants. In energy balance, inputs and outputs cancel out
532010CHP renewable energy + CHP mineral oil = 3.848484848*CHP gas1Fraction CHP gas. Sum of other fuels is used as comparison for gas. (116+11)/33 Others divided by gas
542010CHP gas + CHP mineral oil = 0.379310344*CHP renewable energy1Sum of other fuels is used as comparison for renewable energy. Fraction CHP renewable energy. (33+11)/116 Others divided by renewable energy
552010CHP electricity + CHP loss = 3.324324324*CHP local heating1Fraction CHP local heating. Sum of other outputs is used as comparison for local heating. (27+96)/37 Others divided by local heating.
562010CHP local heating + CHP loss = 4.925925925*CHP electricity1Fraction CHP electricity. Sum of other outputs is used as comparison for electricity. (37+96)/27 Others divided by electricity
572010WWP renewable energy = WWP electricity1Balance Water, Wind, Photovlotaics. In energy balance, inputs and outputs cancel out
582010TPP electricity input + TPP mineral oil + TPP gas = TPP local heating + TPP electricity output + TPP loss1Balance Thermal Power Plant Pfaffenwald. In energy balance, inputs and outputs cancel out
592010TPP mineral oil + TPP gas = 26*TPP electricity input1Fraction TPP electricity input. Sum of other fuels is used as comparison for electricity input. (17+217)/9 Others divided by electricity input
602010TPP electricity input + TPP gas = 13.294117647*TPP mineral oil1Fraction TPP mineral oil. Sum of other fuels is used as comparison for mineral oil. (9+217)/17 Others divided by mineral oil
612010TPP electricity output + TPP loss = 0.380681818*TPP local heating1Fraction TPP local heating. Sum of other outputs is used as comparison for local heating. (61+6)/176 Others divided by local heating
622010TPP local heating +TPP loss = 2.983606557*TPP electricity output1Fraction TPP electricity output. Sum of other outputs is used as comparison for electricity. (176+6)/61 Others divided by electricity
632010TPE waste + TPE gas + TPE coal + TPE mineral oil = TPE electricity + TPE district heating + TPE loss1Balance Thermal Power Plant EVU. In energy balance, inputs and outputs cancel out
642010TPE gas + TPE coal + TPE mineral oil = 0.929245283*TPE waste1Fraction TPE waste. Sum of other fuels is used as comparison for waste. (162+1019+1)/1272 Others divided by waste
652010TPE waste + TPE coal + TPE mineral oil = 14.148148148*TPE gas1Fraction TPE gas. Sum of other fuels is used as comparison for gas. (1272+1019+1)/162 Others divided by gas
662010TPE waste + TPE gas + TPE mineral oil = 1.408243376*TPE coal1Fraction TPE coal. Sum of other fuels is used as comparison for coal. (1272+162+1)/1019 Others divided by coal
672010TPE district heating + TPE loss = 5.104477612*TPE electricity1Fraction TPE electricity. Sum of other outputs is used as comparison for electricity. (1171+881)/402 Others divided by electricity
682010TPE electricity + TPE loss = 1.095644748*TPE district heating1Fraction TPE district heating. Sum of other outputs is used as comparison for district heating. (402+881)/1171 Others divided by district heating
692010Ind gas = Ind electricity + Ind loss1Balance Industrial Plants. In energy balance, inputs and outputs cancel out
702010Ind electricity = 0.533333333*Ind loss1Fraction Ind loss. Amount of district heating is used as comparison for loss. 8/15 district heating per loss
712010STP local heating = 1.243243243*CHP local heating1Fraction local heating producers. CHP local heating production is used as reference. 46/37 STP local heating divided by CHP local heating
722010Ind electricity = 0.006831768*CHP electricity1Fraction electricity producers 1. 8/1171 Ind electricity divided by TPE district heating VﾄﾄRIN 2008 sivulla??
732010WWP electricity = 1.925925925*CHP electricity1Fraction electricity producers 2. CHP electricity production is used as reference. 52/27 WWP electricity divided by CHP electricity
742010TPP electricity output = 2.259259259*CHP electricity1Fraction electricity producers 3. CHP electricity production is used as reference. 61/27 TPP electricity divided by CHP electricity
752010TPE electricity = 14.888888888*CHP electricity1Fraction electricity producers 4. CHP electricity production is used as reference. 402/27 TPE electricity divided by CHP electricity
762010Loss local heating = 0.057915058*STP local heating + 0.057915058*CHP local heating + 0.057915058*TPP local heating1Transmission loss local heating. Known loss divided by production. 15/(46+37+176)
772010Loss electricity = 0.22*CHP electricity + 0.22*WWP electricity + 0.22*TPP electricity output + 0.22*TPE electricity + 0.22*Ind electricity1Transmission loss electricity. Known loss divided by production. 121/(27+52+61+402+8)
782010Loss district heating = 0.102476516*TPE district heating1Transmission loss district heating. Known loss divided by production. 120/1171
792010CES local heating = 0.217391304*STP local heating1Consumption in the Energy Sector local heating. STP local heating is used as reference. 10/46
802010CES electricity = 4.259259259*CHP electricity1Consumption in the Energy Sector electricity. CHP electricity is used as reference. 115/27
812010V renewable energy = 0.235294118*STP renewable energy1Vorketten renewable energy. STP renewable energy is used as reference. 8/34
822010V coal = 0.103042198*TPE coal1Vorketten coal. TPE coal is used as reference. 105/1019
832010V electricity = 14.425373134*TPE electricity1Vorketten electricity. TPE electricity is used as reference. 5799/402
842010V gas = 14.181818181*CHP gas1Vorketten gas. CHP gas is used as reference. 468/33
852010V mineral oil = 31.352941176*TPP mineral oil1Vorketten mineral oil. TPP mineral oil is used as reference. 533/17
862010Bought electricity + CHP electricity + WWP electricity + TPP electricity output + TPE electricity + Ind electricity = STP electricity + TPP electricity input + Loss electricity + CES electricity + V electricity + Cons Ind electricity + Cons Traffic electricity + Cons Home electricity + Cons Commerce electricity1Electricity use balance. In energy balance, inputs and outputs cancel out
872010STP local heating + CHP local heating + TPP local heating = Loss local heating + CES local heating + Cons Ind local heating + Cons Home local heating + Cons Commerce local heating1Local heating balance. In energy balance, inputs and outputs cancel out
882010Bought district heating + TPE district heating = Loss district heating + Cons Ind district heating + Cons Home district heating + Cons Commerce district heating1District heating balance. In energy balance, inputs and outputs cancel out
892010Cons Ind electricity = 23901Consumed electricity industry
902010Cons Traffic electricity = 2251Consumed electricity traffic
912010Cons Home electricity = 10471Consumed electricity households
922010Cons Commerce electricity = 4981Consumed electricity commerce
932010Cons Ind local heating = 61Consumed local heating industry
942010Cons Home local heating = 341Consumed local heating households
952010Cons Commerce local heating = 1941Consumed local heating commerce
962010Cons Ind district heating = 3941Consumed districit heating industry
972010Cons Home district heating = 731Consumed districit heating households
982010Cons Commerce district heating = 9271Consumed districit heating commerce
992025STP renewable energy + STP electricity = STP local heating1Balance Solar Thermal Pump. In energy balance, inputs and outputs cancel out
1002025STP electricity = 0.352941176*STP renewable energy1Fraction STP renewable energy. Amount of electricity is used as comparison for renewable energy. 12/34 Electricity divided by renewable energy
1012025CHP gas + CHP renewable energy + CHP mineral oil = CHP local heating + CHP electricity + CHP loss1Balance CHP Plants. In energy balance, inputs and outputs cancel out
1022025CHP renewable energy + CHP mineral oil = 3.848484848*CHP gas1Fraction CHP gas. Sum of other fuels is used as comparison for gas. (116+11)/33 Others divided by gas
1032025CHP gas + CHP mineral oil = 0.379310344*CHP renewable energy1Sum of other fuels is used as comparison for renewable energy. Fraction CHP renewable energy. (33+11)/116 Others divided by renewable energy
1042025CHP electricity + CHP loss = 3.324324324*CHP local heating1Fraction CHP local heating. Sum of other outputs is used as comparison for local heating. (27+96)/37 Others divided by local heating.
1052025CHP local heating + CHP loss = 4.925925925*CHP electricity1Fraction CHP electricity. Sum of other outputs is used as comparison for electricity. (37+96)/27 Others divided by electricity
1062025WWP renewable energy = WWP electricity1Balance Water, Wind, Photovlotaics. In energy balance, inputs and outputs cancel out
1072025TPP electricity input + TPP mineral oil + TPP gas = TPP local heating + TPP electricity output + TPP loss1Balance Thermal Power Plant Pfaffenwald. In energy balance, inputs and outputs cancel out
1082025TPP mineral oil + TPP gas = 26*TPP electricity input1Fraction TPP electricity input. Sum of other fuels is used as comparison for electricity input. (17+217)/9 Others divided by electricity input
1092025TPP electricity input + TPP gas = 13.294117647*TPP mineral oil1Fraction TPP mineral oil. Sum of other fuels is used as comparison for mineral oil. (9+217)/17 Others divided by mineral oil
1102025TPP electricity output + TPP loss = 0.380681818*TPP local heating1Fraction TPP local heating. Sum of other outputs is used as comparison for local heating. (61+6)/176 Others divided by local heating
1112025TPP local heating +TPP loss = 2.983606557*TPP electricity output1Fraction TPP electricity output. Sum of other outputs is used as comparison for electricity. (176+6)/61 Others divided by electricity
1122025TPE waste + TPE gas + TPE coal + TPE mineral oil = TPE electricity + TPE district heating + TPE loss1Balance Thermal Power Plant EVU. In energy balance, inputs and outputs cancel out
1132025TPE gas + TPE coal + TPE mineral oil = 0.929245283*TPE waste1Fraction TPE waste. Sum of other fuels is used as comparison for waste. (162+1019+1)/1272 Others divided by waste
1142025TPE waste + TPE coal + TPE mineral oil = 14.148148148*TPE gas1Fraction TPE gas. Sum of other fuels is used as comparison for gas. (1272+1019+1)/162 Others divided by gas
1152025TPE waste + TPE gas + TPE mineral oil = 1.408243376*TPE coal1Fraction TPE coal. Sum of other fuels is used as comparison for coal. (1272+162+1)/1019 Others divided by coal
1162025TPE district heating + TPE loss = 5.104477612*TPE electricity1Fraction TPE electricity. Sum of other outputs is used as comparison for electricity. (1171+881)/402 Others divided by electricity
1172025TPE electricity + TPE loss = 1.095644748*TPE district heating1Fraction TPE district heating. Sum of other outputs is used as comparison for district heating. (402+881)/1171 Others divided by district heating
1182025Ind gas = Ind electricity + Ind loss1Balance Industrial Plants. In energy balance, inputs and outputs cancel out
1192025Ind electricity = 0.533333333*Ind loss1Fraction Ind loss. Amount of district heating is used as comparison for loss. 8/15 district heating per loss
1202025STP local heating = 1.243243243*CHP local heating1Fraction local heating producers. CHP local heating production is used as reference. 46/37 STP local heating divided by CHP local heating
1212025Ind electricity = 0.006831768*CHP electricity1Fraction electricity producers 1. 8/1171 Ind electricity divided by TPE district heating VﾄﾄRIN 2008 sivulla??
1222025WWP electricity = 1.925925925*CHP electricity1Fraction electricity producers 2. CHP electricity production is used as reference. 52/27 WWP electricity divided by CHP electricity
1232025TPP electricity output = 2.259259259*CHP electricity1Fraction electricity producers 3. CHP electricity production is used as reference. 61/27 TPP electricity divided by CHP electricity
1242025TPE electricity = 14.888888888*CHP electricity1Fraction electricity producers 4. CHP electricity production is used as reference. 402/27 TPE electricity divided by CHP electricity
1252025Loss local heating = 0.057915058*STP local heating + 0.057915058*CHP local heating + 0.057915058*TPP local heating1Transmission loss local heating. Known loss divided by production. 15/(46+37+176)
1262025Loss electricity = 0.22*CHP electricity + 0.22*WWP electricity + 0.22*TPP electricity output + 0.22*TPE electricity + 0.22*Ind electricity1Transmission loss electricity. Known loss divided by production. 121/(27+52+61+402+8)
1272025Loss district heating = 0.102476516*TPE district heating1Transmission loss district heating. Known loss divided by production. 120/1171
1282025CES local heating = 0.217391304*STP local heating1Consumption in the Energy Sector local heating. STP local heating is used as reference. 10/46
1292025CES electricity = 4.259259259*CHP electricity1Consumption in the Energy Sector electricity. CHP electricity is used as reference. 115/27
1302025V renewable energy = 0.235294118*STP renewable energy1Vorketten renewable energy. STP renewable energy is used as reference. 8/34
1312025V coal = 0.161923454*TPE coal1Vorketten coal. TPE coal is used as reference. 165/1019
1322025V electricity = 14.425373134*TPE electricity1Vorketten electricity. TPE electricity is used as reference. 5799/402
1332025V gas = 14.181818181*CHP gas1Vorketten gas. CHP gas is used as reference. 468/33
1342025V mineral oil = 31.352941176*TPP mineral oil1Vorketten mineral oil. TPP mineral oil is used as reference. 533/17
1352025Bought electricity + CHP electricity + WWP electricity + TPP electricity output + TPE electricity + Ind electricity = STP electricity + TPP electricity input + Loss electricity + CES electricity + V electricity + Cons Ind electricity + Cons Traffic electricity + Cons Home electricity + Cons Commerce electricity1Electricity use balance. In energy balance, inputs and outputs cancel out
1362025STP local heating + CHP local heating + TPP local heating = Loss local heating + CES local heating + Cons Ind local heating + Cons Home local heating + Cons Commerce local heating1Local heating balance. In energy balance, inputs and outputs cancel out
1372025Bought district heating + TPE district heating = Loss district heating + Cons Ind district heating + Cons Home district heating + Cons Commerce district heating1District heating balance. In energy balance, inputs and outputs cancel out
1382025Cons Ind electricity = 24991Consumed electricity industry
1392025Cons Traffic electricity = 2681Consumed electricity traffic
1402025Cons Home electricity = 11371Consumed electricity households
1412025Cons Commerce electricity = 4851Consumed electricity commerce
1422025Cons Ind local heating = 61Consumed local heating industry
1432025Cons Home local heating = 381Consumed local heating households
1442025Cons Commerce local heating = 1621Consumed local heating commerce
1452025Cons Ind district heating = 4001Consumed districit heating industry
1462025Cons Home district heating = 741Consumed districit heating households
1472025Cons Commerce district heating = 9411Consumed districit heating commerce

There are no nonlinearities.