How do I calculate a derivative of a time-variable parameter in SimBiology ?

In SimBiology project I have a parameter that is time dependent. I need its time derivative to use in a formula. How do I calculate the time derivative in Simbiology ?

3 件のコメント

Ingrid Tigges
Ingrid Tigges 2015 年 9 月 9 日
How does the equation for your parameter look like? Can you post an example? In principle you can calculate it using delta parameter/delta t but I am not sure whether this what you are looking for.
Sergey Ermakov
Sergey Ermakov 2015 年 9 月 9 日
Hi Ingrid, actually I am looking for a general case since I anticipate more than one case where I'll need time derivative dY/dt. I don't mind delta Y/delta t, but this means I need Y value from previous time step as well (how to get that ?). I also need to know time step (is there a function to call or something like that?). And this is for simple 1-st order approximation. If you know how to do this please let me know. Thank you.
Ingrid Tigges
Ingrid Tigges 2015 年 9 月 11 日
Can you post a small example (the .sbproj file) here?

サインインしてコメントする。

 採用された回答

Arthur Goldsipe
Arthur Goldsipe 2015 年 10 月 21 日

0 投票

Hi Sergey,
There is no way to directly access the time derivative or previous value of state in SimBiology. There are different workaround depending on what exactly you need to do. I just mentioned one approach in a comment on the previous "answer". The basic idea there turns the problem around: If you can write an expression for the time derivative of your parameter, you can store the value of the derivative by using that expression in a repeated assignment rule, and then you can use this parameter to define a rate rule.
If you do not have an analytic expression for the time derivative of your parameter, there is no straightforward way to access the derivative during simulations.
-Arthur

1 件のコメント

Sergey Ermakov
Sergey Ermakov 2015 年 10 月 21 日
Hello Arthur,
unfortunately more often you don't have an analytical expression for the derivative. You have a variable that depends on many things in the model and you need to calculate a derivative, that will be used in a number of other expressions. I think the ability to calculate the derivative that would a valuable function to have in SimBiology. Thank you.

サインインしてコメントする。

その他の回答 (1 件)

Chao'en Li
Chao'en Li 2015 年 10 月 20 日

0 投票

I met the same problem.
For a reaction a + b = c, I set unknown Kinetic Law, with Reaction Rate as k*Ca*Cb,(Ca and Cb are concentrations of a and b)and repeated assignments: dc_dt = k*Ca*Cb, and Ca = Ca_0 + time*dc_dt (dc_dt is the derivative dc/dt, Ca_0 is the initial concentration of a).
But I got error message as "Repeated assignment rules cannot create algebraic loops (for example, 'x = y' and 'y = x'). The following rules introduce algebraic loops into the model: Ca = Ca + time*dc_dt'"
How to write the following rules: dc/dt(i)=k*Ca(i)*Cb(i), Ca(i+1)=Ca(i)+dc/dt(i)*dt(i)?

1 件のコメント

Arthur Goldsipe
Arthur Goldsipe 2015 年 10 月 21 日
Repeated assignments are not systems of equations that are solved simultaneously. They are simple assignments that are evaluated sequentially at each time step, so they must have a well-defined order of evaluation. You cannot simultaneously have a repeated assignment rule for dc_dt that depends on Ca and a repeated assignment rule for Ca that depends on dc_dt.
I think the real problem is that the rule for Ca isn't really doing what you want. You want Ca to be defined by integrating dc_dt. In SimBiology, you do that with a rate rule. So what I think you want to do is:
  1. Add a repeated assignment rule, "dc_dt = k*Ca*Cb", and
  2. Add a rate rule, "Ca = dc_dt"
One thing that is potentially confusing here is that the left-hand side of the rate rule really means "the time derivative of Ca". In other words, a more traditional mathematical representation of this rate rule would be "d(Ca)/dt = dc_dt".

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Import Data についてさらに検索

製品

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by