Name | NsgOrcFx JSON |
Version |
1.0.30
JSON |
| download |
home_page | None |
Summary | Package with additional tools to the OrcFxAPI package |
upload_time | 2025-02-11 04:35:55 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
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).

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

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
```

## 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')
```

## Example 7 - Extract extreme (max. and min.) Constraint loads (force and moment) from multiple simulation files
```
import NsgOrcFx as ofx
model = ofx.Model()
# create the objects (vessel, constraint, and line)
vessel = model.CreateObject(ofx.ObjectType.Vessel)
constraint = model.CreateObject(ofx.ObjectType.Constraint)
line = model.CreateObject(ofx.ObjectType.Line)
# connect the constraint to the vessel
constraint.name = 'Hang-off'
constraint.InFrameConnection = vessel.name
constraint.InFrameInitialX = 35
constraint.InFrameInitialY = 0
constraint.InFrameInitialZ = -7
constraint.InFrameInitialDeclination = 155 # adjust the nominal top angle
# connect the line End A to the constraint,
# anchor the End B, 155m horizontally away from A,
# and set the line length
line.EndAConnection = constraint.name
line.EndAX, line.EndAY, line.EndAZ = 0, 0, 0
line.EndAxBendingStiffness = ofx.OrcinaInfinity() # to produce moment reaction loads to extract
line.EndBConnection = 'Anchored'
line.PolarReferenceAxes[1] = 'Global Axes'
line.PolarR[1], line.EndBY, line.EndBHeightAboveSeabed = 155, 0, 0
line.Length[0] = 200
# generate the load cases (Example #3)
model.GenerateLoadCases('Dean stream', [135,180,225], [6,7], [9,10], '.')
# run the simulations with multi-threading
ofx.ProcMultiThread('.','.')
# extract extreme loads for the constraint
ofx.ExtremeLoadsFromConstraints('.','.\Results.xlsx')
```

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/67/4a/8edcdb051e27833baa38b2209337d2c2f43ce4a411575235d445be82d31f/nsgorcfx-1.0.30.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\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\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\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\r\n\r\n\r\n## Example 7 - Extract extreme (max. and min.) Constraint loads (force and moment) from multiple simulation files\r\n```\r\nimport NsgOrcFx as ofx\r\n\r\nmodel = ofx.Model()\r\n\r\n# create the objects (vessel, constraint, and line)\r\nvessel = model.CreateObject(ofx.ObjectType.Vessel)\r\nconstraint = model.CreateObject(ofx.ObjectType.Constraint)\r\nline = model.CreateObject(ofx.ObjectType.Line)\r\n\r\n# connect the constraint to the vessel\r\nconstraint.name = 'Hang-off'\r\nconstraint.InFrameConnection = vessel.name\r\nconstraint.InFrameInitialX = 35\r\nconstraint.InFrameInitialY = 0\r\nconstraint.InFrameInitialZ = -7\r\nconstraint.InFrameInitialDeclination = 155 # adjust the nominal top angle\r\n\r\n# connect the line End A to the constraint, \r\n# anchor the End B, 155m horizontally away from A, \r\n# and set the line length\r\nline.EndAConnection = constraint.name\r\nline.EndAX, line.EndAY, line.EndAZ = 0, 0, 0\r\nline.EndAxBendingStiffness = ofx.OrcinaInfinity() # to produce moment reaction loads to extract\r\nline.EndBConnection = 'Anchored'\r\nline.PolarReferenceAxes[1] = 'Global Axes'\r\nline.PolarR[1], line.EndBY, line.EndBHeightAboveSeabed = 155, 0, 0\r\nline.Length[0] = 200\r\n\r\n# generate the load cases (Example #3)\r\nmodel.GenerateLoadCases('Dean stream', [135,180,225], [6,7], [9,10], '.')\r\n\r\n# run the simulations with multi-threading\r\nofx.ProcMultiThread('.','.')\r\n\r\n# extract extreme loads for the constraint\r\nofx.ExtremeLoadsFromConstraints('.','.\\Results.xlsx')\r\n```\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Package with additional tools to the OrcFxAPI package",
"version": "1.0.30",
"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": "e2ce1a547ff17d181b3dd7bbed3186716468eca4c786bcf914059d7e87fba37f",
"md5": "a2e55c495e99e579d015022a30a8bb1d",
"sha256": "1fe666bb050b0dfdb724bd58f2d3d9c3a06e415bd61db033292ff43d3a6ee32e"
},
"downloads": -1,
"filename": "NsgOrcFx-1.0.30-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a2e55c495e99e579d015022a30a8bb1d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 47242,
"upload_time": "2025-02-11T04:35:53",
"upload_time_iso_8601": "2025-02-11T04:35:53.527111Z",
"url": "https://files.pythonhosted.org/packages/e2/ce/1a547ff17d181b3dd7bbed3186716468eca4c786bcf914059d7e87fba37f/NsgOrcFx-1.0.30-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "674a8edcdb051e27833baa38b2209337d2c2f43ce4a411575235d445be82d31f",
"md5": "b0b75b392e698cfa234b613f5cf8e4a0",
"sha256": "299d012d36c99f588db8927ee74c666859b5676d69da987526b775d220df1c86"
},
"downloads": -1,
"filename": "nsgorcfx-1.0.30.tar.gz",
"has_sig": false,
"md5_digest": "b0b75b392e698cfa234b613f5cf8e4a0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 42903,
"upload_time": "2025-02-11T04:35:55",
"upload_time_iso_8601": "2025-02-11T04:35:55.313057Z",
"url": "https://files.pythonhosted.org/packages/67/4a/8edcdb051e27833baa38b2209337d2c2f43ce4a411575235d445be82d31f/nsgorcfx-1.0.30.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-11 04:35:55",
"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"
}