diffusion.f90 Source File


This file depends on

sourcefile~~diffusion.f90~~EfferentGraph sourcefile~diffusion.f90 diffusion.f90 sourcefile~matcha_m.f90 matcha_m.f90 sourcefile~diffusion.f90->sourcefile~matcha_m.f90 sourcefile~distribution_m.f90 distribution_m.f90 sourcefile~matcha_m.f90->sourcefile~distribution_m.f90 sourcefile~input_m.f90 input_m.f90 sourcefile~matcha_m.f90->sourcefile~input_m.f90 sourcefile~output_m.f90 output_m.f90 sourcefile~matcha_m.f90->sourcefile~output_m.f90 sourcefile~subdomain_m.f90 subdomain_m.f90 sourcefile~matcha_m.f90->sourcefile~subdomain_m.f90 sourcefile~t_cell_collection_m.f90 t_cell_collection_m.f90 sourcefile~matcha_m.f90->sourcefile~t_cell_collection_m.f90 sourcefile~output_m.f90->sourcefile~input_m.f90 sourcefile~output_m.f90->sourcefile~t_cell_collection_m.f90 sourcefile~t_cell_collection_m.f90->sourcefile~distribution_m.f90

Source Code

! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt

program diffusion
  !! Solve the partial differential equation governing unsteady 3D homogeneous, isotropic molecular diffusion
  !! using 2nd-order-accurate central differences in space and 2nd-order Runge-Kutta time advancement.
  use matcha_m, only : subdomain_t
  implicit none
  type(subdomain_t) phi, phi_half
  integer, parameter :: steps = 1000
  integer step
  real, parameter :: D = 1.
  real dt

  call phi%define(side=1., boundary_val=0., internal_val=1., n=11) ! const. internally with a step down at boundaries

  associate(dt => phi%dt_stable(D))
    do step = 1, steps
      phi_half =  phi + (dt/2.) * D * .laplacian. phi
      phi      =  phi +      dt * D * .laplacian. phi_half
    end do
  end associate

end program