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

Update MD-F comparison to point to OpenFAST/dev #232

Open
wants to merge 134 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
28b2fb1
Starting 2.3.4
sanguinariojoe Jun 24, 2024
550648b
Let's start building and testing MoorDynF
sanguinariojoe Jun 18, 2024
bbfe6ae
We do not need VTK
sanguinariojoe Jun 18, 2024
3e6cd67
pypa's build pacakge is required
sanguinariojoe Jun 18, 2024
42ae5e4
entries[0] is the failure index
sanguinariojoe Jun 20, 2024
c4b82d8
kbot and cbot options are accepted by MDF
sanguinariojoe Jun 20, 2024
fc94882
WIP verification against MDF
sanguinariojoe Jun 20, 2024
89a20e1
Verifier Python script
sanguinariojoe Jun 20, 2024
e237fd9
First try of verifying
sanguinariojoe Jun 20, 2024
1c4a758
The summary was wrong
sanguinariojoe Jun 20, 2024
6988737
Drop the automatic trigger on mdf branch
sanguinariojoe Jun 20, 2024
8b860b8
Slightly improved summary
sanguinariojoe Jun 20, 2024
8a85443
Send an error to github CI/CD if something fails
sanguinariojoe Jun 20, 2024
b05dde6
Check for MDF '***' outputs
sanguinariojoe Jun 24, 2024
7b20823
dict_values would be wrongly checked by np.all
sanguinariojoe Jun 24, 2024
d1d83be
I forgot the assert
sanguinariojoe Jun 24, 2024
dfb3227
Drop OpenGL functions
sanguinariojoe Jun 25, 2024
7d411cf
Removed a trace (unused) of OpenGL on Rust
sanguinariojoe Jun 25, 2024
71cec56
Added CFL base class
sanguinariojoe Dec 22, 2023
fad5f96
Added a CFL to the lines
sanguinariojoe Dec 22, 2023
4e33a7a
Added a CFL option to atumatically set the timestep according to the …
sanguinariojoe Dec 22, 2023
646672a
This is not anymore a problem
sanguinariojoe Dec 30, 2023
d3952e6
Stationary solution for initializations (and WIP Local-Euler)
sanguinariojoe Dec 30, 2023
840549b
Drop debugging VTK file printing
sanguinariojoe Dec 31, 2023
495cabc
Test the local-Euler and Euler time schemes consistency
sanguinariojoe Dec 31, 2023
c982879
Allow initializing lines hanging above the seabed
sanguinariojoe Jan 2, 2024
1d57ab6
Local-Euler test on a hanging line split on the middle
sanguinariojoe Jan 2, 2024
cd1f7b5
We do not need to initialize twice
sanguinariojoe Jan 2, 2024
53ed9ce
Upgraded Orcaflex validation to Catch2
sanguinariojoe Jan 3, 2024
a811fd0
Show a renormalized error, which makes more sense
sanguinariojoe Jan 3, 2024
c9e03eb
Complex system local-euler test
sanguinariojoe Jan 3, 2024
bb3b339
Slightly reduce the time step so it is stable when using ctest
sanguinariojoe Jan 13, 2024
1fb9436
Base class for local-timestep integrators
sanguinariojoe Jan 13, 2024
1632699
Non-tested local timestep Adam-Bashforth schemes
sanguinariojoe Jan 13, 2024
cf62831
Adams-Bashforths were not actually working as themselves
sanguinariojoe Jan 13, 2024
a5ec183
Added the new local-timestep schemes to the docs
sanguinariojoe Jan 14, 2024
b3bb9de
Windows...
sanguinariojoe Jan 15, 2024
dc5710c
More Windows...
sanguinariojoe Jan 15, 2024
380192b
Newmark implicit scheme (ACA)
sanguinariojoe Feb 6, 2024
ed9a666
Optimized Midpoint and Backward Euler schemes
sanguinariojoe Feb 19, 2024
cf8b66f
Fixed the wrong number of iterations
sanguinariojoe Feb 21, 2024
ba0883e
Added API entries to modify the time step related variables
sanguinariojoe Feb 22, 2024
681aada
Added a midpoint implicit test to optimize it
sanguinariojoe Feb 22, 2024
7b12887
Some fixes
sanguinariojoe Feb 22, 2024
78a7265
Optimized the time steps at the OrcaFlex validation
sanguinariojoe Feb 23, 2024
7766a5d
New time steps
sanguinariojoe Feb 23, 2024
11081e9
Added the complex example to the midpoint scheme
sanguinariojoe Feb 23, 2024
2aa724d
Wilson-theta scheme
sanguinariojoe Mar 22, 2024
9395781
WIP Anderson's acceleration
sanguinariojoe Mar 27, 2024
86ac45f
WIP Anderson's accelerator
sanguinariojoe Mar 27, 2024
b4a8cae
Simplified some computations
sanguinariojoe Jun 5, 2024
b074a30
Wrong number of nodes on the API provided wave kinematics
sanguinariojoe Jun 10, 2024
1e91467
Tweaked the AB2 scheme, which was failing
sanguinariojoe Jun 11, 2024
696c5b5
Unitialized q0 on zero-length rods
sanguinariojoe Jun 11, 2024
0924f14
Slightly reduce the time step so midpoint is not failing
sanguinariojoe Jun 11, 2024
ed4b4f1
Started the automatic memory checking
sanguinariojoe Jun 11, 2024
8a03a81
Typo checking if valgrind was found
sanguinariojoe Jun 11, 2024
7260f82
Suppress some system mem leaks
sanguinariojoe Jun 11, 2024
91c26e9
Release the logger when the MoorDyn system creation fails
sanguinariojoe Jun 11, 2024
ca1a348
RelWithDebInfo for running mem checks
sanguinariojoe Jun 11, 2024
eaaf847
Run several memchecks simutaneously
sanguinariojoe Jun 11, 2024
b7d3890
Mem leak on test
sanguinariojoe Jun 11, 2024
fc3e656
Release the previous time integrator before setting the new one
sanguinariojoe Jun 11, 2024
263adea
Uninitialized error values when no IC is computed (e.g. TmaxIC=0.0)
sanguinariojoe Jun 11, 2024
e04362f
Unintialized accelerations
sanguinariojoe Jun 11, 2024
fb73f93
Conn -> Point
sanguinariojoe Jun 11, 2024
cc8269c
Exclude very long tests from mem check
sanguinariojoe Jun 11, 2024
44cb75c
Give a shot to the memcheck on github
sanguinariojoe Jun 11, 2024
31498fb
Renamed job
sanguinariojoe Jun 11, 2024
11a7bfb
Disable more long tests
sanguinariojoe Jun 11, 2024
afff266
Mem leak on test
sanguinariojoe Jun 11, 2024
0c4c7f4
Do not mem check VTK (a lot of false positives)
sanguinariojoe Jun 11, 2024
16d7d9e
Restrict the mem checks to the pre-releases again
sanguinariojoe Jun 11, 2024
29395c9
Increase the stationary solution convergence verbosity
sanguinariojoe Jun 12, 2024
deb6e90
Lowe and Langley (OMAE-2006) validation
sanguinariojoe Jun 12, 2024
bf70e25
Dammit Windows!
sanguinariojoe Jun 12, 2024
e9a153b
Move the CFL documentation to the right place
sanguinariojoe Jun 14, 2024
c5c7c22
MoorDyn 2 -> Moordyn-C version 2
sanguinariojoe Jun 14, 2024
a64ce70
Added a note to clarify that time schemes are only available on MDC
sanguinariojoe Jun 14, 2024
63d8ddf
Added the Wilson scheme to the list
sanguinariojoe Jun 14, 2024
9055bb3
Typo that twisted MDF and MDC
sanguinariojoe Jun 14, 2024
44c8497
Typo on the name
sanguinariojoe Jun 14, 2024
37a218a
Documented the new time schemes
sanguinariojoe Jun 14, 2024
b27b57e
Restructuring the documentation
sanguinariojoe Jun 24, 2024
da6a618
Add old dynamic relax, tweak to default cfl, docs fixes
RyanDavies19 Jun 24, 2024
7119620
Small wording change in inputs.rst
RyanDavies19 Jun 24, 2024
9decd13
Set the legacy IC as the default one (just for backward compatibility)
sanguinariojoe Jun 25, 2024
67dddc7
Legacy IC is performing quite bad, I set stationary as the default on…
sanguinariojoe Jun 25, 2024
4463b47
It seems the test might fail on Windows, let's reduce the time step
sanguinariojoe Jun 25, 2024
a8f86a4
Docs update for OpenFAST PR 2280
RyanDavies19 Jun 25, 2024
c0b5b67
Some times there are coupled entities but there are not motions
sanguinariojoe Jun 26, 2024
b9fb4f3
Get the MoorDyn version on the legacy compilation systems
sanguinariojoe Jun 26, 2024
d842555
fix: Read first the writelog option, and then anything else
sanguinariojoe Jun 28, 2024
cc222d4
fix: The quaternions shall be renormalized to get the rotation matrix
sanguinariojoe Jun 28, 2024
2cff8b9
test: Excentrical body test
sanguinariojoe Jul 1, 2024
7fa5aa0
feat(body): Add centripetal forces for rotating bodies
sanguinariojoe Jul 2, 2024
13c55c2
test: Test the centripetal force on a simple case
sanguinariojoe Jul 2, 2024
8c0b8b0
test: Strip the VTK from the test and attach two points to the body t…
sanguinariojoe Jul 2, 2024
c4ffd66
build: MinGW needs the DECLDIR on Body::setState
sanguinariojoe Jul 2, 2024
bcdf7fe
fix: Freeze when writeLog is not the first option
sanguinariojoe Jul 2, 2024
7dd2a4c
fix: Centripetal force for parallel axes shall be null
sanguinariojoe Jul 3, 2024
50a919e
fix: Rebranding to include centripetal forces on getNetForceAndMass
sanguinariojoe Jul 3, 2024
8b68967
fix: Add a centripetal force to bodies with a excentric COG
sanguinariojoe Jul 4, 2024
1c59dca
Bump pypa/cibuildwheel from 2.19.1 to 2.19.2
dependabot[bot] Jul 8, 2024
fa7fdb6
test: Update to point ot OpenFAST/dev
RyanDavies19 Jul 3, 2024
999a5f0
fix: Read first the writelog option, and then anything else
sanguinariojoe Jun 28, 2024
2f1b3c0
fix: The quaternions shall be renormalized to get the rotation matrix
sanguinariojoe Jun 28, 2024
a830d10
test: Excentrical body test
sanguinariojoe Jul 1, 2024
955d48f
feat(body): Add centripetal forces for rotating bodies
sanguinariojoe Jul 2, 2024
9ae5d01
test: Test the centripetal force on a simple case
sanguinariojoe Jul 2, 2024
2200122
test: Strip the VTK from the test and attach two points to the body t…
sanguinariojoe Jul 2, 2024
7d1a980
build: MinGW needs the DECLDIR on Body::setState
sanguinariojoe Jul 2, 2024
b561d65
fix: Freeze when writeLog is not the first option
sanguinariojoe Jul 2, 2024
9f3cc1a
fix: Centripetal force for parallel axes shall be null
sanguinariojoe Jul 3, 2024
ebf743c
fix: Rebranding to include centripetal forces on getNetForceAndMass
sanguinariojoe Jul 3, 2024
c4f5102
fix: Add a centripetal force to bodies with a excentric COG
sanguinariojoe Jul 4, 2024
c4d95a7
Bump pypa/cibuildwheel from 2.19.1 to 2.19.2
dependabot[bot] Jul 8, 2024
eb6e52b
test: Updated plotting and artifact upload
RyanDavies19 Jul 9, 2024
e912215
feat: Add optional console printing of timestep
RyanDavies19 Jul 9, 2024
cd575b3
test: Add failure trigger for artifacts
RyanDavies19 Jul 9, 2024
e91b7bc
test: add matplotlib
RyanDavies19 Jul 9, 2024
3ae1285
test: updated path for GH artifacts
RyanDavies19 Jul 9, 2024
6b73a30
test: update plots to include pass/fail
RyanDavies19 Jul 9, 2024
5b87825
test: adds error plotting and error threshold
RyanDavies19 Jul 9, 2024
4feaeba
fix: EulerZYX -> EulerXYZ on moordyn::Euler2Quat()
sanguinariojoe Jul 3, 2024
5f670e7
fix: accelerations of Coupled/fixed bodies/rods when there are severa…
sanguinariojoe Jul 4, 2024
d0ea9e1
fix: Odd treatment was meant for indexes from 1 to 3, not 0 to 2, and…
sanguinariojoe Jul 4, 2024
fce7756
test: Test the rotations
sanguinariojoe Jul 4, 2024
1634d17
test: Typo on the config file description
sanguinariojoe Jul 4, 2024
a62b60f
fix: EulerXYZ intrinsic angles instead of extrinsic
sanguinariojoe Jul 9, 2024
fc2d9cf
docs: Clarify that intrinsic angles are considered, and link to the e…
sanguinariojoe Jul 9, 2024
9992312
fix: Drop the patch to move from extrinsic to intrinsic Euler angles
sanguinariojoe Jul 10, 2024
9abeeb1
Merge remote-tracking branch 'upstream/dev' into update_rtests
RyanDavies19 Jul 10, 2024
ac0eb48
Merge branch 'dev' into update_rtests
sanguinariojoe Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/mdf_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ jobs:
id: setup-python

- name: Install Python dependencies
run: pip install --upgrade build pytest Bokeh numpy
run:
pip install --upgrade build pytest Bokeh numpy matplotlib

- name: Download OpenFAST
shell: bash
run: |
cd ${{github.workspace}}/
git clone --recursive https://github.com/OpenFAST/openfast.git
git clone --recursive --single-branch -b dev https://github.com/OpenFAST/openfast.git

- name: Compile MoorDynF
shell: bash
Expand Down Expand Up @@ -73,3 +74,11 @@ jobs:

- name: Run the tests
run: python ${{github.workspace}}/tests/.mdf_verification/verify.py ${{github.workspace}}/

- name: Upload the artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: MD-F comparison plots
path: |
${{github.workspace}}/*.png
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ compile/SO/test*

#program output files
*.out
*.png
*.log
*.dat
tests/.mdf_verification/*.out
tests/.mdf_verification/*.log
tests/.mdf_verification/*.png
tests/.mdf_verification/*.dat

# Python packaging #
####################
Expand Down
2 changes: 2 additions & 0 deletions docs/inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ The list of possible options is:
If this is enabled initial conditions are calculated with scaled drag according to CdScaleIC.
The new stationary solver in MoorDyn-C is more stable and more precise than the dynamic solver,
but it can take longer to reach equilibrium.
- print_time (1): MoorDyn-C switch for printing the current timestep to the console.

A note about time steps in MoorDyn-C: The internal time step is first taken from the dtM option. If
no CFL factor is provided, then the user provided time step is used to calculate CFL and MoorDyn-C
Expand Down Expand Up @@ -629,6 +630,7 @@ The following MoorDyn-C options are not supported by MoorDyn-F:
- FricDamp: Same as CV in MoorDyn-F.
- StatDynFricScale: Same as MC in MoorDyn-F.
- ICgenDynamic: MoorDyn-F does not have a stationary solver for initial conditions
- print_time: Console printing in MoorDyn-F is controled by OpenFAST

The following options from MoorDyn-F are not supported by MoorDyn-C:

Expand Down
16 changes: 11 additions & 5 deletions source/MoorDyn2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ moordyn::MoorDyn::MoorDyn(const char* infilename, int log_level)
, dtOut(0.0)
, _t_integrator(NULL)
, ICgenDynamic(false)
, print_time(true)
, env(std::make_shared<EnvCond>())
, GroundBody(NULL)
, waves(nullptr)
Expand Down Expand Up @@ -611,12 +612,15 @@ moordyn::MoorDyn::Step(const double* x,
double& dt)
{
// should check if wave kinematics have been set up if expected!
const auto default_precision{std::cout.precision()};
std::cout << std::fixed << setprecision(1);
LOGDBG << "t = " << t << "s \r";
std::cout << std::defaultfloat << setprecision(default_precision);

if (print_time) {
const auto default_precision{std::cout.precision()};
std::cout << std::fixed << setprecision(1);
LOGDBG << "t = " << t << "s \r";
std::cout << std::defaultfloat << setprecision(default_precision);

cout << "\rt = " << t << " " << flush;
cout << "\rt = " << t << " " << flush;
}

if (dt <= 0) {
// Nothing to do, just recover the forces if there are coupled DOFs
Expand Down Expand Up @@ -2183,6 +2187,8 @@ moordyn::MoorDyn::readOptionsLine(vector<string>& in_txt, int i)
this->seafloor->setup(env, filepath);
} else if (name == "ICgenDynamic")
ICgenDynamic = bool(atof(entries[0].c_str()));
else if (name == "print_time")
print_time = bool(atof(entries[0].c_str()));
else
LOGWRN << "Warning: Unrecognized option '" << name << "'" << endl;
}
Expand Down
2 changes: 2 additions & 0 deletions source/MoorDyn2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ class MoorDyn final : public io::IO
real ICthresh;
// use dynamic (true) or stationary (false) inital condition solver
bool ICgenDynamic;
/// print the timesteps. Disable for MD_F reg tests
bool print_time;
// temporary wave kinematics flag used to store input value while keeping
// env.WaveKin=0 for IC gen
moordyn::waves::waves_settings WaveKinTemp;
Expand Down
101 changes: 77 additions & 24 deletions tests/.mdf_verification/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@ def to_num(s):

if line.startswith('"'):
# The value is a string
end = line[1:].find('"') + 1
value = line[1:end]
end = line[1:].find('"') + 2
value = line[1:end-1]
else:
end = line.find(' ')
indicies = [line.find(' '), line.find(' '), line.find('\t')]
if -1 in indicies:
indicies.remove(-1)
end = min(indicies)
value = to_num(line[:end])

line = line[end:]
line = line[end:].strip()
while line.find(" ") != -1:
line = line.replace(" ", " ")
key = line.split(" ")[1]

key = line.split(" ")[0]
data[key] = value

return data
Expand All @@ -106,8 +108,11 @@ def read_driver(test):
test_root = os.path.join(args.root,
'openfast/reg_tests/r-test/modules/moordyn/',
test)
with open(os.path.join(test_root, "md_driver.inp"), "r") as f:
lines = f.readlines()
try:
with open(os.path.join(test_root, "md_driver.inp"), "r") as f:
lines = f.readlines()
except FileNotFoundError:
return -1,-1

def get_section(lines, name):
start, end = None, None
Expand Down Expand Up @@ -153,7 +158,7 @@ def create_input_file(env, md):
end = i
break
opts = mdopts2dict(opts[:end])
for optin, optout in (('Gravity', 'gravity'),
for optin, optout in (('Gravity', 'gravity'), # todo: make case insensitive
('rhoW', 'rho'),
('WtrDpth', 'WtrDpth')):
if optin not in env.keys():
Expand All @@ -168,6 +173,8 @@ def create_input_file(env, md):
f"{optout}={opts[optout]} in MoorDyn config file")
lines.insert(start + end,
f"{env[optin]} {optout} option set by the driver\n")
lines.insert(start+end, "0 print_time - console printing of timesteps disabled for GH actions" )

for line in lines:
fout.write(line)
return fname
Expand Down Expand Up @@ -254,34 +261,79 @@ def to_num(s):
return float(s)

data = []
heads = []
with open(fpath, "r") as fin:
lines = fin.readlines()[skiplines:]
for line in lines:
lines = fin.readlines()[skiplines-2:]
line = lines[0]
line = line.strip().replace("\t", " ")
while line.find(" ") != -1:
line = line.replace(" ", " ")
heads = [field for field in line.split()]

for line in lines[2:]:
line = line.strip().replace("\t", " ")
while line.find(" ") != -1:
line = line.replace(" ", " ")
data.append([to_num(field) for field in line.split()])
return np.transpose(data)
return np.transpose(data), heads


def plot(ref, data, fpath):
def plot(ref, ref_heads, data, data_heads, passed, rtol_mag, atol_mag, fpath):
if plt is None:
return
colors = list(mcolors.XKCD_COLORS.values())
fig,axes = plt.subplots(ref.shape[0]-1, 2, sharex = True, figsize=(12.8,4*(ref.shape[0]-1)))
if ref.shape[0] <= 2:
ax = [axes]
else:
ax = axes
for i in range(1, ref.shape[0]):
plt.plot(ref[0, :], ref[i, :], linestyle='dashed',
color=colors[i - 1])
plt.plot(data[0, :], data[i, :], linestyle='solid',
color=colors[i - 1], label=f'channel {i}')
plt.legend(loc='best')
plt.savefig(fpath)
# Plot the channels
ax[i-1][0].plot(data[0, :], data[i, :], linestyle='solid',
color='b', label=f"MD-C: {(data_heads[i])}")
ax[i-1][0].plot(ref[0, :], ref[i, :], linestyle='dashed',
color='r', label=f"MD-F: {(ref_heads[i])}")
ax[i-1][0].legend(loc='best')

# Plot the difference. First calculate threshold (from OpenFAST testing erorPlotting.py _plotError)
NUMEPS = 1e-12
ATOL_MIN = 1e-6
baseline_offset = ref[i, :] - np.min(ref[i, :])
b_order_of_magnitude = np.floor( np.log10( baseline_offset + NUMEPS ) )
rtol = 10**(-1 * rtol_mag)
atol = 10**(max(b_order_of_magnitude) - atol_mag)
atol = max(atol, ATOL_MIN)
passfail_line = atol + rtol * abs(ref[i, :])
ax[i-1][1].plot(data[0, :], passfail_line, color='g',
label=f"Threshold {(data_heads[i])}")
ax[i-1][1].plot(data[0, :], abs(ref[i, :] - data[i, :]), color='gray',
label=f"Error {(data_heads[i])}")
ax[i-1][1].legend(loc='best')

# titles
if i == 1:
if passed:
ax[i-1][0].set_title("PASSED")
else:
ax[i-1][0].set_title("FAILED")

ax[i-1][1].set_title(f"abs diff btwn MD-C and MD-F")



fig.tight_layout()
fig.savefig(fpath, dpi=400)
plt.close()


# Run the tests...
summary = {}
for test in tests:
print("\n ------------------")
print(f"Test {test}...")
env, md = read_driver(test)
if env == md == -1:
print(f"WARNING: Error in loading {test}. Does not match md_driver.inp convention")
continue
fname = create_input_file(env, md)
system = moordyn.Create(fname)
# Get the NDoFs and check if the motions are right
Expand All @@ -305,17 +357,18 @@ def plot(ref, data, fpath):
moordyn.Step(system, rorg, u, t, dt)
moordyn.Close(system)
# Read the ouputs and compare
ref = read_outs(md["OutRootName"], skiplines=8)
new = read_outs(os.path.splitext(fname)[0] + ".out", skiplines=2)
# Drop the eventual points at the tail that ight come from precision errors
ref, ref_heads = read_outs(md["OutRootName"], skiplines=8)
new, new_heads = read_outs(os.path.splitext(fname)[0] + ".out", skiplines=2)
# Drop the eventual points at the tail that might come from precision errors
# on the time
n_samples = min(ref.shape[1], new.shape[1])
ref = ref[:, :n_samples]
new = new[:, :n_samples]
plot(ref, new, test + ".png")
passing = np.all(
pass_fail.passing_channels(ref, new, args.rtol, args.atol))

plot(ref, ref_heads, new, new_heads, passing, args.rtol, args.atol, test + ".png")

summary[test] = passing

print("")
Expand Down
Loading