X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5d565c9f388ee34b957b69a595e98bbfaf06fb10..3f9b311ec56db95ec539001a860ae3c838c48312:/src/plugins/chiller.cpp diff --git a/src/plugins/chiller.cpp b/src/plugins/chiller.cpp index b0c814e5db..0a4d3afe4d 100644 --- a/src/plugins/chiller.cpp +++ b/src/plugins/chiller.cpp @@ -34,7 +34,7 @@ from the heat of the other devices, such as lighing, accounted using a factor :m 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:: @@ -57,6 +57,7 @@ chiller is not active, the temperature of the room increases. XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Chiller, kernel, "Logging specific to the solar panel plugin"); namespace simgrid::plugins { +xbt::signal Chiller::on_power_change; // initialisation of static field /* ChillerModel */ @@ -76,18 +77,11 @@ void ChillerModel::update_actions_state(double now, double delta) 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 */ @@ -111,30 +105,21 @@ void Chiller::update() 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; }); } @@ -296,19 +281,25 @@ ChillerPtr Chiller::remove_host(s4u::Host* host) } /** @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