-
Notifications
You must be signed in to change notification settings - Fork 902
[WIP] Power Iteration Method for Numerical Stability Analysis of the Non-Linear System #2570
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appart from the nullptr issue with nodes. and missing mpi reduction, this looks correct 👍
SU2_CFD/include/solvers/CSolver.hpp
Outdated
| * \brief Seed derivatives for all solution variables using a flat vector. | ||
| * \param[in] derivatives - Flat vector of derivative values (size nVar * nPoint) | ||
| */ | ||
| void SetSolutionDerivatives(const vector<passivedouble>& derivatives, CVariable* nodes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use su2matrix instead of vector passivedouble so you don't need to deal with the offset variable
| norm += v_estimate[i] * v_estimate[i]; | ||
| } | ||
| norm = sqrt(norm); | ||
| for (unsigned long i = 0; i < nTotal; i++) v_estimate[i] /= norm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For multiple mpi ranks you need to reduce the norm and then take the square root and normalize the vector.
| } | ||
|
|
||
| // Seed derivatives for all solvers | ||
| SeedAllDerivatives(v_estimate, nodes, geometry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodes is nullptr in these calls. You don't need to pass nodes here, the solver owns its nodes.
| unsigned long nPoint = geom_ptr->GetnPointDomain(); | ||
|
|
||
| //requested solver and variable | ||
| unsigned short targetSolver = 2; |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
The best way to fix the problem is to remove the declaration of the unused local variable targetSolver from the CFluidIteration::PreRunSpectralRadius function in SU2_CFD/src/iteration/CFluidIteration.cpp. No changes to functionality or imports are necessary as the variable is completely unused. The code can be safely deleted from line 781 with no other modifications required.
-
Copy modified line R781
| @@ -778,7 +778,7 @@ | ||
| unsigned long nPoint = geom_ptr->GetnPointDomain(); | ||
|
|
||
| //requested solver and variable | ||
| unsigned short targetSolver = 2; | ||
|
|
||
| unsigned short targetVar = 0; | ||
| unsigned long nVarTotal = 1; | ||
|
|
|
|
||
| //requested solver and variable | ||
| unsigned short targetSolver = 2; | ||
| unsigned short targetVar = 0; |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the problem, remove the declaration unsigned short targetVar = 0; on line 782 in SU2_CFD/src/iteration/CFluidIteration.cpp. Since it's completely unused, removal improves readability and prevents any confusion. No other changes to code logic are needed, as no parts of the function refer to this variable.
| @@ -779,7 +779,6 @@ | ||
|
|
||
| //requested solver and variable | ||
| unsigned short targetSolver = 2; | ||
| unsigned short targetVar = 0; | ||
| unsigned long nVarTotal = 1; | ||
|
|
||
| //initialize power iteration matrix |
Proposed Changes
Give a brief overview of your contribution here in a few sentences.
We have a non-linear system described by x_{n+1} = F(x_n), where x_n and x_{n+1} are the solution states at time steps n and n+1, and F represents our nonlinear solver iteration. The spectral radius of the Jacobian matrix J_F = dF/dx determines the stability of our iterative scheme.
The power iteration method allows us to estimate the dominant eigenvalue (spectral radius) without explicitly forming the Jacobian matrix. The basic idea is:
The current version has some bugs leading to seg faults which i'm trying to debug. I would appreciate any comments.
Related Work
Resolve any issues (bug fix or feature request), note any related PRs, or mention interactions with the work of others, if any.
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.