Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Division by zero error when exporting model example as FMU to python

Division by zero error when exporting model example as FMU to python

Exporting the AIMC_Inverter example model as FMU to python through FMI and trying to simulate throws a division by zero error.  On the other hand, simulating from OMedit GUI works fine!

code:

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

fmodel = pyfmi.load_fmu('.../path/to/Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_Inverter.fmu')


# co-simulation parameters

dt = 50e-6 # simulation step
tf = 10.0 # end time
ts = 0.1 # begin time
x = []
y = []
t = []

while ts <= tf:

# Calculate integration step
    try:
        status = fmodel.do_step(ts, dt)
    except Exception as e:
        print('error: ' + e.args)

# check integration step completed

    if status is not pyfmi.fmi.FMI_OK:
        break

# store target variables values
    x.append( fmodel.get( 'currentQuasiRMSSensor.I' ) )
    y.append( fmodel.get( 'aimc.wMechanical' ) )
    t.append( ts )

# Increments simulation step
    ts += dt

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

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

Error:

assert            | debug   | division by zero at time 0, (a=0) / (b=0), where divisor b expression is: vfController.fNominal
getBestJumpBuffer got mmc_jumper=(nil), globalJumpBuffer=(nil)
Aborted (core dumped)

Re: Division by zero error when exporting model example as FMU to python

Problem solved!

It was a offset condition issue!

There are 0 guests and 0 other users also viewing this topic
You are here: