NsgOrcFx


NameNsgOrcFx JSON
Version 1.0.27 PyPI version JSON
download
home_pageNone
SummaryPackage with additional tools to the OrcFxAPI package
upload_time2024-12-22 10:06:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NsgOrcFx
Library of tools for the OrcaFlex API

This package wraps the original API from Orcina (OrcFxAPI) to include:
* methods: pre- and post-processing tools such as line selection, load case generation, modal and fatigue analysis
* coding facilities: auto-complete and hints with descriptions in IDE

\
All the attributes and methods from the source (OrcFxAPI) still accessible in the same way.

\
Installation:
```
pip install --upgrade NsgOrcFx
```

## Example 1 - Auto-complete feature of IDE (e.g. VS Code and Spyder)
```
import NsgOrcFx

model = NsgOrcFx.Model()
line = model.CreateLine()

```
The data name may be found in the `data` attribute with the auto complete of the IDE (e.g., Visual Studio Code, Spyder, and PyCharm).

![Screenshot of auto-complete with the 'data' component of objects (e.g., line.data.{data name})](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/autocomplete_linedata.jpg?raw=True)


In addition, a hint shows the description of the parameter (mouse cursor stopped in the data name).

![Screenshot of hint with the 'data' component of objects (e.g., line.data.{data name})](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/hint_linedata.jpg?raw=True)


In the exemple below, data names of `general`, `environment`, and `line` objects are accessed 
```
model.general.data.ImplicitConstantTimeStep = 0.01 # data from general object
model.environment.data.WaveHeight = 5.0 # data from environment object
line.data.EndAConnection = 'Anchored' # data form the line object
```

The line could be alse located by name with the following method. Although it could be done with the original method (`line = model['Line1']`), the new method is recommended to allow the functionality of auto-complete (`data` attribute)
```
line = model.findLineByName('Line1')
```

A list of all lines in the model may be retrieved and then select the first one by
```
lines = model.getAllLines()
line1 = lines[0]
```

## Example 2 - Reduced simulation time for irregular wave
```
import NsgOrcFx as ofx

model = ofx.Model()

# set irregular wave
model.environment.data.WaveType = 'JONSWAP'
model.environment.data.WaveHs = 2.5
model.environment.data.WaveGamma = 2
model.environment.data.WaveTp = 8

# set reduced simulation duration with 200 seconds
model.SetReducedSimulationDuration(200)

# save data file to check the wave history
model.Save('reduced.dat')

# after executing this code, open the generated data file
# then open Environment -> Waves preview, and set duration of 200s 
# click in View profile and observe that the largest event (rise or fall)
# is in the midle of the sea elevation history

```
![Screenshot of Wave preview (Environment -> Waves preview -> View profile) for a simulation of irregular wave with reduced duration based on the largest rise/fall occurence](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/wave_preview.png?raw=True)


## Example 3 - Generate load cases
```
import NsgOrcFx

model = NsgOrcFx.Model()
model.CreateLine()

# list of wave direction, height, and periods to define the Load Cases (LCs)
directions = [0, 45, 90] 
heights = [1.5, 2.0, 3.0]
periods = [5, 7, 9]

# Folder to save the generated files (LCs)
outFolder = 'tmp'

# Regular waves
model.GenerateLoadCases('Dean stream', directions, heights, periods, outFolder)

```

\
In case of irregular wave:
```
model.GenerateLoadCases('JONSWAP', directions, heights, periods, outFolder)
```
\
To run irregular waves with reduced simulation time, based on the occurance of the largest rise or fall in the specified storm period.
```
model.GenerateLoadCases('JONSWAP', directions, heights, periods, outFolder, reducedIrregDuration=200)
```


## Example 4 - Calculating modal analysis and getting the normalized modal shape 
```
import NsgOrcFx

model = NsgOrcFx.Model()
model.CreateLine()

modes = model.CalculateModal()

# mode shape index (0 for the 1st)
modeIndex = 0

# mode frequency
freq = modes.getModeFrequency(modeIndex)

# if normalize = True, the displacements will be normalized, so the maximum total displacements is equal to the line diameter
[arcLengths, Ux, Uy, Uz] = modes.GlobalDispShape('Line1', modeIndex, True)
print('Frequency = ', freq, 'Hz')
print(arcLengths, Ux, Uy, Uz)
```


## Example 5 - Defining fatigue analysis and getting the fatigue life calculated
```
import NsgOrcFx

simFile = r'tests\tmp\fatigue.sim'
ftgFile = r'tests\tmp\fatigue.ftg'

# First, it is necessary a model with simulation complete
model = NsgOrcFx.Model()
model.CreateLine()
model.RunSimulation()
model.Save(simFile) 

# The fatigue analysis is defined, including the S-N curve based on the DNV-RP-C203
analysis = NsgOrcFx.FatigueAnalysis()
analysis.data.AnalysisType = 'Rainflow'
analysis.data.LoadCaseCount = 1
analysis.addLoadCase(simFile)
analysis.addSNCurveByNameAndEnv('F3','seawater')
analysis.addAnalysisData()
analysis.Calculate()
analysis.Save(ftgFile)

# Result of fatigue life in each node
lifePerNode = analysis.getLifeList()
print(lifePerNode)
```


## Example 6 - Generates RAO plots from vessel type data
```
import NsgOrcFx as ofx

model = ofx.Model()

# Create a 'Vessel Type' object with default data
model.CreateObject(ofx.ObjectType.VesselType)

# Create RAO plots (amplitude and phase) and save to the defined folder
model.SaveRAOplots(r'tests\tmptestfiles')
```
![ plot generated with SaveRAOplots() method](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/Vessel_type1_Amplitude.png?raw=True)



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "NsgOrcFx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "NSG Engenharia <software@nsgeng.com>",
    "download_url": "https://files.pythonhosted.org/packages/54/65/50e745906afa2e48061a7678bce8ebbb03b4a8d322d5a8b548837467241c/nsgorcfx-1.0.27.tar.gz",
    "platform": null,
    "description": "# NsgOrcFx\r\nLibrary of tools for the OrcaFlex API\r\n\r\nThis package wraps the original API from Orcina (OrcFxAPI) to include:\r\n* methods: pre- and post-processing tools such as line selection, load case generation, modal and fatigue analysis\r\n* coding facilities: auto-complete and hints with descriptions in IDE\r\n\r\n\\\r\nAll the attributes and methods from the source (OrcFxAPI) still accessible in the same way.\r\n\r\n\\\r\nInstallation:\r\n```\r\npip install --upgrade NsgOrcFx\r\n```\r\n\r\n## Example 1 - Auto-complete feature of IDE (e.g. VS Code and Spyder)\r\n```\r\nimport NsgOrcFx\r\n\r\nmodel = NsgOrcFx.Model()\r\nline = model.CreateLine()\r\n\r\n```\r\nThe data name may be found in the `data` attribute with the auto complete of the IDE (e.g., Visual Studio Code, Spyder, and PyCharm).\r\n\r\n![Screenshot of auto-complete with the 'data' component of objects (e.g., line.data.{data name})](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/autocomplete_linedata.jpg?raw=True)\r\n\r\n\r\nIn addition, a hint shows the description of the parameter (mouse cursor stopped in the data name).\r\n\r\n![Screenshot of hint with the 'data' component of objects (e.g., line.data.{data name})](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/hint_linedata.jpg?raw=True)\r\n\r\n\r\nIn the exemple below, data names of `general`, `environment`, and `line` objects are accessed \r\n```\r\nmodel.general.data.ImplicitConstantTimeStep = 0.01 # data from general object\r\nmodel.environment.data.WaveHeight = 5.0 # data from environment object\r\nline.data.EndAConnection = 'Anchored' # data form the line object\r\n```\r\n\r\nThe line could be alse located by name with the following method. Although it could be done with the original method (`line = model['Line1']`), the new method is recommended to allow the functionality of auto-complete (`data` attribute)\r\n```\r\nline = model.findLineByName('Line1')\r\n```\r\n\r\nA list of all lines in the model may be retrieved and then select the first one by\r\n```\r\nlines = model.getAllLines()\r\nline1 = lines[0]\r\n```\r\n\r\n## Example 2 - Reduced simulation time for irregular wave\r\n```\r\nimport NsgOrcFx as ofx\r\n\r\nmodel = ofx.Model()\r\n\r\n# set irregular wave\r\nmodel.environment.data.WaveType = 'JONSWAP'\r\nmodel.environment.data.WaveHs = 2.5\r\nmodel.environment.data.WaveGamma = 2\r\nmodel.environment.data.WaveTp = 8\r\n\r\n# set reduced simulation duration with 200 seconds\r\nmodel.SetReducedSimulationDuration(200)\r\n\r\n# save data file to check the wave history\r\nmodel.Save('reduced.dat')\r\n\r\n# after executing this code, open the generated data file\r\n# then open Environment -> Waves preview, and set duration of 200s \r\n# click in View profile and observe that the largest event (rise or fall)\r\n# is in the midle of the sea elevation history\r\n\r\n```\r\n![Screenshot of Wave preview (Environment -> Waves preview -> View profile) for a simulation of irregular wave with reduced duration based on the largest rise/fall occurence](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/wave_preview.png?raw=True)\r\n\r\n\r\n## Example 3 - Generate load cases\r\n```\r\nimport NsgOrcFx\r\n\r\nmodel = NsgOrcFx.Model()\r\nmodel.CreateLine()\r\n\r\n# list of wave direction, height, and periods to define the Load Cases (LCs)\r\ndirections = [0, 45, 90] \r\nheights = [1.5, 2.0, 3.0]\r\nperiods = [5, 7, 9]\r\n\r\n# Folder to save the generated files (LCs)\r\noutFolder = 'tmp'\r\n\r\n# Regular waves\r\nmodel.GenerateLoadCases('Dean stream', directions, heights, periods, outFolder)\r\n\r\n```\r\n\r\n\\\r\nIn case of irregular wave:\r\n```\r\nmodel.GenerateLoadCases('JONSWAP', directions, heights, periods, outFolder)\r\n```\r\n\\\r\nTo run irregular waves with reduced simulation time, based on the occurance of the largest rise or fall in the specified storm period.\r\n```\r\nmodel.GenerateLoadCases('JONSWAP', directions, heights, periods, outFolder, reducedIrregDuration=200)\r\n```\r\n\r\n\r\n## Example 4 - Calculating modal analysis and getting the normalized modal shape \r\n```\r\nimport NsgOrcFx\r\n\r\nmodel = NsgOrcFx.Model()\r\nmodel.CreateLine()\r\n\r\nmodes = model.CalculateModal()\r\n\r\n# mode shape index (0 for the 1st)\r\nmodeIndex = 0\r\n\r\n# mode frequency\r\nfreq = modes.getModeFrequency(modeIndex)\r\n\r\n# if normalize = True, the displacements will be normalized, so the maximum total displacements is equal to the line diameter\r\n[arcLengths, Ux, Uy, Uz] = modes.GlobalDispShape('Line1', modeIndex, True)\r\nprint('Frequency = ', freq, 'Hz')\r\nprint(arcLengths, Ux, Uy, Uz)\r\n```\r\n\r\n\r\n## Example 5 - Defining fatigue analysis and getting the fatigue life calculated\r\n```\r\nimport NsgOrcFx\r\n\r\nsimFile = r'tests\\tmp\\fatigue.sim'\r\nftgFile = r'tests\\tmp\\fatigue.ftg'\r\n\r\n# First, it is necessary a model with simulation complete\r\nmodel = NsgOrcFx.Model()\r\nmodel.CreateLine()\r\nmodel.RunSimulation()\r\nmodel.Save(simFile) \r\n\r\n# The fatigue analysis is defined, including the S-N curve based on the DNV-RP-C203\r\nanalysis = NsgOrcFx.FatigueAnalysis()\r\nanalysis.data.AnalysisType = 'Rainflow'\r\nanalysis.data.LoadCaseCount = 1\r\nanalysis.addLoadCase(simFile)\r\nanalysis.addSNCurveByNameAndEnv('F3','seawater')\r\nanalysis.addAnalysisData()\r\nanalysis.Calculate()\r\nanalysis.Save(ftgFile)\r\n\r\n# Result of fatigue life in each node\r\nlifePerNode = analysis.getLifeList()\r\nprint(lifePerNode)\r\n```\r\n\r\n\r\n## Example 6 - Generates RAO plots from vessel type data\r\n```\r\nimport NsgOrcFx as ofx\r\n\r\nmodel = ofx.Model()\r\n\r\n# Create a 'Vessel Type' object with default data\r\nmodel.CreateObject(ofx.ObjectType.VesselType)\r\n\r\n# Create RAO plots (amplitude and phase) and save to the defined folder\r\nmodel.SaveRAOplots(r'tests\\tmptestfiles')\r\n```\r\n![ plot generated with SaveRAOplots() method](https://github.com/NSG-Engenharia/NsgOrcFx/blob/main/documentation/images/Vessel_type1_Amplitude.png?raw=True)\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Package with additional tools to the OrcFxAPI package",
    "version": "1.0.27",
    "project_urls": {
        "Homepage": "https://github.com/NSG-Engenharia/NsgOrcFx",
        "Issues": "https://github.com/NSG-Engenharia/NsgOrcFx/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f43e50e047f85e710864c1e8d608c6bff2ae36bb4d5424d3451d9d545a69b456",
                "md5": "7abae4d53f8a94186ce8a6d4ae78dab8",
                "sha256": "13309840cddf8f0d1743484e227cb2a16a8de12ff142e28f865c47557f3b2f05"
            },
            "downloads": -1,
            "filename": "NsgOrcFx-1.0.27-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7abae4d53f8a94186ce8a6d4ae78dab8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 40009,
            "upload_time": "2024-12-22T10:06:21",
            "upload_time_iso_8601": "2024-12-22T10:06:21.767895Z",
            "url": "https://files.pythonhosted.org/packages/f4/3e/50e047f85e710864c1e8d608c6bff2ae36bb4d5424d3451d9d545a69b456/NsgOrcFx-1.0.27-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "546550e745906afa2e48061a7678bce8ebbb03b4a8d322d5a8b548837467241c",
                "md5": "2bbb597291d00374635f6275ce2338be",
                "sha256": "16c911e7384aeda663f8e0852b1e6f40fcffe09418fc94340021d95e49132c3b"
            },
            "downloads": -1,
            "filename": "nsgorcfx-1.0.27.tar.gz",
            "has_sig": false,
            "md5_digest": "2bbb597291d00374635f6275ce2338be",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 35697,
            "upload_time": "2024-12-22T10:06:24",
            "upload_time_iso_8601": "2024-12-22T10:06:24.143595Z",
            "url": "https://files.pythonhosted.org/packages/54/65/50e745906afa2e48061a7678bce8ebbb03b4a8d322d5a8b548837467241c/nsgorcfx-1.0.27.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-22 10:06:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NSG-Engenharia",
    "github_project": "NsgOrcFx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "nsgorcfx"
}
        
Elapsed time: 0.42859s