-
Notifications
You must be signed in to change notification settings - Fork 181
Refactor the solver module to a more general and class-based system #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
Here's a diagram of the current solver structure to support the various models for turbine-grid calculations. The visualization routines are in a similar structure. @RHammond2 can you describe how this pull request changes this structure? classDiagram
class Farm
class FlowField {
array u
array v
array w
}
class WakeModelManager {
<<interface>>
}
class Solver {
<<interface>>
}
class sequential_solver {
}
class turbopark_solver {
}
class cc_solver {
}
class empirical_gauss_solver {
}
JensenVelocityModel --> sequential_solver
GCHVelocityModel --> sequential_solver
TurbOParkVelocityModel --> turbopark_solver
EmpiricalGaussVelocityModel --> empirical_gauss_solver
CumulativeCurlVelocityModel --> cc_solver
sequential_solver --> Solver
turbopark_solver --> Solver
cc_solver --> Solver
empirical_gauss_solver --> Solver
Solver --> Grid
Solver --> Farm
Solver --> FlowField
Solver --> WakeModelManager
|
|
@rafmudaf the above structure doesn't meaningfully change, it merely modifies the solver internals to reduce redundant code that can be tricky to consistently maintain. |
|
After discussion with @RHammond2 and other FLORIS developers, this PR is on hold but the general concept of refactoring the solver code is still of direct interest and is slated for future work. Ideally, the various solvers would be unified, either using a class-based system so that inheritance may be employed, and/or a single solver function created that works with all wake models, to minimize repeated code. |
Feature or improvement description
This is a refactoring of
floris/simulation/solver.pyto have less repeated code blocks by moving from function-based operations to class-based operations with a baseSolverclass to implement the initialization and expected methods. In particular, the full flow solvers all followed the same routine, so this is implemented once inSolver.Related issue, if one exists
Impacted areas of the software
floris/simulation/solver.pyfloris/floris.py(when new API is settled)Additional supporting information
This relates to a discussion point where the solver needed to be reconsidered because it was growing too much and having too many of the same code patterns being reused, so moving to a different module-level architecture was desired.
Solverfull_flow_solve()method, which is the same for each child class, so that onlysolvemust be defined for any new solversolve()SequentialSolverProvides the previous
sequential_solver()method asSequentialSolver.solve().CCSolverProvides the previous
cc_solver()method asCCSolver.solve().TurbOParkSolverProvides the previous
turbopark_solver()method asTurbOParkSolver.solve().EmpiricalGaussSolvercoming soon
Remaining Questions
farm,flow_field, andgridneed to be redefined inXSolver.solve()? This feels redundant for the most part, and is likely a remnant of directly porting over the current solver API usage.deepcopyof thefarmandflow_fieldobjects, and do we need to still do that if we move to it being a class attribute?Test results, if applicable