# Concept of the Integration of INSEL models into SimStadt

The main concept to integrate INSEL models into SimStadt is to introduce a SimStadt Workflow step *INSEL templater* that is able to  

1. read an INSEL template
2. writes an INSEL model per feature of interest based on the INSEL template
3. executes the INSEL model
4. reads the results written by the INSEL process and maps the resulting values to the SimStadt data model

In a first prototype, the INSEL template is restricted to variables only. The feature of interest are buildings. For the implementation, the Java-Library handlebars (https://github.com/jknack/handlebars.java) has been choosen. That iomplies that a variable in the INSEL template has been encapsulated by two brackets: {{name of variable}}. To avoid an additional mapping between variables in teh INSEL template and attributes in the SimStadt data model, the names of the variables in the INSEL template have to be the same as in the SimStadt data model.

Example: 

This statement in an INSEL template 

[source,java]
----
{{electricalEfficiency}} % Electrical efficiency [-]
----

will be replaced by the value of the attribute _electricalEfficiency_ in the INSEL model by the INSEL templater Workflow step per building. 

If an attribute is not set in an instance of an object in SimStadt, a default value can be defined in the template:

[source,java]
----
{{getOrDefault electricalEfficiency 0.20}} % Electrical efficiency [-]
----

An example of an INSEL template for a heat pump that is applied to the simulation of every building in SimStadt can be found here:  

[source,java]
----
include::https://gitlab.com/volkercoors/neqmodplus-steinbeis/uploads/c977bb7ac8882d1b2105813d35ea0b63/2020-04-17_HP_central_simple_constants_incl_defaults.txt
----

The example is provided by Verena Weiler.


