Jump to content

Initial condition for sca_lsf::sca_integ


Recommended Posts

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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..  

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...