← 返回资讯屏轩教育 · 行业资讯

Computer Simulation: Construction and Analysis of Sewage Dispersion Model | 计算机模拟:污水扩散模型的构建与分析

2026-08-30 22:00 · 本文部分内容由AI辅助创作

📚 Computer Simulation: Construction and Analysis of Sewage Dispersion Model | 计算机模拟:污水扩散模型的构建与分析

Computational simulation offers a powerful and cost-effective way to study how pollutants spread through natural water bodies. By building a mathematical model of sewage dispersion, scientists and engineers can predict contaminant concentrations, assess environmental risks, and design mitigation strategies without resorting to expensive field experiments.

计算模拟为研究污染物在自然水体中的扩散提供了一种强大且经济高效的手段。通过构建污水扩散数学模型,科学家和工程师可以预测污染物浓度、评估环境风险,并制定缓解策略,而无需进行昂贵的现场实验。


1. Introduction | 引言

Water pollution caused by untreated or partially treated sewage is a pressing environmental concern worldwide. When sewage enters a river, lake, or coastal area, it does not remain in one place; instead, it is transported by currents and spreads due to turbulent mixing. Understanding this dispersion process is critical for protecting public health and aquatic ecosystems.

未经处理或部分处理的污水造成的水污染是世界范围内亟待解决的环境问题。当污水进入河流、湖泊或沿海区域时,它并不会停留在原地,而是会被水流输运,并因湍流混合而扩散。理解这一扩散过程对于保护公众健康和水生生态系统至关重要。

Computer simulation enables researchers to replicate the dispersion process in a virtual environment. This article walks through the construction of a two-dimensional sewage dispersion model, covering the governing physical principles, the mathematical equations, numerical discretisation methods, implementation details, and the analysis of simulation outputs. The target audience includes A-level computer science students who wish to see how programming, numerical methods, and environmental science intersect.

计算机模拟使研究人员能够在虚拟环境中重现扩散过程。本文逐步介绍二维污水扩散模型的构建,涵盖基本物理原理、数学方程、数值离散方法、实现细节以及模拟结果的分析。目标读者是希望了解编程、数值方法与环境科学如何交叉的A-level计算机科学学生。


2. Physical Principles of Sewage Dispersion | 污水扩散的物理原理

The movement of a pollutant in water is governed by two primary physical processes: advection and diffusion. Advection refers to the transport of the pollutant by the bulk movement of water, such as a river current. Diffusion, on the other hand, is the spreading of the pollutant from regions of high concentration to regions of low concentration, driven by random molecular motion and turbulent eddies.

污染物在水体中的运动由两个主要物理过程控制:平流(advection)和扩散(diffusion)。平流是指污染物随水体的整体运动而迁移,例如河流中的水流。扩散则是污染物从高浓度区域向低浓度区域扩散的过程,由随机分子运动和湍流涡旋驱动。

The table below summarises the key symbols used in the dispersion model.

下表总结了扩散模型中使用的关键符号。

SymbolMeaning含义
CPollutant concentration污染物浓度
u, vVelocity components in x and yx和y方向的流速分量
DDiffusion coefficient扩散系数
SSource or sink term源项或汇项
tTime时间
x, ySpatial coordinates空间坐标

3. Mathematical Model Construction | 数学模型构建

The dispersion of a conservative pollutant (one that does not decay or react) in a two-dimensional water body is described by the advection-diffusion equation. This partial differential equation forms the core of the simulation model.

二维水体中保守污染物(即不衰减、不发生反应的污染物)的扩散由平流-扩散方程描述。这一偏微分方程构成了模拟模型的核心。

∂C/∂t + u·∂C/∂x + v·∂C/∂y = D(∂²C/∂x² + ∂²C/∂y²) + S

Here, C(x, y, t) is the concentration at position (x, y) and time t. The terms u·∂C/∂x and v·∂C/∂y represent advection in the x and y directions respectively. The second-order derivatives multiplied by D represent diffusion. The source term S allows us to model a continuous sewage discharge at a specific location.

其中,C(x, y, t) 是位置 (x, y) 在时间 t 的浓度。u·∂C/∂x 和 v·∂C/∂y 分别表示 x 和 y 方向的平流项。乘以 D 的二阶导数项表示扩散。源项 S 用于模拟特定位置的连续污水排放。

To complete the model, we must specify initial conditions and boundary conditions. Initially, the domain is assumed to be clean, so C = 0 everywhere except at the source location. The boundary conditions describe how the pollutant behaves at the edges of the computational domain.

为完善模型,我们必须指定初始条件和边界条件。初始时假定计算域是清洁的,因此除源位置外,各处 C = 0。边界条件描述污染物在计算域边缘的行为。


4. Numerical Discretisation Methods | 数值离散方法

The advection-diffusion equation cannot usually be solved analytically for domains with irregular shapes, variable velocity fields, or complex source terms. Instead, we discretise the continuous equation onto a grid of discrete points and advance the solution in small time steps. The most common approach is the finite difference method.

对于形状不规则、速度场变化或源项复杂的计算域,平流-扩散方程通常无法解析求解。我们将连续方程离散到由离散点组成的网格上,并以小时间步推进求解。最常用的方法是有限差分法。

We define a uniform grid with spacing Δx and Δy in the x and y directions, and a time step Δt. Using the Forward Time Central Space (FTCS) scheme, the derivatives are approximated as follows:

我们定义一个在 x 和 y 方向间距分别为 Δx 和 Δy 的均匀网格,以及时间步长 Δt。使用时间前向、空间中心(FTCS)格式,导数近似如下:

∂C/∂t ≈ (Cᵢ,ⱼⁿ⁺¹ − Cᵢ,ⱼⁿ) / Δt

∂C/∂x ≈ (Cᵢ₊₁,ⱼⁿ − Cᵢ₋₁,ⱼⁿ) / (2Δx)

∂²C/∂x² ≈ (Cᵢ₊₁,ⱼⁿ − 2Cᵢ,ⱼⁿ + Cᵢ₋₁,ⱼⁿ) / Δx²

Here, the subscript i and j denote the grid indices in the x and y directions, and the superscript n denotes the time level. The FTCS scheme is straightforward to implement but is only conditionally stable. Stability requires the time step to be sufficiently small relative to the grid spacing and the diffusion coefficient.

这里下标 i 和 j 表示 x 和 y 方向上的网格索引,上标 n 表示时间层。FTCS 格式实现简单,但仅条件稳定。稳定性要求时间步长相对于网格间距和扩散系数足够小。

Δt ≤ Δx² / (4D)

This condition prevents numerical oscillations that would otherwise cause the simulated concentration to become negative or to blow up exponentially. In practice, we choose Δt well below the stability limit to ensure smooth results.

该条件防止数值振荡,否则模拟浓度可能变为负值或以指数方式发散。实际中,我们选择远低于稳定性极限的 Δt,以确保结果平滑。


5. Implementing the Simulation | 模拟实现

Once the mathematical model and numerical scheme are established, the simulation can be implemented in any general-purpose programming language such as Python, Java, or C++. The algorithm follows a clear sequence of steps.

一旦数学模型和数值格式确定,就可以用任何通用编程语言(如Python、Java或C++)实现模拟。算法遵循清晰的步骤序列。

  1. Define the computational domain dimensions and grid resolution.

    定义计算域尺寸和网格分辨率。

  2. Set physical parameters: velocity components u and v, diffusion coefficient D, and source strength.

    设置物理参数:速度分量 u 和 v、扩散系数 D 以及源强度。

  3. Initialise the concentration array to zero and apply the source term at the discharge cell.

    将浓度数组初始化归零,并在排放单元处施加源项。

  4. At each time step, compute the new concentration using the discretised equation.

    在每个时间步,使用离散方程计算新的浓度。

  5. Apply boundary conditions at the edges of the grid.

    在网格边缘施加边界条件。

  6. Record the concentration field for visualisation and analysis.

    保存浓度场,用于可视化和分析。

The following pseudocode outlines the core loop of the simulation.

以下伪代码概述了模拟的核心循环。

for time = 1 to maxSteps:
    for i = 1 to nx:
        for j = 1 to ny:
            advection_x = u * (C[i+1][j] - C[i-1][j]) / (2 * dx)
            advection_y = v * (C[i][j+1] - C[i][j-1]) / (2 * dy)
            diffusion_x = D * (C[i+1][j] - 2*C[i][j] + C[i-1][j]) / (dx*dx)
            diffusion_y = D * (C[i][j+1] - 2*C[i][j] + C[i][j-1]) / (dy*dy)
            Cnew[i][j] = C[i][j] + dt * (diffusion_x + diffusion_y
                          - advection_x - advection_y) + S[i][j] * dt
    apply_boundary_conditions(Cnew)
    swap(C, Cnew)
    record_snapshot(C)

Notice that the advection terms are subtracted because they transport concentration away from a grid cell, while diffusion terms spread concentration into neighbouring cells.

注意,平流项要相减,因为它们将浓度从某个网格单元输运出去,而扩散项则将浓度扩展到相邻单元。


广告 / Sponsored

6. Boundary Conditions and Stability | 边界条件与稳定性

Boundary conditions play a crucial role in determining how the simulated pollutant behaves when it reaches the edge of the computational domain. Three common types of boundary conditions are used in dispersion modelling.

边界条件在决定模拟污染物到达计算域边缘时的行为方面起着关键作用。扩散建模中常用三种边界条件。

The choice of boundary condition has a direct impact on the accuracy of the simulation. An open boundary at the outflow of a river allows the plume to exit smoothly, whereas a reflective boundary would artificially trap the pollutant and cause unrealistic concentration accumulation.

边界条件的选择直接影响模拟的准确性。河流出流处的开放边界允许羽流平稳离开,而反射边界则会人为地截留污染物,造成不切实际的浓度累积。

Stability is another critical consideration. In addition to the diffusion stability limit, advection imposes its own constraint. The Courant-Friedrichs-Lewy (CFL) condition requires that the distance a particle travels in one time step does not exceed one grid cell:

稳定性是另一个关键考虑因素。除扩散稳定性极限外,平流也有自身的约束。Courant-Friedrichs-Lewy(CFL)条件要求一个时间步内粒子移动的距离不超过一个网格单元:

(|u| / Δx + |v| / Δy) · Δt ≤ 1

If the CFL condition is violated, the numerical solution becomes unstable and produces oscillatory errors that quickly overwhelm the physical signal. Therefore, a well-designed simulation always checks these conditions before running.

如果违反CFL条件,数值解将变得不稳定,产生振荡误差,迅速淹没物理信号。因此,设计良好的模拟在运行前总会检查这些条件。


7. Analysing Simulation Results | 模拟结果分析

The output of a dispersion simulation is a sequence of concentration fields at successive time steps. Analysing these results involves both qualitative visual inspection and quantitative computation of key metrics.

扩散模拟的输出是连续时间步的浓度场序列。分析这些结果既包括定性的视觉检查,也包括关键指标的定量计算。

Visually, the contaminant plume can be plotted as a colour contour map or a three-dimensional surface. Under a steady uniform current, the plume typically elongates downstream and spreads laterally, forming a teardrop-like shape. The peak concentration decreases over time as the pollutant spreads over a larger area.

在视觉上,污染物羽流可以绘制为彩色等值线图或三维曲面。在稳定的均匀水流下,羽流通常向下游拉长并向两侧扩展,形成类似泪滴的形状。随时间推移,峰值浓度下降,因为污染物扩散到更大区域。

Quantitative indicators used to evaluate the simulation include:

用于评估模拟的定量指标包括:

These metrics help environmental engineers determine the distance downstream that a sewage discharge remains hazardous, and how long it takes for the concentration to fall below acceptable levels.

这些指标帮助环境工程师确定污水排放下游多远的距离仍具有危害性,以及浓度需要多长时间才能降至可接受水平以下。


8. Model Validation and Limitations | 模型验证与局限性

Any simulation model must be validated before its predictions can be trusted. One common validation method is to compare the numerical solution with an analytical solution for a simplified scenario, such as an instantaneous point release in an infinite uniform flow with constant diffusivity.

任何模拟模型在预测结果可信之前都必须经过验证。一种常用的验证方法是将数值解与简化场景下的解析解进行比较,例如在无限均匀流场中具有恒定扩散系数的瞬时点源释放。

For a one-dimensional instantaneous release of mass M at x = 0, the analytical solution is a Gaussian curve that spreads over time:

对于一维瞬时释放质量 M 于 x = 0 处,解析解是一条随时间扩展的高斯曲线:

C(x, t) = M / (2√πDt) · exp(−x² / (4Dt))

If the numerical simulation reproduces this Gaussian distribution accurately, the implementation is likely correct. Discrepancies can reveal problems in the grid resolution, time stepping, or boundary treatment.

如果数值模拟能精确重现这一高斯分布,则说明实现基本正确。偏差可以揭示网格分辨率、时间步进或边界处理方面的问题。

However, real-world sewage dispersion involves complications that the simple model cannot capture. These include chemical reactions and biodegradation, temperature stratification, wind-driven surface currents, irregular riverbed geometry, and turbulent fluctuations on multiple scales. The dispersion coefficient may also vary spatially and temporally.

然而,实际污水扩散涉及简单模型无法捕捉的复杂因素。这些因素包括化学反应和生物降解、温度分层、风驱表面流、不规则的河床几何形状以及多尺度湍流波动。扩散系数也可能随空间和时间变化。

To address these limitations, advanced models use higher-order numerical schemes, adaptive grids, and coupled hydrodynamic simulations. Even so, all models are simplifications of reality, and their results should always be interpreted with an understanding of the underlying assumptions.

为解决这些局限性,高级模型采用高阶数值格式、自适应网格和耦合水动力模拟。即便如此,所有模型都是对现实的简化,解释其结果时始终需要理解其基本假设。


9. Applications in Environmental Management | 环境管理中的应用

Despite the limitations, sewage dispersion models are widely used in environmental management and public policy. They provide a rational basis for making decisions that affect water quality and community health.

尽管存在局限性,污水扩散模型仍广泛用于环境管理和公共政策制定。它们为影响水质和社区健康的决策提供了合理依据。

By integrating simulation with real-time monitoring data, a dynamic forecasting system can be built. Such systems are now being deployed in several major river basins around the world, improving our ability to manage water resources sustainably.

通过将模拟与实时监测数据相结合,可以建立动态预报系统。目前,此类系统已部署在全球若干主要流域,提升了我们可持续管理水资源的能力。


10. Conclusion | 结论

The construction of a sewage dispersion model demonstrates the full pipeline of computational scientific simulation: translating a physical phenomenon into a mathematical equation, converting that equation into a numerical algorithm, implementing the algorithm in code, and interpreting the resulting data to support real-world decisions.

污水扩散模型的构建展示了计算科学模拟的完整流程:将物理现象转化为数学方程,将方程转化为数值算法,将算法用代码实现,并解释所得数据以支持现实决策。

Computer science students working on this type of project gain valuable experience in numerical methods, array processing, algorithm design, and data visualisation. They also develop an appreciation for how programming can address pressing global challenges such as water pollution, climate change, and environmental degradation.

从事此类项目的计算机科学学生能够获得数值方法、数组处理、算法设计和数据可视化方面的宝贵经验。他们还体会到编程如何应对水污染、气候变化和环境退化等紧迫的全球性挑战。

By mastering models like the one presented here, students are well prepared for further study in computational science, environmental engineering, or data-driven research — fields where the ability to simulate complex systems is an increasingly valuable skill.

通过掌握本文所介绍的这类模型,学生可以为计算科学、环境工程或数据驱动研究等领域的进一步学习做好充分准备——在这些领域,模拟复杂系统的能力正成为一种日益宝贵的技能。

Published by TutorHao | Computer Science Revision Series | aleveler.com

广告 / Sponsored
Linux高级程序设计(高等院校计算机技术十二五规划教材)/刘加海/季江民/浙江大学出版社
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥55.6

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao