From 2c7d975c1ac0a82c60e4fdda7e1a3c5c781b7363 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 4 Feb 2025 17:00:39 -0600 Subject: [PATCH] Store defaults in a YAML file Allows for using this file in other areas of the software --- floris/default_inputs.py | 127 ------------------------------------- floris/default_inputs.yaml | 106 +++++++++++++++++++++++++++++++ floris/floris_model.py | 4 +- pyproject.toml | 28 ++++---- 4 files changed, 122 insertions(+), 143 deletions(-) delete mode 100644 floris/default_inputs.py create mode 100644 floris/default_inputs.yaml diff --git a/floris/default_inputs.py b/floris/default_inputs.py deleted file mode 100644 index 5b8a4cb16..000000000 --- a/floris/default_inputs.py +++ /dev/null @@ -1,127 +0,0 @@ - -default_inputs = { - "name": "FLORIS defaults", - "description": "Gauss-Curl hybrid model (GCH) default inputs", - "floris_version": "v4", - - "logging": { - "console": { - "enable": True, - "level": "WARNING" - }, - "file": { - "enable": False, - "level": "WARNING" - }, - }, - - "solver": { - "type": "turbine_grid", - "turbine_grid_points": 3 - }, - - "farm": { - "layout_x": [0.0], - "layout_y": [0.0], - "turbine_type": ["nrel_5MW"] - }, - - "flow_field": { - "air_density": 1.225, - "reference_wind_height": -1, - "turbulence_intensities": [], - "wind_directions": [], - "wind_shear": 0.12, - "wind_speeds": [], - "wind_veer": 0.0, - }, - - "wake": { - "model_strings": { - "velocity_model": "gauss", - "deflection_model": "gauss", - "combination_model": "sosfs", - "turbulence_model": "crespo_hernandez", - }, - - "enable_secondary_steering": True, - "enable_yaw_added_recovery": True, - "enable_active_wake_mixing": False, - "enable_transverse_velocities": True, - - "wake_deflection_parameters": { - "gauss": { - "ad": 0.0, - "alpha": 0.58, - "bd": 0.0, - "beta": 0.077, - "dm": 1.0, - "ka": 0.38, - "kb": 0.004 - }, - "jimenez": { - "ad": 0.0, - "bd": 0.0, - "kd": 0.05, - }, - "empirical_gauss": { - "horizontal_deflection_gain_D": 3.0, - "vertical_deflection_gain_D": -1, - "deflection_rate": 22, - "mixing_gain_deflection": 0.0, - "yaw_added_mixing_gain": 0.0 - }, - }, - - "wake_velocity_parameters": { - "gauss": { - "alpha": 0.58, - "beta": 0.077, - "ka": 0.38, - "kb": 0.004 - }, - "jensen": { - "we": 0.05, - }, - "cc": { - "a_s": 0.179367259, - "b_s": 0.0118889215, - "c_s1": 0.0563691592, - "c_s2": 0.13290157, - "a_f": 3.11, - "b_f": -0.68, - "c_f": 2.41, - "alpha_mod": 1.0 - }, - "turbopark": { - "A": 0.04, - "sigma_max_rel": 4.0 - }, - "turboparkgauss": { - "A": 0.04, - "include_mirror_wake": True - }, - "empirical_gauss": { - "wake_expansion_rates": [0.023, 0.008], - "breakpoints_D": [10], - "sigma_0_D": 0.28, - "smoothing_length_D": 2.0, - "mixing_gain_velocity": 2.0, - "awc_wake_exp": 1.2, - "awc_wake_denominator": 400 - }, - }, - - "wake_turbulence_parameters": { - "crespo_hernandez": { - "initial": 0.1, - "constant": 0.5, - "ai": 0.8, - "downstream": -0.32 - }, - "wake_induced_mixing": { - "atmospheric_ti_gain": 0.0 - } - }, - } -} diff --git a/floris/default_inputs.yaml b/floris/default_inputs.yaml new file mode 100644 index 000000000..67e199559 --- /dev/null +++ b/floris/default_inputs.yaml @@ -0,0 +1,106 @@ + +name: GCH +description: "Default initialization: Gauss-Curl hybrid model (GCH)" +floris_version: v4 + +logging: + console: + enable: true + level: WARNING + file: + enable: false + level: WARNING + +solver: + type: turbine_grid + turbine_grid_points: 3 + +farm: + layout_x: + - 0.0 + layout_y: + - 0.0 + turbine_type: + - nrel_5MW + +flow_field: + air_density: 1.225 + reference_wind_height: -1 + turbulence_intensities: [] + wind_directions: [] + wind_shear: 0.12 + wind_speeds: [] + wind_veer: 0.0 + +wake: + model_strings: + combination_model: sosfs + deflection_model: gauss + turbulence_model: crespo_hernandez + velocity_model: gauss + + enable_secondary_steering: true + enable_yaw_added_recovery: true + enable_transverse_velocities: true + enable_active_wake_mixing: false + + wake_deflection_parameters: + gauss: + ad: 0.0 + alpha: 0.58 + bd: 0.0 + beta: 0.077 + dm: 1.0 + ka: 0.38 + kb: 0.004 + jimenez: + ad: 0.0 + bd: 0.0 + kd: 0.05 + empirical_gauss: + horizontal_deflection_gain_D: 3.0 + vertical_deflection_gain_D: -1 + deflection_rate: 22 + mixing_gain_deflection: 0.0 + yaw_added_mixing_gain: 0.0 + + wake_velocity_parameters: + gauss: + alpha: 0.58 + beta: 0.077 + ka: 0.38 + kb: 0.004 + jensen: + we: 0.05 + cc: + a_s: 0.179367259 + b_s: 0.0118889215 + c_s1: 0.0563691592 + c_s2: 0.13290157 + a_f: 3.11 + b_f: -0.68 + c_f: 2.41 + alpha_mod: 1.0 + turbopark: + A: 0.04 + sigma_max_rel: 4.0 + turboparkgauss: + A: 0.04 + include_mirror_wake: True + empirical_gauss: + wake_expansion_rates: [0.023, 0.008] + breakpoints_D: [10] + sigma_0_D: 0.28 + smoothing_length_D: 2.0 + mixing_gain_velocity: 2.0 + awc_wake_exp: 1.2 + awc_wake_denominator: 400 + + wake_turbulence_parameters: + crespo_hernandez: + initial: 0.1 + constant: 0.5 + ai: 0.8 + downstream: -0.32 + wake_induced_mixing: + atmospheric_ti_gain: 0.0 diff --git a/floris/floris_model.py b/floris/floris_model.py index 00c23bc72..23e01c1d6 100644 --- a/floris/floris_model.py +++ b/floris/floris_model.py @@ -25,7 +25,6 @@ thrust_coefficient, ) from floris.cut_plane import CutPlane -from floris.default_inputs import default_inputs from floris.logging_manager import LoggingManager from floris.type_dec import ( floris_array_converter, @@ -34,6 +33,7 @@ NDArrayStr, ) from floris.utilities import ( + load_yaml, nested_get, nested_set, print_nested_dict, @@ -66,7 +66,7 @@ class FlorisModel(LoggingManager): @staticmethod def get_defaults() -> dict: - return copy.deepcopy(default_inputs) + return copy.deepcopy(load_yaml(Path(__file__).parent / "default_inputs.yaml")) def __init__(self, configuration: dict | str | Path): diff --git a/pyproject.toml b/pyproject.toml index 79785ff6d..f924334f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +9,8 @@ description = "A controls-oriented engineering wake model." readme = "README.md" requires-python = ">=3.9" authors = [ - { name = "Rafael Mudafort", email = "rafael.mudafort@nrel.gov" }, - { name = "Paul Fleming", email = "paul.fleming@nrel.gov" }, + { name = "Rafael Mudafort", email = "Rafael.Mudafort@nrel.gov" }, + { name = "Paul Fleming", email = "Paul.Fleming@nrel.gov" }, { name = "Michael (Misha) Sinner", email = "Michael.Sinner@nrel.gov" }, { name = "Eric Simley", email = "Eric.Simley@nrel.gov" }, { name = "Christopher Bay", email = "Christopher.Bay@nrel.gov" }, @@ -18,16 +18,16 @@ authors = [ license = { file = "LICENSE.txt" } keywords = ["floris"] classifiers = [ - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy" + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy" ] dependencies = [ "attrs", @@ -63,7 +63,8 @@ include = ["floris*"] [tool.setuptools.package-data] floris = [ "turbine_library/*.yaml", - "core/wake_velocity/turbopark_lookup_table.mat" + "core/wake_velocity/turbopark_lookup_table.mat", + "default_inputs.yaml" ] [project.urls] @@ -76,7 +77,6 @@ Documentation = "https://nrel.github.io/floris/" branch = true source = "floris/*" omit = [ - "setup.py", "tests/*" ]