Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

python 3.x - How to get over a OpenModelica solver failure?

Running the simulation from OMedit works just fine. But, when I export the model as FMU to a python script thru the pyfmi module, I get the following error:

The default linear solver fails, the fallback solver with total pivoting is started at time 0.000000. That might raise performance issues, for more information use -lv LOG_LS

Here is the code:

import numpy as np
from matplotlib import pyplot as plt
import pyfmi

fmodel = pyfmi.load_fmu('/tmp/OpenModelica_alexandre/OMEdit/AIMC_Inverter/AIMC_Inverter.fmu')

#Define input ramp signal:

def freq(time):
    if time <= 60:
        f = time
    else:
        f = 60
    return f

#CS parameters

dt = 0.5 #simulation step
tf = 10.0 # final instant
ts = 0.1 # initial instant
x = []
y = []
t = []

while ts <= tf:

#Calculates an integration step

    try:
        status = fmodel.do_step(ts, dt)
    except Exception as e:
        print('erro: ' + e.args)

#checks integrations step completed

    if status is not pyfmi.fmi.FMI_OK:
        break

#set next step input value:

    fmodel.set( 'f', freq(ts) )

    x.append( fmodel.get( 'currentQuasiRMSSensor.I' ) )
    y.append( fmodel.get( 'aimc.wMechanical' ) )
    t.append( ts )

    ts += dt

plt.grid()
plt.xlabel('time[s]')
plt.ylabel('y')

plt.plot(t,y,'r+')
plt.show()

Note: I have tried exporting the model using different solvers, such as: Dassl, Euler, Ida, CVode. But I keep getting the same error message. The error mentions a "default linear solver" which I imagine it to be the Dassl one, so It seems as though I change the solver in the OMEdit simulation setup, the model is still being exported as FMU using the Dassl solver.

Could anyone help me?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...