Add commonly used Blocks and Interfaces
During development of our Modelica libraries, we centralize commonly used models and interfaces in the "DymolaModels" library, which is shipped with Dymola. Some of these models are so common that we want to give them back for the MSL.
Summary by CodeRabbit
- New Features
- Introduced multiple new control blocks offering varied input/output configurations for continuous systems.
- Added an intelligent switching component to selectively route integer signals based on conditions.
- Enhanced mathematical operations with blocks for computing scalar products and normalizing vectors.
- Expanded nonlinear processing with components for output protection and smooth interpolation transitions.
- Updated test models and reference data files to support and validate these new capabilities.
Thanks for the PR. Can you please resolve the few issues reported by the static checks, see https://github.com/modelica/ModelicaStandardLibrary/pull/4518/files.
Sure! All checks should pass now and I rebased the branch on current master.
Walkthrough
This pull request introduces several new blocks and models across the Modelica library. In the Interfaces, Logical, Math, and Nonlinear packages, new blocks are added to support various continuous control interfaces, integer signal switching, vector operations, and nonlinear signal shifting. Additionally, new test models are added to ModelicaTest to demonstrate and verify the functionality of these blocks, along with reference comparison files for simulation validation. The changes extend the modeling capabilities and testing framework without modifying existing interfaces or logic.
Changes
| File(s) | Change Summary |
|---|---|
Modelica/Blocks/Interfaces.mo |
Added partial blocks: SI2SO2, SI2MO, and MI2SO defining new continuous control interfaces with multiple inputs and outputs. |
Modelica/Blocks/Logical.mo |
Added IntegerSwitch block with two integer inputs, one boolean input, and one integer output, implementing conditional switching logic with icon annotations. |
Modelica/Blocks/Math.mo |
Added ScalarProduct block for dot product of two vectors and NormalizeVector block for vector normalization with parameters, equations, and icons. |
Modelica/Blocks/Nonlinear.mo |
Added ZeroProtection, LinearShifter, SinSquareShifter, and VariableLinearShifter blocks to provide nonlinear and linear signal shifting and protection functionalities. |
ModelicaTest/Blocks.mo |
Added test models Shifters, Vectors, and IntegerSwitch demonstrating usage of new blocks with experiment annotations. |
ModelicaTest/Resources/Reference/.../comparisonSignals.txt |
Added new reference files listing expected output signals for IntegerSwitch, Shifters, and Vectors test models to support simulation result comparisons. |
Sequence Diagram(s)
sequenceDiagram
participant BoolStep as BooleanStep
participant IntStep as IntegerStep
participant Clock as ContinuousClock
participant IntSwitch as IntegerSwitch
participant R2I as RealToInteger
BoolStep->>IntSwitch: Provide boolean input (u2)
IntStep->>IntSwitch: Provide integer input (u3)
Clock->>R2I: Provide timing signal
R2I->>IntSwitch: Provide integer input (u1)
IntSwitch->>IntSwitch: Switch output y based on u2 condition
sequenceDiagram
participant Sine as Sine Generator
participant ConstPos as Constant (positive)
participant ConstNeg as Constant (negative)
participant ZeroProt as ZeroProtection
participant LinShift as LinearShifter
participant SinSqShift as SinSquareShifter
participant VarLinShift as VariableLinearShifter
Sine->>ZeroProt: Input signal u
Sine->>LinShift: Input signal u
Sine->>SinSqShift: Input signal u
Sine->>VarLinShift: Normalized input u
ConstPos->>VarLinShift: Input u1
ConstNeg->>VarLinShift: Input u2
sequenceDiagram
participant Sine as Sine Generator
participant Const1 as Constant 1
participant Const2 as Constant 2
participant Mux3 as Multiplex3
participant Mux2 as Multiplex3 (second)
participant Scalar as ScalarProduct
participant Norm as NormalizeVector
Sine->>Mux3: Input vector component
Const1->>Mux3: Input vector component
Sine->>Mux2: Input vector component
Const2->>Mux2: Input vector component
Mux3->>Scalar: Vector input u1
Mux2->>Scalar: Vector input u2
Scalar->>Norm: Vector output y
Poem
🐇 In fields of code where signals play,
New blocks arise to light the way.
Switches flip and vectors glide,
Shifters dance with graceful stride.
Protection guards the zero line,
Math and logic all align.
Hop along, the future’s fine! 🌟
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@m-kormann thank you for your contribution! We are planning to deploy a CI & testing infrastructure for MSL, to avoid ending up with a nighmare scenario of regressions and issues when we are getting close to the release date. We still have to decide on a policy for new commits on the master branch. Ideally, we should allow it when the CI is ready. Maybe this will take too much time, so we'll handle this manually.