Open YangyangFu opened 1 year ago
Unfortunately there is no component to do this at the moment but there should be. Or at least a tutorial to demonstrate a solution to this not uncommon task.
You have two options:
input=true
. You can use a custom callback function to update this value every sample time instance. Maybe the code snippets in this older issue help a little. MTK changed in the mean time but you can get the idea. https://github.com/SciML/ModelingToolkit.jl/issues/1180DiscreteUpdate
operator and use a registered function that interpolates your data. Similar to this https://mtk.sciml.ai/stable/tutorials/ode_modeling/#Specifying-a-time-variable-forcing-functionThanks a lot for these very helpful suggestions. I will take a look soon.
The easiest way to incorporate data like this is probably to create an interpolation function using any of the interpolators from https://github.com/PumasAI/DataInterpolations.jl
Have a look at how some of the sources in the standard librsry are implemented, like the sine source https://github.com/SciML/ModelingToolkitStandardLibrary.jl/blob/9cfa7875e8eac8a46d8997a165f851aff888c94f/src/Blocks/sources.jl#L94 Then change the equation to use the interpolator $int(t)$ instead of $\sin(t)$
If this is implemented without a discrete update operator or callback, your data has to be somewhat smooth in oder to get correct results. Although, in the library are step sources that seem to work just fine without, so the solvers are already quite good at handling this.
For most systems, there will be exogenous input signals as control inputs/disturbances, such as the outdoor air temperature.
Say I have a zone temperature file saved as a csv, and the temperature is sampled every hour. But I have a system, which runs at a time step of 5 min. How can I connect this exogenous temperature to
Thermal.PrescribedTemperature
, and solve the resulting ODE on a 5-minute basis?In Modelica, there is a block called
TimeTable
, which performs auto interpolation between time indexes. Is there any similar block inModelingToolkitStandardLibrary
for this purpose?