Co-simulate two co-simulation type of FMUs in PyFMI

428 views Asked by At

How to co-simulate two co-simulation type of FMUs connected in a feedback loop by using PyFMI? How does the co-simulation set-up works in PyFMI? How the connections are defined when

  1. Input is given to "y_ref"
  2. The input that goes to "u" is actually a signal that that comes after the "SUM Block".

I'm getting all the results are coming to zero in the coupled FMU simulation set-up. Here is the piece of scipt i'm using

    import pyfmi
from pyfmi import load_fmu
from pyfmi.master import Master
import pylab as P
import numpy as np

sub_system1 = load_fmu("Simple_System_PI.fmu")

sub_system2 = load_fmu("Simple_System_Plant.fmu")
models = [sub_system1, sub_system2]

connections = [( sub_system1 ,"y",sub_system2 ,"u"),
                ( sub_system2 ,"y",sub_system1 ,"u")]

#Generate input

t = np.linspace (0, 10, 100)
u = np.cos(t)

u_traj = np.transpose(np.vstack((t,u)))

input_object = ((sub_system1, 'u'), u_traj)
#print(input_object)
sub_system1.set('u',u[0])

master_simulator = Master (models, connections)
res = master_simulator.simulate(start_time = 0.0, final_time = 10.0, input = input_object)

Regards, enter image description here

0

There are 0 answers