File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1648,10 +1648,14 @@ def linearize(self): # 22
16481648 return
16491649
16501650 # code to get the matrix and linear inputs, outputs and states
1651- getLinFile = '{}_{}.{}' .format ('linear' , self .modelName , 'mo' )
1652- checkLinFile = os .path .exists (getLinFile )
1653- if checkLinFile :
1654- self .requestApi ('loadFile' , getLinFile )
1651+ linearFile = "linearized_model.mo"
1652+
1653+ # support older openmodelica versions before OpenModelica v1.16.2 where linearize() generates "linear_modelname.mo" file
1654+ if not os .path .exists (linearFile ):
1655+ linearFile = '{}_{}.{}' .format ('linear' , self .modelName , 'mo' )
1656+
1657+ if os .path .exists (linearFile ):
1658+ self .requestApi ('loadFile' , linearFile )
16551659 cNames = self .requestApi ('getClassNames' )
16561660 linModelName = cNames [0 ]
16571661 buildModelmsg = self .requestApi ('buildModel' , linModelName )
@@ -1668,6 +1672,9 @@ def linearize(self): # 22
16681672 return matrices
16691673 else :
16701674 return self .requestApi ('getErrorString' )
1675+ else :
1676+ errormsg = self .sendExpression ("getErrorString()" )
1677+ return print ("Linearization failed: " + "\" " + linearFile + "\" " + " not found \n " + errormsg )
16711678 except Exception as e :
16721679 raise e
16731680
You can’t perform that action at this time.
0 commit comments