|
@@ -0,0 +1,47 @@
|
|
|
+from flask import Flask, request, jsonify
|
|
|
+
|
|
|
+app = Flask(__name__)
|
|
|
+@app.route('/calculate_jt_time', methods=['POST'])
|
|
|
+def calculate_jt_time():
|
|
|
+ try:
|
|
|
+ # 解析 JSON 数据
|
|
|
+ data = request.get_json()
|
|
|
+
|
|
|
+ # 提取参数
|
|
|
+ m_ice = data.get("m_ice", 0) # 冰的质量 (kg)
|
|
|
+ c_ice = data.get("c_ice", 0) # 冰的比热容 (J/kg·K)
|
|
|
+ delta_T_initial = data.get("delta_T_initial", 0) # 初始温差 (K)
|
|
|
+ L = data.get("L", 0) # 冰的熔化潜热 (J/kg)
|
|
|
+ m_coke = data.get("m_coke", 0) # 焦炭质量 (kg)
|
|
|
+ c_coke = data.get("c_coke", 0) # 焦炭的比热容 (J/kg·K)
|
|
|
+ h = data.get("h", 0) # 对流换热系数 (W/m²·K)
|
|
|
+ A = data.get("A", 0) # 有效传热面积 (m²)
|
|
|
+ delta_T_heat = data.get("delta_T_heat", 0) # 热风温差 (K)
|
|
|
+
|
|
|
+ # 计算总热量需求
|
|
|
+ Q_ice = m_ice * (c_ice * delta_T_initial + L)
|
|
|
+ Q_coke = m_coke * c_coke * delta_T_initial
|
|
|
+ Q_total = Q_ice + Q_coke
|
|
|
+
|
|
|
+ # 计算总热传递能力
|
|
|
+ Q_transfer = h * A * delta_T_heat
|
|
|
+
|
|
|
+ # 避免除零错误
|
|
|
+ if Q_transfer == 0:
|
|
|
+ return jsonify({"error": "Heat transfer capacity is zero, invalid input."}), 400
|
|
|
+
|
|
|
+ # 计算时间 (秒)
|
|
|
+ t_seconds = Q_total / Q_transfer
|
|
|
+
|
|
|
+ # 转换为小时
|
|
|
+ t_hours = t_seconds / 3600
|
|
|
+
|
|
|
+ print("焦炭解冻时间为 ", t_hours)
|
|
|
+
|
|
|
+ return jsonify({"jt_time_hours": round(t_hours, 2)})
|
|
|
+ except Exception as e:
|
|
|
+ return jsonify({"error": str(e)}), 500
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ app.run(host='127.0.0.1', port=9996, debug=True)
|