Name | Crane-FMU JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | Basic crane simulation model including publication as FMU, for usage in the SEACo project |
upload_time | 2024-12-18 08:07:32 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License Copyright (c) 2024 [DNV](https://www.dnv.com) [open source](https://github.com/dnv-opensource) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
fmi
osp
crane
model
simulation
tight coupling
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
Introduction
============
The package extends the `component_model` package to provide the means to construct cranes.
The package can be used to define concrete cranes and simulate their usage, see `tests/resources/mobile-crane.py` as example.
Getting Started
---------------
A concrete crane model should consist of an extension of the Crane object,
* defining general model variables like `name`, `author`, `version`, etc.
* defining the anticipated set of booms
* if there is a wish to keep parameters configurable, these can be kept as parameters of the extended model.
* In a separate script, instantiate the concrete crane, test it and run `Model.build(...)` to make the FMU.
See the file `tests/resources/mobile_crane.py` and related test files
as an example on how a concrete crane can be defined and used.
Installation
------------
``pip install crane-fmu``
Usage example
-------------
This is a simple mobile crane, like they are used on e.g. building sites with
* a short pedestal, which can be turn around,
* one boom with variable length and which can be lifted
* one rope, where loads can be attached.
.. code-block:: Python
from crane_fmu.crane import Crane
class MobileCrane(Crane):
"""Simple mobile crane for FMU testing purposes.
The crane has a short pedestal, one variable-length stiff boom and a rope.
The size and weight of the various parts can be configured.
Args:
name (str) : name of the crane type
description (str) : short description
author (str)
version (str)
pedestalMass (str) : mass of the pedestal - quantity and unit as string
pedestalHeight (str) : height (fixed) of the pedestal, with units
boomMass (str) : mass of the single boom, with units
boomLength0 (str) : minimum length of the boom, with units
boomLength1 (str) : maximum length of the boom, with units
"""
def __init__(
self,
name: str = "mobile_crane",
description: str = "Simple mobile crane (for FMU testing) with short pedestal, one variable-length elevation boom and a rope",
author: str = "DNV, SEACo project",
version: str = "0.2",
pedestalMass: str = "10000.0 kg",
pedestalHeight: str = "3.0 m",
boomMass: str = "1000.0 kg",
boomLength0: str = "8 m",
boomLength1: str = "50 m",
rope_mass_range: tuple = ("50kg", "2000 kg"),
**kwargs,
):
super().__init__(name=name, description=description, author=author, version=version, **kwargs)
_ = self.add_boom(
name="pedestal",
description="The crane base, on one side fixed to the vessel and on the other side the first crane boom is fixed to it. The mass should include all additional items fixed to it, like the operator's cab",
mass=pedestalMass,
massCenter=(0.5, -1.0, 0.8),
boom=(pedestalHeight, "0deg", "0deg"),
boom_rng=(None, None, ("0deg", "360deg")),
)
_ = self.add_boom(
name="boom",
description="The boom. Can be lifted and length can change within the given range",
mass=boomMass,
massCenter=(0.5, 0, 0),
boom=(boomLength0, "90deg", "0deg"),
boom_rng=((boomLength0, boomLength1), (0, "90deg"), None),
)
_ = self.add_boom(
name="rope",
description="The rope fixed to the last boom. Flexible connection",
mass="50.0 kg", # so far basically the hook
massCenter=0.95,
mass_rng=rope_mass_range,
boom=("1e-6 m", "180deg", "0 deg"),
boom_rng=(
("1e-6 m", boomLength1),
("90deg", "270deg"),
("-180deg", "180deg"),
),
damping=50.0,
animationLW=2,
)
# make sure that _comSub is calculated for all booms:
self.calc_statics_dynamics(None)
def do_step(self, currentTime, stepSize):
status = super().do_step(currentTime, stepSize)
# print(f"Time {currentTime}, {self.rope_tip}")
# print(f"MobileCrane.do_step. Status {status}")
return status
Testing and usage of the `MobileCrane.fmu` is demonstrated as part of related `test_***` files.
Development Setup
-----------------
1. Install uv
^^^^^^^^^^^^^
This project uses `uv` as package manager.
If you haven't already, install `uv <https://docs.astral.sh/uv/>`_, preferably using it's `"Standalone installer" <https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2/>`_ method:
..on Windows:
``powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"``
..on MacOS and Linux:
``curl -LsSf https://astral.sh/uv/install.sh | sh``
(see `docs.astral.sh/uv <https://docs.astral.sh/uv/getting-started/installation//>`_ for all / alternative installation methods.)
Once installed, you can update `uv` to its latest version, anytime, by running:
``uv self update``
2. Install Python
^^^^^^^^^^^^^^^^^
This project requires Python 3.10 or later.
If you don't already have a compatible version installed on your machine, the probably most comfortable way to install Python is through ``uv``:
``uv python install``
This will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.
Alternatively, and if you want a standalone version of Python on your machine, you can install Python either via ``winget``:
``winget install --id Python.Python``
or you can download and install Python from the `python.org <https://www.python.org/downloads//>`_ website.
3. Clone the repository
^^^^^^^^^^^^^^^^^^^^^^^
Clone the crane-fmu repository into your local development directory:
``git clone https://github.com/dnv-opensource/crane-fmu path/to/your/dev/crane-fmu``
4. Install dependencies
^^^^^^^^^^^^^^^^^^^^^^^
Run ``uv sync`` to create a virtual environment and install all project dependencies into it:
``uv sync``
5. (Optional) Activate the virtual environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When using ``uv``, there is in almost all cases no longer a need to manually activate the virtual environment.
``uv`` will find the ``.venv`` virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via `uv` inside your project folder structure:
``uv run <command>``
However, you still *can* manually activate the virtual environment if needed.
When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings.
To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows:
``.venv\Scripts\activate.bat``
..on Linux:
``source .venv/bin/activate``
6. Install pre-commit hooks
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``.pre-commit-config.yaml`` file in the project root directory contains a configuration for pre-commit hooks.
To install the pre-commit hooks defined therein in your local git repository, run:
``uv run pre-commit install``
All pre-commit hooks configured in ``.pre-commit-config.yam`` will now run each time you commit changes.
7. Test that the installation works
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To test that the installation works, run pytest in the project root folder:
``uv run pytest``
Meta
----
Copyright (c) 2024 `DNV <https://www.dnv.com/>`_ AS. All rights reserved.
Siegfried Eisinger - siegfried.eisinger@dnv.com
Distributed under the MIT license. See `LICENSE <LICENSE.md/>`_ for more information.
`https://github.com/dnv-opensource/crane-fmu <https://github.com/dnv-opensource/crane-fmu/>`_
Contribute
----------
Anybody in the FMU, OSPand SEACo community is especially welcome to contribute to this code, to make it better,
and especially including other features from model assurance and from SEACo issues.
To contribute, follow these steps:
1. Fork it `<https://github.com/dnv-opensource/crane-fmu/fork/>`_
2. Create an issue in your GitHub repo
3. Create your branch based on the issue number and type (``git checkout -b issue-name``)
4. Evaluate and stage the changes you want to commit (``git add -i``)
5. Commit your changes (``git commit -am 'place a descriptive commit message here'``)
6. Push to the branch (``git push origin issue-name``)
7. Create a new Pull Request in GitHub
For your contribution, please make sure you follow the `STYLEGUIDE <STYLEGUIDE.md/>`_ before creating the Pull Request.
Raw data
{
"_id": null,
"home_page": null,
"name": "Crane-FMU",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "FMI, OSP, crane, model, simulation, tight coupling",
"author": null,
"author_email": "Siegfried Eisinger <Siegfried.Eisinger@DNV.com>",
"download_url": "https://files.pythonhosted.org/packages/b2/19/274e43875bd4be29ab75dcc530680a4aebc34790f32b3cec4acb83025844/crane_fmu-0.1.1.tar.gz",
"platform": null,
"description": "Introduction\n============\nThe package extends the `component_model` package to provide the means to construct cranes.\nThe package can be used to define concrete cranes and simulate their usage, see `tests/resources/mobile-crane.py` as example.\n\nGetting Started\n---------------\nA concrete crane model should consist of an extension of the Crane object,\n\n* defining general model variables like `name`, `author`, `version`, etc.\n* defining the anticipated set of booms\n* if there is a wish to keep parameters configurable, these can be kept as parameters of the extended model.\n* In a separate script, instantiate the concrete crane, test it and run `Model.build(...)` to make the FMU.\n\nSee the file `tests/resources/mobile_crane.py` and related test files\nas an example on how a concrete crane can be defined and used.\n\n\nInstallation\n------------\n\n``pip install crane-fmu``\n\n\nUsage example\n-------------\nThis is a simple mobile crane, like they are used on e.g. building sites with\n\n* a short pedestal, which can be turn around,\n* one boom with variable length and which can be lifted\n* one rope, where loads can be attached.\n\n.. code-block:: Python\n\n from crane_fmu.crane import Crane\n\n class MobileCrane(Crane):\n \"\"\"Simple mobile crane for FMU testing purposes.\n The crane has a short pedestal, one variable-length stiff boom and a rope.\n The size and weight of the various parts can be configured.\n\n Args:\n name (str) : name of the crane type\n description (str) : short description\n author (str)\n version (str)\n pedestalMass (str) : mass of the pedestal - quantity and unit as string\n pedestalHeight (str) : height (fixed) of the pedestal, with units\n boomMass (str) : mass of the single boom, with units\n boomLength0 (str) : minimum length of the boom, with units\n boomLength1 (str) : maximum length of the boom, with units\n \"\"\"\n\n def __init__(\n self,\n name: str = \"mobile_crane\",\n description: str = \"Simple mobile crane (for FMU testing) with short pedestal, one variable-length elevation boom and a rope\",\n author: str = \"DNV, SEACo project\",\n version: str = \"0.2\",\n pedestalMass: str = \"10000.0 kg\",\n pedestalHeight: str = \"3.0 m\",\n boomMass: str = \"1000.0 kg\",\n boomLength0: str = \"8 m\",\n boomLength1: str = \"50 m\",\n rope_mass_range: tuple = (\"50kg\", \"2000 kg\"),\n **kwargs,\n ):\n super().__init__(name=name, description=description, author=author, version=version, **kwargs)\n _ = self.add_boom(\n name=\"pedestal\",\n description=\"The crane base, on one side fixed to the vessel and on the other side the first crane boom is fixed to it. The mass should include all additional items fixed to it, like the operator's cab\",\n mass=pedestalMass,\n massCenter=(0.5, -1.0, 0.8),\n boom=(pedestalHeight, \"0deg\", \"0deg\"),\n boom_rng=(None, None, (\"0deg\", \"360deg\")),\n )\n _ = self.add_boom(\n name=\"boom\",\n description=\"The boom. Can be lifted and length can change within the given range\",\n mass=boomMass,\n massCenter=(0.5, 0, 0),\n boom=(boomLength0, \"90deg\", \"0deg\"),\n boom_rng=((boomLength0, boomLength1), (0, \"90deg\"), None),\n )\n _ = self.add_boom(\n name=\"rope\",\n description=\"The rope fixed to the last boom. Flexible connection\",\n mass=\"50.0 kg\", # so far basically the hook\n massCenter=0.95,\n mass_rng=rope_mass_range,\n boom=(\"1e-6 m\", \"180deg\", \"0 deg\"),\n boom_rng=(\n (\"1e-6 m\", boomLength1),\n (\"90deg\", \"270deg\"),\n (\"-180deg\", \"180deg\"),\n ),\n damping=50.0,\n animationLW=2,\n )\n # make sure that _comSub is calculated for all booms:\n self.calc_statics_dynamics(None)\n\n def do_step(self, currentTime, stepSize):\n status = super().do_step(currentTime, stepSize)\n # print(f\"Time {currentTime}, {self.rope_tip}\")\n # print(f\"MobileCrane.do_step. Status {status}\")\n return status\n\n\n\nTesting and usage of the `MobileCrane.fmu` is demonstrated as part of related `test_***` files.\n\n\nDevelopment Setup\n-----------------\n\n1. Install uv\n^^^^^^^^^^^^^\nThis project uses `uv` as package manager.\n\nIf you haven't already, install `uv <https://docs.astral.sh/uv/>`_, preferably using it's `\"Standalone installer\" <https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2/>`_ method:\n\n..on Windows:\n\n``powershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"``\n\n..on MacOS and Linux:\n\n``curl -LsSf https://astral.sh/uv/install.sh | sh``\n\n(see `docs.astral.sh/uv <https://docs.astral.sh/uv/getting-started/installation//>`_ for all / alternative installation methods.)\n\nOnce installed, you can update `uv` to its latest version, anytime, by running:\n\n``uv self update``\n\n2. Install Python\n^^^^^^^^^^^^^^^^^\nThis project requires Python 3.10 or later.\n\nIf you don't already have a compatible version installed on your machine, the probably most comfortable way to install Python is through ``uv``:\n\n``uv python install``\n\nThis will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.\n\nAlternatively, and if you want a standalone version of Python on your machine, you can install Python either via ``winget``:\n\n``winget install --id Python.Python``\n\nor you can download and install Python from the `python.org <https://www.python.org/downloads//>`_ website.\n\n3. Clone the repository\n^^^^^^^^^^^^^^^^^^^^^^^\nClone the crane-fmu repository into your local development directory:\n\n``git clone https://github.com/dnv-opensource/crane-fmu path/to/your/dev/crane-fmu``\n\n4. Install dependencies\n^^^^^^^^^^^^^^^^^^^^^^^\nRun ``uv sync`` to create a virtual environment and install all project dependencies into it:\n\n``uv sync``\n\n5. (Optional) Activate the virtual environment\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nWhen using ``uv``, there is in almost all cases no longer a need to manually activate the virtual environment.\n\n``uv`` will find the ``.venv`` virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via `uv` inside your project folder structure:\n\n``uv run <command>``\n\nHowever, you still *can* manually activate the virtual environment if needed.\nWhen developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings.\nTo manually activate the virtual environment, run one of the \"known\" legacy commands:\n\n..on Windows:\n\n``.venv\\Scripts\\activate.bat``\n\n..on Linux:\n\n``source .venv/bin/activate``\n\n6. Install pre-commit hooks\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\nThe ``.pre-commit-config.yaml`` file in the project root directory contains a configuration for pre-commit hooks.\nTo install the pre-commit hooks defined therein in your local git repository, run:\n\n``uv run pre-commit install``\n\nAll pre-commit hooks configured in ``.pre-commit-config.yam`` will now run each time you commit changes.\n\n7. Test that the installation works\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTo test that the installation works, run pytest in the project root folder:\n\n``uv run pytest``\n\n\nMeta\n----\nCopyright (c) 2024 `DNV <https://www.dnv.com/>`_ AS. All rights reserved.\n\nSiegfried Eisinger - siegfried.eisinger@dnv.com\n\nDistributed under the MIT license. See `LICENSE <LICENSE.md/>`_ for more information.\n\n`https://github.com/dnv-opensource/crane-fmu <https://github.com/dnv-opensource/crane-fmu/>`_\n\nContribute\n----------\nAnybody in the FMU, OSPand SEACo community is especially welcome to contribute to this code, to make it better,\nand especially including other features from model assurance and from SEACo issues.\n\nTo contribute, follow these steps:\n\n1. Fork it `<https://github.com/dnv-opensource/crane-fmu/fork/>`_\n2. Create an issue in your GitHub repo\n3. Create your branch based on the issue number and type (``git checkout -b issue-name``)\n4. Evaluate and stage the changes you want to commit (``git add -i``)\n5. Commit your changes (``git commit -am 'place a descriptive commit message here'``)\n6. Push to the branch (``git push origin issue-name``)\n7. Create a new Pull Request in GitHub\n\nFor your contribution, please make sure you follow the `STYLEGUIDE <STYLEGUIDE.md/>`_ before creating the Pull Request.\n\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 [DNV](https://www.dnv.com) [open source](https://github.com/dnv-opensource) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Basic crane simulation model including publication as FMU, for usage in the SEACo project",
"version": "0.1.1",
"project_urls": {
"Changelog": "https://github.com/dnv-opensource/crane-fmu/blob/main/CHANGELOG.md",
"Documentation": "https://dnv-innersource.github.io/crane-fmu/README.html",
"Homepage": "https://github.com/dnv-opensource/crane-fmu",
"Issues": "https://github.com/dnv-opensource/crane-fmu/issues",
"Repository": "https://github.com/dnv-opensource/crane-fmu.git"
},
"split_keywords": [
"fmi",
" osp",
" crane",
" model",
" simulation",
" tight coupling"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cd29b305ec0cbe2b371a193e26c23219c82ad80d8a8470b7392c5c0061c37b8b",
"md5": "061bf9ba91cf373aeb37125897e2cf69",
"sha256": "f11d81d4b3907321cc11d634d0758779e990bd2fd36cbf95017898e816e7deca"
},
"downloads": -1,
"filename": "crane_fmu-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "061bf9ba91cf373aeb37125897e2cf69",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 21594,
"upload_time": "2024-12-18T08:07:28",
"upload_time_iso_8601": "2024-12-18T08:07:28.225891Z",
"url": "https://files.pythonhosted.org/packages/cd/29/b305ec0cbe2b371a193e26c23219c82ad80d8a8470b7392c5c0061c37b8b/crane_fmu-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b219274e43875bd4be29ab75dcc530680a4aebc34790f32b3cec4acb83025844",
"md5": "30035e3ba33908b9b5ba8b794f47b8fa",
"sha256": "2592dadd833f3d7b2ba6081fb2e822e8b172100d519fd859ae1430ea0e6fb519"
},
"downloads": -1,
"filename": "crane_fmu-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "30035e3ba33908b9b5ba8b794f47b8fa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 1983036,
"upload_time": "2024-12-18T08:07:32",
"upload_time_iso_8601": "2024-12-18T08:07:32.100790Z",
"url": "https://files.pythonhosted.org/packages/b2/19/274e43875bd4be29ab75dcc530680a4aebc34790f32b3cec4acb83025844/crane_fmu-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-18 08:07:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dnv-opensource",
"github_project": "crane-fmu",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "crane-fmu"
}