modelon-community / PyFMI

PyFMI is a package for loading and interacting with Functional Mock-Up Units (FMUs) both for Model Exchange and Co-Simulation, which are compiled dynamic models compliant with the Functional Mock-Up Interface (FMI)
http://jmodelica.org/pyfmi
GNU Lesser General Public License v3.0
160 stars 38 forks source link

delayed #250

Closed YanceyYq closed 2 months ago

YanceyYq commented 2 months ago

environment win11 python=3.11 pyfmi=2.11.0 (latest from conda-forge) CoSimulation model fmiVersion=2 issue

Create FMU model object

model_sub1 = FMUModelCS2("./Sin.fmu") model_sub2 = FMUModelCS2("./Sin2.fmu")

将Put two FMU model objects into the list

models = [model_sub1, model_sub2]

Define the connection relationship between models

connections = [(model_sub1, "o1", model_sub2, "int_in")]

Create a Master object for joint simulation

master = Master(models, connections)

Get default settings for simulation options

opts = master.simulate_options()

Set simulation step size and total duration

opts["step_size"] = 1.0 total_duration = 5.0 # 5秒

Simulate using the set simulation options and total duration

res = master.simulate(options=opts, final_time=total_duration)

Extract results

y1_values = res[0]['o1'] y3_values = res[1]['int_out'] y2_values = res[1]['int_in'] times = res[0]['time']

In the above implementation, the extracted results y1-values are consistent with y2-values, but y3-values will be delayed by 1 second compared to y1-values. Is this the mechanism of pyfmi?

YanceyYq commented 2 months ago

The description is incorrect