np.logic_and/or/not用法

本文详细解析了如何在CSDN上发布一篇高质量的技术博客,包括标题、标签和内容的优化策略,旨在帮助作者提高文章的可见性和吸引力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import numpy as np import matplotlib.pyplot as plt from scipy.integrate import cumulative_trapezoid # ==================== 参数设置 ==================== # 细菌生长参数 a, b, c = -0.0011, 0.0545, -0.0602 K = 3e10 N0 = 1 dt = 0.1 t_total = 36 # 压强模型参数 (调整后的值) k_EPS = 2.5e-6 # 增大EPS分泌速率 alpha = 2.5e3 # 增强EPS对水势的影响 beta = -3e5 gamma = 1000 P_crit = 2e5 # ==================== 函数定义 ==================== def temperature(t): x = t return (-8e-12 * x**6 + 7e-9 * x**5 - 2e-6 * x**4 + 0.0003 * x**3 - 0.0171 * x**2 + 0.2602 * x + 16.89) def humidity(t): x = t return (2e-11 * x**6 - 2e-8 * x**5 + 6e-6 * x**4 - 0.0008 * x**3 + 0.0374 * x**2 - 0.1759 * x + 74.181) def r_T(T): return a * T**2 + b * T + c def bacterial_growth(N, t): T = temperature(t) return r_T(T) * N * (1 - N / K) # ==================== 数值求解 ==================== time_points = np.arange(0, t_total + dt, dt) T_values = temperature(time_points) RH_values = humidity(time_points) # 细菌数量求解 N_values = np.zeros_like(time_points) N_values[0] = N0 for i in range(len(time_points) - 1): t_i = time_points[i] N_i = N_values[i] N_p = N_i + dt * bacterial_growth(N_i, t_i) N_c = N_i + 0.5 * dt * (bacterial_growth(N_i, t_i) + bacterial_growth(N_p, t_i + dt)) N_values[i + 1] = N_c # 压强计算 EPS_values = k_EPS * cumulative_trapezoid(N_values, time_points, initial=0) psi_bacteria = alpha * EPS_values + beta psi_leaf = gamma * (RH_values - 100) P_values = psi_bacteria - psi_leaf # 计算破裂时间 burst_idx = np.where(P_values >= P_crit)[0] t_burst = time_points[burst_idx[0]] if len(burst_idx) > 0 else None # ==================== 可视化 ==================== plt.figure(figsize=(12, 6)) # 压强曲线 plt.plot(time_points, P_values / 1e5, 'b-', label='Pressure (×10⁵ Pa)') plt.axhline(P_crit / 1e5, color='r', linestyle='--', label='Critical Pressure') # 标记破裂时间 if t_burst is not None: plt.axvline(t_burst, color='g', linestyle=':', linewidth=2, label=f'Burst Time: {t_burst:.1f} h') plt.scatter(t_burst, P_crit / 1e5, color='k', zorder=5) plt.xlabel('Time (hours)') plt.ylabel('Pressure (×10⁵ Pa)') plt.title('Necrotic Pressure Dynamics with Burst Time Threshold') plt.legend() plt.grid(True) plt.tight_layout() plt.show() # ==================== 结果输出 ==================== print(f"破裂时间 t_burst: {t_burst:.1f} 小时" if t_burst else "未达到临界压强") 帮我运行上述代码,显示出运行结果
最新发布
05-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值