-
Notifications
You must be signed in to change notification settings - Fork 156
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
Refactor the solver module to a more general and class-based system #503
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.py
to have less repeated code blocks by moving from function-based operations to class-based operations with a baseSolver
class 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.py
floris/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.
Solver
full_flow_solve()
method, which is the same for each child class, so that onlysolve
must be defined for any new solversolve()
SequentialSolver
Provides the previous
sequential_solver()
method asSequentialSolver.solve()
.CCSolver
Provides the previous
cc_solver()
method asCCSolver.solve()
.TurbOParkSolver
Provides the previous
turbopark_solver()
method asTurbOParkSolver.solve()
.EmpiricalGaussSolver
coming soon
Remaining Questions
farm
,flow_field
, andgrid
need 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.deepcopy
of thefarm
andflow_field
objects, and do we need to still do that if we move to it being a class attribute?Test results, if applicable