fortran - Difference of finite difference solution between two timesteps -


i have solution discretized differential equation given by

f(i)   

where i spatial index. how can find difference between solution @ each adjacent time step? more clear:

the solution defined array

real,dimension(0:10) :: f 

i discretize differential equation , solve stepping forward in time. if time index k, portion of code

do k=1,25    = 1,10       f(i) = f(i+1)+f(i-1)+f(i)    end end 

i can print solution, f(i) @ each time step k following code

print*, "print f(i) k=, k print "(//(5(5x,e22.14)))", f 

how can find difference between solution @ each adjacent time step? is, time steps k+1,k. store value in new array g, has dimension given by

real,dimension(0:10) :: g   

so trying find

!g(i)=abs(f(i;k+1)-f(i;k))...not correct code. 

how can this? way implement code? not sure how using if /then statements or whatever code need needed this. thanks

typically, in explicit time integration methods or iterative methods, have save last time-step last solution, current time-step solution , possibly more.

so have

  real,dimension(0:10) :: f0, f 

where f0 previous value

you iterate jacobi or gauss-seidel discretization:

f = f0  k=1,25     = 1,9       f(i) = f(i+1)+f(i-1)+f(i)    end     max_diff = maxval(abs(f-f0))     if (diff small enough) exit     f0 = f  end 

if have time-evolving problem heat equation:

f = f0  k=1,25     = 1,9       f(i) = f0(i) + dt * viscosity * (f0(i+1)+f0(i-1)+f0(i))    end     max_diff = maxval(abs(f-f0))     f0 = f  end 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -