具体的理论知识可以看这篇文章:有限体积法(9)——高阶差分格式:QUICK格式
有限体积法(10)——格式精度与待定系数法
QUICK差分格式
代码:
#一维稳态对流扩散问题
#无源项,QUICK格式
from numpy import *
from numpy.linalg import *
import matplotlib.pyplot as plt
L = 1 #物体总长度
n = 5 #划分网格数
I = 0.1 #扩散系数
p = 1 #密度
u = 0.2 #速度
#边界条件
tA = 1 #左边界A点,定壁温,为1
tB = 0 #右边界B点,定壁温,为0
dx = L/n #控制体宽度
De, Dw = I/dx, I/dx
DA, DB = 2*I/dx, 2*I/dx
Fe, Fw, FA, FB = p*u, p*u, p*u, p*u
Pe = max(Fe/De,FA/DA)
if Pe > 8/3:
print(f'Pe={Pe}>8/3,解不稳定')
else:
print('解是稳定的')
A = zeros((n,n)) #创建零数组
B = zeros((n,1))
if u>0:
# 节点1
A[0][0] = 7/8*Fe + De +3/2*DA
A[0][1] = 3/8*Fe - De -1/6*DA
B[0][0] = (2/8*Fe +