envs package

Submodules

envs.bat_env_fwd_view module

class envs.bat_env_fwd_view.BatteryEnvFwd(env_config)[source]

Bases: Env

CO2_footprint(dc_load, ci, a_t, discharge_energy)[source]

Calculates carbon footprint

Parameters:
  • dc_load (float) – Total energy consumption of the DC.

  • ci (float) – Carbon intensity at current time step.

  • a_t (string) – Agent’s action.

  • discharge_energy (float) – Amount of energy to be discharged

Returns:

Carbon footprint produced at the current time step (gCO2e)

Return type:

CO2_footprint (float)

charging_rate_modifier(battery)[source]

Calculates the battery state depending on the charging rate

Parameters:

battery (batt.Battery2) – Battery model

Returns:

Battery charging rate

Return type:

charging_rate (float)

discharging_rate_modifier(battery)[source]

Calculates the battery state depending on the discharging rate

Parameters:

battery (batt.Battery2) – Battery model

Returns:

Battery discharging rate

Return type:

discharging_rate (float)

reset(*, seed=None, options=None)[source]

Reset BatteryEnvFwd to initial state.

Parameters:
  • seed (int, optional) – Random seed.

  • options (dict, optional) – Environment options.

Returns:

Current state of the environmment info (dict): A dictionary that containing additional information about the environment state

Return type:

temp_state (List[float])

set_dcload(dc_load)[source]

Set the current DC energy consumption

Parameters:

float (dc_load) – DC energy consumption.

sigmoid(x)[source]
step(action_id)[source]

Step function :param action_id: the action id :type action_id: int

Returns:

Current state of the environmment reward (float): reward value. done (bool): A boolean value signaling the if the episode has ended. info (dict): A dictionary that containing additional information about the environment state

Return type:

obs (list)

update_ci(ci, ci_n)[source]

Sets internal CIs values.

update_state()[source]

Updates obsevation with current DC energy consumption

Returns:

normalized_observations (string)

envs.battery_model module

class envs.battery_model.Battery2(capacity, current_load=0, eff_c=1, eff_d=1, c_lim=0.1, d_lim=1, upper_u=-0.04, upper_v=1, lower_u=0.01, lower_v=0)[source]

Bases: object

c_lim = 3
calc_max_charge(T_u)[source]
calc_max_discharge(T_u, dc_load)[source]
capacity = 0
charge(input_load, T_u)[source]
current_load = 0
d_lim = 3
discharge(output_load, T_u, dc_load)[source]
eff_c = 1
eff_d = 1
find_and_init_capacity(input_load)[source]
is_full()[source]
lower_lim_u = 0
lower_lim_v = 0
reset()[source]
upper_lim_u = 0
upper_lim_v = 1

envs.carbon_ls module

class envs.carbon_ls.CarbonLoadEnv(env_config={}, future=True, n_vars_ci=4, flexible_workload_ratio=0.2, n_vars_energy=0, n_vars_battery=1, test_mode=False, queue_max_len=500)[source]

Bases: Env

reset(*, seed=None, options=None)[source]

Reset CarbonLoadEnv to initial state.

Returns:

Current state of the environmment info (dict): A dictionary that containing additional information about the environment state

Return type:

observations (List[float])

step(action)[source]

Makes an environment step in`CarbonLoadEnv.

Parameters:

action (int) – Action to take.

Returns:

Current state of the environmment reward (float): reward value. done (bool): A boolean value signaling the if the episode has ended. info (dict): A dictionary that containing additional information about the environment state

Return type:

observations (List[float])

update_workload(workload)[source]

Makes an environment step in`BatteryEnvFwd.

Parameters:

workload (float) – Workload assigned at the current time step

envs.datacenter module

class envs.datacenter.CPU(full_load_pwr=None, idle_pwr=None, cpu_config=None)[source]

Bases: object

cpu_curve1()[source]

initialize the cpu power ratio curve at different IT workload ratios as a function of inlet temperatures [3]

itfan_curve2()[source]

initialize the itfan velocity ratio curve at different IT workload ratios as a function of inlet temperatures [3]

class envs.datacenter.DataCenter_ITModel(num_racks, rack_supply_approach_temp_list, rack_CPU_config, max_W_per_rack=10000, DC_ITModel_config=None, chiller_sizing=False)[source]

Bases: object

calculate_cooling_tower_water_usage()[source]

Calculate the estimated water usage of the cooling tower.

This function uses the attributes set in the class to estimate the water usage based [Sharma, R.K., Shah, A., Bash, C.E., Christian, T., & Patel, C.D. (2009). Water efficiency management in datacenters: Metrics and methodology. 2009 IEEE International Symposium on Sustainable Systems and Technology, 1-6.] [Mohammed Shublaq, Ahmad K. Sleiti., (2020). Experimental analysis of water evaporation losses in cooling towers using filters] https://spxcooling.com/water-calculator/

compute_datacenter_IT_load_outlet_temp(ITE_load_pct_list, CRAC_setpoint)[source]

Calculate the average outlet temperature of all the racks

Parameters:
  • ITE_load_pct_list (List[float]) – CPU load for each rack

  • CRAC_setpoint (float) – CRAC setpoint

Returns:

Rackwise CPU power usage rackwise_itfan_pwr (List[float]): Rackwise IT fan power usage rackwise_outlet_temp (List[float]): Rackwise outlet temperature

Return type:

rackwise_cpu_pwr (List[float])

total_datacenter_full_load()[source]

Calculate the total DC IT(IT CPU POWER + IT FAN POWER) power consumption

class envs.datacenter.Rack(CPU_config_list, max_W_per_rack=10000, rack_config=None)[source]

Bases: object

clamp_supply_approach_temp(supply_approach_temperature)[source]

Returns the clamped delta/ supply approach temperature between the range [3.8, 5.3]

Returns:

Supply approach temperature

Return type:

float

compute_instantaneous_pwr(inlet_temp, ITE_load_pct)[source]

Calculate the power consumption of the whole rack at the current step

Parameters:
  • inlet_temp (float) – Room temperature

  • ITE_load_pct (float) – Current CPU usage

Returns:

Current CPU power usage

Return type:

cpu_power (float)

compute_instantaneous_pwr_vecd(inlet_temp, ITE_load_pct)[source]

Calculate the power consumption of the whole rack at the current step in a vectorized manner

Parameters:
  • inlet_temp (float) – Room temperature

  • ITE_load_pct (float) – Current CPU usage

Returns:

Current CPU power usage

Return type:

cpu_power (float)

cpu_and_fan_init()[source]

Initialize the CPU and Fan parameters for the servers in each rack with the specified data center configurations

get_average_rack_fan_v()[source]

Calculate the average fan velocity for each rack

Returns:

Average fan flow rate for the rack

Return type:

(float)

get_current_rack_load()[source]

Returns the total power consumption of the rack

Returns:

Total power consumption of the rack

Return type:

float

get_total_rack_fan_v()[source]

Calculate the total fan velocity for each rack

Returns:

Total fan flow rate for the rack

Return type:

(float)

envs.datacenter.calculate_HVAC_power(CRAC_setpoint, avg_CRAC_return_temp, ambient_temp, data_center_full_load, DC_Config, ctafr=None)[source]

Calculate the HVAV power attributes

Parameters:
  • CRAC_Setpoint (float) – The control action

  • avg_CRAC_return_temp (float) – The average of the temperatures from all the Racks + their corresponding return approach temperature (Delta)

  • ambient_temp (float) – outside air temperature

  • data_center_full_load (float) – total data center capacity

Returns:

CRAC fan power CT_Fan_pwr (float): Cooling tower fan power CRAC_cooling_load (float): CRAC cooling load Compressor_load (float): Chiller compressor load

Return type:

CRAC_Fan_load (float)

envs.datacenter.calculate_avg_CRAC_return_temp(rack_return_approach_temp_list, rackwise_outlet_temp)[source]

Calculate the CRAC return air temperature

Parameters:
  • rack_return_approach_temp_list (List[float]) – The delta change in temperature from each rack to the CRAC unit

  • rackwise_outlet_temp (float) – The outlet temperature of each rack

Returns:

CRAC return air temperature

Return type:

(float)

envs.datacenter.calculate_chiller_power(max_cooling_cap, load, ambient_temp)[source]

Calculate the chiller power consumption based on load and operating conditions.

Obtained from:
  1. https://github.com/NREL/EnergyPlus/blob/9bb39b77a871dee7543c892ae53b0812c4c17b0d/testfiles/AirCooledElectricChiller.idf

  2. https://github.com/NREL/EnergyPlus/issues/763

  3. https://dmey.github.io/EnergyPlusFortran-Reference/proc/calcelectricchillermodel.html

  4. https://github.com/NREL/EnergyPlus/blob/9bb39b77a871dee7543c892ae53b0812c4c17b0d/tst/EnergyPlus/unit/ChillerElectric.unit.cc#L95

Parameters:
  • max_cooling_cap (float) – Maximum cooling capacity of the chiller (Watts).

  • load (float) – The heat load to be removed by the chiller (Watts).

  • ambient_temp (float) – Current ambient temperature (Celsius).

Returns:

Estimated power consumption of the chiller (Watts).

Return type:

float

envs.datacenter.chiller_sizing(DC_Config, min_CRAC_setpoint=16, max_CRAC_setpoint=22, max_ambient_temp=40.0)[source]

Calculates the chiller sizing for a data center based on the given configuration and parameters.

Parameters:
  • DC_Config (object) – The data center configuration object.

  • min_CRAC_setpoint (float) – The minimum CRAC setpoint temperature in degrees Celsius. Default is 16.

  • max_CRAC_setpoint (float) – The maximum CRAC setpoint temperature in degrees Celsius. Default is 22.

  • max_ambient_temp (float) – The maximum ambient temperature in degrees Celsius. Default is 40.0.

Returns:

A tuple containing the cooling tower reference air flow rate (ctafr) and the rated load of the cooling tower (CT_rated_load).

Return type:

tuple

envs.dc_gym module

class envs.dc_gym.dc_gymenv(observation_variables: list, observation_space: Box, action_variables: list, action_space: Discrete, action_mapping: dict, ranges: dict, add_cpu_usage: bool, min_temp: float, max_temp: float, action_definition: dict, DC_Config: dict, seed: int = 123, episode_length_in_time: Timedelta | None = None)[source]

Bases: Env

NormalizeObservation()[source]

Obtains the value for normalizing the observation.

get_obs()[source]

Returns the observation at the current time step.

Returns:

Current state of the environmment.

Return type:

observation (List[float])

normalize(obs)[source]

Normalizes the observation.

reset(*, seed=None, options=None)[source]

Reset dc_gymenv to initial state.

Parameters:
  • seed (int, optional) – Random seed.

  • options (dict, optional) – Environment options.

Returns:

Current state of the environmment {} (dict): A dictionary that containing additional information about the environment state

Return type:

raw_curr_state (List[float])

set_ambient_temp(ambient_temp, wet_bulb)[source]

Updates the external temperature.

set_bat_SoC(bat_SoC)[source]

Updates the battery state of charge.

set_shifted_wklds(cpu_load)[source]

Updates the current CPU workload. fraction between 0.0 and 1.0

step(action)[source]

Makes an environment step in`dc_gymenv.

Parameters:

action_id (int) – Action to take.

Returns:

Current state of the environmment reward (float): reward value. done (bool): A boolean value signaling the if the episode has ended. info (dict): A dictionary that containing additional information about the environment state

Return type:

observations (List[float])

Module contents

Includes the environments.