Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/development-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
python-version: 3.12
python: xvfb-run python3
pip_arg: ""
- os: macos-13
- os: macos-15
python-version: 3.12
python: python3
pip_arg: ""
Expand Down
15 changes: 10 additions & 5 deletions openfast_toolbox/case_generation/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def writeBatch(batchfile, fastfiles, fastExe=None, nBatches=1, pause=False, flag
- nBatches: split into nBatches files.
- pause: insert a pause statement at the end so that batch file is not closed after execution
- flags: flags (string) to be placed between the executable and the filename
- flags_after: flags (string) to be placed after the filename
- flags_after: flags to be placed after the filename (single string if the same for every file,
or a list of strings if different for each file)
- run_if_ext_missing: add a line in the batch file so that the command is only run if
the file `f.EXT` is missing, where .EXT is specified in run_if_ext_missing
If None, the command is always run
Expand All @@ -394,8 +395,11 @@ def writeBatch(batchfile, fastfiles, fastExe=None, nBatches=1, pause=False, flag
fastExe_rel = os.path.relpath(fastExe_abs, batchdir)
if len(flags)>0:
flags=' '+flags
if len(flags_after)>0:
flags_after=' '+flags_after
if isinstance(flags_after, str):
if len(flags_after)>0:
flags_after=' '+flags_after
elif isinstance(flags_after, list):
flags_after = [' '+f if len(f)>0 else f for f in flags_after]

# Remove commandlines if outputs are already present
if discard_if_ext_present:
Expand All @@ -414,10 +418,11 @@ def writeb(batchfile, fastfiles):
f.write('@echo off\n')
if preCommands is not None:
f.write(preCommands+'\n')
for ff in fastfiles:
for i, ff in enumerate(fastfiles):
ff_abs = os.path.abspath(ff)
ff_rel = os.path.relpath(ff_abs, batchdir)
cmd = fastExe_rel + flags + ' '+ ff_rel + flags_after
cmd = fastExe_rel + flags + ' '+ ff_rel
cmd += flags_after[i] if isinstance(flags_after, list) else flags_after
if stdOutToFile:
stdout = os.path.splitext(ff_rel)[0]+'.stdout'
cmd += ' > ' +stdout
Expand Down
783 changes: 364 additions & 419 deletions openfast_toolbox/fastfarm/FASTFarmCaseCreation.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def main(test=False):
# --- 1.2 Getting the default resolution and plotting the layout
# --------------------------------------------------------------------------------
# Below we provide the minimal set of arguments needed to compute the resolution automatically.
ffcase = FFCaseCreation(wts=wts, vhub=vhub,
ffcase = FFCaseCreation(path=path, wts=wts, vhub=vhub,
mod_wake=mod_wake,
inflowType=inflowType)

Expand All @@ -151,7 +151,7 @@ def main(test=False):
dt_high = 0.50 # [s]
dt_low = 2.00 # [s]
ds_low = 25 # [m]
ffcase2 = FFCaseCreation(wts=wts, vhub=vhub,
ffcase2 = FFCaseCreation(path=path, wts=wts, vhub=vhub,
dt_high=dt_high,
dt_low=dt_low, ds_low=ds_low,
mod_wake=mod_wake,
Expand Down Expand Up @@ -187,8 +187,6 @@ def main(test=False):

"""



return ffcase, ffcase2


Expand All @@ -200,9 +198,9 @@ def main(test=False):

if __name__=='__test__':
ffcase, ffcase2 = main(test=True)
np.testing.assert_equal(ffcase.ds_low, 0.9)
np.testing.assert_equal(ffcase.ds_low, 20)
np.testing.assert_equal(ffcase.dt_low, 0.9)
np.testing.assert_equal(ffcase.ds_high, 0.3)
np.testing.assert_equal(ffcase.ds_high, 5)
np.testing.assert_equal(ffcase.dt_high, 0.3)
np.testing.assert_array_equal(ffcase.extent_low, [3, 6, 3, 3, 2] )
np.testing.assert_equal(ffcase.vhub , [8])
Expand All @@ -211,9 +209,9 @@ def main(test=False):
np.testing.assert_equal(ffcase.shear , [0])
np.testing.assert_equal(ffcase.TIvalue, [10])

np.testing.assert_equal(ffcase2.ds_low, 2.0)
np.testing.assert_equal(ffcase2.ds_low, 25)
np.testing.assert_equal(ffcase2.dt_low, 2.0)
np.testing.assert_equal(ffcase2.ds_high, 0.5)
np.testing.assert_equal(ffcase2.ds_high, 5)
np.testing.assert_equal(ffcase2.dt_high, 0.5)
np.testing.assert_array_equal(ffcase2.extent_low, [3, 6, 3, 3, 2] )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

from openfast_toolbox.fastfarm.FASTFarmCaseCreation import FFCaseCreation

from openfast_toolbox.fastfarm.FASTFarmCaseCreation import check_files_exist, check_discon_library # Helper functions
from openfast_toolbox.fastfarm.fastfarm import plotFastFarmSetup # Low level FAST.Farm functions
from openfast_toolbox.fastfarm.FASTFarmCaseCreation import check_files_exist, check_discon_library, modifyProperty
from openfast_toolbox.fastfarm.fastfarm import plotFastFarmSetup

scriptDir = os.path.dirname(__file__)

Expand Down Expand Up @@ -177,11 +177,11 @@ def main(test=False):
# END OF USER INPUT
# -----------------------------------------------------------------------------

# Plot turbines locations
# Plot turbines locations
fig = plotFastFarmSetup(wts)
if not test:
check_files_exist(ffbin, tsbin, templateFSTF, templateFiles)
check_discon_library(libdisconfilepath);
check_files_exist(ffbin, tsbin, templateFSTF, templateFiles)
check_discon_library(libdiscon)

# -----------------------------------------------------------------------------
# -------------------- FAST.Farm initial setup --------------------------------
Expand Down
2 changes: 1 addition & 1 deletion openfast_toolbox/fastfarm/fastfarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def writeFastFarm(outputFile, templateFile, xWT, yWT, zWT, FFTS=None, OutListT1=
if isinstance(FFTS[k],int):
fst[k] = FFTS[k]
else:
fst[k] = np.around(FFTS[k],3)
fst[k] = np.around(FFTS[k],5)
fst['WrDisDT'] = FFTS['DT_Low']

# --- Set turbine names, position, and box extent
Expand Down
6 changes: 5 additions & 1 deletion openfast_toolbox/modules/elastodyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@
def RotMat_AxisAngle(u,theta):
""" Returns the rotation matrix for a rotation around an axis u, with an angle theta """
R=np.zeros((3,3))
ux,uy,uz=u
u = np.asarray(u).ravel() # Ensure 1D array
ux,uy,uz = u[0], u[1], u[2]
c,s=np.cos(theta),np.sin(theta)
# Ensure scalar values to avoid numpy deprecation warnings
ux, uy, uz = float(ux), float(uy), float(uz)
c, s = float(c), float(s)
R[0,0]=ux**2*(1-c)+c ; R[0,1]=ux*uy*(1-c)-uz*s; R[0,2]=ux*uz*(1-c)+uy*s;
R[1,0]=uy*ux*(1-c)+uz*s ; R[1,1]=uy**2*(1-c)+c ; R[1,2]=uy*uz*(1-c)-ux*s
R[2,0]=uz*ux*(1-c)-uy*s ; R[2,1]=uz*uy*(1-c)+ux*s; R[2,2]=uz**2*(1-c)+c;
Expand Down
9 changes: 6 additions & 3 deletions openfast_toolbox/postpro/postpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import numpy as np
import re
try:
from scipy.integrate import cumulative_trapezoid
from numpy import trapezoid
except:
from scipy.integrate import cumulative_trapezoid
except ImportError:
from scipy.integrate import cumtrapz as cumulative_trapezoid

try:
from numpy import trapezoid
except ImportError:
from numpy import trapz as trapezoid

import openfast_toolbox.io as weio
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"chardet",
"xarray", # for netcdf files
"pytest",
"dill",
],
test_suite="pytest",
tests_require=["pytest"],
Expand Down