OpenFAST / matlab-toolbox

Collection of Matlab tools developed for use with OpenFAST
Apache License 2.0
50 stars 67 forks source link

Feature/Add MoorDyn capability - rev1 #21

Closed pschuenemann closed 3 years ago

pschuenemann commented 3 years ago

Hello,

this is the second try of adjusting Fast2Matlab and Matlab2Fast to be able to properly handle MoorDyn input files. In my first try/pull request (#20) it seems like I have totally rewritten Fast2Matlab, which is not the case.

Hopefully, this pull request is now clean and better readable. If there are any further suggestions for changes, just let me know.

Best regards, Paul Schünemann

P.S.: For this pull request I restarted from scratch. Doing this I accidentially committed my changes to my master branch at some point. As I am quite new to git I struggeled a bit with undoing this. But finally, I hope that I was successfull in this and that there are no traces of this mistake in my pull request anymore.

ebranlard commented 3 years ago

Thanks for your efforts and sharing your code! It's easier to see the changes now. Things look good to me, I'll wait a bit to see if any one else has a comment.

pschuenemann commented 3 years ago

Yeah, that's a good idea to leave it open a bit. Especially as I have two comments by myself which came up when I used my modified files. The first one is a fix of a bug I introduced with a149ae6 and secondly I slightly adjusted the format specifiers when writing the MoorDyn tables to prevent losing precision and to get nicer tables (see my two latest commits).

Hopefully, there are no further bugs, but in my test runs everything worked like expected. Let me know if there is anything else that needs modification.

ebranlard commented 3 years ago

Sounds good, thanks a lot for the update. I'll see if maybe @mattEhall can try reading/writing a couple of files and give feedback.

pschuenemann commented 3 years ago

Yes, that would be good. Meanwhile, I had to fix another bug which I have introduced and that appeared when I tried to read/write some other file types (e.g. AeroDyn input files).

Sorry for these constant updates. Next time I will test my code more thoroughly before doing a pull request.

ebranlard commented 3 years ago

Our colleague S. Wilson tried it out and mentioned that it worked great. He had the following minor comment "The Solver Options section of the Moordyn input file is not transferred over into MATLAB using FAST2Matlab(). This means that you must rely on the values in the template files, and cannot use this tool to automatically change the them. I’ve never had a reason to change the Solver Options between simulations, so I don’t think this is a big deal."

Let me know if you want to account for this, otherwise, I'll merge this pull request.

pschuenemann commented 3 years ago

Hey @ebranlard, Thanks for sharing the comment. I did a little test on this and for me it worked as intended, i.e. all changes to values in the solver options are also written in the new output file.

Here is the Matlab code of what and how I have tested:

TemplateFile = 'NREL5MW_OC4Semi_MoorDyn.dat'
NewFile = 'New_NREL5MW_OC4Semi_MoorDyn.dat'

FASTPar = FAST2Matlab(TemplateFile,2); % 2: number of header lines of a MoorDyn input file

FASTPar.Val{5,1} = 5;   %set 'dtM' to some arbitrary value
FASTPar.Val{6,1} = 6;   %set 'kbot' to some arbitrary value
FASTPar.Val{7,1} = 7;   %set 'cbot' to some arbitrary value     
FASTPar.Val{8,1} = 8;   %set 'dtIC' to some arbitrary value     
FASTPar.Val{9,1} = 9;   %set 'TmaxIC' to some arbitrary value   
FASTPar.Val{10,1} = 10;   %set 'CdScaleIC' to some arbitrary value
FASTPar.Val{11,1} = 11;   %set 'threshIC' to some arbitrary value 

Matlab2FAST(FASTPar,TemplateFile,NewFile,2); % 2: number of header lines of a MoorDyn input file

Might you or your colleague let me know some more details what haven't worked for you. Then, I would try to account for it.

SamWilson22 commented 3 years ago

I see, I was just looking in the wrong place. Because the other inputs were separated by their header, I was expecting the same for solver options.

We can go ahead with the merge.

pschuenemann commented 3 years ago

Ah ok, I understand and am glad that there isn't another bug. Actually, I tried to adopt the same behaviour that FAST2Matlab/Matlab2FAST also uses for other input files (like AeroDyn, ElastoDyn), meaning that only the input tables are separated by their header and all other parameters of the input file are stored in the FASTPar.Val/FASTPar.Label variables. @SamWilson22 Thanks for testing my code.

ebranlard commented 3 years ago

Thanks again for your work.