How to use Map++ with Python

Hello,

I’m running 64 bit Windows 7 and am able to run the test files from the mmasciola bitbucket repo using python (however I’m using the precompiled DLL’s from the archive available on the project’s homepage).

Instead of using input files, I’m trying to run everything from a single python file (i.e. provide inputs via python functions so I can iterate some of the parameters for a design). I somehow got my hands on a PDF titled “Instructional and Theory Guide to the Mooring Analysis Program Phase I: The Multi-Segmented Quasi-Static Model” that has an example of how to do this but I believe this PDF is old and the functions mentioned there are different than what I see in the python_driver in the latest release.

Is there documentation or an example for using python with the latest release somewhere?

Thanks,
Aaron O’Toole

Sorry for the delay. I just noticed this message. I’m trying migrate the documentation online, but this has a low priority since it is not a funded project. Also, most examples in the PDF are for the old version of MAP and no longer are relevant for the latest releases. There’s a Python example recently uploaded online:

Unfortunately the API itself is not documented, but you can go by the method definitions starting on line 383 in mapsys.py, or defer directly to the MAP++ source in mapapi.c. The Python methods are wrappers to functions in mapapi.c:

bitbucket.org/mmasciola/map-plu … sys.py-383

Dear everybody.

I want to get the mooring stiffness matrix of a mooring system design by using MAP++ in Python. I have tried running the example on the online documentation page of MAP++ after installing the mapsys.py module in Python2.7. However, I get the following error message:

================ RESTART: C:\FAST_tools\MAP\MAP_mooring.py =================

Traceback (most recent call last):
File “C:\FAST_tools\MAP\MAP_mooring.py”, line 10, in
from mapsys import *
File “C:\Python27\mapsys.py”, line 26, in
class Map(object):
File “C:\Python27\mapsys.py”, line 27, in Map
File “C:\Python27\lib\ctypes_init_.py”, line 440, in LoadLibrary
return self.dlltype(name)
File "C:\Python27\lib\ctypes_init
.py", line 362, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] Det angivne modul blev ikke fundet

If someone succeeded in running MAP++ in Python or have some alternative approach to get the mooring stiffness matrix, I would be very happy to learn more.

Hi Jacob,

I think the issue is python can’t locate the map library. There’s a line in mapsys.py file to set the map dll path. Try changing the path directory to point to the DLL, and python should then be able to load the library. The change should be on 29 just after the “Map” class declaration , i.e., look for this line:

Hope this helps,

Hi everyone,
I am an undergraduate student who is doing project using the MAP++. I am a beginner in Python and programming. When i try to run the main.py on Mac OS. The system cannot locate the “libmap-1.20.10.so, 6”.
I read the FAQ on the MAP++ Homepage and it says i need to change the path to locate “libmap-1.20.10.so, 6” correctly. However, i cannot find this file in the whole package i downloaded from the MAP++ homepage.
Could anyone help me ?

Problem has been solved by putting letter “r” in front of the path(i.e r"C:…)

I should make it a habit to check this forum more frequently… but I’m glad it was resolved before I could respond. To follow up on the question, this link may help others with similar problems in the future:

stackoverflow.com/questions/1940 … t-be-found

If the path name has spaces, I think the 3rd option in the first answer would be the best option. I will link this post to the MAP FAQ page shortly.

Dear Jason,

I´m trying to reproduce the OC3 moorings force-displacement relationship using MAP++ by calling it through Python as is it discussed in the following posts: Force-Displacement relationship of OC4 DeepCwind Mooring sys - #5 by Yingyi.Liu. And the information provided in map-plus-plus.readthedocs.io/en … index.html

With that I am able to get the linearized stiffness matrix in equilibrium position as it is reported in the OC3 model documentation (nrel.gov/docs/fy10osti/47535.pdf): [Image3.jpg attached]

However, when I try to define the force-displacement relationship by summing up fairleads’ forces from all the lines (Fx, Fy and Fz), I achieved the following results for surge displacement: [Image1.png Attached]

Which seems to be the expected results with a factor of -1 applied to all the forces when they are compared with the OC3 report: [Image2.jpg attached]

II have thought the problem may arise from the inputs I gave to the simulation, where I define one mooring line as the OC3 documentation explained. The input file (.map) is online available here: bitbucket.org/mmasciola/map-plu … Hywind.map

When a positive surge displacement is applied, I expect to get a negative force in X direction but is not the case.

So, I don’t really know what’s going on with MAP++. Is there anything I should consider with the coordinate systems? Or within Python set up?

Thank you very much!

Ander

Dear Ander,

The figure from the OC3 report shows the loads applied to the floating substructure from the mooring system. However, the outputs from MAP++ are the loads applied to the mooring system from the floating substructure. These are equal in magnitude, but opposite in sign. You can see the same sign reversal in the map.f90 source code used to interface MAP++ to OpenFAST–see the bottom of SUBROUTINE MAP_CalcOutput().

Best regards,

Hi all,

I am trying to run MAP++ on Windows using the python driver. I downloaded the package from Bitbucket. When running it, I’m getting the following error:

I’ve tried Python 3 and 2, both give errors. In mapsys.py I’m using

lib = cdll.LoadLibrary("./map_x64.dll")


and I have the map_x64.dll stored directly in the folder containing the mapsys.py script, so it seems like it’s being accessed alright, but for some reason one of the functions cannot be found.

Full log:

  File "main.py", line 35, in <module>
from mapsys import *
File "H:\mooring_linearisation\map\map-plus-plus\mmasciola-map-plus-plus-79719397feaa\python_driver\mapsys.py", line 28, in <module>
class Map(object):
File "H:\mooring_linearisation\map\map-plus-plus\mmasciola-map-plus-plus-79719397feaa\python_driver\mapsys.py", line 626, in Map
lib.map_offset_fairlead.argtypes = [MapInput_Type, c_int, c_double, c_double, c_double, c_char_p, POINTER(c_int)]
File "C:\Users\gkb20193\Miniconda3\envs\map_py2\lib\ctypes\__init__.py", line 379, in __getattr__
func = self.__getitem__(name)
File "C:\Users\gkb20193\Miniconda3\envs\map_py2\lib\ctypes\__init__.py", line 384, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))


2 Likes

Dear All,
I have the same problem using MAP++ with Python. Has anyone had and solved this problem please ?
Best regards,
Pierre

Hi Pierre/all,
We have a new Python-based quasi-static mooring model called MoorPy that you could use: https://moorpy.readthedocs.io It can read a similar input file format, although there are some differences (it is set up to match the latest version of MoorDyn). I generally recommend using MoorPy because it is more robust. However, MAP++ could be better to use if you are trying to match OpenFAST simulations that use MAP++.
Best,
Matt

Hi Matt,

Will MoorPy be integrated to OpenFAST in the future? At present, it seems that only MAP++ can be linearized in OpenFAST. I have a quick look at MoorPy and find that it can calculate stiffness matrix for coupled degrees of freedom of a mooring system. So I guess it can augment OpenFAST linearization.

Regards,
Ran

Dear @Ran.Tu,

There are not currently plans to interface MoorPy to OpenFAST as an alternative to MAP++, but perhaps this will happen in the future.

Best regards,