-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add consistent scaling for optimization problems #29571
base: next
Are you sure you want to change the base?
Conversation
@lynnmunday |
4d6fc7d
to
75dd85b
Compare
Job Documentation, step Docs: sync website on 904462c wanted to post the following: View the site here This comment will be updated on new commits. |
75dd85b
to
6efdd98
Compare
6efdd98
to
d3c6cd3
Compare
|
||
// This is to prevent automatic scaling of the adjoint system. Scaling is | ||
// taken from the forward system | ||
if (_nl_adjoint.hasVector("scaling_factors")) |
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.
Just to be clear, the above error is checking for manual scaling and this if statement is stripping away adjoint variable scaling when automatic_scaling=true.
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.
Correct
nl_abs_tol = 1e-10 | ||
l_tol = 1e-10 | ||
|
||
automatic_scaling = false |
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.
does automatic_scaling=true override the manual variable scaling?
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.
Does all of this still work when they use residual_vs_jacobian scaling of somethign other than the default, like 1 or 0.5 or 0?
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.
Yes works with all of those
input = main.i | ||
jsondiff = main_out.json | ||
recover = false | ||
cli_args = "MultiApps/forward/cli_args='Executioner/automatic_scaling=true'" |
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.
Same question as above, does this override the manual scaling?
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.
Yes, when setting verbose=true, it outputs the new scalings which are different from the manual.
@@ -52,6 +53,14 @@ AdjointSolve::AdjointSolve(Executioner & ex) | |||
paramError("forward_system", "Forward system does not appear to be a 'NonlinearSystem'."); | |||
if (!dynamic_cast<NonlinearSystem *>(&_nl_adjoint)) | |||
paramError("adjoint_system", "Adjoint system does not appear to be a 'NonlinearSystem'."); | |||
// Adjoint system should never perform it's own automatic scaling. Scaling is | |||
// taken from the forward system | |||
_nl_adjoint.automaticScaling(false); |
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.
do you need this and the below if statement on 197 or do you include both to be extra careful?
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.
I include both to be careful.
@@ -95,6 +104,10 @@ AdjointSolve::solve() | |||
|
|||
// Solve the adjoint system | |||
solver.adjoint_solve(matrix, solution, rhs, tol, maxits); |
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.
Line 109 is a really smart way of doing this. For my clarification, the adjoint solve in line 106 is using the scaled system matrix from the forward system on line 90. Do you think it matters that our solution is from A^T=lambda.
We should try this with a nonsymmetric A. Regular scaling of the system Ax=b would be AD^-1Dx=b. The adjoint system would be A^Tx=b so (AD^-1D)^Tx=b -> (D^TD^-TA^T)x=b.
So I wonder if D needs to be transposed for the adjoint solve. Maybe this doesn't matter because D is for blocks and not columns of matrix.
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.
Do we have an example of a nonsymmetric A in the tests that I could "borrow"
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.
Also a diagonal matrix transposed is just the same diagonal matrix.
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.
I didn't think of that. You're right. I'll try to get a thermal mechanical example we can try.
input = main.i | ||
max_threads = 1 # Optimize executioner does not support multiple threads | ||
cli_args = "MultiApps/forward/cli_args='Variables/T_real_adj/scaling=5'" | ||
expect_err = 'User supplied scaling factors for adjoint variables. Adjoint system is scaled automatically by the forward system.' |
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.
This will fix the failing tests if I copied it in correctly.
expect_err = 'User supplied scaling factors for adjoint variables. Adjoint system is scaled automatically by the forward system.' | |
expect_err = 'User cannot supply scaling factors for adjoint variables. Adjoint system is scaled automatically by the forward system.' |
closes #29570