Q_{room} = (1 + \alpha) \times Q_{machines}
-This energy heats the input temperature :math:`T_{in}` and gives an output temperature :math:`T_{out}` based on the the
+This energy heats the input temperature :math:`T_{in}` and gives an output temperature :math:`T_{out}` based on the
mass of air inside the room :math:`m_{air}` and its specific heat :math:`C_{p}`:
.. math::
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Chiller, kernel, "Logging specific to the solar panel plugin");
namespace simgrid::plugins {
+xbt::signal<void(Chiller*)> Chiller::on_power_change; // initialisation of static field
/* ChillerModel */
double ChillerModel::next_occurring_event(double now)
{
static bool init = false;
- if (!init) {
+ if (not init) {
init = true;
return 0;
- }
- double next_event = -1;
- double tmp;
- for (auto chiller : chillers_) {
- tmp = chiller->get_next_event();
- if (tmp != -1 and (next_event == -1 or tmp < next_event))
- next_event = tmp;
- }
- return next_event;
+ } else
+ return -1;
}
/* Chiller */
return;
double hosts_power_w = 0;
- for (auto const& host : hosts_)
+ for (auto const& host : hosts_) {
hosts_power_w += sg_host_get_current_consumption(host);
- double heat_generated_j = hosts_power_w * (1 + alpha_) * time_delta_s;
- temp_out_c_ = temp_in_c_ + heat_generated_j / (air_mass_kg_ * specific_heat_j_per_kg_per_c_);
- double delta_temp_c = temp_out_c_ - goal_temp_c_;
-
- if (not active_ or delta_temp_c <= 0) {
- temp_in_c_ = temp_out_c_;
- power_w_ = 0;
- last_updated_ = now;
- return;
}
- double cooling_demand_w = delta_temp_c * air_mass_kg_ * specific_heat_j_per_kg_per_c_ / time_delta_s;
- double previous_power_w = power_w_;
- power_w_ = std::min(max_power_w_, cooling_demand_w / cooling_efficiency_);
+ double heat_generated_j = hosts_power_w * (1 + alpha_) * time_delta_s;
+ temp_out_c_ = temp_in_c_ + heat_generated_j / (air_mass_kg_ * specific_heat_j_per_kg_per_c_);
+ double cooling_demand_w =
+ std::max(temp_out_c_ - goal_temp_c_, 0.0) * air_mass_kg_ * specific_heat_j_per_kg_per_c_ / time_delta_s;
+ if (not active_)
+ power_w_ = 0;
+ else
+ power_w_ = std::min(max_power_w_, cooling_demand_w / cooling_efficiency_);
temp_in_c_ =
temp_out_c_ - (power_w_ * time_delta_s * cooling_efficiency_) / (air_mass_kg_ * specific_heat_j_per_kg_per_c_);
-
energy_consumed_j_ += power_w_ * time_delta_s;
- if (previous_power_w != power_w_) {
- on_this_power_change(this);
- on_power_change(this);
- }
last_updated_ = now;
});
}
}
/** @ingroup plugin_chiller
- * @return Time of the next event, i.e.,
- when the chiller will reach the goal temp if possible, -1 otherwise.
+ * @return The time to reach to goal temp, assuming that the system remain in the same state.
*/
-double Chiller::get_next_event()
+double Chiller::get_time_to_goal_temp() const
{
- if (not is_active() or goal_temp_c_ <= temp_out_c_)
+ if (goal_temp_c_ == temp_in_c_)
+ return 0;
+
+ double heat_power_w = 0;
+ for (auto const& host : hosts_)
+ heat_power_w += sg_host_get_current_consumption(host);
+ heat_power_w = heat_power_w * (1 + alpha_);
+
+ if (temp_in_c_ < goal_temp_c_)
+ return air_mass_kg_ * (goal_temp_c_ - temp_in_c_) * specific_heat_j_per_kg_per_c_ / heat_power_w;
+
+ if (not active_)
return -1;
- else {
- double heat_power_w = 0;
- for (auto const& host : hosts_)
- heat_power_w += sg_host_get_current_consumption(host);
- heat_power_w = heat_power_w * (1 + alpha_);
- return air_mass_kg_ * (goal_temp_c_ - temp_out_c_) * specific_heat_j_per_kg_per_c_ / heat_power_w;
- }
+ else
+ return air_mass_kg_ * (temp_in_c_ - goal_temp_c_) * specific_heat_j_per_kg_per_c_ /
+ (power_w_ * cooling_efficiency_ - heat_power_w);
}
} // namespace simgrid::plugins