Skip to content

Commit

Permalink
Pull RAFT ctopt
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Dec 1, 2023
2 parents 93df6ba + 2d752fb commit f2f39d0
Show file tree
Hide file tree
Showing 21 changed files with 642 additions and 235 deletions.
30 changes: 30 additions & 0 deletions RAFT/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

## Description
_Describe the bug here_

### Steps to reproduce issue
_Please provide a minimum working example (MWE) if possible_

1.
2.
3.

### Current behavior

### Expected behavior


### Code versions
_List versions only if relevant_
- Python
-
14 changes: 14 additions & 0 deletions RAFT/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

# Description of feature
Describe the feature here and provide some context. Under what scenario would this be useful?

# Potential solution
Can you think of ways to implement this?
28 changes: 28 additions & 0 deletions RAFT/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Delete the text explanations below these headers and replace them with information about your PR.
Please first consult the [developer guide](https://weis.readthedocs.io/en/latest/how_to_contribute_code.html) to make sure your PR follows all code, testing, and documentation conventions.

## Purpose
Explain the goal of this pull request. If it addresses an existing issue be sure to link to it. Describe the big picture of your changes here, perhaps using a bullet list if multiple changes are done to accomplish a single goal. If it accomplishes multiple goals, it may be best to create separate PR's for each.

## Type of change
What types of change is it?
_Select the appropriate type(s) that describe this PR_

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (non-backwards-compatible fix or feature)
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Documentation update
- [ ] Maintenance update
- [ ] Other (please describe)

## Testing
Explain the steps needed to test the new code to verify that it does indeed address the issue and produce the expected behavior.

## Checklist
_Put an `x` in the boxes that apply._

- [ ] I have run existing tests which pass locally with my changes
- [ ] I have added new tests or examples that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation
52 changes: 52 additions & 0 deletions RAFT/.github/workflows/CI_RAFT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI_RAFT

# We run CI on push commits and pull requests on all branches
on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_conda:
name: Conda Build (${{ matrix.os }}) - ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

strategy:
fail-fast: false #true
matrix:
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
python-version: ["3.10", "3.11"]

steps:
- name: checkout repository
uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v2
# https://github.com/marketplace/actions/setup-miniconda
with:
mamba-version: "*"
miniconda-version: "latest"
#auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
channels: conda-forge
channel-priority: true
activate-environment: test
auto-activate-base: false

# Install
- name: Conda Install RAFT
run: |
pip install -e .
- name: Example run
run: |
cd examples
python example_from_yaml.py false
- name: Test run
run: |
cd tests
pytest .
5 changes: 4 additions & 1 deletion RAFT/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ raft/BEM/
raft/HullMesh.pnl
raft/platform.gdf
tests/BEM/
tests/platform.gdf
tests/platform.gdf

# Emacs
*~
18 changes: 18 additions & 0 deletions RAFT/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: test

channels:
- conda-forge
- defaults

dependencies:
- matplotlib
- moorpy
- numpy
- openmdao
- pyhams
- pip
- python
- pyyaml
- scipy
- setuptools
- wisdem
48 changes: 31 additions & 17 deletions RAFT/examples/example_from_yaml.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
# example script for running RAFT from a YAML input file

import numpy as np
import sys
import matplotlib.pyplot as plt
import yaml
import raft

# open the design YAML file and parse it into a dictionary for passing to raft
with open('VolturnUS-S_example.yaml') as file:
design = yaml.load(file, Loader=yaml.FullLoader)
def run_example(plot_flag = False):
# open the design YAML file and parse it into a dictionary for passing to raft
with open('VolturnUS-S_example.yaml') as file:
design = yaml.load(file, Loader=yaml.FullLoader)

# Create the RAFT model (will set up all model objects based on the design dict)
model = raft.Model(design)
# Create the RAFT model (will set up all model objects based on the design dict)
model = raft.Model(design)

# Evaluate the system properties and equilibrium position before loads are applied
model.analyzeUnloaded()
# Evaluate the system properties and equilibrium position before loads are applied
model.analyzeUnloaded()

# Compute natural frequencie
model.solveEigen()
# Compute natural frequencie
model.solveEigen()

# Simule the different load cases
model.analyzeCases(display=1)
# Simule the different load cases
model.analyzeCases(display=1)

# Plot the power spectral densities from the load cases
model.plotResponses()
if plot_flag:
# Plot the power spectral densities from the load cases
model.plotResponses()

# Visualize the system in its most recently evaluated mean offset position
model.plot(hideGrid=True)
# Visualize the system in its most recently evaluated mean offset position
model.plot()

plt.show()
plt.show()

if __name__ == "__main__":
if len(sys.argv) == 2:
plot_flag = sys.argv[1].lower() in ["1", "t", "true", "y", "yes", 1, True]
elif len(sys.argv) == 1:
plot_flag = True
else:
print("Usage: python example_from_yaml.py <True/False>")
print(" The last argument is an optional declaration to show or suppress the plots (default is True)")

run_example(plot_flag = plot_flag)

Loading

0 comments on commit f2f39d0

Please sign in to comment.