NREL / SOEP-QSS-Test

0 stars 1 forks source link

QSS Solver Test Repository

This is a library of test models and results for development of the QSS solver being developed as part of the "Spawn of EnergyPlus" project. The library serves these purposes:

Models will be run as FMUs since the QSS solver is being built for integration into JModelica via the FMU interface. Some simpler models may also be run as QSS "code-defined" models for results and performance comparison.

Due to the size of model FMUs, modelDescription.xml, and output signal files this repository stores only scripts, models, and descriptive text files.

Organization

The top-level repository directory contains these subdirectories:

  bin/
  mdl/

bin

The bin directory contains scripts for modeling and testing:

bin Notes

mdl

The mdl directory contains the models and results with this (tentative) organization for each model:

ModelName/
  ModelName.mo       Modelica model
  ModelName.ref      Modelica or Buildings Library model name and, optionally, Buildings Library branch and/or commit
  ModelName.txt      Notes
  ModelName.var      Variables to output name list (supports glob wildcards and syntax)
  Dymola/            Dymola model & results
  JModelica/         JModelica model & results
  OCT/               OPTIMICA model & results
  Ptolemy/           Ptolemy model & results
  QSS/               QSS model & results

Each non-QSS modeling tool (OCT, JModelica, Dymola, and Ptolemy) sub-directory has this structure:

*Tool*/
  ModelName.txt                 Notes
  ModelName.mo                  Modelica model customized for Tool if needed
  ModelName.fmu                 FMU generated by Tool (with a modified XML inserted)
  modelDescription.orig.xml     Original FMU XML (if XML modifications needed)
  modelDescription.prep.xml     Modified FMU XML (if XML modifications needed)
  modelDescription.xml          XML from the FMU (after any modifications are made)
  out/                          Results
  run/                          Standard run results
  ref/                          Reference run results

Tools-specific versions of Modelica files include customization for that tool:

The QSS sub-directory has this structure:

QSS/
  ModelName.txt                 Notes
  ModelName.fmu                 Specialized FMU used for QSS runs if needed
  FMU-[LI]QSS#/                 FMU-QSS [LI]QSS# run
  [LI|x]QSS#/                   [LI|x]QSS# run

where # is 1, 2, or 3 indicating the QSS method order. The QSS subdirectories may have a custom run.py script with specialized options suggested or needed for the model. The FMU-QSS subdirectories have a run script that generates the FMU-QSS and then runs it with the QSS application.

The QSS2 method is currently the best choice in most circumstances (QSS3 performance and accuracy are limited due to numerical differentiation) so the other sub-directories may not be present. The LIQSS2 method is probably the best for "stiff" models. The first-order QSS1 and LIQSS1 methods are mostly of academic interest since they are very slow for most models.

Models

Tools

Notes on each of the modeling tools appear below.

OCT (OPTIMICA Compiler Toolkit)

JModelica

Dymola

Ptolemy

QSS

Notes

Issues

Usage

Building FMUs

OPTIMICA is the default Modelica tool for QSS now that it has event indicator and other QSS-specific support.

JModelica lacks this QSS support and is being retired but can still be used for limited QSS modeling so it is still supported here.

FMUs can be built directly from models in the Buildings Library by placing a ModelName.ref file alongside the ModelName.mo file. The ModelName.ref file is a text file with these lines:

Modelica or Buildings Library full model name
Buildings Library branch if not master (optional)
Buildings Library commit hash if not HEAD of branch (optional)

Here is the FloorOpenLoop.ref file:

Buildings.ThermalZones.EnergyPlus.Examples.VAVReheatRefBldgSmallOffice.FloorOpenLoop
issue1129_energyPlus_zone

This model exists in the issue1129_energyPlus_zone branch in the HEAD commit.

Models that are defined in the local .mo file but depend on a specific branch/commit of the Buildings library should use a ref file as above but with just Buildings in the first line.

Building FMUs with OPTIMICA

Run bld_fmu.py from the OCT sub-directory of the model's directory.

Building FMUs with JModelica

Run bld_fmu.py from the JModelica sub-directory of the model's directory.

Running FMUs

Running FMUs with PyFMI

Run run.py or run_PyFMI.py from the desired output sub-directory under the modeling tool sub-directory of the model's directory, such as MyModel/JModelica/out.

Running FMUs with QSS

Run run.py or run_QSS.py in each QSS method sub-directory of the model's QSS sub-directory. Custom run.py scripts may be present under QSS with recommended or needed QSS options for that model.

Notes:

Running JModelica-Generated FMUs with QSS

The use of JModelica-generated FMUs with QSS requires special treatment:

Comparison Testing PyFMI and QSS

The cmp_PyFMI_QSS.py script will run and compare the PyFMI and QSS simulations of the local model. In addition to passing PyFMI and QSS options through it accepts options such as:

The PyFMI and QSS runs are set to use only sampled output to aid in the automated comparison: sampled QSS output may not show key events accurately.

Comparison wrapper scripts, such as cmp_CVode_QSS3_Buildings.py, can be used to run the comparison on a set of models, including any desired custom options. By including RMS "pass" limits these can serve as a type of regression test to make sure that OCT and QSS updates do not cause unexpected solution discrepancies. The cmp_PyFMI_QSS_yaml.py script can compare the YAML results file from two comparison runs with an optional relative tolerance argument to use when comparing variable RMS differences.

Comparison Testing Different Modeling Tools

Run the comparison script from the tst sub-directory of the model's directory passing the directories of the two results to be compared, such as:

comparison ../OCT ../QSS/QSS2

This generates report (.rpt) files for each pair of signals compared, a summary (.sum) file listing the number of signal comparisons that pass and that fail, a 0-size pass (.pass) or fail (.fail) file, and PDFs with plots of signal pairs that fail, showing the signal overlay and difference plots.

Regression Testing Different Versions of a Modeling Tool

Run the regression script from the tst sub-directory of the model's directory passing the directories of the two results to be compared, such as:

regression ../QSS/QSS2/new ../QSS/QSS2

This generates report (.rpt) files for each pair of signals compared, a summary (.sum) file listing the number of signal comparisons that pass and that fail, a 0-size pass (.pass) or fail (.fail) file, and PDFs with plots of signal pairs that fail, showing the signal overlay and difference plots.