dnv-bladed-models


Namednv-bladed-models JSON
Version 0.4.1 PyPI version JSON
download
home_pageNone
SummaryAn API for working with Bladed Next Gen models.
upload_time2024-10-11 12:41:16
maintainerNone
docs_urlNone
authorDNV
requires_python>=3.7
licenseMIT License Copyright (c) 2024 DNV 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 bladed models
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Bladed Next Gen Python Models API

`dnv_bladed_models=0.4.1`

A Python package to easily work with JSON input models for Bladed Next Generation.

Visit <https://bladednextgen.dnv.com/> for more information.

## Prerequisites

- Requires Python 3.7 or above

## Usage

## Add import

```python
import dnv_bladed_models as models
```

There are a large number of model classes (500+) in the Bladed NG input API. They are all accessible via the `models` module.

The root model is `BladedAnalysis`; a JSON file input to the calculation engine must have this model as the root object.

However the same capabilities are available for every model; each one can be read and written to JSON individually, as demonstrated below.

### Load a full Bladed NG JSON analysis model from file

```python
analysis = models.BladedAnalysis.from_file('/path/to/analysis.json')
```

This will perform some validation of the input to ensure the structure adheres to the input model schema.

### Save a model to a JSON file

```python
analysis.to_file('/path/to/file.json')
```

The JSON file can then be opened in VS Code, and will automatically receive validation, doc-string and auto-complete support against the Bladed NG JSON Schema.

### Load a model from a JSON string

```python
analysis = models.BladedAnalysis.from_json(json_str)
```

This will perform some validation of the input to ensure the structure adheres to the input model schema.

### Render a model as a JSON string

```python
json_str = analysis.to_json()
```

### Create a new model object in code

Create a new instance of the root model, 'BladedAnalysis':

```python
analysis = models.BladedAnalysis()
```

A model object can be created with an empty initialiser as shown above, or by specifying some or all of the child models as keyword arguments:

```python
beam = models.LidarBeam(
    MountingPosition=models.LidarMountingPosition(
        X=1,
        Y=2,
        Z=3
    )
)
```

### Modify a model object in code

If a model object is already loaded, properties can be modified as required:

```python
analysis.SteadyCalculation.TipSpeedRatioRange.Minimum = 4.
analysis.SteadyCalculation.TipSpeedRatioRange.Maximum = 10.
analysis.SteadyCalculation.TipSpeedRatioRange.Interval = 0.1
```

### Manipulate the turbine assembly

Access existing component definitions:

```python
# Access a known existing component by it's key
blade: models.Blade = analysis.ComponentDefinitions['blade']

# Iterate over all component entries...
for key, component in analysis.ComponentDefinitions.items():
    print(f"Component key: {key}, Component type: {component.ComponentType}")

# Or just the keys
for key in analysis.ComponentDefinitions.keys():
    print(key)

# Or just the components
for component in analysis.ComponentDefinitions.values():
    print(component.ComponentType)
```

Access existing nodes in the Assembly tree using string and integer accessors:

```python
blade_node = analysis.Turbine.Assembly['hub']['pitch-system-1'][0]
# or
blade_node = analysis.Turbine.Assembly['hub']['pitch-system-1']['blade-1']
# or
blade_nodes = [ps_node[0] for node_name, ps_node in analysis.Turbine.Assembly['hub'].items()]
```

Add new nodes and component definitions:

```python
analysis.ComponentDefinitions['my-hub'] = models.IndependentPitchHub()
analysis.ComponentDefinitions['my-pitch-system'] = models.PitchSystem()
analysis.ComponentDefinitions['my-blade'] = models.Blade()

hub_node = models.AssemblyNode(
    ComponentReference = "#/ComponentDefinitions/my-hub"
)
for i in range(1,4):
    blade_node = models.AssemblyNode(
        ComponentReference = "#/ComponentDefinitions/my-blade"
    )
    ps_node = models.AssemblyNode(
        ComponentReference = "#/ComponentDefinitions/my-pitch-system"
    )
    ps_node[f'blade-{i}'] = blade_node
    hub_node[f'pitch-system-{i}'] = ps_node
analysis.Turbine.Assembly['hub'] = hub_node
```

### Change a model to an alternative choice

Some model properties can be set to one of a number of different model types, to allow a choice between different options available in the calculation.

The property must simply be set to an object of one of the valid types. The valid types available are included in the doc strings, and the schema documentation available on the Bladed Next Gen website.

The example below is for dynamic stall. The detail of setting the specific properties on each model is omitted for brevity:

```python
analysis.Aerodynamics.DynamicStall = models.OyeModel()

# or
analysis.Aerodynamics.DynamicStall = models.IAGModel()

# or
analysis.Aerodynamics.DynamicStall = models.CompressibleBeddoesLeishmanModel()

# or
analysis.Aerodynamics.DynamicStall = models.IncompressibleBeddoesLeishmanModel()
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dnv-bladed-models",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "bladed, models",
    "author": "DNV",
    "author_email": "DNV <bladednextgen@dnv.com>",
    "download_url": "https://files.pythonhosted.org/packages/50/02/abcfdcb26c4c6c85f4b5577e22849a46a5ed6b4939dee430f0705ab116e3/dnv_bladed_models-0.4.1.tar.gz",
    "platform": null,
    "description": "# Bladed Next Gen Python Models API\n\n`dnv_bladed_models=0.4.1`\n\nA Python package to easily work with JSON input models for Bladed Next Generation.\n\nVisit <https://bladednextgen.dnv.com/> for more information.\n\n## Prerequisites\n\n- Requires Python 3.7 or above\n\n## Usage\n\n## Add import\n\n```python\nimport dnv_bladed_models as models\n```\n\nThere are a large number of model classes (500+) in the Bladed NG input API. They are all accessible via the `models` module.\n\nThe root model is `BladedAnalysis`; a JSON file input to the calculation engine must have this model as the root object.\n\nHowever the same capabilities are available for every model; each one can be read and written to JSON individually, as demonstrated below.\n\n### Load a full Bladed NG JSON analysis model from file\n\n```python\nanalysis = models.BladedAnalysis.from_file('/path/to/analysis.json')\n```\n\nThis will perform some validation of the input to ensure the structure adheres to the input model schema.\n\n### Save a model to a JSON file\n\n```python\nanalysis.to_file('/path/to/file.json')\n```\n\nThe JSON file can then be opened in VS Code, and will automatically receive validation, doc-string and auto-complete support against the Bladed NG JSON Schema.\n\n### Load a model from a JSON string\n\n```python\nanalysis = models.BladedAnalysis.from_json(json_str)\n```\n\nThis will perform some validation of the input to ensure the structure adheres to the input model schema.\n\n### Render a model as a JSON string\n\n```python\njson_str = analysis.to_json()\n```\n\n### Create a new model object in code\n\nCreate a new instance of the root model, 'BladedAnalysis':\n\n```python\nanalysis = models.BladedAnalysis()\n```\n\nA model object can be created with an empty initialiser as shown above, or by specifying some or all of the child models as keyword arguments:\n\n```python\nbeam = models.LidarBeam(\n    MountingPosition=models.LidarMountingPosition(\n        X=1,\n        Y=2,\n        Z=3\n    )\n)\n```\n\n### Modify a model object in code\n\nIf a model object is already loaded, properties can be modified as required:\n\n```python\nanalysis.SteadyCalculation.TipSpeedRatioRange.Minimum = 4.\nanalysis.SteadyCalculation.TipSpeedRatioRange.Maximum = 10.\nanalysis.SteadyCalculation.TipSpeedRatioRange.Interval = 0.1\n```\n\n### Manipulate the turbine assembly\n\nAccess existing component definitions:\n\n```python\n# Access a known existing component by it's key\nblade: models.Blade = analysis.ComponentDefinitions['blade']\n\n# Iterate over all component entries...\nfor key, component in analysis.ComponentDefinitions.items():\n    print(f\"Component key: {key}, Component type: {component.ComponentType}\")\n\n# Or just the keys\nfor key in analysis.ComponentDefinitions.keys():\n    print(key)\n\n# Or just the components\nfor component in analysis.ComponentDefinitions.values():\n    print(component.ComponentType)\n```\n\nAccess existing nodes in the Assembly tree using string and integer accessors:\n\n```python\nblade_node = analysis.Turbine.Assembly['hub']['pitch-system-1'][0]\n# or\nblade_node = analysis.Turbine.Assembly['hub']['pitch-system-1']['blade-1']\n# or\nblade_nodes = [ps_node[0] for node_name, ps_node in analysis.Turbine.Assembly['hub'].items()]\n```\n\nAdd new nodes and component definitions:\n\n```python\nanalysis.ComponentDefinitions['my-hub'] = models.IndependentPitchHub()\nanalysis.ComponentDefinitions['my-pitch-system'] = models.PitchSystem()\nanalysis.ComponentDefinitions['my-blade'] = models.Blade()\n\nhub_node = models.AssemblyNode(\n    ComponentReference = \"#/ComponentDefinitions/my-hub\"\n)\nfor i in range(1,4):\n    blade_node = models.AssemblyNode(\n        ComponentReference = \"#/ComponentDefinitions/my-blade\"\n    )\n    ps_node = models.AssemblyNode(\n        ComponentReference = \"#/ComponentDefinitions/my-pitch-system\"\n    )\n    ps_node[f'blade-{i}'] = blade_node\n    hub_node[f'pitch-system-{i}'] = ps_node\nanalysis.Turbine.Assembly['hub'] = hub_node\n```\n\n### Change a model to an alternative choice\n\nSome model properties can be set to one of a number of different model types, to allow a choice between different options available in the calculation.\n\nThe property must simply be set to an object of one of the valid types. The valid types available are included in the doc strings, and the schema documentation available on the Bladed Next Gen website.\n\nThe example below is for dynamic stall. The detail of setting the specific properties on each model is omitted for brevity:\n\n```python\nanalysis.Aerodynamics.DynamicStall = models.OyeModel()\n\n# or\nanalysis.Aerodynamics.DynamicStall = models.IAGModel()\n\n# or\nanalysis.Aerodynamics.DynamicStall = models.CompressibleBeddoesLeishmanModel()\n\n# or\nanalysis.Aerodynamics.DynamicStall = models.IncompressibleBeddoesLeishmanModel()\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 DNV  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": "An API for working with Bladed Next Gen models.",
    "version": "0.4.1",
    "project_urls": {
        "homepage": "https://bladednextgen.dnv.com/"
    },
    "split_keywords": [
        "bladed",
        " models"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5002abcfdcb26c4c6c85f4b5577e22849a46a5ed6b4939dee430f0705ab116e3",
                "md5": "caf97b29580d86f4536faa35d230c9fb",
                "sha256": "9a42212f870d61fba6c6dda903ec3e02b99b9490f164b7962780e92893699cc2"
            },
            "downloads": -1,
            "filename": "dnv_bladed_models-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "caf97b29580d86f4536faa35d230c9fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 198307,
            "upload_time": "2024-10-11T12:41:16",
            "upload_time_iso_8601": "2024-10-11T12:41:16.949363Z",
            "url": "https://files.pythonhosted.org/packages/50/02/abcfdcb26c4c6c85f4b5577e22849a46a5ed6b4939dee430f0705ab116e3/dnv_bladed_models-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-11 12:41:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dnv-bladed-models"
}
        
DNV
Elapsed time: 4.36796s