Code Monkey home page Code Monkey logo

moorpy's Introduction

MoorPy - Quasi-Static Mooring Analysis in Python

MoorPy is a design-oriented mooring system library for Python based around a quasi-static modeling approach.

Prerequisites

  • Python 3.9 or greater
  • The following packages: NumPy, MatPlotLib, pyyaml, scipy

Installation

MoorPy is available on PyPi via:

pip install MoorPy

For an editable install that relies on the local source code, first clone the repository. Then, from the command line in the main MoorPy directory, run the following commands based on your additional needs...

General

pip install .

Development

pip install .[dev]

Testing

pip install .[test]
pre-commit install --hook-type pre-commit --hook-type pre-push

Documentation

pip install .[docs]

MoorPy's documentation website is under development at https://moorpy.readthedocs.io

Citing

The MoorPy software can be cited as: M. Hall, S. Housner, S. Sirnivas, and S. Wilson. MoorPy: Quasi-Static Mooring Analysis in Python. National Renewable Energy Laboratory, 2021. https://doi.org/10.11578/dc.20210726.1.

moorpy's People

Contributors

erickaloz avatar gbarter avatar goharshoukat avatar mattehall avatar ryandavies19 avatar shousner avatar stefan-dalecki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moorpy's Issues

Cd_ax moor prop key issue

Description

Trying to use getLineProps() to get moor props from a yaml file, and I think there might be an issue with keys of some properties which are inconsistent between loadLineProps() and getLineProps().

In getLineProps() we look for 'Cd_ax' key in mat, and if it doesn't exist, we assign a default value:

if 'Cd_ax' in mat:
        CdAx = mat['Cd_ax']
    else:
        CdAx = 0.2

even though in the yaml file this key exists, after loading it gets changed to CdAx (no underscore) in getLineProps() by this line:
output[mat]['CdAx' ] = getFromDict(props, 'Cd_ax' , default=0.0)

As a result, the value of Cd_Ax is never taken from the yaml file and is always set to default (same for Ca_ax).

trying to display a file created by unload isn't working

I created a very trivial test program to try and understand displaying from an input file:

import numpy as np
import matplotlib.pyplot as plt
import moorpy as mp
from moorpy.MoorProps import getLineProps

ms = mp.System(file="sample.txt")

ms.initialize() # make sure everything's connected

ms.solveEquilibrium() # equilibrate
fig, ax = ms.plot() # plot the system in original configuration
plt.show()

I then create a file with the manual_system.py example and try to import it, but the resulting plot looks nothing like the one from manual_system.py

items are buoyant above sea level

if you make a line lighter than water, it will curve up above sea level.

I'm (ab)using moorpy to simulate cable driven robots (attach some winches at given points and suspend something between them) so all my points are above 0 but if I make the volume/weight ratio of a line too light, it curves up instead of down.

getLineProps arguments check

Description

On dev branch, in getLineProps function of helpers.py lines 622-665, there is a check for having both the source and lineProps arguments not None, but it is only done after assigning the inputs from the yaml file to the lineProps variable, so the if not lineProps==None statement can never be False.

Current behavior

Warning: both lineProps and source arguments were passed to getLineProps. lineProps will be ignored is always printed out if source is not None, regardless of the lineProps argument.

forces are far too high

I configure a simple 2d test and the forces after solving seem far too high

import numpy as np
import matplotlib.pyplot as plt
import moorpy as mp
from moorpy.MoorProps import getLineProps

test = mp.System(rho=0)
test.display=5
test.addLineType("main", 0.001, .14, 1e8)
test.addPoint(1, [ -2, 0, 2])
test.addPoint(1, [ 2, 0, 2])
test.addPoint(0, [ 0, 0, 1], m=2)
test.addLine(2.4, "main",100,1,3)
test.addLine(2.4, "main",100,2,3)

test.initialize()
print("tension on line 1 ", test.lineList[0].getTension(0))
print("tension on line 2 ", test.lineList[1].getTension(0))
fig, ax = test.plot2d()                                         # plot the system in original configuration
test.solveEquilibrium()
fig, ax = test.plot2d(ax=ax, color='red')
test.unload("sample-test.txt")
print("position of vertex:", test.pointList[2].r)
print("force: ", test.pointList[2].getForces())
print("tension on line 1 ", test.lineList[0].getTension(0))
print("tension on line 2 ", test.lineList[1].getTension(0))
plt.show()

the run shows:

tension on line 1  3.316107942198013
tension on line 2  3.316107942198013
 mooringEq X=[0. 0. 1.]
 mooringEq f=[  0.           0.         -10.89274317]
 mooringEq X=[-6.14721388e-33 -1.17560694e-16  2.18537683e-01]
 mooringEq f=[0.00000000e+00 1.01816341e-09 1.54287891e+07]
 mooringEq X=[-5.46088357e-33 -1.43598175e-16  5.88568566e-01]
 mooringEq f=[0.00000000e+00 2.34083681e-10 2.30080642e+06]
 mooringEq X=[-4.48518270e-33 -1.83264666e-16  6.68476925e-01]
 mooringEq f=[0.00000000e+00 1.71378957e-11 1.24503070e+05]
 mooringEq X=[-4.48518270e-33 -1.83264666e-16  6.68476925e-01]
 mooringEq f=[0.00000000e+00 1.71378957e-11 1.24503070e+05]
attempting to write sample-test.txt for MoorDyn v2
Successfully written sample-test.txt input file using MoorDyn v2
position of vertex: [-4.48518270e-33 -1.83264666e-16  6.68476925e-01]
force:  [0.00000000e+00 1.71378957e-11 1.24503070e+05]
tension on line 1  112343.32877753118
tension on line 2  112343.32877753118

based on the debug printout, it looks like the first iteration has the expected force of gravity (or close to it anyway, but the second iteration moves the force from -10 to + 1.5E7

it may be that what is happening is that I'm operating at a small enough scale that the time step is excessive and as a result, it moves too far, stretching the wires, producing insane forces. If this is it, I am not seeing where to change the resolution.

Change in stiffness matrix when selecting plots parameter in solveEquilibrium

Dear Moorpy developers,

I noticed a strange behavior of MoorPy 0.9.0 when estimating the stiffness matrix of the OC3-Hywind system. Indeed, the value of the lastly mentioned matrix varies depending on the selection (or not) of the plots parameter in the solveEquilibrium method.

Below is the input file I used with MoorPy:

--------------------- MoorDyn Input File ------------------------------------
Mooring system for OC3-Hywind
TRUE Echo - echo the input file data (flag)
---------------------- LINE DICTIONARY -----------------------------------------------------
LineType Diam MassDenInAir EA cIntDamp EI Can Cat Cdn Cdt
(-) (m) (kg/m) (N) (Pa-s) (N-m^2) (-) (-) (-) (-)
main 0.09 77.7066 384.243E6 -0.8 1.0 0.0 1.6 0.1
--------------------- ROD DICTIONARY -----------------------------------------------------
RodType Diam MassDenInAir Can Cat Cdn Cdt
(-) (m) (kg/m) (-) (-) (-) (-)
----------------------- BODY LIST -----------------------------------
BodyID X0 Y0 Z0 r0 p0 y0 Xcg Ycg Zcg M V IX IY IZ CdA-x,y,z Ca-x,y,z
(-) (m) (m) (m) (deg) (deg) (deg) (m) (m) (m) (kg) (m^3) (kg-m^2) (kg-m^2) (kg-m^2) (m^2) (-)
1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -89.9155 7466.33E3 8026.5 4229.23E6 4229.23E6 164.23E6 0 0 0 0
---------------------- ROD LIST --------------------
RodID Type/BodyID RodType Xa Ya Za Xb Yb Zb NumSegs Flags/Outputs
(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)
---------------------- POINT LIST -----------------------------------------------------
Node Type X Y Z M V FX FY FZ CdA Ca
(-) (-) (m) (m) (m) (kg) (m^3) (kN) (kN) (kN) (m2) ()
1 Vessel 5.2 0.0 -70.0 0 0 0 0 0 0 0
2 Vessel -2.6 4.5 -70.0 0 0 0 0 0 0 0
3 Vessel -2.6 -4.5 -70.0 0 0 0 0 0 0 0
4 Fixed 853.87 0.0 -320.0 0 0 0 0 0 0 0
5 Fixed -426.94 739.47 -320.0 0 0 0 0 0 0 0
6 Fixed -426.94 -739.47 -320.0 0 0 0 0 0 0 0
---------------------- LINE LIST -----------------------------------------------------
Line LineType UnstrLen NumSegs NodeAnch NodeFair Flags/Outputs
(-) (-) (m) (-) (-) (-) (-)
1 main 902.2 20 4 1 pt
2 main 902.2 20 5 2 pt
3 main 902.2 20 6 3 pt
---------------------- SOLVER OPTIONS ---------------------------------------
0.001 dtM - time step to use in mooring integration
0 WaveKin - wave kinematics flag (1=include(unsupported), 0=neglect, 3=currentprofile.txt)
3.0e+06 kb - bottom stiffness
3.0e+05 cb - bottom damping
320.00 WtrDpth - water depth
4.0 ICDfac - factor by which to scale drag coefficients during dynamic relaxation IC gen
0.001 ICthresh - threshold for IC convergence
60 ICTmax - threshold for IC convergence
------------------------ OUTPUTS --------------------------------------------
FairTen1
FairTen2
FairTen3
AnchTen1
AnchTen2
AnchTen3
END
------------------------- need this line --------------------------------------

And hereafter, the python script used to compute the stiffness matrices:

import numpy as np
import moorpy as mp
# Load the MorrDyn file
ms = mp.System('NRELOffshrBsline5MW_OC3Hywind_MoorDyn.dat', depth=320)

ms.initialize(plots=0)
ms.solveEquilibrium(DOFtype="free", plots=0, rmsTol=10, maxIter=200)
K_mooring  = ms.getSystemStiffness(DOFtype="free", dx = 0.1, dth = 0.1, solveOption=1, plots=0)
ms_1 = mp.System('NRELOffshrBsline5MW_OC3Hywind_MoorDyn.dat', depth=320)
ms_1.initialize(plots=0)
ms_1.solveEquilibrium(DOFtype="free", plots=1, rmsTol=10, maxIter=200)
K_mooring_1  = ms_1.getSystemStiffness(DOFtype="free", dx = 0.1, dth = 0.1, solveOption=1, plots=0)

Then, I figured out, thanks to the source code, that the method getSystemStiffness is calling solveEquilibrium function with plots parameter sets to zero. Thus, I am now using the following approach to get the stiffness matrix:

import numpy as np
import moorpy as mp
ms = mp.System('NRELOffshrBsline5MW_OC3Hywind_MoorDyn.dat', depth=320)
ms.initialize(plots=0)
K_mooring = ms.getSystemStiffness(DOFtype="free", dx = 0.1, dth = 0.1, solveOption=1, plots=0)

Best regards,

MoorProps in the __init__.py script

Hi,
I'm not sure why the functions in the MoorProps.py script were not included in the moorpy declaration. I've added it into my installation though. Thought it might have been skipped accidentally so flagging it here.

Thanks!

Problem when reading input files

Dear development team,

Similarly, as #3, I am also planning to use MoorPy to estimate the stiffness matrix of a given mooring system. However, I am having problems when trying to run the library.

I tried the master branch as well as the develop branch. The problem stated below was also observed in the most up-to-date version (commit b01c3c9).

When I try to run my code, I get the following error:
ValueError: Point ID (1800000) out of bounds for line 1 end A attachment.

The same error happens when I try to replicate the same code shown in #3 and the example "imported_system.py". I also tried to run the code in the imported_system.py example with the sample input file given in the documentation.

Therefore, I would like ask if there was any change in the way that the files are read that is not documented or if I somehow let something pass.

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.