-
Notifications
You must be signed in to change notification settings - Fork 249
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
[OptApp] Small fix for QNBB #12262
[OptApp] Small fix for QNBB #12262
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.
Minor comments only. Nice :) thanks @Igarizza :)
...ationApplication/python_scripts/algorithms/algorithm_momentum_relaxed_gradient_projection.py
Outdated
Show resolved
Hide resolved
def test_L2_max(self): | ||
param = Kratos.Parameters("""{ | ||
"type" : "l2_norm", | ||
"max_iter" : 2, | ||
"tolerance" : 1e-4 | ||
}""") | ||
algorithm_data = ComponentDataView("algorithm", self.optimization_problem) | ||
convergence_criterium = CreateConvergenceCriteria(param, self.optimization_problem) | ||
search_direction = KratosOA.CollectiveExpression([Kratos.Expression.ElementExpression(self.model_part)]) | ||
KratosOA.CollectiveExpressionIO.Read(search_direction, KratosOA.CollectiveExpressionIO.PropertiesVariable(Kratos.DENSITY)) | ||
algorithm_data.GetBufferedData()["search_direction"] = search_direction | ||
self.assertFalse(convergence_criterium.IsConverged()) | ||
self.optimization_problem.AdvanceStep() | ||
algorithm_data.GetBufferedData()["search_direction"] = search_direction | ||
self.assertFalse(convergence_criterium.IsConverged()) | ||
self.optimization_problem.AdvanceStep() | ||
algorithm_data.GetBufferedData()["search_direction"] = search_direction | ||
self.assertTrue(convergence_criterium.IsConverged()) |
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 would add a test for max_iter
as well
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.
It is a test for max iter, other one without max in the test name, it tests the expected behavior of conv. criteria
def test_TargetValue_max(self): | ||
param = Kratos.Parameters("""{ | ||
"type" : "target_value", | ||
"max_iter" : 2, | ||
"target_value" : 0.001 | ||
}""") | ||
algorithm_data = ComponentDataView("algorithm", self.optimization_problem) | ||
convergence_criterium = CreateConvergenceCriteria(param, self.optimization_problem) | ||
algorithm_data.GetBufferedData()["std_obj_value"] = 1 | ||
self.assertFalse(convergence_criterium.IsConverged()) | ||
self.optimization_problem.AdvanceStep() | ||
algorithm_data.GetBufferedData()["std_obj_value"] = 0.1 | ||
self.assertFalse(convergence_criterium.IsConverged()) | ||
self.optimization_problem.AdvanceStep() | ||
algorithm_data.GetBufferedData()["std_obj_value"] = 0.01 | ||
self.assertTrue(convergence_criterium.IsConverged()) |
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 would add a test for max_iter
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.
It is a test for max iter
…/algorithm_momentum_relaxed_gradient_projection.py Co-authored-by: Suneth Warnakulasuriya <[email protected]>
@sunethwarna FSI application fails=( |
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.
Thanks @Igarizza
📝 Description
Changes the QNBB max step comparison logic for QNBB to avoid small step size estimations.