2023 APMCM Asia-Pacific Competition (Question B) Microclimate Rules in Glass Greenhouses | Asia-Pacific College Student Mathematical Modeling Competition Modeling Analysis, Senior Xiaolu leads the team to guide full code articles and ideas

I am senior Xiaolu, studying at Shanghai Jiao Tong University. So far, I have helped more than 200 people complete modeling and idea building~
Let’s take a look at the Asia-Pacific Question B of the competition!
Insert image description here

The complete content can be obtained at the end of the article!

Problem restatement

Question 1: Establish a mathematical model to describe the distribution of temperature and wind speed in a glass greenhouse without crops. On the cross section of the greenhouse, specifically at a height of 0.5 meters, the distribution of temperature and wind speed is shown.

Question 2: Develop a mathematical model to describe the distribution of temperature and wind speed in a glass greenhouse where crops are grown. The distribution is presented in two cross-sections inside the greenhouse: one at a height of 0.5 m (corresponding to the level of the plant canopy) and the other at a height of 0.1 m (inside the crop canopy). Analyze whether these conditions are conducive to optimal crop growth.

Question 3: Provide the temperature and wind speed distribution inside the glass greenhouse under two scenarios and compare them with the solution in Question 2. In option one, increase the warm air outlet velocity from 2m/s to 3m/s. In option two, the position of the greenhouse fan is lowered by lowering it from 1.3 meters to a height of 1 meter.

Question 4: Investigate the potential for further optimization of glass greenhouse fan design by considering the impact of greenhouse fan number, location, wind speed, blowout temperature, specifications and different crops. Based on the analysis of these factors, suggestions for improvements are made.

Question one

When using the finite difference method for numerical solution, the mathematical model of Problem 1 can be established in detail according to the following steps:

  1. Griding: Divide the greenhouse space into grids and discretize them in space and time. Define temperature T T Tsum velocity field v \mathbf{v} The value of v at each grid point.

  2. Discretize the heat conduction equation: Discretize the heat conduction equation using the implicit difference method. For temperature T T T, the differential form can be expressed as:

    ρ c p T i , j n + 1 − T i , j n Δ t = ∇ ⋅ ( k ∇ T ) \rho c_p \frac{T_{i,j}^{n+1} - T_{i,j}^n}{\Delta t} = \nabla \cdot (k \nabla T) ρcpΔtTi,jn+1Ti,jn=(kT)

    in that, i i isum j j jis a case index, n n n is the number of steps in time, Δ t \Delta t Δt is the time step.

  3. Discretize the Navier-Stokes equation: Discretize the Navier-Stokes equation using the implicit difference method. For the velocity field v \mathbf{v} v, the differential form can be expressed as:

    ρ ( vi , j n + 1 − vi , j n Δ t + ( vi , j n ⋅ ∇ ) vi , j n ) = − ∇ pi , j n + 1 + μ ∇ 2 vi , j n + 1 + ρ g \rho \left( \frac{\mathbf{v}_{i,j}^{n+1} - \mathbf{v}_{i,j}^n}{\Delta t} + (\mathbf{v}_{i ,j}^n \cdot \example) \mathbf{v}_{i,j}^n \right) = -\example p_{i,j}^{n+1} + \mu \example^2 \ mathbf{v}_{i,j}^{n+1} + \rho \mathbf{g}r(Δtini,jn+1vi,jn+(vi,jn)vi,jn)=pi,jn+1+μ2vi,jn+1+ρg

  4. Pressure-velocity coupling: Use a pressure-velocity coupling algorithm (such as the SIMPLE algorithm) to couple the velocity field and the pressure field.

  5. Boundary conditions: According to the problem description, on one side of the greenhouse, set the boundary conditions to the greenhouse fan as the speed inlet condition to blow out warm air. Other boundary conditions can be set according to actual conditions.

  6. Initial conditions: Set the temperature field and velocity field at the initial moment.

  7. Iterative solution: Iterate in time and space and solve numerically based on the discretized system of equations.

  8. Result analysis: Collect temperature and wind speed data at each time step and spatial location. Pay special attention to the distribution on the cross section with a height of 0.5 meters.

  9. Post-processing: You can use visualization tools to draw isotherms or vector plots of temperature and wind speed to more intuitively understand the climate conditions in the greenhouse.

import numpy as np
import matplotlib.pyplot as plt

# 温室参数
length = 10  # 温室长度 (m)
width = 3    # 温室宽度 (m)
height = 2   # 温室高度 (m)

# 空间和时间离散化
dx = 0.1     # 空间步长 (m)
dt = 0.1     # 时间步长 (s)
steps = 100   # 时间步数

# 网格大小
nx = int(length / dx) + 1
ny = int(width / dx) + 1

# 初始化温度场和速度场
T = 20 * np.ones((nx, ny))  # 初始温度场
u = np.zeros((nx, ny))      # x方向速度场
v = np.zeros((nx, ny))      # y方向速度场

# 模拟主循环
for n in range(steps):
    # 更新温度场
    Tn = T.copy()
    T[1:-1, 1:-1] = Tn[1:-1, 1:-1] + dt * (k * (Tn[2:, 1:-1] - 2*Tn[1:-1, 1:-1] + Tn[:-2, 1:-1]) / dx**2
                                         + k * (Tn[1:-1, 2:] - 2*Tn[1:-1, 1:-1] + Tn[1:-1, :-2]) / dx**2)
    
    # 更新速度场(简化为稳态流场)
    u[1:-1, 1:-1] = 2  # 假设稳态时x方向速度为常数
    v[1:-1, 1:-1] = 0  # 假设稳态时y方向速度为0
#完整版关注文末名片获取

Question 2

When establishing the mathematical model for question 2, the situation with crops in the greenhouse needs to be considered in more detail. Here are the more detailed steps:

  1. Heat conduction equation:

    • Model form: Use the three-dimensional heat conduction equation to describe the evolution of temperature in the greenhouse, taking into account the absorption and release of heat in the greenhouse by crops.
      ρ c p ∂ T ∂ t = ∇ ⋅ ( k ∇ T ) + Q c \rho c_p \frac{\partial T}{\partial t} = \nabla \cdot (k \nabla T) + Q_c ρcptT=(kT)+Qc
      inside, Q c Q_c QcRepresents the additional heat source generated by the crop.

    • Additional heat source Q c Q_c Qc: Additional heat sources for crops can be modeled by considering the heat generated by photosynthesis, respiration, and other metabolic processes of the crop.

  2. Fluid Dynamics Equations:

    • Model form: Use the three-dimensional Navier-Stokes equation to describe the air flow in the greenhouse, taking into account the resistance of crops to air flow.
      ρ ( ∂ v ∂ t + v ⋅ ∇ v ) = − ∇ p + μ ∇ 2 v + ρ g − R c v \rho \left( \frac{\partial \mathbf{v }}{\partial t} + \mathbf{v} \cdot \nabla \mathbf{v} \right) = -\nabla p + \mu \nabla^2 \mathbf{v} + \rho \mathbf{g} - R_c \mathbf{v} r(tv+inv)=p+μ2v+ρgRcv
      inside, R c R_c Rcis an item related to crop resistance.

    • Crop inhibition R c R_c Rc: The resistance of the crop can be obtained by simulating the structure and shape of the crop and the resistance of air passing through the surface of the plant. This may require knowledge of plant physiology and fluid mechanics.

  3. Boundary conditions:

    • Greenhouse Boundary: Consider the boundary conditions of the greenhouse structure, including glass, subsoil, etc.
    • Greenhouse Fan Inlet: Set the speed inlet condition at the fan position to simulate the input of warm air.
    • Crop surface: Consider the heat flux and resistance of the crop surface, which may require consideration of the plant's growth status and stomatal conductance.
  4. Crop model:

    • Heat Source Model: Consider a crop growth model, including photosynthesis and respiration, to determine the amount of heat released or absorbed by the crop.
    • Resistance model: Based on the knowledge of plant structure and morphology, as well as fluid dynamics, a crop resistance model to air flow is established.
  5. Initial conditions:

    • Initial temperature field: Set the temperature field at the initial moment according to the initial conditions of the greenhouse.
    • Initial velocity field: Set the velocity field at the initial moment, taking into account the input of the greenhouse fan.
  6. Numerical solution:

    • Discretization: Use the finite difference method to discretize the heat conduction equation and Navier-Stokes equation.
    • Iterative solution: Solve the coupled heat conduction equation and fluid dynamics equation iteratively until a steady state is reached or for the required number of time steps.
  7. Result analysis:

    • Temperature and wind speed distribution: Analyze the distribution of temperature and wind speed at different locations in the greenhouse, especially near the crop canopy.
    • Crop growth conditions: Evaluate whether the climate conditions in the greenhouse are suitable for crop growth, based on the required temperature and wind speed ranges.
  8. Post-processing:

    • Visualization: Use visualization tools to draw isotherms or vector plots of temperature and wind speed to more intuitively understand climate conditions in the greenhouse.
import numpy as np
import matplotlib.pyplot as plt

# 温室参数
length = 10  # 温室长度 (m)
width = 3    # 温室宽度 (m)
height = 2   # 温室高度 (m)

# 空间和时间离散化
dx = 0.1     # 空间步长 (m)
dt = 0.1     # 时间步长 (s)
steps = 100   # 时间步数

# 网格大小
nx = int(length / dx) + 1
ny = int(width / dx) + 1

# 初始化温度场和速度场
T = 20 * np.ones((nx, ny))  # 初始温度场
u = np.zeros((nx, ny))      # x方向速度场
v = np.zeros((nx, ny))      # y方向速度场

# 模拟主循环
for n in range(steps):
    # 更新温度场#完整版关注文末名片
    Tn = T.copy()

Question three

Question three requires considering two different scenarios (scenario one: increasing the warm air outlet velocity, scenario two: reducing the greenhouse fan position) and comparing them to the situation in question two. The following is the modeling idea for question three:

Scenario 1: Increase warm air outlet velocity

  1. Adjust boundary conditions:

    • Increase the warm air outlet velocity from the value in scenario two (e.g. 2 m/s) to the target value in scenario one (e.g. 3 m/s).
  2. Rerun the model:

    • Using the mathematical model established in question two, adjust the warm air outlet velocity in the boundary conditions to the new target value.
    • Discretize the heat conduction equation and Navier-Stokes equation and solve it iteratively to obtain new temperature and wind speed distributions.
  3. Result analysis:

    • Compare the results of scenario one to the situation in question two, paying particular attention to changes in temperature and wind speed and the impact on crop growing conditions.
    • Analyze the uniformity and stability of temperature and wind speed distribution in the greenhouse.

Scenario 2: Lower the greenhouse fan position

  1. Adjust boundary conditions:

    • Reduce the position of the greenhouse fan from the value in scenario two (e.g. 1.3 m) to the target value in scenario two (e.g. 1 m).
  2. Rerun the model:

    • Use the mathematical model established in question 2 to adjust the greenhouse fan position in the boundary conditions to the new target value.
    • Discretize the heat conduction equation and Navier-Stokes equation and solve it iteratively to obtain new temperature and wind speed distributions.
  3. Result analysis:

    • Compare the results of Scenario 2 with the situation in Question 2, paying attention to changes in temperature and wind speed and the impact on crop growth conditions.
    • Analyze the uniformity and stability of temperature and wind speed distribution in the greenhouse.

Comprehensive analysis:

  1. Compare scenario one and scenario two:

    • Compare the temperature and wind speed distributions of Scenario 1 and Scenario 2, and analyze their effects in increasing the outlet velocity of warm air and reducing the position of greenhouse fans.
    • Consider the impact of these changes on climate conditions and crop growth within the greenhouse.
  2. Optimization suggestions:

    • Based on the comparison results, possible optimization suggestions are proposed, such as adjusting the warm air outlet speed and greenhouse fan position under different scenarios to improve the climate conditions in the greenhouse.
import numpy as np
import matplotlib.pyplot as plt

# 温室参数
length = 10  # 温室长度 (m)
width = 3    # 温室宽度 (m)
height = 2   # 温室高度 (m)

# 空间和时间离散化
dx = 0.1     # 空间步长 (m)
dt = 0.1     # 时间步长 (s)
steps = 100   # 时间步数

# 网格大小
nx = int(length / dx) + 1
ny = int(width / dx) + 1

# 温度场和速度场
T = 20 * np.ones((nx, ny))  # 初始温度场
u = np.zeros((nx, ny))      # x方向速度场
v = np.zeros((nx, ny))      # y方向速度场

def run_greenhouse_model(air_outlet_velocity, fan_position):
    # 重新运行模型的相关代码

    # 假设有一个函数 update_boundary_conditions,用于更新边界条件
    def update_boundary_conditions():
        # 在这里根据参数更新边界条件
        pass

    # 模拟主循环
    for n in range(steps):
        # 更新边界条件
        update_boundary_conditions()

        # 更新温度场
        Tn = T.copy()
        # TODO: 添加热传导方程的离散化更新步骤

        # 更新速度场(简化为稳态流场)
        u[1:-1, 1:-1] = 2  # 假设稳态时x方向速度为常数
        v[1:-1, 1:-1] = 0  # 假设稳态时y方向速度为0

    # 返回结果
    return T, u, v

Question 4

  1. Determination of optimization goals:

    • Objective function: Define an objective function, such as maximizing the growth rate of crops in a greenhouse. This can be a function based on crop growth models and physiological principles, taking into account factors such as temperature, humidity, light, etc.
  2. Selection of decision variables:

    • Number of fans in the greenhouse: The number of fans in the greenhouse is used as the decision variable, indicating the number of fans used in the greenhouse.
    • Fan location: Use the location of the fan (perhaps 3D coordinates) as a decision variable to determine the optimal location layout.
    • Wind speed and blowing temperature: Use the fan's wind speed and blowing temperature as decision variables to find the optimal environmental control strategy.
  3. Establishment of constraints:

    • Technical and physical constraints: Consider the physical dimensions of the greenhouse, technical specifications of the fans, etc. as constraints.
    • Crop requirements: Consider the growth requirements of crops, including suitable temperature range, humidity, etc. as constraints.
  4. Modeling:

    • Integrated model: Integrate the greenhouse model established in Question 2 and Question 3, and add the influence of greenhouse fans, including wind speed distribution, temperature distribution, etc.
    • Crop Growth Model: Integrate the crop's growth model with the greenhouse model to more fully consider the crop's growth needs.
  5. Mathematical optimization model:

    • Objective function formalization: Formalize the optimization objective and decision variables as a mathematical optimization problem, such as maximizing a growth rate function.
    • Constraints: Formalize constraints on technical, physical, and growth requirements into mathematical constraints.
    • Solver selection: Select an appropriate mathematical optimization solver, which may be linear programming, nonlinear programming, or evolutionary algorithms, etc.
  6. Model solving and analysis:

    • Solve the model: Use the selected mathematical optimization method to solve the model to find the optimal combination of decision variables.
    • Analysis results: Analyze the impact of the optimal solution on each variable and understand the improvement effect of the optimal solution on the greenhouse environment and crop growth.
  7. Sensitivity analysis:

    • Parameter sensitivity: Perform sensitivity analysis to evaluate the sensitivity of the model to input parameters to understand the robustness of the optimal solution to parameter changes.
  8. Interpretation of optimization results:

    • Suggestion: Explain the optimal solution and provide specific suggestions for greenhouse fan design, including fan number, location, wind speed and blowing temperature, etc.
  9. Validation and implementation:

    • Verification: Verify the feasibility of the optimization results, which may need to be verified through actual experiments or simulations.
    • Implementation: When implementing optimization plans, monitor actual results and make necessary adjustments.
from scipy.optimize import minimize
import numpy as np

# 假设问题四的目标函数为最大化作物生长速率
def objective_function(decision_variables):
    # 在这里调用你的模型,并返回一个优化目标,例如作物生长速率
    # decision_variables 包含温室风扇的数量、位置、风速和吹出温度等决策变量
    # 这里仅作为示例,需要根据实际模型进行修改
    return -1 * your_growth_rate_model(decision_variables)

# 定义约束条件
def constraint_1(decision_variables):
    # 示例:温室风扇数量不能超过上限
    return total_fans - np.sum(decision_variables[0:number_of_fans])

# 更多约束条件的定义...

# 定义初始决策变量的猜测值
initial_guess = np.array([1, 2, 3, 4, ...])

# 定义优化问题
optimization_problem = {
    
    
    'type': 'maximize',
    'fun': objective_function,
    'x0': initial_guess,
    'constraints': [
        {
    
    'type': 'ineq', 'fun': constraint_1},
        # 更多约束条件的添加...
    ],
}

For more information, you can click on the business card below to learn more, and let Senior Xiaolu lead you on the road to winning the Asia-Pacific Championship! Stay tuned to see what our efforts will bring! Remember to follow Senior LuluYeah

Guess you like

Origin blog.csdn.net/Tech_deer/article/details/134569476