Skip to main content

Python library for working with DNV HydroD workspaces and workflows.

Project description

dnv-hydrod

dnv-hydrod is a Python library that provides seamless integration with DNV HydroD through pythonnet, enabling programmatic access to HydroD workspace files (.hydx) and modeling APIs.

This library automatically locates your HydroD installation, loads required .NET assemblies, and provides a Pythonic interface for workspace operations, analysis execution, and concept manipulation.

Requirements:

  • DNV HydroD 9.0 and higher (must be installed on the system)

  • Python 3.10, 3.11, 3.12, or 3.13 (3.14+ not supported)

  • A matching .NET Desktop Runtime, installed globally (system-wide):

    The self-contained .NET runtime shipped inside HydroD's installation folder cannot be used by this package: hosting CoreCLR from there loads HydroD's bundled Python.Runtime.dll (3.0.5) instead of the pip-installed copy, which then crashes in Python.Runtime.ModuleObject.tp_setattro the first time HydroD's scripting service registers a .NET namespace. If the matching global .NET Desktop Runtime is missing, dnv-hydrod raises a clear RuntimeError on import with a download link.

Installation

Installing from PyPI (when published):

pip install dnv-hydrod

Quick Start

from dnv.hydrod import *

# Open existing workspace with license keys
with WorkspaceSession(
    r"C:\Projects\myworkspace.hydx",
    license_keys=['WIND']
) as session:
    # Access workspace concepts
    analyses = FindConcept("/Workspace/Analyses")
    
    # Create and execute custom analysis
    ca = CustomAnalysis(analyses, "MyAnalysis")
    ca.InlineScript = """
import time
print('Starting analysis...')
time.sleep(2)
print('Analysis completed!')
"""
    ca.Execute()

Key Features

  • Automatic HydroD Detection: Uses DNV Application Version Manager to locate HydroD installation
  • Context Manager Support: Safe workspace handling with automatic cleanup
  • Pythonic API: Clean, intuitive interface for HydroD operations
  • Embedded Modules: Access to Python utilities embedded in HydroD .NET assemblies

Documentation

This library provides Python bindings to HydroD's .NET API. For comprehensive information about available classes, methods, workflows, and HydroD concepts, please refer to the HydroD Documentation and API reference included with your HydroD installation.

Usage Examples

Creating a New Workspace

from dnv.hydrod import *

# Create new workspace with license keys
with WorkspaceSession(
    r"C:\Projects",
    "NewWorkspace",
    license_keys=['WIND']
) as session:
    # Workspace is automatically saved as NewWorkspace.hydx
    print("Workspace created successfully!")

Working with Concepts

from dnv.hydrod import *

with WorkspaceSession(
    r"C:\Projects\myworkspace.hydx",
    license_keys=['WIND']
) as session:
    # Find concepts using path
    load_cases_table = FindConcept("/Workspace/Analyses/DesignLoadCasesTable1")

    # Create new DesignLoadCase entry
    udlc1 = DesignLoadCase()
    udlc1.Selected=True
    udlc1.Name="DLC_new"
    udlc1.SimaBladedFolder="Inputs\\Sima_ULS_Hs11_Deg90_Vw23"
    udlc1.SimaBladedFileName="sima"
    udlc1.EnvironmentalLoadFactor=0.8
    udlc1.PermanentLoadFactor=0.8
    udlc1.StartTime=300
    udlc1.StopTime=340

    # Add new DesignLoadCase entry to "UlsDesignLoadCases1" concept
    load_cases_table.DesignLoadCases.Add(udlc1)

Generate Runs and run ULS workflow through Python

from dnv.hydrod import *

with WorkspaceSession(
    r"C:\Projects\myworkspace.hydx",
    license_keys=['WIND']
) as session:
    runFolder = FindConcept("/Workspace/Analyses/Workflow1/Runs")
    # If the run folder already exists, delete it to remove previous results
    if (runFolder):
        Delete(runFolder)

    workflow = FindConcept("/Workspace/Analyses/Workflow1")
    workflow.GenerateRuns()
    workflow.Execute()

Architecture

  • load_assemblies.py: Initializes .NET runtime, locates HydroD, loads assemblies
  • workspace_utils.py: Provides WorkspaceSession and utility functions
  • Embedded modules: Python code extracted from HydroD .NET assemblies at runtime

Limitations

  • HydroD must be installed on the system

License

This project is licensed under the MIT License. See the LICENSE file in the package directory for full license text.

Support

For issues, questions, or feedback, please contact DNV software support at software.support@dnv.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dnv_hydrod-1.0.3rc66.tar.gz (61.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dnv_hydrod-1.0.3rc66-py3-none-any.whl (65.1 kB view details)

Uploaded Python 3

File details

Details for the file dnv_hydrod-1.0.3rc66.tar.gz.

File metadata

  • Download URL: dnv_hydrod-1.0.3rc66.tar.gz
  • Upload date:
  • Size: 61.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dnv_hydrod-1.0.3rc66.tar.gz
Algorithm Hash digest
SHA256 c22082b0faddb3505e8c7e00e5659a22b6aecb4f3e48e76415de41b462e9c79d
MD5 eabb18ff3e594328724eb861338708d7
BLAKE2b-256 c912716524be386b17ce5dfb454d6239b2e5b1e8d143948f8a21f92267317181

See more details on using hashes here.

File details

Details for the file dnv_hydrod-1.0.3rc66-py3-none-any.whl.

File metadata

  • Download URL: dnv_hydrod-1.0.3rc66-py3-none-any.whl
  • Upload date:
  • Size: 65.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dnv_hydrod-1.0.3rc66-py3-none-any.whl
Algorithm Hash digest
SHA256 6efef215d668966baaf5d9ef9aecac2ca78e2fcba8af7a96550aee32d0aba185
MD5 c80c350b306d5d890621f0a7d533caee
BLAKE2b-256 5018b86cf1ba54dadfe7190d42c1c002b7c457d0f97c32c629933ab7bee6b8a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page