﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4747	Treatment of singular equation systems in source code FMUs	Rüdiger Franke	Martin Sjölund	"OMCompiler comes with the LAPACK solver `3rdParty/dgesv` that ""is based on https://github.com/sjoelund/dgesv""

This enables the solution of linear equation systems with a call of the form:
{{{#!C++
  dgesv_(&_dimSys, &dimRHS, _A, &_dimSys, _ihelpArray, _b, &_dimSys, &irtrn);

  if (irtrn != 0) {
    throw ModelicaSimulationError(ALGLOOP_SOLVER, ""error solving linear system (dgesv info: "" + to_string(irtrn) + "")"");
  }
}}}

Solvers of the simulation runtimes are able to treat such errors. This is useful in cases where equation systems become singular due to switches inside a model, if parts of the model disappear and the respective variables shall become zero.

FMUs should also treat such errors. LAPACK offers the additional functions `dgetc2` and `dgesc2` for this:

{{{#!C++
    dgesv_(&_dimSys, &dimRHS, _A, &_dimSys, _ihelpArray, _b, &_dimSys, &irtrn);

    if  (irtrn != 0) {
      dgetc2_(&_dimSys, _A, &_dimSys, _ihelpArray, _jhelpArray, &irtrn);
      dgesc2_(&_dimSys, _A, &_dimSys, _b, _ihelpArray, _jhelpArray, _scale);
      LOGGER_WRITE(""LinearSolver: Linear system singular, using perturbed system matrix."", LC_LS, LL_DEBUG);
    }
}}}

Please extend 3rdParty/dgesv with the the functions `dgetc2` and `dgesc2`."	enhancement	closed	high	1.13.0	Build Environment	v1.13.0-dev-nightly	fixed		
