Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle units of literal constants by means of rules for the empty unit #3257

Open
wants to merge 26 commits into
base: MCP/0027
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7524b11
Initial commit of ReadMe.md for MCP-0027
henrikt-ma Oct 4, 2022
1309d10
Handle units of literal constants by means of rules for the empty unit
henrikt-ma Oct 4, 2022
2dfb4e8
Clarify that all operands of additive operators need to have the same…
henrikt-ma Oct 5, 2022
0c62f41
Clarify "component references outside functions"
henrikt-ma Oct 5, 2022
203c16e
Fix small mistake in example
henrikt-ma Oct 5, 2022
5d42065
Change "common sense" -> "(standard) dimensional analysis"
henrikt-ma Oct 5, 2022
fc4abde
Add section with examples of "standard dimensional analysis"
henrikt-ma Oct 5, 2022
b86567b
Fix minor typo
henrikt-ma Oct 5, 2022
1f5131c
Put quotes around 'standard dimensional analysis'
henrikt-ma Oct 5, 2022
3291a73
Say "multiplying the operands' units"
henrikt-ma Oct 5, 2022
f639afc
Make use of terminology 'dimensional homogenity'
henrikt-ma Oct 5, 2022
3a3b1f0
Don't present lists as "Examples of...", but add "other" item at the end
henrikt-ma Oct 26, 2022
e411347
Say "reject or approve"
henrikt-ma Oct 26, 2022
f3755a2
Add missing "on"
henrikt-ma Oct 26, 2022
fccda32
Reformulate "In some cases"
henrikt-ma Oct 26, 2022
89092ba
Change 'can be' -> 'is'
henrikt-ma Oct 26, 2022
82bb062
Fix typo in comment
henrikt-ma Oct 26, 2022
99ff3c9
Describe unit propagation and elaborate bottom-up nature of unit deri…
henrikt-ma Oct 26, 2022
13529f7
Also describe unit mappings of transcendental functions to match othe…
henrikt-ma Oct 31, 2022
847e645
Change 'are expected to' -> 'should'
henrikt-ma Nov 1, 2022
ebfc229
Add example illustrating bottom-up nature of unit inference
henrikt-ma Nov 1, 2022
232c4fa
Make stronger statement about when unit inference takes place
henrikt-ma Nov 1, 2022
9aeb15f
Change example on undefined unit to user-defined function instead of …
henrikt-ma Nov 2, 2022
a28b795
Simplify proposal by not omitting rules concerning non-empty units
henrikt-ma Nov 2, 2022
089f554
Move 'Otherwise...' into item list
henrikt-ma Nov 7, 2022
35e4f01
Rule out unit inference for components with empty unit-attribute
henrikt-ma Nov 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion chapters/unitexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,45 @@ \section{The Syntax of Unit Expressions}\label{the-syntax-of-unit-expressions}
\section{Unit Checking}\label{unit-checking}

How to verify that units are used in compatible ways is current not fully determined by the specification.
This section gives rules for certain situations, but in general tools are expected to reason according to standard dimensional analysis (from here on referred to as just \firstuse{dimensional analysis}).
This section gives rules for certain situations, but in general tools are expected to reason according to standard dimensional analysis..


\subsection{Standard Dimensional Analysis}\label{standard-dimensional-analysis}

This section gives an incomplete characterization of \emph{standard dimensional analysis}, also referred to as just \firstuse{dimensional analysis}.
What is described below applies to unit checking in Modelica -- \emph{standard dimensional analysis} could have additional meanings in other contexts.
While Modelica has a concept of \willintroduce{empty units} (described in later sections), standard dimensional analysis only deals with non-empty units such as \lstinline!"m"!, \lstinline!"m/s"!, or \lstinline!"1"!.
It consists of two parts:
\begin{itemize}
\item
Unit compatibility requirements.
\item
Rules for deriving the unit of an expression.
\end{itemize}

Examples of unit compatibility requirements that must be met in Modelica:
henrikt-ma marked this conversation as resolved.
Show resolved Hide resolved
\begin{itemize}
\item
The expression of a declaration equation must have the same unit as the component to which it belongs.
\item
The two sides of an equation or assignment statement must have the same unit.
henrikt-ma marked this conversation as resolved.
Show resolved Hide resolved
\item
The two operands of the additive operators \lstinline!+! and \lstinline!-! must have the same unit.
\item
In a function call, the unit of an argument expression must match the unit (unless empty, see below) of the corresponding function input component.
\end{itemize}

% TODO: Replace these examples by giving unit semantics where operators and built-in functions are defined in the specification,
% and just include some likes to places where such semantics are given.
Examples of unit derivation in Modelica:
\begin{itemize}
\item
The result of additive operators has the same unit as the operands.
\item
The result of multiplication has a unit obtained by adding the exponents of the operands' units.
henrikt-ma marked this conversation as resolved.
Show resolved Hide resolved
\item
Built-in operators such as \lstinline!pre! and \lstinline!previous! preserve units, while \lstinline!der! changes the unit by dividing it by \lstinline!"s"!.
\end{itemize}


\subsection{Empty and Undefined Units}\label{empty-and-undefined-units}
Expand Down