Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove parameter depth of discharge from battery instanciation
authorAdrien Gougeon <adrien.gougeon@ens-rennes.fr>
Thu, 13 Jul 2023 09:40:20 +0000 (11:40 +0200)
committerAdrien Gougeon <adrien.gougeon@ens-rennes.fr>
Thu, 13 Jul 2023 09:40:20 +0000 (11:40 +0200)
examples/cpp/battery-degradation/s4u-battery-degradation.cpp
examples/cpp/battery-energy/s4u-battery-energy.cpp
examples/cpp/battery-energy/s4u-battery-energy.tesh
examples/cpp/battery-simple/s4u-battery-simple.cpp
examples/cpp/battery-simple/s4u-battery-simple.tesh
include/simgrid/plugins/battery.hpp
src/plugins/battery.cpp

index 829efef..cc7e003 100644 (file)
@@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(battery_degradation, "Messages specific for this s4
 
 static void manager()
 {
-  auto battery = simgrid::plugins::Battery::init("Battery", 0.8, 0.9, 0.9, 10, 100, 0.9);
+  auto battery = simgrid::plugins::Battery::init("Battery", 0.8, 0.9, 0.9, 10, 100);
 
   battery->set_load("load", 100);
 
index 09645ca..a950620 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(battery_energy, "Messages specific for this s4u exa
 
 static void manager()
 {
-  auto battery = simgrid::plugins::Battery::init("Battery", 0.8, 0.9, 0.9, 10, 1000, 0.9);
+  auto battery = simgrid::plugins::Battery::init("Battery", 0.8, 0.9, 0.9, 10, 1000);
 
   auto* host1 = simgrid::s4u::Engine::get_instance()->host_by_name("MyHost1");
   auto* host2 = simgrid::s4u::Engine::get_instance()->host_by_name("MyHost2");
index 43094f4..eed565d 100644 (file)
@@ -4,10 +4,10 @@ $ ${bindir:=.}/s4u-battery-energy ${platfdir}/energy_platform.xml
 > [MyHost1:manager:(1) 0.000000] [battery_energy/INFO] Battery state: SoC: 0.800000 SoH: 1.000000 Energy stored: 28800.000000J Energy provided: 0.000000J Energy consumed 0.000000J
 > [MyHost1:manager:(1) 0.000000] [battery_energy/INFO] Connecting hosts MyHost1 and MyHost2 to the battery
 > [MyHost1:manager:(1) 0.000000] [battery_energy/INFO] Host MyHost1 will now execute 1000000000.000000 flops
-> [96.209721] [battery_energy/INFO] Event -> Battery low: SoC: 0.200000 SoH: 0.999700 Energy stored: 7197.839784J Energy provided: 19441.944194J Energy consumed 0.000000J
-> [96.209721] [battery_energy/INFO] Disconnecting hosts MyHost1 and MyHost2
-> [96.209721] [battery_energy/INFO] Energy consumed this far by: MyHost1: 9820.972097J, MyHost2: 9620.972097J, MyHost3: 9620.972097J
-> [MyHost1:manager:(1) 200.000000] [battery_energy/INFO] Battery state: SoC: 0.200000 SoH: 0.999700 Energy stored: 7197.839784J Energy provided: 19441.944194J Energy consumed 0.000000J
+> [96.208749] [battery_energy/INFO] Event -> Battery low: SoC: 0.200000 SoH: 0.999730 Energy stored: 7198.055825J Energy provided: 19441.749757J Energy consumed 0.000000J
+> [96.208749] [battery_energy/INFO] Disconnecting hosts MyHost1 and MyHost2
+> [96.208749] [battery_energy/INFO] Energy consumed this far by: MyHost1: 9820.874879J, MyHost2: 9620.874879J, MyHost3: 9620.874879J
+> [MyHost1:manager:(1) 200.000000] [battery_energy/INFO] Battery state: SoC: 0.200000 SoH: 0.999730 Energy stored: 7198.055825J Energy provided: 19441.749757J Energy consumed 0.000000J
 > [200.000000] [host_energy/INFO] Total energy consumption: 60200.000000 Joules (used hosts: 20200.000000 Joules; unused/idle hosts: 40000.000000)
 > [200.000000] [host_energy/INFO] Energy consumption of host MyHost1: 20200.000000 Joules
 > [200.000000] [host_energy/INFO] Energy consumption of host MyHost2: 20000.000000 Joules
index a499370..6f47cc7 100644 (file)
@@ -14,7 +14,7 @@ int main(int argc, char* argv[])
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  auto battery = simgrid::plugins::Battery::init("Battery", 0.8, 0.9, 0.9, 10, 1000, 0.9);
+  auto battery = simgrid::plugins::Battery::init("Battery", 0.8, 0.9, 0.9, 10, 1000);
 
   XBT_INFO("Initial state: SoC: %f SoH: %f Energy stored: %fJ Energy provided: %fJ Energy consumed %fJ",
            battery->get_state_of_charge(), battery->get_state_of_health(), battery->get_energy_stored(),
index 8870651..1ea75ed 100644 (file)
@@ -3,7 +3,7 @@
 $ ${bindir:=.}/s4u-battery-simple ${platfdir}/energy_platform.xml
 > [0.000000] [battery_simple/INFO] Initial state: SoC: 0.800000 SoH: 1.000000 Energy stored: 28800.000000J Energy provided: 0.000000J Energy consumed 0.000000J
 > [0.000000] [battery_simple/INFO] Set load to 100.000000W
-> [194.419442] [battery_simple/INFO] Discharged state: SoC: 0.200000 SoH: 0.999700 Energy stored: 7197.839784J Energy provided: 19441.944194J Energy consumed 0.000000J
-> [194.419442] [battery_simple/INFO] Set load to -100.000000W
-> [434.229010] [battery_simple/INFO] Charged state: SoC: 0.800000 SoH: 0.999330 Energy stored: 28780.700933J Energy provided: 19441.944194J Energy consumed 23980.956832J
-> [434.229010] [battery_simple/INFO] Set load to 0.000000W
\ No newline at end of file
+> [194.417498] [battery_simple/INFO] Discharged state: SoC: 0.200000 SoH: 0.999730 Energy stored: 7198.055825J Energy provided: 19441.749757J Energy consumed 0.000000J
+> [194.417498] [battery_simple/INFO] Set load to -100.000000W
+> [434.246101] [battery_simple/INFO] Charged state: SoC: 0.800000 SoH: 0.999397 Energy stored: 28782.630156J Energy provided: 19441.749757J Energy consumed 23982.860368J
+> [434.246101] [battery_simple/INFO] Set load to 0.000000W
\ No newline at end of file
index 41d4495..b85cec6 100644 (file)
@@ -99,7 +99,7 @@ private:
   double last_updated_      = 0;
 
   explicit Battery(const std::string& name, double state_of_charge, double charge_efficiency,
-                   double discharge_efficiency, double initial_capacity_wh, int cycles, double depth_of_discharge);
+                   double discharge_efficiency, double initial_capacity_wh, int cycles);
   static void init_plugin();
   void update();
   double next_occurring_event();
@@ -118,8 +118,7 @@ private:
 
 public:
   static BatteryPtr init(const std::string& name, double state_of_charge, double charge_efficiency,
-                         double discharge_efficiency, double initial_capacity_wh, int cycles,
-                         double depth_of_discharge);
+                         double discharge_efficiency, double initial_capacity_wh, int cycles);
   void set_load(const std::string& name, double power_w);
   void connect_host(s4u::Host* host, bool active = true);
   double get_state_of_charge();
index 6967ee4..df6ae46 100644 (file)
@@ -34,10 +34,9 @@ A battery starts with an energy budget :math:`E` such as:
 
 .. math::
 
-  E = C \times D \times N \times 2
+  E = C \times N \times 2
 
-Where :math:`C` is the initial capacity, :math:`D` is the depth of discharge
-and :math:`N` is the number of cycles of the battery.
+Where :math:`C` is the initial capacity and :math:`N` is the number of cycles of the battery.
 
 The SoH represents the consumption of this energy budget during the lifetime of the battery.
 Use the battery reduces its SoH and its capacity in consequence.
@@ -206,12 +205,12 @@ double Battery::next_occurring_event()
 }
 
 Battery::Battery(const std::string& name, double state_of_charge, double charge_efficiency, double discharge_efficiency,
-                 double initial_capacity_wh, int cycles, double depth_of_discharge)
+                 double initial_capacity_wh, int cycles)
     : name_(name)
     , charge_efficiency_(charge_efficiency)
     , discharge_efficiency_(discharge_efficiency)
     , initial_capacity_wh_(initial_capacity_wh)
-    , energy_budget_j_(initial_capacity_wh * depth_of_discharge * 3600 * cycles * 2)
+    , energy_budget_j_(initial_capacity_wh * 3600 * cycles * 2)
     , capacity_wh_(initial_capacity_wh)
     , energy_stored_j_(state_of_charge * 3600 * initial_capacity_wh)
 {
@@ -223,8 +222,6 @@ Battery::Battery(const std::string& name, double state_of_charge, double charge_
              " : discharge efficiency should be in [0,1] (provided: %f)", discharge_efficiency);
   xbt_assert(initial_capacity_wh > 0, " : initial capacity should be > 0 (provided: %f)", initial_capacity_wh);
   xbt_assert(cycles > 0, " : cycles should be > 0 (provided: %d)", cycles);
-  xbt_assert(depth_of_discharge > 0 and depth_of_discharge <= 1,
-             " : depth of discharge should be in ]0, 1] (provided: %f)", depth_of_discharge);
 }
 
 /** @ingroup plugin_battery
@@ -234,11 +231,10 @@ Battery::Battery(const std::string& name, double state_of_charge, double charge_
  *  @param discharge_efficiency The discharge efficiency of the Battery [0,1].
  *  @param initial_capacity_wh The initial capacity of the Battery in Wh (>0).
  *  @param cycles The number of charge-discharge cycles until complete depletion of the Battery capacity.
- *  @param depth_of_discharge The depth of discharge of the Battery.
  *  @return A BatteryPtr pointing to the new Battery.
  */
 BatteryPtr Battery::init(const std::string& name, double state_of_charge, double charge_efficiency,
-                         double discharge_efficiency, double initial_capacity_wh, int cycles, double depth_of_discharge)
+                         double discharge_efficiency, double initial_capacity_wh, int cycles)
 {
   static bool plugin_inited = false;
   if (not plugin_inited) {
@@ -246,7 +242,7 @@ BatteryPtr Battery::init(const std::string& name, double state_of_charge, double
     plugin_inited = true;
   }
   auto battery = BatteryPtr(new Battery(name, state_of_charge, charge_efficiency, discharge_efficiency,
-                                        initial_capacity_wh, cycles, depth_of_discharge));
+                                        initial_capacity_wh, cycles));
   battery_model_->add_battery(battery);
   return battery;
 }