Numerical Method for Linear equations
大约 4 分钟
Numerical Method for Linear equations
重要
Consider the time-dependent Cauchy probelm of scalar equation,
Define:
Up-Wind schemes:
subroutine core_algorithmn_upwind
implicit none
integer :: i
t1_vertex(0)%value = t0_vertex(0)%value - lambda * 0.5 * ax(x(0)) * (t0_vertex(1)%value - t0_vertex(nx)%value) + lambda * 0.5 * abs(ax(x(0))) * (t0_vertex(1)%value - 2. * t0_vertex(0)%value + t0_vertex(nx)%value)
t1_vertex(nx)%value = t0_vertex(nx)%value - lambda * 0.5 * ax(x(0)) * (t0_vertex(0)%value - t0_vertex(nx-1)%value) + lambda * 0.5 * abs(ax(x(0))) * (t0_vertex(0)%value - 2. * t0_vertex(nx)%value + t0_vertex(nx-1)%value)
do i = 1,nx
t1_vertex(i)%value = t0_vertex(i)%value - lambda * 0.5 * ax(x(i)) * (t0_vertex(i+1)%value - t0_vertex(i-1)%value) + lambda * 0.5 * abs(ax(x(i))) * (t0_vertex(i+1)%value - 2. * t0_vertex(i)%value + t0_vertex(i-1)%value)
enddo
do i = 1 - nghost, nx + nghost
t0_vertex(i)%value = t1_vertex(i)%value
enddo
end subroutine core_algorithmn_upwind
Lax-Friedrichs
subroutine core_alogrithmn_LaxFriedrichs
implicit none
integer :: i
t1_vertex(0)%value = t0_vertex(0)%value - lambda * 0.5 * ax(x(0)) * (t0_vertex(1)%value - t0_vertex(nx)%value) + 0.5 * (t0_vertex(1)%value - 2. * t0_vertex(0)%value + t0_vertex(nx)%value)
t1_vertex(nx)%value = t0_vertex(nx)%value - lambda * 0.5 * ax(x(nx)) * (t0_vertex(0)%value - t0_vertex(nx-1)%value) + 0.5 * (t0_vertex(0)%value - 2. * t0_vertex(nx)%value + t0_vertex(nx-1)%value)
do i = 1,nx
t1_vertex(i)%value = t0_vertex(i)%value - lambda * 0.5 * ax(x(i)) * (t0_vertex(i+1)%value - t0_vertex(i-1)%value) + 0.5 * (t0_vertex(i+1)%value - 2. * t0_vertex(i)%value + t0_vertex(i-1)%value)
enddo
do i = 1 - nghost, nx + nghost
t0_vertex(i)%value = t1_vertex(i)%value
enddo
end subroutine core_alogrithmn_LaxFriedrichs
Lax-Friedrichs (Local)
In this case, the pde equation that we want to solve the Burgers' equation is
with the initial solution is
The Lax-Friednrichs will be changed into
where
with
with
where
Therefore, the final result is:
Lax-Wendroff
The general form:
After the expansion:
subroutine core_alogrithmn_LaxWendroff
implicit none
integer :: i
t1_vertex(0)%value = t0_vertex(0)%value - lambda * 0.5 * ax(x(0)) * (t0_vertex(1)%value - t0_vertex(nx)%value) + lambda ** 2 * 0.5 * ax(x(0)) ** 2 * (t0_vertex(1)%value - 2 * t0_vertex(0)%value + t0_vertex(nx)%value)
t1_vertex(nx)%value = t0_vertex(nx)%value - lambda * 0.5 * ax(x(nx)) * (t0_vertex(0)%value - t0_vertex(nx-1)%value) + lambda ** 2 * 0.5 * ax(x(nx)) ** 2 * (t0_vertex(0)%value - 2 * t0_vertex(nx)%value + t0_vertex(nx-1)%value)
do i = 1,nx
t1_vertex(i)%value = t0_vertex(i)%value - lambda * 0.5 * ax(x(i)) * (t0_vertex(i+1)%value - t0_vertex(i-1)%value) + lambda ** 2 * 0.5 * ax(x(i)) ** 2 * (t0_vertex(i+1)%value - 2 * t0_vertex(i)%value + t0_vertex(i-1)%value)
enddo
do i = 1 - nghost, nx + nghost
t0_vertex(i)%value = t1_vertex(i)%value
enddo
end subroutine core_alogrithmn_LaxWendroff
Beam-Warming
The general form:
subroutine core_algorithmn_BeamWarming
implicit none
integer :: i
t1_vertex(1 - nghost)%value = (lambda ** 2 - lambda) * 0.5 * t0_vertex(nx-1)%value + lambda * (2 - lambda) * t0_vertex(nx)%value + (1 - lambda) * (2 - lambda) * 0.5 * t0_vertex(1 - nghost)%value
t1_vertex(0)%value = (lambda ** 2 - lambda) * 0.5 * t0_vertex(nx)%value + lambda * (2 - lambda) * t0_vertex(1 - nghost)%value + (1 - lambda) * (2 - lambda) * 0.5 * t0_vertex(0)%value
do i = 1, nx
t1_vertex(i)%value = (lambda ** 2 - lambda) * 0.5 * t0_vertex(i-2)%value + lambda * (2 - lambda) * t0_vertex(i-1)%value + (1 - lambda) * (2 - lambda) * 0.5 * t0_vertex(i)%value
enddo
do i = 1 - nghost, nx + nghost
t0_vertex(i)%value = t1_vertex(i)%value
enddo
end subroutine core_algorithmn_BeamWarming