Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend support for partial derivatives of functions (#10649)
- Add frontend support for partial derivatives of functions (`df = der(f, x)`) for use by the new backend. Only enabled when using the `--newBackend` flag since the old backend would handle them incorrectly.
- Loading branch information
Showing
18 changed files
with
290 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
testsuite/flattening/modelica/scodeinst/FunctionPartialDerivative1.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// name: FunctionPartialDerivative1 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst, --newBackend | ||
// | ||
|
||
model FunctionPartialDerivative1 | ||
function f | ||
input Real x; | ||
output Real y = x^2; | ||
end f; | ||
|
||
function df = der(f, x); | ||
|
||
Real y = df(0); | ||
end FunctionPartialDerivative1; | ||
|
||
// Result: | ||
// function FunctionPartialDerivative1.df = der(FunctionPartialDerivative1.f, x); | ||
// | ||
// class FunctionPartialDerivative1 | ||
// Real y = FunctionPartialDerivative1.df(0.0); | ||
// end FunctionPartialDerivative1; | ||
// endResult |
26 changes: 26 additions & 0 deletions
26
testsuite/flattening/modelica/scodeinst/FunctionPartialDerivative2.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// name: FunctionPartialDerivative2 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst, --newBackend | ||
// | ||
|
||
model FunctionPartialDerivative2 | ||
function f | ||
input Real x; | ||
output Real y = x^2; | ||
end f; | ||
|
||
function df = der(f, y); | ||
|
||
Real y = df(0); | ||
end FunctionPartialDerivative2; | ||
|
||
// Result: | ||
// Error processing file: FunctionPartialDerivative2.mo | ||
// [flattening/modelica/scodeinst/FunctionPartialDerivative2.mo:15:3-15:17:writable] Error: ‘y‘ in partial derivative of ‘FunctionPartialDerivative2.f‘ does not name an input parameter of the function. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
Oops, something went wrong.