Skip to content

Commit 1a1bc40

Browse files
authored
Merge pull request #621 from Systems-Modeling/ST6RI-606
ST6RI-606 Code generator tooling for ISQ, SI, US Customary Units libraries
2 parents c3f455e + 7c45184 commit 1a1bc40

40 files changed

Lines changed: 36824 additions & 0 deletions
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
### ================== generated with https://www.gitignore.io/
2+
3+
# Created by https://www.gitignore.io/api/python
4+
# Edit at https://www.gitignore.io/?templates=python
5+
6+
### Python ###
7+
# Byte-compiled / optimized / DLL files
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
12+
# C extensions
13+
*.so
14+
15+
# Distribution / packaging
16+
.Python
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib/
24+
lib64/
25+
parts/
26+
sdist/
27+
var/
28+
wheels/
29+
pip-wheel-metadata/
30+
share/python-wheels/
31+
*.egg-info/
32+
.installed.cfg
33+
*.egg
34+
MANIFEST
35+
36+
# PyInstaller
37+
# Usually these files are written by a python script from a template
38+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
39+
*.manifest
40+
*.spec
41+
42+
# Installer logs
43+
pip-log.txt
44+
pip-delete-this-directory.txt
45+
46+
# Unit test / coverage reports
47+
htmlcov/
48+
.tox/
49+
.nox/
50+
.coverage
51+
.coverage.*
52+
.cache
53+
nosetests.xml
54+
coverage.xml
55+
*.cover
56+
.hypothesis/
57+
.pytest_cache/
58+
59+
# Translations
60+
*.mo
61+
*.pot
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# pyenv
73+
.python-version
74+
75+
# pipenv
76+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
77+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
78+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
79+
# install all needed dependencies.
80+
#Pipfile.lock
81+
82+
# celery beat schedule file
83+
celerybeat-schedule
84+
85+
# SageMath parsed files
86+
*.sage.py
87+
88+
# Spyder project settings
89+
.spyderproject
90+
.spyproject
91+
92+
# Rope project settings
93+
.ropeproject
94+
95+
# Mr Developer
96+
.mr.developer.cfg
97+
.project
98+
.pydevproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
.dmypy.json
106+
dmypy.json
107+
108+
# Pyre type checker
109+
.pyre/
110+
111+
# End of https://www.gitignore.io/api/python
112+
113+
114+
# Created by https://www.gitignore.io/api/pycharm
115+
# Edit at https://www.gitignore.io/?templates=pycharm
116+
117+
### PyCharm ###
118+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
119+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
120+
121+
# User-specific stuff
122+
.idea/**/workspace.xml
123+
.idea/**/tasks.xml
124+
.idea/**/usage.statistics.xml
125+
.idea/**/dictionaries
126+
.idea/**/shelf
127+
128+
# Generated files
129+
.idea/**/contentModel.xml
130+
131+
# Sensitive or high-churn files
132+
.idea/**/dataSources/
133+
.idea/**/dataSources.ids
134+
.idea/**/dataSources.local.xml
135+
.idea/**/sqlDataSources.xml
136+
.idea/**/dynamic.xml
137+
.idea/**/uiDesigner.xml
138+
.idea/**/dbnavigator.xml
139+
140+
# Gradle
141+
.idea/**/gradle.xml
142+
.idea/**/libraries
143+
144+
# Gradle and Maven with auto-import
145+
# When using Gradle or Maven with auto-import, you should exclude module files,
146+
# since they will be recreated, and may cause churn. Uncomment if using
147+
# auto-import.
148+
# .idea/modules.xml
149+
# .idea/*.iml
150+
# .idea/modules
151+
# *.iml
152+
# *.ipr
153+
154+
# CMake
155+
cmake-build-*/
156+
157+
# Mongo Explorer plugin
158+
.idea/**/mongoSettings.xml
159+
160+
# File-based project format
161+
*.iws
162+
163+
# IntelliJ
164+
out/
165+
166+
# mpeltonen/sbt-idea plugin
167+
.idea_modules/
168+
169+
# JIRA plugin
170+
atlassian-ide-plugin.xml
171+
172+
# Cursive Clojure plugin
173+
.idea/replstate.xml
174+
175+
# Crashlytics plugin (for Android Studio and IntelliJ)
176+
com_crashlytics_export_strings.xml
177+
crashlytics.properties
178+
crashlytics-build.properties
179+
fabric.properties
180+
181+
# Editor-based Rest Client
182+
.idea/httpRequests
183+
184+
# Android studio 3.1+ serialized cache file
185+
.idea/caches/build_file_checksums.ser
186+
187+
### PyCharm Patch ###
188+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
189+
190+
.idea/**/*.iml
191+
modules.xml
192+
.idea/misc.xml
193+
*.ipr
194+
195+
# Sonarlint plugin
196+
.idea/**/sonarlint/
197+
198+
# SonarQube Plugin
199+
.idea/**/sonarIssues.xml
200+
201+
# Markdown Navigator plugin
202+
.idea/**/markdown-navigator.xml
203+
.idea/**/markdown-navigator/
204+
205+
# End of https://www.gitignore.io/api/pycharm
206+
207+
# Temporary MS Office files
208+
~*.*
209+
210+
.idea/**
211+
.idea
212+
*.log
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
= quantities_lib_generator
2+
3+
Author: Hans Peter de Koning, DEKonsult.
4+
5+
== Overview
6+
7+
This is a generator tool written in Python, that auto-generates the SysML v2 standard library packages for the ISO/IEC 80000 quantities and measurement references, in particular measurement units and coordinate frames.
8+
9+
The primary input is an Excel workbook (`data/iso-iec-80000/iso_iec_80000_quantities_and_units.xlsx`) that captures the ISQ quantities and as well as the SI measurement units defined in the ISO/IEC 80000 series of standards.
10+
11+
Note. ISQ stands for "International System of Quantities", and SI stands for "International System of Units".
12+
13+
A next release of the generator will also contain tools to generate the `USCustomaryUnits.sysml` standard library package based on the official definitions, including their official conversion factors, as defined in NIST SP 811 Annex B.
14+
15+
== Mathematical notation
16+
17+
In order to properly express symbols, definitions and remarks for quantities and measurement units, and stay close to the standards from which the definitions originate, it is highly desirable to support established mathematical notation.
18+
19+
For the SysML source code in this library, the syntax and conventions as defined hereafter are adopted, striving for a balance between:
20+
21+
* simplicity and user readability
22+
* compatibility with the expression syntax in the SysML language
23+
* representation in typical text / programming language editors
24+
* suitability for rendering of high-quality documentation through use of mathematical rendering engines like https://www.mathjax.org[MathJax].
25+
26+
The selected notation for math and physics formulae is http://asciimath.org/[AsciiMath], inserted inside documentation comments between backticks, with the following additional conventions:
27+
28+
[arabic]
29+
. Descriptive subscripts are enclosed between double quotes, e.g. `X_"r"`, `Y_"max"`.
30+
. Variable subscripts are ungrouped when they are a single letter or digit, or else grouped using curly brackets, e.g. `x_i`, `int_t`, `int_{t_1}`.
31+
. Descriptive superscripts are enclosed between double quotes, e.g. `X^"T"`, `Y^"*"` and `Z_"max"^"prime"`.
32+
. Variable superscripts are ungrouped when they are a single letter or digit, or else grouped using parentheses if they are subexpressions, or using curly brackets if they are compound names, e.g. `x^2`, `y^(1/2)`, `z^{i*exp(t/τ)}`, `int^t` , `int^{t_"max"}`.
33+
. Vector quantities are denoted with an overhead arrow using `vec{x}`.
34+
. Tensor quantities are denoted with a double overhead arrow using `vec{vec{x}}`.
35+
. Partial derivatives are denoted using the LaTeX term, i.e., `{partial a}/{partial t}` rather than the http://asciimath.org/[AsciiMath] notation `{del a}/{del t}`.
36+
. Greek letters and math characters like ∞ for infinity are written directly in Unicode. The source code file is assumed to support Unicode characters, and the typical encoding is expected to be UTF-8.
37+
38+
== Development tools
39+
40+
This Python package was developed using the PyCharm tool by JetBrains, configured with _conda_ with its own environment for the latest _python v3.11_ interpreter.
41+
42+
Python version 3.11 was used. Since only vanilla Python is used it should run with any Python version 3.8 or higher.
43+
44+
The generator has been tested with Windows 11, but should run also on any MacOS or Linux operating system.
45+
46+
== Execution instructions
47+
48+
Run the generator and update the standard domain libraries
49+
50+
* Simplest is to run script `quantities_lib_generator.py` directly in the PyCharm IDE.
51+
** Before first use, configure PyCharm as follows:
52+
*** Via menu _File > Settings > Project > Python Interpreter_, select python v3.11 or higher using your favorite environment manager.
53+
*** Install module `openpyxl`, for interaction with Excel `.xlsx` files.
54+
** Open file `quantities_lib_generator.py` and run it by clicking the _run icon_ or selecting menu _Run_.
55+
* In case no IDE is used:
56+
** Ensure python v3.11 or higher is installed, and accessible via the command line.
57+
** Open a terminal and change the working directory to the `tool-support/quantities_lib_generator` folder.
58+
** Install module `openpyxl` e.g. using:
59+
+
60+
....
61+
$ pip install openpyxl
62+
....
63+
** Run the following command:
64+
+
65+
....
66+
$ python quantities_lib_generator.py
67+
....
68+
* The generated output will appear in folder `libs_generated`.
69+
* Inspect the generated `.sysml` standard library packages, and diff them against already existing packages in the `../../sysml.library/Domain Libraries/Quantities and Units` folder.
70+
* If found correct, then copy them to that target folder and commit to update the standard libraries.
Binary file not shown.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Data and dictionaries for use in several converters
3+
"""
4+
5+
greek_letter_dict = {
6+
"varepsilon": "ɛ",
7+
"vartheta": "ϑ",
8+
"varphi": "ϕ",
9+
"Gamma": "Γ",
10+
"Delta": "Δ",
11+
"Theta": "Θ",
12+
"Lambda": "Λ",
13+
"Xi": "Ξ",
14+
"Pi": "Π",
15+
"Sigma": "Σ",
16+
"Phi": "Φ",
17+
"Psi": "Ψ",
18+
"Omega": "Ω",
19+
"alpha": "α",
20+
"beta": "β",
21+
"gamma": "γ",
22+
"delta": "δ",
23+
"epsilon": "ε",
24+
"zeta": "ζ",
25+
"theta": "θ", # theta must go before eta to achieve correct replacement order
26+
"eta": "η",
27+
"iota": "ι",
28+
"kappa": "κ",
29+
"lambda": "λ",
30+
"mu": "μ",
31+
"nu": "ν",
32+
"xi": "ξ",
33+
"pi": "π",
34+
"rho": "ρ",
35+
"sigma": "σ",
36+
"tau": "τ",
37+
"upsilon": "υ",
38+
"phi": "φ",
39+
"chi": "χ",
40+
"psi": "ψ",
41+
"omega": "ω",
42+
}

0 commit comments

Comments
 (0)