Skip to content
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

Improvements for solver.System #887

Merged
merged 15 commits into from
Oct 23, 2024
Merged

Improvements for solver.System #887

merged 15 commits into from
Oct 23, 2024

Conversation

gertjanvanzwieten
Copy link
Contributor

No description provided.

This patch replaces the --break-system-packages introduced in d4a856d by
locally installed Python interpretors to fix Github actions.
@gertjanvanzwieten gertjanvanzwieten force-pushed the solver branch 2 times, most recently from 47132c9 to f7b34e8 Compare October 21, 2024 13:19
nutils/solver.py Outdated Show resolved Hide resolved
examples/cahnhilliard.py Show resolved Hide resolved
This patch adds the functions evaluable.assert_equal and
evaluable.assert_equal_tuple, which instantiate AssertEqual only if the two
arguments are different. This is important because the shape attribute is not
in simplified form if it is generated by the evaluable, and therefore is prone
to stack up with potentially detrimental effects.
This patch improves AssertEqual._simplified by composing a list of unique items
that are compared in the AssertEqual tree, and composing a new tree (if any)
from the results. This allows `AssertEqual(a, AssertEqual(a, b))` to be
simplified to `AssertEqual(a, b)`, which was not formerly the case.
This patch changes the string representation of solver.Minimize from 'newton'
to 'minimize'.
This patch changes System.assemble method to return None for the value of a non
symmetric system, rather than NaN. The old approach was problematic as it did
not completely rule out that the value would be used, and it ignored the
system's dtype.
This patch replaces the trial arguments in a linear system's residual vector
and function value by zeros for cheaper evaluation. The difference is accounted
for in the assemble method with the use of the jacobian matrix.
This patch avoids a second evaluation of a linear system if the matrix, vector
and value are all constant. Formerly only the matrix was cached, but the
changes of commit b7cdff3 imply that the the entire evaluable may become
constant, in which case the residual vector and function value can be reused as
well. A new flag is introduced to differentiate between the situation that all
items are constant (`is_constant`) or only the matrix (`is_constant_matrix`).
This patch changes the behaviour of System.optimize but having it return, in
addition to the solution arrays for self.trials, the existing values of the
constraints parameter rather than arguments. This is to accommodate the main
application of optimize, which is to form constraints for subsequent
invocations of solve. The new behaviour allows for constraint stacking by
feeding existing constraints as the constraints argument of subsequent
optimizations.
This patch changes some SolverError exceptions to ValueError when the reason of
the error is directly apparent from checking the parameters, leaving the use of
SolverError exclusively for errors that occur _during_ the solution process,
for instance due to convergence issues. This fixes System.step's time halving
logic, which spsecifically catches SolverError and MatrixError, that would
repeat forever if the cause of the issue is independent of the timestep.
This patch restores optimize's log entry that counts the number of degrees of
freedom that were constrained. Different from the old log entry is that this
patch separates the counts by trial argument.
This patch lifts the restriction that System.optimize only applies to symmetric
problems, as none of the internal logic actually requires it.
@gertjanvanzwieten
Copy link
Contributor Author

gertjanvanzwieten commented Oct 22, 2024

New since last push: commits 8bce381, 8d3334f, 7c0913e. Fixed e0cfc4b to account for a constant matrix with non-constant residual. Edit: also added af610aa.

This patch renames System.optimize to solve_constraints to reflect that the
method is not limited to symmetric problems, and that its sole purpose is the
establishment of Dirichlet constraints.
This patch removes the reference to solver.optimize from the docstring of the
cahnhilliard example, which switched to using System.solve instead.
This patch adds unit tests solver.System that inspect the behaviour of the
System object directly for combinations of linear and nonlinear, symmetric and
non-symmetric, constant and matrix-constant inputs.
This patch removes rowsupp in System.solve_constraints and replaces it with a
local implementation for column support. Aside from preparing for the imminent
deprecation of rowsupp, switching to a column-based support test is more
appropriate now that solve_constraints is no longer limited to symmetric
systems, as the columns relate to the trial dofs that are being constrained.
When in future row constraints will be better supported then the local test can
be extended with a row test for non-symmetric systems.
@gertjanvanzwieten gertjanvanzwieten merged commit 69fb326 into master Oct 23, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants