我试图通过dymola python接口设置参数和初始值。当我尝试设置一个参数/值时,它可以正常工作,但在尝试设置多个值时,它无法正常工作。
工作:
output = dymola.simulateExtendedModel("Wall_to_Py.Test", 0.0, 60000.0, 3326, 0.0, "Dassl", 0.0001, 0, "TryWall", ["rCWall2.T[mNode]"], TstartWall, ["rCWall2.T[mNode]"], True)
不工作:
output = dymola.simulateExtendedModel("Wall_to_Py.Test", 0.0, 60000.0, 3326, 0.0, "Dassl", 0.0001, 0, "TryWall", ["rCWall2.n", "rCWall2.T[mNode]"], [nWall, TstartWall], ["rCWall2.n", "rCWall2.T[mNode]"], True)
我用这个:
simulateExtendedModel(problem, startTime, stopTime, numberOfIntervals, outputInterval, method, tolerance, fixedstepsize, resultFile, initialNames, initialValues, finalNames, autoLoad)
参数:
problem (str) – Name of model, e.g. Modelica.Mechanics.Rotational.Components.Clutch.
startTime (float) – Start of simulation.
stopTime (float) – End of simulation.
numberOfIntervals (int) – Number of output points.
outputInterval (float) – Distance between output points.
method (str) – Integration method.
tolerance (float) – Tolerance of integration.
fixedstepsize (float) – Fixed step size for Euler.
resultFile (str) – Where to store result.
initialNames (str[]) – Parameters and start-values to set. Dimension [:].
initialValues (float[]) – Parameter values. Dimension [size(initialNames, 1)].
finalNames (str[]) – Variables at end-point. Dimension [:].
autoLoad (bool) – Auto load result.
我不明白语法必须如何:
initialValues (float[]) – Parameter values. Dimension [size(initialNames, 1)].
答案 0 :(得分:2)
因此,据我所知,您目前必须在Python中生成字符串向量和相应的值向量,因此对于n = 3,您必须提供参数["rCWall2.T[1]", "rCWall2.T[2]", "rCWall2.T[3]"]
和[TStartWall[1], TStartWall[2], TStartWall[3]]
,以及在多个参数的情况下连接这样的向量。