In Simscape, all equations must maintain consistent variability, and parametric variability is not allowed to change during simulation. This is likely because time is a continuous variable, and t_L is being set as a parameter which cannot change during simulation.
- Initial Event: The initialevent section is executed at the start of the simulation. Any variables defined here are typically considered parameters (constant throughout the simulation).
- Event Trigger: The elsewhen statement with edge(T>49 || T<51) appears to be intended to capture an event when T crosses the thresholds of 49 or 51. However, t_L is being assigned the value of time within this event, which can potentially lead to a change in t_L's variability from parametric to continuous, causing the error.
- Integration: The integ function typically integrates over the entire simulation time from 0 to the current time. It doesn't support changing the lower limit of integration during the simulation.
Considering these points, if you want to perform integration starting from a particular event in the simulation, you would typically need to use an approach that doesn't change the variability of the variables involved. One way to achieve this is to use a continuous state variable that starts accumulating at the event. Here's a conceptual example:
variables(Balancing = true)
In this example, integ_Q is a continuous state variable that represents the integrated quantity. Its derivative is controlled based on the condition of T. When T is between 49 and 51 and the accumulated quantity is less than 1000, integ_Q accumulates Q. Otherwise, its derivative is set to zero to stop accumulation.
Please adjust the units and other specifics according to your actual model. This approach avoids the problem of changing t_L during the simulation, which is not allowed in Simscape.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.