-
Notifications
You must be signed in to change notification settings - Fork 73
Description
fmu version 3.0 has been uploaded
fmu_vector(2).zip
My python code is as follows:
import fmpy
import numpy as np
from fmpy.simulation import Input
fmu_path = 'fmu_vector(2).fmu'
model_description = fmpy.read_model_description(fmu_path)
u_var = next(var for var in model_description.modelVariables if var.name == 'u' and var.causality == 'input')
print(f"Input variable 'u' type: {u_var.type}, shape: {u_var.shape}")
start_values = {
'm': 3,
'n': 3,
'k': 3,
'u': [1, 2, 3, 4, 5, 6, 7, 8, 9]
}
dtype = [('time', np.float64), ('u', np.float64, 9)]
input_signals = np.array([
(0.0, [1, 2, 3, 4, 5, 6, 7, 8, 9]),
(1.0, [2, 2, 3, 4, 5, 6, 7, 8, 9]),
], dtype=dtype)
result = fmpy.simulate_fmu(
fmu_path,
start_time=0.0,
stop_time=2.0,
start_values=start_values,
output_interval=2,
input=input_signals,
output=['y']
)
print("Simulation results:", result.dtype.names)
print(result)Error reported as follows:
Traceback (most recent call last):
File "F:\python\PythonProject\udf\FMPYceshi\ceshi.py", line 28, in
result = fmpy.simulate_fmu(
File "F:\python\PythonProject\udf.venv\lib\site-packages\fmpy\simulation.py", line 761, in simulate_fmu
result = simulateCS(model_description, fmu, start_time, stop_time, relative_tolerance, start_values, apply_default_start_values, input, output, output_interval, timeout, step_finished, set_input_derivatives, use_event_mode, early_return_allowed, validate, initialize, terminate, set_stop_time)
File "F:\python\PythonProject\udf.venv\lib\site-packages\fmpy\simulation.py", line 1209, in simulateCS
input.apply(time)
File "F:\python\PythonProject\udf.venv\lib\site-packages\fmpy\simulation.py", line 319, in apply
values[:], derivatives[:] = self.interpolate(time=time, t=self.t, table=table, discrete=False, after_event=after_event)
TypeError: only length-1 arrays can be converted to Python scalars
Kneeling and pleading for assistance!!!