Skip to content

Commit 55667f4

Browse files
authored
Merge pull request FloatingArrayDesign#140 from RyanDavies19/ryan_dev
Updates from dev before new version release
2 parents 3a78d32 + 89dd402 commit 55667f4

13 files changed

Lines changed: 122 additions & 90 deletions

File tree

docs/compiling.rst

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,65 @@ the Git window select "Clone Existing Repository".
165165

166166
The Git GUI to clone repositories
167167

168-
We are starting with Eigen3, so in the first box of the window that pops up set
168+
As a default, MoorDyn uses the Egien package that is internal in the source code.
169+
If you would like to use an external copy of Eigen, please follow the instructions
170+
in the :ref:`installing with external eigen <external_eigen>` note at this point.
171+
172+
We will install MoorDyn following a very similar process.
173+
Launch CMake again, and set "C:\MoorDyn\MoorDyn" in the source box and
174+
"C:\MoorDyn\MoorDyn.build" in the binaries box, clicking "Configure" afterwards.
175+
Select again the "MinGW Makefiles" for the generator.
176+
When the configuration options appear, set CMAKE_BUILD_TYPE as "Release", and
177+
enable FORTRAN_WRAPPER and PYTHON_WRAPPER:
178+
179+
.. figure:: win_cmake_moordyn.png
180+
:alt: Configuration options for MoorDyn
181+
182+
Configuration options for MoorDyn
183+
184+
You can also enable MATLAB_WRAPPER if you have MATLAB installed in your system.
185+
We are ready, click "Configure" once more and then "Generate".
186+
187+
Now go back to your Command Prompt from earlier (which has administrative rights), and
188+
type the following commands:
189+
190+
.. code-block:: bash
191+
192+
cd C:\MoorDyn\MoorDyn.build
193+
mingw32-make
194+
mingw32-make install
195+
196+
This will generate three libraries in the MoorDyn/build/source directory labeled
197+
libmoordyn, libmoordyn.2, and libmoordyn.2.2. The first two are symbolic links to the
198+
latter, setup that way for development purposes. In your project you should use
199+
libmoordyn.
200+
201+
202+
NOTE: If you want to generate a Windows installer, disable the PYTHON_WRAPPER
203+
option and type
204+
205+
.. code-block:: bash
206+
207+
cd C:\MoorDyn\MoorDyn.build
208+
mingw32-make
209+
cpack -C Release
210+
211+
NOTE: If you are working on a proxy serveryou may need to add the .crt file for your proxy
212+
configuration to the folder ``C:/msys64/etc/pki/ca-trust/source/anchors`` or equivalent for your
213+
system.
214+
215+
NOTE: You may need to upgrade or install the build tool using pip
216+
217+
.. code-block:: bash
218+
219+
\<path-to-python>/python<version>.exe -m pip install --upgrade build
220+
221+
NOTE: Installing External Eigen
222+
223+
.. _external_eigen:
224+
225+
To use an external copy of Eigen, ensure that the DEXTERNAL_EIGEN flag is turned on.
226+
In the first box of the window that pops up set
169227
"https://gitlab.com/libeigen/eigen.git", and in the second "C:\MoorDyn\eigen":
170228

171229
.. figure:: win_git_eigen.png
@@ -235,55 +293,6 @@ Now you just need to type the following commands:
235293
236294
We will need to use cmd with administrative rights later on, so do not close it.
237295

238-
Now we will install MoorDyn following a very similar process.
239-
Launch CMake again, and set "C:\MoorDyn\MoorDyn" in the source box and
240-
"C:\MoorDyn\MoorDyn.build" in the binaries box, clicking "Configure" afterwards.
241-
Select again the "MinGW Makefiles" for the generator.
242-
When the configuration options appear, set CMAKE_BUILD_TYPE as "Release", and
243-
enable FORTRAN_WRAPPER and PYTHON_WRAPPER:
244-
245-
.. figure:: win_cmake_moordyn.png
246-
:alt: Configuration options for MoorDyn
247-
248-
Configuration options for MoorDyn
249-
250-
You can also enable MATLAB_WRAPPER if you have MATLAB installed in your system.
251-
We are ready, click "Configure" once more and then "Generate".
252-
253-
Now go back to your Command Prompt from earlier (which has administrative rights), and
254-
type the following commands:
255-
256-
.. code-block:: bash
257-
258-
cd C:\MoorDyn\MoorDyn.build
259-
mingw32-make
260-
mingw32-make install
261-
262-
This will generate three libraries in the MoorDyn/build/source directory labeled
263-
libmoordyn, libmoordyn.2, and libmoordyn.2.2. The first two are symbolic links to the
264-
latter, setup that way for development purposes. In your project you should use
265-
libmoordyn.
266-
267-
268-
NOTE: If you want to generate a Windows installer, disable the PYTHON_WRAPPER
269-
option and type
270-
271-
.. code-block:: bash
272-
273-
cd C:\MoorDyn\MoorDyn.build
274-
mingw32-make
275-
cpack -C Release
276-
277-
NOTE: If you are working on a proxy serveryou may need to add the .crt file for your proxy
278-
configuration to the folder ``C:/msys64/etc/pki/ca-trust/source/anchors`` or equivalent for your
279-
system.
280-
281-
NOTE: You may need to upgrade or install the build tool using pip
282-
283-
.. code-block:: bash
284-
285-
\<path-to-python>/python<version>.exe -m pip install --upgrade build
286-
287296
Linux and Mac
288297
^^^^^^^^^^^^^
289298

source/Line.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,34 +485,27 @@ Line::initialize()
485485
&VF,
486486
&HA,
487487
&VA,
488-
N,
488+
N+1,
489489
snodes,
490490
Xl,
491491
Zl,
492492
Te);
493493

494494
if (success >= 0) {
495-
// It might happens that the output solution does not respect the
496-
// queried final point. See the pendulum example
497-
if (abs(Zl[N] - ZF) > Tol) {
498-
LOGWRN << "Wrong catenary initial profile for Line, "
499-
"intializing as linear "
500-
<< number << endl;
501-
} else {
502-
// the catenary solve is successful, update the node positions
503-
LOGDBG << "Catenary initial profile available for Line "
504-
<< number << endl;
505-
for (unsigned int i = 1; i < N; i++) {
506-
vec l(Xl[i] * COSPhi, Xl[i] * SINPhi, Zl[i]);
507-
r[i] = r[0] + l;
508-
}
495+
496+
// the catenary solve is successful, update the node positions
497+
LOGDBG << "Catenary initial profile available for Line "
498+
<< number << endl;
499+
for (unsigned int i = 1; i < N; i++) {
500+
vec l(Xl[i] * COSPhi, Xl[i] * SINPhi, Zl[i]);
501+
r[i] = r[0] + l;
509502
}
510503
} else {
511504
LOGWRN << "Catenary initial profile failed for Line " << number
512-
<< endl;
505+
<< ", initalizing as linear " << endl;
513506
}
514507
} else {
515-
LOGDBG << "Vertical initial profile for Line " << number << endl;
508+
LOGDBG << "Vertical linear initial profile for Line " << number << endl;
516509
}
517510

518511
LOGMSG << "Initialized Line " << number << endl;

source/Line.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Line final : public io::IO
137137
moordyn::real UnstrLend;
138138
/// line diameter
139139
moordyn::real d;
140-
/// line linear density
140+
/// line density (kg/m^3)
141141
moordyn::real rho;
142142
/// line elasticity modulus (Young's modulus) [Pa]
143143
moordyn::real E;

source/MoorDyn2.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,21 @@ moordyn::MoorDyn::MoorDyn(const char* infilename, int log_level)
108108
_basepath = _filepath.substr(0, lastSlash + 1);
109109
}
110110

111-
LOGMSG << "\n Running MoorDyn (v2.a10, 2022-01-01)" << endl
111+
LOGMSG << "\n Running MoorDyn (v2.0.0, 2023-09-18)" << endl
112112
<< " MoorDyn v2 has significant ongoing input file changes "
113113
"from v1."
114114
<< endl
115-
<< " Copyright: (C) 2021 National Renewable Energy Laboratory, "
115+
<< " Copyright: (C) 2023 National Renewable Energy Laboratory, "
116116
"(C) 2014-2019 Matt Hall"
117117
<< endl
118-
<< " This program is released under the GNU General Public "
119-
"License v3."
118+
<< " This program is released under the BSD 3-Clause license."
120119
<< endl;
121120

122121
LOGMSG << "The filename is " << _filepath << endl;
123122
LOGDBG << "The basename is " << _basename << endl;
124123
LOGDBG << "The basepath is " << _basepath << endl;
125124

126-
env->g = 9.8;
125+
env->g = 9.80665;
127126
env->WtrDpth = 0.;
128127
env->rho_w = 1025.;
129128
env->kb = 3.0e6;
@@ -956,7 +955,7 @@ moordyn::MoorDyn::ReadInFile()
956955
LOGERR << "Error in " << _filepath << ":" << i + 1 << "..."
957956
<< endl
958957
<< "'" << in_txt[i] << "'" << endl
959-
<< "7 fields are required, but just " << entries.size()
958+
<< "7 fields are required, but only " << entries.size()
960959
<< " are provided" << endl;
961960
return MOORDYN_INVALID_INPUT;
962961
}
@@ -2091,8 +2090,8 @@ moordyn::MoorDyn::detachLines(FailProps* failure)
20912090
moordyn::error_id
20922091
moordyn::MoorDyn::AllOutput(double t, double dt)
20932092
{
2094-
if (env->writeLog == 0)
2095-
return MOORDYN_SUCCESS;
2093+
// if (env->writeLog == 0)
2094+
// return MOORDYN_SUCCESS;
20962095

20972096
if (dtOut > 0)
20982097
if (t < (floor((t - dt) / dtOut) + 1.0) * dtOut)

source/QSlines.hpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Catenary(T XF,
9595
T* HAout,
9696
T* VAout,
9797
unsigned int Nnodes,
98-
const vector<T>& s,
98+
vector<T>& s,
9999
vector<T>& X,
100100
vector<T>& Z,
101101
vector<T>& Te)
@@ -109,6 +109,16 @@ Catenary(T XF,
109109
if (longwinded == 1)
110110
cout << "hi" << endl;
111111

112+
// Checking inverted points at line ends: from catenary.py in MoorPy
113+
bool reverseFlag;
114+
if ( ZF < 0.0 ){ // True if the fairlead has passed below its anchor
115+
ZF = -ZF;
116+
reverseFlag = true;
117+
if (longwinded == 1)
118+
cout << " Warning from catenary: "
119+
<< "Anchor point is above the fairlead point" << endl;
120+
} else reverseFlag = false;
121+
112122
// Maximum stretched length of the line with seabed interaction beyond which
113123
// the line would have to double-back on itself; here the line forms an "L"
114124
// between the anchor and fairlead (i.e. it is horizontal along the seabed
@@ -226,8 +236,8 @@ Catenary(T XF,
226236
// The current mooring line must be slack and not vertical
227237
Lamda0 = sqrt(3.0 * ((L * L - ZF2) / XF2 - 1.0));
228238
}
229-
// ! As above, set the lower limit of the guess value of HF to the tolerance
230-
HF = max((T)abs(0.5 * W * XF / Lamda0), Tol);
239+
240+
HF = abs(0.5 * W * XF / Lamda0);
231241
VF = 0.5 * W * (ZF / tanh(Lamda0) + L);
232242

233243
/*
@@ -570,5 +580,25 @@ Catenary(T XF,
570580
*HAout = HA;
571581
*VAout = VA;
572582

573-
return 1;
583+
if (reverseFlag) { // return values to normal
584+
reverse(s.begin(), s.end());
585+
reverse(X.begin(), X.end());
586+
reverse(Z.begin(), Z.end());
587+
reverse(Te.begin(), Te.end());
588+
for (unsigned int I = 0; I < Nnodes; I++){
589+
s[I] = L - s[I];
590+
X[I] = XF - X[I];
591+
Z[I] = Z[I] - ZF;
592+
}
593+
ZF = -ZF;
594+
}
595+
596+
// It might happen that the output solution does not respect the
597+
// queried final point. See the pendulum example
598+
if (abs(Z[Nnodes-1] - ZF) > Tol) {
599+
if (longwinded == 1)
600+
cout << "Fairlead and anchor vertical seperation has changed"
601+
<< ", aborting catenary solver ..." << endl;
602+
return -1;
603+
} else return 1;
574604
}

source/Rod.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ Rod::doRHS()
11321132
Mext += vec(Mtemp * sinBeta, -Mtemp * cosBeta, 0.0);
11331133

11341134
// axial drag
1135-
Dq[i] += VOF[i] * Area * env->rho_w * CdEnd * vq_mag * vq;
1135+
Dq[i] += 0.5 * VOF[i] * Area * env->rho_w * CdEnd * vq_mag * vq;
11361136

11371137
// long-wave diffraction force
11381138
const real V_temp = 2.0 / 3.0 * pi * d * d * d / 8.0;
@@ -1159,7 +1159,7 @@ Rod::doRHS()
11591159
Mext += vec(Mtemp * sinBeta, -Mtemp * cosBeta, 0.0);
11601160

11611161
// axial drag
1162-
Dq[i] += VOF[i] * Area * env->rho_w * CdEnd * vq_mag * vq;
1162+
Dq[i] += 0.5 * VOF[i] * Area * env->rho_w * CdEnd * vq_mag * vq;
11631163

11641164
// long-wave diffraction force
11651165
const real V_temp = 2.0 / 3.0 * pi * d * d * d / 8.0;

tests/beam.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define W 100.0
4848
#define EA 1.5e9
4949
#define EI 1.0e7
50-
#define G 9.81
50+
#define G 9.80665
5151

5252
bool
5353
compare(double v1, double v2)

tests/pendulum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pendulum()
113113
const double l = sqrt(x * x + z * z);
114114
CHECK_VALUE("L0", l0, l, 0.01 * l0, 0);
115115

116-
const double w = sqrt(9.81 / l0);
116+
const double w = sqrt(9.80665 / l0);
117117
const double T = 2.0 * M_PI / w;
118118
double dt = T / 100.0;
119119
double t = 0.0;

tests/rods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ added_mass()
5757
double r = 0.25;
5858
double V = length * M_PI * r * r;
5959
double rho_w = 1025;
60-
double g = 9.8;
60+
double g = 9.80665;
6161
double buoyancy = rho_w * V * g;
6262
double weight = mass * g;
6363
double Fnet = buoyancy - weight;

tests/seafloor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pendulum()
108108
double z_max = 5.0;
109109
double z_step = 1.0;
110110

111-
const double w = sqrt(9.81 / l0);
111+
const double w = sqrt(9.80665 / l0);
112112
const double T = 2.0 * M_PI / w;
113113
double dt = T / 20.0;
114114
double t = 0.0;

0 commit comments

Comments
 (0)