Jump to content

Recommended Posts

Posted

I'm modelling a heating system with objects (paper sheets actually) moving in and out of the system.

 

While in the system I want the objects' temperature and position to be governed by a (or multiple) state space equation. When the objects leave the system I'd like the equations to be disabled so that they are not taking up computing time. However, the internal state variable seems to be computed at every activation of the module.

 

What I have right now:

 


sca_tdf::sca_ss paper_pos_ss[paper_array_size], paper_temp_ss[paper_array_size]; // state-space equation
sca_util::sca_matrix<double> zero, a_pos, b_pos, c_pos, d_pos, a_temp, b_temp, c_temp, d_temp; // state-space matrices
sca_util::sca_vector<double> pos_int[paper_array_size], temp_int[paper_array_size]; // state vector

for ( int i = 0; i < paper_array_size; i++)
{
// If the paper is not on the path, keep variables constant
if (pos_int[i](0) < 0.0)
{
v(0) = 0.0;
paper_position[i] = paper_pos_ss[i](zero, zero, zero, zero, pos_int[i], v);
x(0) = 0.0;
x(1) = 0.0;
x(2) = 0.0;
paper_temp[i] = paper_temp_ss[i](zero, zero, zero, zero, temp_int[i], x);
}else // If the paper is on the path, calculate position and temperature with the DE's
{// Read speed and calculate position
v(0) = v_in.read();paper_position[i] = paper_pos_ss[i](a_pos, b_pos, c_pos, d_pos, pos_int[i], v);

// Construct input vector
x(0) = T_ttb_in.read();
x(1) = T_ph_in.read();
x(2) = T_hx_in.read();
x(3) = T_amb;
// Calculate temperature
paper_temp[i] = paper_temp_ss[i](a_temp, b_temp, c_temp, d_temp, temp_int[i], x);


// Check if the paper has left the paper path
if (pos_int[i](0) > path_size + paper_width)
{
// Reset position and temperature if paper has left the paper path
pos_int[i](0) = -1.0;
paper_position[i] = paper_pos_ss[i](zero, zero, zero, zero, pos_int[i], v);
paper_out = true;
temp_int[i](0) = 0.0;
paper_temp[i] = paper_temp_ss[i](zero, zero, zero, zero, temp_int[i], x);
}}
I created the part where the temperature and position are governed by the state space equation with 'zero' matrices to prevent the internal state variable from 'drifting away' due to the equation still being active in the background it seems.
 
Is there a way to dynamically create state space equations as objects enter the system or at least a way to halt calculation while I don't need it to update?
 
I hope I've been able to explain myself enough. If not, please ask.
 
Marijn

 

 

Posted

Hello Marijn,

 

it is hard to read your code example as it didn't get correctly indented. However, from what I see, It seems that you call the calculate() member functions of the SS equations via the via the operator() overload of paper_pos_ss and paper_temp_ss at each activation of processing, as the calls are present in the if and else branches of your code -- only the arguments changes. You could try to not make the call to the respective member functions when it is not needed. Still, SystemC-AMS might solve the equation system with a smaller time step when you call again the SS equation solver, as the current time of the TDF module only constitutes the maximum integration time step.

 

As long as you safe the state of a SS equation system, you should be able to resume from there at any time the simulation. You can also reset directly the state vectors to new initial values to proceed with the simulation.

 

That said, SystemC-AMS support for continuous-time differential equation systems wasn't initially developed to support deactivation/activation of themselves. However, SystemC AMS 2.0 added support for Dynamic TDF, which allows for TDF modules to wait for the occurence of some external event using request_next_activation. You could try to represent each sheet as a TDF module, which receives the printers relative position to it (think of the printer "moving around of the paper"). Once the paper leaves the paper paper, it could go to sleep mode waiting on the external event to wake up, potentially reset its state vector and resume the solution of the SS equation system.

 

If that also doesn't support your need, you may consider to encapsulate an external ODE solver into your TDF module (e.g., from Boost.ODEInt or the GNU Scientific Library (GSL)). Then, you will have more direct control on the solver execution.

 

Regards, Torsten 

Posted

I've tried simply assigning values to the variables instead of calling a SS equation, but I got results that made no sense at all. variables kept drifting away or had a completely different value right after 'resetting' the state variable.

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