tBuLi / symfit

Symbolic Fitting; fitting as it should be.
http://symfit.readthedocs.org
MIT License
232 stars 17 forks source link

Initial conditions for different values of independent variable #368

Closed dolde closed 1 year ago

dolde commented 1 year ago

Suppose I have a system of ODEs such that I have 4 variables - [A, B, C, t], where [A, B, C] are dependent variables and t is our independent variables (Like the reaction kinetics example in the module documentation). When defining initial conditions, you can simply pass a dictionary of the variables and their values (correspond to some time value t0) to the ODEModel() eg initial_conds = {t: t0, A: A0, B: B0, C:C0} where A0 = A(t0), B0 = B(t0), etc.

Reading through the documentation and code, there currently doesn't seem to be a way where I can pass initial conditions that correspond to different times (values of our independent variable), say t0 and t1, where I know the values of our dependent variables at one time or another A1 = A(t1), B0 = B(t0), and C0 = C(t0), but not the values of all dependent variables at only one time.

Is there some method by which I could do this using the module as it currently exists?

pckroon commented 1 year ago

If you have A1 = A(t1), B0 = B(t0), and C0 = C(t0), and no value for A(t0) you cannot integrate your ODE to determine B(t1) and C(t1) (or even B(t0+dt), C(t0+dt), A(t0), nor A(t0+dt)). So mathematics says "no". You need values for A B and C at t=t to determine values for A B and C at t=t+dt.

Jhsmit commented 1 year ago

If for your system you have a mass balance equation, for example A0 + B0 + C0 = 1, you can use that to find A0.