修改控流阀死区为800,优化切换目标流量时PID模式切换逻辑,优化open_loop.py的--help显示,修改模式切换观察周期为10,更新了README.md
This commit is contained in:
+40
-9
@@ -97,7 +97,7 @@ class FlowControlLoop:
|
||||
pid_near_error_target_ratio=0.05,
|
||||
pid_far_error_min_slm=12.0,
|
||||
pid_far_error_target_ratio=0.20,
|
||||
pid_mode_switch_confirm_cycles=3,
|
||||
pid_mode_switch_confirm_cycles=10,
|
||||
logger=None,
|
||||
):
|
||||
if period_s <= 0:
|
||||
@@ -212,7 +212,32 @@ class FlowControlLoop:
|
||||
target_changed = target != self.target_flow_slm
|
||||
self.target_flow_slm = target
|
||||
if target_changed:
|
||||
self._apply_pid_mode("FAR", reason="目标流量切换")
|
||||
self._pid_mode_confirm_count = 0
|
||||
if self.last_flow_slm is None:
|
||||
self._apply_pid_mode(
|
||||
"FAR",
|
||||
reason="目标流量切换且尚无有效流量",
|
||||
)
|
||||
else:
|
||||
error_abs = abs(target - self.last_flow_slm)
|
||||
near_threshold, _ = self._pid_error_thresholds(target)
|
||||
if error_abs > near_threshold:
|
||||
self._apply_pid_mode(
|
||||
"FAR",
|
||||
reason=(
|
||||
f"目标流量切换后 |误差|={error_abs:.3f} SLM "
|
||||
f"> NEAR 阈值={near_threshold:.3f} SLM"
|
||||
),
|
||||
)
|
||||
else:
|
||||
self._log(
|
||||
"info",
|
||||
"目标流量切换后保持 PID %s 模式:"
|
||||
"|误差|=%.3f SLM <= NEAR 阈值=%.3f SLM",
|
||||
self.pid_mode,
|
||||
error_abs,
|
||||
near_threshold,
|
||||
)
|
||||
|
||||
def start(self, initial_opening=100.0):
|
||||
"""复位状态并启动控制;默认从全开开度开始。"""
|
||||
@@ -356,13 +381,8 @@ class FlowControlLoop:
|
||||
def _update_pid_mode(self, flow):
|
||||
"""按误差滞回切换 FAR/NEAR;参数只在模式变化时更新一次。"""
|
||||
error_abs = abs(self.target_flow_slm - flow)
|
||||
near_threshold = max(
|
||||
self.pid_near_error_min_slm,
|
||||
self.pid_near_error_target_ratio * self.target_flow_slm,
|
||||
)
|
||||
far_threshold = max(
|
||||
self.pid_far_error_min_slm,
|
||||
self.pid_far_error_target_ratio * self.target_flow_slm,
|
||||
near_threshold, far_threshold = self._pid_error_thresholds(
|
||||
self.target_flow_slm
|
||||
)
|
||||
|
||||
if self.pid_mode == "FAR":
|
||||
@@ -392,6 +412,17 @@ class FlowControlLoop:
|
||||
),
|
||||
)
|
||||
|
||||
def _pid_error_thresholds(self, target):
|
||||
near_threshold = max(
|
||||
self.pid_near_error_min_slm,
|
||||
self.pid_near_error_target_ratio * target,
|
||||
)
|
||||
far_threshold = max(
|
||||
self.pid_far_error_min_slm,
|
||||
self.pid_far_error_target_ratio * target,
|
||||
)
|
||||
return near_threshold, far_threshold
|
||||
|
||||
def _apply_pid_mode(
|
||||
self,
|
||||
mode,
|
||||
|
||||
Reference in New Issue
Block a user