Code Monkey home page Code Monkey logo

qss-solver's Introduction

QSS Solver 4.3.0

The QSS Solver is a modeling and simulation environment for continuous and hybrid systems and it's optimized for large scale model simulation. The solver is implemented as a set of modules coded in plain C language, simulations can be performed using one of the following integration methods:

  • QSS methods (the entire family is supported)
  • DASSL
  • DOPRI
  • CVODE
  • IDA

Models are described using a subset of the standard Modelica language called μ–Modelica (the language specification can be found here), the compiler extracts all the structural information needed and automatically generates the plain C code that contains an appropiate model definition needed by the QSS Solver engine together with all the configuration files (makefiles, config, etc.).

The QSS Solver has a simple GUI interface that allows the end-user to access all the developed tools in a unified way.

The GUI has the following features:

  • It has a text editor, where models in μ-Modelica can be defined.
  • It invokes the corresponding tools to compile and run simulations.
  • It provides debug information in case of errors during the model generation.
  • It invokes GnuPlot to plot the simulation output trajectories.
  • It shows statistics about simulations (number of steps, simulation time, etc.).

Related Publications

[8] Ernesto Kofman, Joaquin Fernandez, Denise Marzorati. Compact sparse symbolic Jacobian computation in large systems of ODEs Applied Mathematics and Computation

[7] Franco Di Pietro, Joaquin Fernandez, Gustavo Migoni, Ernesto Kofman. Mixed-mode state–time discretization in ODE numerical integration Journal of Computational and Applied Mathematics

[6] Gustavo Migoni, Ernesto Kofman, Federico Bergero, Joaquin Fernandez. Quantization-based simulation of switched mode power supplies Simulation

[5] Federico Bergero, Joaquin Fernandez, Ernesto Kofman, Margarita Portapila. Time discretization versus state quantization in the simulation of a one-dimensional advection–diffusion–reaction equation Simulation

[4] Federico Bergero, Francesco Casella, Ernesto Kofman, Joaquin Fernandez. On the efficiency of quantization-based integration methods for building simulation Building Simulation

[3] Joaquin Fernandez, Ernesto Kofman, Federico Bergero. A parallel Quantized State System Solver for ODEs Journal of Parallel and Distributed Computing

[2] Federico Bergero, Xenofon Floros, Joaquin Fernandez, Ernesto Kofman, Francois Cellier. Simulating Modelica models with a Stand–Alone Quantized State Systems Solver Proceedings of the 9th International Modelica Conference

[1] Joaquin Fernandez, Ernesto Kofman. A stand-alone quantized state system solver for continuous system simulation Simulation

Components

MicroModelica Compiler

The MicroModelica compiler allows the user to describe models using a subset of the standard Modelica language called μ–Modelica (the language specification can be found here), the compiler extracts all the structural information needed and automatically generates the plain C code that contains an appropiate model definition needed by the QSS Solver engine together with all the configuration files (makefiles, config, etc.). The compiler documentation can be found here

QSS Engine

The QSS Engine is a library that allows the simulation of continuous and hybrid systems and it's optimized for large scale model simulation. The solver is implemented as a set of modules coded in plain C language, where the simulated models can contain time and state discontinuities. Simulations can be performed using one of the following integration methods:

  • QSS methods (the entire family is supported)
  • DASSL
  • DOPRI
  • CVODE
  • IDA

In order to obtain an executable model, a plain C file that contains the following functions must be provided:

  • Model definition.
  • Model settings.
  • Model dependencies (for QSS methods).
  • Model Jacobian.
  • Model zero-crossing function.
  • Model event handlers.
  • A function in charge of the simulator data structure initialization.

The signature of these functions and the data structures that are used depends on the integration method used and they can ve viewed here

Finally, the file containing the model has to be compiled and linked with the engine library.

QSS Solver GUI

The QSS Solver GUI is a simple interface that allows the end-user of the QSS Solver to access all the developed tools in a unified way.

The GUI has the following features:

  • It has a text editor, where models in μ-Modelica can be defined.
  • It invokes the corresponding tools to compile and run simulations.
  • It provides debug information in case of errors during the model generation.
  • It invokes GnuPlot to plot the simulation output trajectories.
  • It shows statistics about simulations (number of steps, simulation time, etc.).

The GUI documentation can be found here

Distributed MicroModelica User Packages

MicroModelica packages with math helper functions and file manipulation functions that uses the C user libraries described bellow.

These packages are included in qss-solver, so that in order to use them no aditional annotation has to be used (such as package location, include paths, etc), just import the package into the corresponding model.

Available packages:

  • math.mo: That contains math utility functions.
  • file.mo: That contains file manipulation functions.

Both files are located in the packages folder in the root install location.

C User Libraries

C libraries that contains helper functions used in MicroModelica packages. The Makefile included compiles the source files and generates the static library in the lib folder of the qss-solver. To compile a new user library, follow these steps:

  1. Put the header file in the include directory.

  2. Put the source file in the src directory.

  3. Add the source file and the target library name in the Makefile.

  4. Finally, run make to generate the corresponding static lib.

The generated lib is stored in the default path that the MMOC looks for, so the lib can be directly accesed from MicroModelica functions.

Installation

These are generic installation instructions.

Dependences

In order to be able to install and compile the QSS Solver, the following dependencies must be installed (Ubuntu 22.04):

  • bison++
  • libboost-dev (boost1.71 in Ubuntu 20.04)
  • cmake
  • g++
  • gfortran
  • gnuplot
  • libatlas-base-dev
  • libcln-dev
  • libconfig-dev
  • libginac-dev
  • libgsl-dev
  • libsbml5-dev
  • libscotch-dev
  • libsuitesparse-dev
  • pkgconf
  • qtbase5-dev qt5-qmake (qt5-default in Ubuntu 20.04)

Basic Installation

The simplest way to compile this package is:

  1. cd to the directory containing the package's source code (src) and type make to compile the binaries and libraries.

  2. Type make install to install all the binary files and the libraries. The binaries are located in the bin folder and the libraries are located in the lib folder.

  3. You can remove the program binaries and object files from the source code directory by typing make clean.

Makefile options

The makefile script accepts the following options:

  • MODE = <Debug|Release> When set to Debug (default), adds the compiler's debug flags.

Makefile targets

The makefile script accepts the following targets:

  • qss-engine: Builds the QSS solver libraries.
  • mmo-compiler: Builds the MicroModelica compiler.
  • qss-solver-gui: Builds the graphic interface.
  • qss-user-libs: Builds the user packages included in this distribution.
  • mmo-interfaces: Builds the SBML-MicroModelica translator.
  • qss-solver-doc: Builds the documentation for the QSS solver libraries, the MicroModelica compiler and the QSS solver GUI.

Changelog

[4.3.0] - 21-09-2022

Added

  • mLIQSS and mLIQSS2 methods are now supported.

Changed

  • Fixed input events code generation for non-autonomous equations.

Removed

  • mLIQSS3 is deprecated.

[4.2.1] - 28-06-2023

Added

  • Added mLIQSS article models to distribution.

Changed

  • Fix mLIQSS recompute next time to only update the Jacobian approximation when the influencer is a state variable.

Licensing

Please see the file called LICENSE.

Bug Reporting

Report bugs to: [email protected]

qss-solver's People

Contributors

fbergero avatar francodipietro avatar joaquinffernandez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qss-solver's Issues

Add Parallel macros, refactor.

Code that depends on PARALLEL flags should be refactored and we should use macros to define methods whenever possible.

Refactor util interface.

Although utils is not huge, there's a lot of different structures that may become difficult to find. We must define files/places and store the new files there.

Crash when output more than 1000 variables.

This happens in serial and parallel mode, when the maximum number of simultaneously open files for thread is reached, in this case, the output variables must be processed in batch mode to prevent this situation.

Events are evaluated in multiple LPs

When simulating in parallel mode using the linear scheduler, events can get evaluated in multiple LPs despite being owned by a single one. For certain models this situation may happen throughout the whole simulation, thus not only degrading performance but also possibly leading to unexpected behavior.

Steps to reproduce the bug
    Compile the built-in bbal_downstairs model in parallel mode with debug flags enabled, setting Parallel to TRUE (using two LPs) and choosing the linear scheduler.
    Open a debugger and place a breakpoint in the function MOD_zeroCrossing when the argument i equals 0 (i.e., the first event).
    Run the simulation and continue each time the breakpoint is hit. Among the first five hits you should see that both threads are evaluating this event.
Software in use
    QSS Solver v3.2 compiled from source (checked out in February, 2018)
    Compiler: gcc 5.4.0
    OS: Ubuntu 16.04 LTS
Other comments
    When initializing the data structures for a given LP, those events assigned to it are properly evaluated (see here).
    However, the remaining events are left uninitialized; their corresponding next times equal zero. Thus, they will be eventually scheduled and processed in the main integration loop.
    Considering this, a proposed fix is to add an else clause to this if statement and set the nextEventTime to INF.

Original issue: https://github.com/CIFASIS/qss-solver-engine/issues/34

Some questions about QSS Solver

Dear Dr. Bergero
I am a student. I am learning QSS method and using QSS Solver. However, I am not good at μ–Modelica.I was wondering if you have developed an extension of the OpenModelica compiler which converts models from Modelica to μ–Modelica. Moreover, I havn't had any specification about usage of QSS solver. Please give me some suggestions. Thank you for your time.

Potential issues when using fixed quantums.

Using fixed quantums (e.g. setting dQRel = 0 and dQMin > 0) may lead to crashes or to unexpected behavior as a consequence of how settings are parsed upon initialization. More information below:

Software in use
    QSS Solver v3.2 compiled from source (checked out in February, 2018)
    Compiler: gcc 5.4.0
    OS: Ubuntu 16.04 LTS
Other comments
    The issue seems to be caused by this line.
    When dQRel is zero, so will be sameDQRel, which in turn will lead to the execution of this for loop.
    Since nDQRel == 1, the array settings->dqrel has only one entry. Thus, the for loop will make as many out-of-bounds accesses as the number of state variables in the model.

Original issue: https://github.com/CIFASIS/qss-solver-engine/issues/37

Add non state algebraic dependencies to deps function.

Some variables has algebraics dependencies that are not computed by the deps algorithm (which is correct) since they don't depend on they states that affects them but they need to be added with the other dependencies of the state variables that they affect.

Generate HA matrix

Generate matrix of algebraic dependencies for discrete assignments in handlers.

Test function class array arguments.

Currently in the new version array arguments can be passed to function definitions but we don't have a full test for this feature. We should add this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.