1

I have a single FMU and with 4 inputs, which I want to feed them with csv files. I did the following:

from pyfmi import load_fmu
import pandas as pd

electricity_network = load_fmu(r"C:\Users\kosmy\Pandapower.fmu")

load_file = r"C:\Users\kosmy\load_prof.csv"
load = pd.read_csv(load_file, index_col = 0)
load = load.to_numpy()

pv_file = r"C:\Users\kosmy\pv_prof.csv"
pv = pd.read_csv(pv_file, index_col = 0)
pv = pv.to_numpy()

input_object = [((electricity_network, 'P_load1'), load), 
                ((electricity_network, 'P_load2'), load),
                ((electricity_network, 'P_pv1'), pv),
                ((electricity_network, 'P_pv2'), pv)]

res = electricity_network.simulate(final_time = 96, input = input_object)

But I got the following error:

Traceback (most recent call last):

  File "C:\Users\kosmy\run_pyfmi_csv.py", line 27, in <module>
    res = electricity_network.simulate(final_time = 96, input = input_object)

  File "src\pyfmi\fmi.pyx", line 7501, in pyfmi.fmi.FMUModelCS2.simulate

  File "src\pyfmi\fmi.pyx", line 365, in pyfmi.fmi.ModelBase._exec_simulate_algorithm

  File "src\pyfmi\fmi.pyx", line 359, in pyfmi.fmi.ModelBase._exec_simulate_algorithm

  File "C:\Users\kosmy\anaconda3\envs\env\lib\site-packages\pyfmi\fmi_algorithm_drivers.py", line 772, in __init__
    TrajectoryLinearInterpolation(self.input[1][:,0],

TypeError: tuple indices must be integers or slices, not tuple

Any idea of what is going wrong?

Kosmylo
  • 436
  • 1
  • 6
  • 20
  • What is the full traceback? Initially it could be the `input_object` which is a list with a tuple inside a tuple. But cannot know for sure until i see the full traceback. – Cow Aug 07 '21 at 11:54
  • @user56700 I uploaded the full traceback – Kosmylo Aug 07 '21 at 12:01
  • 1
    It is most definitely your `input_object` that does not have the correct format. I tried looking shortly for anything that could give some examples, but i could not find any. – Cow Aug 07 '21 at 12:16

0 Answers0