-
Notifications
You must be signed in to change notification settings - Fork 107
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 partial derivatives w.r.t. parameters #748
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.
The different sections here could be better reflected as test functions. This would make error reporting through pytest follow your intent of issue separation here. Those test functions are also easy to evolve into accepting parameterized input from data generating fixtures.
Edit: Oops, this should ofc be a comment on the new file under src/pymortests/
Codecov Report
|
Codecov Report
|
I updated the tests following the comment from @renefritze |
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.
Apart from some minor issues, this is looking very nice already! I would say this can be merged after resolving these issues.
I pushed changes proposed by @sdrave . I also added Otherwise, this PR can be merged. Edit: I rebased on master |
e949380
to
ddac947
Compare
I have pushed new changes according to the requests of @sdrave. |
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.
You should also add yourself to AUTHORS.md
.
No objections. |
This function checks whether component is in parameter type and checks whether index has correct shape and items
a6e9916
to
59e24d8
Compare
I think this can be merged in case there are no other objections. |
This pull request adds a basic version of parameters derivatives to pymor.
Parameters package:
ParameterFunctionalInterface
has now apartial_derivative
method that returns a newParameterFunctional
representing the derivative to a specific component and coordinate of the parameterFor this pull request, it is only possible to differentiate
ProjectionParameterFunctional
andExpressionParameterFunctional
. For the latter the user has to provide adict
that contains all partial derivatives of the given Parameter. An assertion on the size of this dict might be useful. All shapes of parameters are possible ( scalar, vector and matrix)Operators package:
I added a
mu_derivative
method to theOperatorInterface
and thus also toOperatorBase
. This method returns a new Operator representing the old Operator differentiated to a certain component and coordinate of the parameter.For this pull request, I only implement the
mu_derivative
toLincombOperator
. This function returns a newLincombOperator
with the differentiatedParameterFunctional
. Note that this only makes sense mathematically if the operators of theLincombOperator
are not parametric. Product rules are not implmented, yet.The names of the methods and members are just in a first-choice fashion. I am very open for other suggestions
I added a small test to the pymortests where I show the usage of the new functions. I did not use pytest or something else yet. Is that required?
There are multiple things to do that I left for future work for now:
a) implement a numeric version of the partial derivative of the parameters
b) Use
sympy
to get automatic expressions for the derivative.c) Add
partial derivative
forProductParameterFunctional
andConjugateParameterFunctional
d) Add
mu_derivative
for moreOperators
Comments and tips are very welcome