Photograph of a hand grabbing a screwdriver from out of a toolbox or toolset that is open on a table. There are several similar screwdrivers lying next to the one being held by the hand.

Friendly Sam is a toolbox for optimisation-based models and simulation of energy systems.

Focus of the text

This text describes Friendly Sam; a toolbox developed to formulate optimization-based models of energy systems, so-called dispatch models. By creating models with an overarching system perspective on the energy system, different sectors could be included, such as heating, cooling, and electricity. Decision makers at e.g. energy companies or urban planning/development will benefit from the text, which aims to facilitate the understanding of this open source software, how to use it – and why. 

Do you need a friend to help you analyse and optimise the energy system? The toolbox Friendly Sam can be used to model the energy system of a city and compare how different measures affect the energy system in terms of e.g. costs and CO2 emissions.


Why Friendly Sam is needed

Climate strategies and targets are in place at many different levels; national, regional and local; as well as for different sectors and companies. Informed decisions are required at different levels to achieve these goals. The energy system is often affecting, or is affected by, these strategies and targets. One way to make a more informed decision is to make a model of the system, to analyse and evaluate the effects of different measures on the system. Friendly Sam is a toolbox for developing these kinds of models.

Friendly Sam is an outcome from the Sinfonia project; a five-year initiative to deploy large-scale, integrated and scalable energy solutions in mid-sized European cities.

What Friendly Sam is

Friendly Sam is a toolbox to formulate and solve optimisation-based models of energy systems. The problem formulation can often be described as: Minimise the operation cost of this system in this time period, subject to the technical and legal constraints of the system. The detail level and system boundaries are defined by the developer of the model. One of the strengths of Friendly Sam is that it can be used to create models with an overarching system perspective on the energy system where different sectors of the energy system could be included, such as heating, cooling, and electricity.


How Friendly Sam could be used

It is possible to develop a base model and add different measures or technologies to Friendly Sam to evaluate their impact on the existing energy system. The model can ease the comparison of different measures targeting different areas of the energy system. The system costs of decreasing the heat demand through renovation could be compared to the systems costs of increasing the efficiency of a production unit in the district heating network.


How Friendly Sam works

Friendly Sam is used to formulate and solve optimisation-based models of energy systems, so-called dispatch models. A dispatch model is usually formulated as a minimisation problem with respect to cost, but the objective function can also be to e.g. minimize a system’s carbon emissions. A Friendly Sam model is data driven and the final results are to a large extent dependent on the input data

The models built by Friendly Sam often uses balance equations for energy and the toolbox contains definitions like Node, Cluster, Resources to simplify the formulation of such constraints. The Node class can be used for modelling of e.g. power plants, solar PV and consumption. Friendly Sam is an open source software implemented in Python.


Figure 1. A visualisation of what a model developed through Friendly Sam could look like


Figure 2. Overview of possible input and output data of a model developed with Friendly Sam.


The core concept of the models developed through Friendly Sam is that resources flow between nodes, and the nodes process and alter these flows. The nodes are instances of predefined archetypes such as power plants, consumers, energy storage etc. and these nodes can be customized by the user. New archetypes with certain characteristics can also be added if necessary. Between these nodes resources flow –  these resources could be e.g. fuels, heat, and electricity. The size of the flows can be limited to represent distribution capacities within the system. Several nodes can be clustered, and there are no distribution limitations within a cluster. It is possible to model different parts of the system with various level of detail. A visualisation of what a model developed through Friendly Sam could look like is shown in figure 1 above. The nodes are represented by the dark blue circles, the arrow the resources and the light blue area represent a cluster.

Text by: Lovisa Axelsson (RISE)




Friendly Sam


Inger-Lise Svensson, e-mail


Impact areas

  • Energy savings
  • Reduced costs
  • Reduced climate impact

External links:

  1. Read more about how to install and use Friendly Sam here.

Send us an email

1 + 15 =

Share This
Toolbox Policy & Planning City planning Friendly Sam – Tools for modelling and optimising energy systems