Skip to content

Commit

Permalink
Merge pull request #18 from idaholab/develop
Browse files Browse the repository at this point in the history
v.1.0.1
  • Loading branch information
manoj1511 authored Jul 17, 2024
2 parents 2cffdd9 + ca68388 commit c63cc9c
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 38 deletions.
4 changes: 2 additions & 2 deletions source/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(GLOBALS_DIR ${PROJECT_SOURCE_DIR}/source/charging_models)
option(ICM "compile caldera_ICM library" OFF)

if(ICM)
add_library(Caldera_ICM_lib datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp
add_library(Caldera_ICM_lib STATIC datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp
battery_integrate_X_in_time.cpp battery.cpp vehicle_charge_model.cpp supply_equipment_load.cpp
supply_equipment_control.cpp supply_equipment.cpp supply_equipment_group.cpp charge_profile_library.cpp
SE_EV_factory_charge_profile.cpp charge_profile_downsample_fragments.cpp ICM_interface.cpp
Expand All @@ -23,7 +23,7 @@ if(ICM)
DESTINATION ${INSTALL_DIR})
endif()

add_library(Caldera_ICM_Aux_lib datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp
add_library(Caldera_ICM_Aux_lib STATIC datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp
battery_integrate_X_in_time.cpp battery.cpp vehicle_charge_model.cpp supply_equipment_load.cpp
supply_equipment_control.cpp supply_equipment.cpp charge_profile_library.cpp SE_EV_factory_charge_profile.cpp
charge_profile_downsample_fragments.cpp Aux_interface.cpp
Expand Down
5 changes: 5 additions & 0 deletions source/base/charge_profile_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class pev_charge_profile_aux
{
return this->setpoint_P3kW < x.setpoint_P3kW;
}

bool operator<(pev_charge_profile_aux& x) const
{
return this->setpoint_P3kW < x.setpoint_P3kW;
}
};


Expand Down
19 changes: 17 additions & 2 deletions source/base/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ struct line_segment
double y_LB() const {return this->a*this->x_LB + this->b;}
double y(double x) const {return this->a*x + this->b;}

bool operator < (const line_segment& rhs) const
bool operator<(const line_segment& rhs) const
{
return this->x_LB < rhs.x_LB;
}

bool operator<(line_segment& rhs) const
{
return this->x_LB < rhs.x_LB;
}
Expand Down Expand Up @@ -53,7 +58,12 @@ struct poly_segment
double d;
double e;

bool operator<(const poly_segment &rhs)
bool operator<(const poly_segment &rhs) const
{
return x_LB < rhs.x_LB;
}

bool operator<(poly_segment &rhs) const
{
return x_LB < rhs.x_LB;
}
Expand Down Expand Up @@ -304,6 +314,11 @@ struct dcfc_charge_event
{
return arrival_unix_time < x.arrival_unix_time;
}
bool operator<(dcfc_charge_event& x) const
{
return arrival_unix_time < x.arrival_unix_time;
}
};
Expand Down
12 changes: 9 additions & 3 deletions source/base/supply_equipment_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void ES100_control_strategy::update_parameters_for_CE(double target_P3kW_, const

double arrival_unix_time = charge_status.arrival_unix_time;
double departure_unix_time = charge_status.departure_unix_time;

pev_charge_profile_result Z = charge_profile->find_result_given_startSOC_and_endSOC(this->target_P3kW, charge_status.now_soc, charge_status.departure_SOC);
double min_time_to_charge_sec = 3600*Z.total_charge_time_hrs;

Expand Down Expand Up @@ -86,12 +86,18 @@ void ES100_control_strategy::update_parameters_for_CE(double target_P3kW_, const

double time_ahead_of_midnight_sec = fmod(arrival_unix_time, 24.0*3600.0);
double midnight_nearest_arrival_unix_time = arrival_unix_time - time_ahead_of_midnight_sec;
if(time_ahead_of_midnight_sec > 12.0*3600.0)
midnight_nearest_arrival_unix_time += 24.0*3600.0;

// midnight_nearest_arrival_unix_time moves a day ahead when it crosses 12, doesn't work with intra day TOU period
//if(time_ahead_of_midnight_sec > 12.0*3600.0)
// midnight_nearest_arrival_unix_time += 24.0*3600.0;

double beginning_of_TofU_rate_period_unix_time = midnight_nearest_arrival_unix_time + beginning_of_TofU_rate_period__time_from_midnight_sec;
double end_of_TofU_rate_period_unix_time = midnight_nearest_arrival_unix_time + end_of_TofU_rate_period__time_from_midnight_sec;

// Fixes TOU rate period when end TOU is smaller than start TOU. i.e intra day TOU. e.g. (8, -6) aka (8, 18)
if (end_of_TofU_rate_period_unix_time < beginning_of_TofU_rate_period_unix_time)
end_of_TofU_rate_period_unix_time += 24.0 * 3600;

//-----------------------------------------
// Calculate this->charge_start_unix_time
//-----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion source/charging_models/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

add_library(Caldera_global_lib datatypes_global.cpp ${PROJECT}/datatypes_global_SE_EV_definitions.cpp)
add_library(Caldera_global_lib STATIC datatypes_global.cpp ${PROJECT}/datatypes_global_SE_EV_definitions.cpp)
target_include_directories(Caldera_global_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(Caldera_global_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT})

Expand Down
7 changes: 6 additions & 1 deletion source/charging_models/DirectXFC/SE_EV_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ class factory_EV_charge_model
double puVrms;
double P2_val;

bool operator<(const point_P2_vs_puVrms& rhs)
bool operator<(const point_P2_vs_puVrms& rhs) const
{
return (this->puVrms < rhs.puVrms);
}

bool operator<(point_P2_vs_puVrms& rhs) const
{
return (this->puVrms < rhs.puVrms);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ std::pair<bool, supply_equipment_enum> get_supply_equipment_enum(const std::stri
if (!std::isspace(str_val[i]))
tmp_str += str_val[i];

if (tmp_str == "1") SE_enum = L1_1440;
else if (tmp_str == "2") SE_enum = L2_3600;
else if (tmp_str == "3") SE_enum = L2_7200;
else if (tmp_str == "4") SE_enum = L2_9600;
else if (tmp_str == "5") SE_enum = L2_11520;
else if (tmp_str == "20") SE_enum = L2_17280;
if (tmp_str == "1" || tmp_str == "L1_1440") SE_enum = L1_1440;
else if (tmp_str == "2" || tmp_str == "L2_3600") SE_enum = L2_3600;
else if (tmp_str == "3" || tmp_str == "L2_7200") SE_enum = L2_7200;
else if (tmp_str == "4" || tmp_str == "L2_9600") SE_enum = L2_9600;
else if (tmp_str == "5" || tmp_str == "L2_11520") SE_enum = L2_11520;
else if (tmp_str == "20" || tmp_str == "L2_17280") SE_enum = L2_17280;

else if (tmp_str == "6") SE_enum = dcfc_50;
else if (tmp_str == "7") SE_enum = xfc_150;
else if (tmp_str == "8") SE_enum = xfc_350;
else if (tmp_str == "6" || tmp_str == "dcfc_50") SE_enum = dcfc_50;
else if (tmp_str == "7" || tmp_str == "xfc_150") SE_enum = xfc_150;
else if (tmp_str == "8" || tmp_str == "xfc_350") SE_enum = xfc_350;
else
{
conversion_successfull = false;
Expand Down Expand Up @@ -164,22 +164,22 @@ std::pair<bool, vehicle_enum> get_vehicle_enum(const std::string str_val)
tmp_str += str_val[i];

// Recharge
if (tmp_str == "1") pev_enum = bev250_ld2_300kW;
else if (tmp_str == "2") pev_enum = bev200_ld4_150kW;
else if (tmp_str == "3") pev_enum = bev275_ld1_150kW;
else if (tmp_str == "4") pev_enum = bev250_ld1_75kW;
else if (tmp_str == "5") pev_enum = bev150_ld1_50kW;
else if (tmp_str == "6") pev_enum = phev_SUV;
else if (tmp_str == "7") pev_enum = phev50;
else if (tmp_str == "8") pev_enum = phev20;
if (tmp_str == "1" || tmp_str == "bev250_ld2_300kW") pev_enum = bev250_ld2_300kW;
else if (tmp_str == "2" || tmp_str == "bev200_ld4_150kW") pev_enum = bev200_ld4_150kW;
else if (tmp_str == "3" || tmp_str == "bev275_ld1_150kW") pev_enum = bev275_ld1_150kW;
else if (tmp_str == "4" || tmp_str == "bev250_ld1_75kW") pev_enum = bev250_ld1_75kW;
else if (tmp_str == "5" || tmp_str == "bev150_ld1_50kW") pev_enum = bev150_ld1_50kW;
else if (tmp_str == "6" || tmp_str == "phev_SUV") pev_enum = phev_SUV;
else if (tmp_str == "7" || tmp_str == "phev50") pev_enum = phev50;
else if (tmp_str == "8" || tmp_str == "phev20") pev_enum = phev20;

// DirectXFC
else if (tmp_str == "9") pev_enum = bev250_400kW;
else if (tmp_str == "10") pev_enum = bev300_575kW;
else if (tmp_str == "11") pev_enum = bev300_400kW;
else if (tmp_str == "12") pev_enum = bev250_350kW;
else if (tmp_str == "13") pev_enum = bev300_300kW;
else if (tmp_str == "14") pev_enum = bev150_150kW;
else if (tmp_str == "9" || tmp_str == "bev250_400kW") pev_enum = bev250_400kW;
else if (tmp_str == "10" || tmp_str == "bev300_575kW") pev_enum = bev300_575kW;
else if (tmp_str == "11" || tmp_str == "bev300_400kW") pev_enum = bev300_400kW;
else if (tmp_str == "12" || tmp_str == "bev250_350kW") pev_enum = bev250_350kW;
else if (tmp_str == "13" || tmp_str == "bev300_300kW") pev_enum = bev300_300kW;
else if (tmp_str == "14" || tmp_str == "bev150_150kW") pev_enum = bev150_150kW;
else
{
conversion_successfull = false;
Expand Down
7 changes: 6 additions & 1 deletion source/charging_models/EVs_at_Risk/SE_EV_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ class factory_EV_charge_model
double puVrms;
double P2_val;

bool operator<(const point_P2_vs_puVrms& rhs)
bool operator<(const point_P2_vs_puVrms& rhs) const
{
return (this->puVrms < rhs.puVrms);
}

bool operator<(point_P2_vs_puVrms& rhs) const
{
return (this->puVrms < rhs.puVrms);
}
Expand Down
12 changes: 11 additions & 1 deletion source/charging_models/datatypes_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ struct charge_event_data
{
return this->arrival_unix_time < rhs.arrival_unix_time;
}

bool operator<(charge_event_data& rhs) const
{
return this->arrival_unix_time < rhs.arrival_unix_time;
}
};
std::ostream& operator<<(std::ostream& out, const charge_event_data& x);

Expand Down Expand Up @@ -554,7 +559,12 @@ struct pev_charge_fragment
pev_charge_fragment() {};
pev_charge_fragment(double soc_, double E1_kWh_, double E2_kWh_, double E3_kWh_, double cumQ3_kVARh_, double time_since_charge_began_hrs_);

bool operator<(const pev_charge_fragment &rhs)
bool operator<(const pev_charge_fragment &rhs) const
{
return (this->time_since_charge_began_hrs < rhs.time_since_charge_began_hrs);
}

bool operator<(pev_charge_fragment &rhs) const
{
return (this->time_since_charge_began_hrs < rhs.time_since_charge_began_hrs);
}
Expand Down
7 changes: 6 additions & 1 deletion source/charging_models/eMosaic/SE_EV_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ class factory_EV_charge_model
double puVrms;
double P2_val;

bool operator<(const point_P2_vs_puVrms& rhs)
bool operator<(const point_P2_vs_puVrms& rhs) const
{
return (this->puVrms < rhs.puVrms);
}

bool operator<(point_P2_vs_puVrms& rhs) const
{
return (this->puVrms < rhs.puVrms);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ struct Ppu_vs_soc_point
double P_pu;
Ppu_vs_soc_point_type point_type;

bool operator<(const Ppu_vs_soc_point& rhs)
bool operator<(const Ppu_vs_soc_point& rhs) const
{
return soc < rhs.soc;
}

bool operator<(Ppu_vs_soc_point& rhs) const
{
return soc < rhs.soc;
}
Expand All @@ -80,7 +85,12 @@ struct line_segment
double y_UB() {return a*x_UB + b;}
double y_LB() {return a*x_LB + b;}

bool operator < (const line_segment& rhs)
bool operator<(const line_segment& rhs) const
{
return this->x_LB < rhs.x_LB;
}

bool operator<(line_segment& rhs) const
{
return this->x_LB < rhs.x_LB;
}
Expand All @@ -101,7 +111,12 @@ class Ppu_vs_soc_curve
double get_current_rate_amps(double bat_capacity_Ah_1C);
const std::vector<Ppu_vs_soc_point>& get_points();

bool operator<(const Ppu_vs_soc_curve& rhs)
bool operator<(const Ppu_vs_soc_curve& rhs) const
{
return C_rate < rhs.C_rate;
}

bool operator<(Ppu_vs_soc_curve& rhs) const
{
return C_rate < rhs.C_rate;
}
Expand Down

0 comments on commit c63cc9c

Please sign in to comment.