For each ODE we have a desired local error, say at t0 = 0.
Calculate step size h to meet the desired error for each equation.
Choose the smallest of the step sizes calculated.
Example
ODEs:
Let desired local error be 1 kg for both M1 and M2.
Local errors are:
M1:
.
At t = 0 this gives
We require
,
or
.
So h = 10 s.
M2:
.
At t = 0,
.
We require
,
or
.
So
s.
Overall, step is restricted to be less than 7.746 s.
Steady state flow balances, no overall accumulation in tanks:
Component balance on solute, Mi being constant:
do i = 1,M
initialise xi(0) = xi(n).end do
do k = 1,max_iterations
call multi_der_fnend dof,DFDX)
do i = 1,Mcalculate gi = xi(k-1) - xi(n) - h fiend do
do j = 1,Mcalculate DGDXij =end doDFDXij
!if i = j, or 0 otherwise
if |gi| <nlae_tolerance for all i = 1 to M, exit
solve the linear equation system
![]()
! use solve_linear
do i=1,Mcalculateend do
do i = 1,M
set xi(n+1) = xi(k-1)end do
Remark:
You must supply a subroutine
multi_der_fn (x,t,f,DFDX)which when given x and t will calculate and return f and DFDX where DFDXij =
Return to Section 4.4.6 Index
Return to Section 4.4 Index
Course Organiser Last modified: Wed Aug 5 12:28:12 BST