#3732 closed defect (worksforme)
Segmentation fault at zero mass flow rate
Reported by: | Michael Wetter | Owned by: | somebody |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | *unknown* | Version: | v1.9.4-dev-nightly |
Keywords: | Cc: |
Description
The following example gives a segmentation fault:
Run
export OPENMODELICALIBRARY=`pwd`:/usr/lib/omlibrary omc +d=nogen,initialization,backenddaeinfo,discreteinfo,stateselection openmod.mos
with openmod.mos
containing
loadModel(Modelica, {"3.2.1"}); getErrorString(); loadModel(Buildings); getErrorString(); simulate(Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU); getErrorString();
The output is
record SimulationResult resultFile = "", simulationOptions = "startTime = 0.0, stopTime = 360.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", messages = "Simulation execution failed for model: Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU assert | debug | division by zero at time 0.72, (a=0) / (b=0), where divisor b expression is: hexPar.m2_flow assert | debug | division by zero at time 0, (a=0) / (b=0), where divisor b expression is: hexPar.m2_flow Limited backtrace at point of segmentation fault /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340)[0x7f4c7d71c340] /lib/x86_64-linux-gnu/libc.so.6(_longjmp+0x10)[0x7f4c7d37db40] /lib/x86_64-linux-gnu/libpthread.so.0(+0xed69)[0x7f4c7d71ad69] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(throwStreamPrintWithEquationIndexes+0xfc)[0x7f4c7e9d39fc] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(+0x29a77)[0x7f4c7e9d3a77] /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU(Buildings_Fluid_HeatExchangers_Examples_DryEffectivenessNTU_eqFunction_1139+0x18d)[0x4782bd] /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU(Buildings_Fluid_HeatExchangers_Examples_DryEffectivenessNTU_functionDAE+0x8e2)[0x486ab2] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(updateDiscreteSystem+0x8d)[0x7f4c7ea0cbdd] /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU[0x46a744] /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU(Buildings_Fluid_HeatExchangers_Examples_DryEffectivenessNTU_performSimulation+0x574)[0x469c24] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(solver_main+0x17c)[0x7f4c7ea1433c] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(callSolver+0x2c9)[0x7f4c7ea36f49] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(startNonInteractiveSimulation+0x5c8)[0x7f4c7ea359c8] /usr/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(_main_SimulationRuntime+0x70)[0x7f4c7ea37fa0] /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings.Fluid.HeatExchangers.Examples.DryEffectivenessNTU(main+0x1f7)[0x487667] Segmentation fault (core dumped) ... [omitted]
Setting POut.k=101225
avoids zero mass flow rate, in which case there is no segmentation fault.
The model is from the latest version of the master
branch of Buildings
, e.g., https://github.com/lbl-srg/modelica-buildings/commit/d0841740172f2812891be5693a9cc4450e1327b8
Change History (4)
follow-up: 2 comment:1 by , 9 years ago
comment:2 by , 9 years ago
Replying to anonymous:
How about
if noEvent(hexPar.m2_flow > 0) then a/b else k_start
Can you be a bit more specific? I see no k_start
. Do you suggest this to be in the model, or in the generated code, and if in the model, where did you find k_start
?
comment:3 by , 7 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
As of OMCompiler v1.12.0-dev.195+gd2bbe7a the following outcome is reported:
assert | division by zero at time 0.07199999999999999, (a=0) / (b=0), where divisor b expression is: hexCroUnm.m2_flow
I don't know if this is the expected result, but at least there is no longer a segfault.
comment:4 by , 7 years ago
I believe this comes from the code below
/* equation index: 1935 type: SIMPLE_ASSIGN hexPar._port_b2._h_outflow = sou_2.ports[5].h_outflow + DIVISION(hexPar.Q2_flow, hexPar.m2_flow) */ void Buildings_Fluid_HeatExchangers_Examples_DryEffectivenessNTU_eqFunction_1935(DATA *data, threadData_t *threadData) { TRACE_PUSH const int equationIndexes[2] = {1,1935}; data->localData[0]->realVars[301] /* hexPar._port_b2._h_outflow variable */ = data->localData[0]->realVars[353] /* sou_2._ports[5]._h_outflow variable */ + DIVISION_SIM(data->localData[0]->realVars[262] /* hexPar._Q2_flow variable */,data->localData[0]->realVars[295] /* hexPar._m2_flow variable */,"hexPar.m2_flow",equationIndexes); TRACE_POP }
Both arguments of the DIVISION
macro are zero. It would be good if OpenModelica could propagate the specific enthalpy if there is zero flow. Zero flow rate is common for initialization of fluid flow models in building applications.
How about