pymoca 0.9.0__tar.gz → 0.9.2.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/MANIFEST.in +0 -1
  2. pymoca-0.9.2.dev0/PKG-INFO +128 -0
  3. pymoca-0.9.2.dev0/java/antlr-4.13.1-complete.jar +0 -0
  4. pymoca-0.9.2.dev0/pyproject.toml +66 -0
  5. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/setup.cfg +1 -8
  6. pymoca-0.9.2.dev0/setup.py +11 -0
  7. pymoca-0.9.2.dev0/src/pymoca/__init__.py +2 -0
  8. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/_version.py +4 -4
  9. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/api.py +8 -3
  10. pymoca-0.9.2.dev0/src/pymoca/generated/ModelicaLexer.py +454 -0
  11. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/generated/ModelicaListener.py +4 -2
  12. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/generated/ModelicaParser.py +660 -621
  13. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/generated/ModelicaVisitor.py +2 -2
  14. pymoca-0.9.2.dev0/src/pymoca.egg-info/PKG-INFO +128 -0
  15. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca.egg-info/SOURCES.txt +2 -2
  16. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca.egg-info/requires.txt +5 -7
  17. pymoca-0.9.0/PKG-INFO +0 -48
  18. pymoca-0.9.0/java/antlr-4.7-complete.jar +0 -0
  19. pymoca-0.9.0/setup.py +0 -147
  20. pymoca-0.9.0/src/pymoca/__init__.py +0 -4
  21. pymoca-0.9.0/src/pymoca/generated/ModelicaLexer.py +0 -507
  22. pymoca-0.9.0/src/pymoca.egg-info/PKG-INFO +0 -48
  23. pymoca-0.9.0/versioneer.py +0 -1822
  24. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/LICENSE +0 -0
  25. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/README.md +0 -0
  26. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/.gitignore +0 -0
  27. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/Makefile +0 -0
  28. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/make.bat +0 -0
  29. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/source/modules.rst +0 -0
  30. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/source/pymoca.generated.rst +0 -0
  31. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/source/pymoca.rst +0 -0
  32. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/doc/source/setup.rst +0 -0
  33. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/Modelica.g4 +0 -0
  34. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/ast.py +0 -0
  35. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/__init__.py +0 -0
  36. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/__init__.py +0 -0
  37. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/_options.py +0 -0
  38. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/alias_relation.py +0 -0
  39. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/generator.py +0 -0
  40. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/model.py +0 -0
  41. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/casadi/mtensor.py +0 -0
  42. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/sympy/__init__.py +0 -0
  43. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/sympy/generator.py +0 -0
  44. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/sympy/runtime.py +0 -0
  45. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/xml/__init__.py +0 -0
  46. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/xml/analysis.py +0 -0
  47. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/xml/generator.py +0 -0
  48. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/xml/model.py +0 -0
  49. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/xml/parser.py +0 -0
  50. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/backends/xml/sim_scipy.py +0 -0
  51. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/generated/__init__.py +0 -0
  52. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/parser.py +0 -0
  53. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca/tree.py +0 -0
  54. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca.egg-info/dependency_links.txt +0 -0
  55. {pymoca-0.9.0 → pymoca-0.9.2.dev0}/src/pymoca.egg-info/top_level.txt +0 -0
@@ -2,7 +2,6 @@ include LICENSE
2
2
  include README.md
3
3
  recursive-include doc *
4
4
  recursive-include java *
5
- include versioneer.py
6
5
  include src/pymoca/_version.py
7
6
  include src/pymoca/Modelica.g4
8
7
  include src/pymoca/backends/xml/ModelicaXML/schemas/*.xsd
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.2
2
+ Name: pymoca
3
+ Version: 0.9.2.dev0
4
+ Summary: A Modelica to computer algebra system (CAS) translator.
5
+ Author: Pymoca Contributors
6
+ Maintainer-email: Jack Vreeken <jack@vreeken.me>, Kent Rutan <gs1150e@icloud.com>
7
+ License: Copyright (c) 2016-2021, James Goppert and the Pymoca contributors.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ * Redistributions of source code must retain the above copyright notice, this
14
+ list of conditions and the following disclaimer.
15
+
16
+ * Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ * Neither the name of pymoca nor the names of its
21
+ contributors may be used to endorse or promote products derived from
22
+ this software without specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+
36
+ Project-URL: homepage, https://github.com/pymoca/pymoca
37
+ Keywords: modelica,simulation,compiler
38
+ Classifier: Development Status :: 3 - Alpha
39
+ Classifier: Intended Audience :: Science/Research
40
+ Classifier: Intended Audience :: Developers
41
+ Classifier: License :: OSI Approved :: BSD License
42
+ Classifier: Programming Language :: Python
43
+ Classifier: Programming Language :: Python :: 3
44
+ Classifier: Programming Language :: Other
45
+ Classifier: Topic :: Software Development
46
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
47
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
48
+ Classifier: Topic :: Scientific/Engineering :: Physics
49
+ Classifier: Topic :: Scientific/Engineering :: Visualization
50
+ Classifier: Operating System :: Microsoft :: Windows
51
+ Classifier: Operating System :: POSIX
52
+ Classifier: Operating System :: Unix
53
+ Classifier: Operating System :: MacOS
54
+ Classifier: Topic :: Software Development :: Code Generators
55
+ Classifier: Topic :: Software Development :: Compilers
56
+ Classifier: Topic :: Software Development :: Embedded Systems
57
+ Requires-Python: >=3.9
58
+ Description-Content-Type: text/markdown
59
+ License-File: LICENSE
60
+ Requires-Dist: numpy>=1.8.2
61
+ Requires-Dist: antlr4-python3-runtime==4.13.*
62
+ Provides-Extra: casadi
63
+ Requires-Dist: casadi>=3.4.0; extra == "casadi"
64
+ Requires-Dist: setuptools>=60.0.0; extra == "casadi"
65
+ Provides-Extra: lxml
66
+ Requires-Dist: lxml>=3.5.0; extra == "lxml"
67
+ Requires-Dist: scipy>=0.13.3; extra == "lxml"
68
+ Provides-Extra: sympy
69
+ Requires-Dist: sympy>=0.7.6.1; extra == "sympy"
70
+ Requires-Dist: scipy>=0.13.3; extra == "sympy"
71
+ Requires-Dist: jinja2>=2.10.1; extra == "sympy"
72
+ Provides-Extra: examples
73
+ Requires-Dist: jupyterlab; extra == "examples"
74
+ Requires-Dist: matplotlib; extra == "examples"
75
+ Requires-Dist: control<=0.10.0,>=0.9.3.post2; extra == "examples"
76
+ Provides-Extra: all
77
+ Requires-Dist: pymoca[casadi,examples,lxml,sympy]; extra == "all"
78
+
79
+ # <img alt="Pymoca" src="branding/icons/pymocalogo.svg" height="60">
80
+
81
+ A Modelica to computer algebra system (CAS) compiler written in python.
82
+
83
+
84
+ [![CI](https://github.com/pymoca/pymoca/workflows/CI/badge.svg)](https://github.com/pymoca/pymoca/actions?query=workflow%3ACI)
85
+ [![Coverage](https://codecov.io/gh/pymoca/pymoca/branch/master/graph/badge.svg)](https://codecov.io/gh/pymoca/pymoca)
86
+ [![DOI](https://zenodo.org/badge/20664755.svg)](https://zenodo.org/badge/latestdoi/20664755)
87
+
88
+
89
+ ## Install
90
+
91
+ Python / PyPI:
92
+
93
+ ```bash
94
+ pip install pymoca
95
+ ```
96
+
97
+ Anaconda / Conda:
98
+ 1. Install anaconda 3.
99
+
100
+ 2. Setup environment.
101
+
102
+ ```bash
103
+ ./create_conda_env.sh enduser
104
+ . activate pymoca
105
+ jupyter notebook
106
+ ```
107
+
108
+ ## Examples
109
+ * [Sympy Example](test/notebooks/Spring.ipynb)
110
+ * [Casadi Example](test/notebooks/Casadi.ipynb)
111
+ * [ModelicaXML Example](test/notebooks/XML.ipynb)
112
+
113
+ ## Roadmap
114
+
115
+ ### Completed Tasks
116
+
117
+ * Parsing Modelica
118
+ * Sympy Simulation/CAS creation for simple models
119
+ * Casadi CAS creation for simple models
120
+
121
+ ### TODO
122
+
123
+ * Gather requirements and unify Casadi model
124
+ * Lazy parsing for reading large libraries
125
+ * Support more of Modelica language elements
126
+
127
+ <!--- vim:ts=4:sw=4:expandtab:
128
+ !-->
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools", "versioneer[toml]==0.29"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pymoca"
7
+ dynamic = ["version"]
8
+ license = { file = "LICENSE" }
9
+ description = "A Modelica to computer algebra system (CAS) translator."
10
+ keywords = ["modelica", "simulation", "compiler"]
11
+ readme = "README.md"
12
+ authors = [{ name = "Pymoca Contributors" }]
13
+ maintainers = [
14
+ { name = "Jack Vreeken", email = "jack@vreeken.me" },
15
+ { name = "Kent Rutan", email = "gs1150e@icloud.com" },
16
+ ]
17
+ requires-python = ">=3.9"
18
+ dependencies = ["numpy >= 1.8.2", "antlr4-python3-runtime == 4.13.*"]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Science/Research",
22
+ "Intended Audience :: Developers",
23
+ "License :: OSI Approved :: BSD License",
24
+ "Programming Language :: Python",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Other",
27
+ "Topic :: Software Development",
28
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
29
+ "Topic :: Scientific/Engineering :: Mathematics",
30
+ "Topic :: Scientific/Engineering :: Physics",
31
+ "Topic :: Scientific/Engineering :: Visualization",
32
+ "Operating System :: Microsoft :: Windows",
33
+ "Operating System :: POSIX",
34
+ "Operating System :: Unix",
35
+ "Operating System :: MacOS",
36
+ "Topic :: Software Development :: Code Generators",
37
+ "Topic :: Software Development :: Compilers",
38
+ "Topic :: Software Development :: Embedded Systems",
39
+ ]
40
+
41
+ [project.urls]
42
+ homepage = "https://github.com/pymoca/pymoca"
43
+
44
+ [project.optional-dependencies]
45
+ # Note that we need setuptools for the distutils.ccompiler dependency
46
+ # in the CasADi backend.
47
+ casadi = ["casadi>=3.4.0", "setuptools>=60.0.0"]
48
+ lxml = ["lxml>=3.5.0", "scipy>=0.13.3"]
49
+ sympy = ["sympy>=0.7.6.1", "scipy>=0.13.3", "jinja2>=2.10.1"]
50
+ examples = ["jupyterlab", "matplotlib", "control>=0.9.3.post2,<=0.10.0"]
51
+ all = ["pymoca[casadi,lxml,sympy,examples]"]
52
+
53
+ # TODO: Uncomment this when moving away from versioneer.
54
+ # [tool.setuptools.dynamic]
55
+ # version = { attr = "pymoca.__version__" }
56
+
57
+ # See the docstring in versioneer.py for instructions. Note that after changing
58
+ # this section, run `versioneer install --no-vendor`, commit the results.
59
+
60
+ [tool.versioneer]
61
+ VCS = "git"
62
+ style = "pep440"
63
+ versionfile_source = "src/pymoca/_version.py"
64
+ versionfile_build = "pymoca/_version.py"
65
+ tag_prefix = ""
66
+ parentdir_prefix = "pymoca-"
@@ -1,14 +1,6 @@
1
1
  [metadata]
2
2
  license_file = LICENSE
3
3
 
4
- [versioneer]
5
- vcs = git
6
- style = pep440
7
- versionfile_source = src/pymoca/_version.py
8
- versionfile_build = pymoca/_version.py
9
- tag_prefix =
10
- parentdir_prefix = pymoca-
11
-
12
4
  [flake8]
13
5
  max-line-length = 99
14
6
  exclude =
@@ -31,6 +23,7 @@ exclude =
31
23
  src/pymoca/backends/casadi/alias_relation.py,
32
24
  src/pymoca/backends/sympy/generator.py,
33
25
  src/pymoca/backends/sympy/runtime.py,
26
+ src/pymoca/backends/xml/generator.py,
34
27
  src/pymoca/tree.py,
35
28
  src/pymoca/ast.py,
36
29
  src/pymoca/ast.py,
@@ -0,0 +1,11 @@
1
+
2
+ """Minimal setup file for versioneer."""
3
+
4
+ from setuptools import setup
5
+
6
+ import versioneer
7
+
8
+ setup(
9
+ version=versioneer.get_version(),
10
+ cmdclass=versioneer.get_cmdclass(),
11
+ )
@@ -0,0 +1,2 @@
1
+ from . import _version
2
+ __version__ = _version.get_versions()['version']
@@ -1,5 +1,5 @@
1
1
 
2
- # This file was generated by 'versioneer.py' (0.18) from
2
+ # This file was generated by 'versioneer.py' (0.29) from
3
3
  # revision-control system data, or from the parent directory name of an
4
4
  # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
5
  # of this file.
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2021-06-18T17:32:21+0200",
11
+ "date": "2025-01-10T23:53:24+0100",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "708deca2dc556d99b795b4956a84a5f94fbfe481",
15
- "version": "0.9.0"
14
+ "full-revisionid": "ae3e226fc72a8db2e7e4a847b2c5d5a89faf08b1",
15
+ "version": "0.9.2.dev0"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -1,3 +1,4 @@
1
+ import itertools
1
2
  from collections import namedtuple
2
3
  from enum import IntEnum
3
4
  from typing import Dict
@@ -139,8 +140,10 @@ def _codegen_model(model_folder: str, f: ca.Function, library_name: str):
139
140
  compiler_flags = ['-O2', '-fPIC']
140
141
  linker_flags = ['-fPIC']
141
142
  else:
142
- compiler_flags = ['/O2', '/wd4101'] # Shut up unused local variable warnings.
143
- linker_flags = ['/DLL']
143
+ # Shut up unused local variable warnings, and use workaround for
144
+ # NaN-constantness bug in recent Windows SDK versions.
145
+ compiler_flags = ["/O2", "/wd4101", "/D_UCRT_NOISY_NAN"]
146
+ linker_flags = ["/DLL"]
144
147
 
145
148
  # Generate C code
146
149
  logger.debug("Generating {}".format(library_name))
@@ -260,6 +263,8 @@ def save_model(model_folder: str, model_name: str, model: Model,
260
263
 
261
264
  duration_dependencies = []
262
265
  for dur in durations:
266
+ if not isinstance(dur, ca.MX):
267
+ dur = ca.MX(dur) # Probably a constant, will have no dependencies
263
268
  duration_dependencies.append(
264
269
  [symbol_to_index[var] for var in ca.symvar(dur) if ca.depends_on(dur, var)])
265
270
  db['__delay_duration_dependent'] = duration_dependencies
@@ -414,7 +419,7 @@ def load_model(model_folder: str, model_name: str, compiler_options: Dict[str, s
414
419
  # Get rid of false dependency symbols not used in any delay
415
420
  # durations. This significantly reduces the work the (slow)
416
421
  # substitute() calls have to do later on.
417
- actual_deps = sorted(set(np.array(duration_dependencies).ravel()))
422
+ actual_deps = sorted(set(itertools.chain(*duration_dependencies)))
418
423
 
419
424
  actual_dep_symbols = [np.nan] * len(all_symbols)
420
425
  for i in actual_deps: