svinco 1 Report post Posted June 29, 2017 My model contains a number of differential equations, that converge only if I set an appropriate initial condition. The model per se is correct (I double-checked both the model and the initial conditions with Simulink), but the corresponding SystemC-AMS implementation diverges after few samples. I set the initial condition as the third parameter of the constructor, e.g.: sca_lsf::sca_integ * myInteg; ... SC_CTOR(myModule){ myInteg = new sca_lsf::sca_integ("myInteg", 1.0, 5.0); ... }; where the initial condition is 5.0. Is this correct? Best regards, S. Share this post Link to post Share on other sites

maehne 67 Report post Posted June 30, 2017 The syntax for assigning the initial condition is correct. I suspect that the diverging results may be caused by the set time step. SystemC AMS uses by default a constant time step to solve the differential equation system. The solver integrated in the proof-of-concept simulator does not do variable time stepping internally as, e.g., Simulink does, because it is purposely limited/optimized to solve (switched) linear differential equation systems. In consequence, you have to be more careful in selecting an appropriate time step based on the time constants in your system. A good rule of thumb is to select a time_step <= 0.1 * smallest_time_constant as a starting point. Share this post Link to post Share on other sites

svinco 1 Report post Posted June 30, 2017 I actually forced Simulink to work with the same time step (fixed time step of 1ms) and with the Euler solver (ode1), which in my understanding is the underlying solver of SystemC-AMS.. This is confusing me. SystemC-AMS starts diverging after two time steps.. Share this post Link to post Share on other sites

maehne 67 Report post Posted July 2, 2017 Without more details, it is hard to give any more advise. How big is the divergence? What kind of system do you try to simulate? What is the structure of the model? What kind of stimuli do you provide in addition to the initial conditions? A minimum working self-contained example demonstrating the problem would also help. Share this post Link to post Share on other sites