﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5975	Numerical problems with initialization of thermofluid model in BuildingSystems	hendrikjob98@…	Lennart Ochel	"Hi,
I'm new to OM. So I hope, that this issue can be solve by more experienced people...
I want to simulate a thermal building under weather conditions. For this i mostly use Blocks from the BuildingSystems library.
I just cant get the following code working. I'm German, so there are some German expression in the comments or the name-declarations. 
{{{
model Wohncontainer
  ""Wohncontainer in Putlos""
  extends Modelica.Icons.Example;

  parameter Integer nSurfaces = 8;
  parameter Modelica.SIunits.Position Laenge = 5.758;
  parameter Modelica.SIunits.Position Breite = 2.174;
  parameter Modelica.SIunits.Position Hoehe = 2.290;

  parameter Real C_max(final unit=""l/m3"")=1;
  parameter Real C_Zuluft(final unit=""l/m3"")=0.35;
  parameter Real C_CO2Atmen(final unit=""1"")=0.04;
  parameter Real Vdot_Atmen(final unit=""l/h"")=240;
  Real nNutzer;
  Real Luftwechsel(final unit=""1/h"");
  Real CO2AustossNutzer;

  record wand 
  extends BuildingSystems.Buildings.Data.Constructions.OpaqueThermalConstruction(nLayers=3, thickness={0.012,0.284,0.004}, material={Sperrholz(), Isolierung(), Stahl()});
  end wand;

  
  record boden 
  extends BuildingSystems.Buildings.Data.Constructions.OpaqueThermalConstruction(nLayers=4, thickness={0.002,0.018,0.278,0.004}, material={PVCBelag(), Sperrholz(), Isolierung(), Stahl()});
  end boden;
  
  record fenster 
  extends BuildingSystems.Buildings.Data.Constructions.TransparentConstruction(nPanes=2, thickness={0.003,0.003}, UValGla = 1.0, UValFra = 1.5, g = 0.52, b0 = 0.7);
  end fenster;
  
  record Isolierung 
    extends BuildingSystems.HAM.Data.MaterialProperties.BaseClasses.MaterialThermalGeneral
    (
    id=11,
    name=""Isolierung"",
    lambda=0.03,
    c=1400,
    rho=35);
  end Isolierung;
    
  record PVCBelag 
    extends BuildingSystems.HAM.Data.MaterialProperties.BaseClasses.MaterialThermalGeneral
    (
    id=13,
    name=""PVCBelag"",
    lambda=0.15,
    c=850,
    rho=138);
  end PVCBelag;
  
  record Sperrholz 
    extends BuildingSystems.HAM.Data.MaterialProperties.BaseClasses.MaterialThermalGeneral
    (
    id=12,
    name=""Sperrholz"",
    lambda=0.17,
    c=2100,
    rho=720);
  end Sperrholz;
  
  record Stahl 
    extends BuildingSystems.HAM.Data.MaterialProperties.BaseClasses.MaterialThermalGeneral
    (
    id=10,
    name=""Stahl"",
    lambda=50,
    c=490,
    rho=7900);
  end Stahl;
  
  BuildingSystems.Buildings.Constructions.Doors.Door door( redeclare wand constructionData, angleDegAzi=180.0, angleDegTil=90.0, calcAirchange = false,height=2.0, width=0.9) annotation(
    Placement(visible = true, transformation(origin = { -54, -88}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Walls.WallThermal1DNodes wall3(height=Hoehe, width=Breite, angleDegAzi=180.0, angleDegTil=90.0, redeclare wand constructionData, AInnSur=door.width*door.height) annotation(
    Placement(visible = true, transformation(origin = {-30, -44}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Walls.WallThermal1DNodes wall4(height=Hoehe, width=Laenge, angleDegAzi=-90.0, angleDegTil=90.0, redeclare wand constructionData) annotation(
    Placement(visible = true, transformation(origin = {-30, -70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Walls.WallThermal1DNodes ceiling(height=Laenge, width=Breite, angleDegAzi=0.0, angleDegTil=180.0, redeclare wand constructionData) annotation(
    Placement(visible = true, transformation(origin = {-30, 32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Walls.WallThermal1DNodes bottom(height=Laenge, width=Breite, angleDegAzi=0.0, angleDegTil=0.0, redeclare boden constructionData) annotation(
    Placement(visible = true, transformation(origin = {-30, 56}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Windows.Window window( redeclare fenster constructionData,angleDegAzi=0.0, angleDegTil=90.0, calcAirchange = false,height=1.2, width=0.9) annotation(
    Placement(visible = true, transformation(origin = {-48, -4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Walls.WallThermal1DNodes wall1(height=Hoehe, width=Breite, angleDegAzi=0.0, angleDegTil=90.0, redeclare wand constructionData, AInnSur=window.width*window.height) annotation(
    Placement(visible = true, transformation(origin = {-30, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Constructions.Walls.WallThermal1DNodes wall2(height=Hoehe, width=Laenge, angleDegAzi=90.0, angleDegTil=90.0, redeclare wand constructionData) annotation(
    Placement(visible = true, transformation(origin = {-30, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

  BuildingSystems.Buildings.Ambience ambience(redeclare block WeatherData = BuildingSystems.Climate.WeatherDataMeteonorm.Germany_Berlin_Meteonorm_ASCII, nSurfaces = nSurfaces)  annotation(
    Placement(visible = true, transformation(origin = {-102, -4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

  BuildingSystems.Buildings.Zones.ZoneTemplateAirvolumeMixed zone( Q_flow_coolingMax = -2000, Q_flow_heatingMax = 2000,T_start = 293.15,V=Laenge*Breite*Hoehe, airchange = Luftwechsel, calcIdealLoads=true, heatSources = true, height = Hoehe, heightAirpath = {0.5, 1.7, 0.0, 2.0}, moistureSources = true, nAirpaths = 4, nConstructions = 8, nMoistureSources = 0, prescribedAirchange = false, x_start = 0.005)  annotation(
    Placement(visible = true, transformation(origin = {28, -4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

  Modelica.Blocks.Sources.Constant TSetHeating(k = 293.15)  annotation(
    Placement(visible = true, transformation(origin = {4, 16}, extent = {{-3, -3}, {3, 3}}, rotation = 0)));
  Modelica.Blocks.Sources.Constant TSetCooling(k = 297.15)  annotation(
    Placement(visible = true, transformation(origin = {4, 6}, extent = {{-3, -3}, {3, 3}}, rotation = 0)));

  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirWall1(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-38, 8}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirWall2(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-38, -20}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirWall3(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-38, -44}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirWall4(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-38, -70}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirCeiling(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-38, 32}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirWindow(T(fixed = true))  annotation(
    Placement(visible = true, transformation(origin = {-70, -4}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirDoor(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-74, -88}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  BuildingSystems.Buildings.Surfaces.SurfaceToAir surfaceToAirBottom(T(fixed = true)) annotation(
    Placement(visible = true, transformation(origin = {-40, 56}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));

equation

  nNutzer = Modelica.Math.Special.erfc((time - 25200)/2000) + 1000 * Modelica.Math.Distributions.Normal.density(time, mu=43200, sigma=1000) + Modelica.Math.Special.erf((time - 61200)/2000) + 1;
  //random number generator einfuegen * Modelica.Math.Random.Generators.Xorshift64star.random(Modelica.Math.Random.Generators.Xorshift64star.initialState(  614657, 30020))
  CO2AustossNutzer = C_CO2Atmen * Vdot_Atmen * nNutzer;
  Luftwechsel = CO2AustossNutzer / ((C_max - C_Zuluft) * Laenge * Breite * Hoehe);
  
  connect(bottom.toSurfacePort_2, zone.toConstructionPorts[8]) annotation(
    Line(points = {{-28, 56}, {28, 56}, {28, -4}}));
  connect(ceiling.toSurfacePort_2, zone.toConstructionPorts[1]) annotation(
    Line(points = {{-28, 32}, {-9, 32}, {-9, -4}, {28, -4}}));
  connect(wall1.toSurfacePort_2, zone.toConstructionPorts[2]) annotation(
    Line(points = {{-28, 8}, {-9, 8}, {-9, -4}, {28, -4}}));
  connect(wall2.toSurfacePort_2, zone.toConstructionPorts[4]) annotation(
    Line(points = {{-28, -20}, {-9, -20}, {-9, -4}, {28, -4}}));
  connect(wall3.toSurfacePort_2, zone.toConstructionPorts[5]) annotation(
    Line(points = {{-28, -44}, {-9, -44}, {-9, -4}, {28, -4}}));
  connect(wall4.toSurfacePort_2, zone.toConstructionPorts[7]) annotation(
    Line(points = {{-28, -70}, {28, -70}, {28, -4}}));
  connect(window.toSurfacePort_2, zone.toConstructionPorts[3]) annotation(
    Line(points = {{-46, -4}, {28, -4}}));
  connect(door.toSurfacePort_2, zone.toConstructionPorts[6]) annotation(
    Line(points = {{-52, -88}, {28, -88}, {28, -4}}));
  connect(TSetHeating.y, zone.T_setHeating) annotation(
    Line(points = {{7, 16}, {11.5, 16}, {11.5, 3}, {17, 3}}, color = {0, 0, 127}));
  connect(TSetCooling.y, zone.T_setCooling) annotation(
    Line(points = {{7, 6}, {9.5, 6}, {9.5, 1}, {17, 1}}, color = {0, 0, 127}));
  connect(ambience.TAirRef, zone.TAirAmb) annotation(
    Line(points = {{-110, 4}, {-126, 4}, {-126, -32}, {0, -32}, {0, -10}, {18, -10}, {18, -8}}, color = {0, 0, 127}));
  connect(ambience.xAir, zone.xAirAmb) annotation(
    Line(points = {{-110, 2}, {-124, 2}, {-124, -34}, {2, -34}, {2, -12}, {18, -12}, {18, -10}}, color = {0, 0, 127}));
  connect(surfaceToAirWall1.toConstructionPort, wall1.toSurfacePort_1) annotation(
    Line(points = {{-38, 8}, {-32, 8}, {-32, 8}, {-32, 8}}));
  connect(surfaceToAirWall2.toConstructionPort, wall2.toSurfacePort_1) annotation(
    Line(points = {{-38, -20}, {-32, -20}, {-32, -20}, {-32, -20}}));
  connect(surfaceToAirWall3.toConstructionPort, wall3.toSurfacePort_1) annotation(
    Line(points = {{-38, -44}, {-32, -44}, {-32, -44}, {-32, -44}}));
  connect(surfaceToAirWall4.toConstructionPort, wall4.toSurfacePort_1) annotation(
    Line(points = {{-38, -70}, {-32, -70}, {-32, -70}, {-32, -70}}));
  connect(surfaceToAirCeiling.toConstructionPort, ceiling.toSurfacePort_1) annotation(
    Line(points = {{-38, 32}, {-32, 32}, {-32, 32}, {-32, 32}}));
  connect(surfaceToAirWindow.toConstructionPort, window.toSurfacePort_1) annotation(
    Line(points = {{-69, -4}, {-50, -4}}));
  connect(surfaceToAirDoor.toConstructionPort, door.toSurfacePort_1) annotation(
    Line(points = {{-73, -88}, {-56, -88}}));
  connect(ambience.toSurfacePorts[1], surfaceToAirCeiling.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, 36}, {-38, 36}, {-38, 36}}));
  connect(ambience.toSurfacePorts[2], surfaceToAirWall1.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, 12}, {-38, 12}, {-38, 12}}));
  connect(ambience.toSurfacePorts[3], surfaceToAirWindow.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-71, 0}}));
  connect(ambience.toSurfacePorts[4], surfaceToAirWall2.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, -16}, {-38, -16}, {-38, -16}}));
  connect(ambience.toSurfacePorts[5], surfaceToAirWall3.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, -40}, {-38, -40}, {-38, -40}}));
  connect(ambience.toSurfacePorts[6], surfaceToAirDoor.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, -84}, {-75, -84}}));
  connect(ambience.toSurfacePorts[7], surfaceToAirWall4.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, -66}, {-38, -66}, {-38, -66}}));
  connect(ambience.toAirPorts[1], surfaceToAirCeiling.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, 28}, {-38, 28}, {-38, 28}}));
  connect(ambience.toAirPorts[2], surfaceToAirWall1.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, 4}, {-38, 4}, {-38, 4}}));
  connect(ambience.toAirPorts[3], surfaceToAirWindow.toAirPort) annotation(
    Line(points = {{-92, -8}, {-71, -8}}));
  connect(ambience.toAirPorts[4], surfaceToAirWall2.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, -24}, {-38, -24}, {-38, -24}}));
  connect(ambience.toAirPorts[6], surfaceToAirDoor.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, -92}, {-75, -92}}));
  connect(ambience.toAirPorts[7], surfaceToAirWall4.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, -74}, {-38, -74}, {-38, -74}}));
  connect(surfaceToAirBottom.toConstructionPort, bottom.toSurfacePort_1) annotation(
    Line(points = {{-38, 56}, {-32, 56}, {-32, 56}, {-32, 56}}));
  connect(ambience.toSurfacePorts[8], surfaceToAirBottom.toSurfacesPort) annotation(
    Line(points = {{-92, 0}, {-88, 0}, {-88, 60}, {-38, 60}, {-38, 60}}));
  connect(ambience.toAirPorts[8], surfaceToAirBottom.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, 52}, {-38, 52}, {-38, 52}}));
  connect(ambience.toAirPorts[5], surfaceToAirWall3.toAirPort) annotation(
    Line(points = {{-92, -8}, {-84, -8}, {-84, -48}, {-38, -48}, {-38, -48}}));
//31536000s = 1 Jahr, 86400s = 1 Tag
  connect(door.port_b1, zone.airpathPorts[1]) annotation(
    Line(points = {{-52, -82}, {-2, -82}, {-2, 26}, {18, 26}, {18, 8}, {22, 8}}, color = {0, 127, 255}));
  connect(window.port_b1, zone.airpathPorts[2]) annotation(
    Line(points = {{-46, 2}, {-42, 2}, {-42, -2}, {-6, -2}, {-6, 30}, {22, 30}, {22, 8}}, color = {0, 127, 255}));
  connect(window.port_a2, zone.airpathPorts[3]) annotation(
    Line(points = {{-46, -10}, {-42, -10}, {-42, -6}, {-4, -6}, {-4, 28}, {20, 28}, {20, 8}, {22, 8}}, color = {0, 127, 255}));
  connect(door.port_a2, zone.airpathPorts[4]) annotation(
    Line(points = {{-52, -94}, {-8, -94}, {-8, 32}, {24, 32}, {24, 8}, {22, 8}}, color = {0, 127, 255}));
  connect(ambience.toAirpathPorts[1], door.port_a1) annotation(
    Line(points = {{-96, 6}, {-56, 6}, {-56, -82}, {-56, -82}}, color = {0, 127, 255}));
  connect(ambience.toAirpathPorts[2], door.port_b2) annotation(
    Line(points = {{-96, 6}, {-64, 6}, {-64, -94}, {-56, -94}, {-56, -94}}, color = {0, 127, 255}));
  connect(ambience.toAirpathPorts[3], window.port_a1) annotation(
    Line(points = {{-96, 6}, {-54, 6}, {-54, 2}, {-50, 2}, {-50, 2}}, color = {0, 127, 255}));
  connect(ambience.toAirpathPorts[4], window.port_b2) annotation(
    Line(points = {{-96, 6}, {-54, 6}, {-54, -10}, {-50, -10}, {-50, -10}}, color = {0, 127, 255}));
  annotation(experiment(StartTime=0, StopTime=86400),
    uses(BuildingSystems(version = ""2.0.0-beta""), Modelica(version = ""3.2.3"")));
end Wohncontainer;

}}}
Currently I am getting the following Error, when trying to simulate:

{{{
... loading ""tab1"" from ""F:\OpenModelica\lib\omlibrary\BuildingSystems 2.0.0-beta\Climate\weather\Germany_Berlin.txt""

Wohncontainer_functions.c:196: Invalid root: (-4.409e-016)^(0.4)
simulation terminated by an assertion at initialization
Simulation process failed. Exited with code -1.
}}}
 When I simulate in Debug-mode, it outputs the following:

{{{
stdout            | info    | ... loading ""tab1"" from ""F:\OpenModelica\lib\omlibrary\BuildingSystems 2.0.0-beta\Climate\weather\Germany_Berlin.txt""
assert            | debug   | F:/OpenModelica/lib/omlibrary/BuildingSystems 2.0.0-beta/Buildings/Functions/vWind.mo:16: Invalid root: (-4.409e-016)^(0.4)
assert            | info    | simulation terminated by an assertion at initialization
You can't do that without a process to debug.
}}}

I hope that someone can help me with this.
"	defect	new	critical		Run-time	v1.14.1			Andreas Heuermann Karim Adbdelhak Lennart Ochel
