I have a simple model called Net. That has a component model Gri instantiated as object gri. This is my Modelica code:
model Net
parameter Modelica.Units.SI.Power P[2]= {1e4,2e4};
parameter Integer n[2]={1,1};
// Outputs
Modelica.Units.SI.Power Psurp;
Components.Gridactual gri;
equation
// Fetch from object
Psurp=gri.gri.y;
end Net;
And I made FMUs with both FMI 2.0 and FMI 3.0 in Dymola. I used FMPy in Python to simulate using the simulate_fmu function:
result = simulate_fmu(
'TestFMU2.fmu',
validate=False,
start_time=0,
stop_time=10,
solver="CVode",
output_interval=5,
record_events=False,
output=['Psurp'],
)
df = pd.DataFrame.from_dict(result)
The FMI 2.0 model is simulating correctly. It gives two output columns 'time' and 'Psurp'. But the FMI 3.0 is returning only the time array. This behaviour is only there when I try to access variables which are inside instantiated components. Tried with different FMU combinations. In each case, the ones made with FMI 2.0 simulates correctly but not FMI 3.0.
Is there a special way to access variables which are inside components in FMPy for fmus made with FMI 3.0 or am I doing something wrong here?
Adding an
outputmodifier to the variable solves the problem:see also https://github.com/CATIA-Systems/FMPy/issues/653.