Solving a system of ODE with Crank Nicholson

10 ビュー (過去 30 日間)
Arkajyoti Chaterjee
Arkajyoti Chaterjee 2021 年 1 月 8 日
コメント済み: Bjorn Gustavsson 2021 年 1 月 12 日
I have a set of ODEs as follows :-
d(A)/dt = f(A,B,V)
d(B)/dt g(A,B,V)
d(C)/dt = h(A,B,C,V)
d(D)/dt = i(A,B,C,V)
V = j(t)
Initial values are known and I need to solve the system using Crank-Nicholson Method. Pseudocode will be welcome.
  4 件のコメント
Alan Stevens
Alan Stevens 2021 年 1 月 8 日
編集済み: Alan Stevens 2021 年 1 月 8 日
Read the documentation on ode45 to see how to pass more than 2 input arguments.
Arkajyoti Chaterjee
Arkajyoti Chaterjee 2021 年 1 月 8 日
That's resolved, thanks! ODE45 is giving the correct solutions.

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

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 1 月 8 日
Note that you have a set of coupled ODEs not PDEs. The Crank-Nicholson method is developed for solving PDEs where we have both "temporal" and "spatial" derivatives, whereas you only seem to have tetmporal derivatives. This makes C-N a rather unusual choise, but is you see your ODEs as "single-position PDEs" you might simply use the equations in that wikipedia-article and scrap all spatial derivatives and boundary-condition-concerns. It will take a bit of time to write out the derivatives and the system of equations you'll need to solve. But it might be well worth for illustrating the method.
Otherwise just use the standard methods for solving coupled ODEs available in matlab (ode45, etc).
HTH
  4 件のコメント
Arkajyoti Chaterjee
Arkajyoti Chaterjee 2021 年 1 月 9 日
ODE45 is solved; thanks. The issue with CN is that I have been asked to use the particular algorithm.
Bjorn Gustavsson
Bjorn Gustavsson 2021 年 1 月 12 日
Well that will give you a set of four non-linear equations - since you'll have to replace A, B, C and D on the right-hand sides with the average values of the values at the current time-step and the next time-step. That is:
should become something like:
From there you might get away with linearising the RHS or you might have to solve that nonlinear system of equations in A, B, C and D at i+1. Perhaps you might get a good enough understanding if you implement a 1-D problem first - that would give you some hands-on experience of where this goes programming-wise.
HTH

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

カテゴリ

Help Center および File ExchangeBoundary Conditions についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by