diff_1D_nm: One-dimensional diffusion, constant boundary conditions,...

Description Usage Arguments Value Examples

View source: R/func_diff_nomessage.R

Description

Function to solve diffusion equation using numerical implicit finite differences method, applied in the condition where: a) the diffusion occurs inside a slab of material unidimensionally, or only along one axis, b) the coefficient of diffusion is constant, and c) the boundary conditions are constant. The only difference between this function and the diff.1D() is that this one does not return any messages with notice about the boundary conditions at the end.

Usage

1
diff_1D_nm(Lx, Tt, nt, nx, D, C_ini, C_lim)

Arguments

Lx

Total length of slab in x direction, usually in mm.

Tt

Total diffusion time, usually in second.

nt

Number of time discretization.

nx

Number of dimension x discretization

D

Coefficient of diffusion. Must be constant value.

C_ini

Initial concentration value inside the slab.

C_lim

Boundary condition, written as a vector with one or two elements. If there is only one element, the other side of the slab will be presented as having Neumann boundary condition with flux = 0. If there are two elements, the first element is the dirichlet concentration on the left side, while the second element is the dirichlet concentration on the right side.

Value

A matrix with nx+1 number of row and nt number of column, profiling the diffusion on slab with Lx length along the time Tt.

Examples

1
2
3
4
5
6
7
8
Lx <- 5 #Length of slab, in mm
Tt <- 20 #Total measured diffusion time, in seconds
nt <- 100 #Number of time discretization, wherein the Tt will be divided into 100 equal parts (0, 0.2, 0.4, ..., 20)
nx <- 50 #Number of dimension discretization
D <- 0.05 #Coefficient of diffusion in mm^2/s.
C_ini <- 0.05 #Initial concentration inside the slab.
C_lim <- c(0.10,0.25) #Dirichlet boundary concentration diffusing into the slab
matC <- diff_1D_nm(Lx, Tt, nt, nx, D, C_ini, C_lim)

ahmad-alkadri/Rdiffsolver documentation built on Feb. 4, 2020, 9:45 p.m.