Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 6c0d7cf

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Set FMI flag providesDirectionalDerivative depending on generated code
Belonging to [master]: - #1954
1 parent 69f2571 commit 6c0d7cf

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Compiler/Template/CodegenFMUCommon.tpl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,29 @@ template ModelExchange(SimCode simCode)
5858
match simCode
5959
case SIMCODE(__) then
6060
let modelIdentifier = modelNamePrefix(simCode)
61+
let pdd = providesDirectionalDerivative(simCode)
6162
<<
6263
<ModelExchange
63-
modelIdentifier="<%modelIdentifier%>"<% if Flags.isSet(FMU_EXPERIMENTAL) then ' providesDirectionalDerivative="true"'%>>
64+
modelIdentifier="<%modelIdentifier%>"<% if not pdd then '>' %>
65+
<% if pdd then 'providesDirectionalDerivative="' + pdd + '">' %>
6466
</ModelExchange>
6567
>>
6668
end ModelExchange;
6769

70+
template providesDirectionalDerivative(SimCode simCode)
71+
"Returns true if Jacobian is present, returns nothing otherwise"
72+
::=
73+
match simCode
74+
case SIMCODE(__) then
75+
let result = if isSome(modelStructure) then
76+
match modelStructure
77+
case SOME(FMIMODELSTRUCTURE(continuousPartialDerivatives=SOME(__)))
78+
then "true"
79+
else ""
80+
else ""
81+
'<%result%>'
82+
end providesDirectionalDerivative;
83+
6884
template fmiModelVariables(SimCode simCode, String FMUVersion)
6985
"Generates code for ModelVariables file for FMU target."
7086
::=

0 commit comments

Comments
 (0)