Support initializing FLORIS with default values #1040
Draft
+237
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an option to initialize FLORIS with default options for use as a library
When used as a library in third-party software, the calling-code typically must carry along a version of the FLORIS input files or require them as user input in order to initialize FLORIS. Often, the inputs are immediately changed by the calling-code such as in an optimization routine. This pattern leads to unnecessary complexity when integrating FLORIS in third-party software, and it could be avoided by providing an option to initialize FLORIS with default data with the understanding that much of it will be overwritten. See #1037.
This pull request modifies the initialization method of
FlorisModel
to load some set of default values whenconfiguration="defaults"
. Additionally, a method to retrieve the default inputs as a Python dictionary is provided so that it can be retrieved and modified prior to initialization from the calling code. This is required, for example, if the calling code will change a value that isn't supported inFlorisModel.set(...)
such as the wake model parameters. I've also added a documentation block in the Advanced Concepts section.Design considerations
Another input file
I considered setting defaults through the
attrs.field
function, but decided against this since it would spread the set of default parameters over many source code files. Instead, they're all contained in one file,floris/default_inputs.py
. It hurts my heart to add yet another input file to the FLORIS repository, and I apologize in advance to any future developer who has to update these 💔.What are good defaults?
I chose the GCH example input file as the defaults. Is that reasonable?
Guessable
Is this confusing to users who use FLORIS directly rather than through another tool? If so, how can it be made more explicit?