Clear Filters
Clear Filters

Modeling efflux time from a tank. Equation 11 in the attached document

1 view (last 30 days)
The equation is first-order nonlinear ordinary differential equation. Says to combine Newton-Rhapson and Runge-Kutta methods to solve numerically.

Answers (1)

Sergey Kasyanov
Sergey Kasyanov on 27 Jan 2017
I think it can be helpful.
You have this function with A, B, C, D are known:
fun = A * (dHdt)^2 + B * (dHdt)^1.75 + C * (dHdt) + D* H;
A=number;
B=number;
C=number;
D=number;
Then you define initial condition:
dHdt0=dHdt0;
H0=H0;
Then you combine solving of function fun(dHdt) and integrate ODE fun(dHdt,H):
%create new function
fun1 = A * (dHdt)^2 + B * (dHdt)^1.75 + C * (dHdt);
%define interval to integrate
T=number;
%define step
dt = 1e-3;
dH = [dHdt0,zeros(1,T/dt)];
H = [H0,zeros(1,T/dt)];
i=2;
%integrate
while i<T/dt+1
%solving of fun(dHdt)
dH(i)=vpasolve(fun1 + H(i-1) * D,dHdt);
%integrate with euler method
H(i)=H(i-1) + dH(i) * dt;
i=i+1;
end
t=[1:i]*dt;
plot(t,H);

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!