Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/INSTALLER +1 -0
- llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/METADATA +278 -0
- llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/RECORD +108 -0
- llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/REQUESTED +0 -0
- llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/WHEEL +4 -0
- llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/licenses/LICENSE +29 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/INSTALLER +1 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/LICENSE +21 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/METADATA +172 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/RECORD +25 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/REQUESTED +0 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/WHEEL +4 -0
- llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/entry_points.txt +4 -0
- llava_next/lib/python3.10/site-packages/psutil/__pycache__/__init__.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/INSTALLER +1 -0
- llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/METADATA +0 -0
- llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/RECORD +212 -0
- llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/REQUESTED +0 -0
- llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/WHEEL +4 -0
- llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/licenses/LICENSE +21 -0
- moondream/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so +3 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/__pycache__/__init__.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/__pycache__/cable.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/__pycache__/truss.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/cable.py +587 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__init__.py +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/test_beam.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/test_cable.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/test_truss.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/test_beam.py +802 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/test_cable.py +83 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/test_truss.py +100 -0
- parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/truss.py +1108 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/__init__.py +16 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/__pycache__/__init__.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/__pycache__/control_plots.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/control_plots.py +978 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/lti.py +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/tests/__init__.py +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/tests/__pycache__/test_control_plots.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/tests/test_control_plots.py +299 -0
- parrot/lib/python3.10/site-packages/sympy/physics/control/tests/test_lti.py +1750 -0
- parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_circuitutils.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_commutator.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_constants.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_grover.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_hilbert.cpython-310.pyc +0 -0
.gitattributes
CHANGED
|
@@ -334,3 +334,4 @@ parrot/lib/python3.10/site-packages/transformers/models/speecht5/__pycache__/mod
|
|
| 334 |
parrot/lib/python3.10/site-packages/transformers/utils/__pycache__/dummy_tf_objects.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 335 |
parrot/lib/python3.10/site-packages/transformers/__pycache__/modeling_tf_utils.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 336 |
parrot/lib/python3.10/site-packages/transformers/__pycache__/trainer.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 334 |
parrot/lib/python3.10/site-packages/transformers/utils/__pycache__/dummy_tf_objects.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 335 |
parrot/lib/python3.10/site-packages/transformers/__pycache__/modeling_tf_utils.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 336 |
parrot/lib/python3.10/site-packages/transformers/__pycache__/trainer.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 337 |
+
moondream/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so filter=lfs diff=lfs merge=lfs -text
|
llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.3
|
| 2 |
+
Name: fsspec
|
| 3 |
+
Version: 2024.10.0
|
| 4 |
+
Summary: File-system specification
|
| 5 |
+
Project-URL: Changelog, https://filesystem-spec.readthedocs.io/en/latest/changelog.html
|
| 6 |
+
Project-URL: Documentation, https://filesystem-spec.readthedocs.io/en/latest/
|
| 7 |
+
Project-URL: Homepage, https://github.com/fsspec/filesystem_spec
|
| 8 |
+
Maintainer-email: Martin Durant <mdurant@anaconda.com>
|
| 9 |
+
License: BSD 3-Clause License
|
| 10 |
+
|
| 11 |
+
Copyright (c) 2018, Martin Durant
|
| 12 |
+
All rights reserved.
|
| 13 |
+
|
| 14 |
+
Redistribution and use in source and binary forms, with or without
|
| 15 |
+
modification, are permitted provided that the following conditions are met:
|
| 16 |
+
|
| 17 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 18 |
+
list of conditions and the following disclaimer.
|
| 19 |
+
|
| 20 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 21 |
+
this list of conditions and the following disclaimer in the documentation
|
| 22 |
+
and/or other materials provided with the distribution.
|
| 23 |
+
|
| 24 |
+
* Neither the name of the copyright holder nor the names of its
|
| 25 |
+
contributors may be used to endorse or promote products derived from
|
| 26 |
+
this software without specific prior written permission.
|
| 27 |
+
|
| 28 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 29 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 30 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 31 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 32 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 33 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 34 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 35 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 36 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 37 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 38 |
+
License-File: LICENSE
|
| 39 |
+
Keywords: file
|
| 40 |
+
Classifier: Development Status :: 4 - Beta
|
| 41 |
+
Classifier: Intended Audience :: Developers
|
| 42 |
+
Classifier: License :: OSI Approved :: BSD License
|
| 43 |
+
Classifier: Operating System :: OS Independent
|
| 44 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 45 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 46 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 47 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 48 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 49 |
+
Requires-Python: >=3.8
|
| 50 |
+
Provides-Extra: abfs
|
| 51 |
+
Requires-Dist: adlfs; extra == 'abfs'
|
| 52 |
+
Provides-Extra: adl
|
| 53 |
+
Requires-Dist: adlfs; extra == 'adl'
|
| 54 |
+
Provides-Extra: arrow
|
| 55 |
+
Requires-Dist: pyarrow>=1; extra == 'arrow'
|
| 56 |
+
Provides-Extra: dask
|
| 57 |
+
Requires-Dist: dask; extra == 'dask'
|
| 58 |
+
Requires-Dist: distributed; extra == 'dask'
|
| 59 |
+
Provides-Extra: dev
|
| 60 |
+
Requires-Dist: pre-commit; extra == 'dev'
|
| 61 |
+
Requires-Dist: ruff; extra == 'dev'
|
| 62 |
+
Provides-Extra: doc
|
| 63 |
+
Requires-Dist: numpydoc; extra == 'doc'
|
| 64 |
+
Requires-Dist: sphinx; extra == 'doc'
|
| 65 |
+
Requires-Dist: sphinx-design; extra == 'doc'
|
| 66 |
+
Requires-Dist: sphinx-rtd-theme; extra == 'doc'
|
| 67 |
+
Requires-Dist: yarl; extra == 'doc'
|
| 68 |
+
Provides-Extra: dropbox
|
| 69 |
+
Requires-Dist: dropbox; extra == 'dropbox'
|
| 70 |
+
Requires-Dist: dropboxdrivefs; extra == 'dropbox'
|
| 71 |
+
Requires-Dist: requests; extra == 'dropbox'
|
| 72 |
+
Provides-Extra: entrypoints
|
| 73 |
+
Provides-Extra: full
|
| 74 |
+
Requires-Dist: adlfs; extra == 'full'
|
| 75 |
+
Requires-Dist: aiohttp!=4.0.0a0,!=4.0.0a1; extra == 'full'
|
| 76 |
+
Requires-Dist: dask; extra == 'full'
|
| 77 |
+
Requires-Dist: distributed; extra == 'full'
|
| 78 |
+
Requires-Dist: dropbox; extra == 'full'
|
| 79 |
+
Requires-Dist: dropboxdrivefs; extra == 'full'
|
| 80 |
+
Requires-Dist: fusepy; extra == 'full'
|
| 81 |
+
Requires-Dist: gcsfs; extra == 'full'
|
| 82 |
+
Requires-Dist: libarchive-c; extra == 'full'
|
| 83 |
+
Requires-Dist: ocifs; extra == 'full'
|
| 84 |
+
Requires-Dist: panel; extra == 'full'
|
| 85 |
+
Requires-Dist: paramiko; extra == 'full'
|
| 86 |
+
Requires-Dist: pyarrow>=1; extra == 'full'
|
| 87 |
+
Requires-Dist: pygit2; extra == 'full'
|
| 88 |
+
Requires-Dist: requests; extra == 'full'
|
| 89 |
+
Requires-Dist: s3fs; extra == 'full'
|
| 90 |
+
Requires-Dist: smbprotocol; extra == 'full'
|
| 91 |
+
Requires-Dist: tqdm; extra == 'full'
|
| 92 |
+
Provides-Extra: fuse
|
| 93 |
+
Requires-Dist: fusepy; extra == 'fuse'
|
| 94 |
+
Provides-Extra: gcs
|
| 95 |
+
Requires-Dist: gcsfs; extra == 'gcs'
|
| 96 |
+
Provides-Extra: git
|
| 97 |
+
Requires-Dist: pygit2; extra == 'git'
|
| 98 |
+
Provides-Extra: github
|
| 99 |
+
Requires-Dist: requests; extra == 'github'
|
| 100 |
+
Provides-Extra: gs
|
| 101 |
+
Requires-Dist: gcsfs; extra == 'gs'
|
| 102 |
+
Provides-Extra: gui
|
| 103 |
+
Requires-Dist: panel; extra == 'gui'
|
| 104 |
+
Provides-Extra: hdfs
|
| 105 |
+
Requires-Dist: pyarrow>=1; extra == 'hdfs'
|
| 106 |
+
Provides-Extra: http
|
| 107 |
+
Requires-Dist: aiohttp!=4.0.0a0,!=4.0.0a1; extra == 'http'
|
| 108 |
+
Provides-Extra: libarchive
|
| 109 |
+
Requires-Dist: libarchive-c; extra == 'libarchive'
|
| 110 |
+
Provides-Extra: oci
|
| 111 |
+
Requires-Dist: ocifs; extra == 'oci'
|
| 112 |
+
Provides-Extra: s3
|
| 113 |
+
Requires-Dist: s3fs; extra == 's3'
|
| 114 |
+
Provides-Extra: sftp
|
| 115 |
+
Requires-Dist: paramiko; extra == 'sftp'
|
| 116 |
+
Provides-Extra: smb
|
| 117 |
+
Requires-Dist: smbprotocol; extra == 'smb'
|
| 118 |
+
Provides-Extra: ssh
|
| 119 |
+
Requires-Dist: paramiko; extra == 'ssh'
|
| 120 |
+
Provides-Extra: test
|
| 121 |
+
Requires-Dist: aiohttp!=4.0.0a0,!=4.0.0a1; extra == 'test'
|
| 122 |
+
Requires-Dist: numpy; extra == 'test'
|
| 123 |
+
Requires-Dist: pytest; extra == 'test'
|
| 124 |
+
Requires-Dist: pytest-asyncio!=0.22.0; extra == 'test'
|
| 125 |
+
Requires-Dist: pytest-benchmark; extra == 'test'
|
| 126 |
+
Requires-Dist: pytest-cov; extra == 'test'
|
| 127 |
+
Requires-Dist: pytest-mock; extra == 'test'
|
| 128 |
+
Requires-Dist: pytest-recording; extra == 'test'
|
| 129 |
+
Requires-Dist: pytest-rerunfailures; extra == 'test'
|
| 130 |
+
Requires-Dist: requests; extra == 'test'
|
| 131 |
+
Provides-Extra: test-downstream
|
| 132 |
+
Requires-Dist: aiobotocore<3.0.0,>=2.5.4; extra == 'test-downstream'
|
| 133 |
+
Requires-Dist: dask-expr; extra == 'test-downstream'
|
| 134 |
+
Requires-Dist: dask[dataframe,test]; extra == 'test-downstream'
|
| 135 |
+
Requires-Dist: moto[server]<5,>4; extra == 'test-downstream'
|
| 136 |
+
Requires-Dist: pytest-timeout; extra == 'test-downstream'
|
| 137 |
+
Requires-Dist: xarray; extra == 'test-downstream'
|
| 138 |
+
Provides-Extra: test-full
|
| 139 |
+
Requires-Dist: adlfs; extra == 'test-full'
|
| 140 |
+
Requires-Dist: aiohttp!=4.0.0a0,!=4.0.0a1; extra == 'test-full'
|
| 141 |
+
Requires-Dist: cloudpickle; extra == 'test-full'
|
| 142 |
+
Requires-Dist: dask; extra == 'test-full'
|
| 143 |
+
Requires-Dist: distributed; extra == 'test-full'
|
| 144 |
+
Requires-Dist: dropbox; extra == 'test-full'
|
| 145 |
+
Requires-Dist: dropboxdrivefs; extra == 'test-full'
|
| 146 |
+
Requires-Dist: fastparquet; extra == 'test-full'
|
| 147 |
+
Requires-Dist: fusepy; extra == 'test-full'
|
| 148 |
+
Requires-Dist: gcsfs; extra == 'test-full'
|
| 149 |
+
Requires-Dist: jinja2; extra == 'test-full'
|
| 150 |
+
Requires-Dist: kerchunk; extra == 'test-full'
|
| 151 |
+
Requires-Dist: libarchive-c; extra == 'test-full'
|
| 152 |
+
Requires-Dist: lz4; extra == 'test-full'
|
| 153 |
+
Requires-Dist: notebook; extra == 'test-full'
|
| 154 |
+
Requires-Dist: numpy; extra == 'test-full'
|
| 155 |
+
Requires-Dist: ocifs; extra == 'test-full'
|
| 156 |
+
Requires-Dist: pandas; extra == 'test-full'
|
| 157 |
+
Requires-Dist: panel; extra == 'test-full'
|
| 158 |
+
Requires-Dist: paramiko; extra == 'test-full'
|
| 159 |
+
Requires-Dist: pyarrow; extra == 'test-full'
|
| 160 |
+
Requires-Dist: pyarrow>=1; extra == 'test-full'
|
| 161 |
+
Requires-Dist: pyftpdlib; extra == 'test-full'
|
| 162 |
+
Requires-Dist: pygit2; extra == 'test-full'
|
| 163 |
+
Requires-Dist: pytest; extra == 'test-full'
|
| 164 |
+
Requires-Dist: pytest-asyncio!=0.22.0; extra == 'test-full'
|
| 165 |
+
Requires-Dist: pytest-benchmark; extra == 'test-full'
|
| 166 |
+
Requires-Dist: pytest-cov; extra == 'test-full'
|
| 167 |
+
Requires-Dist: pytest-mock; extra == 'test-full'
|
| 168 |
+
Requires-Dist: pytest-recording; extra == 'test-full'
|
| 169 |
+
Requires-Dist: pytest-rerunfailures; extra == 'test-full'
|
| 170 |
+
Requires-Dist: python-snappy; extra == 'test-full'
|
| 171 |
+
Requires-Dist: requests; extra == 'test-full'
|
| 172 |
+
Requires-Dist: smbprotocol; extra == 'test-full'
|
| 173 |
+
Requires-Dist: tqdm; extra == 'test-full'
|
| 174 |
+
Requires-Dist: urllib3; extra == 'test-full'
|
| 175 |
+
Requires-Dist: zarr; extra == 'test-full'
|
| 176 |
+
Requires-Dist: zstandard; extra == 'test-full'
|
| 177 |
+
Provides-Extra: tqdm
|
| 178 |
+
Requires-Dist: tqdm; extra == 'tqdm'
|
| 179 |
+
Description-Content-Type: text/markdown
|
| 180 |
+
|
| 181 |
+
# filesystem_spec
|
| 182 |
+
|
| 183 |
+
[](https://pypi.python.org/pypi/fsspec/)
|
| 184 |
+
[](https://anaconda.org/conda-forge/fsspec)
|
| 185 |
+

|
| 186 |
+
[](https://filesystem-spec.readthedocs.io/en/latest/?badge=latest)
|
| 187 |
+
|
| 188 |
+
A specification for pythonic filesystems.
|
| 189 |
+
|
| 190 |
+
## Install
|
| 191 |
+
|
| 192 |
+
```bash
|
| 193 |
+
pip install fsspec
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
would install the base fsspec. Various optionally supported features might require specification of custom
|
| 197 |
+
extra require, e.g. `pip install fsspec[ssh]` will install dependencies for `ssh` backends support.
|
| 198 |
+
Use `pip install fsspec[full]` for installation of all known extra dependencies.
|
| 199 |
+
|
| 200 |
+
Up-to-date package also provided through conda-forge distribution:
|
| 201 |
+
|
| 202 |
+
```bash
|
| 203 |
+
conda install -c conda-forge fsspec
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
## Purpose
|
| 208 |
+
|
| 209 |
+
To produce a template or specification for a file-system interface, that specific implementations should follow,
|
| 210 |
+
so that applications making use of them can rely on a common behaviour and not have to worry about the specific
|
| 211 |
+
internal implementation decisions with any given backend. Many such implementations are included in this package,
|
| 212 |
+
or in sister projects such as `s3fs` and `gcsfs`.
|
| 213 |
+
|
| 214 |
+
In addition, if this is well-designed, then additional functionality, such as a key-value store or FUSE
|
| 215 |
+
mounting of the file-system implementation may be available for all implementations "for free".
|
| 216 |
+
|
| 217 |
+
## Documentation
|
| 218 |
+
|
| 219 |
+
Please refer to [RTD](https://filesystem-spec.readthedocs.io/en/latest/?badge=latest)
|
| 220 |
+
|
| 221 |
+
## Develop
|
| 222 |
+
|
| 223 |
+
fsspec uses GitHub Actions for CI. Environment files can be found
|
| 224 |
+
in the "ci/" directory. Note that the main environment is called "py38",
|
| 225 |
+
but it is expected that the version of python installed be adjustable at
|
| 226 |
+
CI runtime. For local use, pick a version suitable for you.
|
| 227 |
+
|
| 228 |
+
```bash
|
| 229 |
+
# For a new environment (mamba / conda).
|
| 230 |
+
mamba create -n fsspec -c conda-forge python=3.9 -y
|
| 231 |
+
conda activate fsspec
|
| 232 |
+
|
| 233 |
+
# Standard dev install with docs and tests.
|
| 234 |
+
pip install -e ".[dev,doc,test]"
|
| 235 |
+
|
| 236 |
+
# Full tests except for downstream
|
| 237 |
+
pip install s3fs
|
| 238 |
+
pip uninstall s3fs
|
| 239 |
+
pip install -e .[dev,doc,test_full]
|
| 240 |
+
pip install s3fs --no-deps
|
| 241 |
+
pytest -v
|
| 242 |
+
|
| 243 |
+
# Downstream tests.
|
| 244 |
+
sh install_s3fs.sh
|
| 245 |
+
# Windows powershell.
|
| 246 |
+
install_s3fs.sh
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
### Testing
|
| 250 |
+
|
| 251 |
+
Tests can be run in the dev environment, if activated, via ``pytest fsspec``.
|
| 252 |
+
|
| 253 |
+
The full fsspec suite requires a system-level docker, docker-compose, and fuse
|
| 254 |
+
installation. If only making changes to one backend implementation, it is
|
| 255 |
+
not generally necessary to run all tests locally.
|
| 256 |
+
|
| 257 |
+
It is expected that contributors ensure that any change to fsspec does not
|
| 258 |
+
cause issues or regressions for either other fsspec-related packages such
|
| 259 |
+
as gcsfs and s3fs, nor for downstream users of fsspec. The "downstream" CI
|
| 260 |
+
run and corresponding environment file run a set of tests from the dask
|
| 261 |
+
test suite, and very minimal tests against pandas and zarr from the
|
| 262 |
+
test_downstream.py module in this repo.
|
| 263 |
+
|
| 264 |
+
### Code Formatting
|
| 265 |
+
|
| 266 |
+
fsspec uses [Black](https://black.readthedocs.io/en/stable) to ensure
|
| 267 |
+
a consistent code format throughout the project.
|
| 268 |
+
Run ``black fsspec`` from the root of the filesystem_spec repository to
|
| 269 |
+
auto-format your code. Additionally, many editors have plugins that will apply
|
| 270 |
+
``black`` as you edit files. ``black`` is included in the ``tox`` environments.
|
| 271 |
+
|
| 272 |
+
Optionally, you may wish to setup [pre-commit hooks](https://pre-commit.com) to
|
| 273 |
+
automatically run ``black`` when you make a git commit.
|
| 274 |
+
Run ``pre-commit install --install-hooks`` from the root of the
|
| 275 |
+
filesystem_spec repository to setup pre-commit hooks. ``black`` will now be run
|
| 276 |
+
before you commit, reformatting any changed files. You can format without
|
| 277 |
+
committing via ``pre-commit run`` or skip these checks with ``git commit
|
| 278 |
+
--no-verify``.
|
llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fsspec-2024.10.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
fsspec-2024.10.0.dist-info/METADATA,sha256=l8HZ_K6qpTaPGBm3jOSHa1DX6Gja2hM3t5yBrdkmv7E,11750
|
| 3 |
+
fsspec-2024.10.0.dist-info/RECORD,,
|
| 4 |
+
fsspec-2024.10.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 5 |
+
fsspec-2024.10.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
| 6 |
+
fsspec-2024.10.0.dist-info/licenses/LICENSE,sha256=LcNUls5TpzB5FcAIqESq1T53K0mzTN0ARFBnaRQH7JQ,1513
|
| 7 |
+
fsspec/__init__.py,sha256=l9MJaNNV2d4wKpCtMvXDr55n92DkdrAayGy3F9ICjzk,1998
|
| 8 |
+
fsspec/__pycache__/__init__.cpython-310.pyc,,
|
| 9 |
+
fsspec/__pycache__/_version.cpython-310.pyc,,
|
| 10 |
+
fsspec/__pycache__/archive.cpython-310.pyc,,
|
| 11 |
+
fsspec/__pycache__/asyn.cpython-310.pyc,,
|
| 12 |
+
fsspec/__pycache__/caching.cpython-310.pyc,,
|
| 13 |
+
fsspec/__pycache__/callbacks.cpython-310.pyc,,
|
| 14 |
+
fsspec/__pycache__/compression.cpython-310.pyc,,
|
| 15 |
+
fsspec/__pycache__/config.cpython-310.pyc,,
|
| 16 |
+
fsspec/__pycache__/conftest.cpython-310.pyc,,
|
| 17 |
+
fsspec/__pycache__/core.cpython-310.pyc,,
|
| 18 |
+
fsspec/__pycache__/dircache.cpython-310.pyc,,
|
| 19 |
+
fsspec/__pycache__/exceptions.cpython-310.pyc,,
|
| 20 |
+
fsspec/__pycache__/fuse.cpython-310.pyc,,
|
| 21 |
+
fsspec/__pycache__/generic.cpython-310.pyc,,
|
| 22 |
+
fsspec/__pycache__/gui.cpython-310.pyc,,
|
| 23 |
+
fsspec/__pycache__/json.cpython-310.pyc,,
|
| 24 |
+
fsspec/__pycache__/mapping.cpython-310.pyc,,
|
| 25 |
+
fsspec/__pycache__/parquet.cpython-310.pyc,,
|
| 26 |
+
fsspec/__pycache__/registry.cpython-310.pyc,,
|
| 27 |
+
fsspec/__pycache__/spec.cpython-310.pyc,,
|
| 28 |
+
fsspec/__pycache__/transaction.cpython-310.pyc,,
|
| 29 |
+
fsspec/__pycache__/utils.cpython-310.pyc,,
|
| 30 |
+
fsspec/_version.py,sha256=TRFHcujqz6-GeA85-A44TpoeoMj1E4TmW_pLohsSakA,419
|
| 31 |
+
fsspec/archive.py,sha256=S__DzfZj-urAN3tp2W6jJ6YDiXG1fAl7FjvWUN73qIE,2386
|
| 32 |
+
fsspec/asyn.py,sha256=KUi-txo8VDtMUbrgEOu7i6tnJzMPTR2XHU0u70t7nCY,36512
|
| 33 |
+
fsspec/caching.py,sha256=x6IEdxtR3cMDjy40sNHyawR2SLtNSahVuP5i_TImdso,31600
|
| 34 |
+
fsspec/callbacks.py,sha256=BDIwLzK6rr_0V5ch557fSzsivCElpdqhXr5dZ9Te-EE,9210
|
| 35 |
+
fsspec/compression.py,sha256=jCSUMJu-zSNyrusnHT0wKXgOd1tTJR6vM126i5SR5Zc,4865
|
| 36 |
+
fsspec/config.py,sha256=LF4Zmu1vhJW7Je9Q-cwkRc3xP7Rhyy7Xnwj26Z6sv2g,4279
|
| 37 |
+
fsspec/conftest.py,sha256=fVfx-NLrH_OZS1TIpYNoPzM7efEcMoL62reHOdYeFCA,1245
|
| 38 |
+
fsspec/core.py,sha256=pXNmJ0qgMO-BTOKPoPWkBdeScXdrKJZ2gjOtdK8x0b0,23775
|
| 39 |
+
fsspec/dircache.py,sha256=YzogWJrhEastHU7vWz-cJiJ7sdtLXFXhEpInGKd4EcM,2717
|
| 40 |
+
fsspec/exceptions.py,sha256=pauSLDMxzTJMOjvX1WEUK0cMyFkrFxpWJsyFywav7A8,331
|
| 41 |
+
fsspec/fuse.py,sha256=Q-3NOOyLqBfYa4Db5E19z_ZY36zzYHtIs1mOUasItBQ,10177
|
| 42 |
+
fsspec/generic.py,sha256=AFbo-mHBt5QJV1Aplg5CJuUiiJ4bNQhcKRuwkZJdWac,13761
|
| 43 |
+
fsspec/gui.py,sha256=xBnHL2-r0LVwhDAtnHoPpXts7jd4Z32peawCJiI-7lI,13975
|
| 44 |
+
fsspec/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 45 |
+
fsspec/implementations/__pycache__/__init__.cpython-310.pyc,,
|
| 46 |
+
fsspec/implementations/__pycache__/arrow.cpython-310.pyc,,
|
| 47 |
+
fsspec/implementations/__pycache__/cache_mapper.cpython-310.pyc,,
|
| 48 |
+
fsspec/implementations/__pycache__/cache_metadata.cpython-310.pyc,,
|
| 49 |
+
fsspec/implementations/__pycache__/cached.cpython-310.pyc,,
|
| 50 |
+
fsspec/implementations/__pycache__/dask.cpython-310.pyc,,
|
| 51 |
+
fsspec/implementations/__pycache__/data.cpython-310.pyc,,
|
| 52 |
+
fsspec/implementations/__pycache__/dbfs.cpython-310.pyc,,
|
| 53 |
+
fsspec/implementations/__pycache__/dirfs.cpython-310.pyc,,
|
| 54 |
+
fsspec/implementations/__pycache__/ftp.cpython-310.pyc,,
|
| 55 |
+
fsspec/implementations/__pycache__/git.cpython-310.pyc,,
|
| 56 |
+
fsspec/implementations/__pycache__/github.cpython-310.pyc,,
|
| 57 |
+
fsspec/implementations/__pycache__/http.cpython-310.pyc,,
|
| 58 |
+
fsspec/implementations/__pycache__/jupyter.cpython-310.pyc,,
|
| 59 |
+
fsspec/implementations/__pycache__/libarchive.cpython-310.pyc,,
|
| 60 |
+
fsspec/implementations/__pycache__/local.cpython-310.pyc,,
|
| 61 |
+
fsspec/implementations/__pycache__/memory.cpython-310.pyc,,
|
| 62 |
+
fsspec/implementations/__pycache__/reference.cpython-310.pyc,,
|
| 63 |
+
fsspec/implementations/__pycache__/sftp.cpython-310.pyc,,
|
| 64 |
+
fsspec/implementations/__pycache__/smb.cpython-310.pyc,,
|
| 65 |
+
fsspec/implementations/__pycache__/tar.cpython-310.pyc,,
|
| 66 |
+
fsspec/implementations/__pycache__/webhdfs.cpython-310.pyc,,
|
| 67 |
+
fsspec/implementations/__pycache__/zip.cpython-310.pyc,,
|
| 68 |
+
fsspec/implementations/arrow.py,sha256=721Dikne_lV_0tlgk9jyKmHL6W-5MT0h2LKGvOYQTPI,8623
|
| 69 |
+
fsspec/implementations/cache_mapper.py,sha256=W4wlxyPxZbSp9ItJ0pYRVBMh6bw9eFypgP6kUYuuiI4,2421
|
| 70 |
+
fsspec/implementations/cache_metadata.py,sha256=pcOJYcBQY5OaC7Yhw0F3wjg08QLYApGmoISCrbs59ks,8511
|
| 71 |
+
fsspec/implementations/cached.py,sha256=t5atYATgjuABm-mUyReqjGqVyyP1XBSuROX92aMecxY,32826
|
| 72 |
+
fsspec/implementations/dask.py,sha256=CXZbJzIVOhKV8ILcxuy3bTvcacCueAbyQxmvAkbPkrk,4466
|
| 73 |
+
fsspec/implementations/data.py,sha256=LDLczxRh8h7x39Zjrd-GgzdQHr78yYxDlrv2C9Uxb5E,1658
|
| 74 |
+
fsspec/implementations/dbfs.py,sha256=a0eNjLxyfFK7pbEa52U8K-PhNHukzdGVx1eLcVniaXY,15092
|
| 75 |
+
fsspec/implementations/dirfs.py,sha256=ymakitNNQ07tW76EShyw3rC9RvIDHl4gtuOhE_h1vUg,12032
|
| 76 |
+
fsspec/implementations/ftp.py,sha256=VpJWnQscdEKRu4fzkCtuf3jD9A74mBaerS2ijUwZ-_I,11936
|
| 77 |
+
fsspec/implementations/git.py,sha256=4SElW9U5d3k3_ITlvUAx59Yk7XLNRTqkGa2C3hCUkWM,3754
|
| 78 |
+
fsspec/implementations/github.py,sha256=eAn1kJ7VeWR6gVoVRLBYclF_rQDXSJU-xzMXpvPQWqs,8002
|
| 79 |
+
fsspec/implementations/http.py,sha256=RLklsE1WG0eQ271haPRA_4Fz4q3wfnz5n4LifH447Eg,29826
|
| 80 |
+
fsspec/implementations/jupyter.py,sha256=B2uj7OEm7yIk-vRSsO37_ND0t0EBvn4B-Su43ibN4Pg,3811
|
| 81 |
+
fsspec/implementations/libarchive.py,sha256=5_I2DiLXwQ1JC8x-K7jXu-tBwhO9dj7tFLnb0bTnVMQ,7102
|
| 82 |
+
fsspec/implementations/local.py,sha256=DNBZhF9LYYTPR4PKedeWuk32Tztc9jlgXtGRFGX7nv4,15103
|
| 83 |
+
fsspec/implementations/memory.py,sha256=Z-eADtiIQ5_rhhPzX3t-NQVmWCsRtnxKuN-dTWKzrnM,10277
|
| 84 |
+
fsspec/implementations/reference.py,sha256=FxQ20HcV8SMB6DpHW33hpVOOsy8S_2xcVtDJRCtZ9rQ,45145
|
| 85 |
+
fsspec/implementations/sftp.py,sha256=fMY9XZcmpjszQ2tCqO_TPaJesaeD_Dv7ptYzgUPGoO0,5631
|
| 86 |
+
fsspec/implementations/smb.py,sha256=5fhu8h06nOLBPh2c48aT7WBRqh9cEcbIwtyu06wTjec,15236
|
| 87 |
+
fsspec/implementations/tar.py,sha256=dam78Tp_CozybNqCY2JYgGBS3Uc9FuJUAT9oB0lolOs,4111
|
| 88 |
+
fsspec/implementations/webhdfs.py,sha256=aet-AOfMoK91C3jNu5xBxK0Mu2iaAWiL9Xfu12KyjQI,16705
|
| 89 |
+
fsspec/implementations/zip.py,sha256=9LBMHPft2OutJl2Ft-r9u_z3GptLkc2n91ur2A3bCbg,6072
|
| 90 |
+
fsspec/json.py,sha256=65sQ0Y7mTj33u_Y4IId5up4abQ3bAel4E4QzbKMiQSg,3826
|
| 91 |
+
fsspec/mapping.py,sha256=CtD_GEmyYgXefQHndkxu7Zb_kbTS3mlFP2zIwlAoQTY,8289
|
| 92 |
+
fsspec/parquet.py,sha256=ONG29Enesp0ToCH2bQ7zkpimnVIsZ2S4xCLj35-fY78,19455
|
| 93 |
+
fsspec/registry.py,sha256=HVC-4HWDZnA6rycJwAu8F8ZXzON_85MTQVIyS6LOHxo,11320
|
| 94 |
+
fsspec/spec.py,sha256=7RkKPudVJnBJ1zfM6SCPwovsQyPxvt3hXkI7rpZMePk,69491
|
| 95 |
+
fsspec/tests/abstract/__init__.py,sha256=o3rQBCeTTTdji0OxKdTvBvwL7q78sEIh5J5-Q-If6z0,10046
|
| 96 |
+
fsspec/tests/abstract/__pycache__/__init__.cpython-310.pyc,,
|
| 97 |
+
fsspec/tests/abstract/__pycache__/common.cpython-310.pyc,,
|
| 98 |
+
fsspec/tests/abstract/__pycache__/copy.cpython-310.pyc,,
|
| 99 |
+
fsspec/tests/abstract/__pycache__/get.cpython-310.pyc,,
|
| 100 |
+
fsspec/tests/abstract/__pycache__/mv.cpython-310.pyc,,
|
| 101 |
+
fsspec/tests/abstract/__pycache__/put.cpython-310.pyc,,
|
| 102 |
+
fsspec/tests/abstract/common.py,sha256=1GQwNo5AONzAnzZj0fWgn8NJPLXALehbsuGxS3FzWVU,4973
|
| 103 |
+
fsspec/tests/abstract/copy.py,sha256=gU5-d97U3RSde35Vp4RxPY4rWwL744HiSrJ8IBOp9-8,19967
|
| 104 |
+
fsspec/tests/abstract/get.py,sha256=vNR4HztvTR7Cj56AMo7_tx7TeYz1Jgr_2Wb8Lv-UiBY,20755
|
| 105 |
+
fsspec/tests/abstract/mv.py,sha256=k8eUEBIrRrGMsBY5OOaDXdGnQUKGwDIfQyduB6YD3Ns,1982
|
| 106 |
+
fsspec/tests/abstract/put.py,sha256=7aih17OKB_IZZh1Mkq1eBDIjobhtMQmI8x-Pw-S_aZk,21201
|
| 107 |
+
fsspec/transaction.py,sha256=xliRG6U2Zf3khG4xcw9WiB-yAoqJSHEGK_VjHOdtgo0,2398
|
| 108 |
+
fsspec/utils.py,sha256=dVaokocjhMOnO3B1KmKlgxYqojQJyzb3mgIfaAaz8Pk,22941
|
llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/REQUESTED
ADDED
|
File without changes
|
llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: hatchling 1.25.0
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
llava_next/lib/python3.10/site-packages/fsspec-2024.10.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
BSD 3-Clause License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018, Martin Durant
|
| 4 |
+
All rights reserved.
|
| 5 |
+
|
| 6 |
+
Redistribution and use in source and binary forms, with or without
|
| 7 |
+
modification, are permitted provided that the following conditions are met:
|
| 8 |
+
|
| 9 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 10 |
+
list of conditions and the following disclaimer.
|
| 11 |
+
|
| 12 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 13 |
+
this list of conditions and the following disclaimer in the documentation
|
| 14 |
+
and/or other materials provided with the distribution.
|
| 15 |
+
|
| 16 |
+
* Neither the name of the copyright holder nor the names of its
|
| 17 |
+
contributors may be used to endorse or promote products derived from
|
| 18 |
+
this software without specific prior written permission.
|
| 19 |
+
|
| 20 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 21 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 22 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 23 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 24 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 25 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 26 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 27 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 28 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2016 Ronie Martinez
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
Summary: Pure Python library for LaTeX to MathML conversion
|
| 5 |
+
Home-page: https://github.com/roniemartinez/latex2mathml
|
| 6 |
+
License: MIT
|
| 7 |
+
Keywords: latex,mathml
|
| 8 |
+
Author: Ronie Martinez
|
| 9 |
+
Author-email: ronmarti18@gmail.com
|
| 10 |
+
Requires-Python: >=3.8.1,<4.0.0
|
| 11 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 12 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 13 |
+
Classifier: Programming Language :: Python :: 3
|
| 14 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 19 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 20 |
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
| 21 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 22 |
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
| 23 |
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
| 24 |
+
Project-URL: Donate, https://www.buymeacoffee.com/roniemartinez
|
| 25 |
+
Project-URL: Repository, https://github.com/roniemartinez/latex2mathml
|
| 26 |
+
Description-Content-Type: text/markdown
|
| 27 |
+
|
| 28 |
+
<table>
|
| 29 |
+
<tr>
|
| 30 |
+
<td>License</td>
|
| 31 |
+
<td><img src='https://img.shields.io/pypi/l/latex2mathml.svg?style=for-the-badge' alt="License"></td>
|
| 32 |
+
<td>Version</td>
|
| 33 |
+
<td><img src='https://img.shields.io/pypi/v/latex2mathml.svg?logo=pypi&style=for-the-badge' alt="Version"></td>
|
| 34 |
+
</tr>
|
| 35 |
+
<tr>
|
| 36 |
+
<td>Github Actions</td>
|
| 37 |
+
<td><img src='https://img.shields.io/github/actions/workflow/status/roniemartinez/latex2mathml/python.yml?branch=master&label=actions&logo=github%20actions&style=for-the-badge' alt="Github Actions"></td>
|
| 38 |
+
<td>Coverage</td>
|
| 39 |
+
<td><img src='https://img.shields.io/codecov/c/github/roniemartinez/latex2mathml/master?label=codecov&logo=codecov&style=for-the-badge' alt="CodeCov"></td>
|
| 40 |
+
</tr>
|
| 41 |
+
<tr>
|
| 42 |
+
<td>Supported versions</td>
|
| 43 |
+
<td><img src='https://img.shields.io/pypi/pyversions/latex2mathml.svg?logo=python&style=for-the-badge' alt="Python Versions"></td>
|
| 44 |
+
<td>Wheel</td>
|
| 45 |
+
<td><img src='https://img.shields.io/pypi/wheel/latex2mathml.svg?style=for-the-badge' alt="Wheel"></td>
|
| 46 |
+
</tr>
|
| 47 |
+
<tr>
|
| 48 |
+
<td>Status</td>
|
| 49 |
+
<td><img src='https://img.shields.io/pypi/status/latex2mathml.svg?style=for-the-badge' alt="Status"></td>
|
| 50 |
+
<td>Downloads</td>
|
| 51 |
+
<td><img src='https://img.shields.io/pypi/dm/latex2mathml.svg?style=for-the-badge' alt="Downloads"></td>
|
| 52 |
+
</tr>
|
| 53 |
+
<tr>
|
| 54 |
+
<td>All Contributors</td>
|
| 55 |
+
<td><a href="#contributors-"><img src='https://img.shields.io/github/all-contributors/roniemartinez/latex2mathml?style=for-the-badge' alt="All Contributors"></a></td>
|
| 56 |
+
</tr>
|
| 57 |
+
</table>
|
| 58 |
+
|
| 59 |
+
# latex2mathml
|
| 60 |
+
|
| 61 |
+
Pure Python library for LaTeX to MathML conversion
|
| 62 |
+
|
| 63 |
+
## Installation
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
pip install latex2mathml
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## Usage
|
| 70 |
+
|
| 71 |
+
### Python
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
import latex2mathml.converter
|
| 75 |
+
|
| 76 |
+
latex_input = "<your_latex_string>"
|
| 77 |
+
mathml_output = latex2mathml.converter.convert(latex_input)
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
### Command-line
|
| 81 |
+
|
| 82 |
+
```shell
|
| 83 |
+
% latex2mathml -h
|
| 84 |
+
usage: latex2mathml [-h] [-V] [-b] [-t TEXT | -f FILE | -s]
|
| 85 |
+
|
| 86 |
+
Pure Python library for LaTeX to MathML conversion
|
| 87 |
+
|
| 88 |
+
options:
|
| 89 |
+
-h, --help show this help message and exit
|
| 90 |
+
-V, --version Show version
|
| 91 |
+
-b, --block Display block
|
| 92 |
+
|
| 93 |
+
required arguments:
|
| 94 |
+
-t TEXT, --text TEXT Text
|
| 95 |
+
-f FILE, --file FILE File
|
| 96 |
+
-s, --stdin Stdin
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## References
|
| 100 |
+
### LaTeX
|
| 101 |
+
|
| 102 |
+
- https://en.wikibooks.org/wiki/LaTeX/Mathematics
|
| 103 |
+
- http://artofproblemsolving.com/wiki/index.php?title=Main_Page
|
| 104 |
+
- http://milde.users.sourceforge.net/LUCR/Math/
|
| 105 |
+
- https://math-linux.com/latex-26/faq/latex-faq/article/latex-derivatives-limits-sums-products-and-integrals
|
| 106 |
+
- https://www.tutorialspoint.com/tex_commands
|
| 107 |
+
- https://www.giss.nasa.gov/tools/latex/ltx-86.html
|
| 108 |
+
- https://ftp.gwdg.de/pub/ctan/info/l2tabu/english/l2tabuen.pdf
|
| 109 |
+
|
| 110 |
+
### MathML
|
| 111 |
+
|
| 112 |
+
- http://www.xmlmind.com/tutorials/MathML/
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
## Author
|
| 116 |
+
|
| 117 |
+
- [Ronie Martinez](mailto:ronmarti18@gmail.com)
|
| 118 |
+
|
| 119 |
+
## Contributors ✨
|
| 120 |
+
|
| 121 |
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
| 122 |
+
|
| 123 |
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
| 124 |
+
<!-- prettier-ignore-start -->
|
| 125 |
+
<!-- markdownlint-disable -->
|
| 126 |
+
<table>
|
| 127 |
+
<tbody>
|
| 128 |
+
<tr>
|
| 129 |
+
<td align="center" valign="top" width="14.28%"><a href="https://ron.sh"><img src="https://avatars.githubusercontent.com/u/2573537?v=4?s=100" width="100px;" alt="Ronie Martinez"/><br /><sub><b>Ronie Martinez</b></sub></a><br /><a href="#maintenance-roniemartinez" title="Maintenance">🚧</a> <a href="https://github.com/roniemartinez/latex2mathml/commits?author=roniemartinez" title="Code">💻</a> <a href="#infra-roniemartinez" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
| 130 |
+
<td align="center" valign="top" width="14.28%"><a href="https://anwen.cc/"><img src="https://avatars.githubusercontent.com/u/1472850?v=4?s=100" width="100px;" alt="askender"/><br /><sub><b>askender</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/commits?author=askender" title="Documentation">📖</a></td>
|
| 131 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/06180339"><img src="https://avatars.githubusercontent.com/u/25408501?v=4?s=100" width="100px;" alt="06180339"/><br /><sub><b>06180339</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/commits?author=06180339" title="Code">💻</a></td>
|
| 132 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chaihahaha"><img src="https://avatars.githubusercontent.com/u/24356676?v=4?s=100" width="100px;" alt="chaihahaha"/><br /><sub><b>chaihahaha</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/commits?author=chaihahaha" title="Code">💻</a></td>
|
| 133 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/huangradio"><img src="https://avatars.githubusercontent.com/u/63624395?v=4?s=100" width="100px;" alt="HQY"/><br /><sub><b>HQY</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Ahuangradio" title="Bug reports">🐛</a></td>
|
| 134 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Sun-ZhenXing"><img src="https://avatars.githubusercontent.com/u/44517244?v=4?s=100" width="100px;" alt="鸭梨"/><br /><sub><b>鸭梨</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3ASun-ZhenXing" title="Bug reports">🐛</a></td>
|
| 135 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oliverstefanov"><img src="https://avatars.githubusercontent.com/u/33491656?v=4?s=100" width="100px;" alt="oliverstefanov"/><br /><sub><b>oliverstefanov</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aoliverstefanov" title="Bug reports">🐛</a></td>
|
| 136 |
+
</tr>
|
| 137 |
+
<tr>
|
| 138 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ghost"><img src="https://avatars.githubusercontent.com/u/10137?v=4?s=100" width="100px;" alt="Deleted user"/><br /><sub><b>Deleted user</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aghost" title="Bug reports">🐛</a></td>
|
| 139 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/cesaryuan"><img src="https://avatars.githubusercontent.com/u/35998162?v=4?s=100" width="100px;" alt="Cesaryuan"/><br /><sub><b>Cesaryuan</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Acesaryuan" title="Bug reports">🐛</a></td>
|
| 140 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tonystank3000"><img src="https://avatars.githubusercontent.com/u/6315974?v=4?s=100" width="100px;" alt="TonyStank"/><br /><sub><b>TonyStank</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Atonystank3000" title="Bug reports">🐛</a></td>
|
| 141 |
+
<td align="center" valign="top" width="14.28%"><a href="https://polarwinkel.de"><img src="https://avatars.githubusercontent.com/u/1512713?v=4?s=100" width="100px;" alt="Dirk Winkel"/><br /><sub><b>Dirk Winkel</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Apolarwinkel" title="Bug reports">🐛</a></td>
|
| 142 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sinslu"><img src="https://avatars.githubusercontent.com/u/12248270?v=4?s=100" width="100px;" alt="sinslu"/><br /><sub><b>sinslu</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Asinslu" title="Bug reports">🐛</a></td>
|
| 143 |
+
<td align="center" valign="top" width="14.28%"><a href="https://ubavic.rs"><img src="https://avatars.githubusercontent.com/u/53820106?v=4?s=100" width="100px;" alt="Nikola Ubavić"/><br /><sub><b>Nikola Ubavić</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aubavic" title="Bug reports">🐛</a></td>
|
| 144 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/abhisheksia"><img src="https://avatars.githubusercontent.com/u/68808662?v=4?s=100" width="100px;" alt="abhisheksia"/><br /><sub><b>abhisheksia</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aabhisheksia" title="Bug reports">🐛</a></td>
|
| 145 |
+
</tr>
|
| 146 |
+
<tr>
|
| 147 |
+
<td align="center" valign="top" width="14.28%"><a href="http://denissalem.tuxfamily.org"><img src="https://avatars.githubusercontent.com/u/4476506?v=4?s=100" width="100px;" alt="Denis Salem"/><br /><sub><b>Denis Salem</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3ADenisSalem" title="Bug reports">🐛</a> <a href="https://github.com/roniemartinez/latex2mathml/commits?author=DenisSalem" title="Code">💻</a></td>
|
| 148 |
+
<td align="center" valign="top" width="14.28%"><a href="https://clontz.org"><img src="https://avatars.githubusercontent.com/u/1559632?v=4?s=100" width="100px;" alt="Steven Clontz"/><br /><sub><b>Steven Clontz</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3AStevenClontz" title="Bug reports">🐛</a></td>
|
| 149 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yuwenjun1"><img src="https://avatars.githubusercontent.com/u/43265090?v=4?s=100" width="100px;" alt="空白"/><br /><sub><b>空白</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Ayuwenjun1" title="Bug reports">🐛</a></td>
|
| 150 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/amuramatsu"><img src="https://avatars.githubusercontent.com/u/6500918?v=4?s=100" width="100px;" alt="MURAMATSU Atshshi"/><br /><sub><b>MURAMATSU Atshshi</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aamuramatsu" title="Bug reports">🐛</a></td>
|
| 151 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/leingang"><img src="https://avatars.githubusercontent.com/u/570942?v=4?s=100" width="100px;" alt="leingang"/><br /><sub><b>leingang</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aleingang" title="Bug reports">🐛</a></td>
|
| 152 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Nigel-Amers"><img src="https://avatars.githubusercontent.com/u/14248498?v=4?s=100" width="100px;" alt="Nigel Amers"/><br /><sub><b>Nigel Amers</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3ANigel-Amers" title="Bug reports">🐛</a></td>
|
| 153 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/retsyo"><img src="https://avatars.githubusercontent.com/u/7960913?v=4?s=100" width="100px;" alt="retsyo"/><br /><sub><b>retsyo</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Aretsyo" title="Bug reports">🐛</a></td>
|
| 154 |
+
</tr>
|
| 155 |
+
<tr>
|
| 156 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/miakramer"><img src="https://avatars.githubusercontent.com/u/16845265?v=4?s=100" width="100px;" alt="Mia Kramer"/><br /><sub><b>Mia Kramer</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/commits?author=miakramer" title="Code">💻</a> <a href="https://github.com/roniemartinez/latex2mathml/commits?author=miakramer" title="Documentation">📖</a></td>
|
| 157 |
+
<td align="center" valign="top" width="14.28%"><a href="http://cnx.gdn"><img src="https://avatars.githubusercontent.com/u/13689192?v=4?s=100" width="100px;" alt="Nguyễn Gia Phong"/><br /><sub><b>Nguyễn Gia Phong</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3AMcSinyx" title="Bug reports">🐛</a> <a href="https://github.com/roniemartinez/latex2mathml/commits?author=McSinyx" title="Code">💻</a> <a href="https://github.com/roniemartinez/latex2mathml/commits?author=McSinyx" title="Tests">⚠️</a></td>
|
| 158 |
+
<td align="center" valign="top" width="14.28%"><a href="https://cdelker.github.io"><img src="https://avatars.githubusercontent.com/u/44102190?v=4?s=100" width="100px;" alt="Collin Delker"/><br /><sub><b>Collin Delker</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Acdelker" title="Bug reports">🐛</a></td>
|
| 159 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jiotv321"><img src="https://avatars.githubusercontent.com/u/118644533?v=4?s=100" width="100px;" alt="jiotv321"/><br /><sub><b>jiotv321</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/issues?q=author%3Ajiotv321" title="Bug reports">🐛</a></td>
|
| 160 |
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/felixonmars"><img src="https://avatars.githubusercontent.com/u/1006477?v=4?s=100" width="100px;" alt="Felix Yan"/><br /><sub><b>Felix Yan</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/commits?author=felixonmars" title="Code">💻</a></td>
|
| 161 |
+
<td align="center" valign="top" width="14.28%"><a href="https://rob-blackbourn.github.io/blog/"><img src="https://avatars.githubusercontent.com/u/2880305?v=4?s=100" width="100px;" alt="Rob Blackbourn"/><br /><sub><b>Rob Blackbourn</b></sub></a><br /><a href="https://github.com/roniemartinez/latex2mathml/commits?author=rob-blackbourn" title="Code">💻</a></td>
|
| 162 |
+
</tr>
|
| 163 |
+
</tbody>
|
| 164 |
+
</table>
|
| 165 |
+
|
| 166 |
+
<!-- markdownlint-restore -->
|
| 167 |
+
<!-- prettier-ignore-end -->
|
| 168 |
+
|
| 169 |
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
| 170 |
+
|
| 171 |
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
| 172 |
+
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/l2m,sha256=tiRsFHuNF2Y1lraq2gGaQg1Zkg_6YLd9DEP9CMfowBM,237
|
| 2 |
+
../../../bin/latex2mathml,sha256=tiRsFHuNF2Y1lraq2gGaQg1Zkg_6YLd9DEP9CMfowBM,237
|
| 3 |
+
latex2mathml-3.77.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 4 |
+
latex2mathml-3.77.0.dist-info/LICENSE,sha256=SsHh2gf2s0PVQZHF4XFoQFNOCFkbP56uyQ1oAM3EdUM,1071
|
| 5 |
+
latex2mathml-3.77.0.dist-info/METADATA,sha256=8I_5snYGZtFTF_ZdrISzE_x4L1PcEc9WFhHJfwkOUhA,14844
|
| 6 |
+
latex2mathml-3.77.0.dist-info/RECORD,,
|
| 7 |
+
latex2mathml-3.77.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 8 |
+
latex2mathml-3.77.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
| 9 |
+
latex2mathml-3.77.0.dist-info/entry_points.txt,sha256=8cs8b08QDIhqIeEJaUBPeXlBTEE9a-d8ybiKa5ZGMak,92
|
| 10 |
+
latex2mathml/__init__.py,sha256=xA5GqWgZqbTv0TUeOiwBpOk8D48ibElsZI1OGTEnhuk,79
|
| 11 |
+
latex2mathml/__pycache__/__init__.cpython-310.pyc,,
|
| 12 |
+
latex2mathml/__pycache__/commands.cpython-310.pyc,,
|
| 13 |
+
latex2mathml/__pycache__/converter.cpython-310.pyc,,
|
| 14 |
+
latex2mathml/__pycache__/exceptions.cpython-310.pyc,,
|
| 15 |
+
latex2mathml/__pycache__/symbols_parser.cpython-310.pyc,,
|
| 16 |
+
latex2mathml/__pycache__/tokenizer.cpython-310.pyc,,
|
| 17 |
+
latex2mathml/__pycache__/walker.cpython-310.pyc,,
|
| 18 |
+
latex2mathml/commands.py,sha256=ZyBodQ-PqYfg4-LG6YipiDywzc5iUlYCLA1WTV5La04,13087
|
| 19 |
+
latex2mathml/converter.py,sha256=a3CTyam1xFz2oPkNVxklSXuPny_DmqnALLsDTRLVmeI,23219
|
| 20 |
+
latex2mathml/exceptions.py,sha256=zF1xPclVRSTzvZHPsujMv_bNITnHNW7Jvi4wg0aBQ60,645
|
| 21 |
+
latex2mathml/py.typed,sha256=JZLABTSp2pMHV6dDrYko_mqeQOmCl7_w46Ro2OaynOo,10
|
| 22 |
+
latex2mathml/symbols_parser.py,sha256=xZr_xYVWOj1-3GpdVKd0ly44AAkc2wvSmIUvbHBcJfg,2954
|
| 23 |
+
latex2mathml/tokenizer.py,sha256=FtlIzWm279chdDE6SrIohMDeHIcwT8GCeyNqexxHu94,2360
|
| 24 |
+
latex2mathml/unimathsymbols.txt,sha256=dO-JVO-vAdwfsTExPvbX97dBxPeOMPbW02ALndWlWu4,216334
|
| 25 |
+
latex2mathml/walker.py,sha256=3KZEjg4WbWQUogHmKO5yp0Ziu2n_m1JvyQs3sQc5fPA,19969
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/REQUESTED
ADDED
|
File without changes
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: poetry-core 1.8.1
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
llava_next/lib/python3.10/site-packages/latex2mathml-3.77.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
l2m=latex2mathml.converter:main
|
| 3 |
+
latex2mathml=latex2mathml.converter:main
|
| 4 |
+
|
llava_next/lib/python3.10/site-packages/psutil/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (64.6 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/METADATA
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/RECORD
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
pydantic-2.9.2.dist-info/METADATA,sha256=ZQRCMLgcMWSgD0B6N5pY5lGQhRXqVliW7FtsoMle4tg,149443
|
| 3 |
+
pydantic-2.9.2.dist-info/RECORD,,
|
| 4 |
+
pydantic-2.9.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 5 |
+
pydantic-2.9.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
| 6 |
+
pydantic-2.9.2.dist-info/licenses/LICENSE,sha256=qeGG88oWte74QxjnpwFyE1GgDLe4rjpDlLZ7SeNSnvM,1129
|
| 7 |
+
pydantic/__init__.py,sha256=HC9s-yPBr3EPLzc3kl_ak2FPMUz3mRvAHQ-usIMKdbk,14484
|
| 8 |
+
pydantic/__pycache__/__init__.cpython-310.pyc,,
|
| 9 |
+
pydantic/__pycache__/_migration.cpython-310.pyc,,
|
| 10 |
+
pydantic/__pycache__/alias_generators.cpython-310.pyc,,
|
| 11 |
+
pydantic/__pycache__/aliases.cpython-310.pyc,,
|
| 12 |
+
pydantic/__pycache__/annotated_handlers.cpython-310.pyc,,
|
| 13 |
+
pydantic/__pycache__/class_validators.cpython-310.pyc,,
|
| 14 |
+
pydantic/__pycache__/color.cpython-310.pyc,,
|
| 15 |
+
pydantic/__pycache__/config.cpython-310.pyc,,
|
| 16 |
+
pydantic/__pycache__/dataclasses.cpython-310.pyc,,
|
| 17 |
+
pydantic/__pycache__/datetime_parse.cpython-310.pyc,,
|
| 18 |
+
pydantic/__pycache__/decorator.cpython-310.pyc,,
|
| 19 |
+
pydantic/__pycache__/env_settings.cpython-310.pyc,,
|
| 20 |
+
pydantic/__pycache__/error_wrappers.cpython-310.pyc,,
|
| 21 |
+
pydantic/__pycache__/errors.cpython-310.pyc,,
|
| 22 |
+
pydantic/__pycache__/fields.cpython-310.pyc,,
|
| 23 |
+
pydantic/__pycache__/functional_serializers.cpython-310.pyc,,
|
| 24 |
+
pydantic/__pycache__/functional_validators.cpython-310.pyc,,
|
| 25 |
+
pydantic/__pycache__/generics.cpython-310.pyc,,
|
| 26 |
+
pydantic/__pycache__/json.cpython-310.pyc,,
|
| 27 |
+
pydantic/__pycache__/json_schema.cpython-310.pyc,,
|
| 28 |
+
pydantic/__pycache__/main.cpython-310.pyc,,
|
| 29 |
+
pydantic/__pycache__/mypy.cpython-310.pyc,,
|
| 30 |
+
pydantic/__pycache__/networks.cpython-310.pyc,,
|
| 31 |
+
pydantic/__pycache__/parse.cpython-310.pyc,,
|
| 32 |
+
pydantic/__pycache__/root_model.cpython-310.pyc,,
|
| 33 |
+
pydantic/__pycache__/schema.cpython-310.pyc,,
|
| 34 |
+
pydantic/__pycache__/tools.cpython-310.pyc,,
|
| 35 |
+
pydantic/__pycache__/type_adapter.cpython-310.pyc,,
|
| 36 |
+
pydantic/__pycache__/types.cpython-310.pyc,,
|
| 37 |
+
pydantic/__pycache__/typing.cpython-310.pyc,,
|
| 38 |
+
pydantic/__pycache__/utils.cpython-310.pyc,,
|
| 39 |
+
pydantic/__pycache__/validate_call_decorator.cpython-310.pyc,,
|
| 40 |
+
pydantic/__pycache__/validators.cpython-310.pyc,,
|
| 41 |
+
pydantic/__pycache__/version.cpython-310.pyc,,
|
| 42 |
+
pydantic/__pycache__/warnings.cpython-310.pyc,,
|
| 43 |
+
pydantic/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 44 |
+
pydantic/_internal/__pycache__/__init__.cpython-310.pyc,,
|
| 45 |
+
pydantic/_internal/__pycache__/_config.cpython-310.pyc,,
|
| 46 |
+
pydantic/_internal/__pycache__/_core_metadata.cpython-310.pyc,,
|
| 47 |
+
pydantic/_internal/__pycache__/_core_utils.cpython-310.pyc,,
|
| 48 |
+
pydantic/_internal/__pycache__/_dataclasses.cpython-310.pyc,,
|
| 49 |
+
pydantic/_internal/__pycache__/_decorators.cpython-310.pyc,,
|
| 50 |
+
pydantic/_internal/__pycache__/_decorators_v1.cpython-310.pyc,,
|
| 51 |
+
pydantic/_internal/__pycache__/_discriminated_union.cpython-310.pyc,,
|
| 52 |
+
pydantic/_internal/__pycache__/_docs_extraction.cpython-310.pyc,,
|
| 53 |
+
pydantic/_internal/__pycache__/_fields.cpython-310.pyc,,
|
| 54 |
+
pydantic/_internal/__pycache__/_forward_ref.cpython-310.pyc,,
|
| 55 |
+
pydantic/_internal/__pycache__/_generate_schema.cpython-310.pyc,,
|
| 56 |
+
pydantic/_internal/__pycache__/_generics.cpython-310.pyc,,
|
| 57 |
+
pydantic/_internal/__pycache__/_git.cpython-310.pyc,,
|
| 58 |
+
pydantic/_internal/__pycache__/_import_utils.cpython-310.pyc,,
|
| 59 |
+
pydantic/_internal/__pycache__/_internal_dataclass.cpython-310.pyc,,
|
| 60 |
+
pydantic/_internal/__pycache__/_known_annotated_metadata.cpython-310.pyc,,
|
| 61 |
+
pydantic/_internal/__pycache__/_mock_val_ser.cpython-310.pyc,,
|
| 62 |
+
pydantic/_internal/__pycache__/_model_construction.cpython-310.pyc,,
|
| 63 |
+
pydantic/_internal/__pycache__/_repr.cpython-310.pyc,,
|
| 64 |
+
pydantic/_internal/__pycache__/_schema_generation_shared.cpython-310.pyc,,
|
| 65 |
+
pydantic/_internal/__pycache__/_serializers.cpython-310.pyc,,
|
| 66 |
+
pydantic/_internal/__pycache__/_signature.cpython-310.pyc,,
|
| 67 |
+
pydantic/_internal/__pycache__/_std_types_schema.cpython-310.pyc,,
|
| 68 |
+
pydantic/_internal/__pycache__/_typing_extra.cpython-310.pyc,,
|
| 69 |
+
pydantic/_internal/__pycache__/_utils.cpython-310.pyc,,
|
| 70 |
+
pydantic/_internal/__pycache__/_validate_call.cpython-310.pyc,,
|
| 71 |
+
pydantic/_internal/__pycache__/_validators.cpython-310.pyc,,
|
| 72 |
+
pydantic/_internal/_config.py,sha256=-5T2bhD3JNHX3oMdt0Esstgsr8dLy_zbSGANA_7l6QE,12444
|
| 73 |
+
pydantic/_internal/_core_metadata.py,sha256=qVn3XpuIiv57L2jvSzqrjm3AqDs9c9EQhx7tsJ-s-zo,3665
|
| 74 |
+
pydantic/_internal/_core_utils.py,sha256=PG-BO0bej6kOi-HZ8Mmrck0tG5PzBGIlvJzlnvUWCFs,24387
|
| 75 |
+
pydantic/_internal/_dataclasses.py,sha256=tlWlcY4Gp8uMOrvSlrXAW5JSWPhmGak7mER3ESOa-pE,8774
|
| 76 |
+
pydantic/_internal/_decorators.py,sha256=IDo2GuhyZt1DsEjui3R9NAMa53OX819tH-yYiF_sJog,32511
|
| 77 |
+
pydantic/_internal/_decorators_v1.py,sha256=I7Px8gUMJod80_zBMlNkRVq0Mp2Z6mk1T1A4b_0a3Ps,6203
|
| 78 |
+
pydantic/_internal/_discriminated_union.py,sha256=XDzlfKc7LAkJJErQWAZ4EuP_G_CQXJSVFKtwuHRJEmg,26435
|
| 79 |
+
pydantic/_internal/_docs_extraction.py,sha256=bIWhw7nFKFt-qD-txtKRAb5VqGlAD0H9YzEEXE3PHj4,3791
|
| 80 |
+
pydantic/_internal/_fields.py,sha256=BmTevtxubFhm9gfRrn9MgtuoLGlCt0jWcsJ9B_e2q24,14053
|
| 81 |
+
pydantic/_internal/_forward_ref.py,sha256=5n3Y7-3AKLn8_FS3Yc7KutLiPUhyXmAtkEZOaFnonwM,611
|
| 82 |
+
pydantic/_internal/_generate_schema.py,sha256=6KV3kHt0X95H6yXMS_S7zwyt7ieeNT65Fl7TEhY-B6w,115069
|
| 83 |
+
pydantic/_internal/_generics.py,sha256=KA6aNzLwHlI69d5ZuQW82_cUaRrAf6i4Su0-PoGudWk,22226
|
| 84 |
+
pydantic/_internal/_git.py,sha256=lN6QlZm8RNSuNsUdHHC1F5a4VToe8vu5tlUxAfaJgGE,784
|
| 85 |
+
pydantic/_internal/_import_utils.py,sha256=eLe9Aa1GMQB4TD9sKz42yyJBTiTAjBfCuua_rYFTrQo,448
|
| 86 |
+
pydantic/_internal/_internal_dataclass.py,sha256=_bedc1XbuuygRGiLZqkUkwwFpQaoR1hKLlR501nyySY,144
|
| 87 |
+
pydantic/_internal/_known_annotated_metadata.py,sha256=POjTWdc9kpHzK95TwTu5Jgs3v8XfkxGtCNKVPtKNJl0,16389
|
| 88 |
+
pydantic/_internal/_mock_val_ser.py,sha256=g_RJhhodJOWnIrxwYRGNGA1v21eh5UrlfTP-7-ommMw,7315
|
| 89 |
+
pydantic/_internal/_model_construction.py,sha256=9iyybkdjFijWTRIvA65b1CJB6WK9TqXsG9FauMFxBgY,33137
|
| 90 |
+
pydantic/_internal/_repr.py,sha256=_PwsWGy5exFmPHhjZfvTEC8zIWJX0z-HYU2hbSAi1NQ,4564
|
| 91 |
+
pydantic/_internal/_schema_generation_shared.py,sha256=SB5kMqd9pzW9V4M4qjyI7R99MHzU1rfQVkNWP-KsiLM,4853
|
| 92 |
+
pydantic/_internal/_serializers.py,sha256=s0peFJTaHTfdmr4V-l6n3Dh-57ZHeUo8oJcq3NOjJNI,1356
|
| 93 |
+
pydantic/_internal/_signature.py,sha256=FDlxx0TUtRJySM9xtlrsSgwru80diZu5_Pp-w8g32ws,6268
|
| 94 |
+
pydantic/_internal/_std_types_schema.py,sha256=fOT_Orgb5q24UVGeyk_sqMdELokxd3V07YoZ6-vMtp0,16023
|
| 95 |
+
pydantic/_internal/_typing_extra.py,sha256=t_TNQiH2fkwtR5RkvZ1iUA0Fkop1BWYOA_wc2WL4lKQ,22219
|
| 96 |
+
pydantic/_internal/_utils.py,sha256=6hNAMy6j2lcROMfr_iDG8HuVlpaYo7dslZWyQb1nfhU,12723
|
| 97 |
+
pydantic/_internal/_validate_call.py,sha256=ZvVFpCWy5ZwMXJK4hjOF_5v73Fpz7ZXrQ5ugTb3uxGU,3783
|
| 98 |
+
pydantic/_internal/_validators.py,sha256=M_qGIj5_dNkHJKe3_zweU9FevHshObBn4XKk4tms9iU,12089
|
| 99 |
+
pydantic/_migration.py,sha256=j6TbRpJofjAX8lr-k2nVnQcBR9RD2B91I7Ulcw_ZzEo,11913
|
| 100 |
+
pydantic/alias_generators.py,sha256=KM1n3u4JfLSBl1UuYg3hoYHzXJD-yvgrnq8u1ccwh_A,2124
|
| 101 |
+
pydantic/aliases.py,sha256=kySXX0hIhlO1Ifz6QwH7LaGxiBGP943DC5NNaN7qwEo,4819
|
| 102 |
+
pydantic/annotated_handlers.py,sha256=yCeE8kQnLxZCWzT8f689hvwqqepEBW_byDUpVRJwnrM,4353
|
| 103 |
+
pydantic/class_validators.py,sha256=i_V3j-PYdGLSLmj_IJZekTRjunO8SIVz8LMlquPyP7E,148
|
| 104 |
+
pydantic/color.py,sha256=4GrtPvFCBKdM-1NpLVFOC7KkLejyZd1BiELfCKvT2yw,21494
|
| 105 |
+
pydantic/config.py,sha256=pjSZeP_JAVvGwsoTeYtRPM3E576quZE3t7iy8M_Z6PM,35602
|
| 106 |
+
pydantic/dataclasses.py,sha256=496d-nluztWFkekte1uwxZFvQr3kTjyAtiKo8t7A0Tc,14678
|
| 107 |
+
pydantic/datetime_parse.py,sha256=QC-WgMxMr_wQ_mNXUS7AVf-2hLEhvvsPY1PQyhSGOdk,150
|
| 108 |
+
pydantic/decorator.py,sha256=YX-jUApu5AKaVWKPoaV-n-4l7UbS69GEt9Ra3hszmKI,145
|
| 109 |
+
pydantic/deprecated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 110 |
+
pydantic/deprecated/__pycache__/__init__.cpython-310.pyc,,
|
| 111 |
+
pydantic/deprecated/__pycache__/class_validators.cpython-310.pyc,,
|
| 112 |
+
pydantic/deprecated/__pycache__/config.cpython-310.pyc,,
|
| 113 |
+
pydantic/deprecated/__pycache__/copy_internals.cpython-310.pyc,,
|
| 114 |
+
pydantic/deprecated/__pycache__/decorator.cpython-310.pyc,,
|
| 115 |
+
pydantic/deprecated/__pycache__/json.cpython-310.pyc,,
|
| 116 |
+
pydantic/deprecated/__pycache__/parse.cpython-310.pyc,,
|
| 117 |
+
pydantic/deprecated/__pycache__/tools.cpython-310.pyc,,
|
| 118 |
+
pydantic/deprecated/class_validators.py,sha256=IARV4v0NuHCZVVc_ItfaVNJOk1Vful7iv8bawj9o4Uw,10245
|
| 119 |
+
pydantic/deprecated/config.py,sha256=eKhnG--ZQtJ4A7KA3xeF76E15-4pVau3B5T8D39ptFs,2663
|
| 120 |
+
pydantic/deprecated/copy_internals.py,sha256=SoUj1MevXt3fnloqNg5wivSUHSDPnuSj_YydzkEMzu0,7595
|
| 121 |
+
pydantic/deprecated/decorator.py,sha256=P2V1bCwk8wNJ3g_s2p2ASFefXPLKn8bsUVw-Y8Wwcvk,10776
|
| 122 |
+
pydantic/deprecated/json.py,sha256=PIzc-zAZxL-7O2gW7tY986XASvgsgD-J1D5pmhd-JLM,4669
|
| 123 |
+
pydantic/deprecated/parse.py,sha256=Gzd6b_g8zJXcuE7QRq5adhx_EMJahXfcpXCF0RgrqqI,2511
|
| 124 |
+
pydantic/deprecated/tools.py,sha256=XUoIW9W4sgOUWQ6Xzf-Z_NukUC1l_yUwz2_n0fE3MEI,3336
|
| 125 |
+
pydantic/env_settings.py,sha256=6IHeeWEqlUPRUv3V-AXiF_W91fg2Jw_M3O0l34J_eyA,148
|
| 126 |
+
pydantic/error_wrappers.py,sha256=RK6mqATc9yMD-KBD9IJS9HpKCprWHd8wo84Bnm-3fR8,150
|
| 127 |
+
pydantic/errors.py,sha256=hAHNKyxTUIOVsXBS-P9w4ocsdBu-BMXK7TwpmhZCxDc,4863
|
| 128 |
+
pydantic/experimental/__init__.py,sha256=j08eROfz-xW4k_X9W4m2AW26IVdyF3Eg1OzlIGA11vk,328
|
| 129 |
+
pydantic/experimental/__pycache__/__init__.cpython-310.pyc,,
|
| 130 |
+
pydantic/experimental/__pycache__/pipeline.cpython-310.pyc,,
|
| 131 |
+
pydantic/experimental/pipeline.py,sha256=PjiTnmaN5XwLUk-Nlzfr2C2R-xrMz7Nz-XVC8kiFGyU,23979
|
| 132 |
+
pydantic/fields.py,sha256=DxhB8Oy1-0fyz2ZROPoazTk8fSMQGWnkSACcrXbU4tA,52295
|
| 133 |
+
pydantic/functional_serializers.py,sha256=-s-JRdLrlJp03tfRq7tBYw_o3VBs11UbfFZ7z-vZEBA,16336
|
| 134 |
+
pydantic/functional_validators.py,sha256=xLZfiQBsivL1jS6SQjhZ2yMW-wvKs00ti993BbPao2g,28785
|
| 135 |
+
pydantic/generics.py,sha256=0ZqZ9O9annIj_3mGBRqps4htey3b5lV1-d2tUxPMMnA,144
|
| 136 |
+
pydantic/json.py,sha256=ZH8RkI7h4Bz-zp8OdTAxbJUoVvcoU-jhMdRZ0B-k0xc,140
|
| 137 |
+
pydantic/json_schema.py,sha256=ZGPGkcl38YJByg0ckkNw-ZgB-mlb6VuiXDQBbhbDjY4,108690
|
| 138 |
+
pydantic/main.py,sha256=oVDrlPp56cOam44k1IKknlTU6bdxOGCAvbFtp1ZXegs,71978
|
| 139 |
+
pydantic/mypy.py,sha256=YfANt7bkOBTB2mWMbPvHxF7Bp-lw6QAeHWoafoPFSRs,60146
|
| 140 |
+
pydantic/networks.py,sha256=pQkOv5WG6lnw8uAjJrhBOsyfxHmaYnjhuPbBBdJq3sY,23497
|
| 141 |
+
pydantic/parse.py,sha256=wkd82dgtvWtD895U_I6E1htqMlGhBSYEV39cuBSeo3A,141
|
| 142 |
+
pydantic/plugin/__init__.py,sha256=7VFbmK5b0_eRpfwfi-XspqNgCvImdR6KSGZwedTXvLc,6116
|
| 143 |
+
pydantic/plugin/__pycache__/__init__.cpython-310.pyc,,
|
| 144 |
+
pydantic/plugin/__pycache__/_loader.cpython-310.pyc,,
|
| 145 |
+
pydantic/plugin/__pycache__/_schema_validator.cpython-310.pyc,,
|
| 146 |
+
pydantic/plugin/_loader.py,sha256=rmLbIwThDmVR1JwFVi_XvrLH7b1A5teMED-O3pr6Gk4,2140
|
| 147 |
+
pydantic/plugin/_schema_validator.py,sha256=VFaNQpVNSuI2ymRDkTwBGaMKeKmySk1TbW-3rQeozxk,5240
|
| 148 |
+
pydantic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 149 |
+
pydantic/root_model.py,sha256=Nt-HpftxnfFa2q6GUTH6DFXQwoekJ3OYPl9YE-6nVbs,6194
|
| 150 |
+
pydantic/schema.py,sha256=Vqqjvq_LnapVknebUd3Bp_J1p2gXZZnZRgL48bVEG7o,142
|
| 151 |
+
pydantic/tools.py,sha256=iHQpd8SJ5DCTtPV5atAV06T89bjSaMFeZZ2LX9lasZY,141
|
| 152 |
+
pydantic/type_adapter.py,sha256=wKfkrSGiY-5RwVBRMoZ_8kwxWaZ2EyprZXFSQV_kjGc,24784
|
| 153 |
+
pydantic/types.py,sha256=4EWSgnFWcriTG2fKAw-mdbcelmDFCGu6CgES1Uj2cJQ,97593
|
| 154 |
+
pydantic/typing.py,sha256=P7feA35MwTcLsR1uL7db0S-oydBxobmXa55YDoBgajQ,138
|
| 155 |
+
pydantic/utils.py,sha256=15nR2QpqTBFlQV4TNtTItMyTJx_fbyV-gPmIEY1Gooc,141
|
| 156 |
+
pydantic/v1/__init__.py,sha256=SxQPklgBs4XHJwE6BZ9qoewYoGiNyYUnmHzEFCZbfnI,2946
|
| 157 |
+
pydantic/v1/__pycache__/__init__.cpython-310.pyc,,
|
| 158 |
+
pydantic/v1/__pycache__/_hypothesis_plugin.cpython-310.pyc,,
|
| 159 |
+
pydantic/v1/__pycache__/annotated_types.cpython-310.pyc,,
|
| 160 |
+
pydantic/v1/__pycache__/class_validators.cpython-310.pyc,,
|
| 161 |
+
pydantic/v1/__pycache__/color.cpython-310.pyc,,
|
| 162 |
+
pydantic/v1/__pycache__/config.cpython-310.pyc,,
|
| 163 |
+
pydantic/v1/__pycache__/dataclasses.cpython-310.pyc,,
|
| 164 |
+
pydantic/v1/__pycache__/datetime_parse.cpython-310.pyc,,
|
| 165 |
+
pydantic/v1/__pycache__/decorator.cpython-310.pyc,,
|
| 166 |
+
pydantic/v1/__pycache__/env_settings.cpython-310.pyc,,
|
| 167 |
+
pydantic/v1/__pycache__/error_wrappers.cpython-310.pyc,,
|
| 168 |
+
pydantic/v1/__pycache__/errors.cpython-310.pyc,,
|
| 169 |
+
pydantic/v1/__pycache__/fields.cpython-310.pyc,,
|
| 170 |
+
pydantic/v1/__pycache__/generics.cpython-310.pyc,,
|
| 171 |
+
pydantic/v1/__pycache__/json.cpython-310.pyc,,
|
| 172 |
+
pydantic/v1/__pycache__/main.cpython-310.pyc,,
|
| 173 |
+
pydantic/v1/__pycache__/mypy.cpython-310.pyc,,
|
| 174 |
+
pydantic/v1/__pycache__/networks.cpython-310.pyc,,
|
| 175 |
+
pydantic/v1/__pycache__/parse.cpython-310.pyc,,
|
| 176 |
+
pydantic/v1/__pycache__/schema.cpython-310.pyc,,
|
| 177 |
+
pydantic/v1/__pycache__/tools.cpython-310.pyc,,
|
| 178 |
+
pydantic/v1/__pycache__/types.cpython-310.pyc,,
|
| 179 |
+
pydantic/v1/__pycache__/typing.cpython-310.pyc,,
|
| 180 |
+
pydantic/v1/__pycache__/utils.cpython-310.pyc,,
|
| 181 |
+
pydantic/v1/__pycache__/validators.cpython-310.pyc,,
|
| 182 |
+
pydantic/v1/__pycache__/version.cpython-310.pyc,,
|
| 183 |
+
pydantic/v1/_hypothesis_plugin.py,sha256=5ES5xWuw1FQAsymLezy8QgnVz0ZpVfU3jkmT74H27VQ,14847
|
| 184 |
+
pydantic/v1/annotated_types.py,sha256=uk2NAAxqiNELKjiHhyhxKaIOh8F1lYW_LzrW3X7oZBc,3157
|
| 185 |
+
pydantic/v1/class_validators.py,sha256=ULOaIUgYUDBsHL7EEVEarcM-UubKUggoN8hSbDonsFE,14672
|
| 186 |
+
pydantic/v1/color.py,sha256=iZABLYp6OVoo2AFkP9Ipri_wSc6-Kklu8YuhSartd5g,16844
|
| 187 |
+
pydantic/v1/config.py,sha256=a6P0Wer9x4cbwKW7Xv8poSUqM4WP-RLWwX6YMpYq9AA,6532
|
| 188 |
+
pydantic/v1/dataclasses.py,sha256=784cqvInbwIPWr9usfpX3ch7z4t3J2tTK6N067_wk1o,18172
|
| 189 |
+
pydantic/v1/datetime_parse.py,sha256=4Qy1kQpq3rNVZJeIHeSPDpuS2Bvhp1KPtzJG1xu-H00,7724
|
| 190 |
+
pydantic/v1/decorator.py,sha256=zaaxxxoWPCm818D1bs0yhapRjXm32V8G0ZHWCdM1uXA,10339
|
| 191 |
+
pydantic/v1/env_settings.py,sha256=A9VXwtRl02AY-jH0C0ouy5VNw3fi6F_pkzuHDjgAAOM,14105
|
| 192 |
+
pydantic/v1/error_wrappers.py,sha256=6625Mfw9qkC2NwitB_JFAWe8B-Xv6zBU7rL9k28tfyo,5196
|
| 193 |
+
pydantic/v1/errors.py,sha256=mIwPED5vGM5Q5v4C4Z1JPldTRH-omvEylH6ksMhOmPw,17726
|
| 194 |
+
pydantic/v1/fields.py,sha256=VqWJCriUNiEyptXroDVJ501JpVA0en2VANcksqXL2b8,50649
|
| 195 |
+
pydantic/v1/generics.py,sha256=VzC9YUV-EbPpQ3aAfk1cNFej79_IzznkQ7WrmTTZS9E,17871
|
| 196 |
+
pydantic/v1/json.py,sha256=WQ5Hy_hIpfdR3YS8k6N2E6KMJzsdbBi_ldWOPJaV81M,3390
|
| 197 |
+
pydantic/v1/main.py,sha256=A48ds4KJN4SgI34YLgPGqi6K3LhO7OwZ3QEy6GERiUc,44541
|
| 198 |
+
pydantic/v1/mypy.py,sha256=AiZYkv127-WsgL9vwvLqj0dS8dz-HUMbH9Yvvlq4bfE,38949
|
| 199 |
+
pydantic/v1/networks.py,sha256=HYNtKAfOmOnKJpsDg1g6SIkj9WPhU_-i8l5e2JKBpG4,22124
|
| 200 |
+
pydantic/v1/parse.py,sha256=BJtdqiZRtav9VRFCmOxoY-KImQmjPy-A_NoojiFUZxY,1821
|
| 201 |
+
pydantic/v1/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 202 |
+
pydantic/v1/schema.py,sha256=aqBuA--cq8gAVkim5BJPFASHzOZ8dFtmFX_fNGr6ip4,47801
|
| 203 |
+
pydantic/v1/tools.py,sha256=1lDdXHk0jL5uP3u5RCYAvUAlGClgAO-45lkq9j7fyBA,2881
|
| 204 |
+
pydantic/v1/types.py,sha256=Fltx5GoP_qaUmAktlGz7nFeJa13yNy3FY1-RcMzEVt8,35455
|
| 205 |
+
pydantic/v1/typing.py,sha256=GjThObaqHMhLaECzYUrDk0X-RHjo7x6vsv4Z4qUYV8I,19387
|
| 206 |
+
pydantic/v1/utils.py,sha256=fvjXCNeaU1jB-_mi0SUk4fzN4OpvX-SKTu4yJMPRIlQ,25941
|
| 207 |
+
pydantic/v1/validators.py,sha256=Dxcx36zVQjBUfYdjQLs_E0qpYqTeNbrF8PQTcasYgrI,21996
|
| 208 |
+
pydantic/v1/version.py,sha256=dlPLtwaIvGUEfWaizEtaIPQGt2D-IzmNUEgYScCqg8c,1039
|
| 209 |
+
pydantic/validate_call_decorator.py,sha256=dir0UrE95IOF95U6VYSO5NRJPx7IhY5FbKTaU5CoAY0,2127
|
| 210 |
+
pydantic/validators.py,sha256=pwbIJXVb1CV2mAE4w_EGfNj7DwzsKaWw_tTL6cviTus,146
|
| 211 |
+
pydantic/version.py,sha256=aY6ElVl0sbt3Pvh7zjb_T6e9U9OtwF3xUaBOxZEBssc,2442
|
| 212 |
+
pydantic/warnings.py,sha256=upMUWaR6WjvIz_3xfk35Y1bmhvRyWN5zwdevbz4tjR4,3029
|
llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/REQUESTED
ADDED
|
File without changes
|
llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: hatchling 1.25.0
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
llava_next/lib/python3.10/site-packages/pydantic-2.9.2.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors.
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
moondream/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9254d0854dd7615e11de28d771ae408878ca8123a7ac204f21e4cc7a376cc2e5
|
| 3 |
+
size 35123345
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (324 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/__pycache__/cable.cpython-310.pyc
ADDED
|
Binary file (16.6 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/__pycache__/truss.cpython-310.pyc
ADDED
|
Binary file (31.5 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/cable.py
ADDED
|
@@ -0,0 +1,587 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 5 |
+
|
| 6 |
+
from sympy.core.sympify import sympify
|
| 7 |
+
from sympy.core.symbol import Symbol
|
| 8 |
+
from sympy import sin, cos, pi, atan, diff
|
| 9 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
| 10 |
+
from sympy.solvers.solveset import linsolve
|
| 11 |
+
from sympy.matrices import Matrix
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class Cable:
|
| 15 |
+
"""
|
| 16 |
+
Cables are structures in engineering that support
|
| 17 |
+
the applied transverse loads through the tensile
|
| 18 |
+
resistance developed in its members.
|
| 19 |
+
|
| 20 |
+
Cables are widely used in suspension bridges, tension
|
| 21 |
+
leg offshore platforms, transmission lines, and find
|
| 22 |
+
use in several other engineering applications.
|
| 23 |
+
|
| 24 |
+
Examples
|
| 25 |
+
========
|
| 26 |
+
A cable is supported at (0, 10) and (10, 10). Two point loads
|
| 27 |
+
acting vertically downwards act on the cable, one with magnitude 3 kN
|
| 28 |
+
and acting 2 meters from the left support and 3 meters below it, while
|
| 29 |
+
the other with magnitude 2 kN is 6 meters from the left support and
|
| 30 |
+
6 meters below it.
|
| 31 |
+
|
| 32 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 33 |
+
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 34 |
+
>>> c.apply_load(-1, ('P', 2, 7, 3, 270))
|
| 35 |
+
>>> c.apply_load(-1, ('Q', 6, 4, 2, 270))
|
| 36 |
+
>>> c.loads
|
| 37 |
+
{'distributed': {}, 'point_load': {'P': [3, 270], 'Q': [2, 270]}}
|
| 38 |
+
>>> c.loads_position
|
| 39 |
+
{'P': [2, 7], 'Q': [6, 4]}
|
| 40 |
+
"""
|
| 41 |
+
def __init__(self, support_1, support_2):
|
| 42 |
+
"""
|
| 43 |
+
Initializes the class.
|
| 44 |
+
|
| 45 |
+
Parameters
|
| 46 |
+
==========
|
| 47 |
+
|
| 48 |
+
support_1 and support_2 are tuples of the form
|
| 49 |
+
(label, x, y), where
|
| 50 |
+
|
| 51 |
+
label : String or symbol
|
| 52 |
+
The label of the support
|
| 53 |
+
|
| 54 |
+
x : Sympifyable
|
| 55 |
+
The x coordinate of the position of the support
|
| 56 |
+
|
| 57 |
+
y : Sympifyable
|
| 58 |
+
The y coordinate of the position of the support
|
| 59 |
+
"""
|
| 60 |
+
self._left_support = []
|
| 61 |
+
self._right_support = []
|
| 62 |
+
self._supports = {}
|
| 63 |
+
self._support_labels = []
|
| 64 |
+
self._loads = {"distributed": {}, "point_load": {}}
|
| 65 |
+
self._loads_position = {}
|
| 66 |
+
self._length = 0
|
| 67 |
+
self._reaction_loads = {}
|
| 68 |
+
self._tension = {}
|
| 69 |
+
self._lowest_x_global = sympify(0)
|
| 70 |
+
|
| 71 |
+
if support_1[0] == support_2[0]:
|
| 72 |
+
raise ValueError("Supports can not have the same label")
|
| 73 |
+
|
| 74 |
+
elif support_1[1] == support_2[1]:
|
| 75 |
+
raise ValueError("Supports can not be at the same location")
|
| 76 |
+
|
| 77 |
+
x1 = sympify(support_1[1])
|
| 78 |
+
y1 = sympify(support_1[2])
|
| 79 |
+
self._supports[support_1[0]] = [x1, y1]
|
| 80 |
+
|
| 81 |
+
x2 = sympify(support_2[1])
|
| 82 |
+
y2 = sympify(support_2[2])
|
| 83 |
+
self._supports[support_2[0]] = [x2, y2]
|
| 84 |
+
|
| 85 |
+
if support_1[1] < support_2[1]:
|
| 86 |
+
self._left_support.append(x1)
|
| 87 |
+
self._left_support.append(y1)
|
| 88 |
+
self._right_support.append(x2)
|
| 89 |
+
self._right_support.append(y2)
|
| 90 |
+
self._support_labels.append(support_1[0])
|
| 91 |
+
self._support_labels.append(support_2[0])
|
| 92 |
+
|
| 93 |
+
else:
|
| 94 |
+
self._left_support.append(x2)
|
| 95 |
+
self._left_support.append(y2)
|
| 96 |
+
self._right_support.append(x1)
|
| 97 |
+
self._right_support.append(y1)
|
| 98 |
+
self._support_labels.append(support_2[0])
|
| 99 |
+
self._support_labels.append(support_1[0])
|
| 100 |
+
|
| 101 |
+
for i in self._support_labels:
|
| 102 |
+
self._reaction_loads[Symbol("R_"+ i +"_x")] = 0
|
| 103 |
+
self._reaction_loads[Symbol("R_"+ i +"_y")] = 0
|
| 104 |
+
|
| 105 |
+
@property
|
| 106 |
+
def supports(self):
|
| 107 |
+
"""
|
| 108 |
+
Returns the supports of the cable along with their
|
| 109 |
+
positions.
|
| 110 |
+
"""
|
| 111 |
+
return self._supports
|
| 112 |
+
|
| 113 |
+
@property
|
| 114 |
+
def left_support(self):
|
| 115 |
+
"""
|
| 116 |
+
Returns the position of the left support.
|
| 117 |
+
"""
|
| 118 |
+
return self._left_support
|
| 119 |
+
|
| 120 |
+
@property
|
| 121 |
+
def right_support(self):
|
| 122 |
+
"""
|
| 123 |
+
Returns the position of the right support.
|
| 124 |
+
"""
|
| 125 |
+
return self._right_support
|
| 126 |
+
|
| 127 |
+
@property
|
| 128 |
+
def loads(self):
|
| 129 |
+
"""
|
| 130 |
+
Returns the magnitude and direction of the loads
|
| 131 |
+
acting on the cable.
|
| 132 |
+
"""
|
| 133 |
+
return self._loads
|
| 134 |
+
|
| 135 |
+
@property
|
| 136 |
+
def loads_position(self):
|
| 137 |
+
"""
|
| 138 |
+
Returns the position of the point loads acting on the
|
| 139 |
+
cable.
|
| 140 |
+
"""
|
| 141 |
+
return self._loads_position
|
| 142 |
+
|
| 143 |
+
@property
|
| 144 |
+
def length(self):
|
| 145 |
+
"""
|
| 146 |
+
Returns the length of the cable.
|
| 147 |
+
"""
|
| 148 |
+
return self._length
|
| 149 |
+
|
| 150 |
+
@property
|
| 151 |
+
def reaction_loads(self):
|
| 152 |
+
"""
|
| 153 |
+
Returns the reaction forces at the supports, which are
|
| 154 |
+
initialized to 0.
|
| 155 |
+
"""
|
| 156 |
+
return self._reaction_loads
|
| 157 |
+
|
| 158 |
+
@property
|
| 159 |
+
def tension(self):
|
| 160 |
+
"""
|
| 161 |
+
Returns the tension developed in the cable due to the loads
|
| 162 |
+
applied.
|
| 163 |
+
"""
|
| 164 |
+
return self._tension
|
| 165 |
+
|
| 166 |
+
def tension_at(self, x):
|
| 167 |
+
"""
|
| 168 |
+
Returns the tension at a given value of x developed due to
|
| 169 |
+
distributed load.
|
| 170 |
+
"""
|
| 171 |
+
if 'distributed' not in self._tension.keys():
|
| 172 |
+
raise ValueError("No distributed load added or solve method not called")
|
| 173 |
+
|
| 174 |
+
if x > self._right_support[0] or x < self._left_support[0]:
|
| 175 |
+
raise ValueError("The value of x should be between the two supports")
|
| 176 |
+
|
| 177 |
+
A = self._tension['distributed']
|
| 178 |
+
X = Symbol('X')
|
| 179 |
+
|
| 180 |
+
return A.subs({X:(x-self._lowest_x_global)})
|
| 181 |
+
|
| 182 |
+
def apply_length(self, length):
|
| 183 |
+
"""
|
| 184 |
+
This method specifies the length of the cable
|
| 185 |
+
|
| 186 |
+
Parameters
|
| 187 |
+
==========
|
| 188 |
+
|
| 189 |
+
length : Sympifyable
|
| 190 |
+
The length of the cable
|
| 191 |
+
|
| 192 |
+
Examples
|
| 193 |
+
========
|
| 194 |
+
|
| 195 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 196 |
+
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 197 |
+
>>> c.apply_length(20)
|
| 198 |
+
>>> c.length
|
| 199 |
+
20
|
| 200 |
+
"""
|
| 201 |
+
dist = ((self._left_support[0] - self._right_support[0])**2
|
| 202 |
+
- (self._left_support[1] - self._right_support[1])**2)**(1/2)
|
| 203 |
+
|
| 204 |
+
if length < dist:
|
| 205 |
+
raise ValueError("length should not be less than the distance between the supports")
|
| 206 |
+
|
| 207 |
+
self._length = length
|
| 208 |
+
|
| 209 |
+
def change_support(self, label, new_support):
|
| 210 |
+
"""
|
| 211 |
+
This method changes the mentioned support with a new support.
|
| 212 |
+
|
| 213 |
+
Parameters
|
| 214 |
+
==========
|
| 215 |
+
label: String or symbol
|
| 216 |
+
The label of the support to be changed
|
| 217 |
+
|
| 218 |
+
new_support: Tuple of the form (new_label, x, y)
|
| 219 |
+
new_label: String or symbol
|
| 220 |
+
The label of the new support
|
| 221 |
+
|
| 222 |
+
x: Sympifyable
|
| 223 |
+
The x-coordinate of the position of the new support.
|
| 224 |
+
|
| 225 |
+
y: Sympifyable
|
| 226 |
+
The y-coordinate of the position of the new support.
|
| 227 |
+
|
| 228 |
+
Examples
|
| 229 |
+
========
|
| 230 |
+
|
| 231 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 232 |
+
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 233 |
+
>>> c.supports
|
| 234 |
+
{'A': [0, 10], 'B': [10, 10]}
|
| 235 |
+
>>> c.change_support('B', ('C', 5, 6))
|
| 236 |
+
>>> c.supports
|
| 237 |
+
{'A': [0, 10], 'C': [5, 6]}
|
| 238 |
+
"""
|
| 239 |
+
if label not in self._supports:
|
| 240 |
+
raise ValueError("No support exists with the given label")
|
| 241 |
+
|
| 242 |
+
i = self._support_labels.index(label)
|
| 243 |
+
rem_label = self._support_labels[(i+1)%2]
|
| 244 |
+
x1 = self._supports[rem_label][0]
|
| 245 |
+
y1 = self._supports[rem_label][1]
|
| 246 |
+
|
| 247 |
+
x = sympify(new_support[1])
|
| 248 |
+
y = sympify(new_support[2])
|
| 249 |
+
|
| 250 |
+
for l in self._loads_position:
|
| 251 |
+
if l[0] >= max(x, x1) or l[0] <= min(x, x1):
|
| 252 |
+
raise ValueError("The change in support will throw an existing load out of range")
|
| 253 |
+
|
| 254 |
+
self._supports.pop(label)
|
| 255 |
+
self._left_support.clear()
|
| 256 |
+
self._right_support.clear()
|
| 257 |
+
self._reaction_loads.clear()
|
| 258 |
+
self._support_labels.remove(label)
|
| 259 |
+
|
| 260 |
+
self._supports[new_support[0]] = [x, y]
|
| 261 |
+
|
| 262 |
+
if x1 < x:
|
| 263 |
+
self._left_support.append(x1)
|
| 264 |
+
self._left_support.append(y1)
|
| 265 |
+
self._right_support.append(x)
|
| 266 |
+
self._right_support.append(y)
|
| 267 |
+
self._support_labels.append(new_support[0])
|
| 268 |
+
|
| 269 |
+
else:
|
| 270 |
+
self._left_support.append(x)
|
| 271 |
+
self._left_support.append(y)
|
| 272 |
+
self._right_support.append(x1)
|
| 273 |
+
self._right_support.append(y1)
|
| 274 |
+
self._support_labels.insert(0, new_support[0])
|
| 275 |
+
|
| 276 |
+
for i in self._support_labels:
|
| 277 |
+
self._reaction_loads[Symbol("R_"+ i +"_x")] = 0
|
| 278 |
+
self._reaction_loads[Symbol("R_"+ i +"_y")] = 0
|
| 279 |
+
|
| 280 |
+
def apply_load(self, order, load):
|
| 281 |
+
"""
|
| 282 |
+
This method adds load to the cable.
|
| 283 |
+
|
| 284 |
+
Parameters
|
| 285 |
+
==========
|
| 286 |
+
|
| 287 |
+
order : Integer
|
| 288 |
+
The order of the applied load.
|
| 289 |
+
|
| 290 |
+
- For point loads, order = -1
|
| 291 |
+
- For distributed load, order = 0
|
| 292 |
+
|
| 293 |
+
load : tuple
|
| 294 |
+
|
| 295 |
+
* For point loads, load is of the form (label, x, y, magnitude, direction), where:
|
| 296 |
+
|
| 297 |
+
label : String or symbol
|
| 298 |
+
The label of the load
|
| 299 |
+
|
| 300 |
+
x : Sympifyable
|
| 301 |
+
The x coordinate of the position of the load
|
| 302 |
+
|
| 303 |
+
y : Sympifyable
|
| 304 |
+
The y coordinate of the position of the load
|
| 305 |
+
|
| 306 |
+
magnitude : Sympifyable
|
| 307 |
+
The magnitude of the load. It must always be positive
|
| 308 |
+
|
| 309 |
+
direction : Sympifyable
|
| 310 |
+
The angle, in degrees, that the load vector makes with the horizontal
|
| 311 |
+
in the counter-clockwise direction. It takes the values 0 to 360,
|
| 312 |
+
inclusive.
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
* For uniformly distributed load, load is of the form (label, magnitude)
|
| 316 |
+
|
| 317 |
+
label : String or symbol
|
| 318 |
+
The label of the load
|
| 319 |
+
|
| 320 |
+
magnitude : Sympifyable
|
| 321 |
+
The magnitude of the load. It must always be positive
|
| 322 |
+
|
| 323 |
+
Examples
|
| 324 |
+
========
|
| 325 |
+
|
| 326 |
+
For a point load of magnitude 12 units inclined at 30 degrees with the horizontal:
|
| 327 |
+
|
| 328 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 329 |
+
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 330 |
+
>>> c.apply_load(-1, ('Z', 5, 5, 12, 30))
|
| 331 |
+
>>> c.loads
|
| 332 |
+
{'distributed': {}, 'point_load': {'Z': [12, 30]}}
|
| 333 |
+
>>> c.loads_position
|
| 334 |
+
{'Z': [5, 5]}
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
For a uniformly distributed load of magnitude 9 units:
|
| 338 |
+
|
| 339 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 340 |
+
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 341 |
+
>>> c.apply_load(0, ('X', 9))
|
| 342 |
+
>>> c.loads
|
| 343 |
+
{'distributed': {'X': 9}, 'point_load': {}}
|
| 344 |
+
"""
|
| 345 |
+
if order == -1:
|
| 346 |
+
if len(self._loads["distributed"]) != 0:
|
| 347 |
+
raise ValueError("Distributed load already exists")
|
| 348 |
+
|
| 349 |
+
label = load[0]
|
| 350 |
+
if label in self._loads["point_load"]:
|
| 351 |
+
raise ValueError("Label already exists")
|
| 352 |
+
|
| 353 |
+
x = sympify(load[1])
|
| 354 |
+
y = sympify(load[2])
|
| 355 |
+
|
| 356 |
+
if x > self._right_support[0] or x < self._left_support[0]:
|
| 357 |
+
raise ValueError("The load should be positioned between the supports")
|
| 358 |
+
|
| 359 |
+
magnitude = sympify(load[3])
|
| 360 |
+
direction = sympify(load[4])
|
| 361 |
+
|
| 362 |
+
self._loads["point_load"][label] = [magnitude, direction]
|
| 363 |
+
self._loads_position[label] = [x, y]
|
| 364 |
+
|
| 365 |
+
elif order == 0:
|
| 366 |
+
if len(self._loads_position) != 0:
|
| 367 |
+
raise ValueError("Point load(s) already exist")
|
| 368 |
+
|
| 369 |
+
label = load[0]
|
| 370 |
+
if label in self._loads["distributed"]:
|
| 371 |
+
raise ValueError("Label already exists")
|
| 372 |
+
|
| 373 |
+
magnitude = sympify(load[1])
|
| 374 |
+
|
| 375 |
+
self._loads["distributed"][label] = magnitude
|
| 376 |
+
|
| 377 |
+
else:
|
| 378 |
+
raise ValueError("Order should be either -1 or 0")
|
| 379 |
+
|
| 380 |
+
def remove_loads(self, *args):
|
| 381 |
+
"""
|
| 382 |
+
This methods removes the specified loads.
|
| 383 |
+
|
| 384 |
+
Parameters
|
| 385 |
+
==========
|
| 386 |
+
This input takes multiple label(s) as input
|
| 387 |
+
label(s): String or symbol
|
| 388 |
+
The label(s) of the loads to be removed.
|
| 389 |
+
|
| 390 |
+
Examples
|
| 391 |
+
========
|
| 392 |
+
|
| 393 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 394 |
+
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 395 |
+
>>> c.apply_load(-1, ('Z', 5, 5, 12, 30))
|
| 396 |
+
>>> c.loads
|
| 397 |
+
{'distributed': {}, 'point_load': {'Z': [12, 30]}}
|
| 398 |
+
>>> c.remove_loads('Z')
|
| 399 |
+
>>> c.loads
|
| 400 |
+
{'distributed': {}, 'point_load': {}}
|
| 401 |
+
"""
|
| 402 |
+
for i in args:
|
| 403 |
+
if len(self._loads_position) == 0:
|
| 404 |
+
if i not in self._loads['distributed']:
|
| 405 |
+
raise ValueError("Error removing load " + i + ": no such load exists")
|
| 406 |
+
|
| 407 |
+
else:
|
| 408 |
+
self._loads['disrtibuted'].pop(i)
|
| 409 |
+
|
| 410 |
+
else:
|
| 411 |
+
if i not in self._loads['point_load']:
|
| 412 |
+
raise ValueError("Error removing load " + i + ": no such load exists")
|
| 413 |
+
|
| 414 |
+
else:
|
| 415 |
+
self._loads['point_load'].pop(i)
|
| 416 |
+
self._loads_position.pop(i)
|
| 417 |
+
|
| 418 |
+
def solve(self, *args):
|
| 419 |
+
"""
|
| 420 |
+
This method solves for the reaction forces at the supports, the tension developed in
|
| 421 |
+
the cable, and updates the length of the cable.
|
| 422 |
+
|
| 423 |
+
Parameters
|
| 424 |
+
==========
|
| 425 |
+
This method requires no input when solving for point loads
|
| 426 |
+
For distributed load, the x and y coordinates of the lowest point of the cable are
|
| 427 |
+
required as
|
| 428 |
+
|
| 429 |
+
x: Sympifyable
|
| 430 |
+
The x coordinate of the lowest point
|
| 431 |
+
|
| 432 |
+
y: Sympifyable
|
| 433 |
+
The y coordinate of the lowest point
|
| 434 |
+
|
| 435 |
+
Examples
|
| 436 |
+
========
|
| 437 |
+
For point loads,
|
| 438 |
+
|
| 439 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 440 |
+
>>> c = Cable(("A", 0, 10), ("B", 10, 10))
|
| 441 |
+
>>> c.apply_load(-1, ('Z', 2, 7.26, 3, 270))
|
| 442 |
+
>>> c.apply_load(-1, ('X', 4, 6, 8, 270))
|
| 443 |
+
>>> c.solve()
|
| 444 |
+
>>> c.tension
|
| 445 |
+
{A_Z: 8.91403453669861, X_B: 19*sqrt(13)/10, Z_X: 4.79150773600774}
|
| 446 |
+
>>> c.reaction_loads
|
| 447 |
+
{R_A_x: -5.25547445255474, R_A_y: 7.2, R_B_x: 5.25547445255474, R_B_y: 3.8}
|
| 448 |
+
>>> c.length
|
| 449 |
+
5.7560958484519 + 2*sqrt(13)
|
| 450 |
+
|
| 451 |
+
For distributed load,
|
| 452 |
+
|
| 453 |
+
>>> from sympy.physics.continuum_mechanics.cable import Cable
|
| 454 |
+
>>> c=Cable(("A", 0, 40),("B", 100, 20))
|
| 455 |
+
>>> c.apply_load(0, ("X", 850))
|
| 456 |
+
>>> c.solve(58.58, 0)
|
| 457 |
+
>>> c.tension
|
| 458 |
+
{'distributed': 36456.8485*sqrt(0.000543529004799705*(X + 0.00135624381275735)**2 + 1)}
|
| 459 |
+
>>> c.tension_at(0)
|
| 460 |
+
61709.0363315913
|
| 461 |
+
>>> c.reaction_loads
|
| 462 |
+
{R_A_x: 36456.8485, R_A_y: -49788.5866682485, R_B_x: 44389.8401587246, R_B_y: 42866.621696333}
|
| 463 |
+
"""
|
| 464 |
+
|
| 465 |
+
if len(self._loads_position) != 0:
|
| 466 |
+
sorted_position = sorted(self._loads_position.items(), key = lambda item : item[1][0])
|
| 467 |
+
|
| 468 |
+
sorted_position.append(self._support_labels[1])
|
| 469 |
+
sorted_position.insert(0, self._support_labels[0])
|
| 470 |
+
|
| 471 |
+
self._tension.clear()
|
| 472 |
+
moment_sum_from_left_support = 0
|
| 473 |
+
moment_sum_from_right_support = 0
|
| 474 |
+
F_x = 0
|
| 475 |
+
F_y = 0
|
| 476 |
+
self._length = 0
|
| 477 |
+
|
| 478 |
+
for i in range(1, len(sorted_position)-1):
|
| 479 |
+
if i == 1:
|
| 480 |
+
self._length+=sqrt((self._left_support[0] - self._loads_position[sorted_position[i][0]][0])**2 + (self._left_support[1] - self._loads_position[sorted_position[i][0]][1])**2)
|
| 481 |
+
|
| 482 |
+
else:
|
| 483 |
+
self._length+=sqrt((self._loads_position[sorted_position[i-1][0]][0] - self._loads_position[sorted_position[i][0]][0])**2 + (self._loads_position[sorted_position[i-1][0]][1] - self._loads_position[sorted_position[i][0]][1])**2)
|
| 484 |
+
|
| 485 |
+
if i == len(sorted_position)-2:
|
| 486 |
+
self._length+=sqrt((self._right_support[0] - self._loads_position[sorted_position[i][0]][0])**2 + (self._right_support[1] - self._loads_position[sorted_position[i][0]][1])**2)
|
| 487 |
+
|
| 488 |
+
moment_sum_from_left_support += self._loads['point_load'][sorted_position[i][0]][0] * cos(pi * self._loads['point_load'][sorted_position[i][0]][1] / 180) * abs(self._left_support[1] - self._loads_position[sorted_position[i][0]][1])
|
| 489 |
+
moment_sum_from_left_support += self._loads['point_load'][sorted_position[i][0]][0] * sin(pi * self._loads['point_load'][sorted_position[i][0]][1] / 180) * abs(self._left_support[0] - self._loads_position[sorted_position[i][0]][0])
|
| 490 |
+
|
| 491 |
+
F_x += self._loads['point_load'][sorted_position[i][0]][0] * cos(pi * self._loads['point_load'][sorted_position[i][0]][1] / 180)
|
| 492 |
+
F_y += self._loads['point_load'][sorted_position[i][0]][0] * sin(pi * self._loads['point_load'][sorted_position[i][0]][1] / 180)
|
| 493 |
+
|
| 494 |
+
label = Symbol(sorted_position[i][0]+"_"+sorted_position[i+1][0])
|
| 495 |
+
y2 = self._loads_position[sorted_position[i][0]][1]
|
| 496 |
+
x2 = self._loads_position[sorted_position[i][0]][0]
|
| 497 |
+
y1 = 0
|
| 498 |
+
x1 = 0
|
| 499 |
+
|
| 500 |
+
if i == len(sorted_position)-2:
|
| 501 |
+
x1 = self._right_support[0]
|
| 502 |
+
y1 = self._right_support[1]
|
| 503 |
+
|
| 504 |
+
else:
|
| 505 |
+
x1 = self._loads_position[sorted_position[i+1][0]][0]
|
| 506 |
+
y1 = self._loads_position[sorted_position[i+1][0]][1]
|
| 507 |
+
|
| 508 |
+
angle_with_horizontal = atan((y1 - y2)/(x1 - x2))
|
| 509 |
+
|
| 510 |
+
tension = -(moment_sum_from_left_support)/(abs(self._left_support[1] - self._loads_position[sorted_position[i][0]][1])*cos(angle_with_horizontal) + abs(self._left_support[0] - self._loads_position[sorted_position[i][0]][0])*sin(angle_with_horizontal))
|
| 511 |
+
self._tension[label] = tension
|
| 512 |
+
moment_sum_from_right_support += self._loads['point_load'][sorted_position[i][0]][0] * cos(pi * self._loads['point_load'][sorted_position[i][0]][1] / 180) * abs(self._right_support[1] - self._loads_position[sorted_position[i][0]][1])
|
| 513 |
+
moment_sum_from_right_support += self._loads['point_load'][sorted_position[i][0]][0] * sin(pi * self._loads['point_load'][sorted_position[i][0]][1] / 180) * abs(self._right_support[0] - self._loads_position[sorted_position[i][0]][0])
|
| 514 |
+
|
| 515 |
+
label = Symbol(sorted_position[0][0]+"_"+sorted_position[1][0])
|
| 516 |
+
y2 = self._loads_position[sorted_position[1][0]][1]
|
| 517 |
+
x2 = self._loads_position[sorted_position[1][0]][0]
|
| 518 |
+
x1 = self._left_support[0]
|
| 519 |
+
y1 = self._left_support[1]
|
| 520 |
+
|
| 521 |
+
angle_with_horizontal = -atan((y2 - y1)/(x2 - x1))
|
| 522 |
+
tension = -(moment_sum_from_right_support)/(abs(self._right_support[1] - self._loads_position[sorted_position[1][0]][1])*cos(angle_with_horizontal) + abs(self._right_support[0] - self._loads_position[sorted_position[1][0]][0])*sin(angle_with_horizontal))
|
| 523 |
+
self._tension[label] = tension
|
| 524 |
+
|
| 525 |
+
angle_with_horizontal = pi/2 - angle_with_horizontal
|
| 526 |
+
label = self._support_labels[0]
|
| 527 |
+
self._reaction_loads[Symbol("R_"+label+"_x")] = -sin(angle_with_horizontal) * tension
|
| 528 |
+
F_x += -sin(angle_with_horizontal) * tension
|
| 529 |
+
self._reaction_loads[Symbol("R_"+label+"_y")] = cos(angle_with_horizontal) * tension
|
| 530 |
+
F_y += cos(angle_with_horizontal) * tension
|
| 531 |
+
|
| 532 |
+
label = self._support_labels[1]
|
| 533 |
+
self._reaction_loads[Symbol("R_"+label+"_x")] = -F_x
|
| 534 |
+
self._reaction_loads[Symbol("R_"+label+"_y")] = -F_y
|
| 535 |
+
|
| 536 |
+
elif len(self._loads['distributed']) != 0 :
|
| 537 |
+
|
| 538 |
+
if len(args) == 0:
|
| 539 |
+
raise ValueError("Provide the lowest point of the cable")
|
| 540 |
+
|
| 541 |
+
lowest_x = sympify(args[0])
|
| 542 |
+
lowest_y = sympify(args[1])
|
| 543 |
+
self._lowest_x_global = lowest_x
|
| 544 |
+
|
| 545 |
+
a = Symbol('a')
|
| 546 |
+
b = Symbol('b')
|
| 547 |
+
c = Symbol('c')
|
| 548 |
+
# augmented matrix form of linsolve
|
| 549 |
+
|
| 550 |
+
M = Matrix(
|
| 551 |
+
[[self._left_support[0]**2, self._left_support[0], 1, self._left_support[1]],
|
| 552 |
+
[self._right_support[0]**2, self._right_support[0], 1, self._right_support[1]],
|
| 553 |
+
[lowest_x**2, lowest_x, 1, lowest_y] ]
|
| 554 |
+
)
|
| 555 |
+
|
| 556 |
+
coefficient_solution = list(linsolve(M, (a, b, c)))
|
| 557 |
+
|
| 558 |
+
if len(coefficient_solution) == 0:
|
| 559 |
+
raise ValueError("The lowest point is inconsistent with the supports")
|
| 560 |
+
|
| 561 |
+
A = coefficient_solution[0][0]
|
| 562 |
+
B = coefficient_solution[0][1]
|
| 563 |
+
C = coefficient_solution[0][2]
|
| 564 |
+
|
| 565 |
+
|
| 566 |
+
# y = A*x**2 + B*x + C
|
| 567 |
+
# shifting origin to lowest point
|
| 568 |
+
X = Symbol('X')
|
| 569 |
+
Y = Symbol('Y')
|
| 570 |
+
Y = A*(X + lowest_x)**2 + B*(X + lowest_x) + C - lowest_y
|
| 571 |
+
|
| 572 |
+
temp_list = list(self._loads['distributed'].values())
|
| 573 |
+
applied_force = temp_list[0]
|
| 574 |
+
|
| 575 |
+
horizontal_force_constant = (applied_force * (self._right_support[0] - lowest_x)**2) / (2 * (self._right_support[1] - lowest_y))
|
| 576 |
+
|
| 577 |
+
self._tension.clear()
|
| 578 |
+
tangent_slope_to_curve = diff(Y, X)
|
| 579 |
+
self._tension['distributed'] = horizontal_force_constant / (cos(atan(tangent_slope_to_curve)))
|
| 580 |
+
|
| 581 |
+
label = self._support_labels[0]
|
| 582 |
+
self._reaction_loads[Symbol("R_"+label+"_x")] = self.tension_at(self._left_support[0]) * cos(atan(tangent_slope_to_curve.subs(X, self._left_support[0] - lowest_x)))
|
| 583 |
+
self._reaction_loads[Symbol("R_"+label+"_y")] = self.tension_at(self._left_support[0]) * sin(atan(tangent_slope_to_curve.subs(X, self._left_support[0] - lowest_x)))
|
| 584 |
+
|
| 585 |
+
label = self._support_labels[1]
|
| 586 |
+
self._reaction_loads[Symbol("R_"+label+"_x")] = self.tension_at(self._left_support[0]) * cos(atan(tangent_slope_to_curve.subs(X, self._right_support[0] - lowest_x)))
|
| 587 |
+
self._reaction_loads[Symbol("R_"+label+"_y")] = self.tension_at(self._left_support[0]) * sin(atan(tangent_slope_to_curve.subs(X, self._right_support[0] - lowest_x)))
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__init__.py
ADDED
|
File without changes
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (191 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/test_beam.cpython-310.pyc
ADDED
|
Binary file (21.6 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/test_cable.cpython-310.pyc
ADDED
|
Binary file (2.53 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/__pycache__/test_truss.cpython-310.pyc
ADDED
|
Binary file (2.59 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/test_beam.py
ADDED
|
@@ -0,0 +1,802 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core.function import expand
|
| 2 |
+
from sympy.core.numbers import (Rational, pi)
|
| 3 |
+
from sympy.core.singleton import S
|
| 4 |
+
from sympy.core.symbol import (Symbol, symbols)
|
| 5 |
+
from sympy.sets.sets import Interval
|
| 6 |
+
from sympy.simplify.simplify import simplify
|
| 7 |
+
from sympy.physics.continuum_mechanics.beam import Beam
|
| 8 |
+
from sympy.functions import SingularityFunction, Piecewise, meijerg, Abs, log
|
| 9 |
+
from sympy.testing.pytest import raises
|
| 10 |
+
from sympy.physics.units import meter, newton, kilo, giga, milli
|
| 11 |
+
from sympy.physics.continuum_mechanics.beam import Beam3D
|
| 12 |
+
from sympy.geometry import Circle, Polygon, Point2D, Triangle
|
| 13 |
+
from sympy.core.sympify import sympify
|
| 14 |
+
|
| 15 |
+
x = Symbol('x')
|
| 16 |
+
y = Symbol('y')
|
| 17 |
+
R1, R2 = symbols('R1, R2')
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_Beam():
|
| 21 |
+
E = Symbol('E')
|
| 22 |
+
E_1 = Symbol('E_1')
|
| 23 |
+
I = Symbol('I')
|
| 24 |
+
I_1 = Symbol('I_1')
|
| 25 |
+
A = Symbol('A')
|
| 26 |
+
|
| 27 |
+
b = Beam(1, E, I)
|
| 28 |
+
assert b.length == 1
|
| 29 |
+
assert b.elastic_modulus == E
|
| 30 |
+
assert b.second_moment == I
|
| 31 |
+
assert b.variable == x
|
| 32 |
+
|
| 33 |
+
# Test the length setter
|
| 34 |
+
b.length = 4
|
| 35 |
+
assert b.length == 4
|
| 36 |
+
|
| 37 |
+
# Test the E setter
|
| 38 |
+
b.elastic_modulus = E_1
|
| 39 |
+
assert b.elastic_modulus == E_1
|
| 40 |
+
|
| 41 |
+
# Test the I setter
|
| 42 |
+
b.second_moment = I_1
|
| 43 |
+
assert b.second_moment is I_1
|
| 44 |
+
|
| 45 |
+
# Test the variable setter
|
| 46 |
+
b.variable = y
|
| 47 |
+
assert b.variable is y
|
| 48 |
+
|
| 49 |
+
# Test for all boundary conditions.
|
| 50 |
+
b.bc_deflection = [(0, 2)]
|
| 51 |
+
b.bc_slope = [(0, 1)]
|
| 52 |
+
assert b.boundary_conditions == {'deflection': [(0, 2)], 'slope': [(0, 1)]}
|
| 53 |
+
|
| 54 |
+
# Test for slope boundary condition method
|
| 55 |
+
b.bc_slope.extend([(4, 3), (5, 0)])
|
| 56 |
+
s_bcs = b.bc_slope
|
| 57 |
+
assert s_bcs == [(0, 1), (4, 3), (5, 0)]
|
| 58 |
+
|
| 59 |
+
# Test for deflection boundary condition method
|
| 60 |
+
b.bc_deflection.extend([(4, 3), (5, 0)])
|
| 61 |
+
d_bcs = b.bc_deflection
|
| 62 |
+
assert d_bcs == [(0, 2), (4, 3), (5, 0)]
|
| 63 |
+
|
| 64 |
+
# Test for updated boundary conditions
|
| 65 |
+
bcs_new = b.boundary_conditions
|
| 66 |
+
assert bcs_new == {
|
| 67 |
+
'deflection': [(0, 2), (4, 3), (5, 0)],
|
| 68 |
+
'slope': [(0, 1), (4, 3), (5, 0)]}
|
| 69 |
+
|
| 70 |
+
b1 = Beam(30, E, I)
|
| 71 |
+
b1.apply_load(-8, 0, -1)
|
| 72 |
+
b1.apply_load(R1, 10, -1)
|
| 73 |
+
b1.apply_load(R2, 30, -1)
|
| 74 |
+
b1.apply_load(120, 30, -2)
|
| 75 |
+
b1.bc_deflection = [(10, 0), (30, 0)]
|
| 76 |
+
b1.solve_for_reaction_loads(R1, R2)
|
| 77 |
+
|
| 78 |
+
# Test for finding reaction forces
|
| 79 |
+
p = b1.reaction_loads
|
| 80 |
+
q = {R1: 6, R2: 2}
|
| 81 |
+
assert p == q
|
| 82 |
+
|
| 83 |
+
# Test for load distribution function.
|
| 84 |
+
p = b1.load
|
| 85 |
+
q = -8*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 10, -1) \
|
| 86 |
+
+ 120*SingularityFunction(x, 30, -2) + 2*SingularityFunction(x, 30, -1)
|
| 87 |
+
assert p == q
|
| 88 |
+
|
| 89 |
+
# Test for shear force distribution function
|
| 90 |
+
p = b1.shear_force()
|
| 91 |
+
q = 8*SingularityFunction(x, 0, 0) - 6*SingularityFunction(x, 10, 0) \
|
| 92 |
+
- 120*SingularityFunction(x, 30, -1) - 2*SingularityFunction(x, 30, 0)
|
| 93 |
+
assert p == q
|
| 94 |
+
|
| 95 |
+
# Test for shear stress distribution function
|
| 96 |
+
p = b1.shear_stress()
|
| 97 |
+
q = (8*SingularityFunction(x, 0, 0) - 6*SingularityFunction(x, 10, 0) \
|
| 98 |
+
- 120*SingularityFunction(x, 30, -1) \
|
| 99 |
+
- 2*SingularityFunction(x, 30, 0))/A
|
| 100 |
+
assert p==q
|
| 101 |
+
|
| 102 |
+
# Test for bending moment distribution function
|
| 103 |
+
p = b1.bending_moment()
|
| 104 |
+
q = 8*SingularityFunction(x, 0, 1) - 6*SingularityFunction(x, 10, 1) \
|
| 105 |
+
- 120*SingularityFunction(x, 30, 0) - 2*SingularityFunction(x, 30, 1)
|
| 106 |
+
assert p == q
|
| 107 |
+
|
| 108 |
+
# Test for slope distribution function
|
| 109 |
+
p = b1.slope()
|
| 110 |
+
q = -4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2) \
|
| 111 |
+
+ 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) \
|
| 112 |
+
+ Rational(4000, 3)
|
| 113 |
+
assert p == q/(E*I)
|
| 114 |
+
|
| 115 |
+
# Test for deflection distribution function
|
| 116 |
+
p = b1.deflection()
|
| 117 |
+
q = x*Rational(4000, 3) - 4*SingularityFunction(x, 0, 3)/3 \
|
| 118 |
+
+ SingularityFunction(x, 10, 3) + 60*SingularityFunction(x, 30, 2) \
|
| 119 |
+
+ SingularityFunction(x, 30, 3)/3 - 12000
|
| 120 |
+
assert p == q/(E*I)
|
| 121 |
+
|
| 122 |
+
# Test using symbols
|
| 123 |
+
l = Symbol('l')
|
| 124 |
+
w0 = Symbol('w0')
|
| 125 |
+
w2 = Symbol('w2')
|
| 126 |
+
a1 = Symbol('a1')
|
| 127 |
+
c = Symbol('c')
|
| 128 |
+
c1 = Symbol('c1')
|
| 129 |
+
d = Symbol('d')
|
| 130 |
+
e = Symbol('e')
|
| 131 |
+
f = Symbol('f')
|
| 132 |
+
|
| 133 |
+
b2 = Beam(l, E, I)
|
| 134 |
+
|
| 135 |
+
b2.apply_load(w0, a1, 1)
|
| 136 |
+
b2.apply_load(w2, c1, -1)
|
| 137 |
+
|
| 138 |
+
b2.bc_deflection = [(c, d)]
|
| 139 |
+
b2.bc_slope = [(e, f)]
|
| 140 |
+
|
| 141 |
+
# Test for load distribution function.
|
| 142 |
+
p = b2.load
|
| 143 |
+
q = w0*SingularityFunction(x, a1, 1) + w2*SingularityFunction(x, c1, -1)
|
| 144 |
+
assert p == q
|
| 145 |
+
|
| 146 |
+
# Test for shear force distribution function
|
| 147 |
+
p = b2.shear_force()
|
| 148 |
+
q = -w0*SingularityFunction(x, a1, 2)/2 \
|
| 149 |
+
- w2*SingularityFunction(x, c1, 0)
|
| 150 |
+
assert p == q
|
| 151 |
+
|
| 152 |
+
# Test for shear stress distribution function
|
| 153 |
+
p = b2.shear_stress()
|
| 154 |
+
q = (-w0*SingularityFunction(x, a1, 2)/2 \
|
| 155 |
+
- w2*SingularityFunction(x, c1, 0))/A
|
| 156 |
+
assert p == q
|
| 157 |
+
|
| 158 |
+
# Test for bending moment distribution function
|
| 159 |
+
p = b2.bending_moment()
|
| 160 |
+
q = -w0*SingularityFunction(x, a1, 3)/6 - w2*SingularityFunction(x, c1, 1)
|
| 161 |
+
assert p == q
|
| 162 |
+
|
| 163 |
+
# Test for slope distribution function
|
| 164 |
+
p = b2.slope()
|
| 165 |
+
q = (w0*SingularityFunction(x, a1, 4)/24 + w2*SingularityFunction(x, c1, 2)/2)/(E*I) + (E*I*f - w0*SingularityFunction(e, a1, 4)/24 - w2*SingularityFunction(e, c1, 2)/2)/(E*I)
|
| 166 |
+
assert expand(p) == expand(q)
|
| 167 |
+
|
| 168 |
+
# Test for deflection distribution function
|
| 169 |
+
p = b2.deflection()
|
| 170 |
+
q = x*(E*I*f - w0*SingularityFunction(e, a1, 4)/24 \
|
| 171 |
+
- w2*SingularityFunction(e, c1, 2)/2)/(E*I) \
|
| 172 |
+
+ (w0*SingularityFunction(x, a1, 5)/120 \
|
| 173 |
+
+ w2*SingularityFunction(x, c1, 3)/6)/(E*I) \
|
| 174 |
+
+ (E*I*(-c*f + d) + c*w0*SingularityFunction(e, a1, 4)/24 \
|
| 175 |
+
+ c*w2*SingularityFunction(e, c1, 2)/2 \
|
| 176 |
+
- w0*SingularityFunction(c, a1, 5)/120 \
|
| 177 |
+
- w2*SingularityFunction(c, c1, 3)/6)/(E*I)
|
| 178 |
+
assert simplify(p - q) == 0
|
| 179 |
+
|
| 180 |
+
b3 = Beam(9, E, I, 2)
|
| 181 |
+
b3.apply_load(value=-2, start=2, order=2, end=3)
|
| 182 |
+
b3.bc_slope.append((0, 2))
|
| 183 |
+
C3 = symbols('C3')
|
| 184 |
+
C4 = symbols('C4')
|
| 185 |
+
|
| 186 |
+
p = b3.load
|
| 187 |
+
q = -2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) \
|
| 188 |
+
+ 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2)
|
| 189 |
+
assert p == q
|
| 190 |
+
|
| 191 |
+
p = b3.shear_force()
|
| 192 |
+
q = 2*SingularityFunction(x, 2, 3)/3 - 2*SingularityFunction(x, 3, 1) \
|
| 193 |
+
- 2*SingularityFunction(x, 3, 2) - 2*SingularityFunction(x, 3, 3)/3
|
| 194 |
+
assert p == q
|
| 195 |
+
|
| 196 |
+
p = b3.shear_stress()
|
| 197 |
+
q = SingularityFunction(x, 2, 3)/3 - 1*SingularityFunction(x, 3, 1) \
|
| 198 |
+
- 1*SingularityFunction(x, 3, 2) - 1*SingularityFunction(x, 3, 3)/3
|
| 199 |
+
assert p == q
|
| 200 |
+
|
| 201 |
+
p = b3.slope()
|
| 202 |
+
q = 2 - (SingularityFunction(x, 2, 5)/30 - SingularityFunction(x, 3, 3)/3 \
|
| 203 |
+
- SingularityFunction(x, 3, 4)/6 - SingularityFunction(x, 3, 5)/30)/(E*I)
|
| 204 |
+
assert p == q
|
| 205 |
+
|
| 206 |
+
p = b3.deflection()
|
| 207 |
+
q = 2*x - (SingularityFunction(x, 2, 6)/180 \
|
| 208 |
+
- SingularityFunction(x, 3, 4)/12 - SingularityFunction(x, 3, 5)/30 \
|
| 209 |
+
- SingularityFunction(x, 3, 6)/180)/(E*I)
|
| 210 |
+
assert p == q + C4
|
| 211 |
+
|
| 212 |
+
b4 = Beam(4, E, I, 3)
|
| 213 |
+
b4.apply_load(-3, 0, 0, end=3)
|
| 214 |
+
|
| 215 |
+
p = b4.load
|
| 216 |
+
q = -3*SingularityFunction(x, 0, 0) + 3*SingularityFunction(x, 3, 0)
|
| 217 |
+
assert p == q
|
| 218 |
+
|
| 219 |
+
p = b4.shear_force()
|
| 220 |
+
q = 3*SingularityFunction(x, 0, 1) \
|
| 221 |
+
- 3*SingularityFunction(x, 3, 1)
|
| 222 |
+
assert p == q
|
| 223 |
+
|
| 224 |
+
p = b4.shear_stress()
|
| 225 |
+
q = SingularityFunction(x, 0, 1) - SingularityFunction(x, 3, 1)
|
| 226 |
+
assert p == q
|
| 227 |
+
|
| 228 |
+
p = b4.slope()
|
| 229 |
+
q = -3*SingularityFunction(x, 0, 3)/6 + 3*SingularityFunction(x, 3, 3)/6
|
| 230 |
+
assert p == q/(E*I) + C3
|
| 231 |
+
|
| 232 |
+
p = b4.deflection()
|
| 233 |
+
q = -3*SingularityFunction(x, 0, 4)/24 + 3*SingularityFunction(x, 3, 4)/24
|
| 234 |
+
assert p == q/(E*I) + C3*x + C4
|
| 235 |
+
|
| 236 |
+
# can't use end with point loads
|
| 237 |
+
raises(ValueError, lambda: b4.apply_load(-3, 0, -1, end=3))
|
| 238 |
+
with raises(TypeError):
|
| 239 |
+
b4.variable = 1
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def test_insufficient_bconditions():
|
| 243 |
+
# Test cases when required number of boundary conditions
|
| 244 |
+
# are not provided to solve the integration constants.
|
| 245 |
+
L = symbols('L', positive=True)
|
| 246 |
+
E, I, P, a3, a4 = symbols('E I P a3 a4')
|
| 247 |
+
|
| 248 |
+
b = Beam(L, E, I, base_char='a')
|
| 249 |
+
b.apply_load(R2, L, -1)
|
| 250 |
+
b.apply_load(R1, 0, -1)
|
| 251 |
+
b.apply_load(-P, L/2, -1)
|
| 252 |
+
b.solve_for_reaction_loads(R1, R2)
|
| 253 |
+
|
| 254 |
+
p = b.slope()
|
| 255 |
+
q = P*SingularityFunction(x, 0, 2)/4 - P*SingularityFunction(x, L/2, 2)/2 + P*SingularityFunction(x, L, 2)/4
|
| 256 |
+
assert p == q/(E*I) + a3
|
| 257 |
+
|
| 258 |
+
p = b.deflection()
|
| 259 |
+
q = P*SingularityFunction(x, 0, 3)/12 - P*SingularityFunction(x, L/2, 3)/6 + P*SingularityFunction(x, L, 3)/12
|
| 260 |
+
assert p == q/(E*I) + a3*x + a4
|
| 261 |
+
|
| 262 |
+
b.bc_deflection = [(0, 0)]
|
| 263 |
+
p = b.deflection()
|
| 264 |
+
q = a3*x + P*SingularityFunction(x, 0, 3)/12 - P*SingularityFunction(x, L/2, 3)/6 + P*SingularityFunction(x, L, 3)/12
|
| 265 |
+
assert p == q/(E*I)
|
| 266 |
+
|
| 267 |
+
b.bc_deflection = [(0, 0), (L, 0)]
|
| 268 |
+
p = b.deflection()
|
| 269 |
+
q = -L**2*P*x/16 + P*SingularityFunction(x, 0, 3)/12 - P*SingularityFunction(x, L/2, 3)/6 + P*SingularityFunction(x, L, 3)/12
|
| 270 |
+
assert p == q/(E*I)
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def test_statically_indeterminate():
|
| 274 |
+
E = Symbol('E')
|
| 275 |
+
I = Symbol('I')
|
| 276 |
+
M1, M2 = symbols('M1, M2')
|
| 277 |
+
F = Symbol('F')
|
| 278 |
+
l = Symbol('l', positive=True)
|
| 279 |
+
|
| 280 |
+
b5 = Beam(l, E, I)
|
| 281 |
+
b5.bc_deflection = [(0, 0),(l, 0)]
|
| 282 |
+
b5.bc_slope = [(0, 0),(l, 0)]
|
| 283 |
+
|
| 284 |
+
b5.apply_load(R1, 0, -1)
|
| 285 |
+
b5.apply_load(M1, 0, -2)
|
| 286 |
+
b5.apply_load(R2, l, -1)
|
| 287 |
+
b5.apply_load(M2, l, -2)
|
| 288 |
+
b5.apply_load(-F, l/2, -1)
|
| 289 |
+
|
| 290 |
+
b5.solve_for_reaction_loads(R1, R2, M1, M2)
|
| 291 |
+
p = b5.reaction_loads
|
| 292 |
+
q = {R1: F/2, R2: F/2, M1: -F*l/8, M2: F*l/8}
|
| 293 |
+
assert p == q
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
def test_beam_units():
|
| 297 |
+
E = Symbol('E')
|
| 298 |
+
I = Symbol('I')
|
| 299 |
+
R1, R2 = symbols('R1, R2')
|
| 300 |
+
|
| 301 |
+
kN = kilo*newton
|
| 302 |
+
gN = giga*newton
|
| 303 |
+
|
| 304 |
+
b = Beam(8*meter, 200*gN/meter**2, 400*1000000*(milli*meter)**4)
|
| 305 |
+
b.apply_load(5*kN, 2*meter, -1)
|
| 306 |
+
b.apply_load(R1, 0*meter, -1)
|
| 307 |
+
b.apply_load(R2, 8*meter, -1)
|
| 308 |
+
b.apply_load(10*kN/meter, 4*meter, 0, end=8*meter)
|
| 309 |
+
b.bc_deflection = [(0*meter, 0*meter), (8*meter, 0*meter)]
|
| 310 |
+
b.solve_for_reaction_loads(R1, R2)
|
| 311 |
+
assert b.reaction_loads == {R1: -13750*newton, R2: -31250*newton}
|
| 312 |
+
|
| 313 |
+
b = Beam(3*meter, E*newton/meter**2, I*meter**4)
|
| 314 |
+
b.apply_load(8*kN, 1*meter, -1)
|
| 315 |
+
b.apply_load(R1, 0*meter, -1)
|
| 316 |
+
b.apply_load(R2, 3*meter, -1)
|
| 317 |
+
b.apply_load(12*kN*meter, 2*meter, -2)
|
| 318 |
+
b.bc_deflection = [(0*meter, 0*meter), (3*meter, 0*meter)]
|
| 319 |
+
b.solve_for_reaction_loads(R1, R2)
|
| 320 |
+
assert b.reaction_loads == {R1: newton*Rational(-28000, 3), R2: newton*Rational(4000, 3)}
|
| 321 |
+
assert b.deflection().subs(x, 1*meter) == 62000*meter/(9*E*I)
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
def test_variable_moment():
|
| 325 |
+
E = Symbol('E')
|
| 326 |
+
I = Symbol('I')
|
| 327 |
+
|
| 328 |
+
b = Beam(4, E, 2*(4 - x))
|
| 329 |
+
b.apply_load(20, 4, -1)
|
| 330 |
+
R, M = symbols('R, M')
|
| 331 |
+
b.apply_load(R, 0, -1)
|
| 332 |
+
b.apply_load(M, 0, -2)
|
| 333 |
+
b.bc_deflection = [(0, 0)]
|
| 334 |
+
b.bc_slope = [(0, 0)]
|
| 335 |
+
b.solve_for_reaction_loads(R, M)
|
| 336 |
+
assert b.slope().expand() == ((10*x*SingularityFunction(x, 0, 0)
|
| 337 |
+
- 10*(x - 4)*SingularityFunction(x, 4, 0))/E).expand()
|
| 338 |
+
assert b.deflection().expand() == ((5*x**2*SingularityFunction(x, 0, 0)
|
| 339 |
+
- 10*Piecewise((0, Abs(x)/4 < 1), (x**2*meijerg(((-1, 1), ()), ((), (-2, 0)), x/4), True))
|
| 340 |
+
+ 40*SingularityFunction(x, 4, 1))/E).expand()
|
| 341 |
+
|
| 342 |
+
b = Beam(4, E - x, I)
|
| 343 |
+
b.apply_load(20, 4, -1)
|
| 344 |
+
R, M = symbols('R, M')
|
| 345 |
+
b.apply_load(R, 0, -1)
|
| 346 |
+
b.apply_load(M, 0, -2)
|
| 347 |
+
b.bc_deflection = [(0, 0)]
|
| 348 |
+
b.bc_slope = [(0, 0)]
|
| 349 |
+
b.solve_for_reaction_loads(R, M)
|
| 350 |
+
assert b.slope().expand() == ((-80*(-log(-E) + log(-E + x))*SingularityFunction(x, 0, 0)
|
| 351 |
+
+ 80*(-log(-E + 4) + log(-E + x))*SingularityFunction(x, 4, 0) + 20*(-E*log(-E)
|
| 352 |
+
+ E*log(-E + x) + x)*SingularityFunction(x, 0, 0) - 20*(-E*log(-E + 4) + E*log(-E + x)
|
| 353 |
+
+ x - 4)*SingularityFunction(x, 4, 0))/I).expand()
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def test_composite_beam():
|
| 357 |
+
E = Symbol('E')
|
| 358 |
+
I = Symbol('I')
|
| 359 |
+
b1 = Beam(2, E, 1.5*I)
|
| 360 |
+
b2 = Beam(2, E, I)
|
| 361 |
+
b = b1.join(b2, "fixed")
|
| 362 |
+
b.apply_load(-20, 0, -1)
|
| 363 |
+
b.apply_load(80, 0, -2)
|
| 364 |
+
b.apply_load(20, 4, -1)
|
| 365 |
+
b.bc_slope = [(0, 0)]
|
| 366 |
+
b.bc_deflection = [(0, 0)]
|
| 367 |
+
assert b.length == 4
|
| 368 |
+
assert b.second_moment == Piecewise((1.5*I, x <= 2), (I, x <= 4))
|
| 369 |
+
assert b.slope().subs(x, 4) == 120.0/(E*I)
|
| 370 |
+
assert b.slope().subs(x, 2) == 80.0/(E*I)
|
| 371 |
+
assert int(b.deflection().subs(x, 4).args[0]) == -302 # Coefficient of 1/(E*I)
|
| 372 |
+
|
| 373 |
+
l = symbols('l', positive=True)
|
| 374 |
+
R1, M1, R2, R3, P = symbols('R1 M1 R2 R3 P')
|
| 375 |
+
b1 = Beam(2*l, E, I)
|
| 376 |
+
b2 = Beam(2*l, E, I)
|
| 377 |
+
b = b1.join(b2,"hinge")
|
| 378 |
+
b.apply_load(M1, 0, -2)
|
| 379 |
+
b.apply_load(R1, 0, -1)
|
| 380 |
+
b.apply_load(R2, l, -1)
|
| 381 |
+
b.apply_load(R3, 4*l, -1)
|
| 382 |
+
b.apply_load(P, 3*l, -1)
|
| 383 |
+
b.bc_slope = [(0, 0)]
|
| 384 |
+
b.bc_deflection = [(0, 0), (l, 0), (4*l, 0)]
|
| 385 |
+
b.solve_for_reaction_loads(M1, R1, R2, R3)
|
| 386 |
+
assert b.reaction_loads == {R3: -P/2, R2: P*Rational(-5, 4), M1: -P*l/4, R1: P*Rational(3, 4)}
|
| 387 |
+
assert b.slope().subs(x, 3*l) == -7*P*l**2/(48*E*I)
|
| 388 |
+
assert b.deflection().subs(x, 2*l) == 7*P*l**3/(24*E*I)
|
| 389 |
+
assert b.deflection().subs(x, 3*l) == 5*P*l**3/(16*E*I)
|
| 390 |
+
|
| 391 |
+
# When beams having same second moment are joined.
|
| 392 |
+
b1 = Beam(2, 500, 10)
|
| 393 |
+
b2 = Beam(2, 500, 10)
|
| 394 |
+
b = b1.join(b2, "fixed")
|
| 395 |
+
b.apply_load(M1, 0, -2)
|
| 396 |
+
b.apply_load(R1, 0, -1)
|
| 397 |
+
b.apply_load(R2, 1, -1)
|
| 398 |
+
b.apply_load(R3, 4, -1)
|
| 399 |
+
b.apply_load(10, 3, -1)
|
| 400 |
+
b.bc_slope = [(0, 0)]
|
| 401 |
+
b.bc_deflection = [(0, 0), (1, 0), (4, 0)]
|
| 402 |
+
b.solve_for_reaction_loads(M1, R1, R2, R3)
|
| 403 |
+
assert b.slope() == -2*SingularityFunction(x, 0, 1)/5625 + SingularityFunction(x, 0, 2)/1875\
|
| 404 |
+
- 133*SingularityFunction(x, 1, 2)/135000 + SingularityFunction(x, 3, 2)/1000\
|
| 405 |
+
- 37*SingularityFunction(x, 4, 2)/67500
|
| 406 |
+
assert b.deflection() == -SingularityFunction(x, 0, 2)/5625 + SingularityFunction(x, 0, 3)/5625\
|
| 407 |
+
- 133*SingularityFunction(x, 1, 3)/405000 + SingularityFunction(x, 3, 3)/3000\
|
| 408 |
+
- 37*SingularityFunction(x, 4, 3)/202500
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
def test_point_cflexure():
|
| 412 |
+
E = Symbol('E')
|
| 413 |
+
I = Symbol('I')
|
| 414 |
+
b = Beam(10, E, I)
|
| 415 |
+
b.apply_load(-4, 0, -1)
|
| 416 |
+
b.apply_load(-46, 6, -1)
|
| 417 |
+
b.apply_load(10, 2, -1)
|
| 418 |
+
b.apply_load(20, 4, -1)
|
| 419 |
+
b.apply_load(3, 6, 0)
|
| 420 |
+
assert b.point_cflexure() == [Rational(10, 3)]
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
def test_remove_load():
|
| 424 |
+
E = Symbol('E')
|
| 425 |
+
I = Symbol('I')
|
| 426 |
+
b = Beam(4, E, I)
|
| 427 |
+
|
| 428 |
+
try:
|
| 429 |
+
b.remove_load(2, 1, -1)
|
| 430 |
+
# As no load is applied on beam, ValueError should be returned.
|
| 431 |
+
except ValueError:
|
| 432 |
+
assert True
|
| 433 |
+
else:
|
| 434 |
+
assert False
|
| 435 |
+
|
| 436 |
+
b.apply_load(-3, 0, -2)
|
| 437 |
+
b.apply_load(4, 2, -1)
|
| 438 |
+
b.apply_load(-2, 2, 2, end = 3)
|
| 439 |
+
b.remove_load(-2, 2, 2, end = 3)
|
| 440 |
+
assert b.load == -3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1)
|
| 441 |
+
assert b.applied_loads == [(-3, 0, -2, None), (4, 2, -1, None)]
|
| 442 |
+
|
| 443 |
+
try:
|
| 444 |
+
b.remove_load(1, 2, -1)
|
| 445 |
+
# As load of this magnitude was never applied at
|
| 446 |
+
# this position, method should return a ValueError.
|
| 447 |
+
except ValueError:
|
| 448 |
+
assert True
|
| 449 |
+
else:
|
| 450 |
+
assert False
|
| 451 |
+
|
| 452 |
+
b.remove_load(-3, 0, -2)
|
| 453 |
+
b.remove_load(4, 2, -1)
|
| 454 |
+
assert b.load == 0
|
| 455 |
+
assert b.applied_loads == []
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
def test_apply_support():
|
| 459 |
+
E = Symbol('E')
|
| 460 |
+
I = Symbol('I')
|
| 461 |
+
|
| 462 |
+
b = Beam(4, E, I)
|
| 463 |
+
b.apply_support(0, "cantilever")
|
| 464 |
+
b.apply_load(20, 4, -1)
|
| 465 |
+
M_0, R_0 = symbols('M_0, R_0')
|
| 466 |
+
b.solve_for_reaction_loads(R_0, M_0)
|
| 467 |
+
assert simplify(b.slope()) == simplify((80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2)
|
| 468 |
+
+ 10*SingularityFunction(x, 4, 2))/(E*I))
|
| 469 |
+
assert simplify(b.deflection()) == simplify((40*SingularityFunction(x, 0, 2) - 10*SingularityFunction(x, 0, 3)/3
|
| 470 |
+
+ 10*SingularityFunction(x, 4, 3)/3)/(E*I))
|
| 471 |
+
|
| 472 |
+
b = Beam(30, E, I)
|
| 473 |
+
p0 = b.apply_support(10, "pin")
|
| 474 |
+
p1 = b.apply_support(30, "roller")
|
| 475 |
+
b.apply_load(-8, 0, -1)
|
| 476 |
+
b.apply_load(120, 30, -2)
|
| 477 |
+
b.solve_for_reaction_loads(p0, p1)
|
| 478 |
+
assert b.slope() == (-4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2)
|
| 479 |
+
+ 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) + Rational(4000, 3))/(E*I)
|
| 480 |
+
assert b.deflection() == (x*Rational(4000, 3) - 4*SingularityFunction(x, 0, 3)/3 + SingularityFunction(x, 10, 3)
|
| 481 |
+
+ 60*SingularityFunction(x, 30, 2) + SingularityFunction(x, 30, 3)/3 - 12000)/(E*I)
|
| 482 |
+
R_10 = Symbol('R_10')
|
| 483 |
+
R_30 = Symbol('R_30')
|
| 484 |
+
assert p0 == R_10
|
| 485 |
+
assert b.reaction_loads == {R_10: 6, R_30: 2}
|
| 486 |
+
assert b.reaction_loads[p0] == 6
|
| 487 |
+
|
| 488 |
+
b = Beam(8, E, I)
|
| 489 |
+
p0, m0 = b.apply_support(0, "fixed")
|
| 490 |
+
p1 = b.apply_support(8, "roller")
|
| 491 |
+
b.apply_load(-5, 0, 0, 8)
|
| 492 |
+
b.solve_for_reaction_loads(p0, m0, p1)
|
| 493 |
+
R_0 = Symbol('R_0')
|
| 494 |
+
M_0 = Symbol('M_0')
|
| 495 |
+
R_8 = Symbol('R_8')
|
| 496 |
+
assert p0 == R_0
|
| 497 |
+
assert m0 == M_0
|
| 498 |
+
assert p1 == R_8
|
| 499 |
+
assert b.reaction_loads == {R_0: 25, M_0: -40, R_8: 15}
|
| 500 |
+
assert b.reaction_loads[m0] == -40
|
| 501 |
+
|
| 502 |
+
P = Symbol('P', positive=True)
|
| 503 |
+
L = Symbol('L', positive=True)
|
| 504 |
+
b = Beam(L, E, I)
|
| 505 |
+
b.apply_support(0, type='fixed')
|
| 506 |
+
b.apply_support(L, type='fixed')
|
| 507 |
+
b.apply_load(-P, L/2, -1)
|
| 508 |
+
R_0, R_L, M_0, M_L = symbols('R_0, R_L, M_0, M_L')
|
| 509 |
+
b.solve_for_reaction_loads(R_0, R_L, M_0, M_L)
|
| 510 |
+
assert b.reaction_loads == {R_0: P/2, R_L: P/2, M_0: -L*P/8, M_L: L*P/8}
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
def test_max_shear_force():
|
| 514 |
+
E = Symbol('E')
|
| 515 |
+
I = Symbol('I')
|
| 516 |
+
|
| 517 |
+
b = Beam(3, E, I)
|
| 518 |
+
R, M = symbols('R, M')
|
| 519 |
+
b.apply_load(R, 0, -1)
|
| 520 |
+
b.apply_load(M, 0, -2)
|
| 521 |
+
b.apply_load(2, 3, -1)
|
| 522 |
+
b.apply_load(4, 2, -1)
|
| 523 |
+
b.apply_load(2, 2, 0, end=3)
|
| 524 |
+
b.solve_for_reaction_loads(R, M)
|
| 525 |
+
assert b.max_shear_force() == (Interval(0, 2), 8)
|
| 526 |
+
|
| 527 |
+
l = symbols('l', positive=True)
|
| 528 |
+
P = Symbol('P')
|
| 529 |
+
b = Beam(l, E, I)
|
| 530 |
+
R1, R2 = symbols('R1, R2')
|
| 531 |
+
b.apply_load(R1, 0, -1)
|
| 532 |
+
b.apply_load(R2, l, -1)
|
| 533 |
+
b.apply_load(P, 0, 0, end=l)
|
| 534 |
+
b.solve_for_reaction_loads(R1, R2)
|
| 535 |
+
max_shear = b.max_shear_force()
|
| 536 |
+
assert max_shear[0] == 0
|
| 537 |
+
assert simplify(max_shear[1] - (l*Abs(P)/2)) == 0
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
def test_max_bmoment():
|
| 541 |
+
E = Symbol('E')
|
| 542 |
+
I = Symbol('I')
|
| 543 |
+
l, P = symbols('l, P', positive=True)
|
| 544 |
+
|
| 545 |
+
b = Beam(l, E, I)
|
| 546 |
+
R1, R2 = symbols('R1, R2')
|
| 547 |
+
b.apply_load(R1, 0, -1)
|
| 548 |
+
b.apply_load(R2, l, -1)
|
| 549 |
+
b.apply_load(P, l/2, -1)
|
| 550 |
+
b.solve_for_reaction_loads(R1, R2)
|
| 551 |
+
b.reaction_loads
|
| 552 |
+
assert b.max_bmoment() == (l/2, P*l/4)
|
| 553 |
+
|
| 554 |
+
b = Beam(l, E, I)
|
| 555 |
+
R1, R2 = symbols('R1, R2')
|
| 556 |
+
b.apply_load(R1, 0, -1)
|
| 557 |
+
b.apply_load(R2, l, -1)
|
| 558 |
+
b.apply_load(P, 0, 0, end=l)
|
| 559 |
+
b.solve_for_reaction_loads(R1, R2)
|
| 560 |
+
assert b.max_bmoment() == (l/2, P*l**2/8)
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
def test_max_deflection():
|
| 564 |
+
E, I, l, F = symbols('E, I, l, F', positive=True)
|
| 565 |
+
b = Beam(l, E, I)
|
| 566 |
+
b.bc_deflection = [(0, 0),(l, 0)]
|
| 567 |
+
b.bc_slope = [(0, 0),(l, 0)]
|
| 568 |
+
b.apply_load(F/2, 0, -1)
|
| 569 |
+
b.apply_load(-F*l/8, 0, -2)
|
| 570 |
+
b.apply_load(F/2, l, -1)
|
| 571 |
+
b.apply_load(F*l/8, l, -2)
|
| 572 |
+
b.apply_load(-F, l/2, -1)
|
| 573 |
+
assert b.max_deflection() == (l/2, F*l**3/(192*E*I))
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+
def test_Beam3D():
|
| 577 |
+
l, E, G, I, A = symbols('l, E, G, I, A')
|
| 578 |
+
R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
|
| 579 |
+
|
| 580 |
+
b = Beam3D(l, E, G, I, A)
|
| 581 |
+
m, q = symbols('m, q')
|
| 582 |
+
b.apply_load(q, 0, 0, dir="y")
|
| 583 |
+
b.apply_moment_load(m, 0, 0, dir="z")
|
| 584 |
+
b.bc_slope = [(0, [0, 0, 0]), (l, [0, 0, 0])]
|
| 585 |
+
b.bc_deflection = [(0, [0, 0, 0]), (l, [0, 0, 0])]
|
| 586 |
+
b.solve_slope_deflection()
|
| 587 |
+
|
| 588 |
+
assert b.polar_moment() == 2*I
|
| 589 |
+
assert b.shear_force() == [0, -q*x, 0]
|
| 590 |
+
assert b.shear_stress() == [0, -q*x/A, 0]
|
| 591 |
+
assert b.axial_stress() == 0
|
| 592 |
+
assert b.bending_moment() == [0, 0, -m*x + q*x**2/2]
|
| 593 |
+
expected_deflection = (x*(A*G*q*x**3/4 + A*G*x**2*(-l*(A*G*l*(l*q - 2*m) +
|
| 594 |
+
12*E*I*q)/(A*G*l**2 + 12*E*I)/2 - m) + 3*E*I*l*(A*G*l*(l*q - 2*m) +
|
| 595 |
+
12*E*I*q)/(A*G*l**2 + 12*E*I) + x*(-A*G*l**2*q/2 +
|
| 596 |
+
3*A*G*l**2*(A*G*l*(l*q - 2*m) + 12*E*I*q)/(A*G*l**2 + 12*E*I)/4 +
|
| 597 |
+
A*G*l*m*Rational(3, 2) - 3*E*I*q))/(6*A*E*G*I))
|
| 598 |
+
dx, dy, dz = b.deflection()
|
| 599 |
+
assert dx == dz == 0
|
| 600 |
+
assert simplify(dy - expected_deflection) == 0
|
| 601 |
+
|
| 602 |
+
b2 = Beam3D(30, E, G, I, A, x)
|
| 603 |
+
b2.apply_load(50, start=0, order=0, dir="y")
|
| 604 |
+
b2.bc_deflection = [(0, [0, 0, 0]), (30, [0, 0, 0])]
|
| 605 |
+
b2.apply_load(R1, start=0, order=-1, dir="y")
|
| 606 |
+
b2.apply_load(R2, start=30, order=-1, dir="y")
|
| 607 |
+
b2.solve_for_reaction_loads(R1, R2)
|
| 608 |
+
assert b2.reaction_loads == {R1: -750, R2: -750}
|
| 609 |
+
|
| 610 |
+
b2.solve_slope_deflection()
|
| 611 |
+
assert b2.slope() == [0, 0, 25*x**3/(3*E*I) - 375*x**2/(E*I) + 3750*x/(E*I)]
|
| 612 |
+
expected_deflection = 25*x**4/(12*E*I) - 125*x**3/(E*I) + 1875*x**2/(E*I) - \
|
| 613 |
+
25*x**2/(A*G) + 750*x/(A*G)
|
| 614 |
+
dx, dy, dz = b2.deflection()
|
| 615 |
+
assert dx == dz == 0
|
| 616 |
+
assert dy == expected_deflection
|
| 617 |
+
|
| 618 |
+
# Test for solve_for_reaction_loads
|
| 619 |
+
b3 = Beam3D(30, E, G, I, A, x)
|
| 620 |
+
b3.apply_load(8, start=0, order=0, dir="y")
|
| 621 |
+
b3.apply_load(9*x, start=0, order=0, dir="z")
|
| 622 |
+
b3.apply_load(R1, start=0, order=-1, dir="y")
|
| 623 |
+
b3.apply_load(R2, start=30, order=-1, dir="y")
|
| 624 |
+
b3.apply_load(R3, start=0, order=-1, dir="z")
|
| 625 |
+
b3.apply_load(R4, start=30, order=-1, dir="z")
|
| 626 |
+
b3.solve_for_reaction_loads(R1, R2, R3, R4)
|
| 627 |
+
assert b3.reaction_loads == {R1: -120, R2: -120, R3: -1350, R4: -2700}
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
def test_polar_moment_Beam3D():
|
| 631 |
+
l, E, G, A, I1, I2 = symbols('l, E, G, A, I1, I2')
|
| 632 |
+
I = [I1, I2]
|
| 633 |
+
|
| 634 |
+
b = Beam3D(l, E, G, I, A)
|
| 635 |
+
assert b.polar_moment() == I1 + I2
|
| 636 |
+
|
| 637 |
+
|
| 638 |
+
def test_parabolic_loads():
|
| 639 |
+
|
| 640 |
+
E, I, L = symbols('E, I, L', positive=True, real=True)
|
| 641 |
+
R, M, P = symbols('R, M, P', real=True)
|
| 642 |
+
|
| 643 |
+
# cantilever beam fixed at x=0 and parabolic distributed loading across
|
| 644 |
+
# length of beam
|
| 645 |
+
beam = Beam(L, E, I)
|
| 646 |
+
|
| 647 |
+
beam.bc_deflection.append((0, 0))
|
| 648 |
+
beam.bc_slope.append((0, 0))
|
| 649 |
+
beam.apply_load(R, 0, -1)
|
| 650 |
+
beam.apply_load(M, 0, -2)
|
| 651 |
+
|
| 652 |
+
# parabolic load
|
| 653 |
+
beam.apply_load(1, 0, 2)
|
| 654 |
+
|
| 655 |
+
beam.solve_for_reaction_loads(R, M)
|
| 656 |
+
|
| 657 |
+
assert beam.reaction_loads[R] == -L**3/3
|
| 658 |
+
|
| 659 |
+
# cantilever beam fixed at x=0 and parabolic distributed loading across
|
| 660 |
+
# first half of beam
|
| 661 |
+
beam = Beam(2*L, E, I)
|
| 662 |
+
|
| 663 |
+
beam.bc_deflection.append((0, 0))
|
| 664 |
+
beam.bc_slope.append((0, 0))
|
| 665 |
+
beam.apply_load(R, 0, -1)
|
| 666 |
+
beam.apply_load(M, 0, -2)
|
| 667 |
+
|
| 668 |
+
# parabolic load from x=0 to x=L
|
| 669 |
+
beam.apply_load(1, 0, 2, end=L)
|
| 670 |
+
|
| 671 |
+
beam.solve_for_reaction_loads(R, M)
|
| 672 |
+
|
| 673 |
+
# result should be the same as the prior example
|
| 674 |
+
assert beam.reaction_loads[R] == -L**3/3
|
| 675 |
+
|
| 676 |
+
# check constant load
|
| 677 |
+
beam = Beam(2*L, E, I)
|
| 678 |
+
beam.apply_load(P, 0, 0, end=L)
|
| 679 |
+
loading = beam.load.xreplace({L: 10, E: 20, I: 30, P: 40})
|
| 680 |
+
assert loading.xreplace({x: 5}) == 40
|
| 681 |
+
assert loading.xreplace({x: 15}) == 0
|
| 682 |
+
|
| 683 |
+
# check ramp load
|
| 684 |
+
beam = Beam(2*L, E, I)
|
| 685 |
+
beam.apply_load(P, 0, 1, end=L)
|
| 686 |
+
assert beam.load == (P*SingularityFunction(x, 0, 1) -
|
| 687 |
+
P*SingularityFunction(x, L, 1) -
|
| 688 |
+
P*L*SingularityFunction(x, L, 0))
|
| 689 |
+
|
| 690 |
+
# check higher order load: x**8 load from x=0 to x=L
|
| 691 |
+
beam = Beam(2*L, E, I)
|
| 692 |
+
beam.apply_load(P, 0, 8, end=L)
|
| 693 |
+
loading = beam.load.xreplace({L: 10, E: 20, I: 30, P: 40})
|
| 694 |
+
assert loading.xreplace({x: 5}) == 40*5**8
|
| 695 |
+
assert loading.xreplace({x: 15}) == 0
|
| 696 |
+
|
| 697 |
+
|
| 698 |
+
def test_cross_section():
|
| 699 |
+
I = Symbol('I')
|
| 700 |
+
l = Symbol('l')
|
| 701 |
+
E = Symbol('E')
|
| 702 |
+
C3, C4 = symbols('C3, C4')
|
| 703 |
+
a, c, g, h, r, n = symbols('a, c, g, h, r, n')
|
| 704 |
+
|
| 705 |
+
# test for second_moment and cross_section setter
|
| 706 |
+
b0 = Beam(l, E, I)
|
| 707 |
+
assert b0.second_moment == I
|
| 708 |
+
assert b0.cross_section == None
|
| 709 |
+
b0.cross_section = Circle((0, 0), 5)
|
| 710 |
+
assert b0.second_moment == pi*Rational(625, 4)
|
| 711 |
+
assert b0.cross_section == Circle((0, 0), 5)
|
| 712 |
+
b0.second_moment = 2*n - 6
|
| 713 |
+
assert b0.second_moment == 2*n-6
|
| 714 |
+
assert b0.cross_section == None
|
| 715 |
+
with raises(ValueError):
|
| 716 |
+
b0.second_moment = Circle((0, 0), 5)
|
| 717 |
+
|
| 718 |
+
# beam with a circular cross-section
|
| 719 |
+
b1 = Beam(50, E, Circle((0, 0), r))
|
| 720 |
+
assert b1.cross_section == Circle((0, 0), r)
|
| 721 |
+
assert b1.second_moment == pi*r*Abs(r)**3/4
|
| 722 |
+
|
| 723 |
+
b1.apply_load(-10, 0, -1)
|
| 724 |
+
b1.apply_load(R1, 5, -1)
|
| 725 |
+
b1.apply_load(R2, 50, -1)
|
| 726 |
+
b1.apply_load(90, 45, -2)
|
| 727 |
+
b1.solve_for_reaction_loads(R1, R2)
|
| 728 |
+
assert b1.load == (-10*SingularityFunction(x, 0, -1) + 82*SingularityFunction(x, 5, -1)/S(9)
|
| 729 |
+
+ 90*SingularityFunction(x, 45, -2) + 8*SingularityFunction(x, 50, -1)/9)
|
| 730 |
+
assert b1.bending_moment() == (10*SingularityFunction(x, 0, 1) - 82*SingularityFunction(x, 5, 1)/9
|
| 731 |
+
- 90*SingularityFunction(x, 45, 0) - 8*SingularityFunction(x, 50, 1)/9)
|
| 732 |
+
q = (-5*SingularityFunction(x, 0, 2) + 41*SingularityFunction(x, 5, 2)/S(9)
|
| 733 |
+
+ 90*SingularityFunction(x, 45, 1) + 4*SingularityFunction(x, 50, 2)/S(9))/(pi*E*r*Abs(r)**3)
|
| 734 |
+
assert b1.slope() == C3 + 4*q
|
| 735 |
+
q = (-5*SingularityFunction(x, 0, 3)/3 + 41*SingularityFunction(x, 5, 3)/27 + 45*SingularityFunction(x, 45, 2)
|
| 736 |
+
+ 4*SingularityFunction(x, 50, 3)/27)/(pi*E*r*Abs(r)**3)
|
| 737 |
+
assert b1.deflection() == C3*x + C4 + 4*q
|
| 738 |
+
|
| 739 |
+
# beam with a recatangular cross-section
|
| 740 |
+
b2 = Beam(20, E, Polygon((0, 0), (a, 0), (a, c), (0, c)))
|
| 741 |
+
assert b2.cross_section == Polygon((0, 0), (a, 0), (a, c), (0, c))
|
| 742 |
+
assert b2.second_moment == a*c**3/12
|
| 743 |
+
# beam with a triangular cross-section
|
| 744 |
+
b3 = Beam(15, E, Triangle((0, 0), (g, 0), (g/2, h)))
|
| 745 |
+
assert b3.cross_section == Triangle(Point2D(0, 0), Point2D(g, 0), Point2D(g/2, h))
|
| 746 |
+
assert b3.second_moment == g*h**3/36
|
| 747 |
+
|
| 748 |
+
# composite beam
|
| 749 |
+
b = b2.join(b3, "fixed")
|
| 750 |
+
b.apply_load(-30, 0, -1)
|
| 751 |
+
b.apply_load(65, 0, -2)
|
| 752 |
+
b.apply_load(40, 0, -1)
|
| 753 |
+
b.bc_slope = [(0, 0)]
|
| 754 |
+
b.bc_deflection = [(0, 0)]
|
| 755 |
+
|
| 756 |
+
assert b.second_moment == Piecewise((a*c**3/12, x <= 20), (g*h**3/36, x <= 35))
|
| 757 |
+
assert b.cross_section == None
|
| 758 |
+
assert b.length == 35
|
| 759 |
+
assert b.slope().subs(x, 7) == 8400/(E*a*c**3)
|
| 760 |
+
assert b.slope().subs(x, 25) == 52200/(E*g*h**3) + 39600/(E*a*c**3)
|
| 761 |
+
assert b.deflection().subs(x, 30) == -537000/(E*g*h**3) - 712000/(E*a*c**3)
|
| 762 |
+
|
| 763 |
+
def test_max_shear_force_Beam3D():
|
| 764 |
+
x = symbols('x')
|
| 765 |
+
b = Beam3D(20, 40, 21, 100, 25)
|
| 766 |
+
b.apply_load(15, start=0, order=0, dir="z")
|
| 767 |
+
b.apply_load(12*x, start=0, order=0, dir="y")
|
| 768 |
+
b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
|
| 769 |
+
assert b.max_shear_force() == [(0, 0), (20, 2400), (20, 300)]
|
| 770 |
+
|
| 771 |
+
def test_max_bending_moment_Beam3D():
|
| 772 |
+
x = symbols('x')
|
| 773 |
+
b = Beam3D(20, 40, 21, 100, 25)
|
| 774 |
+
b.apply_load(15, start=0, order=0, dir="z")
|
| 775 |
+
b.apply_load(12*x, start=0, order=0, dir="y")
|
| 776 |
+
b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
|
| 777 |
+
assert b.max_bmoment() == [(0, 0), (20, 3000), (20, 16000)]
|
| 778 |
+
|
| 779 |
+
def test_max_deflection_Beam3D():
|
| 780 |
+
x = symbols('x')
|
| 781 |
+
b = Beam3D(20, 40, 21, 100, 25)
|
| 782 |
+
b.apply_load(15, start=0, order=0, dir="z")
|
| 783 |
+
b.apply_load(12*x, start=0, order=0, dir="y")
|
| 784 |
+
b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
|
| 785 |
+
b.solve_slope_deflection()
|
| 786 |
+
c = sympify("495/14")
|
| 787 |
+
p = sympify("-10 + 10*sqrt(10793)/43")
|
| 788 |
+
q = sympify("(10 - 10*sqrt(10793)/43)**3/160 - 20/7 + (10 - 10*sqrt(10793)/43)**4/6400 + 20*sqrt(10793)/301 + 27*(10 - 10*sqrt(10793)/43)**2/560")
|
| 789 |
+
assert b.max_deflection() == [(0, 0), (10, c), (p, q)]
|
| 790 |
+
|
| 791 |
+
def test_torsion_Beam3D():
|
| 792 |
+
x = symbols('x')
|
| 793 |
+
b = Beam3D(20, 40, 21, 100, 25)
|
| 794 |
+
b.apply_moment_load(15, 5, -2, dir='x')
|
| 795 |
+
b.apply_moment_load(25, 10, -2, dir='x')
|
| 796 |
+
b.apply_moment_load(-5, 20, -2, dir='x')
|
| 797 |
+
b.solve_for_torsion()
|
| 798 |
+
assert b.angular_deflection().subs(x, 3) == sympify("1/40")
|
| 799 |
+
assert b.angular_deflection().subs(x, 9) == sympify("17/280")
|
| 800 |
+
assert b.angular_deflection().subs(x, 12) == sympify("53/840")
|
| 801 |
+
assert b.angular_deflection().subs(x, 17) == sympify("2/35")
|
| 802 |
+
assert b.angular_deflection().subs(x, 20) == sympify("3/56")
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/test_cable.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.physics.continuum_mechanics.cable import Cable
|
| 2 |
+
from sympy.core.symbol import Symbol
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def test_cable():
|
| 6 |
+
c = Cable(('A', 0, 10), ('B', 10, 10))
|
| 7 |
+
assert c.supports == {'A': [0, 10], 'B': [10, 10]}
|
| 8 |
+
assert c.left_support == [0, 10]
|
| 9 |
+
assert c.right_support == [10, 10]
|
| 10 |
+
assert c.loads == {'distributed': {}, 'point_load': {}}
|
| 11 |
+
assert c.loads_position == {}
|
| 12 |
+
assert c.length == 0
|
| 13 |
+
assert c.reaction_loads == {Symbol("R_A_x"): 0, Symbol("R_A_y"): 0, Symbol("R_B_x"): 0, Symbol("R_B_y"): 0}
|
| 14 |
+
|
| 15 |
+
# tests for change_support method
|
| 16 |
+
c.change_support('A', ('C', 12, 3))
|
| 17 |
+
assert c.supports == {'B': [10, 10], 'C': [12, 3]}
|
| 18 |
+
assert c.left_support == [10, 10]
|
| 19 |
+
assert c.right_support == [12, 3]
|
| 20 |
+
assert c.reaction_loads == {Symbol("R_B_x"): 0, Symbol("R_B_y"): 0, Symbol("R_C_x"): 0, Symbol("R_C_y"): 0}
|
| 21 |
+
|
| 22 |
+
c.change_support('C', ('A', 0, 10))
|
| 23 |
+
|
| 24 |
+
# tests for apply_load method for point loads
|
| 25 |
+
c.apply_load(-1, ('X', 2, 5, 3, 30))
|
| 26 |
+
c.apply_load(-1, ('Y', 5, 8, 5, 60))
|
| 27 |
+
assert c.loads == {'distributed': {}, 'point_load': {'X': [3, 30], 'Y': [5, 60]}}
|
| 28 |
+
assert c.loads_position == {'X': [2, 5], 'Y': [5, 8]}
|
| 29 |
+
assert c.length == 0
|
| 30 |
+
assert c.reaction_loads == {Symbol("R_A_x"): 0, Symbol("R_A_y"): 0, Symbol("R_B_x"): 0, Symbol("R_B_y"): 0}
|
| 31 |
+
|
| 32 |
+
# tests for remove_loads method
|
| 33 |
+
c.remove_loads('X')
|
| 34 |
+
assert c.loads == {'distributed': {}, 'point_load': {'Y': [5, 60]}}
|
| 35 |
+
assert c.loads_position == {'Y': [5, 8]}
|
| 36 |
+
assert c.length == 0
|
| 37 |
+
assert c.reaction_loads == {Symbol("R_A_x"): 0, Symbol("R_A_y"): 0, Symbol("R_B_x"): 0, Symbol("R_B_y"): 0}
|
| 38 |
+
|
| 39 |
+
c.remove_loads('Y')
|
| 40 |
+
|
| 41 |
+
#tests for apply_load method for distributed load
|
| 42 |
+
c.apply_load(0, ('Z', 9))
|
| 43 |
+
assert c.loads == {'distributed': {'Z': 9}, 'point_load': {}}
|
| 44 |
+
assert c.loads_position == {}
|
| 45 |
+
assert c.length == 0
|
| 46 |
+
assert c.reaction_loads == {Symbol("R_A_x"): 0, Symbol("R_A_y"): 0, Symbol("R_B_x"): 0, Symbol("R_B_y"): 0}
|
| 47 |
+
|
| 48 |
+
# tests for apply_length method
|
| 49 |
+
c.apply_length(20)
|
| 50 |
+
assert c.length == 20
|
| 51 |
+
|
| 52 |
+
del c
|
| 53 |
+
# tests for solve method
|
| 54 |
+
# for point loads
|
| 55 |
+
c = Cable(("A", 0, 10), ("B", 5.5, 8))
|
| 56 |
+
c.apply_load(-1, ('Z', 2, 7.26, 3, 270))
|
| 57 |
+
c.apply_load(-1, ('X', 4, 6, 8, 270))
|
| 58 |
+
c.solve()
|
| 59 |
+
#assert c.tension == {Symbol("Z_X"): 4.79150773600774, Symbol("X_B"): 6.78571428571429, Symbol("A_Z"): 6.89488895397307}
|
| 60 |
+
assert abs(c.tension[Symbol("A_Z")] - 6.89488895397307) < 10e-12
|
| 61 |
+
assert abs(c.tension[Symbol("Z_X")] - 4.79150773600774) < 10e-12
|
| 62 |
+
assert abs(c.tension[Symbol("X_B")] - 6.78571428571429) < 10e-12
|
| 63 |
+
#assert c.reaction_loads == {Symbol("R_A_x"): -4.06504065040650, Symbol("R_A_y"): 5.56910569105691, Symbol("R_B_x"): 4.06504065040650, Symbol("R_B_y"): 5.43089430894309}
|
| 64 |
+
assert abs(c.reaction_loads[Symbol("R_A_x")] + 4.06504065040650) < 10e-12
|
| 65 |
+
assert abs(c.reaction_loads[Symbol("R_A_y")] - 5.56910569105691) < 10e-12
|
| 66 |
+
assert abs(c.reaction_loads[Symbol("R_B_x")] - 4.06504065040650) < 10e-12
|
| 67 |
+
assert abs(c.reaction_loads[Symbol("R_B_y")] - 5.43089430894309) < 10e-12
|
| 68 |
+
assert abs(c.length - 8.25609584845190) < 10e-12
|
| 69 |
+
|
| 70 |
+
del c
|
| 71 |
+
# tests for solve method
|
| 72 |
+
# for distributed loads
|
| 73 |
+
c=Cable(("A", 0, 40),("B", 100, 20))
|
| 74 |
+
c.apply_load(0, ("X", 850))
|
| 75 |
+
c.solve(58.58, 0)
|
| 76 |
+
|
| 77 |
+
# assert c.tension['distributed'] == 36456.8485*sqrt(0.000543529004799705*(X + 0.00135624381275735)**2 + 1)
|
| 78 |
+
assert abs(c.tension_at(0) - 61709.0363315913) < 10e-11
|
| 79 |
+
assert abs(c.tension_at(40) - 39729.7316969361) < 10e-11
|
| 80 |
+
assert abs(c.reaction_loads[Symbol("R_A_x")] - 36456.8485000000) < 10e-11
|
| 81 |
+
assert abs(c.reaction_loads[Symbol("R_A_y")] + 49788.5866682486) < 10e-11
|
| 82 |
+
assert abs(c.reaction_loads[Symbol("R_B_x")] - 44389.8401587246) < 10e-11
|
| 83 |
+
assert abs(c.reaction_loads[Symbol("R_B_y")] - 42866.6216963330) < 10e-11
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/tests/test_truss.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core.symbol import Symbol, symbols
|
| 2 |
+
from sympy.physics.continuum_mechanics.truss import Truss
|
| 3 |
+
from sympy import sqrt
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def test_truss():
|
| 7 |
+
A = Symbol('A')
|
| 8 |
+
B = Symbol('B')
|
| 9 |
+
C = Symbol('C')
|
| 10 |
+
AB, BC, AC = symbols('AB, BC, AC')
|
| 11 |
+
P = Symbol('P')
|
| 12 |
+
|
| 13 |
+
t = Truss()
|
| 14 |
+
assert t.nodes == []
|
| 15 |
+
assert t.node_labels == []
|
| 16 |
+
assert t.node_positions == []
|
| 17 |
+
assert t.members == {}
|
| 18 |
+
assert t.loads == {}
|
| 19 |
+
assert t.supports == {}
|
| 20 |
+
assert t.reaction_loads == {}
|
| 21 |
+
assert t.internal_forces == {}
|
| 22 |
+
|
| 23 |
+
# testing the add_node method
|
| 24 |
+
t.add_node((A, 0, 0), (B, 2, 2), (C, 3, 0))
|
| 25 |
+
assert t.nodes == [(A, 0, 0), (B, 2, 2), (C, 3, 0)]
|
| 26 |
+
assert t.node_labels == [A, B, C]
|
| 27 |
+
assert t.node_positions == [(0, 0), (2, 2), (3, 0)]
|
| 28 |
+
assert t.loads == {}
|
| 29 |
+
assert t.supports == {}
|
| 30 |
+
assert t.reaction_loads == {}
|
| 31 |
+
|
| 32 |
+
# testing the remove_node method
|
| 33 |
+
t.remove_node(C)
|
| 34 |
+
assert t.nodes == [(A, 0, 0), (B, 2, 2)]
|
| 35 |
+
assert t.node_labels == [A, B]
|
| 36 |
+
assert t.node_positions == [(0, 0), (2, 2)]
|
| 37 |
+
assert t.loads == {}
|
| 38 |
+
assert t.supports == {}
|
| 39 |
+
|
| 40 |
+
t.add_node((C, 3, 0))
|
| 41 |
+
|
| 42 |
+
# testing the add_member method
|
| 43 |
+
t.add_member((AB, A, B), (BC, B, C), (AC, A, C))
|
| 44 |
+
assert t.members == {AB: [A, B], BC: [B, C], AC: [A, C]}
|
| 45 |
+
assert t.internal_forces == {AB: 0, BC: 0, AC: 0}
|
| 46 |
+
|
| 47 |
+
# testing the remove_member method
|
| 48 |
+
t.remove_member(BC)
|
| 49 |
+
assert t.members == {AB: [A, B], AC: [A, C]}
|
| 50 |
+
assert t.internal_forces == {AB: 0, AC: 0}
|
| 51 |
+
|
| 52 |
+
t.add_member((BC, B, C))
|
| 53 |
+
|
| 54 |
+
D, CD = symbols('D, CD')
|
| 55 |
+
|
| 56 |
+
# testing the change_label methods
|
| 57 |
+
t.change_node_label((B, D))
|
| 58 |
+
assert t.nodes == [(A, 0, 0), (D, 2, 2), (C, 3, 0)]
|
| 59 |
+
assert t.node_labels == [A, D, C]
|
| 60 |
+
assert t.loads == {}
|
| 61 |
+
assert t.supports == {}
|
| 62 |
+
assert t.members == {AB: [A, D], BC: [D, C], AC: [A, C]}
|
| 63 |
+
|
| 64 |
+
t.change_member_label((BC, CD))
|
| 65 |
+
assert t.members == {AB: [A, D], CD: [D, C], AC: [A, C]}
|
| 66 |
+
assert t.internal_forces == {AB: 0, CD: 0, AC: 0}
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
# testing the apply_load method
|
| 70 |
+
t.apply_load((A, P, 90), (A, P/4, 90), (A, 2*P,45), (D, P/2, 90))
|
| 71 |
+
assert t.loads == {A: [[P, 90], [P/4, 90], [2*P, 45]], D: [[P/2, 90]]}
|
| 72 |
+
assert t.loads[A] == [[P, 90], [P/4, 90], [2*P, 45]]
|
| 73 |
+
|
| 74 |
+
# testing the remove_load method
|
| 75 |
+
t.remove_load((A, P/4, 90))
|
| 76 |
+
assert t.loads == {A: [[P, 90], [2*P, 45]], D: [[P/2, 90]]}
|
| 77 |
+
assert t.loads[A] == [[P, 90], [2*P, 45]]
|
| 78 |
+
|
| 79 |
+
# testing the apply_support method
|
| 80 |
+
t.apply_support((A, "pinned"), (D, "roller"))
|
| 81 |
+
assert t.supports == {A: 'pinned', D: 'roller'}
|
| 82 |
+
assert t.reaction_loads == {}
|
| 83 |
+
assert t.loads == {A: [[P, 90], [2*P, 45], [Symbol('R_A_x'), 0], [Symbol('R_A_y'), 90]], D: [[P/2, 90], [Symbol('R_D_y'), 90]]}
|
| 84 |
+
|
| 85 |
+
# testing the remove_support method
|
| 86 |
+
t.remove_support(A)
|
| 87 |
+
assert t.supports == {D: 'roller'}
|
| 88 |
+
assert t.reaction_loads == {}
|
| 89 |
+
assert t.loads == {A: [[P, 90], [2*P, 45]], D: [[P/2, 90], [Symbol('R_D_y'), 90]]}
|
| 90 |
+
|
| 91 |
+
t.apply_support((A, "pinned"))
|
| 92 |
+
|
| 93 |
+
# testing the solve method
|
| 94 |
+
t.solve()
|
| 95 |
+
assert t.reaction_loads['R_A_x'] == -sqrt(2)*P
|
| 96 |
+
assert t.reaction_loads['R_A_y'] == -sqrt(2)*P - P
|
| 97 |
+
assert t.reaction_loads['R_D_y'] == -P/2
|
| 98 |
+
assert t.internal_forces[AB]/P == 0
|
| 99 |
+
assert t.internal_forces[CD] == 0
|
| 100 |
+
assert t.internal_forces[AC] == 0
|
parrot/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/truss.py
ADDED
|
@@ -0,0 +1,1108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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can be used to solve problems related
|
| 3 |
+
to 2D Trusses.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
from cmath import atan, inf
|
| 8 |
+
from sympy.core.add import Add
|
| 9 |
+
from sympy.core.evalf import INF
|
| 10 |
+
from sympy.core.mul import Mul
|
| 11 |
+
from sympy.core.symbol import Symbol
|
| 12 |
+
from sympy.core.sympify import sympify
|
| 13 |
+
from sympy import Matrix, pi
|
| 14 |
+
from sympy.external.importtools import import_module
|
| 15 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
| 16 |
+
from sympy.matrices.dense import zeros
|
| 17 |
+
import math
|
| 18 |
+
from sympy.physics.units.quantities import Quantity
|
| 19 |
+
from sympy.plotting import plot
|
| 20 |
+
from sympy.utilities.decorator import doctest_depends_on
|
| 21 |
+
from sympy import sin, cos
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
__doctest_requires__ = {('Truss.draw'): ['matplotlib']}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
numpy = import_module('numpy', import_kwargs={'fromlist':['arange']})
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Truss:
|
| 31 |
+
"""
|
| 32 |
+
A Truss is an assembly of members such as beams,
|
| 33 |
+
connected by nodes, that create a rigid structure.
|
| 34 |
+
In engineering, a truss is a structure that
|
| 35 |
+
consists of two-force members only.
|
| 36 |
+
|
| 37 |
+
Trusses are extremely important in engineering applications
|
| 38 |
+
and can be seen in numerous real-world applications like bridges.
|
| 39 |
+
|
| 40 |
+
Examples
|
| 41 |
+
========
|
| 42 |
+
|
| 43 |
+
There is a Truss consisting of four nodes and five
|
| 44 |
+
members connecting the nodes. A force P acts
|
| 45 |
+
downward on the node D and there also exist pinned
|
| 46 |
+
and roller joints on the nodes A and B respectively.
|
| 47 |
+
|
| 48 |
+
.. image:: truss_example.png
|
| 49 |
+
|
| 50 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 51 |
+
>>> t = Truss()
|
| 52 |
+
>>> t.add_node(("node_1", 0, 0), ("node_2", 6, 0), ("node_3", 2, 2), ("node_4", 2, 0))
|
| 53 |
+
>>> t.add_member(("member_1", "node_1", "node_4"), ("member_2", "node_2", "node_4"), ("member_3", "node_1", "node_3"))
|
| 54 |
+
>>> t.add_member(("member_4", "node_2", "node_3"), ("member_5", "node_3", "node_4"))
|
| 55 |
+
>>> t.apply_load(("node_4", 10, 270))
|
| 56 |
+
>>> t.apply_support(("node_1", "pinned"), ("node_2", "roller"))
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
def __init__(self):
|
| 60 |
+
"""
|
| 61 |
+
Initializes the class
|
| 62 |
+
"""
|
| 63 |
+
self._nodes = []
|
| 64 |
+
self._members = {}
|
| 65 |
+
self._loads = {}
|
| 66 |
+
self._supports = {}
|
| 67 |
+
self._node_labels = []
|
| 68 |
+
self._node_positions = []
|
| 69 |
+
self._node_position_x = []
|
| 70 |
+
self._node_position_y = []
|
| 71 |
+
self._nodes_occupied = {}
|
| 72 |
+
self._member_lengths = {}
|
| 73 |
+
self._reaction_loads = {}
|
| 74 |
+
self._internal_forces = {}
|
| 75 |
+
self._node_coordinates = {}
|
| 76 |
+
|
| 77 |
+
@property
|
| 78 |
+
def nodes(self):
|
| 79 |
+
"""
|
| 80 |
+
Returns the nodes of the truss along with their positions.
|
| 81 |
+
"""
|
| 82 |
+
return self._nodes
|
| 83 |
+
|
| 84 |
+
@property
|
| 85 |
+
def node_labels(self):
|
| 86 |
+
"""
|
| 87 |
+
Returns the node labels of the truss.
|
| 88 |
+
"""
|
| 89 |
+
return self._node_labels
|
| 90 |
+
|
| 91 |
+
@property
|
| 92 |
+
def node_positions(self):
|
| 93 |
+
"""
|
| 94 |
+
Returns the positions of the nodes of the truss.
|
| 95 |
+
"""
|
| 96 |
+
return self._node_positions
|
| 97 |
+
|
| 98 |
+
@property
|
| 99 |
+
def members(self):
|
| 100 |
+
"""
|
| 101 |
+
Returns the members of the truss along with the start and end points.
|
| 102 |
+
"""
|
| 103 |
+
return self._members
|
| 104 |
+
|
| 105 |
+
@property
|
| 106 |
+
def member_lengths(self):
|
| 107 |
+
"""
|
| 108 |
+
Returns the length of each member of the truss.
|
| 109 |
+
"""
|
| 110 |
+
return self._member_lengths
|
| 111 |
+
|
| 112 |
+
@property
|
| 113 |
+
def supports(self):
|
| 114 |
+
"""
|
| 115 |
+
Returns the nodes with provided supports along with the kind of support provided i.e.
|
| 116 |
+
pinned or roller.
|
| 117 |
+
"""
|
| 118 |
+
return self._supports
|
| 119 |
+
|
| 120 |
+
@property
|
| 121 |
+
def loads(self):
|
| 122 |
+
"""
|
| 123 |
+
Returns the loads acting on the truss.
|
| 124 |
+
"""
|
| 125 |
+
return self._loads
|
| 126 |
+
|
| 127 |
+
@property
|
| 128 |
+
def reaction_loads(self):
|
| 129 |
+
"""
|
| 130 |
+
Returns the reaction forces for all supports which are all initialized to 0.
|
| 131 |
+
"""
|
| 132 |
+
return self._reaction_loads
|
| 133 |
+
|
| 134 |
+
@property
|
| 135 |
+
def internal_forces(self):
|
| 136 |
+
"""
|
| 137 |
+
Returns the internal forces for all members which are all initialized to 0.
|
| 138 |
+
"""
|
| 139 |
+
return self._internal_forces
|
| 140 |
+
|
| 141 |
+
def add_node(self, *args):
|
| 142 |
+
"""
|
| 143 |
+
This method adds a node to the truss along with its name/label and its location.
|
| 144 |
+
Multiple nodes can be added at the same time.
|
| 145 |
+
|
| 146 |
+
Parameters
|
| 147 |
+
==========
|
| 148 |
+
The input(s) for this method are tuples of the form (label, x, y).
|
| 149 |
+
|
| 150 |
+
label: String or a Symbol
|
| 151 |
+
The label for a node. It is the only way to identify a particular node.
|
| 152 |
+
|
| 153 |
+
x: Sympifyable
|
| 154 |
+
The x-coordinate of the position of the node.
|
| 155 |
+
|
| 156 |
+
y: Sympifyable
|
| 157 |
+
The y-coordinate of the position of the node.
|
| 158 |
+
|
| 159 |
+
Examples
|
| 160 |
+
========
|
| 161 |
+
|
| 162 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 163 |
+
>>> t = Truss()
|
| 164 |
+
>>> t.add_node(('A', 0, 0))
|
| 165 |
+
>>> t.nodes
|
| 166 |
+
[('A', 0, 0)]
|
| 167 |
+
>>> t.add_node(('B', 3, 0), ('C', 4, 1))
|
| 168 |
+
>>> t.nodes
|
| 169 |
+
[('A', 0, 0), ('B', 3, 0), ('C', 4, 1)]
|
| 170 |
+
"""
|
| 171 |
+
|
| 172 |
+
for i in args:
|
| 173 |
+
label = i[0]
|
| 174 |
+
x = i[1]
|
| 175 |
+
x = sympify(x)
|
| 176 |
+
y=i[2]
|
| 177 |
+
y = sympify(y)
|
| 178 |
+
if label in self._node_coordinates:
|
| 179 |
+
raise ValueError("Node needs to have a unique label")
|
| 180 |
+
|
| 181 |
+
elif [x, y] in self._node_coordinates.values():
|
| 182 |
+
raise ValueError("A node already exists at the given position")
|
| 183 |
+
|
| 184 |
+
else :
|
| 185 |
+
self._nodes.append((label, x, y))
|
| 186 |
+
self._node_labels.append(label)
|
| 187 |
+
self._node_positions.append((x, y))
|
| 188 |
+
self._node_position_x.append(x)
|
| 189 |
+
self._node_position_y.append(y)
|
| 190 |
+
self._node_coordinates[label] = [x, y]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def remove_node(self, *args):
|
| 195 |
+
"""
|
| 196 |
+
This method removes a node from the truss.
|
| 197 |
+
Multiple nodes can be removed at the same time.
|
| 198 |
+
|
| 199 |
+
Parameters
|
| 200 |
+
==========
|
| 201 |
+
The input(s) for this method are the labels of the nodes to be removed.
|
| 202 |
+
|
| 203 |
+
label: String or Symbol
|
| 204 |
+
The label of the node to be removed.
|
| 205 |
+
|
| 206 |
+
Examples
|
| 207 |
+
========
|
| 208 |
+
|
| 209 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 210 |
+
>>> t = Truss()
|
| 211 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0), ('C', 5, 0))
|
| 212 |
+
>>> t.nodes
|
| 213 |
+
[('A', 0, 0), ('B', 3, 0), ('C', 5, 0)]
|
| 214 |
+
>>> t.remove_node('A', 'C')
|
| 215 |
+
>>> t.nodes
|
| 216 |
+
[('B', 3, 0)]
|
| 217 |
+
"""
|
| 218 |
+
for label in args:
|
| 219 |
+
for i in range(len(self.nodes)):
|
| 220 |
+
if self._node_labels[i] == label:
|
| 221 |
+
x = self._node_position_x[i]
|
| 222 |
+
y = self._node_position_y[i]
|
| 223 |
+
|
| 224 |
+
if label not in self._node_coordinates:
|
| 225 |
+
raise ValueError("No such node exists in the truss")
|
| 226 |
+
|
| 227 |
+
else:
|
| 228 |
+
members_duplicate = self._members.copy()
|
| 229 |
+
for member in members_duplicate:
|
| 230 |
+
if label == self._members[member][0] or label == self._members[member][1]:
|
| 231 |
+
raise ValueError("The given node already has member attached to it")
|
| 232 |
+
self._nodes.remove((label, x, y))
|
| 233 |
+
self._node_labels.remove(label)
|
| 234 |
+
self._node_positions.remove((x, y))
|
| 235 |
+
self._node_position_x.remove(x)
|
| 236 |
+
self._node_position_y.remove(y)
|
| 237 |
+
if label in self._loads:
|
| 238 |
+
self._loads.pop(label)
|
| 239 |
+
if label in self._supports:
|
| 240 |
+
self._supports.pop(label)
|
| 241 |
+
self._node_coordinates.pop(label)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def add_member(self, *args):
|
| 246 |
+
"""
|
| 247 |
+
This method adds a member between any two nodes in the given truss.
|
| 248 |
+
|
| 249 |
+
Parameters
|
| 250 |
+
==========
|
| 251 |
+
The input(s) of the method are tuple(s) of the form (label, start, end).
|
| 252 |
+
|
| 253 |
+
label: String or Symbol
|
| 254 |
+
The label for a member. It is the only way to identify a particular member.
|
| 255 |
+
|
| 256 |
+
start: String or Symbol
|
| 257 |
+
The label of the starting point/node of the member.
|
| 258 |
+
|
| 259 |
+
end: String or Symbol
|
| 260 |
+
The label of the ending point/node of the member.
|
| 261 |
+
|
| 262 |
+
Examples
|
| 263 |
+
========
|
| 264 |
+
|
| 265 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 266 |
+
>>> t = Truss()
|
| 267 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0), ('C', 2, 2))
|
| 268 |
+
>>> t.add_member(('AB', 'A', 'B'), ('BC', 'B', 'C'))
|
| 269 |
+
>>> t.members
|
| 270 |
+
{'AB': ['A', 'B'], 'BC': ['B', 'C']}
|
| 271 |
+
"""
|
| 272 |
+
for i in args:
|
| 273 |
+
label = i[0]
|
| 274 |
+
start = i[1]
|
| 275 |
+
end = i[2]
|
| 276 |
+
|
| 277 |
+
if start not in self._node_coordinates or end not in self._node_coordinates or start==end:
|
| 278 |
+
raise ValueError("The start and end points of the member must be unique nodes")
|
| 279 |
+
|
| 280 |
+
elif label in self._members:
|
| 281 |
+
raise ValueError("A member with the same label already exists for the truss")
|
| 282 |
+
|
| 283 |
+
elif self._nodes_occupied.get((start, end)):
|
| 284 |
+
raise ValueError("A member already exists between the two nodes")
|
| 285 |
+
|
| 286 |
+
else:
|
| 287 |
+
self._members[label] = [start, end]
|
| 288 |
+
self._member_lengths[label] = sqrt((self._node_coordinates[end][0]-self._node_coordinates[start][0])**2 + (self._node_coordinates[end][1]-self._node_coordinates[start][1])**2)
|
| 289 |
+
self._nodes_occupied[start, end] = True
|
| 290 |
+
self._nodes_occupied[end, start] = True
|
| 291 |
+
self._internal_forces[label] = 0
|
| 292 |
+
|
| 293 |
+
def remove_member(self, *args):
|
| 294 |
+
"""
|
| 295 |
+
This method removes members from the given truss.
|
| 296 |
+
|
| 297 |
+
Parameters
|
| 298 |
+
==========
|
| 299 |
+
labels: String or Symbol
|
| 300 |
+
The label for the member to be removed.
|
| 301 |
+
|
| 302 |
+
Examples
|
| 303 |
+
========
|
| 304 |
+
|
| 305 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 306 |
+
>>> t = Truss()
|
| 307 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0), ('C', 2, 2))
|
| 308 |
+
>>> t.add_member(('AB', 'A', 'B'), ('AC', 'A', 'C'), ('BC', 'B', 'C'))
|
| 309 |
+
>>> t.members
|
| 310 |
+
{'AB': ['A', 'B'], 'AC': ['A', 'C'], 'BC': ['B', 'C']}
|
| 311 |
+
>>> t.remove_member('AC', 'BC')
|
| 312 |
+
>>> t.members
|
| 313 |
+
{'AB': ['A', 'B']}
|
| 314 |
+
"""
|
| 315 |
+
for label in args:
|
| 316 |
+
if label not in self._members:
|
| 317 |
+
raise ValueError("No such member exists in the Truss")
|
| 318 |
+
|
| 319 |
+
else:
|
| 320 |
+
self._nodes_occupied.pop((self._members[label][0], self._members[label][1]))
|
| 321 |
+
self._nodes_occupied.pop((self._members[label][1], self._members[label][0]))
|
| 322 |
+
self._members.pop(label)
|
| 323 |
+
self._member_lengths.pop(label)
|
| 324 |
+
self._internal_forces.pop(label)
|
| 325 |
+
|
| 326 |
+
def change_node_label(self, *args):
|
| 327 |
+
"""
|
| 328 |
+
This method changes the label(s) of the specified node(s).
|
| 329 |
+
|
| 330 |
+
Parameters
|
| 331 |
+
==========
|
| 332 |
+
The input(s) of this method are tuple(s) of the form (label, new_label).
|
| 333 |
+
|
| 334 |
+
label: String or Symbol
|
| 335 |
+
The label of the node for which the label has
|
| 336 |
+
to be changed.
|
| 337 |
+
|
| 338 |
+
new_label: String or Symbol
|
| 339 |
+
The new label of the node.
|
| 340 |
+
|
| 341 |
+
Examples
|
| 342 |
+
========
|
| 343 |
+
|
| 344 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 345 |
+
>>> t = Truss()
|
| 346 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0))
|
| 347 |
+
>>> t.nodes
|
| 348 |
+
[('A', 0, 0), ('B', 3, 0)]
|
| 349 |
+
>>> t.change_node_label(('A', 'C'), ('B', 'D'))
|
| 350 |
+
>>> t.nodes
|
| 351 |
+
[('C', 0, 0), ('D', 3, 0)]
|
| 352 |
+
"""
|
| 353 |
+
for i in args:
|
| 354 |
+
label = i[0]
|
| 355 |
+
new_label = i[1]
|
| 356 |
+
if label not in self._node_coordinates:
|
| 357 |
+
raise ValueError("No such node exists for the Truss")
|
| 358 |
+
elif new_label in self._node_coordinates:
|
| 359 |
+
raise ValueError("A node with the given label already exists")
|
| 360 |
+
else:
|
| 361 |
+
for node in self._nodes:
|
| 362 |
+
if node[0] == label:
|
| 363 |
+
self._nodes[self._nodes.index((label, node[1], node[2]))] = (new_label, node[1], node[2])
|
| 364 |
+
self._node_labels[self._node_labels.index(node[0])] = new_label
|
| 365 |
+
self._node_coordinates[new_label] = self._node_coordinates[label]
|
| 366 |
+
self._node_coordinates.pop(label)
|
| 367 |
+
if node[0] in self._supports:
|
| 368 |
+
self._supports[new_label] = self._supports[node[0]]
|
| 369 |
+
self._supports.pop(node[0])
|
| 370 |
+
if new_label in self._supports:
|
| 371 |
+
if self._supports[new_label] == 'pinned':
|
| 372 |
+
if 'R_'+str(label)+'_x' in self._reaction_loads and 'R_'+str(label)+'_y' in self._reaction_loads:
|
| 373 |
+
self._reaction_loads['R_'+str(new_label)+'_x'] = self._reaction_loads['R_'+str(label)+'_x']
|
| 374 |
+
self._reaction_loads['R_'+str(new_label)+'_y'] = self._reaction_loads['R_'+str(label)+'_y']
|
| 375 |
+
self._reaction_loads.pop('R_'+str(label)+'_x')
|
| 376 |
+
self._reaction_loads.pop('R_'+str(label)+'_y')
|
| 377 |
+
self._loads[new_label] = self._loads[label]
|
| 378 |
+
for load in self._loads[new_label]:
|
| 379 |
+
if load[1] == 90:
|
| 380 |
+
load[0] -= Symbol('R_'+str(label)+'_y')
|
| 381 |
+
if load[0] == 0:
|
| 382 |
+
self._loads[label].remove(load)
|
| 383 |
+
break
|
| 384 |
+
for load in self._loads[new_label]:
|
| 385 |
+
if load[1] == 0:
|
| 386 |
+
load[0] -= Symbol('R_'+str(label)+'_x')
|
| 387 |
+
if load[0] == 0:
|
| 388 |
+
self._loads[label].remove(load)
|
| 389 |
+
break
|
| 390 |
+
self.apply_load(new_label, Symbol('R_'+str(new_label)+'_x'), 0)
|
| 391 |
+
self.apply_load(new_label, Symbol('R_'+str(new_label)+'_y'), 90)
|
| 392 |
+
self._loads.pop(label)
|
| 393 |
+
elif self._supports[new_label] == 'roller':
|
| 394 |
+
self._loads[new_label] = self._loads[label]
|
| 395 |
+
for load in self._loads[label]:
|
| 396 |
+
if load[1] == 90:
|
| 397 |
+
load[0] -= Symbol('R_'+str(label)+'_y')
|
| 398 |
+
if load[0] == 0:
|
| 399 |
+
self._loads[label].remove(load)
|
| 400 |
+
break
|
| 401 |
+
self.apply_load(new_label, Symbol('R_'+str(new_label)+'_y'), 90)
|
| 402 |
+
self._loads.pop(label)
|
| 403 |
+
else:
|
| 404 |
+
if label in self._loads:
|
| 405 |
+
self._loads[new_label] = self._loads[label]
|
| 406 |
+
self._loads.pop(label)
|
| 407 |
+
for member in self._members:
|
| 408 |
+
if self._members[member][0] == node[0]:
|
| 409 |
+
self._members[member][0] = new_label
|
| 410 |
+
self._nodes_occupied[(new_label, self._members[member][1])] = True
|
| 411 |
+
self._nodes_occupied[(self._members[member][1], new_label)] = True
|
| 412 |
+
self._nodes_occupied.pop((label, self._members[member][1]))
|
| 413 |
+
self._nodes_occupied.pop((self._members[member][1], label))
|
| 414 |
+
elif self._members[member][1] == node[0]:
|
| 415 |
+
self._members[member][1] = new_label
|
| 416 |
+
self._nodes_occupied[(self._members[member][0], new_label)] = True
|
| 417 |
+
self._nodes_occupied[(new_label, self._members[member][0])] = True
|
| 418 |
+
self._nodes_occupied.pop((self._members[member][0], label))
|
| 419 |
+
self._nodes_occupied.pop((label, self._members[member][0]))
|
| 420 |
+
|
| 421 |
+
def change_member_label(self, *args):
|
| 422 |
+
"""
|
| 423 |
+
This method changes the label(s) of the specified member(s).
|
| 424 |
+
|
| 425 |
+
Parameters
|
| 426 |
+
==========
|
| 427 |
+
The input(s) of this method are tuple(s) of the form (label, new_label)
|
| 428 |
+
|
| 429 |
+
label: String or Symbol
|
| 430 |
+
The label of the member for which the label has
|
| 431 |
+
to be changed.
|
| 432 |
+
|
| 433 |
+
new_label: String or Symbol
|
| 434 |
+
The new label of the member.
|
| 435 |
+
|
| 436 |
+
Examples
|
| 437 |
+
========
|
| 438 |
+
|
| 439 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 440 |
+
>>> t = Truss()
|
| 441 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0), ('D', 5, 0))
|
| 442 |
+
>>> t.nodes
|
| 443 |
+
[('A', 0, 0), ('B', 3, 0), ('D', 5, 0)]
|
| 444 |
+
>>> t.change_node_label(('A', 'C'))
|
| 445 |
+
>>> t.nodes
|
| 446 |
+
[('C', 0, 0), ('B', 3, 0), ('D', 5, 0)]
|
| 447 |
+
>>> t.add_member(('BC', 'B', 'C'), ('BD', 'B', 'D'))
|
| 448 |
+
>>> t.members
|
| 449 |
+
{'BC': ['B', 'C'], 'BD': ['B', 'D']}
|
| 450 |
+
>>> t.change_member_label(('BC', 'BC_new'), ('BD', 'BD_new'))
|
| 451 |
+
>>> t.members
|
| 452 |
+
{'BC_new': ['B', 'C'], 'BD_new': ['B', 'D']}
|
| 453 |
+
"""
|
| 454 |
+
for i in args:
|
| 455 |
+
label = i[0]
|
| 456 |
+
new_label = i[1]
|
| 457 |
+
if label not in self._members:
|
| 458 |
+
raise ValueError("No such member exists for the Truss")
|
| 459 |
+
else:
|
| 460 |
+
members_duplicate = list(self._members).copy()
|
| 461 |
+
for member in members_duplicate:
|
| 462 |
+
if member == label:
|
| 463 |
+
self._members[new_label] = [self._members[member][0], self._members[member][1]]
|
| 464 |
+
self._members.pop(label)
|
| 465 |
+
self._member_lengths[new_label] = self._member_lengths[label]
|
| 466 |
+
self._member_lengths.pop(label)
|
| 467 |
+
self._internal_forces[new_label] = self._internal_forces[label]
|
| 468 |
+
self._internal_forces.pop(label)
|
| 469 |
+
|
| 470 |
+
def apply_load(self, *args):
|
| 471 |
+
"""
|
| 472 |
+
This method applies external load(s) at the specified node(s).
|
| 473 |
+
|
| 474 |
+
Parameters
|
| 475 |
+
==========
|
| 476 |
+
The input(s) of the method are tuple(s) of the form (location, magnitude, direction).
|
| 477 |
+
|
| 478 |
+
location: String or Symbol
|
| 479 |
+
Label of the Node at which load is applied.
|
| 480 |
+
|
| 481 |
+
magnitude: Sympifyable
|
| 482 |
+
Magnitude of the load applied. It must always be positive and any changes in
|
| 483 |
+
the direction of the load are not reflected here.
|
| 484 |
+
|
| 485 |
+
direction: Sympifyable
|
| 486 |
+
The angle, in degrees, that the load vector makes with the horizontal
|
| 487 |
+
in the counter-clockwise direction. It takes the values 0 to 360,
|
| 488 |
+
inclusive.
|
| 489 |
+
|
| 490 |
+
Examples
|
| 491 |
+
========
|
| 492 |
+
|
| 493 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 494 |
+
>>> from sympy import symbols
|
| 495 |
+
>>> t = Truss()
|
| 496 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0))
|
| 497 |
+
>>> P = symbols('P')
|
| 498 |
+
>>> t.apply_load(('A', P, 90), ('A', P/2, 45), ('A', P/4, 90))
|
| 499 |
+
>>> t.loads
|
| 500 |
+
{'A': [[P, 90], [P/2, 45], [P/4, 90]]}
|
| 501 |
+
"""
|
| 502 |
+
for i in args:
|
| 503 |
+
location = i[0]
|
| 504 |
+
magnitude = i[1]
|
| 505 |
+
direction = i[2]
|
| 506 |
+
magnitude = sympify(magnitude)
|
| 507 |
+
direction = sympify(direction)
|
| 508 |
+
|
| 509 |
+
if location not in self._node_coordinates:
|
| 510 |
+
raise ValueError("Load must be applied at a known node")
|
| 511 |
+
|
| 512 |
+
else:
|
| 513 |
+
if location in self._loads:
|
| 514 |
+
self._loads[location].append([magnitude, direction])
|
| 515 |
+
else:
|
| 516 |
+
self._loads[location] = [[magnitude, direction]]
|
| 517 |
+
|
| 518 |
+
def remove_load(self, *args):
|
| 519 |
+
"""
|
| 520 |
+
This method removes already
|
| 521 |
+
present external load(s) at specified node(s).
|
| 522 |
+
|
| 523 |
+
Parameters
|
| 524 |
+
==========
|
| 525 |
+
The input(s) of this method are tuple(s) of the form (location, magnitude, direction).
|
| 526 |
+
|
| 527 |
+
location: String or Symbol
|
| 528 |
+
Label of the Node at which load is applied and is to be removed.
|
| 529 |
+
|
| 530 |
+
magnitude: Sympifyable
|
| 531 |
+
Magnitude of the load applied.
|
| 532 |
+
|
| 533 |
+
direction: Sympifyable
|
| 534 |
+
The angle, in degrees, that the load vector makes with the horizontal
|
| 535 |
+
in the counter-clockwise direction. It takes the values 0 to 360,
|
| 536 |
+
inclusive.
|
| 537 |
+
|
| 538 |
+
Examples
|
| 539 |
+
========
|
| 540 |
+
|
| 541 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 542 |
+
>>> from sympy import symbols
|
| 543 |
+
>>> t = Truss()
|
| 544 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0))
|
| 545 |
+
>>> P = symbols('P')
|
| 546 |
+
>>> t.apply_load(('A', P, 90), ('A', P/2, 45), ('A', P/4, 90))
|
| 547 |
+
>>> t.loads
|
| 548 |
+
{'A': [[P, 90], [P/2, 45], [P/4, 90]]}
|
| 549 |
+
>>> t.remove_load(('A', P/4, 90), ('A', P/2, 45))
|
| 550 |
+
>>> t.loads
|
| 551 |
+
{'A': [[P, 90]]}
|
| 552 |
+
"""
|
| 553 |
+
for i in args:
|
| 554 |
+
location = i[0]
|
| 555 |
+
magnitude = i[1]
|
| 556 |
+
direction = i[2]
|
| 557 |
+
magnitude = sympify(magnitude)
|
| 558 |
+
direction = sympify(direction)
|
| 559 |
+
|
| 560 |
+
if location not in self._node_coordinates:
|
| 561 |
+
raise ValueError("Load must be removed from a known node")
|
| 562 |
+
|
| 563 |
+
else:
|
| 564 |
+
if [magnitude, direction] not in self._loads[location]:
|
| 565 |
+
raise ValueError("No load of this magnitude and direction has been applied at this node")
|
| 566 |
+
else:
|
| 567 |
+
self._loads[location].remove([magnitude, direction])
|
| 568 |
+
if self._loads[location] == []:
|
| 569 |
+
self._loads.pop(location)
|
| 570 |
+
|
| 571 |
+
def apply_support(self, *args):
|
| 572 |
+
"""
|
| 573 |
+
This method adds a pinned or roller support at specified node(s).
|
| 574 |
+
|
| 575 |
+
Parameters
|
| 576 |
+
==========
|
| 577 |
+
The input(s) of this method are of the form (location, type).
|
| 578 |
+
|
| 579 |
+
location: String or Symbol
|
| 580 |
+
Label of the Node at which support is added.
|
| 581 |
+
|
| 582 |
+
type: String
|
| 583 |
+
Type of the support being provided at the node.
|
| 584 |
+
|
| 585 |
+
Examples
|
| 586 |
+
========
|
| 587 |
+
|
| 588 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 589 |
+
>>> t = Truss()
|
| 590 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0))
|
| 591 |
+
>>> t.apply_support(('A', 'pinned'), ('B', 'roller'))
|
| 592 |
+
>>> t.supports
|
| 593 |
+
{'A': 'pinned', 'B': 'roller'}
|
| 594 |
+
"""
|
| 595 |
+
for i in args:
|
| 596 |
+
location = i[0]
|
| 597 |
+
type = i[1]
|
| 598 |
+
if location not in self._node_coordinates:
|
| 599 |
+
raise ValueError("Support must be added on a known node")
|
| 600 |
+
|
| 601 |
+
else:
|
| 602 |
+
if location not in self._supports:
|
| 603 |
+
if type == 'pinned':
|
| 604 |
+
self.apply_load((location, Symbol('R_'+str(location)+'_x'), 0))
|
| 605 |
+
self.apply_load((location, Symbol('R_'+str(location)+'_y'), 90))
|
| 606 |
+
elif type == 'roller':
|
| 607 |
+
self.apply_load((location, Symbol('R_'+str(location)+'_y'), 90))
|
| 608 |
+
elif self._supports[location] == 'pinned':
|
| 609 |
+
if type == 'roller':
|
| 610 |
+
self.remove_load((location, Symbol('R_'+str(location)+'_x'), 0))
|
| 611 |
+
elif self._supports[location] == 'roller':
|
| 612 |
+
if type == 'pinned':
|
| 613 |
+
self.apply_load((location, Symbol('R_'+str(location)+'_x'), 0))
|
| 614 |
+
self._supports[location] = type
|
| 615 |
+
|
| 616 |
+
def remove_support(self, *args):
|
| 617 |
+
"""
|
| 618 |
+
This method removes support from specified node(s.)
|
| 619 |
+
|
| 620 |
+
Parameters
|
| 621 |
+
==========
|
| 622 |
+
|
| 623 |
+
locations: String or Symbol
|
| 624 |
+
Label of the Node(s) at which support is to be removed.
|
| 625 |
+
|
| 626 |
+
Examples
|
| 627 |
+
========
|
| 628 |
+
|
| 629 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 630 |
+
>>> t = Truss()
|
| 631 |
+
>>> t.add_node(('A', 0, 0), ('B', 3, 0))
|
| 632 |
+
>>> t.apply_support(('A', 'pinned'), ('B', 'roller'))
|
| 633 |
+
>>> t.supports
|
| 634 |
+
{'A': 'pinned', 'B': 'roller'}
|
| 635 |
+
>>> t.remove_support('A','B')
|
| 636 |
+
>>> t.supports
|
| 637 |
+
{}
|
| 638 |
+
"""
|
| 639 |
+
for location in args:
|
| 640 |
+
|
| 641 |
+
if location not in self._node_coordinates:
|
| 642 |
+
raise ValueError("No such node exists in the Truss")
|
| 643 |
+
|
| 644 |
+
elif location not in self._supports:
|
| 645 |
+
raise ValueError("No support has been added to the given node")
|
| 646 |
+
|
| 647 |
+
else:
|
| 648 |
+
if self._supports[location] == 'pinned':
|
| 649 |
+
self.remove_load((location, Symbol('R_'+str(location)+'_x'), 0))
|
| 650 |
+
self.remove_load((location, Symbol('R_'+str(location)+'_y'), 90))
|
| 651 |
+
elif self._supports[location] == 'roller':
|
| 652 |
+
self.remove_load((location, Symbol('R_'+str(location)+'_y'), 90))
|
| 653 |
+
self._supports.pop(location)
|
| 654 |
+
|
| 655 |
+
def solve(self):
|
| 656 |
+
"""
|
| 657 |
+
This method solves for all reaction forces of all supports and all internal forces
|
| 658 |
+
of all the members in the truss, provided the Truss is solvable.
|
| 659 |
+
|
| 660 |
+
A Truss is solvable if the following condition is met,
|
| 661 |
+
|
| 662 |
+
2n >= r + m
|
| 663 |
+
|
| 664 |
+
Where n is the number of nodes, r is the number of reaction forces, where each pinned
|
| 665 |
+
support has 2 reaction forces and each roller has 1, and m is the number of members.
|
| 666 |
+
|
| 667 |
+
The given condition is derived from the fact that a system of equations is solvable
|
| 668 |
+
only when the number of variables is lesser than or equal to the number of equations.
|
| 669 |
+
Equilibrium Equations in x and y directions give two equations per node giving 2n number
|
| 670 |
+
equations. However, the truss needs to be stable as well and may be unstable if 2n > r + m.
|
| 671 |
+
The number of variables is simply the sum of the number of reaction forces and member
|
| 672 |
+
forces.
|
| 673 |
+
|
| 674 |
+
.. note::
|
| 675 |
+
The sign convention for the internal forces present in a member revolves around whether each
|
| 676 |
+
force is compressive or tensile. While forming equations for each node, internal force due
|
| 677 |
+
to a member on the node is assumed to be away from the node i.e. each force is assumed to
|
| 678 |
+
be compressive by default. Hence, a positive value for an internal force implies the
|
| 679 |
+
presence of compressive force in the member and a negative value implies a tensile force.
|
| 680 |
+
|
| 681 |
+
Examples
|
| 682 |
+
========
|
| 683 |
+
|
| 684 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 685 |
+
>>> t = Truss()
|
| 686 |
+
>>> t.add_node(("node_1", 0, 0), ("node_2", 6, 0), ("node_3", 2, 2), ("node_4", 2, 0))
|
| 687 |
+
>>> t.add_member(("member_1", "node_1", "node_4"), ("member_2", "node_2", "node_4"), ("member_3", "node_1", "node_3"))
|
| 688 |
+
>>> t.add_member(("member_4", "node_2", "node_3"), ("member_5", "node_3", "node_4"))
|
| 689 |
+
>>> t.apply_load(("node_4", 10, 270))
|
| 690 |
+
>>> t.apply_support(("node_1", "pinned"), ("node_2", "roller"))
|
| 691 |
+
>>> t.solve()
|
| 692 |
+
>>> t.reaction_loads
|
| 693 |
+
{'R_node_1_x': 0, 'R_node_1_y': 20/3, 'R_node_2_y': 10/3}
|
| 694 |
+
>>> t.internal_forces
|
| 695 |
+
{'member_1': 20/3, 'member_2': 20/3, 'member_3': -20*sqrt(2)/3, 'member_4': -10*sqrt(5)/3, 'member_5': 10}
|
| 696 |
+
"""
|
| 697 |
+
count_reaction_loads = 0
|
| 698 |
+
for node in self._nodes:
|
| 699 |
+
if node[0] in self._supports:
|
| 700 |
+
if self._supports[node[0]]=='pinned':
|
| 701 |
+
count_reaction_loads += 2
|
| 702 |
+
elif self._supports[node[0]]=='roller':
|
| 703 |
+
count_reaction_loads += 1
|
| 704 |
+
if 2*len(self._nodes) != len(self._members) + count_reaction_loads:
|
| 705 |
+
raise ValueError("The given truss cannot be solved")
|
| 706 |
+
coefficients_matrix = [[0 for i in range(2*len(self._nodes))] for j in range(2*len(self._nodes))]
|
| 707 |
+
load_matrix = zeros(2*len(self.nodes), 1)
|
| 708 |
+
load_matrix_row = 0
|
| 709 |
+
for node in self._nodes:
|
| 710 |
+
if node[0] in self._loads:
|
| 711 |
+
for load in self._loads[node[0]]:
|
| 712 |
+
if load[0]!=Symbol('R_'+str(node[0])+'_x') and load[0]!=Symbol('R_'+str(node[0])+'_y'):
|
| 713 |
+
load_matrix[load_matrix_row] -= load[0]*cos(pi*load[1]/180)
|
| 714 |
+
load_matrix[load_matrix_row + 1] -= load[0]*sin(pi*load[1]/180)
|
| 715 |
+
load_matrix_row += 2
|
| 716 |
+
cols = 0
|
| 717 |
+
row = 0
|
| 718 |
+
for node in self._nodes:
|
| 719 |
+
if node[0] in self._supports:
|
| 720 |
+
if self._supports[node[0]]=='pinned':
|
| 721 |
+
coefficients_matrix[row][cols] += 1
|
| 722 |
+
coefficients_matrix[row+1][cols+1] += 1
|
| 723 |
+
cols += 2
|
| 724 |
+
elif self._supports[node[0]]=='roller':
|
| 725 |
+
coefficients_matrix[row+1][cols] += 1
|
| 726 |
+
cols += 1
|
| 727 |
+
row += 2
|
| 728 |
+
for member in self._members:
|
| 729 |
+
start = self._members[member][0]
|
| 730 |
+
end = self._members[member][1]
|
| 731 |
+
length = sqrt((self._node_coordinates[start][0]-self._node_coordinates[end][0])**2 + (self._node_coordinates[start][1]-self._node_coordinates[end][1])**2)
|
| 732 |
+
start_index = self._node_labels.index(start)
|
| 733 |
+
end_index = self._node_labels.index(end)
|
| 734 |
+
horizontal_component_start = (self._node_coordinates[end][0]-self._node_coordinates[start][0])/length
|
| 735 |
+
vertical_component_start = (self._node_coordinates[end][1]-self._node_coordinates[start][1])/length
|
| 736 |
+
horizontal_component_end = (self._node_coordinates[start][0]-self._node_coordinates[end][0])/length
|
| 737 |
+
vertical_component_end = (self._node_coordinates[start][1]-self._node_coordinates[end][1])/length
|
| 738 |
+
coefficients_matrix[start_index*2][cols] += horizontal_component_start
|
| 739 |
+
coefficients_matrix[start_index*2+1][cols] += vertical_component_start
|
| 740 |
+
coefficients_matrix[end_index*2][cols] += horizontal_component_end
|
| 741 |
+
coefficients_matrix[end_index*2+1][cols] += vertical_component_end
|
| 742 |
+
cols += 1
|
| 743 |
+
forces_matrix = (Matrix(coefficients_matrix)**-1)*load_matrix
|
| 744 |
+
self._reaction_loads = {}
|
| 745 |
+
i = 0
|
| 746 |
+
min_load = inf
|
| 747 |
+
for node in self._nodes:
|
| 748 |
+
if node[0] in self._loads:
|
| 749 |
+
for load in self._loads[node[0]]:
|
| 750 |
+
if type(load[0]) not in [Symbol, Mul, Add]:
|
| 751 |
+
min_load = min(min_load, load[0])
|
| 752 |
+
for j in range(len(forces_matrix)):
|
| 753 |
+
if type(forces_matrix[j]) not in [Symbol, Mul, Add]:
|
| 754 |
+
if abs(forces_matrix[j]/min_load) <1E-10:
|
| 755 |
+
forces_matrix[j] = 0
|
| 756 |
+
for node in self._nodes:
|
| 757 |
+
if node[0] in self._supports:
|
| 758 |
+
if self._supports[node[0]]=='pinned':
|
| 759 |
+
self._reaction_loads['R_'+str(node[0])+'_x'] = forces_matrix[i]
|
| 760 |
+
self._reaction_loads['R_'+str(node[0])+'_y'] = forces_matrix[i+1]
|
| 761 |
+
i += 2
|
| 762 |
+
elif self._supports[node[0]]=='roller':
|
| 763 |
+
self._reaction_loads['R_'+str(node[0])+'_y'] = forces_matrix[i]
|
| 764 |
+
i += 1
|
| 765 |
+
for member in self._members:
|
| 766 |
+
self._internal_forces[member] = forces_matrix[i]
|
| 767 |
+
i += 1
|
| 768 |
+
return
|
| 769 |
+
|
| 770 |
+
@doctest_depends_on(modules=('numpy',))
|
| 771 |
+
def draw(self, subs_dict=None):
|
| 772 |
+
"""
|
| 773 |
+
Returns a plot object of the Truss with all its nodes, members,
|
| 774 |
+
supports and loads.
|
| 775 |
+
|
| 776 |
+
.. note::
|
| 777 |
+
The user must be careful while entering load values in their
|
| 778 |
+
directions. The draw function assumes a sign convention that
|
| 779 |
+
is used for plotting loads.
|
| 780 |
+
|
| 781 |
+
Given a right-handed coordinate system with XYZ coordinates,
|
| 782 |
+
the supports are assumed to be such that the reaction forces of a
|
| 783 |
+
pinned support is in the +X and +Y direction while those of a
|
| 784 |
+
roller support is in the +Y direction. For the load, the range
|
| 785 |
+
of angles, one can input goes all the way to 360 degrees which, in the
|
| 786 |
+
the plot is the angle that the load vector makes with the positive x-axis in the anticlockwise direction.
|
| 787 |
+
|
| 788 |
+
For example, for a 90-degree angle, the load will be a vertically
|
| 789 |
+
directed along +Y while a 270-degree angle denotes a vertical
|
| 790 |
+
load as well but along -Y.
|
| 791 |
+
|
| 792 |
+
Examples
|
| 793 |
+
========
|
| 794 |
+
|
| 795 |
+
.. plot::
|
| 796 |
+
:context: close-figs
|
| 797 |
+
:format: doctest
|
| 798 |
+
:include-source: True
|
| 799 |
+
|
| 800 |
+
>>> from sympy.physics.continuum_mechanics.truss import Truss
|
| 801 |
+
>>> import math
|
| 802 |
+
>>> t = Truss()
|
| 803 |
+
>>> t.add_node(("A", -4, 0), ("B", 0, 0), ("C", 4, 0), ("D", 8, 0))
|
| 804 |
+
>>> t.add_node(("E", 6, 2/math.sqrt(3)))
|
| 805 |
+
>>> t.add_node(("F", 2, 2*math.sqrt(3)))
|
| 806 |
+
>>> t.add_node(("G", -2, 2/math.sqrt(3)))
|
| 807 |
+
>>> t.add_member(("AB","A","B"), ("BC","B","C"), ("CD","C","D"))
|
| 808 |
+
>>> t.add_member(("AG","A","G"), ("GB","G","B"), ("GF","G","F"))
|
| 809 |
+
>>> t.add_member(("BF","B","F"), ("FC","F","C"), ("CE","C","E"))
|
| 810 |
+
>>> t.add_member(("FE","F","E"), ("DE","D","E"))
|
| 811 |
+
>>> t.apply_support(("A","pinned"), ("D","roller"))
|
| 812 |
+
>>> t.apply_load(("G", 3, 90), ("E", 3, 90), ("F", 2, 90))
|
| 813 |
+
>>> p = t.draw()
|
| 814 |
+
>>> p # doctest: +ELLIPSIS
|
| 815 |
+
Plot object containing:
|
| 816 |
+
[0]: cartesian line: 1 for x over (1.0, 1.0)
|
| 817 |
+
...
|
| 818 |
+
>>> p.show()
|
| 819 |
+
"""
|
| 820 |
+
if not numpy:
|
| 821 |
+
raise ImportError("To use this function numpy module is required")
|
| 822 |
+
|
| 823 |
+
x = Symbol('x')
|
| 824 |
+
|
| 825 |
+
markers = []
|
| 826 |
+
annotations = []
|
| 827 |
+
rectangles = []
|
| 828 |
+
|
| 829 |
+
node_markers = self._draw_nodes(subs_dict)
|
| 830 |
+
markers += node_markers
|
| 831 |
+
|
| 832 |
+
member_rectangles = self._draw_members()
|
| 833 |
+
rectangles += member_rectangles
|
| 834 |
+
|
| 835 |
+
support_markers = self._draw_supports()
|
| 836 |
+
markers += support_markers
|
| 837 |
+
|
| 838 |
+
load_annotations = self._draw_loads()
|
| 839 |
+
annotations += load_annotations
|
| 840 |
+
|
| 841 |
+
xmax = -INF
|
| 842 |
+
xmin = INF
|
| 843 |
+
ymax = -INF
|
| 844 |
+
ymin = INF
|
| 845 |
+
|
| 846 |
+
for node in self._node_coordinates:
|
| 847 |
+
xmax = max(xmax, self._node_coordinates[node][0])
|
| 848 |
+
xmin = min(xmin, self._node_coordinates[node][0])
|
| 849 |
+
ymax = max(ymax, self._node_coordinates[node][1])
|
| 850 |
+
ymin = min(ymin, self._node_coordinates[node][1])
|
| 851 |
+
|
| 852 |
+
lim = max(xmax*1.1-xmin*0.8+1, ymax*1.1-ymin*0.8+1)
|
| 853 |
+
|
| 854 |
+
if lim==xmax*1.1-xmin*0.8+1:
|
| 855 |
+
sing_plot = plot(1, (x, 1, 1), markers=markers, show=False, annotations=annotations, xlim=(xmin-0.05*lim, xmax*1.1), ylim=(xmin-0.05*lim, xmax*1.1), axis=False, rectangles=rectangles)
|
| 856 |
+
|
| 857 |
+
else:
|
| 858 |
+
sing_plot = plot(1, (x, 1, 1), markers=markers, show=False, annotations=annotations, xlim=(ymin-0.05*lim, ymax*1.1), ylim=(ymin-0.05*lim, ymax*1.1), axis=False, rectangles=rectangles)
|
| 859 |
+
|
| 860 |
+
return sing_plot
|
| 861 |
+
|
| 862 |
+
|
| 863 |
+
def _draw_nodes(self, subs_dict):
|
| 864 |
+
node_markers = []
|
| 865 |
+
|
| 866 |
+
for node in self._node_coordinates:
|
| 867 |
+
if (type(self._node_coordinates[node][0]) in (Symbol, Quantity)):
|
| 868 |
+
if self._node_coordinates[node][0] in subs_dict:
|
| 869 |
+
self._node_coordinates[node][0] = subs_dict[self._node_coordinates[node][0]]
|
| 870 |
+
else:
|
| 871 |
+
raise ValueError("provided substituted dictionary is not adequate")
|
| 872 |
+
elif (type(self._node_coordinates[node][0]) == Mul):
|
| 873 |
+
objects = self._node_coordinates[node][0].as_coeff_Mul()
|
| 874 |
+
for object in objects:
|
| 875 |
+
if type(object) in (Symbol, Quantity):
|
| 876 |
+
if subs_dict==None or object not in subs_dict:
|
| 877 |
+
raise ValueError("provided substituted dictionary is not adequate")
|
| 878 |
+
else:
|
| 879 |
+
self._node_coordinates[node][0] /= object
|
| 880 |
+
self._node_coordinates[node][0] *= subs_dict[object]
|
| 881 |
+
|
| 882 |
+
if (type(self._node_coordinates[node][1]) in (Symbol, Quantity)):
|
| 883 |
+
if self._node_coordinates[node][1] in subs_dict:
|
| 884 |
+
self._node_coordinates[node][1] = subs_dict[self._node_coordinates[node][1]]
|
| 885 |
+
else:
|
| 886 |
+
raise ValueError("provided substituted dictionary is not adequate")
|
| 887 |
+
elif (type(self._node_coordinates[node][1]) == Mul):
|
| 888 |
+
objects = self._node_coordinates[node][1].as_coeff_Mul()
|
| 889 |
+
for object in objects:
|
| 890 |
+
if type(object) in (Symbol, Quantity):
|
| 891 |
+
if subs_dict==None or object not in subs_dict:
|
| 892 |
+
raise ValueError("provided substituted dictionary is not adequate")
|
| 893 |
+
else:
|
| 894 |
+
self._node_coordinates[node][1] /= object
|
| 895 |
+
self._node_coordinates[node][1] *= subs_dict[object]
|
| 896 |
+
|
| 897 |
+
for node in self._node_coordinates:
|
| 898 |
+
node_markers.append(
|
| 899 |
+
{
|
| 900 |
+
'args':[[self._node_coordinates[node][0]], [self._node_coordinates[node][1]]],
|
| 901 |
+
'marker':'o',
|
| 902 |
+
'markersize':5,
|
| 903 |
+
'color':'black'
|
| 904 |
+
}
|
| 905 |
+
)
|
| 906 |
+
return node_markers
|
| 907 |
+
|
| 908 |
+
def _draw_members(self):
|
| 909 |
+
|
| 910 |
+
member_rectangles = []
|
| 911 |
+
|
| 912 |
+
xmax = -INF
|
| 913 |
+
xmin = INF
|
| 914 |
+
ymax = -INF
|
| 915 |
+
ymin = INF
|
| 916 |
+
|
| 917 |
+
for node in self._node_coordinates:
|
| 918 |
+
xmax = max(xmax, self._node_coordinates[node][0])
|
| 919 |
+
xmin = min(xmin, self._node_coordinates[node][0])
|
| 920 |
+
ymax = max(ymax, self._node_coordinates[node][1])
|
| 921 |
+
ymin = min(ymin, self._node_coordinates[node][1])
|
| 922 |
+
|
| 923 |
+
if abs(1.1*xmax-0.8*xmin)>abs(1.1*ymax-0.8*ymin):
|
| 924 |
+
max_diff = 1.1*xmax-0.8*xmin
|
| 925 |
+
else:
|
| 926 |
+
max_diff = 1.1*ymax-0.8*ymin
|
| 927 |
+
|
| 928 |
+
for member in self._members:
|
| 929 |
+
x1 = self._node_coordinates[self._members[member][0]][0]
|
| 930 |
+
y1 = self._node_coordinates[self._members[member][0]][1]
|
| 931 |
+
x2 = self._node_coordinates[self._members[member][1]][0]
|
| 932 |
+
y2 = self._node_coordinates[self._members[member][1]][1]
|
| 933 |
+
if x2!=x1 and y2!=y1:
|
| 934 |
+
if x2>x1:
|
| 935 |
+
member_rectangles.append(
|
| 936 |
+
{
|
| 937 |
+
'xy':(x1-0.005*max_diff*cos(pi/4+atan((y2-y1)/(x2-x1)))/2, y1-0.005*max_diff*sin(pi/4+atan((y2-y1)/(x2-x1)))/2),
|
| 938 |
+
'width':sqrt((x1-x2)**2+(y1-y2)**2)+0.005*max_diff/math.sqrt(2),
|
| 939 |
+
'height':0.005*max_diff,
|
| 940 |
+
'angle':180*atan((y2-y1)/(x2-x1))/pi,
|
| 941 |
+
'color':'brown'
|
| 942 |
+
}
|
| 943 |
+
)
|
| 944 |
+
else:
|
| 945 |
+
member_rectangles.append(
|
| 946 |
+
{
|
| 947 |
+
'xy':(x2-0.005*max_diff*cos(pi/4+atan((y2-y1)/(x2-x1)))/2, y2-0.005*max_diff*sin(pi/4+atan((y2-y1)/(x2-x1)))/2),
|
| 948 |
+
'width':sqrt((x1-x2)**2+(y1-y2)**2)+0.005*max_diff/math.sqrt(2),
|
| 949 |
+
'height':0.005*max_diff,
|
| 950 |
+
'angle':180*atan((y2-y1)/(x2-x1))/pi,
|
| 951 |
+
'color':'brown'
|
| 952 |
+
}
|
| 953 |
+
)
|
| 954 |
+
elif y2==y1:
|
| 955 |
+
if x2>x1:
|
| 956 |
+
member_rectangles.append(
|
| 957 |
+
{
|
| 958 |
+
'xy':(x1-0.005*max_diff/2, y1-0.005*max_diff/2),
|
| 959 |
+
'width':sqrt((x1-x2)**2+(y1-y2)**2),
|
| 960 |
+
'height':0.005*max_diff,
|
| 961 |
+
'angle':90*(1-math.copysign(1, x2-x1)),
|
| 962 |
+
'color':'brown'
|
| 963 |
+
}
|
| 964 |
+
)
|
| 965 |
+
else:
|
| 966 |
+
member_rectangles.append(
|
| 967 |
+
{
|
| 968 |
+
'xy':(x1-0.005*max_diff/2, y1-0.005*max_diff/2),
|
| 969 |
+
'width':sqrt((x1-x2)**2+(y1-y2)**2),
|
| 970 |
+
'height':-0.005*max_diff,
|
| 971 |
+
'angle':90*(1-math.copysign(1, x2-x1)),
|
| 972 |
+
'color':'brown'
|
| 973 |
+
}
|
| 974 |
+
)
|
| 975 |
+
else:
|
| 976 |
+
if y1<y2:
|
| 977 |
+
member_rectangles.append(
|
| 978 |
+
{
|
| 979 |
+
'xy':(x1-0.005*max_diff/2, y1-0.005*max_diff/2),
|
| 980 |
+
'width':sqrt((x1-x2)**2+(y1-y2)**2)+0.005*max_diff/2,
|
| 981 |
+
'height':0.005*max_diff,
|
| 982 |
+
'angle':90*math.copysign(1, y2-y1),
|
| 983 |
+
'color':'brown'
|
| 984 |
+
}
|
| 985 |
+
)
|
| 986 |
+
else:
|
| 987 |
+
member_rectangles.append(
|
| 988 |
+
{
|
| 989 |
+
'xy':(x2-0.005*max_diff/2, y2-0.005*max_diff/2),
|
| 990 |
+
'width':-(sqrt((x1-x2)**2+(y1-y2)**2)+0.005*max_diff/2),
|
| 991 |
+
'height':0.005*max_diff,
|
| 992 |
+
'angle':90*math.copysign(1, y2-y1),
|
| 993 |
+
'color':'brown'
|
| 994 |
+
}
|
| 995 |
+
)
|
| 996 |
+
|
| 997 |
+
return member_rectangles
|
| 998 |
+
|
| 999 |
+
def _draw_supports(self):
|
| 1000 |
+
support_markers = []
|
| 1001 |
+
|
| 1002 |
+
xmax = -INF
|
| 1003 |
+
xmin = INF
|
| 1004 |
+
ymax = -INF
|
| 1005 |
+
ymin = INF
|
| 1006 |
+
|
| 1007 |
+
for node in self._node_coordinates:
|
| 1008 |
+
xmax = max(xmax, self._node_coordinates[node][0])
|
| 1009 |
+
xmin = min(xmin, self._node_coordinates[node][0])
|
| 1010 |
+
ymax = max(ymax, self._node_coordinates[node][1])
|
| 1011 |
+
ymin = min(ymin, self._node_coordinates[node][1])
|
| 1012 |
+
if abs(1.1*xmax-0.8*xmin)>abs(1.1*ymax-0.8*ymin):
|
| 1013 |
+
max_diff = 1.1*xmax-0.8*xmin
|
| 1014 |
+
else:
|
| 1015 |
+
max_diff = 1.1*ymax-0.8*ymin
|
| 1016 |
+
|
| 1017 |
+
for node in self._supports:
|
| 1018 |
+
if self._supports[node]=='pinned':
|
| 1019 |
+
support_markers.append(
|
| 1020 |
+
{
|
| 1021 |
+
'args':[
|
| 1022 |
+
[self._node_coordinates[node][0]],
|
| 1023 |
+
[self._node_coordinates[node][1]]
|
| 1024 |
+
],
|
| 1025 |
+
'marker':6,
|
| 1026 |
+
'markersize':15,
|
| 1027 |
+
'color':'black',
|
| 1028 |
+
'markerfacecolor':'none'
|
| 1029 |
+
}
|
| 1030 |
+
)
|
| 1031 |
+
support_markers.append(
|
| 1032 |
+
{
|
| 1033 |
+
'args':[
|
| 1034 |
+
[self._node_coordinates[node][0]],
|
| 1035 |
+
[self._node_coordinates[node][1]-0.035*max_diff]
|
| 1036 |
+
],
|
| 1037 |
+
'marker':'_',
|
| 1038 |
+
'markersize':14,
|
| 1039 |
+
'color':'black'
|
| 1040 |
+
}
|
| 1041 |
+
)
|
| 1042 |
+
|
| 1043 |
+
elif self._supports[node]=='roller':
|
| 1044 |
+
support_markers.append(
|
| 1045 |
+
{
|
| 1046 |
+
'args':[
|
| 1047 |
+
[self._node_coordinates[node][0]],
|
| 1048 |
+
[self._node_coordinates[node][1]-0.02*max_diff]
|
| 1049 |
+
],
|
| 1050 |
+
'marker':'o',
|
| 1051 |
+
'markersize':11,
|
| 1052 |
+
'color':'black',
|
| 1053 |
+
'markerfacecolor':'none'
|
| 1054 |
+
}
|
| 1055 |
+
)
|
| 1056 |
+
support_markers.append(
|
| 1057 |
+
{
|
| 1058 |
+
'args':[
|
| 1059 |
+
[self._node_coordinates[node][0]],
|
| 1060 |
+
[self._node_coordinates[node][1]-0.0375*max_diff]
|
| 1061 |
+
],
|
| 1062 |
+
'marker':'_',
|
| 1063 |
+
'markersize':14,
|
| 1064 |
+
'color':'black'
|
| 1065 |
+
}
|
| 1066 |
+
)
|
| 1067 |
+
return support_markers
|
| 1068 |
+
|
| 1069 |
+
def _draw_loads(self):
|
| 1070 |
+
load_annotations = []
|
| 1071 |
+
|
| 1072 |
+
xmax = -INF
|
| 1073 |
+
xmin = INF
|
| 1074 |
+
ymax = -INF
|
| 1075 |
+
ymin = INF
|
| 1076 |
+
|
| 1077 |
+
for node in self._node_coordinates:
|
| 1078 |
+
xmax = max(xmax, self._node_coordinates[node][0])
|
| 1079 |
+
xmin = min(xmin, self._node_coordinates[node][0])
|
| 1080 |
+
ymax = max(ymax, self._node_coordinates[node][1])
|
| 1081 |
+
ymin = min(ymin, self._node_coordinates[node][1])
|
| 1082 |
+
|
| 1083 |
+
if abs(1.1*xmax-0.8*xmin)>abs(1.1*ymax-0.8*ymin):
|
| 1084 |
+
max_diff = 1.1*xmax-0.8*xmin+5
|
| 1085 |
+
else:
|
| 1086 |
+
max_diff = 1.1*ymax-0.8*ymin+5
|
| 1087 |
+
|
| 1088 |
+
for node in self._loads:
|
| 1089 |
+
for load in self._loads[node]:
|
| 1090 |
+
if load[0] in [Symbol('R_'+str(node)+'_x'), Symbol('R_'+str(node)+'_y')]:
|
| 1091 |
+
continue
|
| 1092 |
+
x = self._node_coordinates[node][0]
|
| 1093 |
+
y = self._node_coordinates[node][1]
|
| 1094 |
+
load_annotations.append(
|
| 1095 |
+
{
|
| 1096 |
+
'text':'',
|
| 1097 |
+
'xy':(
|
| 1098 |
+
x-math.cos(pi*load[1]/180)*(max_diff/100),
|
| 1099 |
+
y-math.sin(pi*load[1]/180)*(max_diff/100)
|
| 1100 |
+
),
|
| 1101 |
+
'xytext':(
|
| 1102 |
+
x-(max_diff/100+abs(xmax-xmin)+abs(ymax-ymin))*math.cos(pi*load[1]/180)/20,
|
| 1103 |
+
y-(max_diff/100+abs(xmax-xmin)+abs(ymax-ymin))*math.sin(pi*load[1]/180)/20
|
| 1104 |
+
),
|
| 1105 |
+
'arrowprops':{'width':1.5, 'headlength':5, 'headwidth':5, 'facecolor':'black'}
|
| 1106 |
+
}
|
| 1107 |
+
)
|
| 1108 |
+
return load_annotations
|
parrot/lib/python3.10/site-packages/sympy/physics/control/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .lti import (TransferFunction, Series, MIMOSeries, Parallel, MIMOParallel,
|
| 2 |
+
Feedback, MIMOFeedback, TransferFunctionMatrix, StateSpace, gbt, bilinear, forward_diff,
|
| 3 |
+
backward_diff, phase_margin, gain_margin)
|
| 4 |
+
from .control_plots import (pole_zero_numerical_data, pole_zero_plot, step_response_numerical_data,
|
| 5 |
+
step_response_plot, impulse_response_numerical_data, impulse_response_plot, ramp_response_numerical_data,
|
| 6 |
+
ramp_response_plot, bode_magnitude_numerical_data, bode_phase_numerical_data, bode_magnitude_plot,
|
| 7 |
+
bode_phase_plot, bode_plot)
|
| 8 |
+
|
| 9 |
+
__all__ = ['TransferFunction', 'Series', 'MIMOSeries', 'Parallel',
|
| 10 |
+
'MIMOParallel', 'Feedback', 'MIMOFeedback', 'TransferFunctionMatrix', 'StateSpace',
|
| 11 |
+
'gbt', 'bilinear', 'forward_diff', 'backward_diff', 'phase_margin', 'gain_margin',
|
| 12 |
+
'pole_zero_numerical_data', 'pole_zero_plot', 'step_response_numerical_data',
|
| 13 |
+
'step_response_plot', 'impulse_response_numerical_data', 'impulse_response_plot',
|
| 14 |
+
'ramp_response_numerical_data', 'ramp_response_plot',
|
| 15 |
+
'bode_magnitude_numerical_data', 'bode_phase_numerical_data',
|
| 16 |
+
'bode_magnitude_plot', 'bode_phase_plot', 'bode_plot']
|
parrot/lib/python3.10/site-packages/sympy/physics/control/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.13 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/control/__pycache__/control_plots.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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core.numbers import I, pi
|
| 2 |
+
from sympy.functions.elementary.exponential import (exp, log)
|
| 3 |
+
from sympy.polys.partfrac import apart
|
| 4 |
+
from sympy.core.symbol import Dummy
|
| 5 |
+
from sympy.external import import_module
|
| 6 |
+
from sympy.functions import arg, Abs
|
| 7 |
+
from sympy.integrals.laplace import _fast_inverse_laplace
|
| 8 |
+
from sympy.physics.control.lti import SISOLinearTimeInvariant
|
| 9 |
+
from sympy.plotting.series import LineOver1DRangeSeries
|
| 10 |
+
from sympy.polys.polytools import Poly
|
| 11 |
+
from sympy.printing.latex import latex
|
| 12 |
+
|
| 13 |
+
__all__ = ['pole_zero_numerical_data', 'pole_zero_plot',
|
| 14 |
+
'step_response_numerical_data', 'step_response_plot',
|
| 15 |
+
'impulse_response_numerical_data', 'impulse_response_plot',
|
| 16 |
+
'ramp_response_numerical_data', 'ramp_response_plot',
|
| 17 |
+
'bode_magnitude_numerical_data', 'bode_phase_numerical_data',
|
| 18 |
+
'bode_magnitude_plot', 'bode_phase_plot', 'bode_plot']
|
| 19 |
+
|
| 20 |
+
matplotlib = import_module(
|
| 21 |
+
'matplotlib', import_kwargs={'fromlist': ['pyplot']},
|
| 22 |
+
catch=(RuntimeError,))
|
| 23 |
+
|
| 24 |
+
numpy = import_module('numpy')
|
| 25 |
+
|
| 26 |
+
if matplotlib:
|
| 27 |
+
plt = matplotlib.pyplot
|
| 28 |
+
|
| 29 |
+
if numpy:
|
| 30 |
+
np = numpy # Matplotlib already has numpy as a compulsory dependency. No need to install it separately.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _check_system(system):
|
| 34 |
+
"""Function to check whether the dynamical system passed for plots is
|
| 35 |
+
compatible or not."""
|
| 36 |
+
if not isinstance(system, SISOLinearTimeInvariant):
|
| 37 |
+
raise NotImplementedError("Only SISO LTI systems are currently supported.")
|
| 38 |
+
sys = system.to_expr()
|
| 39 |
+
len_free_symbols = len(sys.free_symbols)
|
| 40 |
+
if len_free_symbols > 1:
|
| 41 |
+
raise ValueError("Extra degree of freedom found. Make sure"
|
| 42 |
+
" that there are no free symbols in the dynamical system other"
|
| 43 |
+
" than the variable of Laplace transform.")
|
| 44 |
+
if sys.has(exp):
|
| 45 |
+
# Should test that exp is not part of a constant, in which case
|
| 46 |
+
# no exception is required, compare exp(s) with s*exp(1)
|
| 47 |
+
raise NotImplementedError("Time delay terms are not supported.")
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def pole_zero_numerical_data(system):
|
| 51 |
+
"""
|
| 52 |
+
Returns the numerical data of poles and zeros of the system.
|
| 53 |
+
It is internally used by ``pole_zero_plot`` to get the data
|
| 54 |
+
for plotting poles and zeros. Users can use this data to further
|
| 55 |
+
analyse the dynamics of the system or plot using a different
|
| 56 |
+
backend/plotting-module.
|
| 57 |
+
|
| 58 |
+
Parameters
|
| 59 |
+
==========
|
| 60 |
+
|
| 61 |
+
system : SISOLinearTimeInvariant
|
| 62 |
+
The system for which the pole-zero data is to be computed.
|
| 63 |
+
|
| 64 |
+
Returns
|
| 65 |
+
=======
|
| 66 |
+
|
| 67 |
+
tuple : (zeros, poles)
|
| 68 |
+
zeros = Zeros of the system. NumPy array of complex numbers.
|
| 69 |
+
poles = Poles of the system. NumPy array of complex numbers.
|
| 70 |
+
|
| 71 |
+
Raises
|
| 72 |
+
======
|
| 73 |
+
|
| 74 |
+
NotImplementedError
|
| 75 |
+
When a SISO LTI system is not passed.
|
| 76 |
+
|
| 77 |
+
When time delay terms are present in the system.
|
| 78 |
+
|
| 79 |
+
ValueError
|
| 80 |
+
When more than one free symbol is present in the system.
|
| 81 |
+
The only variable in the transfer function should be
|
| 82 |
+
the variable of the Laplace transform.
|
| 83 |
+
|
| 84 |
+
Examples
|
| 85 |
+
========
|
| 86 |
+
|
| 87 |
+
>>> from sympy.abc import s
|
| 88 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 89 |
+
>>> from sympy.physics.control.control_plots import pole_zero_numerical_data
|
| 90 |
+
>>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
|
| 91 |
+
>>> pole_zero_numerical_data(tf1) # doctest: +SKIP
|
| 92 |
+
([-0.+1.j 0.-1.j], [-2. +0.j -0.5+0.8660254j -0.5-0.8660254j -1. +0.j ])
|
| 93 |
+
|
| 94 |
+
See Also
|
| 95 |
+
========
|
| 96 |
+
|
| 97 |
+
pole_zero_plot
|
| 98 |
+
|
| 99 |
+
"""
|
| 100 |
+
_check_system(system)
|
| 101 |
+
system = system.doit() # Get the equivalent TransferFunction object.
|
| 102 |
+
|
| 103 |
+
num_poly = Poly(system.num, system.var).all_coeffs()
|
| 104 |
+
den_poly = Poly(system.den, system.var).all_coeffs()
|
| 105 |
+
|
| 106 |
+
num_poly = np.array(num_poly, dtype=np.complex128)
|
| 107 |
+
den_poly = np.array(den_poly, dtype=np.complex128)
|
| 108 |
+
|
| 109 |
+
zeros = np.roots(num_poly)
|
| 110 |
+
poles = np.roots(den_poly)
|
| 111 |
+
|
| 112 |
+
return zeros, poles
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def pole_zero_plot(system, pole_color='blue', pole_markersize=10,
|
| 116 |
+
zero_color='orange', zero_markersize=7, grid=True, show_axes=True,
|
| 117 |
+
show=True, **kwargs):
|
| 118 |
+
r"""
|
| 119 |
+
Returns the Pole-Zero plot (also known as PZ Plot or PZ Map) of a system.
|
| 120 |
+
|
| 121 |
+
A Pole-Zero plot is a graphical representation of a system's poles and
|
| 122 |
+
zeros. It is plotted on a complex plane, with circular markers representing
|
| 123 |
+
the system's zeros and 'x' shaped markers representing the system's poles.
|
| 124 |
+
|
| 125 |
+
Parameters
|
| 126 |
+
==========
|
| 127 |
+
|
| 128 |
+
system : SISOLinearTimeInvariant type systems
|
| 129 |
+
The system for which the pole-zero plot is to be computed.
|
| 130 |
+
pole_color : str, tuple, optional
|
| 131 |
+
The color of the pole points on the plot. Default color
|
| 132 |
+
is blue. The color can be provided as a matplotlib color string,
|
| 133 |
+
or a 3-tuple of floats each in the 0-1 range.
|
| 134 |
+
pole_markersize : Number, optional
|
| 135 |
+
The size of the markers used to mark the poles in the plot.
|
| 136 |
+
Default pole markersize is 10.
|
| 137 |
+
zero_color : str, tuple, optional
|
| 138 |
+
The color of the zero points on the plot. Default color
|
| 139 |
+
is orange. The color can be provided as a matplotlib color string,
|
| 140 |
+
or a 3-tuple of floats each in the 0-1 range.
|
| 141 |
+
zero_markersize : Number, optional
|
| 142 |
+
The size of the markers used to mark the zeros in the plot.
|
| 143 |
+
Default zero markersize is 7.
|
| 144 |
+
grid : boolean, optional
|
| 145 |
+
If ``True``, the plot will have a grid. Defaults to True.
|
| 146 |
+
show_axes : boolean, optional
|
| 147 |
+
If ``True``, the coordinate axes will be shown. Defaults to False.
|
| 148 |
+
show : boolean, optional
|
| 149 |
+
If ``True``, the plot will be displayed otherwise
|
| 150 |
+
the equivalent matplotlib ``plot`` object will be returned.
|
| 151 |
+
Defaults to True.
|
| 152 |
+
|
| 153 |
+
Examples
|
| 154 |
+
========
|
| 155 |
+
|
| 156 |
+
.. plot::
|
| 157 |
+
:context: close-figs
|
| 158 |
+
:format: doctest
|
| 159 |
+
:include-source: True
|
| 160 |
+
|
| 161 |
+
>>> from sympy.abc import s
|
| 162 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 163 |
+
>>> from sympy.physics.control.control_plots import pole_zero_plot
|
| 164 |
+
>>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
|
| 165 |
+
>>> pole_zero_plot(tf1) # doctest: +SKIP
|
| 166 |
+
|
| 167 |
+
See Also
|
| 168 |
+
========
|
| 169 |
+
|
| 170 |
+
pole_zero_numerical_data
|
| 171 |
+
|
| 172 |
+
References
|
| 173 |
+
==========
|
| 174 |
+
|
| 175 |
+
.. [1] https://en.wikipedia.org/wiki/Pole%E2%80%93zero_plot
|
| 176 |
+
|
| 177 |
+
"""
|
| 178 |
+
zeros, poles = pole_zero_numerical_data(system)
|
| 179 |
+
|
| 180 |
+
zero_real = np.real(zeros)
|
| 181 |
+
zero_imag = np.imag(zeros)
|
| 182 |
+
|
| 183 |
+
pole_real = np.real(poles)
|
| 184 |
+
pole_imag = np.imag(poles)
|
| 185 |
+
|
| 186 |
+
plt.plot(pole_real, pole_imag, 'x', mfc='none',
|
| 187 |
+
markersize=pole_markersize, color=pole_color)
|
| 188 |
+
plt.plot(zero_real, zero_imag, 'o', markersize=zero_markersize,
|
| 189 |
+
color=zero_color)
|
| 190 |
+
plt.xlabel('Real Axis')
|
| 191 |
+
plt.ylabel('Imaginary Axis')
|
| 192 |
+
plt.title(f'Poles and Zeros of ${latex(system)}$', pad=20)
|
| 193 |
+
|
| 194 |
+
if grid:
|
| 195 |
+
plt.grid()
|
| 196 |
+
if show_axes:
|
| 197 |
+
plt.axhline(0, color='black')
|
| 198 |
+
plt.axvline(0, color='black')
|
| 199 |
+
if show:
|
| 200 |
+
plt.show()
|
| 201 |
+
return
|
| 202 |
+
|
| 203 |
+
return plt
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def step_response_numerical_data(system, prec=8, lower_limit=0,
|
| 207 |
+
upper_limit=10, **kwargs):
|
| 208 |
+
"""
|
| 209 |
+
Returns the numerical values of the points in the step response plot
|
| 210 |
+
of a SISO continuous-time system. By default, adaptive sampling
|
| 211 |
+
is used. If the user wants to instead get an uniformly
|
| 212 |
+
sampled response, then ``adaptive`` kwarg should be passed ``False``
|
| 213 |
+
and ``n`` must be passed as additional kwargs.
|
| 214 |
+
Refer to the parameters of class :class:`sympy.plotting.series.LineOver1DRangeSeries`
|
| 215 |
+
for more details.
|
| 216 |
+
|
| 217 |
+
Parameters
|
| 218 |
+
==========
|
| 219 |
+
|
| 220 |
+
system : SISOLinearTimeInvariant
|
| 221 |
+
The system for which the unit step response data is to be computed.
|
| 222 |
+
prec : int, optional
|
| 223 |
+
The decimal point precision for the point coordinate values.
|
| 224 |
+
Defaults to 8.
|
| 225 |
+
lower_limit : Number, optional
|
| 226 |
+
The lower limit of the plot range. Defaults to 0.
|
| 227 |
+
upper_limit : Number, optional
|
| 228 |
+
The upper limit of the plot range. Defaults to 10.
|
| 229 |
+
kwargs :
|
| 230 |
+
Additional keyword arguments are passed to the underlying
|
| 231 |
+
:class:`sympy.plotting.series.LineOver1DRangeSeries` class.
|
| 232 |
+
|
| 233 |
+
Returns
|
| 234 |
+
=======
|
| 235 |
+
|
| 236 |
+
tuple : (x, y)
|
| 237 |
+
x = Time-axis values of the points in the step response. NumPy array.
|
| 238 |
+
y = Amplitude-axis values of the points in the step response. NumPy array.
|
| 239 |
+
|
| 240 |
+
Raises
|
| 241 |
+
======
|
| 242 |
+
|
| 243 |
+
NotImplementedError
|
| 244 |
+
When a SISO LTI system is not passed.
|
| 245 |
+
|
| 246 |
+
When time delay terms are present in the system.
|
| 247 |
+
|
| 248 |
+
ValueError
|
| 249 |
+
When more than one free symbol is present in the system.
|
| 250 |
+
The only variable in the transfer function should be
|
| 251 |
+
the variable of the Laplace transform.
|
| 252 |
+
|
| 253 |
+
When ``lower_limit`` parameter is less than 0.
|
| 254 |
+
|
| 255 |
+
Examples
|
| 256 |
+
========
|
| 257 |
+
|
| 258 |
+
>>> from sympy.abc import s
|
| 259 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 260 |
+
>>> from sympy.physics.control.control_plots import step_response_numerical_data
|
| 261 |
+
>>> tf1 = TransferFunction(s, s**2 + 5*s + 8, s)
|
| 262 |
+
>>> step_response_numerical_data(tf1) # doctest: +SKIP
|
| 263 |
+
([0.0, 0.025413462339411542, 0.0484508722725343, ... , 9.670250533855183, 9.844291913708725, 10.0],
|
| 264 |
+
[0.0, 0.023844582399907256, 0.042894276802320226, ..., 6.828770759094287e-12, 6.456457160755703e-12])
|
| 265 |
+
|
| 266 |
+
See Also
|
| 267 |
+
========
|
| 268 |
+
|
| 269 |
+
step_response_plot
|
| 270 |
+
|
| 271 |
+
"""
|
| 272 |
+
if lower_limit < 0:
|
| 273 |
+
raise ValueError("Lower limit of time must be greater "
|
| 274 |
+
"than or equal to zero.")
|
| 275 |
+
_check_system(system)
|
| 276 |
+
_x = Dummy("x")
|
| 277 |
+
expr = system.to_expr()/(system.var)
|
| 278 |
+
expr = apart(expr, system.var, full=True)
|
| 279 |
+
_y = _fast_inverse_laplace(expr, system.var, _x).evalf(prec)
|
| 280 |
+
return LineOver1DRangeSeries(_y, (_x, lower_limit, upper_limit),
|
| 281 |
+
**kwargs).get_points()
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def step_response_plot(system, color='b', prec=8, lower_limit=0,
|
| 285 |
+
upper_limit=10, show_axes=False, grid=True, show=True, **kwargs):
|
| 286 |
+
r"""
|
| 287 |
+
Returns the unit step response of a continuous-time system. It is
|
| 288 |
+
the response of the system when the input signal is a step function.
|
| 289 |
+
|
| 290 |
+
Parameters
|
| 291 |
+
==========
|
| 292 |
+
|
| 293 |
+
system : SISOLinearTimeInvariant type
|
| 294 |
+
The LTI SISO system for which the Step Response is to be computed.
|
| 295 |
+
color : str, tuple, optional
|
| 296 |
+
The color of the line. Default is Blue.
|
| 297 |
+
show : boolean, optional
|
| 298 |
+
If ``True``, the plot will be displayed otherwise
|
| 299 |
+
the equivalent matplotlib ``plot`` object will be returned.
|
| 300 |
+
Defaults to True.
|
| 301 |
+
lower_limit : Number, optional
|
| 302 |
+
The lower limit of the plot range. Defaults to 0.
|
| 303 |
+
upper_limit : Number, optional
|
| 304 |
+
The upper limit of the plot range. Defaults to 10.
|
| 305 |
+
prec : int, optional
|
| 306 |
+
The decimal point precision for the point coordinate values.
|
| 307 |
+
Defaults to 8.
|
| 308 |
+
show_axes : boolean, optional
|
| 309 |
+
If ``True``, the coordinate axes will be shown. Defaults to False.
|
| 310 |
+
grid : boolean, optional
|
| 311 |
+
If ``True``, the plot will have a grid. Defaults to True.
|
| 312 |
+
|
| 313 |
+
Examples
|
| 314 |
+
========
|
| 315 |
+
|
| 316 |
+
.. plot::
|
| 317 |
+
:context: close-figs
|
| 318 |
+
:format: doctest
|
| 319 |
+
:include-source: True
|
| 320 |
+
|
| 321 |
+
>>> from sympy.abc import s
|
| 322 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 323 |
+
>>> from sympy.physics.control.control_plots import step_response_plot
|
| 324 |
+
>>> tf1 = TransferFunction(8*s**2 + 18*s + 32, s**3 + 6*s**2 + 14*s + 24, s)
|
| 325 |
+
>>> step_response_plot(tf1) # doctest: +SKIP
|
| 326 |
+
|
| 327 |
+
See Also
|
| 328 |
+
========
|
| 329 |
+
|
| 330 |
+
impulse_response_plot, ramp_response_plot
|
| 331 |
+
|
| 332 |
+
References
|
| 333 |
+
==========
|
| 334 |
+
|
| 335 |
+
.. [1] https://www.mathworks.com/help/control/ref/lti.step.html
|
| 336 |
+
|
| 337 |
+
"""
|
| 338 |
+
x, y = step_response_numerical_data(system, prec=prec,
|
| 339 |
+
lower_limit=lower_limit, upper_limit=upper_limit, **kwargs)
|
| 340 |
+
plt.plot(x, y, color=color)
|
| 341 |
+
plt.xlabel('Time (s)')
|
| 342 |
+
plt.ylabel('Amplitude')
|
| 343 |
+
plt.title(f'Unit Step Response of ${latex(system)}$', pad=20)
|
| 344 |
+
|
| 345 |
+
if grid:
|
| 346 |
+
plt.grid()
|
| 347 |
+
if show_axes:
|
| 348 |
+
plt.axhline(0, color='black')
|
| 349 |
+
plt.axvline(0, color='black')
|
| 350 |
+
if show:
|
| 351 |
+
plt.show()
|
| 352 |
+
return
|
| 353 |
+
|
| 354 |
+
return plt
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
def impulse_response_numerical_data(system, prec=8, lower_limit=0,
|
| 358 |
+
upper_limit=10, **kwargs):
|
| 359 |
+
"""
|
| 360 |
+
Returns the numerical values of the points in the impulse response plot
|
| 361 |
+
of a SISO continuous-time system. By default, adaptive sampling
|
| 362 |
+
is used. If the user wants to instead get an uniformly
|
| 363 |
+
sampled response, then ``adaptive`` kwarg should be passed ``False``
|
| 364 |
+
and ``n`` must be passed as additional kwargs.
|
| 365 |
+
Refer to the parameters of class :class:`sympy.plotting.series.LineOver1DRangeSeries`
|
| 366 |
+
for more details.
|
| 367 |
+
|
| 368 |
+
Parameters
|
| 369 |
+
==========
|
| 370 |
+
|
| 371 |
+
system : SISOLinearTimeInvariant
|
| 372 |
+
The system for which the impulse response data is to be computed.
|
| 373 |
+
prec : int, optional
|
| 374 |
+
The decimal point precision for the point coordinate values.
|
| 375 |
+
Defaults to 8.
|
| 376 |
+
lower_limit : Number, optional
|
| 377 |
+
The lower limit of the plot range. Defaults to 0.
|
| 378 |
+
upper_limit : Number, optional
|
| 379 |
+
The upper limit of the plot range. Defaults to 10.
|
| 380 |
+
kwargs :
|
| 381 |
+
Additional keyword arguments are passed to the underlying
|
| 382 |
+
:class:`sympy.plotting.series.LineOver1DRangeSeries` class.
|
| 383 |
+
|
| 384 |
+
Returns
|
| 385 |
+
=======
|
| 386 |
+
|
| 387 |
+
tuple : (x, y)
|
| 388 |
+
x = Time-axis values of the points in the impulse response. NumPy array.
|
| 389 |
+
y = Amplitude-axis values of the points in the impulse response. NumPy array.
|
| 390 |
+
|
| 391 |
+
Raises
|
| 392 |
+
======
|
| 393 |
+
|
| 394 |
+
NotImplementedError
|
| 395 |
+
When a SISO LTI system is not passed.
|
| 396 |
+
|
| 397 |
+
When time delay terms are present in the system.
|
| 398 |
+
|
| 399 |
+
ValueError
|
| 400 |
+
When more than one free symbol is present in the system.
|
| 401 |
+
The only variable in the transfer function should be
|
| 402 |
+
the variable of the Laplace transform.
|
| 403 |
+
|
| 404 |
+
When ``lower_limit`` parameter is less than 0.
|
| 405 |
+
|
| 406 |
+
Examples
|
| 407 |
+
========
|
| 408 |
+
|
| 409 |
+
>>> from sympy.abc import s
|
| 410 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 411 |
+
>>> from sympy.physics.control.control_plots import impulse_response_numerical_data
|
| 412 |
+
>>> tf1 = TransferFunction(s, s**2 + 5*s + 8, s)
|
| 413 |
+
>>> impulse_response_numerical_data(tf1) # doctest: +SKIP
|
| 414 |
+
([0.0, 0.06616480200395854,... , 9.854500743565858, 10.0],
|
| 415 |
+
[0.9999999799999999, 0.7042848373025861,...,7.170748906965121e-13, -5.1901263495547205e-12])
|
| 416 |
+
|
| 417 |
+
See Also
|
| 418 |
+
========
|
| 419 |
+
|
| 420 |
+
impulse_response_plot
|
| 421 |
+
|
| 422 |
+
"""
|
| 423 |
+
if lower_limit < 0:
|
| 424 |
+
raise ValueError("Lower limit of time must be greater "
|
| 425 |
+
"than or equal to zero.")
|
| 426 |
+
_check_system(system)
|
| 427 |
+
_x = Dummy("x")
|
| 428 |
+
expr = system.to_expr()
|
| 429 |
+
expr = apart(expr, system.var, full=True)
|
| 430 |
+
_y = _fast_inverse_laplace(expr, system.var, _x).evalf(prec)
|
| 431 |
+
return LineOver1DRangeSeries(_y, (_x, lower_limit, upper_limit),
|
| 432 |
+
**kwargs).get_points()
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
def impulse_response_plot(system, color='b', prec=8, lower_limit=0,
|
| 436 |
+
upper_limit=10, show_axes=False, grid=True, show=True, **kwargs):
|
| 437 |
+
r"""
|
| 438 |
+
Returns the unit impulse response (Input is the Dirac-Delta Function) of a
|
| 439 |
+
continuous-time system.
|
| 440 |
+
|
| 441 |
+
Parameters
|
| 442 |
+
==========
|
| 443 |
+
|
| 444 |
+
system : SISOLinearTimeInvariant type
|
| 445 |
+
The LTI SISO system for which the Impulse Response is to be computed.
|
| 446 |
+
color : str, tuple, optional
|
| 447 |
+
The color of the line. Default is Blue.
|
| 448 |
+
show : boolean, optional
|
| 449 |
+
If ``True``, the plot will be displayed otherwise
|
| 450 |
+
the equivalent matplotlib ``plot`` object will be returned.
|
| 451 |
+
Defaults to True.
|
| 452 |
+
lower_limit : Number, optional
|
| 453 |
+
The lower limit of the plot range. Defaults to 0.
|
| 454 |
+
upper_limit : Number, optional
|
| 455 |
+
The upper limit of the plot range. Defaults to 10.
|
| 456 |
+
prec : int, optional
|
| 457 |
+
The decimal point precision for the point coordinate values.
|
| 458 |
+
Defaults to 8.
|
| 459 |
+
show_axes : boolean, optional
|
| 460 |
+
If ``True``, the coordinate axes will be shown. Defaults to False.
|
| 461 |
+
grid : boolean, optional
|
| 462 |
+
If ``True``, the plot will have a grid. Defaults to True.
|
| 463 |
+
|
| 464 |
+
Examples
|
| 465 |
+
========
|
| 466 |
+
|
| 467 |
+
.. plot::
|
| 468 |
+
:context: close-figs
|
| 469 |
+
:format: doctest
|
| 470 |
+
:include-source: True
|
| 471 |
+
|
| 472 |
+
>>> from sympy.abc import s
|
| 473 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 474 |
+
>>> from sympy.physics.control.control_plots import impulse_response_plot
|
| 475 |
+
>>> tf1 = TransferFunction(8*s**2 + 18*s + 32, s**3 + 6*s**2 + 14*s + 24, s)
|
| 476 |
+
>>> impulse_response_plot(tf1) # doctest: +SKIP
|
| 477 |
+
|
| 478 |
+
See Also
|
| 479 |
+
========
|
| 480 |
+
|
| 481 |
+
step_response_plot, ramp_response_plot
|
| 482 |
+
|
| 483 |
+
References
|
| 484 |
+
==========
|
| 485 |
+
|
| 486 |
+
.. [1] https://www.mathworks.com/help/control/ref/dynamicsystem.impulse.html
|
| 487 |
+
|
| 488 |
+
"""
|
| 489 |
+
x, y = impulse_response_numerical_data(system, prec=prec,
|
| 490 |
+
lower_limit=lower_limit, upper_limit=upper_limit, **kwargs)
|
| 491 |
+
plt.plot(x, y, color=color)
|
| 492 |
+
plt.xlabel('Time (s)')
|
| 493 |
+
plt.ylabel('Amplitude')
|
| 494 |
+
plt.title(f'Impulse Response of ${latex(system)}$', pad=20)
|
| 495 |
+
|
| 496 |
+
if grid:
|
| 497 |
+
plt.grid()
|
| 498 |
+
if show_axes:
|
| 499 |
+
plt.axhline(0, color='black')
|
| 500 |
+
plt.axvline(0, color='black')
|
| 501 |
+
if show:
|
| 502 |
+
plt.show()
|
| 503 |
+
return
|
| 504 |
+
|
| 505 |
+
return plt
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
def ramp_response_numerical_data(system, slope=1, prec=8,
|
| 509 |
+
lower_limit=0, upper_limit=10, **kwargs):
|
| 510 |
+
"""
|
| 511 |
+
Returns the numerical values of the points in the ramp response plot
|
| 512 |
+
of a SISO continuous-time system. By default, adaptive sampling
|
| 513 |
+
is used. If the user wants to instead get an uniformly
|
| 514 |
+
sampled response, then ``adaptive`` kwarg should be passed ``False``
|
| 515 |
+
and ``n`` must be passed as additional kwargs.
|
| 516 |
+
Refer to the parameters of class :class:`sympy.plotting.series.LineOver1DRangeSeries`
|
| 517 |
+
for more details.
|
| 518 |
+
|
| 519 |
+
Parameters
|
| 520 |
+
==========
|
| 521 |
+
|
| 522 |
+
system : SISOLinearTimeInvariant
|
| 523 |
+
The system for which the ramp response data is to be computed.
|
| 524 |
+
slope : Number, optional
|
| 525 |
+
The slope of the input ramp function. Defaults to 1.
|
| 526 |
+
prec : int, optional
|
| 527 |
+
The decimal point precision for the point coordinate values.
|
| 528 |
+
Defaults to 8.
|
| 529 |
+
lower_limit : Number, optional
|
| 530 |
+
The lower limit of the plot range. Defaults to 0.
|
| 531 |
+
upper_limit : Number, optional
|
| 532 |
+
The upper limit of the plot range. Defaults to 10.
|
| 533 |
+
kwargs :
|
| 534 |
+
Additional keyword arguments are passed to the underlying
|
| 535 |
+
:class:`sympy.plotting.series.LineOver1DRangeSeries` class.
|
| 536 |
+
|
| 537 |
+
Returns
|
| 538 |
+
=======
|
| 539 |
+
|
| 540 |
+
tuple : (x, y)
|
| 541 |
+
x = Time-axis values of the points in the ramp response plot. NumPy array.
|
| 542 |
+
y = Amplitude-axis values of the points in the ramp response plot. NumPy array.
|
| 543 |
+
|
| 544 |
+
Raises
|
| 545 |
+
======
|
| 546 |
+
|
| 547 |
+
NotImplementedError
|
| 548 |
+
When a SISO LTI system is not passed.
|
| 549 |
+
|
| 550 |
+
When time delay terms are present in the system.
|
| 551 |
+
|
| 552 |
+
ValueError
|
| 553 |
+
When more than one free symbol is present in the system.
|
| 554 |
+
The only variable in the transfer function should be
|
| 555 |
+
the variable of the Laplace transform.
|
| 556 |
+
|
| 557 |
+
When ``lower_limit`` parameter is less than 0.
|
| 558 |
+
|
| 559 |
+
When ``slope`` is negative.
|
| 560 |
+
|
| 561 |
+
Examples
|
| 562 |
+
========
|
| 563 |
+
|
| 564 |
+
>>> from sympy.abc import s
|
| 565 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 566 |
+
>>> from sympy.physics.control.control_plots import ramp_response_numerical_data
|
| 567 |
+
>>> tf1 = TransferFunction(s, s**2 + 5*s + 8, s)
|
| 568 |
+
>>> ramp_response_numerical_data(tf1) # doctest: +SKIP
|
| 569 |
+
(([0.0, 0.12166980856813935,..., 9.861246379582118, 10.0],
|
| 570 |
+
[1.4504508011325967e-09, 0.006046440489058766,..., 0.12499999999568202, 0.12499999999661349]))
|
| 571 |
+
|
| 572 |
+
See Also
|
| 573 |
+
========
|
| 574 |
+
|
| 575 |
+
ramp_response_plot
|
| 576 |
+
|
| 577 |
+
"""
|
| 578 |
+
if slope < 0:
|
| 579 |
+
raise ValueError("Slope must be greater than or equal"
|
| 580 |
+
" to zero.")
|
| 581 |
+
if lower_limit < 0:
|
| 582 |
+
raise ValueError("Lower limit of time must be greater "
|
| 583 |
+
"than or equal to zero.")
|
| 584 |
+
_check_system(system)
|
| 585 |
+
_x = Dummy("x")
|
| 586 |
+
expr = (slope*system.to_expr())/((system.var)**2)
|
| 587 |
+
expr = apart(expr, system.var, full=True)
|
| 588 |
+
_y = _fast_inverse_laplace(expr, system.var, _x).evalf(prec)
|
| 589 |
+
return LineOver1DRangeSeries(_y, (_x, lower_limit, upper_limit),
|
| 590 |
+
**kwargs).get_points()
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
def ramp_response_plot(system, slope=1, color='b', prec=8, lower_limit=0,
|
| 594 |
+
upper_limit=10, show_axes=False, grid=True, show=True, **kwargs):
|
| 595 |
+
r"""
|
| 596 |
+
Returns the ramp response of a continuous-time system.
|
| 597 |
+
|
| 598 |
+
Ramp function is defined as the straight line
|
| 599 |
+
passing through origin ($f(x) = mx$). The slope of
|
| 600 |
+
the ramp function can be varied by the user and
|
| 601 |
+
the default value is 1.
|
| 602 |
+
|
| 603 |
+
Parameters
|
| 604 |
+
==========
|
| 605 |
+
|
| 606 |
+
system : SISOLinearTimeInvariant type
|
| 607 |
+
The LTI SISO system for which the Ramp Response is to be computed.
|
| 608 |
+
slope : Number, optional
|
| 609 |
+
The slope of the input ramp function. Defaults to 1.
|
| 610 |
+
color : str, tuple, optional
|
| 611 |
+
The color of the line. Default is Blue.
|
| 612 |
+
show : boolean, optional
|
| 613 |
+
If ``True``, the plot will be displayed otherwise
|
| 614 |
+
the equivalent matplotlib ``plot`` object will be returned.
|
| 615 |
+
Defaults to True.
|
| 616 |
+
lower_limit : Number, optional
|
| 617 |
+
The lower limit of the plot range. Defaults to 0.
|
| 618 |
+
upper_limit : Number, optional
|
| 619 |
+
The upper limit of the plot range. Defaults to 10.
|
| 620 |
+
prec : int, optional
|
| 621 |
+
The decimal point precision for the point coordinate values.
|
| 622 |
+
Defaults to 8.
|
| 623 |
+
show_axes : boolean, optional
|
| 624 |
+
If ``True``, the coordinate axes will be shown. Defaults to False.
|
| 625 |
+
grid : boolean, optional
|
| 626 |
+
If ``True``, the plot will have a grid. Defaults to True.
|
| 627 |
+
|
| 628 |
+
Examples
|
| 629 |
+
========
|
| 630 |
+
|
| 631 |
+
.. plot::
|
| 632 |
+
:context: close-figs
|
| 633 |
+
:format: doctest
|
| 634 |
+
:include-source: True
|
| 635 |
+
|
| 636 |
+
>>> from sympy.abc import s
|
| 637 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 638 |
+
>>> from sympy.physics.control.control_plots import ramp_response_plot
|
| 639 |
+
>>> tf1 = TransferFunction(s, (s+4)*(s+8), s)
|
| 640 |
+
>>> ramp_response_plot(tf1, upper_limit=2) # doctest: +SKIP
|
| 641 |
+
|
| 642 |
+
See Also
|
| 643 |
+
========
|
| 644 |
+
|
| 645 |
+
step_response_plot, impulse_response_plot
|
| 646 |
+
|
| 647 |
+
References
|
| 648 |
+
==========
|
| 649 |
+
|
| 650 |
+
.. [1] https://en.wikipedia.org/wiki/Ramp_function
|
| 651 |
+
|
| 652 |
+
"""
|
| 653 |
+
x, y = ramp_response_numerical_data(system, slope=slope, prec=prec,
|
| 654 |
+
lower_limit=lower_limit, upper_limit=upper_limit, **kwargs)
|
| 655 |
+
plt.plot(x, y, color=color)
|
| 656 |
+
plt.xlabel('Time (s)')
|
| 657 |
+
plt.ylabel('Amplitude')
|
| 658 |
+
plt.title(f'Ramp Response of ${latex(system)}$ [Slope = {slope}]', pad=20)
|
| 659 |
+
|
| 660 |
+
if grid:
|
| 661 |
+
plt.grid()
|
| 662 |
+
if show_axes:
|
| 663 |
+
plt.axhline(0, color='black')
|
| 664 |
+
plt.axvline(0, color='black')
|
| 665 |
+
if show:
|
| 666 |
+
plt.show()
|
| 667 |
+
return
|
| 668 |
+
|
| 669 |
+
return plt
|
| 670 |
+
|
| 671 |
+
|
| 672 |
+
def bode_magnitude_numerical_data(system, initial_exp=-5, final_exp=5, freq_unit='rad/sec', **kwargs):
|
| 673 |
+
"""
|
| 674 |
+
Returns the numerical data of the Bode magnitude plot of the system.
|
| 675 |
+
It is internally used by ``bode_magnitude_plot`` to get the data
|
| 676 |
+
for plotting Bode magnitude plot. Users can use this data to further
|
| 677 |
+
analyse the dynamics of the system or plot using a different
|
| 678 |
+
backend/plotting-module.
|
| 679 |
+
|
| 680 |
+
Parameters
|
| 681 |
+
==========
|
| 682 |
+
|
| 683 |
+
system : SISOLinearTimeInvariant
|
| 684 |
+
The system for which the data is to be computed.
|
| 685 |
+
initial_exp : Number, optional
|
| 686 |
+
The initial exponent of 10 of the semilog plot. Defaults to -5.
|
| 687 |
+
final_exp : Number, optional
|
| 688 |
+
The final exponent of 10 of the semilog plot. Defaults to 5.
|
| 689 |
+
freq_unit : string, optional
|
| 690 |
+
User can choose between ``'rad/sec'`` (radians/second) and ``'Hz'`` (Hertz) as frequency units.
|
| 691 |
+
|
| 692 |
+
Returns
|
| 693 |
+
=======
|
| 694 |
+
|
| 695 |
+
tuple : (x, y)
|
| 696 |
+
x = x-axis values of the Bode magnitude plot.
|
| 697 |
+
y = y-axis values of the Bode magnitude plot.
|
| 698 |
+
|
| 699 |
+
Raises
|
| 700 |
+
======
|
| 701 |
+
|
| 702 |
+
NotImplementedError
|
| 703 |
+
When a SISO LTI system is not passed.
|
| 704 |
+
|
| 705 |
+
When time delay terms are present in the system.
|
| 706 |
+
|
| 707 |
+
ValueError
|
| 708 |
+
When more than one free symbol is present in the system.
|
| 709 |
+
The only variable in the transfer function should be
|
| 710 |
+
the variable of the Laplace transform.
|
| 711 |
+
|
| 712 |
+
When incorrect frequency units are given as input.
|
| 713 |
+
|
| 714 |
+
Examples
|
| 715 |
+
========
|
| 716 |
+
|
| 717 |
+
>>> from sympy.abc import s
|
| 718 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 719 |
+
>>> from sympy.physics.control.control_plots import bode_magnitude_numerical_data
|
| 720 |
+
>>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
|
| 721 |
+
>>> bode_magnitude_numerical_data(tf1) # doctest: +SKIP
|
| 722 |
+
([1e-05, 1.5148378120533502e-05,..., 68437.36188804005, 100000.0],
|
| 723 |
+
[-6.020599914256786, -6.0205999155219505,..., -193.4117304087953, -200.00000000260573])
|
| 724 |
+
|
| 725 |
+
See Also
|
| 726 |
+
========
|
| 727 |
+
|
| 728 |
+
bode_magnitude_plot, bode_phase_numerical_data
|
| 729 |
+
|
| 730 |
+
"""
|
| 731 |
+
_check_system(system)
|
| 732 |
+
expr = system.to_expr()
|
| 733 |
+
freq_units = ('rad/sec', 'Hz')
|
| 734 |
+
if freq_unit not in freq_units:
|
| 735 |
+
raise ValueError('Only "rad/sec" and "Hz" are accepted frequency units.')
|
| 736 |
+
|
| 737 |
+
_w = Dummy("w", real=True)
|
| 738 |
+
if freq_unit == 'Hz':
|
| 739 |
+
repl = I*_w*2*pi
|
| 740 |
+
else:
|
| 741 |
+
repl = I*_w
|
| 742 |
+
w_expr = expr.subs({system.var: repl})
|
| 743 |
+
|
| 744 |
+
mag = 20*log(Abs(w_expr), 10)
|
| 745 |
+
|
| 746 |
+
x, y = LineOver1DRangeSeries(mag,
|
| 747 |
+
(_w, 10**initial_exp, 10**final_exp), xscale='log', **kwargs).get_points()
|
| 748 |
+
|
| 749 |
+
return x, y
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
def bode_magnitude_plot(system, initial_exp=-5, final_exp=5,
|
| 753 |
+
color='b', show_axes=False, grid=True, show=True, freq_unit='rad/sec', **kwargs):
|
| 754 |
+
r"""
|
| 755 |
+
Returns the Bode magnitude plot of a continuous-time system.
|
| 756 |
+
|
| 757 |
+
See ``bode_plot`` for all the parameters.
|
| 758 |
+
"""
|
| 759 |
+
x, y = bode_magnitude_numerical_data(system, initial_exp=initial_exp,
|
| 760 |
+
final_exp=final_exp, freq_unit=freq_unit)
|
| 761 |
+
plt.plot(x, y, color=color, **kwargs)
|
| 762 |
+
plt.xscale('log')
|
| 763 |
+
|
| 764 |
+
|
| 765 |
+
plt.xlabel('Frequency (%s) [Log Scale]' % freq_unit)
|
| 766 |
+
plt.ylabel('Magnitude (dB)')
|
| 767 |
+
plt.title(f'Bode Plot (Magnitude) of ${latex(system)}$', pad=20)
|
| 768 |
+
|
| 769 |
+
if grid:
|
| 770 |
+
plt.grid(True)
|
| 771 |
+
if show_axes:
|
| 772 |
+
plt.axhline(0, color='black')
|
| 773 |
+
plt.axvline(0, color='black')
|
| 774 |
+
if show:
|
| 775 |
+
plt.show()
|
| 776 |
+
return
|
| 777 |
+
|
| 778 |
+
return plt
|
| 779 |
+
|
| 780 |
+
|
| 781 |
+
def bode_phase_numerical_data(system, initial_exp=-5, final_exp=5, freq_unit='rad/sec', phase_unit='rad', phase_unwrap = True, **kwargs):
|
| 782 |
+
"""
|
| 783 |
+
Returns the numerical data of the Bode phase plot of the system.
|
| 784 |
+
It is internally used by ``bode_phase_plot`` to get the data
|
| 785 |
+
for plotting Bode phase plot. Users can use this data to further
|
| 786 |
+
analyse the dynamics of the system or plot using a different
|
| 787 |
+
backend/plotting-module.
|
| 788 |
+
|
| 789 |
+
Parameters
|
| 790 |
+
==========
|
| 791 |
+
|
| 792 |
+
system : SISOLinearTimeInvariant
|
| 793 |
+
The system for which the Bode phase plot data is to be computed.
|
| 794 |
+
initial_exp : Number, optional
|
| 795 |
+
The initial exponent of 10 of the semilog plot. Defaults to -5.
|
| 796 |
+
final_exp : Number, optional
|
| 797 |
+
The final exponent of 10 of the semilog plot. Defaults to 5.
|
| 798 |
+
freq_unit : string, optional
|
| 799 |
+
User can choose between ``'rad/sec'`` (radians/second) and '``'Hz'`` (Hertz) as frequency units.
|
| 800 |
+
phase_unit : string, optional
|
| 801 |
+
User can choose between ``'rad'`` (radians) and ``'deg'`` (degree) as phase units.
|
| 802 |
+
phase_unwrap : bool, optional
|
| 803 |
+
Set to ``True`` by default.
|
| 804 |
+
|
| 805 |
+
Returns
|
| 806 |
+
=======
|
| 807 |
+
|
| 808 |
+
tuple : (x, y)
|
| 809 |
+
x = x-axis values of the Bode phase plot.
|
| 810 |
+
y = y-axis values of the Bode phase plot.
|
| 811 |
+
|
| 812 |
+
Raises
|
| 813 |
+
======
|
| 814 |
+
|
| 815 |
+
NotImplementedError
|
| 816 |
+
When a SISO LTI system is not passed.
|
| 817 |
+
|
| 818 |
+
When time delay terms are present in the system.
|
| 819 |
+
|
| 820 |
+
ValueError
|
| 821 |
+
When more than one free symbol is present in the system.
|
| 822 |
+
The only variable in the transfer function should be
|
| 823 |
+
the variable of the Laplace transform.
|
| 824 |
+
|
| 825 |
+
When incorrect frequency or phase units are given as input.
|
| 826 |
+
|
| 827 |
+
Examples
|
| 828 |
+
========
|
| 829 |
+
|
| 830 |
+
>>> from sympy.abc import s
|
| 831 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 832 |
+
>>> from sympy.physics.control.control_plots import bode_phase_numerical_data
|
| 833 |
+
>>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
|
| 834 |
+
>>> bode_phase_numerical_data(tf1) # doctest: +SKIP
|
| 835 |
+
([1e-05, 1.4472354033813751e-05, 2.035581932165858e-05,..., 47577.3248186011, 67884.09326036123, 100000.0],
|
| 836 |
+
[-2.5000000000291665e-05, -3.6180885085e-05, -5.08895483066e-05,...,-3.1415085799262523, -3.14155265358979])
|
| 837 |
+
|
| 838 |
+
See Also
|
| 839 |
+
========
|
| 840 |
+
|
| 841 |
+
bode_magnitude_plot, bode_phase_numerical_data
|
| 842 |
+
|
| 843 |
+
"""
|
| 844 |
+
_check_system(system)
|
| 845 |
+
expr = system.to_expr()
|
| 846 |
+
freq_units = ('rad/sec', 'Hz')
|
| 847 |
+
phase_units = ('rad', 'deg')
|
| 848 |
+
if freq_unit not in freq_units:
|
| 849 |
+
raise ValueError('Only "rad/sec" and "Hz" are accepted frequency units.')
|
| 850 |
+
if phase_unit not in phase_units:
|
| 851 |
+
raise ValueError('Only "rad" and "deg" are accepted phase units.')
|
| 852 |
+
|
| 853 |
+
_w = Dummy("w", real=True)
|
| 854 |
+
if freq_unit == 'Hz':
|
| 855 |
+
repl = I*_w*2*pi
|
| 856 |
+
else:
|
| 857 |
+
repl = I*_w
|
| 858 |
+
w_expr = expr.subs({system.var: repl})
|
| 859 |
+
|
| 860 |
+
if phase_unit == 'deg':
|
| 861 |
+
phase = arg(w_expr)*180/pi
|
| 862 |
+
else:
|
| 863 |
+
phase = arg(w_expr)
|
| 864 |
+
|
| 865 |
+
x, y = LineOver1DRangeSeries(phase,
|
| 866 |
+
(_w, 10**initial_exp, 10**final_exp), xscale='log', **kwargs).get_points()
|
| 867 |
+
|
| 868 |
+
half = None
|
| 869 |
+
if phase_unwrap:
|
| 870 |
+
if(phase_unit == 'rad'):
|
| 871 |
+
half = pi
|
| 872 |
+
elif(phase_unit == 'deg'):
|
| 873 |
+
half = 180
|
| 874 |
+
if half:
|
| 875 |
+
unit = 2*half
|
| 876 |
+
for i in range(1, len(y)):
|
| 877 |
+
diff = y[i] - y[i - 1]
|
| 878 |
+
if diff > half: # Jump from -half to half
|
| 879 |
+
y[i] = (y[i] - unit)
|
| 880 |
+
elif diff < -half: # Jump from half to -half
|
| 881 |
+
y[i] = (y[i] + unit)
|
| 882 |
+
|
| 883 |
+
return x, y
|
| 884 |
+
|
| 885 |
+
|
| 886 |
+
def bode_phase_plot(system, initial_exp=-5, final_exp=5,
|
| 887 |
+
color='b', show_axes=False, grid=True, show=True, freq_unit='rad/sec', phase_unit='rad', phase_unwrap=True, **kwargs):
|
| 888 |
+
r"""
|
| 889 |
+
Returns the Bode phase plot of a continuous-time system.
|
| 890 |
+
|
| 891 |
+
See ``bode_plot`` for all the parameters.
|
| 892 |
+
"""
|
| 893 |
+
x, y = bode_phase_numerical_data(system, initial_exp=initial_exp,
|
| 894 |
+
final_exp=final_exp, freq_unit=freq_unit, phase_unit=phase_unit, phase_unwrap=phase_unwrap)
|
| 895 |
+
plt.plot(x, y, color=color, **kwargs)
|
| 896 |
+
plt.xscale('log')
|
| 897 |
+
|
| 898 |
+
plt.xlabel('Frequency (%s) [Log Scale]' % freq_unit)
|
| 899 |
+
plt.ylabel('Phase (%s)' % phase_unit)
|
| 900 |
+
plt.title(f'Bode Plot (Phase) of ${latex(system)}$', pad=20)
|
| 901 |
+
|
| 902 |
+
if grid:
|
| 903 |
+
plt.grid(True)
|
| 904 |
+
if show_axes:
|
| 905 |
+
plt.axhline(0, color='black')
|
| 906 |
+
plt.axvline(0, color='black')
|
| 907 |
+
if show:
|
| 908 |
+
plt.show()
|
| 909 |
+
return
|
| 910 |
+
|
| 911 |
+
return plt
|
| 912 |
+
|
| 913 |
+
|
| 914 |
+
def bode_plot(system, initial_exp=-5, final_exp=5,
|
| 915 |
+
grid=True, show_axes=False, show=True, freq_unit='rad/sec', phase_unit='rad', phase_unwrap=True, **kwargs):
|
| 916 |
+
r"""
|
| 917 |
+
Returns the Bode phase and magnitude plots of a continuous-time system.
|
| 918 |
+
|
| 919 |
+
Parameters
|
| 920 |
+
==========
|
| 921 |
+
|
| 922 |
+
system : SISOLinearTimeInvariant type
|
| 923 |
+
The LTI SISO system for which the Bode Plot is to be computed.
|
| 924 |
+
initial_exp : Number, optional
|
| 925 |
+
The initial exponent of 10 of the semilog plot. Defaults to -5.
|
| 926 |
+
final_exp : Number, optional
|
| 927 |
+
The final exponent of 10 of the semilog plot. Defaults to 5.
|
| 928 |
+
show : boolean, optional
|
| 929 |
+
If ``True``, the plot will be displayed otherwise
|
| 930 |
+
the equivalent matplotlib ``plot`` object will be returned.
|
| 931 |
+
Defaults to True.
|
| 932 |
+
prec : int, optional
|
| 933 |
+
The decimal point precision for the point coordinate values.
|
| 934 |
+
Defaults to 8.
|
| 935 |
+
grid : boolean, optional
|
| 936 |
+
If ``True``, the plot will have a grid. Defaults to True.
|
| 937 |
+
show_axes : boolean, optional
|
| 938 |
+
If ``True``, the coordinate axes will be shown. Defaults to False.
|
| 939 |
+
freq_unit : string, optional
|
| 940 |
+
User can choose between ``'rad/sec'`` (radians/second) and ``'Hz'`` (Hertz) as frequency units.
|
| 941 |
+
phase_unit : string, optional
|
| 942 |
+
User can choose between ``'rad'`` (radians) and ``'deg'`` (degree) as phase units.
|
| 943 |
+
|
| 944 |
+
Examples
|
| 945 |
+
========
|
| 946 |
+
|
| 947 |
+
.. plot::
|
| 948 |
+
:context: close-figs
|
| 949 |
+
:format: doctest
|
| 950 |
+
:include-source: True
|
| 951 |
+
|
| 952 |
+
>>> from sympy.abc import s
|
| 953 |
+
>>> from sympy.physics.control.lti import TransferFunction
|
| 954 |
+
>>> from sympy.physics.control.control_plots import bode_plot
|
| 955 |
+
>>> tf1 = TransferFunction(1*s**2 + 0.1*s + 7.5, 1*s**4 + 0.12*s**3 + 9*s**2, s)
|
| 956 |
+
>>> bode_plot(tf1, initial_exp=0.2, final_exp=0.7) # doctest: +SKIP
|
| 957 |
+
|
| 958 |
+
See Also
|
| 959 |
+
========
|
| 960 |
+
|
| 961 |
+
bode_magnitude_plot, bode_phase_plot
|
| 962 |
+
|
| 963 |
+
"""
|
| 964 |
+
plt.subplot(211)
|
| 965 |
+
mag = bode_magnitude_plot(system, initial_exp=initial_exp, final_exp=final_exp,
|
| 966 |
+
show=False, grid=grid, show_axes=show_axes,
|
| 967 |
+
freq_unit=freq_unit, **kwargs)
|
| 968 |
+
mag.title(f'Bode Plot of ${latex(system)}$', pad=20)
|
| 969 |
+
mag.xlabel(None)
|
| 970 |
+
plt.subplot(212)
|
| 971 |
+
bode_phase_plot(system, initial_exp=initial_exp, final_exp=final_exp,
|
| 972 |
+
show=False, grid=grid, show_axes=show_axes, freq_unit=freq_unit, phase_unit=phase_unit, phase_unwrap=phase_unwrap, **kwargs).title(None)
|
| 973 |
+
|
| 974 |
+
if show:
|
| 975 |
+
plt.show()
|
| 976 |
+
return
|
| 977 |
+
|
| 978 |
+
return plt
|
parrot/lib/python3.10/site-packages/sympy/physics/control/lti.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/control/tests/__init__.py
ADDED
|
File without changes
|
parrot/lib/python3.10/site-packages/sympy/physics/control/tests/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (179 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/control/tests/__pycache__/test_control_plots.cpython-310.pyc
ADDED
|
Binary file (11.5 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/control/tests/test_control_plots.py
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from math import isclose
|
| 2 |
+
from sympy.core.numbers import I
|
| 3 |
+
from sympy.core.symbol import Dummy
|
| 4 |
+
from sympy.functions.elementary.complexes import (Abs, arg)
|
| 5 |
+
from sympy.functions.elementary.exponential import log
|
| 6 |
+
from sympy.abc import s, p, a
|
| 7 |
+
from sympy.external import import_module
|
| 8 |
+
from sympy.physics.control.control_plots import \
|
| 9 |
+
(pole_zero_numerical_data, pole_zero_plot, step_response_numerical_data,
|
| 10 |
+
step_response_plot, impulse_response_numerical_data,
|
| 11 |
+
impulse_response_plot, ramp_response_numerical_data,
|
| 12 |
+
ramp_response_plot, bode_magnitude_numerical_data,
|
| 13 |
+
bode_phase_numerical_data, bode_plot)
|
| 14 |
+
from sympy.physics.control.lti import (TransferFunction,
|
| 15 |
+
Series, Parallel, TransferFunctionMatrix)
|
| 16 |
+
from sympy.testing.pytest import raises, skip
|
| 17 |
+
|
| 18 |
+
matplotlib = import_module(
|
| 19 |
+
'matplotlib', import_kwargs={'fromlist': ['pyplot']},
|
| 20 |
+
catch=(RuntimeError,))
|
| 21 |
+
|
| 22 |
+
numpy = import_module('numpy')
|
| 23 |
+
|
| 24 |
+
tf1 = TransferFunction(1, p**2 + 0.5*p + 2, p)
|
| 25 |
+
tf2 = TransferFunction(p, 6*p**2 + 3*p + 1, p)
|
| 26 |
+
tf3 = TransferFunction(p, p**3 - 1, p)
|
| 27 |
+
tf4 = TransferFunction(10, p**3, p)
|
| 28 |
+
tf5 = TransferFunction(5, s**2 + 2*s + 10, s)
|
| 29 |
+
tf6 = TransferFunction(1, 1, s)
|
| 30 |
+
tf7 = TransferFunction(4*s*3 + 9*s**2 + 0.1*s + 11, 8*s**6 + 9*s**4 + 11, s)
|
| 31 |
+
tf8 = TransferFunction(5, s**2 + (2+I)*s + 10, s)
|
| 32 |
+
|
| 33 |
+
ser1 = Series(tf4, TransferFunction(1, p - 5, p))
|
| 34 |
+
ser2 = Series(tf3, TransferFunction(p, p + 2, p))
|
| 35 |
+
|
| 36 |
+
par1 = Parallel(tf1, tf2)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _to_tuple(a, b):
|
| 40 |
+
return tuple(a), tuple(b)
|
| 41 |
+
|
| 42 |
+
def _trim_tuple(a, b):
|
| 43 |
+
a, b = _to_tuple(a, b)
|
| 44 |
+
return tuple(a[0: 2] + a[len(a)//2 : len(a)//2 + 1] + a[-2:]), \
|
| 45 |
+
tuple(b[0: 2] + b[len(b)//2 : len(b)//2 + 1] + b[-2:])
|
| 46 |
+
|
| 47 |
+
def y_coordinate_equality(plot_data_func, evalf_func, system):
|
| 48 |
+
"""Checks whether the y-coordinate value of the plotted
|
| 49 |
+
data point is equal to the value of the function at a
|
| 50 |
+
particular x."""
|
| 51 |
+
x, y = plot_data_func(system)
|
| 52 |
+
x, y = _trim_tuple(x, y)
|
| 53 |
+
y_exp = tuple(evalf_func(system, x_i) for x_i in x)
|
| 54 |
+
return all(Abs(y_exp_i - y_i) < 1e-8 for y_exp_i, y_i in zip(y_exp, y))
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def test_errors():
|
| 58 |
+
if not matplotlib:
|
| 59 |
+
skip("Matplotlib not the default backend")
|
| 60 |
+
|
| 61 |
+
# Invalid `system` check
|
| 62 |
+
tfm = TransferFunctionMatrix([[tf6, tf5], [tf5, tf6]])
|
| 63 |
+
expr = 1/(s**2 - 1)
|
| 64 |
+
raises(NotImplementedError, lambda: pole_zero_plot(tfm))
|
| 65 |
+
raises(NotImplementedError, lambda: pole_zero_numerical_data(expr))
|
| 66 |
+
raises(NotImplementedError, lambda: impulse_response_plot(expr))
|
| 67 |
+
raises(NotImplementedError, lambda: impulse_response_numerical_data(tfm))
|
| 68 |
+
raises(NotImplementedError, lambda: step_response_plot(tfm))
|
| 69 |
+
raises(NotImplementedError, lambda: step_response_numerical_data(expr))
|
| 70 |
+
raises(NotImplementedError, lambda: ramp_response_plot(expr))
|
| 71 |
+
raises(NotImplementedError, lambda: ramp_response_numerical_data(tfm))
|
| 72 |
+
raises(NotImplementedError, lambda: bode_plot(tfm))
|
| 73 |
+
|
| 74 |
+
# More than 1 variables
|
| 75 |
+
tf_a = TransferFunction(a, s + 1, s)
|
| 76 |
+
raises(ValueError, lambda: pole_zero_plot(tf_a))
|
| 77 |
+
raises(ValueError, lambda: pole_zero_numerical_data(tf_a))
|
| 78 |
+
raises(ValueError, lambda: impulse_response_plot(tf_a))
|
| 79 |
+
raises(ValueError, lambda: impulse_response_numerical_data(tf_a))
|
| 80 |
+
raises(ValueError, lambda: step_response_plot(tf_a))
|
| 81 |
+
raises(ValueError, lambda: step_response_numerical_data(tf_a))
|
| 82 |
+
raises(ValueError, lambda: ramp_response_plot(tf_a))
|
| 83 |
+
raises(ValueError, lambda: ramp_response_numerical_data(tf_a))
|
| 84 |
+
raises(ValueError, lambda: bode_plot(tf_a))
|
| 85 |
+
|
| 86 |
+
# lower_limit > 0 for response plots
|
| 87 |
+
raises(ValueError, lambda: impulse_response_plot(tf1, lower_limit=-1))
|
| 88 |
+
raises(ValueError, lambda: step_response_plot(tf1, lower_limit=-0.1))
|
| 89 |
+
raises(ValueError, lambda: ramp_response_plot(tf1, lower_limit=-4/3))
|
| 90 |
+
|
| 91 |
+
# slope in ramp_response_plot() is negative
|
| 92 |
+
raises(ValueError, lambda: ramp_response_plot(tf1, slope=-0.1))
|
| 93 |
+
|
| 94 |
+
# incorrect frequency or phase unit
|
| 95 |
+
raises(ValueError, lambda: bode_plot(tf1,freq_unit = 'hz'))
|
| 96 |
+
raises(ValueError, lambda: bode_plot(tf1,phase_unit = 'degree'))
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def test_pole_zero():
|
| 100 |
+
if not numpy:
|
| 101 |
+
skip("NumPy is required for this test")
|
| 102 |
+
|
| 103 |
+
def pz_tester(sys, expected_value):
|
| 104 |
+
z, p = pole_zero_numerical_data(sys)
|
| 105 |
+
z_check = numpy.allclose(z, expected_value[0])
|
| 106 |
+
p_check = numpy.allclose(p, expected_value[1])
|
| 107 |
+
return p_check and z_check
|
| 108 |
+
|
| 109 |
+
exp1 = [[], [-0.24999999999999994+1.3919410907075054j, -0.24999999999999994-1.3919410907075054j]]
|
| 110 |
+
exp2 = [[0.0], [-0.25+0.3227486121839514j, -0.25-0.3227486121839514j]]
|
| 111 |
+
exp3 = [[0.0], [-0.5000000000000004+0.8660254037844395j,
|
| 112 |
+
-0.5000000000000004-0.8660254037844395j, 0.9999999999999998+0j]]
|
| 113 |
+
exp4 = [[], [5.0, 0.0, 0.0, 0.0]]
|
| 114 |
+
exp5 = [[-5.645751311064592, -0.5000000000000008, -0.3542486889354093],
|
| 115 |
+
[-0.24999999999999986+1.3919410907075052j,
|
| 116 |
+
-0.24999999999999986-1.3919410907075052j, -0.2499999999999998+0.32274861218395134j,
|
| 117 |
+
-0.2499999999999998-0.32274861218395134j]]
|
| 118 |
+
exp6 = [[], [-1.1641600331447917-3.545808351896439j,
|
| 119 |
+
-0.8358399668552097+2.5458083518964383j]]
|
| 120 |
+
|
| 121 |
+
assert pz_tester(tf1, exp1)
|
| 122 |
+
assert pz_tester(tf2, exp2)
|
| 123 |
+
assert pz_tester(tf3, exp3)
|
| 124 |
+
assert pz_tester(ser1, exp4)
|
| 125 |
+
assert pz_tester(par1, exp5)
|
| 126 |
+
assert pz_tester(tf8, exp6)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def test_bode():
|
| 130 |
+
if not numpy:
|
| 131 |
+
skip("NumPy is required for this test")
|
| 132 |
+
|
| 133 |
+
def bode_phase_evalf(system, point):
|
| 134 |
+
expr = system.to_expr()
|
| 135 |
+
_w = Dummy("w", real=True)
|
| 136 |
+
w_expr = expr.subs({system.var: I*_w})
|
| 137 |
+
return arg(w_expr).subs({_w: point}).evalf()
|
| 138 |
+
|
| 139 |
+
def bode_mag_evalf(system, point):
|
| 140 |
+
expr = system.to_expr()
|
| 141 |
+
_w = Dummy("w", real=True)
|
| 142 |
+
w_expr = expr.subs({system.var: I*_w})
|
| 143 |
+
return 20*log(Abs(w_expr), 10).subs({_w: point}).evalf()
|
| 144 |
+
|
| 145 |
+
def test_bode_data(sys):
|
| 146 |
+
return y_coordinate_equality(bode_magnitude_numerical_data, bode_mag_evalf, sys) \
|
| 147 |
+
and y_coordinate_equality(bode_phase_numerical_data, bode_phase_evalf, sys)
|
| 148 |
+
|
| 149 |
+
assert test_bode_data(tf1)
|
| 150 |
+
assert test_bode_data(tf2)
|
| 151 |
+
assert test_bode_data(tf3)
|
| 152 |
+
assert test_bode_data(tf4)
|
| 153 |
+
assert test_bode_data(tf5)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def check_point_accuracy(a, b):
|
| 157 |
+
return all(isclose(*_, rel_tol=1e-1, abs_tol=1e-6
|
| 158 |
+
) for _ in zip(a, b))
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def test_impulse_response():
|
| 162 |
+
if not numpy:
|
| 163 |
+
skip("NumPy is required for this test")
|
| 164 |
+
|
| 165 |
+
def impulse_res_tester(sys, expected_value):
|
| 166 |
+
x, y = _to_tuple(*impulse_response_numerical_data(sys,
|
| 167 |
+
adaptive=False, n=10))
|
| 168 |
+
x_check = check_point_accuracy(x, expected_value[0])
|
| 169 |
+
y_check = check_point_accuracy(y, expected_value[1])
|
| 170 |
+
return x_check and y_check
|
| 171 |
+
|
| 172 |
+
exp1 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 173 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 174 |
+
(0.0, 0.544019738507865, 0.01993849743234938, -0.31140243360893216, -0.022852779906491996, 0.1778306498155759,
|
| 175 |
+
0.01962941084328499, -0.1013115194573652, -0.014975541213105696, 0.0575789724730714))
|
| 176 |
+
exp2 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 177 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (0.1666666675, 0.08389223412935855,
|
| 178 |
+
0.02338051973475047, -0.014966807776379383, -0.034645954223054234, -0.040560075735512804,
|
| 179 |
+
-0.037658628907103885, -0.030149507719590022, -0.021162090730736834, -0.012721292737437523))
|
| 180 |
+
exp3 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 181 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (4.369893391586999e-09, 1.1750333000630964,
|
| 182 |
+
3.2922404058312473, 9.432290008148343, 28.37098083007151, 86.18577464367974, 261.90356653762115,
|
| 183 |
+
795.6538758627842, 2416.9920942096983, 7342.159505206647))
|
| 184 |
+
exp4 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 185 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (0.0, 6.17283950617284, 24.69135802469136,
|
| 186 |
+
55.555555555555564, 98.76543209876544, 154.320987654321, 222.22222222222226, 302.46913580246917,
|
| 187 |
+
395.0617283950618, 500.0))
|
| 188 |
+
exp5 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 189 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (0.0, -0.10455606138085417,
|
| 190 |
+
0.06757671513476461, -0.03234567568833768, 0.013582514927757873, -0.005273419510705473,
|
| 191 |
+
0.0019364083003354075, -0.000680070134067832, 0.00022969845960406913, -7.476094359583917e-05))
|
| 192 |
+
exp6 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 193 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 194 |
+
(-6.016699583000218e-09, 0.35039802056107394, 3.3728423827689884, 12.119846079276684,
|
| 195 |
+
25.86101014293389, 29.352480635282088, -30.49475907497664, -273.8717189554019, -863.2381702029659,
|
| 196 |
+
-1747.0262164682233))
|
| 197 |
+
exp7 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335,
|
| 198 |
+
4.444444444444445, 5.555555555555555, 6.666666666666667, 7.777777777777779,
|
| 199 |
+
8.88888888888889, 10.0), (0.0, 18.934638095560974, 5346.93244680907, 1384609.8718249386,
|
| 200 |
+
358161126.65801865, 92645770015.70108, 23964739753087.42, 6198974342083139.0, 1.603492601616059e+18,
|
| 201 |
+
4.147764422869658e+20))
|
| 202 |
+
|
| 203 |
+
assert impulse_res_tester(tf1, exp1)
|
| 204 |
+
assert impulse_res_tester(tf2, exp2)
|
| 205 |
+
assert impulse_res_tester(tf3, exp3)
|
| 206 |
+
assert impulse_res_tester(tf4, exp4)
|
| 207 |
+
assert impulse_res_tester(tf5, exp5)
|
| 208 |
+
assert impulse_res_tester(tf7, exp6)
|
| 209 |
+
assert impulse_res_tester(ser1, exp7)
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def test_step_response():
|
| 213 |
+
if not numpy:
|
| 214 |
+
skip("NumPy is required for this test")
|
| 215 |
+
|
| 216 |
+
def step_res_tester(sys, expected_value):
|
| 217 |
+
x, y = _to_tuple(*step_response_numerical_data(sys,
|
| 218 |
+
adaptive=False, n=10))
|
| 219 |
+
x_check = check_point_accuracy(x, expected_value[0])
|
| 220 |
+
y_check = check_point_accuracy(y, expected_value[1])
|
| 221 |
+
return x_check and y_check
|
| 222 |
+
|
| 223 |
+
exp1 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 224 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 225 |
+
(-1.9193285738516863e-08, 0.42283495488246126, 0.7840485977945262, 0.5546841805655717,
|
| 226 |
+
0.33903033806932087, 0.4627251747410237, 0.5909907598988051, 0.5247213989553071,
|
| 227 |
+
0.4486997874319281, 0.4839358435839171))
|
| 228 |
+
exp2 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 229 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 230 |
+
(0.0, 0.13728409095645816, 0.19474559355325086, 0.1974909129243011, 0.16841657696573073,
|
| 231 |
+
0.12559777736159378, 0.08153828016664713, 0.04360471317348958, 0.015072994568868221,
|
| 232 |
+
-0.003636420058445484))
|
| 233 |
+
exp3 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 234 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 235 |
+
(0.0, 0.6314542141914303, 2.9356520038101035, 9.37731009663807, 28.452300356688376,
|
| 236 |
+
86.25721933273988, 261.9236645044672, 795.6435410577224, 2416.9786984578764, 7342.154119725917))
|
| 237 |
+
exp4 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 238 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 239 |
+
(0.0, 2.286236899862826, 18.28989519890261, 61.72839629629631, 146.31916159122088, 285.7796124828532,
|
| 240 |
+
493.8271703703705, 784.1792566529494, 1170.553292729767, 1666.6667))
|
| 241 |
+
exp5 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 242 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 243 |
+
(-3.999999997894577e-09, 0.6720357068882895, 0.4429938256137113, 0.5182010838004518,
|
| 244 |
+
0.4944139147159695, 0.5016379853883338, 0.4995466896527733, 0.5001154784851325,
|
| 245 |
+
0.49997448824584123, 0.5000039745919259))
|
| 246 |
+
exp6 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 247 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 248 |
+
(-1.5433688493882158e-09, 0.3428705539937336, 1.1253619102202777, 3.1849962651016517,
|
| 249 |
+
9.47532757182671, 28.727231099148135, 87.29426924860557, 265.2138681048606, 805.6636260007757,
|
| 250 |
+
2447.387582370878))
|
| 251 |
+
|
| 252 |
+
assert step_res_tester(tf1, exp1)
|
| 253 |
+
assert step_res_tester(tf2, exp2)
|
| 254 |
+
assert step_res_tester(tf3, exp3)
|
| 255 |
+
assert step_res_tester(tf4, exp4)
|
| 256 |
+
assert step_res_tester(tf5, exp5)
|
| 257 |
+
assert step_res_tester(ser2, exp6)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def test_ramp_response():
|
| 261 |
+
if not numpy:
|
| 262 |
+
skip("NumPy is required for this test")
|
| 263 |
+
|
| 264 |
+
def ramp_res_tester(sys, num_points, expected_value, slope=1):
|
| 265 |
+
x, y = _to_tuple(*ramp_response_numerical_data(sys,
|
| 266 |
+
slope=slope, adaptive=False, n=num_points))
|
| 267 |
+
x_check = check_point_accuracy(x, expected_value[0])
|
| 268 |
+
y_check = check_point_accuracy(y, expected_value[1])
|
| 269 |
+
return x_check and y_check
|
| 270 |
+
|
| 271 |
+
exp1 = ((0.0, 2.0, 4.0, 6.0, 8.0, 10.0), (0.0, 0.7324667795033895, 1.9909720978650398,
|
| 272 |
+
2.7956587704217783, 3.9224897567931514, 4.85022655284895))
|
| 273 |
+
exp2 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445,
|
| 274 |
+
5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0),
|
| 275 |
+
(2.4360213402019326e-08, 0.10175320182493253, 0.33057612497658406, 0.5967937263298935,
|
| 276 |
+
0.8431511866718248, 1.0398805391471613, 1.1776043125035738, 1.2600994825747305, 1.2981042689274653,
|
| 277 |
+
1.304684417610106))
|
| 278 |
+
exp3 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 279 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (-3.9329040468771836e-08,
|
| 280 |
+
0.34686634635794555, 2.9998828170537903, 12.33303690737476, 40.993913948137795, 127.84145222317912,
|
| 281 |
+
391.41713691996, 1192.0006858708389, 3623.9808672503405, 11011.728034546572))
|
| 282 |
+
exp4 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 283 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (0.0, 1.9051973784484078, 30.483158055174524,
|
| 284 |
+
154.32098765432104, 487.7305288827924, 1190.7483615302544, 2469.1358024691367, 4574.3789056546275,
|
| 285 |
+
7803.688462124678, 12500.0))
|
| 286 |
+
exp5 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 287 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (0.0, 3.8844361856975635, 9.141792069209865,
|
| 288 |
+
14.096349157657231, 19.09783068994694, 24.10179770390321, 29.09907319114121, 34.10040420185154,
|
| 289 |
+
39.09983919254265, 44.10006013058409))
|
| 290 |
+
exp6 = ((0.0, 1.1111111111111112, 2.2222222222222223, 3.3333333333333335, 4.444444444444445, 5.555555555555555,
|
| 291 |
+
6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0), (0.0, 1.1111111111111112, 2.2222222222222223,
|
| 292 |
+
3.3333333333333335, 4.444444444444445, 5.555555555555555, 6.666666666666667, 7.777777777777779, 8.88888888888889, 10.0))
|
| 293 |
+
|
| 294 |
+
assert ramp_res_tester(tf1, 6, exp1)
|
| 295 |
+
assert ramp_res_tester(tf2, 10, exp2, 1.2)
|
| 296 |
+
assert ramp_res_tester(tf3, 10, exp3, 1.5)
|
| 297 |
+
assert ramp_res_tester(tf4, 10, exp4, 3)
|
| 298 |
+
assert ramp_res_tester(tf5, 10, exp5, 9)
|
| 299 |
+
assert ramp_res_tester(tf6, 10, exp6)
|
parrot/lib/python3.10/site-packages/sympy/physics/control/tests/test_lti.py
ADDED
|
@@ -0,0 +1,1750 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core.add import Add
|
| 2 |
+
from sympy.core.function import Function
|
| 3 |
+
from sympy.core.mul import Mul
|
| 4 |
+
from sympy.core.numbers import (I, pi, Rational, oo)
|
| 5 |
+
from sympy.core.power import Pow
|
| 6 |
+
from sympy.core.singleton import S
|
| 7 |
+
from sympy.core.symbol import symbols
|
| 8 |
+
from sympy.functions.elementary.exponential import (exp, log)
|
| 9 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
| 10 |
+
from sympy.functions.elementary.trigonometric import atan
|
| 11 |
+
from sympy.matrices.dense import eye
|
| 12 |
+
from sympy.polys.polytools import factor
|
| 13 |
+
from sympy.polys.rootoftools import CRootOf
|
| 14 |
+
from sympy.simplify.simplify import simplify
|
| 15 |
+
from sympy.core.containers import Tuple
|
| 16 |
+
from sympy.matrices import ImmutableMatrix, Matrix, ShapeError
|
| 17 |
+
from sympy.physics.control import (TransferFunction, Series, Parallel,
|
| 18 |
+
Feedback, TransferFunctionMatrix, MIMOSeries, MIMOParallel, MIMOFeedback,
|
| 19 |
+
StateSpace, gbt, bilinear, forward_diff, backward_diff, phase_margin, gain_margin)
|
| 20 |
+
from sympy.testing.pytest import raises
|
| 21 |
+
|
| 22 |
+
a, x, b, c, s, g, d, p, k, tau, zeta, wn, T = symbols('a, x, b, c, s, g, d, p, k,\
|
| 23 |
+
tau, zeta, wn, T')
|
| 24 |
+
a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3, d0, d1, d2, d3 = symbols('a0:4,\
|
| 25 |
+
b0:4, c0:4, d0:4')
|
| 26 |
+
TF1 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 27 |
+
TF2 = TransferFunction(k, 1, s)
|
| 28 |
+
TF3 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_TransferFunction_construction():
|
| 32 |
+
tf = TransferFunction(s + 1, s**2 + s + 1, s)
|
| 33 |
+
assert tf.num == (s + 1)
|
| 34 |
+
assert tf.den == (s**2 + s + 1)
|
| 35 |
+
assert tf.args == (s + 1, s**2 + s + 1, s)
|
| 36 |
+
|
| 37 |
+
tf1 = TransferFunction(s + 4, s - 5, s)
|
| 38 |
+
assert tf1.num == (s + 4)
|
| 39 |
+
assert tf1.den == (s - 5)
|
| 40 |
+
assert tf1.args == (s + 4, s - 5, s)
|
| 41 |
+
|
| 42 |
+
# using different polynomial variables.
|
| 43 |
+
tf2 = TransferFunction(p + 3, p**2 - 9, p)
|
| 44 |
+
assert tf2.num == (p + 3)
|
| 45 |
+
assert tf2.den == (p**2 - 9)
|
| 46 |
+
assert tf2.args == (p + 3, p**2 - 9, p)
|
| 47 |
+
|
| 48 |
+
tf3 = TransferFunction(p**3 + 5*p**2 + 4, p**4 + 3*p + 1, p)
|
| 49 |
+
assert tf3.args == (p**3 + 5*p**2 + 4, p**4 + 3*p + 1, p)
|
| 50 |
+
|
| 51 |
+
# no pole-zero cancellation on its own.
|
| 52 |
+
tf4 = TransferFunction((s + 3)*(s - 1), (s - 1)*(s + 5), s)
|
| 53 |
+
assert tf4.den == (s - 1)*(s + 5)
|
| 54 |
+
assert tf4.args == ((s + 3)*(s - 1), (s - 1)*(s + 5), s)
|
| 55 |
+
|
| 56 |
+
tf4_ = TransferFunction(p + 2, p + 2, p)
|
| 57 |
+
assert tf4_.args == (p + 2, p + 2, p)
|
| 58 |
+
|
| 59 |
+
tf5 = TransferFunction(s - 1, 4 - p, s)
|
| 60 |
+
assert tf5.args == (s - 1, 4 - p, s)
|
| 61 |
+
|
| 62 |
+
tf5_ = TransferFunction(s - 1, s - 1, s)
|
| 63 |
+
assert tf5_.args == (s - 1, s - 1, s)
|
| 64 |
+
|
| 65 |
+
tf6 = TransferFunction(5, 6, s)
|
| 66 |
+
assert tf6.num == 5
|
| 67 |
+
assert tf6.den == 6
|
| 68 |
+
assert tf6.args == (5, 6, s)
|
| 69 |
+
|
| 70 |
+
tf6_ = TransferFunction(1/2, 4, s)
|
| 71 |
+
assert tf6_.num == 0.5
|
| 72 |
+
assert tf6_.den == 4
|
| 73 |
+
assert tf6_.args == (0.500000000000000, 4, s)
|
| 74 |
+
|
| 75 |
+
tf7 = TransferFunction(3*s**2 + 2*p + 4*s, 8*p**2 + 7*s, s)
|
| 76 |
+
tf8 = TransferFunction(3*s**2 + 2*p + 4*s, 8*p**2 + 7*s, p)
|
| 77 |
+
assert not tf7 == tf8
|
| 78 |
+
|
| 79 |
+
tf7_ = TransferFunction(a0*s + a1*s**2 + a2*s**3, b0*p - b1*s, s)
|
| 80 |
+
tf8_ = TransferFunction(a0*s + a1*s**2 + a2*s**3, b0*p - b1*s, s)
|
| 81 |
+
assert tf7_ == tf8_
|
| 82 |
+
assert -(-tf7_) == tf7_ == -(-(-(-tf7_)))
|
| 83 |
+
|
| 84 |
+
tf9 = TransferFunction(a*s**3 + b*s**2 + g*s + d, d*p + g*p**2 + g*s, s)
|
| 85 |
+
assert tf9.args == (a*s**3 + b*s**2 + d + g*s, d*p + g*p**2 + g*s, s)
|
| 86 |
+
|
| 87 |
+
tf10 = TransferFunction(p**3 + d, g*s**2 + d*s + a, p)
|
| 88 |
+
tf10_ = TransferFunction(p**3 + d, g*s**2 + d*s + a, p)
|
| 89 |
+
assert tf10.args == (d + p**3, a + d*s + g*s**2, p)
|
| 90 |
+
assert tf10_ == tf10
|
| 91 |
+
|
| 92 |
+
tf11 = TransferFunction(a1*s + a0, b2*s**2 + b1*s + b0, s)
|
| 93 |
+
assert tf11.num == (a0 + a1*s)
|
| 94 |
+
assert tf11.den == (b0 + b1*s + b2*s**2)
|
| 95 |
+
assert tf11.args == (a0 + a1*s, b0 + b1*s + b2*s**2, s)
|
| 96 |
+
|
| 97 |
+
# when just the numerator is 0, leave the denominator alone.
|
| 98 |
+
tf12 = TransferFunction(0, p**2 - p + 1, p)
|
| 99 |
+
assert tf12.args == (0, p**2 - p + 1, p)
|
| 100 |
+
|
| 101 |
+
tf13 = TransferFunction(0, 1, s)
|
| 102 |
+
assert tf13.args == (0, 1, s)
|
| 103 |
+
|
| 104 |
+
# float exponents
|
| 105 |
+
tf14 = TransferFunction(a0*s**0.5 + a2*s**0.6 - a1, a1*p**(-8.7), s)
|
| 106 |
+
assert tf14.args == (a0*s**0.5 - a1 + a2*s**0.6, a1*p**(-8.7), s)
|
| 107 |
+
|
| 108 |
+
tf15 = TransferFunction(a2**2*p**(1/4) + a1*s**(-4/5), a0*s - p, p)
|
| 109 |
+
assert tf15.args == (a1*s**(-0.8) + a2**2*p**0.25, a0*s - p, p)
|
| 110 |
+
|
| 111 |
+
omega_o, k_p, k_o, k_i = symbols('omega_o, k_p, k_o, k_i')
|
| 112 |
+
tf18 = TransferFunction((k_p + k_o*s + k_i/s), s**2 + 2*omega_o*s + omega_o**2, s)
|
| 113 |
+
assert tf18.num == k_i/s + k_o*s + k_p
|
| 114 |
+
assert tf18.args == (k_i/s + k_o*s + k_p, omega_o**2 + 2*omega_o*s + s**2, s)
|
| 115 |
+
|
| 116 |
+
# ValueError when denominator is zero.
|
| 117 |
+
raises(ValueError, lambda: TransferFunction(4, 0, s))
|
| 118 |
+
raises(ValueError, lambda: TransferFunction(s, 0, s))
|
| 119 |
+
raises(ValueError, lambda: TransferFunction(0, 0, s))
|
| 120 |
+
|
| 121 |
+
raises(TypeError, lambda: TransferFunction(Matrix([1, 2, 3]), s, s))
|
| 122 |
+
|
| 123 |
+
raises(TypeError, lambda: TransferFunction(s**2 + 2*s - 1, s + 3, 3))
|
| 124 |
+
raises(TypeError, lambda: TransferFunction(p + 1, 5 - p, 4))
|
| 125 |
+
raises(TypeError, lambda: TransferFunction(3, 4, 8))
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def test_TransferFunction_functions():
|
| 129 |
+
# classmethod from_rational_expression
|
| 130 |
+
expr_1 = Mul(0, Pow(s, -1, evaluate=False), evaluate=False)
|
| 131 |
+
expr_2 = s/0
|
| 132 |
+
expr_3 = (p*s**2 + 5*s)/(s + 1)**3
|
| 133 |
+
expr_4 = 6
|
| 134 |
+
expr_5 = ((2 + 3*s)*(5 + 2*s))/((9 + 3*s)*(5 + 2*s**2))
|
| 135 |
+
expr_6 = (9*s**4 + 4*s**2 + 8)/((s + 1)*(s + 9))
|
| 136 |
+
tf = TransferFunction(s + 1, s**2 + 2, s)
|
| 137 |
+
delay = exp(-s/tau)
|
| 138 |
+
expr_7 = delay*tf.to_expr()
|
| 139 |
+
H1 = TransferFunction.from_rational_expression(expr_7, s)
|
| 140 |
+
H2 = TransferFunction(s + 1, (s**2 + 2)*exp(s/tau), s)
|
| 141 |
+
expr_8 = Add(2, 3*s/(s**2 + 1), evaluate=False)
|
| 142 |
+
|
| 143 |
+
assert TransferFunction.from_rational_expression(expr_1) == TransferFunction(0, s, s)
|
| 144 |
+
raises(ZeroDivisionError, lambda: TransferFunction.from_rational_expression(expr_2))
|
| 145 |
+
raises(ValueError, lambda: TransferFunction.from_rational_expression(expr_3))
|
| 146 |
+
assert TransferFunction.from_rational_expression(expr_3, s) == TransferFunction((p*s**2 + 5*s), (s + 1)**3, s)
|
| 147 |
+
assert TransferFunction.from_rational_expression(expr_3, p) == TransferFunction((p*s**2 + 5*s), (s + 1)**3, p)
|
| 148 |
+
raises(ValueError, lambda: TransferFunction.from_rational_expression(expr_4))
|
| 149 |
+
assert TransferFunction.from_rational_expression(expr_4, s) == TransferFunction(6, 1, s)
|
| 150 |
+
assert TransferFunction.from_rational_expression(expr_5, s) == \
|
| 151 |
+
TransferFunction((2 + 3*s)*(5 + 2*s), (9 + 3*s)*(5 + 2*s**2), s)
|
| 152 |
+
assert TransferFunction.from_rational_expression(expr_6, s) == \
|
| 153 |
+
TransferFunction((9*s**4 + 4*s**2 + 8), (s + 1)*(s + 9), s)
|
| 154 |
+
assert H1 == H2
|
| 155 |
+
assert TransferFunction.from_rational_expression(expr_8, s) == \
|
| 156 |
+
TransferFunction(2*s**2 + 3*s + 2, s**2 + 1, s)
|
| 157 |
+
|
| 158 |
+
# classmethod from_coeff_lists
|
| 159 |
+
tf1 = TransferFunction.from_coeff_lists([1, 2], [3, 4, 5], s)
|
| 160 |
+
num2 = [p**2, 2*p]
|
| 161 |
+
den2 = [p**3, p + 1, 4]
|
| 162 |
+
tf2 = TransferFunction.from_coeff_lists(num2, den2, s)
|
| 163 |
+
num3 = [1, 2, 3]
|
| 164 |
+
den3 = [0, 0]
|
| 165 |
+
|
| 166 |
+
assert tf1 == TransferFunction(s + 2, 3*s**2 + 4*s + 5, s)
|
| 167 |
+
assert tf2 == TransferFunction(p**2*s + 2*p, p**3*s**2 + s*(p + 1) + 4, s)
|
| 168 |
+
raises(ZeroDivisionError, lambda: TransferFunction.from_coeff_lists(num3, den3, s))
|
| 169 |
+
|
| 170 |
+
# classmethod from_zpk
|
| 171 |
+
zeros = [4]
|
| 172 |
+
poles = [-1+2j, -1-2j]
|
| 173 |
+
gain = 3
|
| 174 |
+
tf1 = TransferFunction.from_zpk(zeros, poles, gain, s)
|
| 175 |
+
|
| 176 |
+
assert tf1 == TransferFunction(3*s - 12, (s + 1.0 - 2.0*I)*(s + 1.0 + 2.0*I), s)
|
| 177 |
+
|
| 178 |
+
# explicitly cancel poles and zeros.
|
| 179 |
+
tf0 = TransferFunction(s**5 + s**3 + s, s - s**2, s)
|
| 180 |
+
a = TransferFunction(-(s**4 + s**2 + 1), s - 1, s)
|
| 181 |
+
assert tf0.simplify() == simplify(tf0) == a
|
| 182 |
+
|
| 183 |
+
tf1 = TransferFunction((p + 3)*(p - 1), (p - 1)*(p + 5), p)
|
| 184 |
+
b = TransferFunction(p + 3, p + 5, p)
|
| 185 |
+
assert tf1.simplify() == simplify(tf1) == b
|
| 186 |
+
|
| 187 |
+
# expand the numerator and the denominator.
|
| 188 |
+
G1 = TransferFunction((1 - s)**2, (s**2 + 1)**2, s)
|
| 189 |
+
G2 = TransferFunction(1, -3, p)
|
| 190 |
+
c = (a2*s**p + a1*s**s + a0*p**p)*(p**s + s**p)
|
| 191 |
+
d = (b0*s**s + b1*p**s)*(b2*s*p + p**p)
|
| 192 |
+
e = a0*p**p*p**s + a0*p**p*s**p + a1*p**s*s**s + a1*s**p*s**s + a2*p**s*s**p + a2*s**(2*p)
|
| 193 |
+
f = b0*b2*p*s*s**s + b0*p**p*s**s + b1*b2*p*p**s*s + b1*p**p*p**s
|
| 194 |
+
g = a1*a2*s*s**p + a1*p*s + a2*b1*p*s*s**p + b1*p**2*s
|
| 195 |
+
G3 = TransferFunction(c, d, s)
|
| 196 |
+
G4 = TransferFunction(a0*s**s - b0*p**p, (a1*s + b1*s*p)*(a2*s**p + p), p)
|
| 197 |
+
|
| 198 |
+
assert G1.expand() == TransferFunction(s**2 - 2*s + 1, s**4 + 2*s**2 + 1, s)
|
| 199 |
+
assert tf1.expand() == TransferFunction(p**2 + 2*p - 3, p**2 + 4*p - 5, p)
|
| 200 |
+
assert G2.expand() == G2
|
| 201 |
+
assert G3.expand() == TransferFunction(e, f, s)
|
| 202 |
+
assert G4.expand() == TransferFunction(a0*s**s - b0*p**p, g, p)
|
| 203 |
+
|
| 204 |
+
# purely symbolic polynomials.
|
| 205 |
+
p1 = a1*s + a0
|
| 206 |
+
p2 = b2*s**2 + b1*s + b0
|
| 207 |
+
SP1 = TransferFunction(p1, p2, s)
|
| 208 |
+
expect1 = TransferFunction(2.0*s + 1.0, 5.0*s**2 + 4.0*s + 3.0, s)
|
| 209 |
+
expect1_ = TransferFunction(2*s + 1, 5*s**2 + 4*s + 3, s)
|
| 210 |
+
assert SP1.subs({a0: 1, a1: 2, b0: 3, b1: 4, b2: 5}) == expect1_
|
| 211 |
+
assert SP1.subs({a0: 1, a1: 2, b0: 3, b1: 4, b2: 5}).evalf() == expect1
|
| 212 |
+
assert expect1_.evalf() == expect1
|
| 213 |
+
|
| 214 |
+
c1, d0, d1, d2 = symbols('c1, d0:3')
|
| 215 |
+
p3, p4 = c1*p, d2*p**3 + d1*p**2 - d0
|
| 216 |
+
SP2 = TransferFunction(p3, p4, p)
|
| 217 |
+
expect2 = TransferFunction(2.0*p, 5.0*p**3 + 2.0*p**2 - 3.0, p)
|
| 218 |
+
expect2_ = TransferFunction(2*p, 5*p**3 + 2*p**2 - 3, p)
|
| 219 |
+
assert SP2.subs({c1: 2, d0: 3, d1: 2, d2: 5}) == expect2_
|
| 220 |
+
assert SP2.subs({c1: 2, d0: 3, d1: 2, d2: 5}).evalf() == expect2
|
| 221 |
+
assert expect2_.evalf() == expect2
|
| 222 |
+
|
| 223 |
+
SP3 = TransferFunction(a0*p**3 + a1*s**2 - b0*s + b1, a1*s + p, s)
|
| 224 |
+
expect3 = TransferFunction(2.0*p**3 + 4.0*s**2 - s + 5.0, p + 4.0*s, s)
|
| 225 |
+
expect3_ = TransferFunction(2*p**3 + 4*s**2 - s + 5, p + 4*s, s)
|
| 226 |
+
assert SP3.subs({a0: 2, a1: 4, b0: 1, b1: 5}) == expect3_
|
| 227 |
+
assert SP3.subs({a0: 2, a1: 4, b0: 1, b1: 5}).evalf() == expect3
|
| 228 |
+
assert expect3_.evalf() == expect3
|
| 229 |
+
|
| 230 |
+
SP4 = TransferFunction(s - a1*p**3, a0*s + p, p)
|
| 231 |
+
expect4 = TransferFunction(7.0*p**3 + s, p - s, p)
|
| 232 |
+
expect4_ = TransferFunction(7*p**3 + s, p - s, p)
|
| 233 |
+
assert SP4.subs({a0: -1, a1: -7}) == expect4_
|
| 234 |
+
assert SP4.subs({a0: -1, a1: -7}).evalf() == expect4
|
| 235 |
+
assert expect4_.evalf() == expect4
|
| 236 |
+
|
| 237 |
+
# evaluate the transfer function at particular frequencies.
|
| 238 |
+
assert tf1.eval_frequency(wn) == wn**2/(wn**2 + 4*wn - 5) + 2*wn/(wn**2 + 4*wn - 5) - 3/(wn**2 + 4*wn - 5)
|
| 239 |
+
assert G1.eval_frequency(1 + I) == S(3)/25 + S(4)*I/25
|
| 240 |
+
assert G4.eval_frequency(S(5)/3) == \
|
| 241 |
+
a0*s**s/(a1*a2*s**(S(8)/3) + S(5)*a1*s/3 + 5*a2*b1*s**(S(8)/3)/3 + S(25)*b1*s/9) - 5*3**(S(1)/3)*5**(S(2)/3)*b0/(9*a1*a2*s**(S(8)/3) + 15*a1*s + 15*a2*b1*s**(S(8)/3) + 25*b1*s)
|
| 242 |
+
|
| 243 |
+
# Low-frequency (or DC) gain.
|
| 244 |
+
assert tf0.dc_gain() == 1
|
| 245 |
+
assert tf1.dc_gain() == Rational(3, 5)
|
| 246 |
+
assert SP2.dc_gain() == 0
|
| 247 |
+
assert expect4.dc_gain() == -1
|
| 248 |
+
assert expect2_.dc_gain() == 0
|
| 249 |
+
assert TransferFunction(1, s, s).dc_gain() == oo
|
| 250 |
+
|
| 251 |
+
# Poles of a transfer function.
|
| 252 |
+
tf_ = TransferFunction(x**3 - k, k, x)
|
| 253 |
+
_tf = TransferFunction(k, x**4 - k, x)
|
| 254 |
+
TF_ = TransferFunction(x**2, x**10 + x + x**2, x)
|
| 255 |
+
_TF = TransferFunction(x**10 + x + x**2, x**2, x)
|
| 256 |
+
assert G1.poles() == [I, I, -I, -I]
|
| 257 |
+
assert G2.poles() == []
|
| 258 |
+
assert tf1.poles() == [-5, 1]
|
| 259 |
+
assert expect4_.poles() == [s]
|
| 260 |
+
assert SP4.poles() == [-a0*s]
|
| 261 |
+
assert expect3.poles() == [-0.25*p]
|
| 262 |
+
assert str(expect2.poles()) == str([0.729001428685125, -0.564500714342563 - 0.710198984796332*I, -0.564500714342563 + 0.710198984796332*I])
|
| 263 |
+
assert str(expect1.poles()) == str([-0.4 - 0.66332495807108*I, -0.4 + 0.66332495807108*I])
|
| 264 |
+
assert _tf.poles() == [k**(Rational(1, 4)), -k**(Rational(1, 4)), I*k**(Rational(1, 4)), -I*k**(Rational(1, 4))]
|
| 265 |
+
assert TF_.poles() == [CRootOf(x**9 + x + 1, 0), 0, CRootOf(x**9 + x + 1, 1), CRootOf(x**9 + x + 1, 2),
|
| 266 |
+
CRootOf(x**9 + x + 1, 3), CRootOf(x**9 + x + 1, 4), CRootOf(x**9 + x + 1, 5), CRootOf(x**9 + x + 1, 6),
|
| 267 |
+
CRootOf(x**9 + x + 1, 7), CRootOf(x**9 + x + 1, 8)]
|
| 268 |
+
raises(NotImplementedError, lambda: TransferFunction(x**2, a0*x**10 + x + x**2, x).poles())
|
| 269 |
+
|
| 270 |
+
# Stability of a transfer function.
|
| 271 |
+
q, r = symbols('q, r', negative=True)
|
| 272 |
+
t = symbols('t', positive=True)
|
| 273 |
+
TF_ = TransferFunction(s**2 + a0 - a1*p, q*s - r, s)
|
| 274 |
+
stable_tf = TransferFunction(s**2 + a0 - a1*p, q*s - 1, s)
|
| 275 |
+
stable_tf_ = TransferFunction(s**2 + a0 - a1*p, q*s - t, s)
|
| 276 |
+
|
| 277 |
+
assert G1.is_stable() is False
|
| 278 |
+
assert G2.is_stable() is True
|
| 279 |
+
assert tf1.is_stable() is False # as one pole is +ve, and the other is -ve.
|
| 280 |
+
assert expect2.is_stable() is False
|
| 281 |
+
assert expect1.is_stable() is True
|
| 282 |
+
assert stable_tf.is_stable() is True
|
| 283 |
+
assert stable_tf_.is_stable() is True
|
| 284 |
+
assert TF_.is_stable() is False
|
| 285 |
+
assert expect4_.is_stable() is None # no assumption provided for the only pole 's'.
|
| 286 |
+
assert SP4.is_stable() is None
|
| 287 |
+
|
| 288 |
+
# Zeros of a transfer function.
|
| 289 |
+
assert G1.zeros() == [1, 1]
|
| 290 |
+
assert G2.zeros() == []
|
| 291 |
+
assert tf1.zeros() == [-3, 1]
|
| 292 |
+
assert expect4_.zeros() == [7**(Rational(2, 3))*(-s)**(Rational(1, 3))/7, -7**(Rational(2, 3))*(-s)**(Rational(1, 3))/14 -
|
| 293 |
+
sqrt(3)*7**(Rational(2, 3))*I*(-s)**(Rational(1, 3))/14, -7**(Rational(2, 3))*(-s)**(Rational(1, 3))/14 + sqrt(3)*7**(Rational(2, 3))*I*(-s)**(Rational(1, 3))/14]
|
| 294 |
+
assert SP4.zeros() == [(s/a1)**(Rational(1, 3)), -(s/a1)**(Rational(1, 3))/2 - sqrt(3)*I*(s/a1)**(Rational(1, 3))/2,
|
| 295 |
+
-(s/a1)**(Rational(1, 3))/2 + sqrt(3)*I*(s/a1)**(Rational(1, 3))/2]
|
| 296 |
+
assert str(expect3.zeros()) == str([0.125 - 1.11102430216445*sqrt(-0.405063291139241*p**3 - 1.0),
|
| 297 |
+
1.11102430216445*sqrt(-0.405063291139241*p**3 - 1.0) + 0.125])
|
| 298 |
+
assert tf_.zeros() == [k**(Rational(1, 3)), -k**(Rational(1, 3))/2 - sqrt(3)*I*k**(Rational(1, 3))/2,
|
| 299 |
+
-k**(Rational(1, 3))/2 + sqrt(3)*I*k**(Rational(1, 3))/2]
|
| 300 |
+
assert _TF.zeros() == [CRootOf(x**9 + x + 1, 0), 0, CRootOf(x**9 + x + 1, 1), CRootOf(x**9 + x + 1, 2),
|
| 301 |
+
CRootOf(x**9 + x + 1, 3), CRootOf(x**9 + x + 1, 4), CRootOf(x**9 + x + 1, 5), CRootOf(x**9 + x + 1, 6),
|
| 302 |
+
CRootOf(x**9 + x + 1, 7), CRootOf(x**9 + x + 1, 8)]
|
| 303 |
+
raises(NotImplementedError, lambda: TransferFunction(a0*x**10 + x + x**2, x**2, x).zeros())
|
| 304 |
+
|
| 305 |
+
# negation of TF.
|
| 306 |
+
tf2 = TransferFunction(s + 3, s**2 - s**3 + 9, s)
|
| 307 |
+
tf3 = TransferFunction(-3*p + 3, 1 - p, p)
|
| 308 |
+
assert -tf2 == TransferFunction(-s - 3, s**2 - s**3 + 9, s)
|
| 309 |
+
assert -tf3 == TransferFunction(3*p - 3, 1 - p, p)
|
| 310 |
+
|
| 311 |
+
# taking power of a TF.
|
| 312 |
+
tf4 = TransferFunction(p + 4, p - 3, p)
|
| 313 |
+
tf5 = TransferFunction(s**2 + 1, 1 - s, s)
|
| 314 |
+
expect2 = TransferFunction((s**2 + 1)**3, (1 - s)**3, s)
|
| 315 |
+
expect1 = TransferFunction((p + 4)**2, (p - 3)**2, p)
|
| 316 |
+
assert (tf4*tf4).doit() == tf4**2 == pow(tf4, 2) == expect1
|
| 317 |
+
assert (tf5*tf5*tf5).doit() == tf5**3 == pow(tf5, 3) == expect2
|
| 318 |
+
assert tf5**0 == pow(tf5, 0) == TransferFunction(1, 1, s)
|
| 319 |
+
assert Series(tf4).doit()**-1 == tf4**-1 == pow(tf4, -1) == TransferFunction(p - 3, p + 4, p)
|
| 320 |
+
assert (tf5*tf5).doit()**-1 == tf5**-2 == pow(tf5, -2) == TransferFunction((1 - s)**2, (s**2 + 1)**2, s)
|
| 321 |
+
|
| 322 |
+
raises(ValueError, lambda: tf4**(s**2 + s - 1))
|
| 323 |
+
raises(ValueError, lambda: tf5**s)
|
| 324 |
+
raises(ValueError, lambda: tf4**tf5)
|
| 325 |
+
|
| 326 |
+
# SymPy's own functions.
|
| 327 |
+
tf = TransferFunction(s - 1, s**2 - 2*s + 1, s)
|
| 328 |
+
tf6 = TransferFunction(s + p, p**2 - 5, s)
|
| 329 |
+
assert factor(tf) == TransferFunction(s - 1, (s - 1)**2, s)
|
| 330 |
+
assert tf.num.subs(s, 2) == tf.den.subs(s, 2) == 1
|
| 331 |
+
# subs & xreplace
|
| 332 |
+
assert tf.subs(s, 2) == TransferFunction(s - 1, s**2 - 2*s + 1, s)
|
| 333 |
+
assert tf6.subs(p, 3) == TransferFunction(s + 3, 4, s)
|
| 334 |
+
assert tf3.xreplace({p: s}) == TransferFunction(-3*s + 3, 1 - s, s)
|
| 335 |
+
raises(TypeError, lambda: tf3.xreplace({p: exp(2)}))
|
| 336 |
+
assert tf3.subs(p, exp(2)) == tf3
|
| 337 |
+
|
| 338 |
+
tf7 = TransferFunction(a0*s**p + a1*p**s, a2*p - s, s)
|
| 339 |
+
assert tf7.xreplace({s: k}) == TransferFunction(a0*k**p + a1*p**k, a2*p - k, k)
|
| 340 |
+
assert tf7.subs(s, k) == TransferFunction(a0*s**p + a1*p**s, a2*p - s, s)
|
| 341 |
+
|
| 342 |
+
# Conversion to Expr with to_expr()
|
| 343 |
+
tf8 = TransferFunction(a0*s**5 + 5*s**2 + 3, s**6 - 3, s)
|
| 344 |
+
tf9 = TransferFunction((5 + s), (5 + s)*(6 + s), s)
|
| 345 |
+
tf10 = TransferFunction(0, 1, s)
|
| 346 |
+
tf11 = TransferFunction(1, 1, s)
|
| 347 |
+
assert tf8.to_expr() == Mul((a0*s**5 + 5*s**2 + 3), Pow((s**6 - 3), -1, evaluate=False), evaluate=False)
|
| 348 |
+
assert tf9.to_expr() == Mul((s + 5), Pow((5 + s)*(6 + s), -1, evaluate=False), evaluate=False)
|
| 349 |
+
assert tf10.to_expr() == Mul(S(0), Pow(1, -1, evaluate=False), evaluate=False)
|
| 350 |
+
assert tf11.to_expr() == Pow(1, -1, evaluate=False)
|
| 351 |
+
|
| 352 |
+
def test_TransferFunction_addition_and_subtraction():
|
| 353 |
+
tf1 = TransferFunction(s + 6, s - 5, s)
|
| 354 |
+
tf2 = TransferFunction(s + 3, s + 1, s)
|
| 355 |
+
tf3 = TransferFunction(s + 1, s**2 + s + 1, s)
|
| 356 |
+
tf4 = TransferFunction(p, 2 - p, p)
|
| 357 |
+
|
| 358 |
+
# addition
|
| 359 |
+
assert tf1 + tf2 == Parallel(tf1, tf2)
|
| 360 |
+
assert tf3 + tf1 == Parallel(tf3, tf1)
|
| 361 |
+
assert -tf1 + tf2 + tf3 == Parallel(-tf1, tf2, tf3)
|
| 362 |
+
assert tf1 + (tf2 + tf3) == Parallel(tf1, tf2, tf3)
|
| 363 |
+
|
| 364 |
+
c = symbols("c", commutative=False)
|
| 365 |
+
raises(ValueError, lambda: tf1 + Matrix([1, 2, 3]))
|
| 366 |
+
raises(ValueError, lambda: tf2 + c)
|
| 367 |
+
raises(ValueError, lambda: tf3 + tf4)
|
| 368 |
+
raises(ValueError, lambda: tf1 + (s - 1))
|
| 369 |
+
raises(ValueError, lambda: tf1 + 8)
|
| 370 |
+
raises(ValueError, lambda: (1 - p**3) + tf1)
|
| 371 |
+
|
| 372 |
+
# subtraction
|
| 373 |
+
assert tf1 - tf2 == Parallel(tf1, -tf2)
|
| 374 |
+
assert tf3 - tf2 == Parallel(tf3, -tf2)
|
| 375 |
+
assert -tf1 - tf3 == Parallel(-tf1, -tf3)
|
| 376 |
+
assert tf1 - tf2 + tf3 == Parallel(tf1, -tf2, tf3)
|
| 377 |
+
|
| 378 |
+
raises(ValueError, lambda: tf1 - Matrix([1, 2, 3]))
|
| 379 |
+
raises(ValueError, lambda: tf3 - tf4)
|
| 380 |
+
raises(ValueError, lambda: tf1 - (s - 1))
|
| 381 |
+
raises(ValueError, lambda: tf1 - 8)
|
| 382 |
+
raises(ValueError, lambda: (s + 5) - tf2)
|
| 383 |
+
raises(ValueError, lambda: (1 + p**4) - tf1)
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
def test_TransferFunction_multiplication_and_division():
|
| 387 |
+
G1 = TransferFunction(s + 3, -s**3 + 9, s)
|
| 388 |
+
G2 = TransferFunction(s + 1, s - 5, s)
|
| 389 |
+
G3 = TransferFunction(p, p**4 - 6, p)
|
| 390 |
+
G4 = TransferFunction(p + 4, p - 5, p)
|
| 391 |
+
G5 = TransferFunction(s + 6, s - 5, s)
|
| 392 |
+
G6 = TransferFunction(s + 3, s + 1, s)
|
| 393 |
+
G7 = TransferFunction(1, 1, s)
|
| 394 |
+
|
| 395 |
+
# multiplication
|
| 396 |
+
assert G1*G2 == Series(G1, G2)
|
| 397 |
+
assert -G1*G5 == Series(-G1, G5)
|
| 398 |
+
assert -G2*G5*-G6 == Series(-G2, G5, -G6)
|
| 399 |
+
assert -G1*-G2*-G5*-G6 == Series(-G1, -G2, -G5, -G6)
|
| 400 |
+
assert G3*G4 == Series(G3, G4)
|
| 401 |
+
assert (G1*G2)*-(G5*G6) == \
|
| 402 |
+
Series(G1, G2, TransferFunction(-1, 1, s), Series(G5, G6))
|
| 403 |
+
assert G1*G2*(G5 + G6) == Series(G1, G2, Parallel(G5, G6))
|
| 404 |
+
|
| 405 |
+
# division - See ``test_Feedback_functions()`` for division by Parallel objects.
|
| 406 |
+
assert G5/G6 == Series(G5, pow(G6, -1))
|
| 407 |
+
assert -G3/G4 == Series(-G3, pow(G4, -1))
|
| 408 |
+
assert (G5*G6)/G7 == Series(G5, G6, pow(G7, -1))
|
| 409 |
+
|
| 410 |
+
c = symbols("c", commutative=False)
|
| 411 |
+
raises(ValueError, lambda: G3 * Matrix([1, 2, 3]))
|
| 412 |
+
raises(ValueError, lambda: G1 * c)
|
| 413 |
+
raises(ValueError, lambda: G3 * G5)
|
| 414 |
+
raises(ValueError, lambda: G5 * (s - 1))
|
| 415 |
+
raises(ValueError, lambda: 9 * G5)
|
| 416 |
+
|
| 417 |
+
raises(ValueError, lambda: G3 / Matrix([1, 2, 3]))
|
| 418 |
+
raises(ValueError, lambda: G6 / 0)
|
| 419 |
+
raises(ValueError, lambda: G3 / G5)
|
| 420 |
+
raises(ValueError, lambda: G5 / 2)
|
| 421 |
+
raises(ValueError, lambda: G5 / s**2)
|
| 422 |
+
raises(ValueError, lambda: (s - 4*s**2) / G2)
|
| 423 |
+
raises(ValueError, lambda: 0 / G4)
|
| 424 |
+
raises(ValueError, lambda: G7 / (1 + G6))
|
| 425 |
+
raises(ValueError, lambda: G7 / (G5 * G6))
|
| 426 |
+
raises(ValueError, lambda: G7 / (G7 + (G5 + G6)))
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
def test_TransferFunction_is_proper():
|
| 430 |
+
omega_o, zeta, tau = symbols('omega_o, zeta, tau')
|
| 431 |
+
G1 = TransferFunction(omega_o**2, s**2 + p*omega_o*zeta*s + omega_o**2, omega_o)
|
| 432 |
+
G2 = TransferFunction(tau - s**3, tau + p**4, tau)
|
| 433 |
+
G3 = TransferFunction(a*b*s**3 + s**2 - a*p + s, b - s*p**2, p)
|
| 434 |
+
G4 = TransferFunction(b*s**2 + p**2 - a*p + s, b - p**2, s)
|
| 435 |
+
assert G1.is_proper
|
| 436 |
+
assert G2.is_proper
|
| 437 |
+
assert G3.is_proper
|
| 438 |
+
assert not G4.is_proper
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
def test_TransferFunction_is_strictly_proper():
|
| 442 |
+
omega_o, zeta, tau = symbols('omega_o, zeta, tau')
|
| 443 |
+
tf1 = TransferFunction(omega_o**2, s**2 + p*omega_o*zeta*s + omega_o**2, omega_o)
|
| 444 |
+
tf2 = TransferFunction(tau - s**3, tau + p**4, tau)
|
| 445 |
+
tf3 = TransferFunction(a*b*s**3 + s**2 - a*p + s, b - s*p**2, p)
|
| 446 |
+
tf4 = TransferFunction(b*s**2 + p**2 - a*p + s, b - p**2, s)
|
| 447 |
+
assert not tf1.is_strictly_proper
|
| 448 |
+
assert not tf2.is_strictly_proper
|
| 449 |
+
assert tf3.is_strictly_proper
|
| 450 |
+
assert not tf4.is_strictly_proper
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
def test_TransferFunction_is_biproper():
|
| 454 |
+
tau, omega_o, zeta = symbols('tau, omega_o, zeta')
|
| 455 |
+
tf1 = TransferFunction(omega_o**2, s**2 + p*omega_o*zeta*s + omega_o**2, omega_o)
|
| 456 |
+
tf2 = TransferFunction(tau - s**3, tau + p**4, tau)
|
| 457 |
+
tf3 = TransferFunction(a*b*s**3 + s**2 - a*p + s, b - s*p**2, p)
|
| 458 |
+
tf4 = TransferFunction(b*s**2 + p**2 - a*p + s, b - p**2, s)
|
| 459 |
+
assert tf1.is_biproper
|
| 460 |
+
assert tf2.is_biproper
|
| 461 |
+
assert not tf3.is_biproper
|
| 462 |
+
assert not tf4.is_biproper
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
def test_Series_construction():
|
| 466 |
+
tf = TransferFunction(a0*s**3 + a1*s**2 - a2*s, b0*p**4 + b1*p**3 - b2*s*p, s)
|
| 467 |
+
tf2 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 468 |
+
tf3 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 469 |
+
tf4 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 470 |
+
inp = Function('X_d')(s)
|
| 471 |
+
out = Function('X')(s)
|
| 472 |
+
|
| 473 |
+
s0 = Series(tf, tf2)
|
| 474 |
+
assert s0.args == (tf, tf2)
|
| 475 |
+
assert s0.var == s
|
| 476 |
+
|
| 477 |
+
s1 = Series(Parallel(tf, -tf2), tf2)
|
| 478 |
+
assert s1.args == (Parallel(tf, -tf2), tf2)
|
| 479 |
+
assert s1.var == s
|
| 480 |
+
|
| 481 |
+
tf3_ = TransferFunction(inp, 1, s)
|
| 482 |
+
tf4_ = TransferFunction(-out, 1, s)
|
| 483 |
+
s2 = Series(tf, Parallel(tf3_, tf4_), tf2)
|
| 484 |
+
assert s2.args == (tf, Parallel(tf3_, tf4_), tf2)
|
| 485 |
+
|
| 486 |
+
s3 = Series(tf, tf2, tf4)
|
| 487 |
+
assert s3.args == (tf, tf2, tf4)
|
| 488 |
+
|
| 489 |
+
s4 = Series(tf3_, tf4_)
|
| 490 |
+
assert s4.args == (tf3_, tf4_)
|
| 491 |
+
assert s4.var == s
|
| 492 |
+
|
| 493 |
+
s6 = Series(tf2, tf4, Parallel(tf2, -tf), tf4)
|
| 494 |
+
assert s6.args == (tf2, tf4, Parallel(tf2, -tf), tf4)
|
| 495 |
+
|
| 496 |
+
s7 = Series(tf, tf2)
|
| 497 |
+
assert s0 == s7
|
| 498 |
+
assert not s0 == s2
|
| 499 |
+
|
| 500 |
+
raises(ValueError, lambda: Series(tf, tf3))
|
| 501 |
+
raises(ValueError, lambda: Series(tf, tf2, tf3, tf4))
|
| 502 |
+
raises(ValueError, lambda: Series(-tf3, tf2))
|
| 503 |
+
raises(TypeError, lambda: Series(2, tf, tf4))
|
| 504 |
+
raises(TypeError, lambda: Series(s**2 + p*s, tf3, tf2))
|
| 505 |
+
raises(TypeError, lambda: Series(tf3, Matrix([1, 2, 3, 4])))
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
def test_MIMOSeries_construction():
|
| 509 |
+
tf_1 = TransferFunction(a0*s**3 + a1*s**2 - a2*s, b0*p**4 + b1*p**3 - b2*s*p, s)
|
| 510 |
+
tf_2 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 511 |
+
tf_3 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 512 |
+
|
| 513 |
+
tfm_1 = TransferFunctionMatrix([[tf_1, tf_2, tf_3], [-tf_3, -tf_2, tf_1]])
|
| 514 |
+
tfm_2 = TransferFunctionMatrix([[-tf_2], [-tf_2], [-tf_3]])
|
| 515 |
+
tfm_3 = TransferFunctionMatrix([[-tf_3]])
|
| 516 |
+
tfm_4 = TransferFunctionMatrix([[TF3], [TF2], [-TF1]])
|
| 517 |
+
tfm_5 = TransferFunctionMatrix.from_Matrix(Matrix([1/p]), p)
|
| 518 |
+
|
| 519 |
+
s8 = MIMOSeries(tfm_2, tfm_1)
|
| 520 |
+
assert s8.args == (tfm_2, tfm_1)
|
| 521 |
+
assert s8.var == s
|
| 522 |
+
assert s8.shape == (s8.num_outputs, s8.num_inputs) == (2, 1)
|
| 523 |
+
|
| 524 |
+
s9 = MIMOSeries(tfm_3, tfm_2, tfm_1)
|
| 525 |
+
assert s9.args == (tfm_3, tfm_2, tfm_1)
|
| 526 |
+
assert s9.var == s
|
| 527 |
+
assert s9.shape == (s9.num_outputs, s9.num_inputs) == (2, 1)
|
| 528 |
+
|
| 529 |
+
s11 = MIMOSeries(tfm_3, MIMOParallel(-tfm_2, -tfm_4), tfm_1)
|
| 530 |
+
assert s11.args == (tfm_3, MIMOParallel(-tfm_2, -tfm_4), tfm_1)
|
| 531 |
+
assert s11.shape == (s11.num_outputs, s11.num_inputs) == (2, 1)
|
| 532 |
+
|
| 533 |
+
# arg cannot be empty tuple.
|
| 534 |
+
raises(ValueError, lambda: MIMOSeries())
|
| 535 |
+
|
| 536 |
+
# arg cannot contain SISO as well as MIMO systems.
|
| 537 |
+
raises(TypeError, lambda: MIMOSeries(tfm_1, tf_1))
|
| 538 |
+
|
| 539 |
+
# for all the adjacent transfer function matrices:
|
| 540 |
+
# no. of inputs of first TFM must be equal to the no. of outputs of the second TFM.
|
| 541 |
+
raises(ValueError, lambda: MIMOSeries(tfm_1, tfm_2, -tfm_1))
|
| 542 |
+
|
| 543 |
+
# all the TFMs must use the same complex variable.
|
| 544 |
+
raises(ValueError, lambda: MIMOSeries(tfm_3, tfm_5))
|
| 545 |
+
|
| 546 |
+
# Number or expression not allowed in the arguments.
|
| 547 |
+
raises(TypeError, lambda: MIMOSeries(2, tfm_2, tfm_3))
|
| 548 |
+
raises(TypeError, lambda: MIMOSeries(s**2 + p*s, -tfm_2, tfm_3))
|
| 549 |
+
raises(TypeError, lambda: MIMOSeries(Matrix([1/p]), tfm_3))
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
def test_Series_functions():
|
| 553 |
+
tf1 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 554 |
+
tf2 = TransferFunction(k, 1, s)
|
| 555 |
+
tf3 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 556 |
+
tf4 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 557 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 558 |
+
|
| 559 |
+
assert tf1*tf2*tf3 == Series(tf1, tf2, tf3) == Series(Series(tf1, tf2), tf3) \
|
| 560 |
+
== Series(tf1, Series(tf2, tf3))
|
| 561 |
+
assert tf1*(tf2 + tf3) == Series(tf1, Parallel(tf2, tf3))
|
| 562 |
+
assert tf1*tf2 + tf5 == Parallel(Series(tf1, tf2), tf5)
|
| 563 |
+
assert tf1*tf2 - tf5 == Parallel(Series(tf1, tf2), -tf5)
|
| 564 |
+
assert tf1*tf2 + tf3 + tf5 == Parallel(Series(tf1, tf2), tf3, tf5)
|
| 565 |
+
assert tf1*tf2 - tf3 - tf5 == Parallel(Series(tf1, tf2), -tf3, -tf5)
|
| 566 |
+
assert tf1*tf2 - tf3 + tf5 == Parallel(Series(tf1, tf2), -tf3, tf5)
|
| 567 |
+
assert tf1*tf2 + tf3*tf5 == Parallel(Series(tf1, tf2), Series(tf3, tf5))
|
| 568 |
+
assert tf1*tf2 - tf3*tf5 == Parallel(Series(tf1, tf2), Series(TransferFunction(-1, 1, s), Series(tf3, tf5)))
|
| 569 |
+
assert tf2*tf3*(tf2 - tf1)*tf3 == Series(tf2, tf3, Parallel(tf2, -tf1), tf3)
|
| 570 |
+
assert -tf1*tf2 == Series(-tf1, tf2)
|
| 571 |
+
assert -(tf1*tf2) == Series(TransferFunction(-1, 1, s), Series(tf1, tf2))
|
| 572 |
+
raises(ValueError, lambda: tf1*tf2*tf4)
|
| 573 |
+
raises(ValueError, lambda: tf1*(tf2 - tf4))
|
| 574 |
+
raises(ValueError, lambda: tf3*Matrix([1, 2, 3]))
|
| 575 |
+
|
| 576 |
+
# evaluate=True -> doit()
|
| 577 |
+
assert Series(tf1, tf2, evaluate=True) == Series(tf1, tf2).doit() == \
|
| 578 |
+
TransferFunction(k, s**2 + 2*s*wn*zeta + wn**2, s)
|
| 579 |
+
assert Series(tf1, tf2, Parallel(tf1, -tf3), evaluate=True) == Series(tf1, tf2, Parallel(tf1, -tf3)).doit() == \
|
| 580 |
+
TransferFunction(k*(a2*s + p + (-a2*p + s)*(s**2 + 2*s*wn*zeta + wn**2)), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2)**2, s)
|
| 581 |
+
assert Series(tf2, tf1, -tf3, evaluate=True) == Series(tf2, tf1, -tf3).doit() == \
|
| 582 |
+
TransferFunction(k*(-a2*p + s), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 583 |
+
assert not Series(tf1, -tf2, evaluate=False) == Series(tf1, -tf2).doit()
|
| 584 |
+
|
| 585 |
+
assert Series(Parallel(tf1, tf2), Parallel(tf2, -tf3)).doit() == \
|
| 586 |
+
TransferFunction((k*(s**2 + 2*s*wn*zeta + wn**2) + 1)*(-a2*p + k*(a2*s + p) + s), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 587 |
+
assert Series(-tf1, -tf2, -tf3).doit() == \
|
| 588 |
+
TransferFunction(k*(-a2*p + s), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 589 |
+
assert -Series(tf1, tf2, tf3).doit() == \
|
| 590 |
+
TransferFunction(-k*(a2*p - s), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 591 |
+
assert Series(tf2, tf3, Parallel(tf2, -tf1), tf3).doit() == \
|
| 592 |
+
TransferFunction(k*(a2*p - s)**2*(k*(s**2 + 2*s*wn*zeta + wn**2) - 1), (a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 593 |
+
|
| 594 |
+
assert Series(tf1, tf2).rewrite(TransferFunction) == TransferFunction(k, s**2 + 2*s*wn*zeta + wn**2, s)
|
| 595 |
+
assert Series(tf2, tf1, -tf3).rewrite(TransferFunction) == \
|
| 596 |
+
TransferFunction(k*(-a2*p + s), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 597 |
+
|
| 598 |
+
S1 = Series(Parallel(tf1, tf2), Parallel(tf2, -tf3))
|
| 599 |
+
assert S1.is_proper
|
| 600 |
+
assert not S1.is_strictly_proper
|
| 601 |
+
assert S1.is_biproper
|
| 602 |
+
|
| 603 |
+
S2 = Series(tf1, tf2, tf3)
|
| 604 |
+
assert S2.is_proper
|
| 605 |
+
assert S2.is_strictly_proper
|
| 606 |
+
assert not S2.is_biproper
|
| 607 |
+
|
| 608 |
+
S3 = Series(tf1, -tf2, Parallel(tf1, -tf3))
|
| 609 |
+
assert S3.is_proper
|
| 610 |
+
assert S3.is_strictly_proper
|
| 611 |
+
assert not S3.is_biproper
|
| 612 |
+
|
| 613 |
+
|
| 614 |
+
def test_MIMOSeries_functions():
|
| 615 |
+
tfm1 = TransferFunctionMatrix([[TF1, TF2, TF3], [-TF3, -TF2, TF1]])
|
| 616 |
+
tfm2 = TransferFunctionMatrix([[-TF1], [-TF2], [-TF3]])
|
| 617 |
+
tfm3 = TransferFunctionMatrix([[-TF1]])
|
| 618 |
+
tfm4 = TransferFunctionMatrix([[-TF2, -TF3], [-TF1, TF2]])
|
| 619 |
+
tfm5 = TransferFunctionMatrix([[TF2, -TF2], [-TF3, -TF2]])
|
| 620 |
+
tfm6 = TransferFunctionMatrix([[-TF3], [TF1]])
|
| 621 |
+
tfm7 = TransferFunctionMatrix([[TF1], [-TF2]])
|
| 622 |
+
|
| 623 |
+
assert tfm1*tfm2 + tfm6 == MIMOParallel(MIMOSeries(tfm2, tfm1), tfm6)
|
| 624 |
+
assert tfm1*tfm2 + tfm7 + tfm6 == MIMOParallel(MIMOSeries(tfm2, tfm1), tfm7, tfm6)
|
| 625 |
+
assert tfm1*tfm2 - tfm6 - tfm7 == MIMOParallel(MIMOSeries(tfm2, tfm1), -tfm6, -tfm7)
|
| 626 |
+
assert tfm4*tfm5 + (tfm4 - tfm5) == MIMOParallel(MIMOSeries(tfm5, tfm4), tfm4, -tfm5)
|
| 627 |
+
assert tfm4*-tfm6 + (-tfm4*tfm6) == MIMOParallel(MIMOSeries(-tfm6, tfm4), MIMOSeries(tfm6, -tfm4))
|
| 628 |
+
|
| 629 |
+
raises(ValueError, lambda: tfm1*tfm2 + TF1)
|
| 630 |
+
raises(TypeError, lambda: tfm1*tfm2 + a0)
|
| 631 |
+
raises(TypeError, lambda: tfm4*tfm6 - (s - 1))
|
| 632 |
+
raises(TypeError, lambda: tfm4*-tfm6 - 8)
|
| 633 |
+
raises(TypeError, lambda: (-1 + p**5) + tfm1*tfm2)
|
| 634 |
+
|
| 635 |
+
# Shape criteria.
|
| 636 |
+
|
| 637 |
+
raises(TypeError, lambda: -tfm1*tfm2 + tfm4)
|
| 638 |
+
raises(TypeError, lambda: tfm1*tfm2 - tfm4 + tfm5)
|
| 639 |
+
raises(TypeError, lambda: tfm1*tfm2 - tfm4*tfm5)
|
| 640 |
+
|
| 641 |
+
assert tfm1*tfm2*-tfm3 == MIMOSeries(-tfm3, tfm2, tfm1)
|
| 642 |
+
assert (tfm1*-tfm2)*tfm3 == MIMOSeries(tfm3, -tfm2, tfm1)
|
| 643 |
+
|
| 644 |
+
# Multiplication of a Series object with a SISO TF not allowed.
|
| 645 |
+
|
| 646 |
+
raises(ValueError, lambda: tfm4*tfm5*TF1)
|
| 647 |
+
raises(TypeError, lambda: tfm4*tfm5*a1)
|
| 648 |
+
raises(TypeError, lambda: tfm4*-tfm5*(s - 2))
|
| 649 |
+
raises(TypeError, lambda: tfm5*tfm4*9)
|
| 650 |
+
raises(TypeError, lambda: (-p**3 + 1)*tfm5*tfm4)
|
| 651 |
+
|
| 652 |
+
# Transfer function matrix in the arguments.
|
| 653 |
+
assert (MIMOSeries(tfm2, tfm1, evaluate=True) == MIMOSeries(tfm2, tfm1).doit()
|
| 654 |
+
== TransferFunctionMatrix(((TransferFunction(-k**2*(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**2 + (-a2*p + s)*(a2*p - s)*(s**2 + 2*s*wn*zeta + wn**2)**2 - (a2*s + p)**2,
|
| 655 |
+
(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**2, s),),
|
| 656 |
+
(TransferFunction(k**2*(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**2 + (-a2*p + s)*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) + (a2*p - s)*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2),
|
| 657 |
+
(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**2, s),))))
|
| 658 |
+
|
| 659 |
+
# doit() should not cancel poles and zeros.
|
| 660 |
+
mat_1 = Matrix([[1/(1+s), (1+s)/(1+s**2+2*s)**3]])
|
| 661 |
+
mat_2 = Matrix([[(1+s)], [(1+s**2+2*s)**3/(1+s)]])
|
| 662 |
+
tm_1, tm_2 = TransferFunctionMatrix.from_Matrix(mat_1, s), TransferFunctionMatrix.from_Matrix(mat_2, s)
|
| 663 |
+
assert (MIMOSeries(tm_2, tm_1).doit()
|
| 664 |
+
== TransferFunctionMatrix(((TransferFunction(2*(s + 1)**2*(s**2 + 2*s + 1)**3, (s + 1)**2*(s**2 + 2*s + 1)**3, s),),)))
|
| 665 |
+
assert MIMOSeries(tm_2, tm_1).doit().simplify() == TransferFunctionMatrix(((TransferFunction(2, 1, s),),))
|
| 666 |
+
|
| 667 |
+
# calling doit() will expand the internal Series and Parallel objects.
|
| 668 |
+
assert (MIMOSeries(-tfm3, -tfm2, tfm1, evaluate=True)
|
| 669 |
+
== MIMOSeries(-tfm3, -tfm2, tfm1).doit()
|
| 670 |
+
== TransferFunctionMatrix(((TransferFunction(k**2*(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**2 + (a2*p - s)**2*(s**2 + 2*s*wn*zeta + wn**2)**2 + (a2*s + p)**2,
|
| 671 |
+
(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**3, s),),
|
| 672 |
+
(TransferFunction(-k**2*(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**2 + (-a2*p + s)*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) + (a2*p - s)*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2),
|
| 673 |
+
(a2*s + p)**2*(s**2 + 2*s*wn*zeta + wn**2)**3, s),))))
|
| 674 |
+
assert (MIMOSeries(MIMOParallel(tfm4, tfm5), tfm5, evaluate=True)
|
| 675 |
+
== MIMOSeries(MIMOParallel(tfm4, tfm5), tfm5).doit()
|
| 676 |
+
== TransferFunctionMatrix(((TransferFunction(-k*(-a2*s - p + (-a2*p + s)*(s**2 + 2*s*wn*zeta + wn**2)), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s), TransferFunction(k*(-a2*p - \
|
| 677 |
+
k*(a2*s + p) + s), a2*s + p, s)), (TransferFunction(-k*(-a2*s - p + (-a2*p + s)*(s**2 + 2*s*wn*zeta + wn**2)), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s), \
|
| 678 |
+
TransferFunction((-a2*p + s)*(-a2*p - k*(a2*s + p) + s), (a2*s + p)**2, s)))) == MIMOSeries(MIMOParallel(tfm4, tfm5), tfm5).rewrite(TransferFunctionMatrix))
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
def test_Parallel_construction():
|
| 682 |
+
tf = TransferFunction(a0*s**3 + a1*s**2 - a2*s, b0*p**4 + b1*p**3 - b2*s*p, s)
|
| 683 |
+
tf2 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 684 |
+
tf3 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 685 |
+
tf4 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 686 |
+
inp = Function('X_d')(s)
|
| 687 |
+
out = Function('X')(s)
|
| 688 |
+
|
| 689 |
+
p0 = Parallel(tf, tf2)
|
| 690 |
+
assert p0.args == (tf, tf2)
|
| 691 |
+
assert p0.var == s
|
| 692 |
+
|
| 693 |
+
p1 = Parallel(Series(tf, -tf2), tf2)
|
| 694 |
+
assert p1.args == (Series(tf, -tf2), tf2)
|
| 695 |
+
assert p1.var == s
|
| 696 |
+
|
| 697 |
+
tf3_ = TransferFunction(inp, 1, s)
|
| 698 |
+
tf4_ = TransferFunction(-out, 1, s)
|
| 699 |
+
p2 = Parallel(tf, Series(tf3_, -tf4_), tf2)
|
| 700 |
+
assert p2.args == (tf, Series(tf3_, -tf4_), tf2)
|
| 701 |
+
|
| 702 |
+
p3 = Parallel(tf, tf2, tf4)
|
| 703 |
+
assert p3.args == (tf, tf2, tf4)
|
| 704 |
+
|
| 705 |
+
p4 = Parallel(tf3_, tf4_)
|
| 706 |
+
assert p4.args == (tf3_, tf4_)
|
| 707 |
+
assert p4.var == s
|
| 708 |
+
|
| 709 |
+
p5 = Parallel(tf, tf2)
|
| 710 |
+
assert p0 == p5
|
| 711 |
+
assert not p0 == p1
|
| 712 |
+
|
| 713 |
+
p6 = Parallel(tf2, tf4, Series(tf2, -tf4))
|
| 714 |
+
assert p6.args == (tf2, tf4, Series(tf2, -tf4))
|
| 715 |
+
|
| 716 |
+
p7 = Parallel(tf2, tf4, Series(tf2, -tf), tf4)
|
| 717 |
+
assert p7.args == (tf2, tf4, Series(tf2, -tf), tf4)
|
| 718 |
+
|
| 719 |
+
raises(ValueError, lambda: Parallel(tf, tf3))
|
| 720 |
+
raises(ValueError, lambda: Parallel(tf, tf2, tf3, tf4))
|
| 721 |
+
raises(ValueError, lambda: Parallel(-tf3, tf4))
|
| 722 |
+
raises(TypeError, lambda: Parallel(2, tf, tf4))
|
| 723 |
+
raises(TypeError, lambda: Parallel(s**2 + p*s, tf3, tf2))
|
| 724 |
+
raises(TypeError, lambda: Parallel(tf3, Matrix([1, 2, 3, 4])))
|
| 725 |
+
|
| 726 |
+
|
| 727 |
+
def test_MIMOParallel_construction():
|
| 728 |
+
tfm1 = TransferFunctionMatrix([[TF1], [TF2], [TF3]])
|
| 729 |
+
tfm2 = TransferFunctionMatrix([[-TF3], [TF2], [TF1]])
|
| 730 |
+
tfm3 = TransferFunctionMatrix([[TF1]])
|
| 731 |
+
tfm4 = TransferFunctionMatrix([[TF2], [TF1], [TF3]])
|
| 732 |
+
tfm5 = TransferFunctionMatrix([[TF1, TF2], [TF2, TF1]])
|
| 733 |
+
tfm6 = TransferFunctionMatrix([[TF2, TF1], [TF1, TF2]])
|
| 734 |
+
tfm7 = TransferFunctionMatrix.from_Matrix(Matrix([[1/p]]), p)
|
| 735 |
+
|
| 736 |
+
p8 = MIMOParallel(tfm1, tfm2)
|
| 737 |
+
assert p8.args == (tfm1, tfm2)
|
| 738 |
+
assert p8.var == s
|
| 739 |
+
assert p8.shape == (p8.num_outputs, p8.num_inputs) == (3, 1)
|
| 740 |
+
|
| 741 |
+
p9 = MIMOParallel(MIMOSeries(tfm3, tfm1), tfm2)
|
| 742 |
+
assert p9.args == (MIMOSeries(tfm3, tfm1), tfm2)
|
| 743 |
+
assert p9.var == s
|
| 744 |
+
assert p9.shape == (p9.num_outputs, p9.num_inputs) == (3, 1)
|
| 745 |
+
|
| 746 |
+
p10 = MIMOParallel(tfm1, MIMOSeries(tfm3, tfm4), tfm2)
|
| 747 |
+
assert p10.args == (tfm1, MIMOSeries(tfm3, tfm4), tfm2)
|
| 748 |
+
assert p10.var == s
|
| 749 |
+
assert p10.shape == (p10.num_outputs, p10.num_inputs) == (3, 1)
|
| 750 |
+
|
| 751 |
+
p11 = MIMOParallel(tfm2, tfm1, tfm4)
|
| 752 |
+
assert p11.args == (tfm2, tfm1, tfm4)
|
| 753 |
+
assert p11.shape == (p11.num_outputs, p11.num_inputs) == (3, 1)
|
| 754 |
+
|
| 755 |
+
p12 = MIMOParallel(tfm6, tfm5)
|
| 756 |
+
assert p12.args == (tfm6, tfm5)
|
| 757 |
+
assert p12.shape == (p12.num_outputs, p12.num_inputs) == (2, 2)
|
| 758 |
+
|
| 759 |
+
p13 = MIMOParallel(tfm2, tfm4, MIMOSeries(-tfm3, tfm4), -tfm4)
|
| 760 |
+
assert p13.args == (tfm2, tfm4, MIMOSeries(-tfm3, tfm4), -tfm4)
|
| 761 |
+
assert p13.shape == (p13.num_outputs, p13.num_inputs) == (3, 1)
|
| 762 |
+
|
| 763 |
+
# arg cannot be empty tuple.
|
| 764 |
+
raises(TypeError, lambda: MIMOParallel(()))
|
| 765 |
+
|
| 766 |
+
# arg cannot contain SISO as well as MIMO systems.
|
| 767 |
+
raises(TypeError, lambda: MIMOParallel(tfm1, tfm2, TF1))
|
| 768 |
+
|
| 769 |
+
# all TFMs must have same shapes.
|
| 770 |
+
raises(TypeError, lambda: MIMOParallel(tfm1, tfm3, tfm4))
|
| 771 |
+
|
| 772 |
+
# all TFMs must be using the same complex variable.
|
| 773 |
+
raises(ValueError, lambda: MIMOParallel(tfm3, tfm7))
|
| 774 |
+
|
| 775 |
+
# Number or expression not allowed in the arguments.
|
| 776 |
+
raises(TypeError, lambda: MIMOParallel(2, tfm1, tfm4))
|
| 777 |
+
raises(TypeError, lambda: MIMOParallel(s**2 + p*s, -tfm4, tfm2))
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
def test_Parallel_functions():
|
| 781 |
+
tf1 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 782 |
+
tf2 = TransferFunction(k, 1, s)
|
| 783 |
+
tf3 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 784 |
+
tf4 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 785 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 786 |
+
|
| 787 |
+
assert tf1 + tf2 + tf3 == Parallel(tf1, tf2, tf3)
|
| 788 |
+
assert tf1 + tf2 + tf3 + tf5 == Parallel(tf1, tf2, tf3, tf5)
|
| 789 |
+
assert tf1 + tf2 - tf3 - tf5 == Parallel(tf1, tf2, -tf3, -tf5)
|
| 790 |
+
assert tf1 + tf2*tf3 == Parallel(tf1, Series(tf2, tf3))
|
| 791 |
+
assert tf1 - tf2*tf3 == Parallel(tf1, -Series(tf2,tf3))
|
| 792 |
+
assert -tf1 - tf2 == Parallel(-tf1, -tf2)
|
| 793 |
+
assert -(tf1 + tf2) == Series(TransferFunction(-1, 1, s), Parallel(tf1, tf2))
|
| 794 |
+
assert (tf2 + tf3)*tf1 == Series(Parallel(tf2, tf3), tf1)
|
| 795 |
+
assert (tf1 + tf2)*(tf3*tf5) == Series(Parallel(tf1, tf2), tf3, tf5)
|
| 796 |
+
assert -(tf2 + tf3)*-tf5 == Series(TransferFunction(-1, 1, s), Parallel(tf2, tf3), -tf5)
|
| 797 |
+
assert tf2 + tf3 + tf2*tf1 + tf5 == Parallel(tf2, tf3, Series(tf2, tf1), tf5)
|
| 798 |
+
assert tf2 + tf3 + tf2*tf1 - tf3 == Parallel(tf2, tf3, Series(tf2, tf1), -tf3)
|
| 799 |
+
assert (tf1 + tf2 + tf5)*(tf3 + tf5) == Series(Parallel(tf1, tf2, tf5), Parallel(tf3, tf5))
|
| 800 |
+
raises(ValueError, lambda: tf1 + tf2 + tf4)
|
| 801 |
+
raises(ValueError, lambda: tf1 - tf2*tf4)
|
| 802 |
+
raises(ValueError, lambda: tf3 + Matrix([1, 2, 3]))
|
| 803 |
+
|
| 804 |
+
# evaluate=True -> doit()
|
| 805 |
+
assert Parallel(tf1, tf2, evaluate=True) == Parallel(tf1, tf2).doit() == \
|
| 806 |
+
TransferFunction(k*(s**2 + 2*s*wn*zeta + wn**2) + 1, s**2 + 2*s*wn*zeta + wn**2, s)
|
| 807 |
+
assert Parallel(tf1, tf2, Series(-tf1, tf3), evaluate=True) == \
|
| 808 |
+
Parallel(tf1, tf2, Series(-tf1, tf3)).doit() == TransferFunction(k*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2)**2 + \
|
| 809 |
+
(-a2*p + s)*(s**2 + 2*s*wn*zeta + wn**2) + (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), (a2*s + p)*(s**2 + \
|
| 810 |
+
2*s*wn*zeta + wn**2)**2, s)
|
| 811 |
+
assert Parallel(tf2, tf1, -tf3, evaluate=True) == Parallel(tf2, tf1, -tf3).doit() == \
|
| 812 |
+
TransferFunction(a2*s + k*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) + p + (-a2*p + s)*(s**2 + 2*s*wn*zeta + wn**2) \
|
| 813 |
+
, (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 814 |
+
assert not Parallel(tf1, -tf2, evaluate=False) == Parallel(tf1, -tf2).doit()
|
| 815 |
+
|
| 816 |
+
assert Parallel(Series(tf1, tf2), Series(tf2, tf3)).doit() == \
|
| 817 |
+
TransferFunction(k*(a2*p - s)*(s**2 + 2*s*wn*zeta + wn**2) + k*(a2*s + p), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 818 |
+
assert Parallel(-tf1, -tf2, -tf3).doit() == \
|
| 819 |
+
TransferFunction(-a2*s - k*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) - p + (-a2*p + s)*(s**2 + 2*s*wn*zeta + wn**2), \
|
| 820 |
+
(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 821 |
+
assert -Parallel(tf1, tf2, tf3).doit() == \
|
| 822 |
+
TransferFunction(-a2*s - k*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) - p - (a2*p - s)*(s**2 + 2*s*wn*zeta + wn**2), \
|
| 823 |
+
(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 824 |
+
assert Parallel(tf2, tf3, Series(tf2, -tf1), tf3).doit() == \
|
| 825 |
+
TransferFunction(k*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) - k*(a2*s + p) + (2*a2*p - 2*s)*(s**2 + 2*s*wn*zeta \
|
| 826 |
+
+ wn**2), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 827 |
+
|
| 828 |
+
assert Parallel(tf1, tf2).rewrite(TransferFunction) == \
|
| 829 |
+
TransferFunction(k*(s**2 + 2*s*wn*zeta + wn**2) + 1, s**2 + 2*s*wn*zeta + wn**2, s)
|
| 830 |
+
assert Parallel(tf2, tf1, -tf3).rewrite(TransferFunction) == \
|
| 831 |
+
TransferFunction(a2*s + k*(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2) + p + (-a2*p + s)*(s**2 + 2*s*wn*zeta + \
|
| 832 |
+
wn**2), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 833 |
+
|
| 834 |
+
assert Parallel(tf1, Parallel(tf2, tf3)) == Parallel(tf1, tf2, tf3) == Parallel(Parallel(tf1, tf2), tf3)
|
| 835 |
+
|
| 836 |
+
P1 = Parallel(Series(tf1, tf2), Series(tf2, tf3))
|
| 837 |
+
assert P1.is_proper
|
| 838 |
+
assert not P1.is_strictly_proper
|
| 839 |
+
assert P1.is_biproper
|
| 840 |
+
|
| 841 |
+
P2 = Parallel(tf1, -tf2, -tf3)
|
| 842 |
+
assert P2.is_proper
|
| 843 |
+
assert not P2.is_strictly_proper
|
| 844 |
+
assert P2.is_biproper
|
| 845 |
+
|
| 846 |
+
P3 = Parallel(tf1, -tf2, Series(tf1, tf3))
|
| 847 |
+
assert P3.is_proper
|
| 848 |
+
assert not P3.is_strictly_proper
|
| 849 |
+
assert P3.is_biproper
|
| 850 |
+
|
| 851 |
+
|
| 852 |
+
def test_MIMOParallel_functions():
|
| 853 |
+
tf4 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 854 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 855 |
+
|
| 856 |
+
tfm1 = TransferFunctionMatrix([[TF1], [TF2], [TF3]])
|
| 857 |
+
tfm2 = TransferFunctionMatrix([[-TF2], [tf5], [-TF1]])
|
| 858 |
+
tfm3 = TransferFunctionMatrix([[tf5], [-tf5], [TF2]])
|
| 859 |
+
tfm4 = TransferFunctionMatrix([[TF2, -tf5], [TF1, tf5]])
|
| 860 |
+
tfm5 = TransferFunctionMatrix([[TF1, TF2], [TF3, -tf5]])
|
| 861 |
+
tfm6 = TransferFunctionMatrix([[-TF2]])
|
| 862 |
+
tfm7 = TransferFunctionMatrix([[tf4], [-tf4], [tf4]])
|
| 863 |
+
|
| 864 |
+
assert tfm1 + tfm2 + tfm3 == MIMOParallel(tfm1, tfm2, tfm3) == MIMOParallel(MIMOParallel(tfm1, tfm2), tfm3)
|
| 865 |
+
assert tfm2 - tfm1 - tfm3 == MIMOParallel(tfm2, -tfm1, -tfm3)
|
| 866 |
+
assert tfm2 - tfm3 + (-tfm1*tfm6*-tfm6) == MIMOParallel(tfm2, -tfm3, MIMOSeries(-tfm6, tfm6, -tfm1))
|
| 867 |
+
assert tfm1 + tfm1 - (-tfm1*tfm6) == MIMOParallel(tfm1, tfm1, -MIMOSeries(tfm6, -tfm1))
|
| 868 |
+
assert tfm2 - tfm3 - tfm1 + tfm2 == MIMOParallel(tfm2, -tfm3, -tfm1, tfm2)
|
| 869 |
+
assert tfm1 + tfm2 - tfm3 - tfm1 == MIMOParallel(tfm1, tfm2, -tfm3, -tfm1)
|
| 870 |
+
raises(ValueError, lambda: tfm1 + tfm2 + TF2)
|
| 871 |
+
raises(TypeError, lambda: tfm1 - tfm2 - a1)
|
| 872 |
+
raises(TypeError, lambda: tfm2 - tfm3 - (s - 1))
|
| 873 |
+
raises(TypeError, lambda: -tfm3 - tfm2 - 9)
|
| 874 |
+
raises(TypeError, lambda: (1 - p**3) - tfm3 - tfm2)
|
| 875 |
+
# All TFMs must use the same complex var. tfm7 uses 'p'.
|
| 876 |
+
raises(ValueError, lambda: tfm3 - tfm2 - tfm7)
|
| 877 |
+
raises(ValueError, lambda: tfm2 - tfm1 + tfm7)
|
| 878 |
+
# (tfm1 +/- tfm2) has (3, 1) shape while tfm4 has (2, 2) shape.
|
| 879 |
+
raises(TypeError, lambda: tfm1 + tfm2 + tfm4)
|
| 880 |
+
raises(TypeError, lambda: (tfm1 - tfm2) - tfm4)
|
| 881 |
+
|
| 882 |
+
assert (tfm1 + tfm2)*tfm6 == MIMOSeries(tfm6, MIMOParallel(tfm1, tfm2))
|
| 883 |
+
assert (tfm2 - tfm3)*tfm6*-tfm6 == MIMOSeries(-tfm6, tfm6, MIMOParallel(tfm2, -tfm3))
|
| 884 |
+
assert (tfm2 - tfm1 - tfm3)*(tfm6 + tfm6) == MIMOSeries(MIMOParallel(tfm6, tfm6), MIMOParallel(tfm2, -tfm1, -tfm3))
|
| 885 |
+
raises(ValueError, lambda: (tfm4 + tfm5)*TF1)
|
| 886 |
+
raises(TypeError, lambda: (tfm2 - tfm3)*a2)
|
| 887 |
+
raises(TypeError, lambda: (tfm3 + tfm2)*(s - 6))
|
| 888 |
+
raises(TypeError, lambda: (tfm1 + tfm2 + tfm3)*0)
|
| 889 |
+
raises(TypeError, lambda: (1 - p**3)*(tfm1 + tfm3))
|
| 890 |
+
|
| 891 |
+
# (tfm3 - tfm2) has (3, 1) shape while tfm4*tfm5 has (2, 2) shape.
|
| 892 |
+
raises(ValueError, lambda: (tfm3 - tfm2)*tfm4*tfm5)
|
| 893 |
+
# (tfm1 - tfm2) has (3, 1) shape while tfm5 has (2, 2) shape.
|
| 894 |
+
raises(ValueError, lambda: (tfm1 - tfm2)*tfm5)
|
| 895 |
+
|
| 896 |
+
# TFM in the arguments.
|
| 897 |
+
assert (MIMOParallel(tfm1, tfm2, evaluate=True) == MIMOParallel(tfm1, tfm2).doit()
|
| 898 |
+
== MIMOParallel(tfm1, tfm2).rewrite(TransferFunctionMatrix)
|
| 899 |
+
== TransferFunctionMatrix(((TransferFunction(-k*(s**2 + 2*s*wn*zeta + wn**2) + 1, s**2 + 2*s*wn*zeta + wn**2, s),), \
|
| 900 |
+
(TransferFunction(-a0 + a1*s**2 + a2*s + k*(a0 + s), a0 + s, s),), (TransferFunction(-a2*s - p + (a2*p - s)* \
|
| 901 |
+
(s**2 + 2*s*wn*zeta + wn**2), (a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s),))))
|
| 902 |
+
|
| 903 |
+
|
| 904 |
+
def test_Feedback_construction():
|
| 905 |
+
tf1 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 906 |
+
tf2 = TransferFunction(k, 1, s)
|
| 907 |
+
tf3 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 908 |
+
tf4 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 909 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 910 |
+
tf6 = TransferFunction(s - p, p + s, p)
|
| 911 |
+
|
| 912 |
+
f1 = Feedback(TransferFunction(1, 1, s), tf1*tf2*tf3)
|
| 913 |
+
assert f1.args == (TransferFunction(1, 1, s), Series(tf1, tf2, tf3), -1)
|
| 914 |
+
assert f1.sys1 == TransferFunction(1, 1, s)
|
| 915 |
+
assert f1.sys2 == Series(tf1, tf2, tf3)
|
| 916 |
+
assert f1.var == s
|
| 917 |
+
|
| 918 |
+
f2 = Feedback(tf1, tf2*tf3)
|
| 919 |
+
assert f2.args == (tf1, Series(tf2, tf3), -1)
|
| 920 |
+
assert f2.sys1 == tf1
|
| 921 |
+
assert f2.sys2 == Series(tf2, tf3)
|
| 922 |
+
assert f2.var == s
|
| 923 |
+
|
| 924 |
+
f3 = Feedback(tf1*tf2, tf5)
|
| 925 |
+
assert f3.args == (Series(tf1, tf2), tf5, -1)
|
| 926 |
+
assert f3.sys1 == Series(tf1, tf2)
|
| 927 |
+
|
| 928 |
+
f4 = Feedback(tf4, tf6)
|
| 929 |
+
assert f4.args == (tf4, tf6, -1)
|
| 930 |
+
assert f4.sys1 == tf4
|
| 931 |
+
assert f4.var == p
|
| 932 |
+
|
| 933 |
+
f5 = Feedback(tf5, TransferFunction(1, 1, s))
|
| 934 |
+
assert f5.args == (tf5, TransferFunction(1, 1, s), -1)
|
| 935 |
+
assert f5.var == s
|
| 936 |
+
assert f5 == Feedback(tf5) # When sys2 is not passed explicitly, it is assumed to be unit tf.
|
| 937 |
+
|
| 938 |
+
f6 = Feedback(TransferFunction(1, 1, p), tf4)
|
| 939 |
+
assert f6.args == (TransferFunction(1, 1, p), tf4, -1)
|
| 940 |
+
assert f6.var == p
|
| 941 |
+
|
| 942 |
+
f7 = -Feedback(tf4*tf6, TransferFunction(1, 1, p))
|
| 943 |
+
assert f7.args == (Series(TransferFunction(-1, 1, p), Series(tf4, tf6)), -TransferFunction(1, 1, p), -1)
|
| 944 |
+
assert f7.sys1 == Series(TransferFunction(-1, 1, p), Series(tf4, tf6))
|
| 945 |
+
|
| 946 |
+
# denominator can't be a Parallel instance
|
| 947 |
+
raises(TypeError, lambda: Feedback(tf1, tf2 + tf3))
|
| 948 |
+
raises(TypeError, lambda: Feedback(tf1, Matrix([1, 2, 3])))
|
| 949 |
+
raises(TypeError, lambda: Feedback(TransferFunction(1, 1, s), s - 1))
|
| 950 |
+
raises(TypeError, lambda: Feedback(1, 1))
|
| 951 |
+
# raises(ValueError, lambda: Feedback(TransferFunction(1, 1, s), TransferFunction(1, 1, s)))
|
| 952 |
+
raises(ValueError, lambda: Feedback(tf2, tf4*tf5))
|
| 953 |
+
raises(ValueError, lambda: Feedback(tf2, tf1, 1.5)) # `sign` can only be -1 or 1
|
| 954 |
+
raises(ValueError, lambda: Feedback(tf1, -tf1**-1)) # denominator can't be zero
|
| 955 |
+
raises(ValueError, lambda: Feedback(tf4, tf5)) # Both systems should use the same `var`
|
| 956 |
+
|
| 957 |
+
|
| 958 |
+
def test_Feedback_functions():
|
| 959 |
+
tf = TransferFunction(1, 1, s)
|
| 960 |
+
tf1 = TransferFunction(1, s**2 + 2*zeta*wn*s + wn**2, s)
|
| 961 |
+
tf2 = TransferFunction(k, 1, s)
|
| 962 |
+
tf3 = TransferFunction(a2*p - s, a2*s + p, s)
|
| 963 |
+
tf4 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 964 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 965 |
+
tf6 = TransferFunction(s - p, p + s, p)
|
| 966 |
+
|
| 967 |
+
assert (tf1*tf2*tf3 / tf3*tf5) == Series(tf1, tf2, tf3, pow(tf3, -1), tf5)
|
| 968 |
+
assert (tf1*tf2*tf3) / (tf3*tf5) == Series((tf1*tf2*tf3).doit(), pow((tf3*tf5).doit(),-1))
|
| 969 |
+
assert tf / (tf + tf1) == Feedback(tf, tf1)
|
| 970 |
+
assert tf / (tf + tf1*tf2*tf3) == Feedback(tf, tf1*tf2*tf3)
|
| 971 |
+
assert tf1 / (tf + tf1*tf2*tf3) == Feedback(tf1, tf2*tf3)
|
| 972 |
+
assert (tf1*tf2) / (tf + tf1*tf2) == Feedback(tf1*tf2, tf)
|
| 973 |
+
assert (tf1*tf2) / (tf + tf1*tf2*tf5) == Feedback(tf1*tf2, tf5)
|
| 974 |
+
assert (tf1*tf2) / (tf + tf1*tf2*tf5*tf3) in (Feedback(tf1*tf2, tf5*tf3), Feedback(tf1*tf2, tf3*tf5))
|
| 975 |
+
assert tf4 / (TransferFunction(1, 1, p) + tf4*tf6) == Feedback(tf4, tf6)
|
| 976 |
+
assert tf5 / (tf + tf5) == Feedback(tf5, tf)
|
| 977 |
+
|
| 978 |
+
raises(TypeError, lambda: tf1*tf2*tf3 / (1 + tf1*tf2*tf3))
|
| 979 |
+
raises(ValueError, lambda: tf2*tf3 / (tf + tf2*tf3*tf4))
|
| 980 |
+
|
| 981 |
+
assert Feedback(tf, tf1*tf2*tf3).doit() == \
|
| 982 |
+
TransferFunction((a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), k*(a2*p - s) + \
|
| 983 |
+
(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 984 |
+
assert Feedback(tf, tf1*tf2*tf3).sensitivity == \
|
| 985 |
+
1/(k*(a2*p - s)/((a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2)) + 1)
|
| 986 |
+
assert Feedback(tf1, tf2*tf3).doit() == \
|
| 987 |
+
TransferFunction((a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2), (k*(a2*p - s) + \
|
| 988 |
+
(a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2))*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 989 |
+
assert Feedback(tf1, tf2*tf3).sensitivity == \
|
| 990 |
+
1/(k*(a2*p - s)/((a2*s + p)*(s**2 + 2*s*wn*zeta + wn**2)) + 1)
|
| 991 |
+
assert Feedback(tf1*tf2, tf5).doit() == \
|
| 992 |
+
TransferFunction(k*(a0 + s)*(s**2 + 2*s*wn*zeta + wn**2), (k*(-a0 + a1*s**2 + a2*s) + \
|
| 993 |
+
(a0 + s)*(s**2 + 2*s*wn*zeta + wn**2))*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 994 |
+
assert Feedback(tf1*tf2, tf5, 1).sensitivity == \
|
| 995 |
+
1/(-k*(-a0 + a1*s**2 + a2*s)/((a0 + s)*(s**2 + 2*s*wn*zeta + wn**2)) + 1)
|
| 996 |
+
assert Feedback(tf4, tf6).doit() == \
|
| 997 |
+
TransferFunction(p*(p + s)*(a0*p + p**a1 - s), p*(p*(p + s) + (-p + s)*(a0*p + p**a1 - s)), p)
|
| 998 |
+
assert -Feedback(tf4*tf6, TransferFunction(1, 1, p)).doit() == \
|
| 999 |
+
TransferFunction(-p*(-p + s)*(p + s)*(a0*p + p**a1 - s), p*(p + s)*(p*(p + s) + (-p + s)*(a0*p + p**a1 - s)), p)
|
| 1000 |
+
assert Feedback(tf, tf).doit() == TransferFunction(1, 2, s)
|
| 1001 |
+
|
| 1002 |
+
assert Feedback(tf1, tf2*tf5).rewrite(TransferFunction) == \
|
| 1003 |
+
TransferFunction((a0 + s)*(s**2 + 2*s*wn*zeta + wn**2), (k*(-a0 + a1*s**2 + a2*s) + \
|
| 1004 |
+
(a0 + s)*(s**2 + 2*s*wn*zeta + wn**2))*(s**2 + 2*s*wn*zeta + wn**2), s)
|
| 1005 |
+
assert Feedback(TransferFunction(1, 1, p), tf4).rewrite(TransferFunction) == \
|
| 1006 |
+
TransferFunction(p, a0*p + p + p**a1 - s, p)
|
| 1007 |
+
|
| 1008 |
+
|
| 1009 |
+
def test_Feedback_as_TransferFunction():
|
| 1010 |
+
# Solves issue https://github.com/sympy/sympy/issues/26161
|
| 1011 |
+
tf1 = TransferFunction(s+1, 1, s)
|
| 1012 |
+
tf2 = TransferFunction(s+2, 1, s)
|
| 1013 |
+
fd1 = Feedback(tf1, tf2, -1) # Negative Feedback system
|
| 1014 |
+
fd2 = Feedback(tf1, tf2, 1) # Positive Feedback system
|
| 1015 |
+
unit = TransferFunction(1, 1, s)
|
| 1016 |
+
|
| 1017 |
+
# Checking the type
|
| 1018 |
+
assert isinstance(fd1, TransferFunction)
|
| 1019 |
+
assert isinstance(fd1, Feedback)
|
| 1020 |
+
|
| 1021 |
+
# Testing the numerator and denominator
|
| 1022 |
+
assert fd1.num == tf1
|
| 1023 |
+
assert fd2.num == tf1
|
| 1024 |
+
assert fd1.den == Parallel(unit, Series(tf2, tf1))
|
| 1025 |
+
assert fd2.den == Parallel(unit, -Series(tf2, tf1))
|
| 1026 |
+
|
| 1027 |
+
# Testing the Series and Parallel Combination with Feedback and TransferFunction
|
| 1028 |
+
s1 = Series(tf1, fd1)
|
| 1029 |
+
p1 = Parallel(tf1, fd1)
|
| 1030 |
+
assert tf1 * fd1 == s1
|
| 1031 |
+
assert tf1 + fd1 == p1
|
| 1032 |
+
assert s1.doit() == TransferFunction((s + 1)**2, (s + 1)*(s + 2) + 1, s)
|
| 1033 |
+
assert p1.doit() == TransferFunction(s + (s + 1)*((s + 1)*(s + 2) + 1) + 1, (s + 1)*(s + 2) + 1, s)
|
| 1034 |
+
|
| 1035 |
+
# Testing the use of Feedback and TransferFunction with Feedback
|
| 1036 |
+
fd3 = Feedback(tf1*fd1, tf2, -1)
|
| 1037 |
+
assert fd3 == Feedback(Series(tf1, fd1), tf2)
|
| 1038 |
+
assert fd3.num == tf1 * fd1
|
| 1039 |
+
assert fd3.den == Parallel(unit, Series(tf2, Series(tf1, fd1)))
|
| 1040 |
+
|
| 1041 |
+
# Testing the use of Feedback and TransferFunction with TransferFunction
|
| 1042 |
+
tf3 = TransferFunction(tf1*fd1, tf2, s)
|
| 1043 |
+
assert tf3 == TransferFunction(Series(tf1, fd1), tf2, s)
|
| 1044 |
+
assert tf3.num == tf1*fd1
|
| 1045 |
+
|
| 1046 |
+
def test_issue_26161():
|
| 1047 |
+
# Issue https://github.com/sympy/sympy/issues/26161
|
| 1048 |
+
Ib, Is, m, h, l2, l1 = symbols('I_b, I_s, m, h, l2, l1',
|
| 1049 |
+
real=True, nonnegative=True)
|
| 1050 |
+
KD, KP, v = symbols('K_D, K_P, v', real=True)
|
| 1051 |
+
|
| 1052 |
+
tau1_sq = (Ib + m * h ** 2) / m / g / h
|
| 1053 |
+
tau2 = l2 / v
|
| 1054 |
+
tau3 = v / (l1 + l2)
|
| 1055 |
+
K = v ** 2 / g / (l1 + l2)
|
| 1056 |
+
|
| 1057 |
+
Gtheta = TransferFunction(-K * (tau2 * s + 1), tau1_sq * s ** 2 - 1, s)
|
| 1058 |
+
Gdelta = TransferFunction(1, Is * s ** 2 + c * s, s)
|
| 1059 |
+
Gpsi = TransferFunction(1, tau3 * s, s)
|
| 1060 |
+
Dcont = TransferFunction(KD * s, 1, s)
|
| 1061 |
+
PIcont = TransferFunction(KP, s, s)
|
| 1062 |
+
Gunity = TransferFunction(1, 1, s)
|
| 1063 |
+
|
| 1064 |
+
Ginner = Feedback(Dcont * Gdelta, Gtheta)
|
| 1065 |
+
Gouter = Feedback(PIcont * Ginner * Gpsi, Gunity)
|
| 1066 |
+
assert Gouter == Feedback(Series(PIcont, Series(Ginner, Gpsi)), Gunity)
|
| 1067 |
+
assert Gouter.num == Series(PIcont, Series(Ginner, Gpsi))
|
| 1068 |
+
assert Gouter.den == Parallel(Gunity, Series(Gunity, Series(PIcont, Series(Ginner, Gpsi))))
|
| 1069 |
+
expr = (KD*KP*g*s**3*v**2*(l1 + l2)*(Is*s**2 + c*s)**2*(-g*h*m + s**2*(Ib + h**2*m))*(-KD*g*h*m*s*v**2*(l2*s + v) + \
|
| 1070 |
+
g*v*(l1 + l2)*(Is*s**2 + c*s)*(-g*h*m + s**2*(Ib + h**2*m))))/((s**2*v*(Is*s**2 + c*s)*(-KD*g*h*m*s*v**2* \
|
| 1071 |
+
(l2*s + v) + g*v*(l1 + l2)*(Is*s**2 + c*s)*(-g*h*m + s**2*(Ib + h**2*m)))*(KD*KP*g*s*v*(l1 + l2)**2* \
|
| 1072 |
+
(Is*s**2 + c*s)*(-g*h*m + s**2*(Ib + h**2*m)) + s**2*v*(Is*s**2 + c*s)*(-KD*g*h*m*s*v**2*(l2*s + v) + \
|
| 1073 |
+
g*v*(l1 + l2)*(Is*s**2 + c*s)*(-g*h*m + s**2*(Ib + h**2*m))))/(l1 + l2)))
|
| 1074 |
+
|
| 1075 |
+
assert (Gouter.to_expr() - expr).simplify() == 0
|
| 1076 |
+
|
| 1077 |
+
|
| 1078 |
+
def test_MIMOFeedback_construction():
|
| 1079 |
+
tf1 = TransferFunction(1, s, s)
|
| 1080 |
+
tf2 = TransferFunction(s, s**3 - 1, s)
|
| 1081 |
+
tf3 = TransferFunction(s, s + 1, s)
|
| 1082 |
+
tf4 = TransferFunction(s, s**2 + 1, s)
|
| 1083 |
+
|
| 1084 |
+
tfm_1 = TransferFunctionMatrix([[tf1, tf2], [tf3, tf4]])
|
| 1085 |
+
tfm_2 = TransferFunctionMatrix([[tf2, tf3], [tf4, tf1]])
|
| 1086 |
+
tfm_3 = TransferFunctionMatrix([[tf3, tf4], [tf1, tf2]])
|
| 1087 |
+
|
| 1088 |
+
f1 = MIMOFeedback(tfm_1, tfm_2)
|
| 1089 |
+
assert f1.args == (tfm_1, tfm_2, -1)
|
| 1090 |
+
assert f1.sys1 == tfm_1
|
| 1091 |
+
assert f1.sys2 == tfm_2
|
| 1092 |
+
assert f1.var == s
|
| 1093 |
+
assert f1.sign == -1
|
| 1094 |
+
assert -(-f1) == f1
|
| 1095 |
+
|
| 1096 |
+
f2 = MIMOFeedback(tfm_2, tfm_1, 1)
|
| 1097 |
+
assert f2.args == (tfm_2, tfm_1, 1)
|
| 1098 |
+
assert f2.sys1 == tfm_2
|
| 1099 |
+
assert f2.sys2 == tfm_1
|
| 1100 |
+
assert f2.var == s
|
| 1101 |
+
assert f2.sign == 1
|
| 1102 |
+
|
| 1103 |
+
f3 = MIMOFeedback(tfm_1, MIMOSeries(tfm_3, tfm_2))
|
| 1104 |
+
assert f3.args == (tfm_1, MIMOSeries(tfm_3, tfm_2), -1)
|
| 1105 |
+
assert f3.sys1 == tfm_1
|
| 1106 |
+
assert f3.sys2 == MIMOSeries(tfm_3, tfm_2)
|
| 1107 |
+
assert f3.var == s
|
| 1108 |
+
assert f3.sign == -1
|
| 1109 |
+
|
| 1110 |
+
mat = Matrix([[1, 1/s], [0, 1]])
|
| 1111 |
+
sys1 = controller = TransferFunctionMatrix.from_Matrix(mat, s)
|
| 1112 |
+
f4 = MIMOFeedback(sys1, controller)
|
| 1113 |
+
assert f4.args == (sys1, controller, -1)
|
| 1114 |
+
assert f4.sys1 == f4.sys2 == sys1
|
| 1115 |
+
|
| 1116 |
+
|
| 1117 |
+
def test_MIMOFeedback_errors():
|
| 1118 |
+
tf1 = TransferFunction(1, s, s)
|
| 1119 |
+
tf2 = TransferFunction(s, s**3 - 1, s)
|
| 1120 |
+
tf3 = TransferFunction(s, s - 1, s)
|
| 1121 |
+
tf4 = TransferFunction(s, s**2 + 1, s)
|
| 1122 |
+
tf5 = TransferFunction(1, 1, s)
|
| 1123 |
+
tf6 = TransferFunction(-1, s - 1, s)
|
| 1124 |
+
|
| 1125 |
+
tfm_1 = TransferFunctionMatrix([[tf1, tf2], [tf3, tf4]])
|
| 1126 |
+
tfm_2 = TransferFunctionMatrix([[tf2, tf3], [tf4, tf1]])
|
| 1127 |
+
tfm_3 = TransferFunctionMatrix.from_Matrix(eye(2), var=s)
|
| 1128 |
+
tfm_4 = TransferFunctionMatrix([[tf1, tf5], [tf5, tf5]])
|
| 1129 |
+
tfm_5 = TransferFunctionMatrix([[-tf3, tf3], [tf3, tf6]])
|
| 1130 |
+
# tfm_4 is inverse of tfm_5. Therefore tfm_5*tfm_4 = I
|
| 1131 |
+
tfm_6 = TransferFunctionMatrix([[-tf3]])
|
| 1132 |
+
tfm_7 = TransferFunctionMatrix([[tf3, tf4]])
|
| 1133 |
+
|
| 1134 |
+
# Unsupported Types
|
| 1135 |
+
raises(TypeError, lambda: MIMOFeedback(tf1, tf2))
|
| 1136 |
+
raises(TypeError, lambda: MIMOFeedback(MIMOParallel(tfm_1, tfm_2), tfm_3))
|
| 1137 |
+
# Shape Errors
|
| 1138 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_1, tfm_6, 1))
|
| 1139 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_7, tfm_7))
|
| 1140 |
+
# sign not 1/-1
|
| 1141 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_1, tfm_2, -2))
|
| 1142 |
+
# Non-Invertible Systems
|
| 1143 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_5, tfm_4, 1))
|
| 1144 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_4, -tfm_5))
|
| 1145 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_3, tfm_3, 1))
|
| 1146 |
+
# Variable not same in both the systems
|
| 1147 |
+
tfm_8 = TransferFunctionMatrix.from_Matrix(eye(2), var=p)
|
| 1148 |
+
raises(ValueError, lambda: MIMOFeedback(tfm_1, tfm_8, 1))
|
| 1149 |
+
|
| 1150 |
+
|
| 1151 |
+
def test_MIMOFeedback_functions():
|
| 1152 |
+
tf1 = TransferFunction(1, s, s)
|
| 1153 |
+
tf2 = TransferFunction(s, s - 1, s)
|
| 1154 |
+
tf3 = TransferFunction(1, 1, s)
|
| 1155 |
+
tf4 = TransferFunction(-1, s - 1, s)
|
| 1156 |
+
|
| 1157 |
+
tfm_1 = TransferFunctionMatrix.from_Matrix(eye(2), var=s)
|
| 1158 |
+
tfm_2 = TransferFunctionMatrix([[tf1, tf3], [tf3, tf3]])
|
| 1159 |
+
tfm_3 = TransferFunctionMatrix([[-tf2, tf2], [tf2, tf4]])
|
| 1160 |
+
tfm_4 = TransferFunctionMatrix([[tf1, tf2], [-tf2, tf1]])
|
| 1161 |
+
|
| 1162 |
+
# sensitivity, doit(), rewrite()
|
| 1163 |
+
F_1 = MIMOFeedback(tfm_2, tfm_3)
|
| 1164 |
+
F_2 = MIMOFeedback(tfm_2, MIMOSeries(tfm_4, -tfm_1), 1)
|
| 1165 |
+
|
| 1166 |
+
assert F_1.sensitivity == Matrix([[S.Half, 0], [0, S.Half]])
|
| 1167 |
+
assert F_2.sensitivity == Matrix([[(-2*s**4 + s**2)/(s**2 - s + 1),
|
| 1168 |
+
(2*s**3 - s**2)/(s**2 - s + 1)], [-s**2, s]])
|
| 1169 |
+
|
| 1170 |
+
assert F_1.doit() == \
|
| 1171 |
+
TransferFunctionMatrix(((TransferFunction(1, 2*s, s),
|
| 1172 |
+
TransferFunction(1, 2, s)), (TransferFunction(1, 2, s),
|
| 1173 |
+
TransferFunction(1, 2, s)))) == F_1.rewrite(TransferFunctionMatrix)
|
| 1174 |
+
assert F_2.doit(cancel=False, expand=True) == \
|
| 1175 |
+
TransferFunctionMatrix(((TransferFunction(-s**5 + 2*s**4 - 2*s**3 + s**2, s**5 - 2*s**4 + 3*s**3 - 2*s**2 + s, s),
|
| 1176 |
+
TransferFunction(-2*s**4 + 2*s**3, s**2 - s + 1, s)), (TransferFunction(0, 1, s), TransferFunction(-s**2 + s, 1, s))))
|
| 1177 |
+
assert F_2.doit(cancel=False) == \
|
| 1178 |
+
TransferFunctionMatrix(((TransferFunction(s*(2*s**3 - s**2)*(s**2 - s + 1) + \
|
| 1179 |
+
(-2*s**4 + s**2)*(s**2 - s + 1), s*(s**2 - s + 1)**2, s), TransferFunction(-2*s**4 + 2*s**3, s**2 - s + 1, s)),
|
| 1180 |
+
(TransferFunction(0, 1, s), TransferFunction(-s**2 + s, 1, s))))
|
| 1181 |
+
assert F_2.doit() == \
|
| 1182 |
+
TransferFunctionMatrix(((TransferFunction(s*(-2*s**2 + s*(2*s - 1) + 1), s**2 - s + 1, s),
|
| 1183 |
+
TransferFunction(-2*s**3*(s - 1), s**2 - s + 1, s)), (TransferFunction(0, 1, s), TransferFunction(s*(1 - s), 1, s))))
|
| 1184 |
+
assert F_2.doit(expand=True) == \
|
| 1185 |
+
TransferFunctionMatrix(((TransferFunction(-s**2 + s, s**2 - s + 1, s), TransferFunction(-2*s**4 + 2*s**3, s**2 - s + 1, s)),
|
| 1186 |
+
(TransferFunction(0, 1, s), TransferFunction(-s**2 + s, 1, s))))
|
| 1187 |
+
|
| 1188 |
+
assert -(F_1.doit()) == (-F_1).doit() # First negating then calculating vs calculating then negating.
|
| 1189 |
+
|
| 1190 |
+
|
| 1191 |
+
def test_TransferFunctionMatrix_construction():
|
| 1192 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 1193 |
+
tf4 = TransferFunction(a0*p + p**a1 - s, p, p)
|
| 1194 |
+
|
| 1195 |
+
tfm3_ = TransferFunctionMatrix([[-TF3]])
|
| 1196 |
+
assert tfm3_.shape == (tfm3_.num_outputs, tfm3_.num_inputs) == (1, 1)
|
| 1197 |
+
assert tfm3_.args == Tuple(Tuple(Tuple(-TF3)))
|
| 1198 |
+
assert tfm3_.var == s
|
| 1199 |
+
|
| 1200 |
+
tfm5 = TransferFunctionMatrix([[TF1, -TF2], [TF3, tf5]])
|
| 1201 |
+
assert tfm5.shape == (tfm5.num_outputs, tfm5.num_inputs) == (2, 2)
|
| 1202 |
+
assert tfm5.args == Tuple(Tuple(Tuple(TF1, -TF2), Tuple(TF3, tf5)))
|
| 1203 |
+
assert tfm5.var == s
|
| 1204 |
+
|
| 1205 |
+
tfm7 = TransferFunctionMatrix([[TF1, TF2], [TF3, -tf5], [-tf5, TF2]])
|
| 1206 |
+
assert tfm7.shape == (tfm7.num_outputs, tfm7.num_inputs) == (3, 2)
|
| 1207 |
+
assert tfm7.args == Tuple(Tuple(Tuple(TF1, TF2), Tuple(TF3, -tf5), Tuple(-tf5, TF2)))
|
| 1208 |
+
assert tfm7.var == s
|
| 1209 |
+
|
| 1210 |
+
# all transfer functions will use the same complex variable. tf4 uses 'p'.
|
| 1211 |
+
raises(ValueError, lambda: TransferFunctionMatrix([[TF1], [TF2], [tf4]]))
|
| 1212 |
+
raises(ValueError, lambda: TransferFunctionMatrix([[TF1, tf4], [TF3, tf5]]))
|
| 1213 |
+
|
| 1214 |
+
# length of all the lists in the TFM should be equal.
|
| 1215 |
+
raises(ValueError, lambda: TransferFunctionMatrix([[TF1], [TF3, tf5]]))
|
| 1216 |
+
raises(ValueError, lambda: TransferFunctionMatrix([[TF1, TF3], [tf5]]))
|
| 1217 |
+
|
| 1218 |
+
# lists should only support transfer functions in them.
|
| 1219 |
+
raises(TypeError, lambda: TransferFunctionMatrix([[TF1, TF2], [TF3, Matrix([1, 2])]]))
|
| 1220 |
+
raises(TypeError, lambda: TransferFunctionMatrix([[TF1, Matrix([1, 2])], [TF3, TF2]]))
|
| 1221 |
+
|
| 1222 |
+
# `arg` should strictly be nested list of TransferFunction
|
| 1223 |
+
raises(ValueError, lambda: TransferFunctionMatrix([TF1, TF2, tf5]))
|
| 1224 |
+
raises(ValueError, lambda: TransferFunctionMatrix([TF1]))
|
| 1225 |
+
|
| 1226 |
+
def test_TransferFunctionMatrix_functions():
|
| 1227 |
+
tf5 = TransferFunction(a1*s**2 + a2*s - a0, s + a0, s)
|
| 1228 |
+
|
| 1229 |
+
# Classmethod (from_matrix)
|
| 1230 |
+
|
| 1231 |
+
mat_1 = ImmutableMatrix([
|
| 1232 |
+
[s*(s + 1)*(s - 3)/(s**4 + 1), 2],
|
| 1233 |
+
[p, p*(s + 1)/(s*(s**1 + 1))]
|
| 1234 |
+
])
|
| 1235 |
+
mat_2 = ImmutableMatrix([[(2*s + 1)/(s**2 - 9)]])
|
| 1236 |
+
mat_3 = ImmutableMatrix([[1, 2], [3, 4]])
|
| 1237 |
+
assert TransferFunctionMatrix.from_Matrix(mat_1, s) == \
|
| 1238 |
+
TransferFunctionMatrix([[TransferFunction(s*(s - 3)*(s + 1), s**4 + 1, s), TransferFunction(2, 1, s)],
|
| 1239 |
+
[TransferFunction(p, 1, s), TransferFunction(p, s, s)]])
|
| 1240 |
+
assert TransferFunctionMatrix.from_Matrix(mat_2, s) == \
|
| 1241 |
+
TransferFunctionMatrix([[TransferFunction(2*s + 1, s**2 - 9, s)]])
|
| 1242 |
+
assert TransferFunctionMatrix.from_Matrix(mat_3, p) == \
|
| 1243 |
+
TransferFunctionMatrix([[TransferFunction(1, 1, p), TransferFunction(2, 1, p)],
|
| 1244 |
+
[TransferFunction(3, 1, p), TransferFunction(4, 1, p)]])
|
| 1245 |
+
|
| 1246 |
+
# Negating a TFM
|
| 1247 |
+
|
| 1248 |
+
tfm1 = TransferFunctionMatrix([[TF1], [TF2]])
|
| 1249 |
+
assert -tfm1 == TransferFunctionMatrix([[-TF1], [-TF2]])
|
| 1250 |
+
|
| 1251 |
+
tfm2 = TransferFunctionMatrix([[TF1, TF2, TF3], [tf5, -TF1, -TF3]])
|
| 1252 |
+
assert -tfm2 == TransferFunctionMatrix([[-TF1, -TF2, -TF3], [-tf5, TF1, TF3]])
|
| 1253 |
+
|
| 1254 |
+
# subs()
|
| 1255 |
+
|
| 1256 |
+
H_1 = TransferFunctionMatrix.from_Matrix(mat_1, s)
|
| 1257 |
+
H_2 = TransferFunctionMatrix([[TransferFunction(a*p*s, k*s**2, s), TransferFunction(p*s, k*(s**2 - a), s)]])
|
| 1258 |
+
assert H_1.subs(p, 1) == TransferFunctionMatrix([[TransferFunction(s*(s - 3)*(s + 1), s**4 + 1, s), TransferFunction(2, 1, s)], [TransferFunction(1, 1, s), TransferFunction(1, s, s)]])
|
| 1259 |
+
assert H_1.subs({p: 1}) == TransferFunctionMatrix([[TransferFunction(s*(s - 3)*(s + 1), s**4 + 1, s), TransferFunction(2, 1, s)], [TransferFunction(1, 1, s), TransferFunction(1, s, s)]])
|
| 1260 |
+
assert H_1.subs({p: 1, s: 1}) == TransferFunctionMatrix([[TransferFunction(s*(s - 3)*(s + 1), s**4 + 1, s), TransferFunction(2, 1, s)], [TransferFunction(1, 1, s), TransferFunction(1, s, s)]]) # This should ignore `s` as it is `var`
|
| 1261 |
+
assert H_2.subs(p, 2) == TransferFunctionMatrix([[TransferFunction(2*a*s, k*s**2, s), TransferFunction(2*s, k*(-a + s**2), s)]])
|
| 1262 |
+
assert H_2.subs(k, 1) == TransferFunctionMatrix([[TransferFunction(a*p*s, s**2, s), TransferFunction(p*s, -a + s**2, s)]])
|
| 1263 |
+
assert H_2.subs(a, 0) == TransferFunctionMatrix([[TransferFunction(0, k*s**2, s), TransferFunction(p*s, k*s**2, s)]])
|
| 1264 |
+
assert H_2.subs({p: 1, k: 1, a: a0}) == TransferFunctionMatrix([[TransferFunction(a0*s, s**2, s), TransferFunction(s, -a0 + s**2, s)]])
|
| 1265 |
+
|
| 1266 |
+
# eval_frequency()
|
| 1267 |
+
assert H_2.eval_frequency(S(1)/2 + I) == Matrix([[2*a*p/(5*k) - 4*I*a*p/(5*k), I*p/(-a*k - 3*k/4 + I*k) + p/(-2*a*k - 3*k/2 + 2*I*k)]])
|
| 1268 |
+
|
| 1269 |
+
# transpose()
|
| 1270 |
+
|
| 1271 |
+
assert H_1.transpose() == TransferFunctionMatrix([[TransferFunction(s*(s - 3)*(s + 1), s**4 + 1, s), TransferFunction(p, 1, s)], [TransferFunction(2, 1, s), TransferFunction(p, s, s)]])
|
| 1272 |
+
assert H_2.transpose() == TransferFunctionMatrix([[TransferFunction(a*p*s, k*s**2, s)], [TransferFunction(p*s, k*(-a + s**2), s)]])
|
| 1273 |
+
assert H_1.transpose().transpose() == H_1
|
| 1274 |
+
assert H_2.transpose().transpose() == H_2
|
| 1275 |
+
|
| 1276 |
+
# elem_poles()
|
| 1277 |
+
|
| 1278 |
+
assert H_1.elem_poles() == [[[-sqrt(2)/2 - sqrt(2)*I/2, -sqrt(2)/2 + sqrt(2)*I/2, sqrt(2)/2 - sqrt(2)*I/2, sqrt(2)/2 + sqrt(2)*I/2], []],
|
| 1279 |
+
[[], [0]]]
|
| 1280 |
+
assert H_2.elem_poles() == [[[0, 0], [sqrt(a), -sqrt(a)]]]
|
| 1281 |
+
assert tfm2.elem_poles() == [[[wn*(-zeta + sqrt((zeta - 1)*(zeta + 1))), wn*(-zeta - sqrt((zeta - 1)*(zeta + 1)))], [], [-p/a2]],
|
| 1282 |
+
[[-a0], [wn*(-zeta + sqrt((zeta - 1)*(zeta + 1))), wn*(-zeta - sqrt((zeta - 1)*(zeta + 1)))], [-p/a2]]]
|
| 1283 |
+
|
| 1284 |
+
# elem_zeros()
|
| 1285 |
+
|
| 1286 |
+
assert H_1.elem_zeros() == [[[-1, 0, 3], []], [[], []]]
|
| 1287 |
+
assert H_2.elem_zeros() == [[[0], [0]]]
|
| 1288 |
+
assert tfm2.elem_zeros() == [[[], [], [a2*p]],
|
| 1289 |
+
[[-a2/(2*a1) - sqrt(4*a0*a1 + a2**2)/(2*a1), -a2/(2*a1) + sqrt(4*a0*a1 + a2**2)/(2*a1)], [], [a2*p]]]
|
| 1290 |
+
|
| 1291 |
+
# doit()
|
| 1292 |
+
|
| 1293 |
+
H_3 = TransferFunctionMatrix([[Series(TransferFunction(1, s**3 - 3, s), TransferFunction(s**2 - 2*s + 5, 1, s), TransferFunction(1, s, s))]])
|
| 1294 |
+
H_4 = TransferFunctionMatrix([[Parallel(TransferFunction(s**3 - 3, 4*s**4 - s**2 - 2*s + 5, s), TransferFunction(4 - s**3, 4*s**4 - s**2 - 2*s + 5, s))]])
|
| 1295 |
+
|
| 1296 |
+
assert H_3.doit() == TransferFunctionMatrix([[TransferFunction(s**2 - 2*s + 5, s*(s**3 - 3), s)]])
|
| 1297 |
+
assert H_4.doit() == TransferFunctionMatrix([[TransferFunction(1, 4*s**4 - s**2 - 2*s + 5, s)]])
|
| 1298 |
+
|
| 1299 |
+
# _flat()
|
| 1300 |
+
|
| 1301 |
+
assert H_1._flat() == [TransferFunction(s*(s - 3)*(s + 1), s**4 + 1, s), TransferFunction(2, 1, s), TransferFunction(p, 1, s), TransferFunction(p, s, s)]
|
| 1302 |
+
assert H_2._flat() == [TransferFunction(a*p*s, k*s**2, s), TransferFunction(p*s, k*(-a + s**2), s)]
|
| 1303 |
+
assert H_3._flat() == [Series(TransferFunction(1, s**3 - 3, s), TransferFunction(s**2 - 2*s + 5, 1, s), TransferFunction(1, s, s))]
|
| 1304 |
+
assert H_4._flat() == [Parallel(TransferFunction(s**3 - 3, 4*s**4 - s**2 - 2*s + 5, s), TransferFunction(4 - s**3, 4*s**4 - s**2 - 2*s + 5, s))]
|
| 1305 |
+
|
| 1306 |
+
# evalf()
|
| 1307 |
+
|
| 1308 |
+
assert H_1.evalf() == \
|
| 1309 |
+
TransferFunctionMatrix(((TransferFunction(s*(s - 3.0)*(s + 1.0), s**4 + 1.0, s), TransferFunction(2.0, 1, s)), (TransferFunction(1.0*p, 1, s), TransferFunction(p, s, s))))
|
| 1310 |
+
assert H_2.subs({a:3.141, p:2.88, k:2}).evalf() == \
|
| 1311 |
+
TransferFunctionMatrix(((TransferFunction(4.5230399999999999494093572138808667659759521484375, s, s),
|
| 1312 |
+
TransferFunction(2.87999999999999989341858963598497211933135986328125*s, 2.0*s**2 - 6.282000000000000028421709430404007434844970703125, s)),))
|
| 1313 |
+
|
| 1314 |
+
# simplify()
|
| 1315 |
+
|
| 1316 |
+
H_5 = TransferFunctionMatrix([[TransferFunction(s**5 + s**3 + s, s - s**2, s),
|
| 1317 |
+
TransferFunction((s + 3)*(s - 1), (s - 1)*(s + 5), s)]])
|
| 1318 |
+
|
| 1319 |
+
assert H_5.simplify() == simplify(H_5) == \
|
| 1320 |
+
TransferFunctionMatrix(((TransferFunction(-s**4 - s**2 - 1, s - 1, s), TransferFunction(s + 3, s + 5, s)),))
|
| 1321 |
+
|
| 1322 |
+
# expand()
|
| 1323 |
+
|
| 1324 |
+
assert (H_1.expand()
|
| 1325 |
+
== TransferFunctionMatrix(((TransferFunction(s**3 - 2*s**2 - 3*s, s**4 + 1, s), TransferFunction(2, 1, s)),
|
| 1326 |
+
(TransferFunction(p, 1, s), TransferFunction(p, s, s)))))
|
| 1327 |
+
assert H_5.expand() == \
|
| 1328 |
+
TransferFunctionMatrix(((TransferFunction(s**5 + s**3 + s, -s**2 + s, s), TransferFunction(s**2 + 2*s - 3, s**2 + 4*s - 5, s)),))
|
| 1329 |
+
|
| 1330 |
+
def test_TransferFunction_gbt():
|
| 1331 |
+
# simple transfer function, e.g. ohms law
|
| 1332 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1333 |
+
numZ, denZ = gbt(tf, T, 0.5)
|
| 1334 |
+
# discretized transfer function with coefs from tf.gbt()
|
| 1335 |
+
tf_test_bilinear = TransferFunction(s * numZ[0] + numZ[1], s * denZ[0] + denZ[1], s)
|
| 1336 |
+
# corresponding tf with manually calculated coefs
|
| 1337 |
+
tf_test_manual = TransferFunction(s * T/(2*(a + b*T/2)) + T/(2*(a + b*T/2)), s + (-a + b*T/2)/(a + b*T/2), s)
|
| 1338 |
+
|
| 1339 |
+
assert S.Zero == (tf_test_bilinear.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1340 |
+
|
| 1341 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1342 |
+
numZ, denZ = gbt(tf, T, 0)
|
| 1343 |
+
# discretized transfer function with coefs from tf.gbt()
|
| 1344 |
+
tf_test_forward = TransferFunction(numZ[0], s*denZ[0]+denZ[1], s)
|
| 1345 |
+
# corresponding tf with manually calculated coefs
|
| 1346 |
+
tf_test_manual = TransferFunction(T/a, s + (-a + b*T)/a, s)
|
| 1347 |
+
|
| 1348 |
+
assert S.Zero == (tf_test_forward.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1349 |
+
|
| 1350 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1351 |
+
numZ, denZ = gbt(tf, T, 1)
|
| 1352 |
+
# discretized transfer function with coefs from tf.gbt()
|
| 1353 |
+
tf_test_backward = TransferFunction(s*numZ[0], s*denZ[0]+denZ[1], s)
|
| 1354 |
+
# corresponding tf with manually calculated coefs
|
| 1355 |
+
tf_test_manual = TransferFunction(s * T/(a + b*T), s - a/(a + b*T), s)
|
| 1356 |
+
|
| 1357 |
+
assert S.Zero == (tf_test_backward.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1358 |
+
|
| 1359 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1360 |
+
numZ, denZ = gbt(tf, T, 0.3)
|
| 1361 |
+
# discretized transfer function with coefs from tf.gbt()
|
| 1362 |
+
tf_test_gbt = TransferFunction(s*numZ[0]+numZ[1], s*denZ[0]+denZ[1], s)
|
| 1363 |
+
# corresponding tf with manually calculated coefs
|
| 1364 |
+
tf_test_manual = TransferFunction(s*3*T/(10*(a + 3*b*T/10)) + 7*T/(10*(a + 3*b*T/10)), s + (-a + 7*b*T/10)/(a + 3*b*T/10), s)
|
| 1365 |
+
|
| 1366 |
+
assert S.Zero == (tf_test_gbt.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1367 |
+
|
| 1368 |
+
def test_TransferFunction_bilinear():
|
| 1369 |
+
# simple transfer function, e.g. ohms law
|
| 1370 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1371 |
+
numZ, denZ = bilinear(tf, T)
|
| 1372 |
+
# discretized transfer function with coefs from tf.bilinear()
|
| 1373 |
+
tf_test_bilinear = TransferFunction(s*numZ[0]+numZ[1], s*denZ[0]+denZ[1], s)
|
| 1374 |
+
# corresponding tf with manually calculated coefs
|
| 1375 |
+
tf_test_manual = TransferFunction(s * T/(2*(a + b*T/2)) + T/(2*(a + b*T/2)), s + (-a + b*T/2)/(a + b*T/2), s)
|
| 1376 |
+
|
| 1377 |
+
assert S.Zero == (tf_test_bilinear.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1378 |
+
|
| 1379 |
+
def test_TransferFunction_forward_diff():
|
| 1380 |
+
# simple transfer function, e.g. ohms law
|
| 1381 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1382 |
+
numZ, denZ = forward_diff(tf, T)
|
| 1383 |
+
# discretized transfer function with coefs from tf.forward_diff()
|
| 1384 |
+
tf_test_forward = TransferFunction(numZ[0], s*denZ[0]+denZ[1], s)
|
| 1385 |
+
# corresponding tf with manually calculated coefs
|
| 1386 |
+
tf_test_manual = TransferFunction(T/a, s + (-a + b*T)/a, s)
|
| 1387 |
+
|
| 1388 |
+
assert S.Zero == (tf_test_forward.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1389 |
+
|
| 1390 |
+
def test_TransferFunction_backward_diff():
|
| 1391 |
+
# simple transfer function, e.g. ohms law
|
| 1392 |
+
tf = TransferFunction(1, a*s+b, s)
|
| 1393 |
+
numZ, denZ = backward_diff(tf, T)
|
| 1394 |
+
# discretized transfer function with coefs from tf.backward_diff()
|
| 1395 |
+
tf_test_backward = TransferFunction(s*numZ[0]+numZ[1], s*denZ[0]+denZ[1], s)
|
| 1396 |
+
# corresponding tf with manually calculated coefs
|
| 1397 |
+
tf_test_manual = TransferFunction(s * T/(a + b*T), s - a/(a + b*T), s)
|
| 1398 |
+
|
| 1399 |
+
assert S.Zero == (tf_test_backward.simplify()-tf_test_manual.simplify()).simplify().num
|
| 1400 |
+
|
| 1401 |
+
def test_TransferFunction_phase_margin():
|
| 1402 |
+
# Test for phase margin
|
| 1403 |
+
tf1 = TransferFunction(10, p**3 + 1, p)
|
| 1404 |
+
tf2 = TransferFunction(s**2, 10, s)
|
| 1405 |
+
tf3 = TransferFunction(1, a*s+b, s)
|
| 1406 |
+
tf4 = TransferFunction((s + 1)*exp(s/tau), s**2 + 2, s)
|
| 1407 |
+
tf_m = TransferFunctionMatrix([[tf2],[tf3]])
|
| 1408 |
+
|
| 1409 |
+
assert phase_margin(tf1) == -180 + 180*atan(3*sqrt(11))/pi
|
| 1410 |
+
assert phase_margin(tf2) == 0
|
| 1411 |
+
|
| 1412 |
+
raises(NotImplementedError, lambda: phase_margin(tf4))
|
| 1413 |
+
raises(ValueError, lambda: phase_margin(tf3))
|
| 1414 |
+
raises(ValueError, lambda: phase_margin(MIMOSeries(tf_m)))
|
| 1415 |
+
|
| 1416 |
+
def test_TransferFunction_gain_margin():
|
| 1417 |
+
# Test for gain margin
|
| 1418 |
+
tf1 = TransferFunction(s**2, 5*(s+1)*(s-5)*(s-10), s)
|
| 1419 |
+
tf2 = TransferFunction(s**2 + 2*s + 1, 1, s)
|
| 1420 |
+
tf3 = TransferFunction(1, a*s+b, s)
|
| 1421 |
+
tf4 = TransferFunction((s + 1)*exp(s/tau), s**2 + 2, s)
|
| 1422 |
+
tf_m = TransferFunctionMatrix([[tf2],[tf3]])
|
| 1423 |
+
|
| 1424 |
+
assert gain_margin(tf1) == -20*log(S(7)/540)/log(10)
|
| 1425 |
+
assert gain_margin(tf2) == oo
|
| 1426 |
+
|
| 1427 |
+
raises(NotImplementedError, lambda: gain_margin(tf4))
|
| 1428 |
+
raises(ValueError, lambda: gain_margin(tf3))
|
| 1429 |
+
raises(ValueError, lambda: gain_margin(MIMOSeries(tf_m)))
|
| 1430 |
+
|
| 1431 |
+
|
| 1432 |
+
def test_StateSpace_construction():
|
| 1433 |
+
# using different numbers for a SISO system.
|
| 1434 |
+
A1 = Matrix([[0, 1], [1, 0]])
|
| 1435 |
+
B1 = Matrix([1, 0])
|
| 1436 |
+
C1 = Matrix([[0, 1]])
|
| 1437 |
+
D1 = Matrix([0])
|
| 1438 |
+
ss1 = StateSpace(A1, B1, C1, D1)
|
| 1439 |
+
|
| 1440 |
+
assert ss1.state_matrix == Matrix([[0, 1], [1, 0]])
|
| 1441 |
+
assert ss1.input_matrix == Matrix([1, 0])
|
| 1442 |
+
assert ss1.output_matrix == Matrix([[0, 1]])
|
| 1443 |
+
assert ss1.feedforward_matrix == Matrix([0])
|
| 1444 |
+
assert ss1.args == (Matrix([[0, 1], [1, 0]]), Matrix([[1], [0]]), Matrix([[0, 1]]), Matrix([[0]]))
|
| 1445 |
+
|
| 1446 |
+
# using different symbols for a SISO system.
|
| 1447 |
+
ss2 = StateSpace(Matrix([a0]), Matrix([a1]),
|
| 1448 |
+
Matrix([a2]), Matrix([a3]))
|
| 1449 |
+
|
| 1450 |
+
assert ss2.state_matrix == Matrix([[a0]])
|
| 1451 |
+
assert ss2.input_matrix == Matrix([[a1]])
|
| 1452 |
+
assert ss2.output_matrix == Matrix([[a2]])
|
| 1453 |
+
assert ss2.feedforward_matrix == Matrix([[a3]])
|
| 1454 |
+
assert ss2.args == (Matrix([[a0]]), Matrix([[a1]]), Matrix([[a2]]), Matrix([[a3]]))
|
| 1455 |
+
|
| 1456 |
+
# using different numbers for a MIMO system.
|
| 1457 |
+
ss3 = StateSpace(Matrix([[-1.5, -2], [1, 0]]),
|
| 1458 |
+
Matrix([[0.5, 0], [0, 1]]),
|
| 1459 |
+
Matrix([[0, 1], [0, 2]]),
|
| 1460 |
+
Matrix([[2, 2], [1, 1]]))
|
| 1461 |
+
|
| 1462 |
+
assert ss3.state_matrix == Matrix([[-1.5, -2], [1, 0]])
|
| 1463 |
+
assert ss3.input_matrix == Matrix([[0.5, 0], [0, 1]])
|
| 1464 |
+
assert ss3.output_matrix == Matrix([[0, 1], [0, 2]])
|
| 1465 |
+
assert ss3.feedforward_matrix == Matrix([[2, 2], [1, 1]])
|
| 1466 |
+
assert ss3.args == (Matrix([[-1.5, -2],
|
| 1467 |
+
[1, 0]]),
|
| 1468 |
+
Matrix([[0.5, 0],
|
| 1469 |
+
[0, 1]]),
|
| 1470 |
+
Matrix([[0, 1],
|
| 1471 |
+
[0, 2]]),
|
| 1472 |
+
Matrix([[2, 2],
|
| 1473 |
+
[1, 1]]))
|
| 1474 |
+
|
| 1475 |
+
# using different symbols for a MIMO system.
|
| 1476 |
+
A4 = Matrix([[a0, a1], [a2, a3]])
|
| 1477 |
+
B4 = Matrix([[b0, b1], [b2, b3]])
|
| 1478 |
+
C4 = Matrix([[c0, c1], [c2, c3]])
|
| 1479 |
+
D4 = Matrix([[d0, d1], [d2, d3]])
|
| 1480 |
+
ss4 = StateSpace(A4, B4, C4, D4)
|
| 1481 |
+
|
| 1482 |
+
assert ss4.state_matrix == Matrix([[a0, a1], [a2, a3]])
|
| 1483 |
+
assert ss4.input_matrix == Matrix([[b0, b1], [b2, b3]])
|
| 1484 |
+
assert ss4.output_matrix == Matrix([[c0, c1], [c2, c3]])
|
| 1485 |
+
assert ss4.feedforward_matrix == Matrix([[d0, d1], [d2, d3]])
|
| 1486 |
+
assert ss4.args == (Matrix([[a0, a1],
|
| 1487 |
+
[a2, a3]]),
|
| 1488 |
+
Matrix([[b0, b1],
|
| 1489 |
+
[b2, b3]]),
|
| 1490 |
+
Matrix([[c0, c1],
|
| 1491 |
+
[c2, c3]]),
|
| 1492 |
+
Matrix([[d0, d1],
|
| 1493 |
+
[d2, d3]]))
|
| 1494 |
+
|
| 1495 |
+
# using less matrices. Rest will be filled with a minimum of zeros.
|
| 1496 |
+
ss5 = StateSpace()
|
| 1497 |
+
assert ss5.args == (Matrix([[0]]), Matrix([[0]]), Matrix([[0]]), Matrix([[0]]))
|
| 1498 |
+
|
| 1499 |
+
A6 = Matrix([[0, 1], [1, 0]])
|
| 1500 |
+
B6 = Matrix([1, 1])
|
| 1501 |
+
ss6 = StateSpace(A6, B6)
|
| 1502 |
+
|
| 1503 |
+
assert ss6.state_matrix == Matrix([[0, 1], [1, 0]])
|
| 1504 |
+
assert ss6.input_matrix == Matrix([1, 1])
|
| 1505 |
+
assert ss6.output_matrix == Matrix([[0, 0]])
|
| 1506 |
+
assert ss6.feedforward_matrix == Matrix([[0]])
|
| 1507 |
+
assert ss6.args == (Matrix([[0, 1],
|
| 1508 |
+
[1, 0]]),
|
| 1509 |
+
Matrix([[1],
|
| 1510 |
+
[1]]),
|
| 1511 |
+
Matrix([[0, 0]]),
|
| 1512 |
+
Matrix([[0]]))
|
| 1513 |
+
|
| 1514 |
+
# Check if the system is SISO or MIMO.
|
| 1515 |
+
# If system is not SISO, then it is definitely MIMO.
|
| 1516 |
+
|
| 1517 |
+
assert ss1.is_SISO == True
|
| 1518 |
+
assert ss2.is_SISO == True
|
| 1519 |
+
assert ss3.is_SISO == False
|
| 1520 |
+
assert ss4.is_SISO == False
|
| 1521 |
+
assert ss5.is_SISO == True
|
| 1522 |
+
assert ss6.is_SISO == True
|
| 1523 |
+
|
| 1524 |
+
# ShapeError if matrices do not fit.
|
| 1525 |
+
raises(ShapeError, lambda: StateSpace(Matrix([s, (s+1)**2]), Matrix([s+1]),
|
| 1526 |
+
Matrix([s**2 - 1]), Matrix([2*s])))
|
| 1527 |
+
raises(ShapeError, lambda: StateSpace(Matrix([s]), Matrix([s+1, s**3 + 1]),
|
| 1528 |
+
Matrix([s**2 - 1]), Matrix([2*s])))
|
| 1529 |
+
raises(ShapeError, lambda: StateSpace(Matrix([s]), Matrix([s+1]),
|
| 1530 |
+
Matrix([[s**2 - 1], [s**2 + 2*s + 1]]), Matrix([2*s])))
|
| 1531 |
+
raises(ShapeError, lambda: StateSpace(Matrix([[-s, -s], [s, 0]]),
|
| 1532 |
+
Matrix([[s/2, 0], [0, s]]),
|
| 1533 |
+
Matrix([[0, s]]),
|
| 1534 |
+
Matrix([[2*s, 2*s], [s, s]])))
|
| 1535 |
+
|
| 1536 |
+
# TypeError if arguments are not sympy matrices.
|
| 1537 |
+
raises(TypeError, lambda: StateSpace(s**2, s+1, 2*s, 1))
|
| 1538 |
+
raises(TypeError, lambda: StateSpace(Matrix([2, 0.5]), Matrix([-1]),
|
| 1539 |
+
Matrix([1]), 0))
|
| 1540 |
+
def test_StateSpace_add():
|
| 1541 |
+
A1 = Matrix([[4, 1],[2, -3]])
|
| 1542 |
+
B1 = Matrix([[5, 2],[-3, -3]])
|
| 1543 |
+
C1 = Matrix([[2, -4],[0, 1]])
|
| 1544 |
+
D1 = Matrix([[3, 2],[1, -1]])
|
| 1545 |
+
ss1 = StateSpace(A1, B1, C1, D1)
|
| 1546 |
+
|
| 1547 |
+
A2 = Matrix([[-3, 4, 2],[-1, -3, 0],[2, 5, 3]])
|
| 1548 |
+
B2 = Matrix([[1, 4],[-3, -3],[-2, 1]])
|
| 1549 |
+
C2 = Matrix([[4, 2, -3],[1, 4, 3]])
|
| 1550 |
+
D2 = Matrix([[-2, 4],[0, 1]])
|
| 1551 |
+
ss2 = StateSpace(A2, B2, C2, D2)
|
| 1552 |
+
ss3 = StateSpace()
|
| 1553 |
+
ss4 = StateSpace(Matrix([1]), Matrix([2]), Matrix([3]), Matrix([4]))
|
| 1554 |
+
|
| 1555 |
+
expected_add = \
|
| 1556 |
+
StateSpace(
|
| 1557 |
+
Matrix([
|
| 1558 |
+
[4, 1, 0, 0, 0],
|
| 1559 |
+
[2, -3, 0, 0, 0],
|
| 1560 |
+
[0, 0, -3, 4, 2],
|
| 1561 |
+
[0, 0, -1, -3, 0],
|
| 1562 |
+
[0, 0, 2, 5, 3]]),
|
| 1563 |
+
Matrix([
|
| 1564 |
+
[ 5, 2],
|
| 1565 |
+
[-3, -3],
|
| 1566 |
+
[ 1, 4],
|
| 1567 |
+
[-3, -3],
|
| 1568 |
+
[-2, 1]]),
|
| 1569 |
+
Matrix([
|
| 1570 |
+
[2, -4, 4, 2, -3],
|
| 1571 |
+
[0, 1, 1, 4, 3]]),
|
| 1572 |
+
Matrix([
|
| 1573 |
+
[1, 6],
|
| 1574 |
+
[1, 0]]))
|
| 1575 |
+
|
| 1576 |
+
expected_mul = \
|
| 1577 |
+
StateSpace(
|
| 1578 |
+
Matrix([
|
| 1579 |
+
[ -3, 4, 2, 0, 0],
|
| 1580 |
+
[ -1, -3, 0, 0, 0],
|
| 1581 |
+
[ 2, 5, 3, 0, 0],
|
| 1582 |
+
[ 22, 18, -9, 4, 1],
|
| 1583 |
+
[-15, -18, 0, 2, -3]]),
|
| 1584 |
+
Matrix([
|
| 1585 |
+
[ 1, 4],
|
| 1586 |
+
[ -3, -3],
|
| 1587 |
+
[ -2, 1],
|
| 1588 |
+
[-10, 22],
|
| 1589 |
+
[ 6, -15]]),
|
| 1590 |
+
Matrix([
|
| 1591 |
+
[14, 14, -3, 2, -4],
|
| 1592 |
+
[ 3, -2, -6, 0, 1]]),
|
| 1593 |
+
Matrix([
|
| 1594 |
+
[-6, 14],
|
| 1595 |
+
[-2, 3]]))
|
| 1596 |
+
|
| 1597 |
+
assert ss1 + ss2 == expected_add
|
| 1598 |
+
assert ss1*ss2 == expected_mul
|
| 1599 |
+
assert ss3 + 1/2 == StateSpace(Matrix([[0]]), Matrix([[0]]), Matrix([[0]]), Matrix([[0.5]]))
|
| 1600 |
+
assert ss4*1.5 == StateSpace(Matrix([[1]]), Matrix([[2]]), Matrix([[4.5]]), Matrix([[6.0]]))
|
| 1601 |
+
assert 1.5*ss4 == StateSpace(Matrix([[1]]), Matrix([[3.0]]), Matrix([[3]]), Matrix([[6.0]]))
|
| 1602 |
+
raises(ShapeError, lambda: ss1 + ss3)
|
| 1603 |
+
raises(ShapeError, lambda: ss2*ss4)
|
| 1604 |
+
|
| 1605 |
+
def test_StateSpace_negation():
|
| 1606 |
+
A = Matrix([[a0, a1], [a2, a3]])
|
| 1607 |
+
B = Matrix([[b0, b1], [b2, b3]])
|
| 1608 |
+
C = Matrix([[c0, c1], [c1, c2], [c2, c3]])
|
| 1609 |
+
D = Matrix([[d0, d1], [d1, d2], [d2, d3]])
|
| 1610 |
+
SS = StateSpace(A, B, C, D)
|
| 1611 |
+
SS_neg = -SS
|
| 1612 |
+
|
| 1613 |
+
state_mat = Matrix([[-1, 1], [1, -1]])
|
| 1614 |
+
input_mat = Matrix([1, -1])
|
| 1615 |
+
output_mat = Matrix([[-1, 1]])
|
| 1616 |
+
feedforward_mat = Matrix([1])
|
| 1617 |
+
system = StateSpace(state_mat, input_mat, output_mat, feedforward_mat)
|
| 1618 |
+
|
| 1619 |
+
assert SS_neg == \
|
| 1620 |
+
StateSpace(Matrix([[a0, a1],
|
| 1621 |
+
[a2, a3]]),
|
| 1622 |
+
Matrix([[b0, b1],
|
| 1623 |
+
[b2, b3]]),
|
| 1624 |
+
Matrix([[-c0, -c1],
|
| 1625 |
+
[-c1, -c2],
|
| 1626 |
+
[-c2, -c3]]),
|
| 1627 |
+
Matrix([[-d0, -d1],
|
| 1628 |
+
[-d1, -d2],
|
| 1629 |
+
[-d2, -d3]]))
|
| 1630 |
+
assert -system == \
|
| 1631 |
+
StateSpace(Matrix([[-1, 1],
|
| 1632 |
+
[ 1, -1]]),
|
| 1633 |
+
Matrix([[ 1],[-1]]),
|
| 1634 |
+
Matrix([[1, -1]]),
|
| 1635 |
+
Matrix([[-1]]))
|
| 1636 |
+
assert -SS_neg == SS
|
| 1637 |
+
assert -(-(-(-system))) == system
|
| 1638 |
+
|
| 1639 |
+
def test_SymPy_substitution_functions():
|
| 1640 |
+
# subs
|
| 1641 |
+
ss1 = StateSpace(Matrix([s]), Matrix([(s + 1)**2]), Matrix([s**2 - 1]), Matrix([2*s]))
|
| 1642 |
+
ss2 = StateSpace(Matrix([s + p]), Matrix([(s + 1)*(p - 1)]), Matrix([p**3 - s**3]), Matrix([s - p]))
|
| 1643 |
+
|
| 1644 |
+
assert ss1.subs({s:5}) == StateSpace(Matrix([[5]]), Matrix([[36]]), Matrix([[24]]), Matrix([[10]]))
|
| 1645 |
+
assert ss2.subs({p:1}) == StateSpace(Matrix([[s + 1]]), Matrix([[0]]), Matrix([[1 - s**3]]), Matrix([[s - 1]]))
|
| 1646 |
+
|
| 1647 |
+
# xreplace
|
| 1648 |
+
assert ss1.xreplace({s:p}) == \
|
| 1649 |
+
StateSpace(Matrix([[p]]), Matrix([[(p + 1)**2]]), Matrix([[p**2 - 1]]), Matrix([[2*p]]))
|
| 1650 |
+
assert ss2.xreplace({s:a, p:b}) == \
|
| 1651 |
+
StateSpace(Matrix([[a + b]]), Matrix([[(a + 1)*(b - 1)]]), Matrix([[-a**3 + b**3]]), Matrix([[a - b]]))
|
| 1652 |
+
|
| 1653 |
+
# evalf
|
| 1654 |
+
p1 = a1*s + a0
|
| 1655 |
+
p2 = b2*s**2 + b1*s + b0
|
| 1656 |
+
G = StateSpace(Matrix([p1]), Matrix([p2]))
|
| 1657 |
+
expect = StateSpace(Matrix([[2*s + 1]]), Matrix([[5*s**2 + 4*s + 3]]), Matrix([[0]]), Matrix([[0]]))
|
| 1658 |
+
expect_ = StateSpace(Matrix([[2.0*s + 1.0]]), Matrix([[5.0*s**2 + 4.0*s + 3.0]]), Matrix([[0]]), Matrix([[0]]))
|
| 1659 |
+
assert G.subs({a0: 1, a1: 2, b0: 3, b1: 4, b2: 5}) == expect
|
| 1660 |
+
assert G.subs({a0: 1, a1: 2, b0: 3, b1: 4, b2: 5}).evalf() == expect_
|
| 1661 |
+
assert expect.evalf() == expect_
|
| 1662 |
+
|
| 1663 |
+
def test_conversion():
|
| 1664 |
+
# StateSpace to TransferFunction for SISO
|
| 1665 |
+
A1 = Matrix([[-5, -1], [3, -1]])
|
| 1666 |
+
B1 = Matrix([2, 5])
|
| 1667 |
+
C1 = Matrix([[1, 2]])
|
| 1668 |
+
D1 = Matrix([0])
|
| 1669 |
+
H1 = StateSpace(A1, B1, C1, D1)
|
| 1670 |
+
tm1 = H1.rewrite(TransferFunction)
|
| 1671 |
+
tm2 = (-H1).rewrite(TransferFunction)
|
| 1672 |
+
|
| 1673 |
+
tf1 = tm1[0][0]
|
| 1674 |
+
tf2 = tm2[0][0]
|
| 1675 |
+
|
| 1676 |
+
assert tf1 == TransferFunction(12*s + 59, s**2 + 6*s + 8, s)
|
| 1677 |
+
assert tf2.num == -tf1.num
|
| 1678 |
+
assert tf2.den == tf1.den
|
| 1679 |
+
|
| 1680 |
+
# StateSpace to TransferFunction for MIMO
|
| 1681 |
+
A2 = Matrix([[-1.5, -2, 3], [1, 0, 1], [2, 1, 1]])
|
| 1682 |
+
B2 = Matrix([[0.5, 0, 1], [0, 1, 2], [2, 2, 3]])
|
| 1683 |
+
C2 = Matrix([[0, 1, 0], [0, 2, 1], [1, 0, 2]])
|
| 1684 |
+
D2 = Matrix([[2, 2, 0], [1, 1, 1], [3, 2, 1]])
|
| 1685 |
+
H2 = StateSpace(A2, B2, C2, D2)
|
| 1686 |
+
tm3 = H2.rewrite(TransferFunction)
|
| 1687 |
+
|
| 1688 |
+
# outputs for input i obtained at Index i-1. Consider input 1
|
| 1689 |
+
assert tm3[0][0] == TransferFunction(2.0*s**3 + 1.0*s**2 - 10.5*s + 4.5, 1.0*s**3 + 0.5*s**2 - 6.5*s - 2.5, s)
|
| 1690 |
+
assert tm3[0][1] == TransferFunction(2.0*s**3 + 2.0*s**2 - 10.5*s - 3.5, 1.0*s**3 + 0.5*s**2 - 6.5*s - 2.5, s)
|
| 1691 |
+
assert tm3[0][2] == TransferFunction(2.0*s**2 + 5.0*s - 0.5, 1.0*s**3 + 0.5*s**2 - 6.5*s - 2.5, s)
|
| 1692 |
+
|
| 1693 |
+
# TransferFunction to StateSpace
|
| 1694 |
+
SS = TF1.rewrite(StateSpace)
|
| 1695 |
+
assert SS == \
|
| 1696 |
+
StateSpace(Matrix([[ 0, 1],
|
| 1697 |
+
[-wn**2, -2*wn*zeta]]),
|
| 1698 |
+
Matrix([[0],
|
| 1699 |
+
[1]]),
|
| 1700 |
+
Matrix([[1, 0]]),
|
| 1701 |
+
Matrix([[0]]))
|
| 1702 |
+
assert SS.rewrite(TransferFunction)[0][0] == TF1
|
| 1703 |
+
|
| 1704 |
+
# Transfer function has to be proper
|
| 1705 |
+
raises(ValueError, lambda: TransferFunction(b*s**2 + p**2 - a*p + s, b - p**2, s).rewrite(StateSpace))
|
| 1706 |
+
|
| 1707 |
+
|
| 1708 |
+
def test_StateSpace_functions():
|
| 1709 |
+
# https://in.mathworks.com/help/control/ref/statespacemodel.obsv.html
|
| 1710 |
+
|
| 1711 |
+
A_mat = Matrix([[-1.5, -2], [1, 0]])
|
| 1712 |
+
B_mat = Matrix([0.5, 0])
|
| 1713 |
+
C_mat = Matrix([[0, 1]])
|
| 1714 |
+
D_mat = Matrix([1])
|
| 1715 |
+
SS1 = StateSpace(A_mat, B_mat, C_mat, D_mat)
|
| 1716 |
+
SS2 = StateSpace(Matrix([[1, 1], [4, -2]]),Matrix([[0, 1], [0, 2]]),Matrix([[-1, 1], [1, -1]]))
|
| 1717 |
+
SS3 = StateSpace(Matrix([[1, 1], [4, -2]]),Matrix([[1, -1], [1, -1]]))
|
| 1718 |
+
|
| 1719 |
+
# Observability
|
| 1720 |
+
assert SS1.is_observable() == True
|
| 1721 |
+
assert SS2.is_observable() == False
|
| 1722 |
+
assert SS1.observability_matrix() == Matrix([[0, 1], [1, 0]])
|
| 1723 |
+
assert SS2.observability_matrix() == Matrix([[-1, 1], [ 1, -1], [ 3, -3], [-3, 3]])
|
| 1724 |
+
assert SS1.observable_subspace() == [Matrix([[0], [1]]), Matrix([[1], [0]])]
|
| 1725 |
+
assert SS2.observable_subspace() == [Matrix([[-1], [ 1], [ 3], [-3]])]
|
| 1726 |
+
|
| 1727 |
+
# Controllability
|
| 1728 |
+
assert SS1.is_controllable() == True
|
| 1729 |
+
assert SS3.is_controllable() == False
|
| 1730 |
+
assert SS1.controllability_matrix() == Matrix([[0.5, -0.75], [ 0, 0.5]])
|
| 1731 |
+
assert SS3.controllability_matrix() == Matrix([[1, -1, 2, -2], [1, -1, 2, -2]])
|
| 1732 |
+
assert SS1.controllable_subspace() == [Matrix([[0.5], [ 0]]), Matrix([[-0.75], [ 0.5]])]
|
| 1733 |
+
assert SS3.controllable_subspace() == [Matrix([[1], [1]])]
|
| 1734 |
+
|
| 1735 |
+
# Append
|
| 1736 |
+
A1 = Matrix([[0, 1], [1, 0]])
|
| 1737 |
+
B1 = Matrix([[0], [1]])
|
| 1738 |
+
C1 = Matrix([[0, 1]])
|
| 1739 |
+
D1 = Matrix([[0]])
|
| 1740 |
+
ss1 = StateSpace(A1, B1, C1, D1)
|
| 1741 |
+
ss2 = StateSpace(Matrix([[1, 0], [0, 1]]), Matrix([[1], [0]]), Matrix([[1, 0]]), Matrix([[1]]))
|
| 1742 |
+
ss3 = ss1.append(ss2)
|
| 1743 |
+
|
| 1744 |
+
assert ss3.num_states == ss1.num_states + ss2.num_states
|
| 1745 |
+
assert ss3.num_inputs == ss1.num_inputs + ss2.num_inputs
|
| 1746 |
+
assert ss3.num_outputs == ss1.num_outputs + ss2.num_outputs
|
| 1747 |
+
assert ss3.state_matrix == Matrix([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
|
| 1748 |
+
assert ss3.input_matrix == Matrix([[0, 0], [1, 0], [0, 1], [0, 0]])
|
| 1749 |
+
assert ss3.output_matrix == Matrix([[0, 1, 0, 0], [0, 0, 1, 0]])
|
| 1750 |
+
assert ss3.feedforward_matrix == Matrix([[0, 0], [0, 1]])
|
parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_circuitutils.cpython-310.pyc
ADDED
|
Binary file (8.8 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_commutator.cpython-310.pyc
ADDED
|
Binary file (3.44 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_constants.cpython-310.pyc
ADDED
|
Binary file (588 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_grover.cpython-310.pyc
ADDED
|
Binary file (3.44 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_hilbert.cpython-310.pyc
ADDED
|
Binary file (2.92 kB). View file
|
|
|