Skip to content

Commit f743a82

Browse files
committed
Reworked folder structure for input files
1 parent 426976f commit f743a82

16 files changed

+107
-117
lines changed
File renamed without changes.
File renamed without changes.

example_data/bin/FASTv8.16_Win32.exe

24.2 MB
Binary file not shown.

example_data/bin/MAP_Win32.dll

336 KB
Binary file not shown.
File renamed without changes.

example_data/dlc_spec.json

-18
This file was deleted.

example_data/fast_input_files/NRELOffshrBsline5MW_ADAMSSpecific.dat

-33
This file was deleted.

example_data/fast_input_files/NRELOffshrBsline5MW_AeroDyn.ipt example_data/fast_input_files/v7/NRELOffshrBsline5MW_AeroDyn.ipt

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ PRANDtl HLModel - Hub-loss model (EQUIL only) [PRANdtl or NONE] (unquote
1616
1.464E-5 KinVisc - Kinematic air viscosity [CURRENTLY IGNORED] (m^2/sec)
1717
0.02479 DTAero - Time interval for aerodynamic calculations (sec)
1818
8 NumFoil - Number of airfoil files (-)
19-
"AeroData\Cylinder1.dat" FoilNm - Names of the airfoil files [NumFoil lines] (quoted strings)
20-
"AeroData\Cylinder2.dat"
21-
"AeroData\DU40_A17.dat"
22-
"AeroData\DU35_A17.dat"
23-
"AeroData\DU30_A17.dat"
24-
"AeroData\DU25_A17.dat"
25-
"AeroData\DU21_A17.dat"
26-
"AeroData\NACA64_A17.dat"
19+
"..\AeroData\Cylinder1.dat" FoilNm - Names of the airfoil files [NumFoil lines] (quoted strings)
20+
"..\AeroData\Cylinder2.dat"
21+
"..\AeroData\DU40_A17.dat"
22+
"..\AeroData\DU35_A17.dat"
23+
"..\AeroData\DU30_A17.dat"
24+
"..\AeroData\DU25_A17.dat"
25+
"..\AeroData\DU21_A17.dat"
26+
"..\AeroData\NACA64_A17.dat"
2727
17 BldNodes - Number of blade nodes used for analysis (-)
2828
RNodes AeroTwst DRNodes Chord NFoil PrnElm
2929
2.8667 13.308 2.7333 3.542 1 NOPRINT

example_data/fast_input_files/v8/NRELOffshrBsline5MW_Onshore_ServoDyn.dat

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ False CompNTMD - Compute nacelle tuned mass damper {true/false} (fla
6363
False CompTTMD - Compute tower tuned mass damper {true/false} (flag)
6464
"NRELOffshrBsline5MW_ServoDyn_TMD.dat" TTMDfile - Name of the file for tower tuned mass damper (quoted string) [unused when CompTTMD is false]
6565
---------------------- BLADED INTERFACE ---------------------------------------- [used only with Bladed Interface]
66-
"../../Discon.dll" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
66+
"../../bin/Discon.dll" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
6767
"DISCON.IN" DLL_InFile - Name of input file sent to the DLL (-) [used only with Bladed Interface]
6868
"DISCON" DLL_ProcName - Name of procedure in DLL to be called (-) [case sensitive; used only with DLL Interface]
6969
"default" DLL_DT - Communication interval for dynamic library (s) (or "default") [used only with Bladed Interface]

spawnwind/nrel/plugin.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
from spawn.util.validation import validate_file, validate_dir
2424

2525
from .simulation_input import TurbsimInput
26-
from .fast_input import Fast7Input
26+
from .fast_input import Fast7Input, Fast8Input
2727
from .turbsim_spawner import TurbsimSpawner
2828
from .fast_spawner import FastSimulationSpawner
2929
from .tasks import WindGenerationTask, FastSimulationTask
3030

3131
def create_spawner(
32-
turbsim_exe, fast_exe, turbsim_base_file, fast_base_file,
32+
turbsim_exe, fast_exe, turbsim_base_file, fast_base_file, fast_version,
3333
runner_type, turbsim_working_dir, fast_working_dir, outdir, prereq_outdir
3434
):
3535
"""
@@ -40,6 +40,7 @@ def create_spawner(
4040
from which wind file generation tasks are spawned
4141
:param fast_base_file: FAST input file (typically `.fst`) to which all parameter
4242
editions are made and from which simulations are spawned
43+
:param fast_version: Major version of FAST {'v7', 'v8'}
4344
:param runner_type: default is `process`
4445
:param turbsim_working_dir: Directory in which TurbSim wind generation tasks are executed
4546
:param fast_working_dir: Directory in which FAST simulations are executed.
@@ -65,7 +66,13 @@ def create_spawner(
6566
luigi_config.set(FastSimulationTask.__name__, '_working_dir', fast_working_dir)
6667

6768
wind_spawner = TurbsimSpawner(TurbsimInput.from_file(turbsim_base_file))
68-
return FastSimulationSpawner(Fast7Input.from_file(fast_base_file), wind_spawner, path.join(outdir, prereq_outdir))
69+
fast_input_cls = {
70+
'v7': Fast7Input,
71+
'v8': Fast8Input
72+
}
73+
return FastSimulationSpawner(fast_input_cls[fast_version].from_file(fast_base_file),
74+
wind_spawner,
75+
path.join(outdir, prereq_outdir))
6976

7077

7178
#pylint: disable=invalid-name

tests/conftest.py

+39-27
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,37 @@
2727

2828
__home_dir = path.dirname(path.realpath(__file__))
2929
_example_data_folder = path.join(__home_dir, pardir, 'example_data')
30+
_fast_exe_paths = {
31+
'v7': path.join(_example_data_folder, 'bin', 'FASTv7.0.2.exe'),
32+
'v8': path.join(_example_data_folder, 'bin', 'FASTv8.16_Win32.exe')
33+
}
3034

3135
@pytest.fixture(scope='session')
32-
def exe_paths():
33-
return {
34-
'turbsim': path.join(_example_data_folder, 'TurbSim.exe'),
35-
'fast_v7': path.join(_example_data_folder, 'FASTv7.0.2.exe'),
36-
'fast_v8': path.join(_example_data_folder, 'FASTv8.16_Win32.exe')
37-
}
36+
def turbsim_exe():
37+
return path.join(_example_data_folder, 'bin', 'TurbSim.exe')
3838

3939
@pytest.fixture(scope='session', autouse=True)
40-
def configure_luigi(exe_paths):
40+
def configure_luigi(turbsim_exe):
4141
luigi.configuration.get_config().set('WindGenerationTask', '_runner_type', 'process')
42-
luigi.configuration.get_config().set('WindGenerationTask', '_exe_path', exe_paths['turbsim'])
42+
luigi.configuration.get_config().set('WindGenerationTask', '_exe_path', turbsim_exe)
4343
luigi.configuration.get_config().set('FastSimulationTask', '_runner_type', 'process')
44-
luigi.configuration.get_config().set('FastSimulationTask', '_exe_path', exe_paths['fast_v8'])
4544

4645
@pytest.fixture(params=['v7', 'v8'], scope='module')
47-
def fast_version(request, exe_paths):
48-
if request.param == 'v8':
49-
luigi.configuration.get_config().set('FastSimulationTask', '_exe_path', exe_paths['fast_v8'])
50-
elif request.param == 'v7':
51-
luigi.configuration.get_config().set('FastSimulationTask', '_exe_path', exe_paths['fast_v7'])
46+
def fast_version(request):
47+
luigi.configuration.get_config().set('FastSimulationTask', '_exe_path', _fast_exe_paths[request.param])
5248
return request.param
5349

50+
@pytest.fixture(scope='module')
51+
def exe_paths(turbsim_exe, fast_version):
52+
return {
53+
'turbsim': turbsim_exe,
54+
'fast': _fast_exe_paths[fast_version]
55+
}
56+
57+
@pytest.fixture()
58+
def fast_exe(exe_paths):
59+
return exe_paths['fast']
60+
5461
@pytest.fixture(scope='module')
5562
def turbsim_input_file():
5663
return path.join(_example_data_folder, 'fast_input_files', 'TurbSim.inp')
@@ -60,11 +67,19 @@ def inflowwind_input_file():
6067
return path.join(_example_data_folder, 'fast_input_files', 'v8', 'InflowWind.inp')
6168

6269
@pytest.fixture(scope='module')
63-
def fast_input_file(fast_version):
70+
def base_fast_input_folder():
71+
return path.join(_example_data_folder, 'fast_input_files')
72+
73+
@pytest.fixture(scope='module')
74+
def fast_input_folder(fast_version):
75+
return path.join(_example_data_folder, 'fast_input_files', fast_version)
76+
77+
@pytest.fixture(scope='module')
78+
def fast_input_file(fast_version, fast_input_folder):
6479
if fast_version == 'v7':
65-
return path.join(_example_data_folder, 'fast_input_files', 'NRELOffshrBsline5MW_Onshore.fst')
80+
return path.join(fast_input_folder, 'NRELOffshrBsline5MW_Onshore.fst')
6681
elif fast_version == 'v8':
67-
return path.join(_example_data_folder, 'fast_input_files', 'v8', 'NREL5MW.fst')
82+
return path.join(fast_input_folder, 'NREL5MW.fst')
6883

6984
@pytest.fixture(scope='function')
7085
def fast_input(fast_version, fast_input_file):
@@ -77,10 +92,6 @@ def fast_input(fast_version, fast_input_file):
7792
def example_data_folder():
7893
return _example_data_folder
7994

80-
@pytest.fixture
81-
def examples_folder(example_data_folder):
82-
return path.join(example_data_folder, 'fast_input_files')
83-
8495
@pytest.fixture
8596
def wind_gen_spawner(turbsim_input_file):
8697
return TurbsimSpawner(TurbsimInput.from_file(turbsim_input_file))
@@ -90,14 +101,15 @@ def spawner(wind_gen_spawner, fast_v7_input_file, tmpdir):
90101
return FastSimulationSpawner(Fast7Input.from_file(fast_v7_input_file), wind_gen_spawner, tmpdir)
91102

92103
@pytest.fixture
93-
def plugin_loader(tmpdir, exe_paths):
104+
def plugin_loader(tmpdir, fast_version, fast_input_file, exe_paths, turbsim_input_file):
94105
default_config = DefaultConfiguration()
95106
command_line_configuration = CommandLineConfiguration(
96-
turbsim_exe=exe_paths['turbsim'], fast_exe=exe_paths['fast_v7'],
97-
turbsim_base_file=path.join(_example_data_folder, 'fast_input_files', 'TurbSim.inp'),
98-
fast_base_file=path.join(_example_data_folder, 'fast_input_files', 'NRELOffshrBsline5MW_Onshore.fst'),
99-
turbsim_working_dir=_example_data_folder,
100-
fast_working_dir=_example_data_folder,
107+
turbsim_exe=exe_paths['turbsim'], fast_exe=exe_paths['fast'],
108+
turbsim_base_file=turbsim_input_file,
109+
fast_base_file=fast_input_file,
110+
fast_version=fast_version,
111+
turbsim_working_dir=path.join(_example_data_folder, 'bin'),
112+
fast_working_dir=path.join(_example_data_folder, 'bin'),
101113
outdir=str(tmpdir)
102114
)
103115
return PluginLoader(CompositeConfiguration(command_line_configuration, default_config))

tests/nrel/fast_spawner_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
from spawnwind.nrel import TurbsimSpawner, FastSimulationSpawner, TurbsimInput, WindGenerationTask
2525

2626
@pytest.fixture(scope='function')
27-
def turbsim_input(examples_folder):
28-
return TurbsimInput.from_file(path.join(examples_folder, 'TurbSim.inp'))
27+
def turbsim_input(turbsim_input_file):
28+
return TurbsimInput.from_file(turbsim_input_file)
2929

3030

3131
@pytest.mark.skipif('sys.platform != "win32"')

tests/nrel/simulation_input_tests.py

+47-25
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,78 @@
1919
import tempfile
2020

2121
from spawnwind.nrel.nrel_input_line import NrelInputLine
22-
from spawnwind.nrel import TurbsimInput, AerodynInput, FastInput, NRELSimulationInput
22+
from spawnwind.nrel import TurbsimInput, AerodynInput, NRELSimulationInput, Fast7Input, Fast8Input, TurbsimSpawner
2323

2424

25-
@pytest.mark.parametrize('cls,file,key', [
26-
(TurbsimInput, 'TurbSim.inp', 'CTStartTime'),
27-
(AerodynInput, 'NRELOffshrBsline5MW_AeroDyn.ipt', 'BldNodes'),
28-
(FastInput, 'NRELOffshrBsline5MW_Onshore.fst', 'NBlGages')
25+
@pytest.fixture(scope='function')
26+
def turbsim_input(turbsim_input_file):
27+
return TurbsimInput.from_file(turbsim_input_file)
28+
29+
@pytest.fixture(scope='function')
30+
def aerodyn_input(turbsim_input_file, base_fast_input_folder):
31+
input_file = path.join(base_fast_input_folder, 'v7', 'NRELOffshrBsline5MW_AeroDyn.ipt')
32+
return AerodynInput.from_file(input_file, TurbsimSpawner(TurbsimInput.from_file(turbsim_input_file)))
33+
34+
@pytest.fixture(scope='function')
35+
def fast7_input(base_fast_input_folder):
36+
input_file = path.join(base_fast_input_folder, 'v7', 'NRELOffshrBsline5MW_Onshore.fst')
37+
return Fast7Input.from_file(input_file)
38+
39+
@pytest.fixture(scope='function')
40+
def fast8_input(base_fast_input_folder):
41+
input_file = path.join(base_fast_input_folder, 'v8', 'NREL5MW.fst')
42+
return Fast8Input.from_file(input_file)
43+
44+
45+
@pytest.mark.parametrize('input_fixture,key', [
46+
('turbsim_input', 'CTStartTime'),
47+
('fast7_input', 'NBlGages'),
48+
('fast8_input', 'TMax')
2949
])
30-
def test_read_write_round_trip(examples_folder, cls, file, key):
31-
_input = cls.from_file(path.join(examples_folder, file))
50+
def test_read_write_round_trip(input_fixture, key, request):
51+
_input = request.getfixturevalue(input_fixture)
3252
with tempfile.TemporaryDirectory() as outfile:
3353
name = path.join(outfile, 'temp.txt')
3454
_input.to_file(name)
35-
_input2 = cls.from_file(name)
55+
_input2 = _input.__class__.from_file(name)
3656
assert _input[key] == _input2[key]
3757

3858

39-
@pytest.mark.parametrize('cls,file,key,value', [
40-
(TurbsimInput, 'TurbSim.inp', 'URef', 11.0),
41-
(AerodynInput, 'NRELOffshrBsline5MW_AeroDyn.ipt', 'WindFile', 'Other.wnd'),
42-
(FastInput, 'NRELOffshrBsline5MW_Onshore.fst', 'TMax', 300.0)
59+
@pytest.mark.parametrize('input_fixture,key,value', [
60+
('turbsim_input', 'URef', 11.0),
61+
('fast7_input', 'TMax', 300.0),
62+
('fast8_input', 'DT', 0.001)
4363
])
44-
def test_writes_edited_Specification(examples_folder, cls, file, key, value):
45-
_input = cls.from_file(path.join(examples_folder, file))
64+
def test_writes_edited_Specification(input_fixture, key, value, request):
65+
_input = request.getfixturevalue(input_fixture)
4666
_input[key] = value
4767
with tempfile.TemporaryDirectory() as outfile:
4868
name = path.join(outfile, 'temp.txt')
4969
_input.to_file(name)
50-
_input2 = cls.from_file(name)
70+
_input2 = _input.__class__.from_file(name)
5171
assert _input2[key] == str(value)
5272

5373

54-
@pytest.mark.parametrize('cls,file,keys', [
55-
(AerodynInput, 'NRELOffshrBsline5MW_AeroDyn.ipt', ['FoilNm']),
56-
(FastInput, 'NRELOffshrBsline5MW_Onshore.fst', ['BldFile(1)', 'BldFile(3)', 'TwrFile'])
74+
@pytest.mark.parametrize('input_fixture,keys', [
75+
('aerodyn_input', ['FoilNm']),
76+
('fast7_input', ['BldFile(1)', 'BldFile(3)', 'TwrFile']),
77+
('fast8_input', ['EDFile', 'InflowFile', 'ServoFile', 'AeroFile'])
5778
])
58-
def test_paths_are_absolute(examples_folder, cls, file, keys):
59-
_input = cls.from_file(path.join(examples_folder, file))
79+
def test_paths_are_absolute(input_fixture, keys, request):
80+
_input = request.getfixturevalue(input_fixture)
6081
for k in keys:
6182
f = _input[k]
6283
#sanitise windows paths
6384
assert path.isfile(path.sep.join(f.split('\\')))
6485

6586

66-
@pytest.mark.parametrize('cls,file,key', [
67-
(AerodynInput, 'NRELOffshrBsline5MW_AeroDyn.ipt', 'WindFile'),
68-
(FastInput, 'NRELOffshrBsline5MW_Onshore.fst', 'TwrFile')
87+
@pytest.mark.parametrize('input_fixture,key', [
88+
('aerodyn_input', 'WindFile'),
89+
('fast7_input', 'TwrFile'),
90+
('fast8_input', 'EDFile')
6991
])
70-
def test_can_handle_spaces_in_paths(examples_folder, cls, file, key):
71-
_input = cls.from_file(path.join(examples_folder, file))
92+
def test_can_handle_spaces_in_paths(input_fixture, key, request):
93+
_input = request.getfixturevalue(input_fixture)
7294
spacey_path = '"C:/this is a spacey/path.ipt"'
7395
_input[key] = spacey_path
7496
assert spacey_path.strip('"') == _input[key].strip('"')

0 commit comments

Comments
 (0)