Exponential Function Modeling

Hello everyone,

I’m currently working on a project in Xcos where I need to model a system response that involves an exponential function of the simulation time, specifically ( \exp(-t) ). My goal is to use this within a larger system model that calculates temperature response based on several input parameters and the exponential decay of time.

To achieve this, I attempted to use the “CLOCK_c” block to generate a signal representing the current simulation time and then intended to multiply this by -1 using a “GAINBLK_f” block to create a signal for ( -t ), which would then feed into an exponential block (“EXPBLK_m” or a similar function).

Issue Encountered:
When I try to connect the “CLOCK_c” block (which I expected to output the simulation time) to the “GAINBLK_f” block, I receive the following error message:

  • “Explicit data input port must be connected to explicit data output port.”

It appears there’s a compatibility issue between the output of the “CLOCK_c” block and the input of the “GAINBLK_f” block, preventing the direct connection and manipulation of the simulation time as I had planned.

Attempts to Resolve:

  • I considered using a “scifunc_block” to directly implement the exponential function using Scilab expressions but am unsure of the correct approach to dynamically reference the simulation time within this block.
  • I’ve also explored documentation and tutorials but haven’t found a clear example that matches this specific use case, particularly how to handle the simulation time correctly for such operations.

Questions:

  1. Is there a recommended method or a specific block in Xcos that allows for the manipulation of the simulation time signal to generate ( \exp(-t) ) directly?
  2. If using “scifunc_block” is the correct approach, how can I correctly reference the simulation time within this block to apply the ( -t ) operation and subsequently the exponential function?
  3. Are there alternative strategies within Xcos for modeling functions of the simulation time, especially for non-linear equations involving exponential time decay?

Any guidance, examples, or references to documentation would be greatly appreciated as I navigate this challenge.

Thank you in advance for your help!

[y = (1 - \exp(-t))]

My goal is to accurately model this behavior within Xcos, and I’ve considered several approaches but am unsure which is the most effective or correct. Here are the ideas I’ve contemplated:

  1. Using “scifunc_block” Without Explicit Input Ports: Implementing the function directly as y1 = (1 - exp(-t)) with the Input ports sizes set to [ ] (none). I am uncertain how to properly reference the simulation time t in this configuration.

  2. Using “scifunc_block” With Explicit Input for Simulation Time: Another approach is using y1 = (1 - exp(-t)) with Input ports sizes [1,1] and incorporating a “TIME_f” Block to explicitly provide the simulation time as input. I’m seeking clarification on how to set this up correctly.

  3. Modeling with “EXPBLK_m”: I’ve also considered directly modeling the exponential term using “EXPBLK_m”. My question here is how to input the expression exp(u1) into this block to achieve the desired function of time t.

**Questions **:

  • Which of these approaches is recommended for accurately modeling the equation (y = (1 - \exp(-t))) in Xcos?
  • For the “scifunc_block” methods, how can I correctly reference or input the simulation time t?
  • If using “EXPBLK_m” is viable, how exactly should I configure the block to represent the exponential decay based on simulation time?

I appreciate any guidance, examples, or suggestions you can provide to help me navigate this modeling challenge. Your expertise and insights will be incredibly valuable to ensuring the accuracy of my system response function within Xcos.

Thank you in advance for your support!

Hello,

As \exp(-t) is the solution of the ode

y'=-y,

and y(0)=1, would not it be easier to generate it using a simple integrator with feedback like this ?

Screenshot 2024-03-18 at 10.52.54

S.

1 Like

I’m attempting to model a system response function, specifically using the equation:

y(t) = S \cdot \left[ 1 - \exp\left(-\frac{t - T_0}{\tau}\right) \right]^\beta

I’ve attached my initial attempt with this post. The results are promising, but I’ve noticed that the exponent \beta significantly affects the time delay in the system’s response, denoted by y(t).

I’m contemplating incorporating a time delay block to model T_0 more effectively. This approach seems like it might offer a more nuanced control over the delay aspect of the system response.

Does anyone have suggestions or experience with this kind of modeling? How would you approach integrating a time delay block into this equation or any tips on managing the time delay aspect more effectively?

Looking forward to your insights and suggestions.

Thank you!

I’m trying to figure out if it’s possible to set the initial state of an Integral block by using an external Constant block. Essentially, I want to initialize my Integral block with a specific value at the start of the simulation, and I was thinking of using a Constant block to specify this value.

Summary

  1. System Response Modeling: How to model system response with equation y(t) = S \cdot \left[ 1 - \exp\left(-\frac{t - T_0}{\tau}\right) \right]^\beta and integrate a time delay block for better control over T_0.

  2. Initial State of Integral Block: Exploring the possibility of setting the initial state of an Integral block using an external Constant block for simulation initialization.

Hello again,

I’m still working through a few challenges, such as adding an input port to the integral block ((1/s)) to allow the initial value to be variable and externally set, similar to how it’s done in Simulink. Additionally, I’m looking into more advanced manipulation of the scope output, like adding legends.

However, I’m excited to share that I’ve developed three solutions to model the function:

y(t) = e^{\frac{-(t-T_o)}{\tau}} = e^{-t/\tau} \cdot e^{T_o/\tau}

T_o : Delay Time
\tau : variable Input

This might bring a smile to your face, especially considering it’s been 15 years since I last engaged with mathematics or used Simulink for simulation.

@mottelet
Are there any advantages / disadvantages between these 3 solutions to model the function y(t)?

I need the possibility to control the initial value, which is not given by the integrator block \Big [ \frac{1}{s} \Big ]?!

The blocks “y1=exp(-t)” and “%e^u” will be slower as they need to call Scilab interpreter but will give an exact result (up to relative machine precision).

The integrator with negative feedback will be faster (it uses only Xcos internals) but will give an approximate results depending on the ode integration method and the chosen tolerance. You can change its initial value with a double-click on its icon.

S.

Thank you, @mottelet, for your insights. I aim to compare the simulation results directly with my measurement data, hence my preference for precise outcomes. Your input has significantly clarified the details for me.