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

Code cleanup #39

Merged
merged 48 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f2fb98a
change sim outputs: return g instead of individual constraints
rebeccamccabe Aug 21, 2022
d9c815e
change param sens xlim to show results w/ float constraint on
rebeccamccabe Aug 21, 2022
b62d7dd
create mdocean source folder
rebeccamccabe Sep 25, 2022
c0eb2d1
create class-based unit test with code coverage
rebeccamccabe Sep 25, 2022
a56f04a
move unused files to dev folder
rebeccamccabe Sep 25, 2022
1df910c
make validation run in the class-based test framework
rebeccamccabe Sep 26, 2022
a0f360e
parameterize validation tests, use sim and act rather than pct_error
rebeccamccabe Sep 26, 2022
7b1276d
Create CI workflow
rebeccamccabe Sep 26, 2022
f74eba2
Add ci to list of branches for CI
rebeccamccabe Oct 2, 2022
46f670d
uncomment test for all figures
rebeccamccabe Oct 2, 2022
1bf6449
Merge remote-tracking branch 'origin/ci' into code-cleanup
rebeccamccabe Oct 2, 2022
1efcbd1
use personal test script rather than mathworks default
rebeccamccabe Oct 2, 2022
8ba1854
try going back to server test with source code folder added
rebeccamccabe Oct 3, 2022
40fd7bc
add codecov
rebeccamccabe Oct 3, 2022
009f8a1
make codecov run even if test fails
rebeccamccabe Oct 3, 2022
2c7ab67
add action for viewing junit xml results
rebeccamccabe Oct 3, 2022
6e9303a
add local test outputting results as pdf
rebeccamccabe Oct 3, 2022
7f2b516
include passed tests in report
rebeccamccabe Oct 3, 2022
ea2f93a
add pdf test report to workflow
rebeccamccabe Oct 3, 2022
88e7b48
always run pdf upload
rebeccamccabe Oct 3, 2022
073e422
fix quotation marks on include_passed test annotations
rebeccamccabe Oct 3, 2022
0f56d63
add folders for dynamics and sensitivities
rebeccamccabe Oct 11, 2022
94bbd8c
give up on including passed tests in gui
rebeccamccabe Oct 11, 2022
25069a4
use new coeff function and calculate mean error
rebeccamccabe Oct 11, 2022
ddf84be
add wamit hydro coeff check into testcases
rebeccamccabe Oct 16, 2022
dfa3860
change name and location of hydro coeff checker
rebeccamccabe Oct 16, 2022
3447073
parameterize all figures test to run one at a time
rebeccamccabe Oct 17, 2022
ec1f094
change scripts to functions to avoid variable overlap
rebeccamccabe Oct 17, 2022
de821cc
get rid of results mat file
rebeccamccabe Oct 17, 2022
902cccb
increase tolerance for economic validation so more pass
rebeccamccabe Oct 17, 2022
716be7e
readability updates to dynamics
rebeccamccabe Oct 17, 2022
a504d67
first attempt at hydro limit check, not working yet
rebeccamccabe Oct 18, 2022
6bef274
add unsaturated power as an output
rebeccamccabe Nov 3, 2022
72d9d71
add oswec hydro coeffs from wecsim
rebeccamccabe Jan 7, 2023
9d9d7c3
abs hydro coeffs and modify struct, so test cases all run
rebeccamccabe Jan 8, 2023
1a7bc15
add badges to readme
rebeccamccabe Jan 8, 2023
2f89196
change branch for code coverage badge
rebeccamccabe Jan 8, 2023
8a3179b
remove p from var_bounds, and find nominal inputs each time
rebeccamccabe Jan 8, 2023
0b16812
adjust hyperlinks
rebeccamccabe Jan 8, 2023
72f57d5
add badges for license and doi
rebeccamccabe Jan 9, 2023
3d35acf
modify quadratic to be simpler, shouldnt change results
rebeccamccabe Jan 9, 2023
dc1320b
math for abc in terms of w/wn and zeta, plot for max power case
rebeccamccabe Jan 10, 2023
c89fa49
break function out into new file
rebeccamccabe Jan 12, 2023
e76bd6f
newly generated abc file
rebeccamccabe Jan 12, 2023
a0aa602
plot r_k zeta vs freq for particular geometries
rebeccamccabe Jan 12, 2023
6d30c3e
adjust controller sat energy plot, attempt Fmax/Fd parameterization
rebeccamccabe Jan 12, 2023
0e90f5e
subs pi in quadratic script
rebeccamccabe Feb 2, 2023
01474af
add plot for capture width exceedance
rebeccamccabe May 22, 2023
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
57 changes: 57 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main", "ci"]
pull_request:
branches: [ "main", "ci"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout branch
uses: actions/checkout@v3

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1

- name: Run tests and generate artifacts
uses: matlab-actions/run-tests@v1
with:
source-folder: mdocean
test-results-junit: test-results/results.xml
test-results-pdf: test-results/testreport.pdf
code-coverage-cobertura: code-coverage/coverage.xml

- name: Publish code coverage
if: always()
uses: codecov/codecov-action@v1
with:
file: code-coverage/coverage.xml

- name: Publish test report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: 'test-results/results.xml'

- name: Upload test report PDF
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report
path: test-results/testreport.pdf
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ codegen/
octave-workspace

# auto-generated optimization functions
optimization/generated
mdocean/optimization/generated

# html report files
html/
html/

# unit test output folders
code-coverage/
test-results/

# mat data files
*.mat
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[![Unit Tests](https://github.com/symbiotic-engineering/MDOcean/actions/workflows/tests.yml/badge.svg)](https://github.com/symbiotic-engineering/MDOcean/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/symbiotic-engineering/MDOcean/branch/code-cleanup/graph/badge.svg?token=PQNFQ72IC8)](https://codecov.io/gh/symbiotic-engineering/MDOcean)
![GitHub](https://img.shields.io/github/license/symbiotic-engineering/MDOcean)
[![DOI](https://zenodo.org/badge/410160635.svg)](https://zenodo.org/badge/latestdoi/410160635)

# MDOcean
This is an open source codebase that uses Multidisciplinary Design Optimization (**MDO**) to optimize an **ocean** wave energy converter (WEC).

Expand All @@ -6,13 +11,17 @@ of the Reference Model 3 (RM3) WEC, using a fast simplified frequency domain WEC

**Context**

The project is part of research in the [Symbiotic Engineering Analysis (SEA) Lab](https://sea.mae.cornell.edu/) and has been accepted for publication/presentation
in the [2022 ASME IDETC-CIE](https://event.asme.org/IDETC-CIE).
At this conference, the work was presented at the [DAC-6](https://www.designautomationconference.org/dac-6) session and is publication number 90227.
The project is part of research in the [Symbiotic Engineering Analysis (SEA) Lab](https://sea.mae.cornell.edu/)
and has been accepted for publication/presentation in the 2022 ASME IDETC-CIE.
At this conference, the work was presented at the DAC-6 session and is publication number 90227.
A recording of the conference presentation is available [here](https://www.youtube.com/watch?v=LjpfXvujUGY).
The project began as an effort in Cornell course [MAE 5350](https://classes.cornell.edu/browse/roster/FA21/class/MAE/5350).

Citation: R. McCabe, O. Murphy, and M. N. Haji, “Multidisciplinary Optimization to Reduce Cost and Power Variation of a Wave Energy Converter,” *International Design Engineering Technical Conferences & Computers and Information in Engineering Conference*, St. Louis, MO, August 14-17, 2022.
Citation: R. McCabe, O. Murphy, and M. N. Haji, “Multidisciplinary Optimization
to Reduce Cost and Power Variation of a Wave Energy Converter,”
*International Design Engineering Technical Conferences & Computers and
Information in Engineering Conference*, St. Louis, MO, August 14-17, 2022.
https://doi.org/10.1115/DETC2022-90227.

**Authors**
- Rebecca McCabe, [email protected] (Project lead and point of contact) @rebeccamccabe
Expand All @@ -21,7 +30,8 @@ Citation: R. McCabe, O. Murphy, and M. N. Haji, “Multidisciplinary Optimizatio

**Disclaimer**

The versions of the simulation used in the conference proceedings paper ([v1.2](https://github.com/symbiotic-engineering/MDOcean/releases/tag/v1.2)) and in the conference video ([v1.3](https://github.com/symbiotic-engineering/MDOcean/releases/tag/v1.3)) were later found to have a number of errors.
The versions of the simulation used in the conference proceedings paper ([v1.2](https://github.com/symbiotic-engineering/MDOcean/releases/tag/v1.2))
and in the conference video ([v1.3](https://github.com/symbiotic-engineering/MDOcean/releases/tag/v1.3)) were later found to have a number of errors.
These errors have since been corrected, and the current code ([v1.4](https://github.com/symbiotic-engineering/MDOcean/releases/tag/v1.4)) is correct to the best of the authors' knowledge, within the limitations of the stated assumptions.
Known areas for improvement are listed as GitHub issues. If you find any additional errors, please let us know.

Expand Down
2 changes: 1 addition & 1 deletion simulation/run/experiments.m → dev/experiments.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
clear;clc;close all

p = parameters();
b = var_bounds(p);
b = var_bounds();

% X = [ 20 10 30; % outer diameter of float
% .3 .1 .5; % inner diameter ratio of float
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
clear;clc
p = parameters();
b = var_bounds(p);
b = var_bounds();
num_runs = 1e5;
[LCOE,P_var,feasible] = deal(zeros(1,num_runs));

X = zeros(num_runs,8);
for i=1:num_runs
xx = random_x0(b);
X(i,:) = xx;
[LCOE(i), P_var(i), B, FOS1Y, FOS2Y, FOS3Y, ...
FOS_buckling, GM, P_elec, D_d, P_matrix, g] = simulation(xx, p);
FOS = min([FOS1Y,FOS2Y,FOS3Y,FOS_buckling]);
feasible(i) = is_feasible(B, FOS, GM, P_elec, D_d, g(16), g(17), g(18), p);
[LCOE(i), P_var(i), P_matrix, g] = simulation(xx, p);
feasible(i) = is_feasible(g, b);
end

feasible = logical(feasible);
Expand Down
49 changes: 49 additions & 0 deletions dev/plot_r_k_zeta.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
% plot r_k * zeta as a function of omega for optimal control
% for the nominal design and LCOE-optimal design
clear

p = parameters();
b = var_bounds();

nominalX = [b.X_noms; 1];
optimalX = gradient_optim(b.X_start_struct,p,b,1);
Xs = [nominalX, optimalX];

figure
hold on

linespec = {'','--'};
for i = 1:2
Xi = Xs(:,i);
[D_f, D_s_ratio, h_f_ratio, T_s_ratio] = deal(Xi(1),Xi(2),Xi(3),Xi(4));
h_f = b.h_f_ratio_nom * D_f;
T_f = p.T_f_over_h_f * h_f;
D_s = D_s_ratio * D_f;
T_s = p.T_s_over_D_s * D_s;
h_s = T_s / b.T_s_ratio_nom;
h_d = p.h_d_over_D_s * D_s;
D_d = p.D_d_over_D_s * D_s;

w = linspace(0.1,2);
T = 2*pi./w;
Hs = 1;
[w,A,B_h,K_h] = dynamics_simple(Hs, T, D_f, T_f, p.rho_w, p.g);
[~, ~, m_float] = geometry(D_s, D_f, T_f, h_f, h_s, ...
p.t_ft, p.t_fr, p.t_fc, p.t_fb, p.t_sr, ...
p.t_dt, D_d, p.D_dt, p.theta_dt, T_s, h_d, ...
b.M_nom, p.rho_m, p.rho_w, p.m_scale);
m = m_float + A;

r_k_zeta = w .* B_h ./ (m*w.^2 - K_h);


plot(w,abs(r_k_zeta),linespec{i})
end

xlabel('\omega')
ylabel('|r_k \zeta|')
title('Simulated Hydro Coeffs')
ylim([-.5 3])
grid on
legend('Nominal','Optimal LCOE')
improvePlot
10 changes: 5 additions & 5 deletions dev/power_matrix_compare.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

% inputs
p = parameters();
b = var_bounds(p);
b = var_bounds();
X = [b.X_noms; 1];

% unsaturated power
actual_mech_unsat = readmatrix(filename,'Range','E73:S86','Sheet','Performance & Economics');
actual_elec_unsat = actual_mech_unsat * p.pto_eff;
[~, P_var, ~, ~, ~, ~, ~, ~, P_elec, ~, P_matrix] = simulation(X,p);
actual_elec_unsat = actual_mech_unsat * p.eff_pto;
[~, ~, P_matrix] = simulation(X,p);
sim_elec_unsat = P_matrix/1000;

% saturated power
v = validation_inputs();
p.power_max = v.power_max;
actual_elec_sat = readmatrix(filename,'Range','E97:S110','Sheet','Performance & Economics');
[~, P_var, ~, ~, ~, ~, ~, ~, P_elec, ~, P_matrix] = simulation(X,p);
[~, ~, P_matrix] = simulation(X,p);
sim_elec_sat = P_matrix/1000;

% wave resources
Expand Down Expand Up @@ -87,7 +87,7 @@
title(resource_titles{i})
colorbar
end
sgtitle('Wave Resource')
sgtitle('Wave Resource (kW/m)')

% JPD figure
JPDs = JPD;
Expand Down
Loading
Loading