All the electricity that is consumed somewhere must have been produced somewhere else. This gives us a balance equation, that can be applied to each country.
Therefore, for the $i$-th country, the following equality holds about electricity:
$$ consumption_i = production_i + import_i - export_i - transmission_i $$We will now assume that transmission costs are negligible. Each term of the equation has an associated carbon intensity, which we will describe:
This enables us to write an updated balance equation for the carbon flow taking place in the $i$-th country, having imports from $j$, exports to $k$ and production modes $m$
$$ x_i \cdot consumption_i = \sum_m I_{i,m} \cdot production_{i,m} + \sum_j x_j \cdot import_{i,j} - \sum_k x_i \cdot export_{i,k} $$Note that because in this simplified model $consumption = production + import - export$, exports cancel out, and the equation reduces to
$$ x_i \left(\sum_m production_{i,m} + \sum_j import_{i,j} \right) = \sum_m I_{i,m} \cdot production_i + \sum_j x_j \cdot import_{i,j}$$which is neatly renamed to
$$ x_i \left(production_i + import_i \right) = \sum_m I_{i,m} \cdot production_i + \sum_j x_j \cdot import_{i,j}$$Writing out all equations for all countries, one obtains a linear system of equations, where we wish to solve for $x$:
$$ \begin{bmatrix}production_{1} + import_{1} & import_{1,2} & import_{1,3} \\ import_{2,1} & \ddots & import_{2,3}\\ import_{3,1} & import_{3,2} & production_{n} + import_{n} \end{bmatrix} \begin{bmatrix}x_1\\\vdots\\x_n\end{bmatrix} = \begin{bmatrix} \sum_m I_{1,m} \cdot production_1\\ \vdots\\ \sum_m I_{n,m} \cdot production_n \end{bmatrix}$$where $import_{i,j}$ represents the amount of import to $i$-th country from $j$-th country. The matrix is sparse, and represents the connectivity of the countries.
Solving this linear system gives the carbon intensities $x_i$ of each country.
In [ ]: