Talk:Energy balance

From Opasnet
Jump to: navigation, search

New way to parameterise

Question
How should we parameterise a linear equation group in such a way that it is intuitive for the user? The equation group has a form A x = B, where A is a square matrix of parameters, x is a horizontal vector of variables and B is a vertical vector of constants.
Answer

The basic idea is to make a table where the equations are given as rows and variables (V1, V2, V3, ...) and parameters (P1, P2, P3, ...) for the variables are given as subsequent pairs in columns. This is more intuitive than giving one variable-parameter pair per row, as one equation then takes several rows. The structure of a table is given below. The index for parameters and variables is Observation.

Energy balance table (based on OECD structure) and energy balance matrix are linked in the following way. Each cell in an energy balance table is an unknown variable and therefore a column in an energy balance matrix. They are named "Column in Row" (e.g. "Electricity in Electricity plants" or "Petrochem products in Agriculture & Fishery") based on the Energy balance table.

Indices

Indices are given as extra columns in energy balance tables before parameters and variables. There are two kinds of indices in an energy balance model. First, some indices apply to the whole matrix, such as Year, City, Iter etc. These are called global indices.

There is a specific kind of global index. It defines an equation that is only valid for particular values of a particular variable. For example, there may be an equation for a power plant where demand = production. This is only valid for demand <= 80, as the maximum capacity of this power plant is 80 MW. For values demand > 80, there is an equation: production = 80. Because we don't know the value of the demand before we have solved the matrix, we will create two matrices, one with either equation, solve both, and reject the one where the demand is outside the domain of the equation. If the alternative equations form a function that is piecewise linear and continuous, there should always be exactly one solutions that is within the domain of the equation (I haven't proven this, though).

Second, some indices, called partial indices, are treated in a way that the location name (e.g. fuel) is put in front of the variable name. In this way, it is possible to use a single row to define the same equation for e.g. each fuel. The trick is that the list of fuels is given once, and it is applied to all such equations in a table that do not have s specified fuel.

The different indices are given in the same way as columns of an energy balance table. The code treats the indices in different ways, and therefore which index is which kind is given to the computer separately. (See an example table below.)

  • GlobalIndex <- c("Year"). A global index for different scenarios.
  • ConditionIndex <- c("HaapaniemiDemand"). A global index that is used in defining the domain for equations and after solution to check which solution is within the domain.
  • PartialIndex <- c("Building"). A partial index. Partial indices are not needed if all equations are written down for all locations.

How to develop a matrix from an energy balance table?

These equations are needed:

  • For each fuel, variable Total.supply is needed. It is calculated as the sum of all individual supplies.
  • For each fuel, variable Total.available is needed. It is Total.supply + sum of all individual transform processes.
  • For each fuel, Total.available is also a sum of all individual end use processes.
  • For Heat plants, there is a transformation of fuels into Heat, and energy efficiency * input = output, where output is the usable Heat produced.
    • The same applies to CHP plants and Heat, CHP plants and Electricity, and Electricity plants and Electricity.
    • There is a need for separate equations for appliances pre-2007 and post-2007, if the energy efficiencies have improved. These are given as partial indices.
  • Some system transformations (such as Statistical differences, Coal transformation, Other transformation, Own use, Distribution losses) are relative to the activity. Therefore, for each fuel, two equations are needed:
    1. Total.supply = P1 * Total.supply.increase, where P1 is the total supply baseline (given as a constant from the energy balance table and Total.supply.increase is the relative increase.
    2. Eg. Statistical differences = P1 * Total.supply.increase, where P1 is the baseline value from the energy balance table.
  • The fractions of fuels used are given as separate equations. These are case-specific values and they are given in a separate table.

Table with basic equations for each fuel. These equations tell how different activities relate to each other. These are generic and same for all cases.

Basic equations(-)
ObsActivityP1V1P2V2P3V3P4V4P5V5P6V6Equation
1Coal & peat-1Total available1Total supply1Total transfers
2Crude oil-1Total available1Total supply1Total transfers
3Petrochem products-1Total available1Total supply1Total transfers
4Gas-1Total available1Total supply1Total transfers
5Nuclear-1Total available1Total supply1Total transfers
6Hydro-1Total available1Total supply1Total transfers
7Geo & solar & wind-1Total available1Total supply1Total transfers
8Renew & waste-1Total available1Total supply1Total transfers
9Electricity-1Total available1Total supply1Total transfers
10Heat-1Total available1Total supply1Total transfers
11-1Total supply1Production1Imports1Exports1Intl marine bunkers1Supply.a
12-1Supply.a1Intl aviation bunkers1Stock changes
13-1Total transfers1Transfers.a1Transfers.b1Transfers.c
14-1Transfers.a1Transfers1Statistical differences1Electricity plants1CHP Plants1Heat plants
15-1Transfers.b1Gas works1Petroleum refineries1Coal transformation1Liquefication plants1Other transformation
16-1Transfers.c1Own use1Distribution losses
17-1Total available1Total industry1Total transport1Total other sectors1Total non-energy
18-1Total industry1Industry.a1Industry.b1Industry.c
19-1Industry.a1Iron and steel1Chemical and petrochem1Non-ferrous metals1Non-metallic minerals1Transport equipment
20-1Industry.b1Machinery1Mining and quarrying1Food and tobacco1Paper, pulp & printing1Wood and wood products
21-1Industry.c1Construction1Textile and leather1Non-specified
22-1Total transport1Domestic aviation1International aviation1Road transport1Rail transport1Transport.a
23-1Transport.a1Pipeline transport1Domestic navigation1International navigation1Non-specified
24-1Total other sectors1Residential1Community & public services1Agriculture & forestry1Fishing1Non-specified
25-1Total non-energy1in industry transf. and energy1in transport1in other sectors

Energy efficiency

How to combine an energy efficiency table into an energy matrix?

We use equations like this:

Heat = P1 Coal & peat + P2 Gas + P3 Nuclear etc,

where Pi are the energy efficiency coefficients. Equations are specific for transformation activity (row in an energy balance table). If an equation has more terms that the table has columns, the equation is divided into two rows with a technical variable ending with ".a".

This table applies to all energy balances, as these processes and parameter values are universal.

Energy efficiency(fraction)
ObsActivityInstallationP1V1P2V2P3V3P4V4P5V5P6V6P7V7P8V8
1Electricity plantsBefore 2007-1Electricity0.365Coal & peat0.4Petrochem products0.46Gas0.325Nuclear1Hydro1Geo & solar & wind0.32Renew & waste
2CHP plantsBefore 2007-1Electricity0.33Coal & peat0.38Petrochem products0.44Gas0.3Nuclear1Hydro1Geo & solar & wind0.28Renew & waste
3CHP plantsBefore 2007-1Heat0.24Coal & peat0.39Petrochem products0.39Gas0.4Nuclear1Hydro1Geo & solar & wind0.255Renew & waste
4Heat plantsBefore 2007-1Heat0.86Coal & peat0.95Petrochem products0.95Gas1Geo & solar & wind0.85Renew & waste1Electricity
5Electricity plantsAfter 2007-1Electricity0.45Coal & peat0.5Petrochem products0.53Gas0.37Nuclear1Hydro1Geo & solar & wind0.4Renew & waste
6CHP plantsAfter 2007-1Electricity0.35Coal & peat0.4Petrochem products0.5Gas0.32Nuclear1Hydro1Geo & solar & wind0.33Renew & waste
7CHP plantsAfter 2007-1Heat0.55Coal & peat0.5Petrochem products0.4Gas0.5Nuclear1Hydro1Geo & solar & wind0.55Renew & waste
8Heat plantsAfter 2007-1Heat1Coal & peat1Petrochem products1Gas1Hydro1Geo & solar & wind1Renew & waste1Electricity

This is an example table with case-specific equations.

Talk:Energy balance(-)
ObsYearHaapaniemiDemandP1V1P2V2P3V3P4V4Equation
12013<80-1HaapaniemiDemand1HaapaniemiProductionHaapaniemiDemand = HaapaniemiProduction
22013=>80-1HaapaniemiProduction80HaapaniemiProduction = 80
32018<170-1HaapaniemiDemand1HaapaniemiProductionHaapaniemiDemand = HaapaniemiProduction
42018=>170-1HaapaniemiProduction170HaapaniemiProduction = 170
5-1Peat-1Wood1Heat1ElectricityPeat + Wood = Heat + Electricity
6-65Peat35Wood35% Peat + 65% Wood
7-40Heat60Electricity60% Heat + 40% Electricity
8-1Detached.Heat37Detached.Heat = 37
9-1Apartment.Heat43Apartment.Heat = 43
10-1Heat1Detached.Heat1Apartment.HeatHeat = Detached.Heat + Apartment.Heat

Pseudo code

This is a pseudo code for how to actually implement the table-to-matrix conversion. It is in Finnish because all code developers are Finns.

  1. Määrittele funktio, joka ottaa balance-tyyppisen taulukon ja tuottaa siitä matriisin ja ratkaisuvektorin yhtälönratkaisua varten. Se missä vaiheessa tämä pitää tehdä mitä kaikkea funktion pitää alla olevasta koodista sisältää on vielä vähän epäselvää.
    1. Joka tapauksessa ideana on se, että balance-tyyppisiä taulukoita on useita ja niitä ajetaan matriisiin yksi kerrallaan. Taulukoita ajetaan sisään rivi kerrallaan niin kauan, että on saatu yhtä monta yhtälöä kuin on tuntemattomia muuttujia. Yhtälöt on siis asetettava karkeaan tärkeysjärjestykseen. Loppuosan yhtälöt ovat yksinkertaisia tyyppiä Muuttuja = Vakio, ja tiedot otetaan olemassaolevasta energiatasetaulukosta. Näin käyttäjän ei tarvitse käydä läpi hankalaa tarkistusprosessia varmistaakseen, montako yhtälöä tarvitaan ja montako niitä on. Ainoastaan pitää tarkistaan, ettei yhtälöiden joukossa ole sellaisia, jotka ovat tosiasiallisesti identtisiä eivätkä siten tuo lisätietoa.
      1. Ensin ajetaan Basic equations, joka sisältää polttoainekohtaisesti erilaisten aktiviteettien välisiä suhteita (jotka näkyvät pystysuuntaisina riippuvuuksina energiatasetaulukossa).
      2. Sitten ajetaan Energy efficiencies, joka kuvaa energiatyyppien muuttamista toisikseen (jotka näkyvät vaakasuuntaisina riippuvuuksina energiatasetaulukon Transfers-osiossa).
      3. Kolmantena ajetaan tapauskohtaisia yhtälöitä, erityisesti eri prosessien osuuksia kuten polttoainejakaumia kaupungissa.
      4. Neljänneksi ajetaan energiatasetaulukosta vakioita, kunnes yhtälöitä on yhtä monta kuin muuttujia.
  2. Tee data.frame balance <- Lataa energiatasetaulu pitkässä muodossa. Säilytä Obs.
  3. Luo ratkaisuvektori B, jossa on yhtä monta riviä kuin datassa on Obseja. Alussa B sisältää vain nollia.
  4. Tee balancesta ovariable: params Se sisältää Parametririvien arvot (eli niiden rivien, joissa Observation on P1, P2,...).
  5. Tee balancesta myös data.frame: vars. Se sisältää muuttujarivien (Observation = V1, V2,...) arvot (muuttujanimet).
  6. Evaluoi params, jolloin mahdolliset interpretattavat Resultit saadaan oikein.
  7. Tee paramsille fillna(), jotta tyhjät indeksien nimet saadaan täytettyä ja kaikille lokaatioille saadaan vastaavat tulokset.
  8. Tee vektori Cols <- Tee vars:n Resultille unique(). Näin saadaan matriisin sarakenimet.
  9. Päivitä params <- Poista Observationista "P", jolloin jää muuttujan numero.
  10. Päivitä vars <- Poista Observationista "V", jolloin jää muuttujan numero.
  11. Tee data.frame scenarios <- leikataan params:sta indeksit ja tehdään niille unique().
  12. Tee tulosta varten data.frame out, jossa on ensin kaikki params:n indeksit (eli scenarios) ja sitten Cols sarakkeina.
  13. Tee for-luuppi niin, että jokainen scenarios:n rivi käydään kerrallaan.
    1. Mergaa scenarios:n rivi params:n ja toisaalta vars:n kanssa. Näin jäljelle jäävät vain ne yhtälöt, jotka kuuluvat nimenomaan tuohon skenaarioon.
    2. Tee energyMatrix <- Sijoita kukin params:n arvo energiamatriisiin sellaiseen ruutuun, jossa Obs on sama kuin matriisin rivinumero ja sarakkeen numero sama kuin Cols-vektorissa se solu, jossa on sama muuttujanimi kuin vars:n vastaavassa ruudussa.
      1. Jos vars-taulu on tyhjä siltä kohtaa, kyseessä on vakio ja params:n arvo vähennetään ratkaisuvektorin B riviltä Obs (vähennetään, koska se siirretään yhtälön toiselle puolelle).
    3. Ratkaise energyMatrix ratkaisuvektorin B avulla.
    4. Tallenna saadut muuttujien arvot out:iin kyseisen skenaarion kohdalle.
  14. Käy läpi kaikki ehtoindeksit (esim. HaapaniemiDemand<80) ja poista kaikki ne rivit, joissa ratkaisun mukaan ehto ei täyty (esim. HaapaniemiDemand-sarakkeen ratkaistu arvo on yli 80 sellaisella rivillä, jossa sen piti olla <80).
  15. Tulosta out.

A more fancy syntax for equations

It is possible to give the equations as text strings. However, this would require more code which does not exist yet. Therefore, we will stick to the previous syntax that starts with tables where interpretation has already been done further. This has not been translated into English because it is not in use.

Vastaus
Kuvataan kukin yhtälö tekstinä, josta pilkotaan eri tekijät esiin standardinotaatiosta. Yhtälöön voi liittyä indeksejä (kuten mihin tahansa Resultiin), jotka määrittelevät milloin kyseinen yhtälö on voimassa. Jokainen uniikki indeksien lokaatioiden joukko muodostaa oman yhtälöryhmänsä, joka ratkaistaan erikseen. Lisäksi yhtälöiden parametrit voivat olla epävarmoja siten kuin interpret-funktio ymmärtää. Tällöin myös Iter on yksi indekseistä.
Kysymys
Millaisia notaatioita tarvitaan sellaisten yhtälöiden kuvaamiseen, joita on käytännössä käytössä?
Vastaus
  1. Tavallinen yhtälö, joista erityistapauksena Input = Output
  2. Osatekijät summautuvat vakiosuhteessa
  3. Muuttuja on vakio ⇤--#: . Tämä on vain erikoistapaus ykköskohdasta eikä vaadi omaa käsittelyä. --Jouni 06:31, 7 June 2013 (EEST) (type: truth; paradigms: science: attack)
Tavallinen yhtälö
Tämä kirjoitettaisiin näin
Notaatio: peat + oil + wood = heat + electricity + loss
Tai: 2.3*a + 3.5*b + 1-3*c = d (Huom. Ei voi käyttää interpret-notaatiota, jossa on +)
Ja toiminta:
Strsplitataan =:n kohdalta ja loppuosan parametrien etumerkki vaihdetaan
Strsplitataan +:n kohdalta jolloin muodostuvat termit
Strsplitataan *:n kohdalta jolloin ensimmäinen osa on kerroin ja toinen on muuttujanimi. Jos * puuttuu, kerroin on 1.
Kertoimet muunnetaan numeroiksi jos mahdollista, tai ajetaan interpret-funktiolla. Jos tämäkään ei onnistu, tulostetaan NA.
Jos yhtälössä on vakio: peat + wood = 230
Toiminta: Vakio lisätään yhtälön ratkaisuvektoriin.
Osatekijät summautuvat vakiosuhteessa
Notaatio: 40% peat + 12% oil + wood
Merkitys: %-merkkiä edeltävä luku tarkoittaa kyseisen muuttujan osuutta (prosentteina) kaikkien listattujen muuttujien kokonaismäärästä. Viimeistä prosenttia ei ilmoiteta, vaan se on loput. Tämä siitä syystä, että prosentit voivat olla epävarmoja. Yleensä suurin osuus kannattaa jättää viimeiseksi, koska siinä absoluuttiset heilahtelut aiheuttavat vähiten haittaa jakauman muodossa.
Toiminta: Pilkotaan seuraaviksi yhtälöiksi:
12*peat + -40*oil = 0
(100 - 40 - 12)*peat + -40*wood = 0

Abstract to ISEE 2013 Basel

Submitted 20.2.2013.


Energy balance model poster in ISEE2013 in Basel, 20 Aug 2013.

Online energy balance tool to assess health impacts of climate policies in cities - case EU (Kuopio, Stuttgart) and China (Suzhou)

Tuomisto JT, Torras Ortiz S, Niittynen M

Background. Climate mitigation policies in municipalities have global impacts on climate change, but the actual impacts on the municipalities themselves are other than climate. Typically, energy policies may add or reduce fine particle emissions and thus cardiopulmonary effects; traffic policies affect e.g. urban sprawl, accidents, and well-being. As a part of climate policy support, there is a need for simple online impact models including energy and health.

Aims. We developed an online computational model for estimating energy balance (inputs and outputs of energy on municipality level) and related emissions. The model was designed to be both a modelling and dissemination tool, and able to be updated and run by municipality authorities or even by interested citizens.

Methods. We decided to use matrix calculation as the core of the tool, as we need a straightforward way to calculate a new solution when some inputs or outputs are changed by a user. The model was implemented in an open web workspace Opasnet http://en.opasnet.org/w/Energy_balance with R software. The structure of the balance table was taken from the OECD energy balance sheets, with city-specific modifications when needed.

Results. Data was collected and model adjusted for two European cities: Kuopio (100000 inhabitants, in Finland) and Stuttgart (600000 inhabitants, in Germany) and one Chinese city Suzhou (2.38 million inhabitants). For example, the household electricity consumption was 296, 1077, and 625 GWh per year in Kuopio, Stuttgart, and Suzhou, respectively. The respective numbers for industry were 204, 2257, and 7032 GWh per year, showing large variation by city and by sector.

Conclusions. The energy balance model works as intended and is able to calculate input/output balances for different scenarios. The next steps are to connect the model to emission models, to develop multi-city capabilities, and to improve user-friendliness.

Old thoughts 22.2.2013

Energy balance has these parts

  • General table that describes balances and conversions from ole fuel to another.
    • Items and sums Are defined at generic level.
  • Data table that contains amounts from OECD table
  • Fraction table thAt describes how detailSs Are derived from sums.
  • if there Are additions to sta dard items, they descrided at city level in an addition table. It must have the struxture of the matrix table in long format.
  • can nonlinearities ne handled simply by indices separating two linear parts of nonlinear equations?