From 16be3880b2bb1804207803bfc3da3359df5f917e Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Tue, 23 Apr 2024 07:41:29 -0700 Subject: [PATCH] Issue3809 add sort output backward compatible (#3813) * updated sort block * Added output yIdx to CDL.Reals.Sort This is a backward compatible version of https://github.com/lbl-srg/modelica-buildings/pull/3810 --------- Co-authored-by: JayHuLBL --- Buildings/Controls/OBC/CDL/Reals/Sort.mo | 20 ++++++++--- ...Controls_OBC_CDL_Reals_Validation_Sort.txt | 34 ++++++++++++------- .../OBC/CDL/Reals/Validation/Sort.mos | 10 ++++-- ...Controls.OBC.CDL.Reals.Validation.Sort.mos | 12 ++++++- .../Controls/StagingRotation/SortRuntime.mo | 6 ++-- .../Validation/EquipmentEnable.mo | 4 +-- .../UsersGuide/ReleaseNotes/Version_11_0_1.mo | 8 ++++- 7 files changed, 67 insertions(+), 27 deletions(-) diff --git a/Buildings/Controls/OBC/CDL/Reals/Sort.mo b/Buildings/Controls/OBC/CDL/Reals/Sort.mo index 1ba7b3a4bad..0894cf6d076 100644 --- a/Buildings/Controls/OBC/CDL/Reals/Sort.mo +++ b/Buildings/Controls/OBC/CDL/Reals/Sort.mo @@ -13,11 +13,15 @@ block Sort Buildings.Controls.OBC.CDL.Interfaces.RealOutput y[nin] "Connector of Real output signals" annotation (Placement(transformation(extent={{100,-20},{140,20}}))); - + Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yIdx[nin] + "Indices of the sorted vector with respect to the original vector" + annotation (Placement(transformation(extent={{100,-80},{140,-40}}), + iconTransformation(extent={{100,-80},{140,-40}}))); equation - y=Modelica.Math.Vectors.sort( + (y, yIdx)=Modelica.Math.Vectors.sort( u, ascending=ascending); + annotation ( defaultComponentName="sort", Icon( @@ -42,10 +46,12 @@ equation info="

Block that sorts the elements of the input signal u. -If the parameter ascending = true, then the output signal satisfies +If the parameter ascending = true, then the output signal y satisfies yi <= yi+1 for all i ∈ {1, ..., n-1}. Otherwise, it satisfies yi >= yi+1 for all i ∈ {1, ..., n-1}. +The output signal yIdx contains the indices of the sorted elements, +with respect to the input vector u.

Usage

@@ -62,10 +68,14 @@ In real controllers, measurement noise may cause the output to change frequently This block may for example be used in a variable air volume flow controller to access the position of the dampers that are most open.

-", - revisions=" +", revisions="