### ThermalStation with Boiler Example
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
An example of a simple thermal station that includes essential child elements like Pump, TemperatureSetpoint, PressureSetpoint, and an energy conversion unit (Boiler).
```XML
```
--------------------------------
### Build FMILib on Linux/Mac
Source: https://github.com/kaemco/citysim-solver/blob/main/FMILibrary/doc/FMILIB_Readme.txt
Use this command to build the FMI Library on Linux or Mac with default settings. Ensure you set the installation prefix.
```bash
mkdir build-fmil; cd build-fmil
cmake -DFMILIB_INSTALL_PREFIX=
make install test
```
--------------------------------
### Build FMILib on Windows (Visual Studio)
Source: https://github.com/kaemco/citysim-solver/blob/main/FMILibrary/doc/FMILIB_Readme.txt
Build the FMI Library using Microsoft Visual Studio compilers on Windows. Specify the Visual Studio generator and the installation prefix.
```bash
mkdir build-fmil; cd build-fmil
cmake -DFMILIB_INSTALL_PREFIX= -G "Visual Studio 10"
cmake --build . --config MinSizeRel --target install
```
--------------------------------
### Detailed Tree example with vertices
Source: https://github.com/kaemco/citysim-solver/wiki/The-District
An example of a specific Tree tag, including detailed vertex data for its Leaf and Trunc components. This allows for precise geometric representation.
```XML
(more Trunc tags...)
```
--------------------------------
### Build FMILib on Windows (MSYS)
Source: https://github.com/kaemco/citysim-solver/blob/main/FMILibrary/doc/FMILIB_Readme.txt
Build the FMI Library in an MSYS terminal using g++/gcc on Windows. Specify the MSYS Makefiles generator and the installation prefix.
```bash
mkdir build-fmil; cd build-fmil
cmake -DFMILIB_INSTALL_PREFIX= -G "MSYS Makefiles"
make install test
```
--------------------------------
### CitySim Climate File Header Example
Source: https://github.com/kaemco/citysim-solver/wiki/The-Climate-File
The header of a .cli file specifies the city name and its geographical coordinates (latitude, longitude, altitude) and meridian.
```text
Basel
47.55,7.583,316,1
```
--------------------------------
### NodePair ID Conflict Example
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Illustrates an incorrect configuration where ThermalStationNodePair and NodePair share the same ID, which is not allowed. Node IDs must be unique.
```XML
```
--------------------------------
### Define Node Pairs in District Energy Center
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Example of defining various node pairs within a district energy center configuration. Ensure IDs are unique across the entire district.
```XML
```
--------------------------------
### CitySim XML Header Example
Source: https://github.com/kaemco/citysim-solver/wiki/The-Header
This XML snippet defines the header for a CitySim simulation. It specifies the simulation period and references a climate file. Ensure sprngSeed is a unique unsigned 32-bit integer for stochastic model results.
```xml
```
--------------------------------
### Define Pipe Pair with Supply and Return Pipes
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Example of a PipePair element connecting two nodes, specifying length, inner radius, and inter-pipe distance. It includes child elements for SupplyPipe and ReturnPipe, detailing insulation and burial depth.
```XML
```
--------------------------------
### HeatSource with Simple Boiler
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Configures a simple boiler as a heat source, specifying maximum power and thermal efficiency. This is a basic setup for a heating system.
```XML
```
--------------------------------
### Get Build Timestamp Function
Source: https://github.com/kaemco/citysim-solver/blob/main/FMILibrary/doc/FMILIB_Readme.txt
Retrieves the build time stamp generated during the library build. This function is available when FMILIB_GENERATE_BUILD_STAMP is enabled.
```c
const char* fmilib_get_build_stamp(void);
```
--------------------------------
### Simulate Occupancy and Block Absence
Source: https://github.com/kaemco/citysim-solver/blob/main/scrap.txt
This C++ code simulates room occupancy and manages block absence periods, determining absence duration and checking for occupant return. It uses random number generation to decide on absence start and duration.
```cpp
if (blockAbs0==0){
x=randomUniform(0.0,1.0);
if (x < pLongAbsence){
blockAbs=1;
x = randomUniform(0.0,1.0);
count = 0;
for(int l = 0;l < vLongAbs.size();l++){
if(vLongAbs[l] tEndBlockAbs) blockAbs=0;
else blockAbs=1;
}
if (blockAbs==1)
occ=0;
else if ((blockAbs0==1)&&(blockAbs==0))
occ=1;
else{
x=randomUniform(0.0,1.0);
if (occ0==0){
if (T01[k]>x) occ=1;
else occ=0;
}
else if (occ0==1){
T10[k]=1-T11[k];
if (T10[k]>x) occ=0;
else occ=1;
}
}
occ0 = occ;
blockAbs0 = blockAbs;
nbPers[i+1] += occ;
}
}
}
pDistrict->getBuilding(b)->getZone(z)->setPresence(nbPers);
}
}
}
```
--------------------------------
### Configure Simple Substation
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Adds a substation to a CoolSource or HeatSource. Requires a linkedNodeId, design thermal power, temperature difference, and performance epsilon.
```XML
```
--------------------------------
### Model Window Opening Based on Temperature and Probability
Source: https://github.com/kaemco/citysim-solver/blob/main/scrap.txt
This C++ function calculates window opening status based on indoor and outdoor temperatures, atmospheric pressure, and various probabilistic models. It includes deterministic and logistic regression models for window opening.
```cpp
void Model::WindowsOpening(Building *pBuilding, Climate *pClimate, unsigned int step, unsigned int step2, double &Nvent){
double To = pClimate->getToutCelsius(dt*step), Ti;
double patm = pClimate->getPatm(step);
const double C = 0.6;
const double g = 9.81;
double rho;
double Vdot;
bool windowOpen = true;
double winArea, h = 1, W = 1, V;
double a, b,c, alea, pactwin;
for (int i=0;igetnZones();i++) {
if (step2==0) Ti = pBuilding->getZone(i)->getTa(step);
else Ti = pBuilding->getZone(i)->getTaExpl(step*12+step2-1);
if (windowOpen){
```
--------------------------------
### Affine Temperature Setpoint Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Configures a temperature setpoint that varies affinely with external temperature. Specify temperature ranges and corresponding supply temperatures for interpolation.
```XML
```
--------------------------------
### Define Composite Material for Asphalt Road
Source: https://github.com/kaemco/citysim-solver/wiki/The-District
Defines a composite material for an asphalt road with four distinct layers, specifying their properties. This example illustrates a ground composite.
```XML
```
--------------------------------
### Presence Model Implementation in C++
Source: https://github.com/kaemco/citysim-solver/blob/main/scrap.txt
This C++ function implements the Presence Model, which calculates occupancy distribution within buildings based on presence profiles and long-term absence data. It requires building and climate data as input.
```cpp
void Model::Presence(District *pDistrict, int NTS){
vector pd; //presence distribution
//load("presence.txt", pd); // commented here JK - 20.03.09 (due to removal of fct.cpp)
vector T11, T01, T10, vLongAbs,vLongAbs0;
vector nbPers;
int nbPersMax;
double mu, beta, pLongAbsence, x; //beta is the mobility factor (mu) adjusted
//load("LongAbs.txt", vLongAbs0); // commented here JK - 20.03.09 (due to removal of fct.cpp)
for (unsigned int b=0;bgetnBuildings();b++){
for (unsigned int z=0;zgetBuilding(b)->getnZones();z++){
mu = pDistrict->getBuilding(b)->getZone(z)->getMu(); //parametre de mobilit
pLongAbsence = pDistrict->getBuilding(b)->getZone(z)->getDayOff()/52 / (7*24*4);
nbPersMax = pDistrict->getBuilding(b)->getZone(z)->getNbPersMax();
nbPers.assign(NTS, 0);
T01.assign (pd.size(), 0.0);
T11.assign (pd.size(), 0.0);
T10.assign (pd.size(), 0.0);
///Determination de T01 et T11
beta = mu; //ajustement du mu
for (int i = 0;i < pd.size();i++){
if(pd[i+1]==0){
T01[i] = 0;
T11[i] = 0;
}
else if(pd[i+1]==1){
T01[i] = 1;
T11[i] = 1;
}
else{
if (pd[i]==1){
T11[i] = pd[i+1];
T01[i] = 0;
}
else if (pd[i]==0){
T01[i]=pd[i+1];
T11 [i]=0;
}
else if (pd[i] == pd[i+1]){
if (pd[i] + pd[i+1]>1){
if (mu>1/(2*pd[i]-1))
beta=1/(2*pd[i]-1);
else beta=mu;
}
else if (pd[i]+pd[i+1] < 1){
if (mu > 1/(1-2*pd[i]))
beta = 1/(1-2*pd[i]);
else beta = mu;
}
else beta = mu;
T01[i] = 2*beta*pd[i]/(beta+1);
T11[i] = 1-(1-pd[i])*T01[i]/pd[i];
}
else if (pd[i] 1) && (mu>(pd[i]-pd[i+1]+1)/(pd[i+1]+pd[i+1]-1)))
beta=(pd[i]-pd[i+1]+1)/(pd[i+1]+pd[i+1]-1);
else if ((pd[i]+pd[i+1]<1) && (mu > (1-pd[i]+pd[i+1])/(1-pd[i]-pd[i+1])))
beta=(1-pd[i]+pd[i+1])/(1-pd[i]-pd[i+1]);
else beta = mu;
T01[i] = pd[i+1]+pd[i]*(beta-1)/(beta+1);
T11[i] = 1/pd[i]*(pd[i+1]-(1-pd[i])*T01[i]);
}
else{
if (mu<(pd[i]-pd[i+1])/(pd[i+1]+pd[i]))
beta =( pd[i]-pd[i+1])/(pd[i+1]+pd[i]);
else
if ((pd[i]+pd[i+1]>1) && (mu >(pd[i]-pd[i+1]+1)/(pd[i+1]+pd/*change p en pd*/[i]-1)))
beta = (pd[i]-pd[i+1]+1)/(pd[i+1]+pd[i]-1);
else if ((pd[i]+pd[i+1] < 1) && (mu > (1-pd[i]+pd[i+1])/(1-pd[i]-pd[i+1])))
beta=(1-pd[i]+pd[i+1])/(1-pd/*change pd en p*/[i]-pd[i+1]);
else beta=mu;
T01[i] = pd[i+1]+pd[i]*(beta-1)/(beta+1);
T11[i] = 1/pd[i]*(pd[i+1]-(1-pd[i])*T01[i]);
}
}
}
double dBlockAbs /*dur block absence*/ , absDurationBin = 12.0, absDurationMin =12.0, tEndBlockAbs /*fin du absence block */;
vLongAbs = vLongAbs0;
for (int i = 1; i < vLongAbs.size(); i++){
vLongAbs[i] += vLongAbs[i-1];
if (vLongAbs[i] > 1.0)
vLongAbs[i] = 1.0;
}
int occ0, occ, blockAbs0, blockAbs, count;
for (int j = 0;j= NTS-1)
```
--------------------------------
### Constant Temperature Setpoint Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Defines a constant target supply temperature for a temperature setpoint. Use this when a fixed temperature is required regardless of external conditions.
```XML
```
--------------------------------
### Add PV Panels to a Wall
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
This snippet demonstrates adding PV panels to a wall element. It specifies PV panel properties such as reference efficiency, nominal operating cell temperature, reference temperature, voltage at maximum power, and temperature coefficient.
```XML
```
--------------------------------
### ThermalStation Configuration (Simple Type)
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Configures a simple thermal station within the DistrictEnergyCenter. It specifies the operational days, the linked node ID, and the type. This type can only produce heat or cold.
```XML
```
--------------------------------
### Define Ground Surfaces with Detailed Simulation
Source: https://github.com/kaemco/citysim-solver/wiki/The-District
Defines triangular ground surfaces with properties like ShortWaveReflectance and kFactor. Setting detailedSimulation to true enables a more accurate, layer-by-layer ground temperature calculation.
```XML
```
--------------------------------
### Affine Pressure Setpoint Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Defines a pressure setpoint that varies affinely with mass flow. Multiple mass flow and pressure difference points are used to define piecewise affine behavior.
```XML
```
--------------------------------
### Define Daily Occupancy Profile
Source: https://github.com/kaemco/citysim-solver/wiki/Occupant-profile
Defines the hourly occupancy rate for a single day. Use 'p' followed by the hour (1-24) to set the occupancy rate for that hour.
```XML
```
--------------------------------
### Define Building Wall with Basic Properties
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Use this XML structure to define a building wall with its type, thermal properties, glazing details, and vertex coordinates. The LongWaveEmissivity defaults to 0.9 if not specified.
```XML
```
--------------------------------
### Add PV Panels to a Roof
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
This snippet shows how to integrate PV panels onto a roof element. It includes the same PV panel technical properties as for walls, allowing for consistent simulation across different building surfaces.
```XML
```
--------------------------------
### Define Building Floor in XML
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Use this XML structure to define a building floor, including its ID, type, and vertex coordinates.
```XML
```
--------------------------------
### Define Building Wall with PV and Solar Heater
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
This XML defines a wall with integrated photovoltaic panels and solar heaters, specifying their coverage ratios and performance parameters. It also allows direct U-value definition instead of referencing a wall type.
```XML
```
--------------------------------
### Daily DHW Profile Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/Occupant-profile
Defines a daily DHW profile with water consumption and hourly distribution probabilities. Use this to model typical daily hot water usage patterns.
```XML
```
--------------------------------
### Network Configuration with Node and Pipe Definitions
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Configures the thermal network, including soil conductivity and detailed definitions of nodes and pipe segments. This structure is essential for simulating heat flow within the district energy system.
```XML
```
--------------------------------
### Constant Pressure Setpoint Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Sets a constant target pressure difference for a pressure setpoint. Use this for applications requiring a fixed pressure differential.
```XML
```
--------------------------------
### Building Tag Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Defines a building with identification, infiltration rate, blinds behavior, and simulation settings. Ensure 'id' is unique per building.
```XML
```
--------------------------------
### Substation Configuration for Prosumer HeatSource
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Configures a substation as a 'prosumer' for injecting solar thermal heat into the network. Requires flow control valve, temperature setpoint, pressure setpoint, and pump details. 'kvMaxFlowControlValve' is crucial for flow control.
```XML
```
--------------------------------
### Define Activity Types and Activities
Source: https://github.com/kaemco/citysim-solver/wiki/Occupant-profile
XML structure for defining activity types, which group individual activities. Each activity has hourly mean probabilities and is associated with a device type. Probabilities are mutually exclusive and cumulative.
```XML
```
--------------------------------
### Define Device Types and Devices
Source: https://github.com/kaemco/citysim-solver/wiki/Occupant-profile
XML structure for defining device types and individual devices, including average power and heat gain fractions. Use this to model different types of electrical devices and their thermal properties.
```XML
```
--------------------------------
### HeatSource with Boiler Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Defines a heat source using a boiler, specifying its operational period and efficiency. The 'beginDay' and 'endDay' attributes define the active period.
```XML
```
--------------------------------
### Storage Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Defines a simple storage tank within a ThermalStation. It requires initial temperature and heat capacity. This is used for storing thermal energy.
```XML
```
--------------------------------
### Configure Substation as Heat Pump (SubstationHP)
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Defines a substation that functions as a heat pump within a HeatSource. Includes substation parameters and additional heat pump characteristics like Pmax and target temperature.
```XML
```
--------------------------------
### Define Building Roof with Basic Properties
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
This XML defines a building roof with its type, thermal properties, glazing details, and vertex coordinates. Similar to walls, roofs can also be fitted with PV panels.
```XML
```
--------------------------------
### Define Micro Wind Turbine on Roof
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
This snippet defines a roof with an integrated micro wind turbine. It includes parameters for the turbine's operational speeds, performance coefficients, air density, hub height, and terrain interaction.
```XML
```
--------------------------------
### Tank Configurations for Building
Source: https://github.com/kaemco/citysim-solver/wiki/The-building
Configures heat, domestic hot water (DHW), and cool tanks within a building. Specifies volume, density, specific heat, thermal losses, temperature ranges, and critical temperatures.
```XML
```
--------------------------------
### Pump Performance Parameters
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Specifies the performance characteristics of a pump, including its efficiency and parameters that describe its pressure-increasing capabilities based on flow rate.
```XML
```
--------------------------------
### Yearly DHW Profile Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/Occupant-profile
Defines a yearly DHW profile by associating each day of the year with a specific daily DHW profile ID. This allows for seasonal variations in hot water usage.
```XML
```
--------------------------------
### DistrictEnergyCenter Configuration
Source: https://github.com/kaemco/citysim-solver/wiki/District-Energy-Center
Defines a district energy center with its ID and heat transfer fluid properties. The dynamic viscosity can be set to a constant value or use the Vogel-Fulcher-Tammann formula for water.
```XML
```