.
This commit is contained in:
parent
d1c2f57891
commit
101c7f2058
@ -416,56 +416,32 @@ local function calculateOutputRate()
|
|||||||
result = math.floor(generationRate * 0.8)
|
result = math.floor(generationRate * 0.8)
|
||||||
reason = state .. " - 80% of generation"
|
reason = state .. " - 80% of generation"
|
||||||
else
|
else
|
||||||
-- Normal operation with temperature and saturation targeting
|
-- Normal operation: SATURATION is primary driver, TEMPERATURE is safety limit
|
||||||
local targetTemp = CONFIG.target_temperature
|
|
||||||
local targetSat = CONFIG.target_saturation
|
local targetSat = CONFIG.target_saturation
|
||||||
local limitingFactor = "OPTIMAL"
|
local limitingFactor = "OPTIMAL"
|
||||||
|
|
||||||
-- Temperature factor: controls output based on temp vs target
|
-- Saturation-based output: high sat = drain more, low sat = drain less
|
||||||
local tempFactor = 1.0
|
|
||||||
local tempCritical = false
|
|
||||||
if temp > CONFIG.critical_temperature then
|
|
||||||
-- Above critical: reduce output significantly for safety
|
|
||||||
local overTemp = temp - CONFIG.critical_temperature
|
|
||||||
local tempRange = CONFIG.max_temperature - CONFIG.critical_temperature
|
|
||||||
tempFactor = 1.0 - (overTemp / tempRange) * 0.8
|
|
||||||
tempCritical = true
|
|
||||||
limitingFactor = "TEMP_CRITICAL"
|
|
||||||
elseif temp > targetTemp then
|
|
||||||
-- Above target but below critical: increase output to cool down
|
|
||||||
local overTarget = temp - targetTemp
|
|
||||||
local targetRange = CONFIG.critical_temperature - targetTemp
|
|
||||||
tempFactor = 1.0 + (overTarget / targetRange) * 0.5 -- Up to 1.5x
|
|
||||||
limitingFactor = "TEMP_HIGH"
|
|
||||||
elseif temp < targetTemp * 0.8 then
|
|
||||||
-- Well below target: reduce output to let temp rise
|
|
||||||
local underTarget = targetTemp - temp
|
|
||||||
tempFactor = 0.5 + (temp / targetTemp) * 0.5 -- 0.5x to 1.0x
|
|
||||||
limitingFactor = "TEMP_LOW"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Saturation-based output adjustment (more aggressive: 0.3x to 2.0x)
|
|
||||||
local satError = saturation - targetSat -- positive = too high, negative = too low
|
local satError = saturation - targetSat -- positive = too high, negative = too low
|
||||||
|
local satFactor = 1.0 + satError * 3.0 -- More aggressive: 3x multiplier
|
||||||
|
satFactor = math.max(0.3, math.min(2.5, satFactor)) -- Clamp to 30%-250%
|
||||||
|
|
||||||
-- Quadratic scaling for more aggressive response when far from target
|
if satError > 0.1 then
|
||||||
local satFactor = 1.0 + satError * 2.0
|
|
||||||
satFactor = math.max(0.3, math.min(2.0, satFactor)) -- Clamp to 30%-200%
|
|
||||||
|
|
||||||
-- Track if saturation is the limiting factor
|
|
||||||
if satError > 0.1 and limitingFactor == "OPTIMAL" then
|
|
||||||
limitingFactor = "SAT_HIGH"
|
limitingFactor = "SAT_HIGH"
|
||||||
elseif satError < -0.1 and limitingFactor == "OPTIMAL" then
|
elseif satError < -0.1 then
|
||||||
limitingFactor = "SAT_LOW"
|
limitingFactor = "SAT_LOW"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- SAFETY: If temperature is critical, don't increase output
|
-- Temperature is ONLY a safety limiter (reduces output when too hot)
|
||||||
if tempCritical and satFactor > 1.0 then
|
local tempFactor = 1.0
|
||||||
satFactor = 1.0
|
if temp > CONFIG.critical_temperature then
|
||||||
end
|
-- Above critical: reduce output for safety
|
||||||
|
local overTemp = temp - CONFIG.critical_temperature
|
||||||
-- SAFETY: If temp is low, don't increase output even if sat is high
|
local tempRange = CONFIG.max_temperature - CONFIG.critical_temperature
|
||||||
if temp < targetTemp * 0.8 and satFactor > 1.0 then
|
tempFactor = 1.0 - (overTemp / tempRange) * 0.8
|
||||||
satFactor = 1.0
|
tempFactor = math.max(0.2, tempFactor) -- Never go below 20%
|
||||||
|
limitingFactor = "TEMP_CRITICAL"
|
||||||
|
-- Also cap saturation factor when temp critical
|
||||||
|
satFactor = math.min(satFactor, 1.0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local outputRate = generationRate * tempFactor * satFactor
|
local outputRate = generationRate * tempFactor * satFactor
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user