Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems encountered when compiling V2 for matlab #274

Closed
frozenheartsaber opened this issue Nov 17, 2024 · 31 comments
Closed

Problems encountered when compiling V2 for matlab #274

frozenheartsaber opened this issue Nov 17, 2024 · 31 comments
Assignees

Comments

@frozenheartsaber
Copy link

Hello everybody

I am trying to use Moordyn with my code in matlab. I tried to compile it as mentioned in : https://moordyn.readthedocs.io/en/latest/compiling.html#id4
I installed Cmake, MinGW and added them into path. I find Cmake ask me to install a fortran installer which I fixed by installing mingw-w64-x86_64-gcc-fortran in MINGW64. But then Cmake shows :" PyPA’s build package is required. Please install it typing msys64/mingw64/bin/python3.12.exe -m pip install --upgrade build". I use cmd to install it and Cmake seems to run well, but when I use:
mingw32-make, it fails as shown in picture. I wonder how to fix it? I tried to reinstall mingw or cmake, nothing works.
error

@sanguinariojoe
Copy link
Collaborator

sanguinariojoe commented Nov 18, 2024 via email

@frozenheartsaber
Copy link
Author

Just disable the Python wrapper on CMake setting the option PYTHON_WRAPPER as OFF

On Sun, 17 Nov 2024, 23:36 frozenheartsaber, @.> wrote: Hello everybody I am trying to use Moordyn with my code in matlab. I tried to compile it as mentioned in : https://moordyn.readthedocs.io/en/latest/compiling.html#id4 I installed Cmake, MinGW and added them into path. I find Cmake ask me to install a fortran installer which I fixed by installing mingw-w64-x86_64-gcc-fortran in MINGW64. But then Cmake shows :" PyPA’s build package is required. Please install it typing msys64/mingw64/bin/python3.12.exe -m pip install --upgrade build". I use cmd to install it and Cmake seems to run well, but when I use: mingw32-make, it fails as shown in picture. I wonder how to fix it? I tried to reinstall mingw or cmake, nothing works. error.png (view on web) https://github.com/user-attachments/assets/d58b948a-a9b3-4866-9c76-7c6d6c140698 — Reply to this email directly, view it on GitHub <#274>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMXKKEXLNPOR43UFOLC6IT2BELALAVCNFSM6AAAAABR6MW3CWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGY3DMNRTG4ZDQNY . You are receiving this because you are subscribed to this thread.Message ID: @.>

I installed it and found only libmoordyn.dll in the source. As shown on the website, there should be libmoordyn、libmoordyn.2 and libmoordyn.2.2.

I added the path C:\Program Files (x86)MoorDynbin into Matlab, and I copied the code given in Matlab, but it could not run, I doubt if I forgot something. I hope to fix this problem.

f0d6294f-7402-49a2-a8bd-29d15c0c81f0
f4368f5d-d234-4fff-ae95-fa23b4f266ac
ba5b5bb7-a755-43c9-8f91-ab9d7337342d

@RyanDavies19
Copy link
Collaborator

Hi @frozenheartsaber,

It seems like the path you have added does not include the MATLAB wrapper files. Try specifically adding MoorDyn/build/wrappers/matlab to the MATLAB path. That directory should have a file for each MoorDyn function that can be called.

@frozenheartsaber
Copy link
Author

你好@frozenheartsaber

您添加的路径似乎不包含 MATLAB 包装器文件。请尝试专门添加MoorDyn/build/wrappers/matlab到 MATLAB 路径。该目录应该包含每个可调用的 MoorDyn 函数的文件。

Hi RyanDavies
I find those mex files in MoorDyn/build/wrappers/matlab are also included in C:\Program Files (x86)\Moordyn\bin. I added it into path, something went wrong without specific advice. It just tells me "Incorrect using". I hope to know what I shoud do to fix it.
6a3a9dc7-60ec-475a-8f1f-2b13f75b27ca
eb516f22-915a-4e4a-bcc1-e484c9306c8c

@RyanDavies19
Copy link
Collaborator

RyanDavies19 commented Nov 18, 2024

Hi @frozenheartsaber,

Can you share your MATLAB code (if it is different from the one shared above) and MoorDyn input file? I suspect things are linked up correctly but MoorDyn is being used incorrectly

@frozenheartsaber
Copy link
Author

Hi @frozenheartsaber,

Can you share your MATLAB code and MoorDyn input file? I suspect things are linked up correctly but MoorDyn is being used incorrectly

I find the reason, so sorry for my last question. I forgot I need to create a line.txt in this example. I will try to change my old .txt here to test again. Really thank you for your advice.

@frozenheartsaber
Copy link
Author

frozenheartsaber commented Nov 19, 2024

你好@frozenheartsaber

您能分享一下您的 MATLAB 代码(如果与上面分享的代码不同)和 MoorDyn 输入文件吗?我怀疑一切都正确连接了,但 MoorDyn 的使用方式不正确

Hi,RyanDavies
I tried to change a old txt and I hope to compare the result with Orcaflex. I find some problems during the test. I modelled a 1000 seconds tests with and without current. I did a similar test with codes shown in figure below in the past as I need to couple the motion of the fairlead with a rigid body, I changes x and xd each time step.
c1fce0da-5146-413e-a1bb-f68d433f1dcf
And I hope to know if my new code means the same? I think it works well, but I am not so sure.
46bf4b7c-b93a-42c2-aa4b-d696709ba3c0
One of the problem is that, in the new code , I use f in [t, f(i,1:3)] = MoorDynM_Step(system, x, xd, t, dt) and ten = MoorDynM_GetLineNodeTen(line, node_id-1) to get the tension in the fairlead but the results seems to be different. As I seen in the document , the tension at fairlead should be the same as I get from MoorDynM_Step. The results is shown in figure below
8dbf53df-d4de-44f4-a5d6-1769fd930a79 The difference becomes more obviously when the the number of anchor chain sections is smaller。
Another problem is I can not use " 1 Currents the water currents are provided in a grid (-)" or using implicit method as wilison in current code which may cause an error. I wonder how to fix those problems.

I followed my code below. Really thank you for your help.

testmoor.zip

@frozenheartsaber
Copy link
Author

frozenheartsaber commented Nov 20, 2024

Another problem is that, during the test above, I found the result different with Orcaflex when using catenary, the tension at the fairlead seems to be fun. But tensions of lines from the anchor point to the touch down point are different in Moordyn and Orcaflex. I think it might be caused by the friction force? As I changed the shear stiffness of the seabed to 0, the result seemed to be similar in Orcaflex. I changed the cbot and friction coefficient in .txt, but nothing changed. I also changed the time step and section length into smaller pieces , but nothing helps.

@sanguinariojoe
Copy link
Collaborator

sanguinariojoe commented Nov 20, 2024 via email

@sanguinariojoe
Copy link
Collaborator

sanguinariojoe commented Nov 20, 2024 via email

@RyanDavies19
Copy link
Collaborator

Yeah, MoorDyn and Orcaflex have different seabed friction models. Just look for some literature about that on Google Scholar. I tend to think that the Orcaflex model is rather inconsistent. But to be honest, I do not know any paper with an actual validation. Not for Orcaflex nor for MoorDyn. So take my comment just as an opinion.

On Wed, 20 Nov 2024, 16:16 frozenheartsaber, @.> wrote: Another problem is that, during the test above, I found the result different with Orcaflex when using catenary, the tension at the fairlead seems to be fun. But tensions of lines from the anchor point to the touch down point are different in Moordyn and Orcaflex. I think it might be caused by the friction force? As I changed the shear stiffness of the seabed to 0, the result seemed to be similar in Orcaflex. I changed the cbot and friction coefficient in .txt, but nothing changed. — Reply to this email directly, view it on GitHub <#274 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMXKKGB7FDU5WQ75MY4YLD2BSRWVAVCNFSM6AAAAABR6MW3CWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBYHA2TKNJTHE . You are receiving this because you commented.Message ID: @.>

I'll point to the references in the documentation for some papers regarding the seabed contact approaches used in MoorDyn: https://moordyn.readthedocs.io/en/latest/references.html#references

However note that the axial and transverse friction as described in https://doi.org/10.1088/1742-6596/2362/1/012018 have only been implemented in MD-F.

@frozenheartsaber
Copy link
Author

frozenheartsaber commented Nov 20, 2024

Thank you for your advice. I think other main problems will be that , I can not use current or wave by changing 0 or 1 in .txt, so as changing to the implicit time integration method. And I use my old code to make an example to do another test with current as given in the following zips. (results saves the .mat)(the fairlead point is also forced to move with assigned path)

1m_s_test_orca_compare.zip
results.zip

It can be found with figures below, at the begining of the simulation, an unexpected large force occurs in Moordyn, I think it is because Orcaflex did a static simulation before the dynamic simulation. I hope to try it in Moordyn. But as I can not use the new code with current, I have not tried it. And I think as said in the document, Moordyn has already used catenary solver for static caculation? In order to avoid numerical damping , I changed orcaflex into explicit calculation.

But It can also be seen that, the anchor force seems to be pretty different as I mentioned before, as I know it may be caused by different firiction from your suggestion. But no matter I change which parameter, the anchor force seems do not change. I wonder how to solve above problems, I do not know if it is because I am using matlab version or I missed something else?
farilead
anchor

@RyanDavies19
Copy link
Collaborator

Hi @frozenheartsaber,

I'm not sure I understand your question about currents and time integrators.

A couple things to check: Does MoorDyn reach equilibrium before the simulation states? If it fails to initialized you will get a warning in the console like: "Fairlead tensions did not converge". The initial force you see is likely due to a failure to find the steady state. Secondly, it seems that after this initial transient, the anchor force (Force on Line end A) converges on a similar value to your OrcaFlex outputs, just over 5e4 N. It might be helpful to output the motions of the fairlead point from MoorDyn using Point2PX/Y/Z. This will tell you if it is actually moving as you desire. Based on your outputs there, it seems the point is stationary.

@RyanDavies19
Copy link
Collaborator

If you could provide the console outputs moordyn produces, or your log file, it would help figure out what's going on here.

@frozenheartsaber
Copy link
Author

to check: Does MoorDyn reach equilibrium before the simulation states? If it fa
Hi RyanDavies,
The problem with current and time integrators is that I can not use implicit integrators or add current or wave conditions to mooring lines. I can only simulate mooring lines without current by using the new Matlab code, although I changed the options in .txt.
I put the log file and all inputs of this problem in the following problems_log_current_implicit.zip.
problems_log_current_implicit.zip

@RyanDavies19
Copy link
Collaborator

Hi @frozenheartsaber, I tried replicating your error and got:

ERR <path>/MoorDyn/source/Waves/WaveGrid.cpp:558 constructSteadyCurrentGrid(): Cannot read the file '/current_profile.txt'
Error (-1) during the Mooring System creation:
Exception while reading the input file
Error using testmoor (line 1)
MoorDyn reported an error

This might be a bug with the paths being picked up. I will take a look at it tomorrow.

For dev notes: this is caused by the path passed to waves->setup:

waves->setup(env, seafloor, _t_integrator, _basepath.c_str());

What issues have you had with the time integrators?

@frozenheartsaber
Copy link
Author

s->s
I put the .log with time integrator here. It shows "WRN D:\Moordyn\MoorDyn\source\MoorDyn2.cpp:2187 readOptionsLine(): Warning: Unrecognized option 'tscheme'"
line_implicit.log

@sanguinariojoe
Copy link
Collaborator

sanguinariojoe commented Nov 26, 2024 via email

@frozenheartsaber
Copy link
Author

你好@frozenheartsaber

我不确定我是否理解您有关当前和时间积分器的问题。

需要检查以下几点:MoorDyn 是否处于模拟状态之前达到平衡?如果初始化失败,您将在控制台中收到警告,例如:“导缆器张力未收敛”。您看到的初始力可能是由于未能成功找到稳定状态。其次,似乎此时初始瞬态之后,锚力(线端A上的力)收敛到与OrcaFlex输出相似的值,略为5e4 N。使用来自MoorDyn的Point2PX/Y/Z输出导缆器点的运动可能会有所帮助。这将告诉您它是否真的按照您的意愿移动。根据您那里的输出,该点似乎是原来的。

I added the section and get a better results, but the initial problem is still here. I added the log file and source code below. I did not find the Point2PX/Y/Z so I used x(:,i) obtained from belowing code as an instead to show the position of the top node.
"[,,x_moor(:,i),dx_moor(:,i),TopTension(:,i),time,delta_t] = calllib('libmoordyn2','MoorDyn_Step',system, x_moor(:,i), dx_moor(:,i), TopTension(:,i),time,delta_t);"

matlab_code_old.zip
log_txt_profile_out.zip

@frozenheartsaber
Copy link
Author

注意,它区分大小写。也许我们应该改变这一点

2024 年 11 月 26 日星期二 10:27,frozenheartsaber,@.> 写道:s->s 我将带有时间积分器的 .log 放在这里。它显示“WRN D:\Moordyn\MoorDyn\source\MoorDyn2.cpp:2187 readOptionsLine(): 警告:无法识别选项‘tscheme’”line_implicit.log < https://github.com/user-attachments/files/17917090/line_implicit.log > — 直接回复此电子邮件,在 GitHub 上查看 < #274 (comment) >,或取消订阅 < https://github.com/notifications/unsubscribe-auth/AAMXKKDH275OA5IYA2OTLFL2CQ5HDAVCNFSM6AAAAABR6MW3CWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBQGA4TINBXHE > 。您收到此邮件是因为您发表了评论。消息 ID:@.>

Thank you for your advice. And I tried to change RK4 into rk4 or reverse, it works well. But no matter using ACA5 or aca5 (given in the document), it can not find the right integrator.

@RyanDavies19
Copy link
Collaborator

RyanDavies19 commented Nov 26, 2024

Take care, It is case sensitive. Probably we should change that

Agreed @sanguinariojoe, while I'm changing the options list in Alex's PR I'll add this in

@RyanDavies19
Copy link
Collaborator

注意,它区分大小写。也许我们应该改变这一点

2024 年 11 月 26 日星期二 10:27,frozenheartsaber,@.> 写道:s->s 我将带有时间积分器的 .log 放在这里。它显示“WRN D:\Moordyn\MoorDyn\source\MoorDyn2.cpp:2187 readOptionsLine(): 警告:无法识别选项‘tscheme’”line_implicit.log < https://github.com/user-attachments/files/17917090/line_implicit.log > — 直接回复此电子邮件,在 GitHub 上查看 < #274 (comment) >,或取消订阅 < https://github.com/notifications/unsubscribe-auth/AAMXKKDH275OA5IYA2OTLFL2CQ5HDAVCNFSM6AAAAABR6MW3CWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBQGA4TINBXHE > 。您收到此邮件是因为您发表了评论。消息 ID:@.>

Thank you for your advice. And I tried to change RK4 into rk4 or reverse, it works well. But no matter using ACA5 or aca5 (given in the document), it can not find the right integrator.

Does moordyn say Invalid Average Constant Acceleration name format or Unknown time scheme?

@RyanDavies19
Copy link
Collaborator

你好@frozenheartsaber
我不确定我是否理解您有关当前和时间积分器的问题。
需要检查以下几点:MoorDyn 是否处于模拟状态之前达到平衡?如果初始化失败,您将在控制台中收到警告,例如:“导缆器张力未收敛”。您看到的初始力可能是由于未能成功找到稳定状态。其次,似乎此时初始瞬态之后,锚力(线端A上的力)收敛到与OrcaFlex输出相似的值,略为5e4 N。使用来自MoorDyn的Point2PX/Y/Z输出导缆器点的运动可能会有所帮助。这将告诉您它是否真的按照您的意愿移动。根据您那里的输出,该点似乎是原来的。

I added the section and get a better results, but the initial problem is still here. I added the log file and source code below. I did not find the Point2PX/Y/Z so I used x(:,i) obtained from belowing code as an instead to show the position of the top node. "[,,x_moor(:,i),dx_moor(:,i),TopTension(:,i),time,delta_t] = calllib('libmoordyn2','MoorDyn_Step',system, x_moor(:,i), dx_moor(:,i), TopTension(:,i),time,delta_t);"

matlab_code_old.zip log_txt_profile_out.zip

@frozenheartsaber that approach will work for getting the node positions in real time. In your MoorDyn outputs you need to specify specifically POINT2PX, POINT2PY, or POINT2PZ. Just double checking are you saying that one of those output channels was not working?

@frozenheartsaber
Copy link
Author

etter results, but the initial problem is still here. I added the log file and source code below. I did not find the Point2PX/Y/Z so I used x(:,i) obtained from belowing code as an instead to show the position of the top node. "[,,x_moor(:,i),dx_moor(:,i),TopTension(:,i),time,delta_t] = calllib('libmoordyn2','MoorDyn_Step',system, x_moor(:,i), dx_moor(:,i), TopTension(:,i),time,delta_t);"

matlab_code_old.zip log_txt_profile_out.zip

Sorry,I misunderstand POINT2PX that I thought I should find it in functions, I will use it to get some output.

@frozenheartsaber
Copy link
Author

frozenheartsaber commented Nov 26, 2024

Unrecognized option 'tscheme'"

It shows "Unrecognized option 'tscheme'"

@RyanDavies19
Copy link
Collaborator

RyanDavies19 commented Nov 26, 2024

Try tScheme

This case sensitivity stuff can be annoying. I'll work on making it case insensitive in an upcoming PR

@frozenheartsaber
Copy link
Author

Try tScheme

This case sensitivity stuff can be annoying. I'll work on making it case insensitive in an upcoming PR

Thank you for this advice. Implicit integration works now.

@RyanDavies19 RyanDavies19 self-assigned this Nov 26, 2024
@RyanDavies19
Copy link
Collaborator

RyanDavies19 commented Nov 26, 2024

Hi @frozenheartsaber, I tried replicating your error and got:

ERR <path>/MoorDyn/source/Waves/WaveGrid.cpp:558 constructSteadyCurrentGrid(): Cannot read the file '/current_profile.txt'
Error (-1) during the Mooring System creation:
Exception while reading the input file
Error using testmoor (line 1)
MoorDyn reported an error

This might be a bug with the paths being picked up. I will take a look at it tomorrow.

For dev notes: this is caused by the path passed to waves->setup:

waves->setup(env, seafloor, _t_integrator, _basepath.c_str());

What issues have you had with the time integrators?

PR #276 contains a fix to the path error you were seeing @frozenheartsaber. It was only appearing in the MATLAB wrapper, which we didn't have a robust set of tests for because MATLAB is annoying. If you compile the dev branch you should now be able to run things.

@frozenheartsaber
Copy link
Author

Thank you for your help! I will test it in next week. I was busy with some coupling problems last week.

@sanguinariojoe
Copy link
Collaborator

@frozenheartsaber , can we close this?

@frozenheartsaber
Copy link
Author

frozenheartsaber commented Dec 17, 2024

So sorry for my late reply. I was writing a code of rigid body in the past weeks. . I will focus on running the new code with Moordyn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants