Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Belonging to [master]: - OpenModelica/OMCompiler#2501 - OpenModelica/OpenModelica-testsuite#973
- Loading branch information
1 parent
82c85da
commit 3cc7e9d
Showing
6 changed files
with
183 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// name: FunctionDerivative1 | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
function f1 | ||
input Real x; | ||
input Real y; | ||
output Real z = x + y; | ||
algorithm | ||
annotation(derivative = f2); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
input Real y; | ||
input Real der_x; | ||
output Real z = 0; | ||
end f2; | ||
|
||
model FunctionDerivative1 | ||
Real x = f1(time, time); | ||
end FunctionDerivative1; | ||
|
||
// Result: | ||
// function f1 | ||
// input Real x; | ||
// input Real y; | ||
// output Real z = x + y; | ||
// algorithm | ||
// end f1; | ||
// | ||
// function f2 | ||
// input Real x; | ||
// input Real y; | ||
// input Real der_x; | ||
// output Real z = 0.0; | ||
// end f2; | ||
// | ||
// class FunctionDerivative1 | ||
// Real x = f1(time, time); | ||
// end FunctionDerivative1; | ||
// endResult |
34 changes: 34 additions & 0 deletions
34
flattening/modelica/scodeinst/FunctionDerivativeInvalidInput1.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,34 @@ | ||
// name: FunctionDerivativeInvalidInput1 | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
function f1 | ||
input Real x; | ||
input Real y; | ||
output Real z = x + y; | ||
algorithm | ||
annotation(derivative(zeroDerivative = z) = f2); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
input Real y; | ||
input Real der_x; | ||
output Real z = 0; | ||
end f2; | ||
|
||
model FunctionDerivativeInvalidInput1 | ||
Real x = f1(time, time); | ||
end FunctionDerivativeInvalidInput1; | ||
|
||
// Result: | ||
// Error processing file: FunctionDerivativeInvalidInput1.mo | ||
// [flattening/modelica/scodeinst/FunctionDerivativeInvalidInput1.mo:12:14-12:49:writable] Error: ‘z‘ is not an input of function ‘f1‘. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
34 changes: 34 additions & 0 deletions
34
flattening/modelica/scodeinst/FunctionDerivativeInvalidOrder1.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,34 @@ | ||
// name: FunctionDerivativeInvalidOrder1 | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
function f1 | ||
input Real x; | ||
input Real y; | ||
output Real z = x + y; | ||
algorithm | ||
annotation(derivative(order = z) = f2); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
input Real y; | ||
input Real der_x; | ||
output Real z = 0; | ||
end f2; | ||
|
||
model FunctionDerivativeInvalidOrder1 | ||
Real x = f1(time, time); | ||
end FunctionDerivativeInvalidOrder1; | ||
|
||
// Result: | ||
// Error processing file: FunctionDerivativeInvalidOrder1.mo | ||
// [flattening/modelica/scodeinst/FunctionDerivativeInvalidOrder1.mo:7:1-13:7:writable] Error: Type mismatch in binding order = z, expected subtype of Integer, got type Real. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
34 changes: 34 additions & 0 deletions
34
flattening/modelica/scodeinst/FunctionDerivativeInvalidOrder2.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,34 @@ | ||
// name: FunctionDerivativeInvalidOrder2 | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
function f1 | ||
input Real x; | ||
input Real y; | ||
output Integer z = integer(x + y); | ||
algorithm | ||
annotation(derivative(order = z) = f2); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
input Real y; | ||
input Real der_x; | ||
output Real z = 0; | ||
end f2; | ||
|
||
model FunctionDerivativeInvalidOrder2 | ||
Real x = f1(time, time); | ||
end FunctionDerivativeInvalidOrder2; | ||
|
||
// Result: | ||
// Error processing file: FunctionDerivativeInvalidOrder2.mo | ||
// [flattening/modelica/scodeinst/FunctionDerivativeInvalidOrder2.mo:7:1-13:7:writable] Error: Component order of variability constant has binding z of higher variability discrete. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
32 changes: 32 additions & 0 deletions
32
flattening/modelica/scodeinst/FunctionDerivativeMissingName1.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,32 @@ | ||
// name: FunctionDerivativeMissingName1 | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
function f1 | ||
input Real x; | ||
input Real y; | ||
output Real z = x + y; | ||
algorithm | ||
annotation(derivative(order = 1)); | ||
end f1; | ||
|
||
model FunctionDerivativeMissingName1 | ||
Real x = f1(time, time); | ||
end FunctionDerivativeMissingName1; | ||
|
||
// Result: | ||
// function f1 | ||
// input Real x; | ||
// input Real y; | ||
// output Real z = x + y; | ||
// algorithm | ||
// end f1; | ||
// | ||
// class FunctionDerivativeMissingName1 | ||
// Real x = f1(time, time); | ||
// end FunctionDerivativeMissingName1; | ||
// [flattening/modelica/scodeinst/FunctionDerivativeMissingName1.mo:12:14-12:35:writable] Warning: Derivative annotation for function ‘f1‘ does not specify a derivative function. | ||
// | ||
// endResult |
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