Clarify calculations a little for #5
Ordering of ramping cases was a bit over the shop, so cleaned up. Comment about slope definitions was out of sync. Comment about $demand range clarified. Some mathematical terms bracketed to be less ambiguous. Fixes #5.
This commit is contained in:
parent
be27b2e538
commit
e29a05f4ab
1 changed files with 13 additions and 10 deletions
|
|
@ -121,40 +121,43 @@ sub set_fans_servo {
|
||||||
average(@cputemps), average(@coretemps), average(@hddtemps)),
|
average(@cputemps), average(@coretemps), average(@hddtemps)),
|
||||||
average(@hddtemps));
|
average(@hddtemps));
|
||||||
|
|
||||||
if (!defined $weighted_temp or $weighted_temp == 0) {
|
if ((!defined $weighted_temp) or ($weighted_temp == 0)) {
|
||||||
print "Error reading all temperatures! Fallback to idrac control\n";
|
print "Error reading all temperatures! Fallback to idrac control\n";
|
||||||
set_fans_default();
|
set_fans_default();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print "weighted_temp = $weighted_temp ; ambient_temp $ambient_temp\n" if $print_stats;
|
print "weighted_temp = $weighted_temp ; ambient_temp $ambient_temp\n" if $print_stats;
|
||||||
|
|
||||||
if (!defined $current_mode or $current_mode ne "set") {
|
if ((!defined $current_mode) or ($current_mode ne "set")) {
|
||||||
$current_mode="set";
|
|
||||||
print "--> disable dynamic fan control\n";
|
print "--> disable dynamic fan control\n";
|
||||||
system("ipmitool raw 0x30 0x30 0x01 0x00") == 0 or return 0;
|
system("ipmitool raw 0x30 0x30 0x01 0x00") == 0 or return 0;
|
||||||
# if this fails, want to return telling caller not to think weve
|
# if this fails, want to return telling caller not to think weve
|
||||||
# made a change
|
# made a change
|
||||||
|
$current_mode="set";
|
||||||
}
|
}
|
||||||
|
|
||||||
# FIXME: probably want to take into account ambient temperature - if
|
# FIXME: probably want to take into account ambient temperature - if
|
||||||
# the difference between weighted_temp and ambient_temp is small
|
# the difference between weighted_temp and ambient_temp is small
|
||||||
# because ambient_temp is large, then less need to run the fans
|
# because ambient_temp is large, then less need to run the fans
|
||||||
# because there's still low power demands
|
# because there's still low power demands
|
||||||
my $demand = 0; # want demand to be a reading from 0-100% of
|
my $demand = 0; # sort of starts off with a range roughly 0-255,
|
||||||
# $static_speed_low - $static_speed_high
|
# which we multiply later to be ranged roughly
|
||||||
|
# between 0-100% of
|
||||||
|
# ($static_speed_low - $static_speed_high)
|
||||||
if ($weighted_temp > $base_temp and
|
if ($weighted_temp > $base_temp and
|
||||||
$weighted_temp < $desired_temp1) {
|
$weighted_temp < $desired_temp1) {
|
||||||
# slope m = (y2-y1)/(x2-x1)
|
# slope m = (y2-y1)/(x2-x1)
|
||||||
# y - y1 = (x-x1)(y2-y1)/(x2-x1)
|
# y - y1 = (x-x1)(y2-y1)/(x2-x1)
|
||||||
# y1 = 0 ; x1 = base_temp ; y2 = demand1 ; x2 = desired_temp1
|
# y1 = 0 ; x1 = base_temp ; y2 = demand1 ; x2 = desired_temp1
|
||||||
# x = weighted_temp
|
# x = weighted_temp
|
||||||
$demand = 0 + ($weighted_temp - $base_temp) * ($demand1 - 0)/($desired_temp1 - $base_temp);
|
$demand = 0 + ($weighted_temp - $base_temp ) * ($demand1 - 0 )/($desired_temp1 - $base_temp );
|
||||||
} elsif ($weighted_temp >= $desired_temp2) {
|
} elsif (($weighted_temp >= $desired_temp1) or ($weighted_temp < $desired_temp2)) {
|
||||||
# y1 = demand1 ; x1 = desired_temp1 ; y2 = demand2 ; x2 = desired_temp2
|
|
||||||
$demand = $demand2 + ($weighted_temp - $desired_temp2) * ($demand3 - $demand2)/($desired_temp3 - $desired_temp2);
|
|
||||||
} elsif ($weighted_temp >= $desired_temp1) {
|
|
||||||
# y1 = demand1 ; x1 = desired_temp1 ; y2 = demand2 ; x2 = desired_temp2
|
# y1 = demand1 ; x1 = desired_temp1 ; y2 = demand2 ; x2 = desired_temp2
|
||||||
$demand = $demand1 + ($weighted_temp - $desired_temp1) * ($demand2 - $demand1)/($desired_temp2 - $desired_temp1);
|
$demand = $demand1 + ($weighted_temp - $desired_temp1) * ($demand2 - $demand1)/($desired_temp2 - $desired_temp1);
|
||||||
|
} elsif ($weighted_temp >= $desired_temp2) {
|
||||||
|
# y1 = demand2 ; x1 = desired_temp2 ; y2 = demand3 ; x2 = desired_temp3
|
||||||
|
# demand will increase above $demand3 for temps above $desired_temp3, linearly, until we cap it below
|
||||||
|
$demand = $demand2 + ($weighted_temp - $desired_temp2) * ($demand3 - $demand2)/($desired_temp3 - $desired_temp2);
|
||||||
}
|
}
|
||||||
printf "demand(%0.2f)", $demand if $print_stats;
|
printf "demand(%0.2f)", $demand if $print_stats;
|
||||||
$demand = int($static_speed_low + $demand/100*($static_speed_high-$static_speed_low));
|
$demand = int($static_speed_low + $demand/100*($static_speed_high-$static_speed_low));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue