Basic crane simulation model including publication as FMU, for usage in the SEACo project
Project description
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.
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, preferably using it’s “Standalone installer” 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 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 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 AS. All rights reserved.
Siegfried Eisinger - siegfried.eisinger@dnv.com
Distributed under the MIT license. See LICENSE for more information.
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:
Create an issue in your GitHub repo
Create your branch based on the issue number and type (git checkout -b issue-name)
Evaluate and stage the changes you want to commit (git add -i)
Commit your changes (git commit -am 'place a descriptive commit message here')
Push to the branch (git push origin issue-name)
Create a new Pull Request in GitHub
For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crane_fmu-0.1.1.tar.gz.
File metadata
- Download URL: crane_fmu-0.1.1.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2592dadd833f3d7b2ba6081fb2e822e8b172100d519fd859ae1430ea0e6fb519
|
|
| MD5 |
30035e3ba33908b9b5ba8b794f47b8fa
|
|
| BLAKE2b-256 |
b219274e43875bd4be29ab75dcc530680a4aebc34790f32b3cec4acb83025844
|
Provenance
The following attestation bundles were made for crane_fmu-0.1.1.tar.gz:
Publisher:
publish_release.yml on dnv-opensource/crane-fmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crane_fmu-0.1.1.tar.gz -
Subject digest:
2592dadd833f3d7b2ba6081fb2e822e8b172100d519fd859ae1430ea0e6fb519 - Sigstore transparency entry: 156303399
- Sigstore integration time:
-
Permalink:
dnv-opensource/crane-fmu@638a5a34b321b1d126f9f3a40f345c404545ed30 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/dnv-opensource
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_release.yml@638a5a34b321b1d126f9f3a40f345c404545ed30 -
Trigger Event:
push
-
Statement type:
File details
Details for the file crane_fmu-0.1.1-py3-none-any.whl.
File metadata
- Download URL: crane_fmu-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f11d81d4b3907321cc11d634d0758779e990bd2fd36cbf95017898e816e7deca
|
|
| MD5 |
061bf9ba91cf373aeb37125897e2cf69
|
|
| BLAKE2b-256 |
cd29b305ec0cbe2b371a193e26c23219c82ad80d8a8470b7392c5c0061c37b8b
|
Provenance
The following attestation bundles were made for crane_fmu-0.1.1-py3-none-any.whl:
Publisher:
publish_release.yml on dnv-opensource/crane-fmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crane_fmu-0.1.1-py3-none-any.whl -
Subject digest:
f11d81d4b3907321cc11d634d0758779e990bd2fd36cbf95017898e816e7deca - Sigstore transparency entry: 156303400
- Sigstore integration time:
-
Permalink:
dnv-opensource/crane-fmu@638a5a34b321b1d126f9f3a40f345c404545ed30 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/dnv-opensource
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_release.yml@638a5a34b321b1d126f9f3a40f345c404545ed30 -
Trigger Event:
push
-
Statement type: