Skip to content

Commit

Permalink
Merge pull request #22 from idaholab/develop
Browse files Browse the repository at this point in the history
ICM Cleanup
  • Loading branch information
manoj1511 authored Jul 18, 2024
2 parents 3e0d298 + cafb12b commit b7e96ed
Show file tree
Hide file tree
Showing 37 changed files with 1,397 additions and 425 deletions.
Binary file added docs/charging_model_process.pptx
Binary file not shown.
Binary file removed docs/new_interface.pptx
Binary file not shown.
1 change: 1 addition & 0 deletions source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.csv
38 changes: 30 additions & 8 deletions source/base/Aux_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ CP_interface::CP_interface(const std::string& input_path, bool save_validation_d
{
}

pev_charge_profile_library CP_interface::load_CP_library(const EV_EVSE_inventory& inventory, bool save_validation_data)
pev_charge_profile_library CP_interface::load_CP_library( const EV_EVSE_inventory& inventory,
const bool save_validation_data ) const
{
bool create_charge_profile_library = true;
factory_charge_profile_library CP_Factory{ inventory };
Expand All @@ -74,35 +75,49 @@ std::map< std::pair<EV_type, EVSE_type>, std::vector<charge_profile_validation_d
}


charge_event_P3kW_limits CP_interface::get_charge_event_P3kW_limits(EV_type pev_type, EVSE_type SE_type)
charge_event_P3kW_limits CP_interface::get_charge_event_P3kW_limits( const EV_type pev_type,
const EVSE_type SE_type )
{
pev_charge_profile* CP_ptr = this->CP_library.get_charge_profile(pev_type, SE_type);
return CP_ptr->get_charge_event_P3kW_limits();
}


std::vector<double> CP_interface::get_P3kW_setpoints_of_charge_profiles(EV_type pev_type, EVSE_type SE_type)
std::vector<double> CP_interface::get_P3kW_setpoints_of_charge_profiles( const EV_type pev_type,
const EVSE_type SE_type )
{
pev_charge_profile* CP_ptr = this->CP_library.get_charge_profile(pev_type, SE_type);
return CP_ptr->get_P3kW_setpoints_of_charge_profiles();
}


pev_charge_profile_result CP_interface::find_result_given_startSOC_and_endSOC(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, double endSOC)
pev_charge_profile_result CP_interface::find_result_given_startSOC_and_endSOC( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const double endSOC )
{
pev_charge_profile* CP_ptr = this->CP_library.get_charge_profile(pev_type, SE_type);
return CP_ptr->find_result_given_startSOC_and_endSOC(setpoint_P3kW, startSOC, endSOC);
}


pev_charge_profile_result CP_interface::find_result_given_startSOC_and_chargeTime(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, double charge_time_hrs)
pev_charge_profile_result CP_interface::find_result_given_startSOC_and_chargeTime( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const double charge_time_hrs )
{
pev_charge_profile* CP_ptr = this->CP_library.get_charge_profile(pev_type, SE_type);
return CP_ptr->find_result_given_startSOC_and_chargeTime(setpoint_P3kW, startSOC, charge_time_hrs);
}


std::vector<pev_charge_profile_result> CP_interface::find_chargeProfile_given_startSOC_and_endSOCs(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, std::vector<double> endSOC)
std::vector<pev_charge_profile_result> CP_interface::find_chargeProfile_given_startSOC_and_endSOCs( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const std::vector<double> endSOC )
{
pev_charge_profile* CP_ptr = this->CP_library.get_charge_profile(pev_type, SE_type);

Expand All @@ -113,7 +128,11 @@ std::vector<pev_charge_profile_result> CP_interface::find_chargeProfile_given_st
}


std::vector<pev_charge_profile_result> CP_interface::find_chargeProfile_given_startSOC_and_chargeTimes(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, std::vector<double> charge_time_hrs)
std::vector<pev_charge_profile_result> CP_interface::find_chargeProfile_given_startSOC_and_chargeTimes( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const std::vector<double> charge_time_hrs )
{
pev_charge_profile* CP_ptr = this->CP_library.get_charge_profile(pev_type, SE_type);

Expand All @@ -124,7 +143,10 @@ std::vector<pev_charge_profile_result> CP_interface::find_chargeProfile_given_st
}


std::vector<pev_charge_fragment> CP_interface::USE_FOR_DEBUG_PURPOSES_ONLY_get_raw_charge_profile(double time_step_sec, double target_acP3_kW, EV_type pev_type, EVSE_type SE_type)
std::vector<pev_charge_fragment> CP_interface::USE_FOR_DEBUG_PURPOSES_ONLY_get_raw_charge_profile( const double time_step_sec,
const double target_acP3_kW,
const EV_type pev_type,
const EVSE_type SE_type ) const
{
factory_charge_profile_library CP_Factory{this->inventory};
return CP_Factory.USE_FOR_DEBUG_PURPOSES_ONLY_get_raw_charge_profile(time_step_sec, target_acP3_kW, pev_type, SE_type);
Expand Down
41 changes: 33 additions & 8 deletions source/base/Aux_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,46 @@ class CP_interface
CP_interface(const std::string& input_path);
CP_interface(const std::string& input_path, bool save_validation_data);

pev_charge_profile_library load_CP_library(const EV_EVSE_inventory& inventory, bool save_validation_data);
pev_charge_profile_library load_CP_library( const EV_EVSE_inventory& inventory,
const bool save_validation_data ) const;

double get_size_of_CP_library_MB();
std::map< std::pair<EV_type, EVSE_type>, std::vector<charge_profile_validation_data> > get_CP_validation_data();

charge_event_P3kW_limits get_charge_event_P3kW_limits(EV_type pev_type, EVSE_type SE_type);
std::vector<double> get_P3kW_setpoints_of_charge_profiles(EV_type pev_type, EVSE_type SE_type);
charge_event_P3kW_limits get_charge_event_P3kW_limits( const EV_type pev_type,
const EVSE_type SE_type );

std::vector<double> get_P3kW_setpoints_of_charge_profiles( const EV_type pev_type,
const EVSE_type SE_type );

pev_charge_profile_result find_result_given_startSOC_and_endSOC(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, double endSOC);
pev_charge_profile_result find_result_given_startSOC_and_chargeTime(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, double charge_time_hrs);
pev_charge_profile_result find_result_given_startSOC_and_endSOC( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const double endSOC );

pev_charge_profile_result find_result_given_startSOC_and_chargeTime( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const double charge_time_hrs );

std::vector<pev_charge_profile_result> find_chargeProfile_given_startSOC_and_endSOCs(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, std::vector<double> endSOC);
std::vector<pev_charge_profile_result> find_chargeProfile_given_startSOC_and_chargeTimes(EV_type pev_type, EVSE_type SE_type, double setpoint_P3kW, double startSOC, std::vector<double> charge_time_hrs);
std::vector<pev_charge_profile_result> find_chargeProfile_given_startSOC_and_endSOCs( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const std::vector<double> endSOC );

std::vector<pev_charge_profile_result> find_chargeProfile_given_startSOC_and_chargeTimes( const EV_type pev_type,
const EVSE_type SE_type,
const double setpoint_P3kW,
const double startSOC,
const std::vector<double> charge_time_hrs );

std::vector<pev_charge_fragment> USE_FOR_DEBUG_PURPOSES_ONLY_get_raw_charge_profile(double time_step_sec, double target_acP3_kW, EV_type pev_type, EVSE_type SE_type);
std::vector<pev_charge_fragment> USE_FOR_DEBUG_PURPOSES_ONLY_get_raw_charge_profile( const double time_step_sec,
const double target_acP3_kW,
const EV_type pev_type,
const EVSE_type SE_type) const;
};


Expand Down
65 changes: 37 additions & 28 deletions source/base/ICM_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include <string>
#include <unordered_set>

interface_to_SE_groups::interface_to_SE_groups(const std::string& input_path,
const interface_to_SE_groups_inputs& inputs)
: loader{ input_path },
inventory{ this->loader.get_EV_EVSE_inventory() },
charge_profile_library{ load_charge_profile_library(inputs) }
interface_to_SE_groups::interface_to_SE_groups( const std::string& input_path,
const interface_to_SE_groups_inputs& inputs )
: loader{ input_path },
inventory{ this->loader.get_EV_EVSE_inventory() },
charge_profile_library{ load_charge_profile_library(inputs) }
{
EV_EVSE_ramping_map ramping_by_pevType_seType_map;
for (const pev_charge_ramping_workaround& X : inputs.ramping_by_pevType_seType)
Expand Down Expand Up @@ -85,7 +85,9 @@ interface_to_SE_groups::interface_to_SE_groups(const std::string& input_path,
//=========================================================================

for (supply_equipment* SE_ptr : this->SE_ptr_vector)
{
SE_ptr->set_ensure_pev_charge_needs_met_for_ext_control_strategy(inputs.ensure_pev_charge_needs_met);
}

}

Expand Down Expand Up @@ -116,7 +118,7 @@ void interface_to_SE_groups::stop_active_charge_events(std::vector<SE_id_type> S
try
{
for(SE_id_type x : SE_ids)
this->SEid_to_SE_ptr[x]->stop_active_CE();
this->SEid_to_SE_ptr.at(x)->stop_active_CE();
}
catch(...)
{
Expand All @@ -126,12 +128,14 @@ void interface_to_SE_groups::stop_active_charge_events(std::vector<SE_id_type> S
}


void interface_to_SE_groups::add_charge_events(std::vector<charge_event_data> charge_events)
void interface_to_SE_groups::add_charge_events( const std::vector<charge_event_data>& charge_events )
{
try
{
for(charge_event_data& X : charge_events)
this->SEid_to_SE_ptr[X.SE_id]->add_charge_event(X);
for( const charge_event_data& X : charge_events )
{
this->SEid_to_SE_ptr.at(X.SE_id)->add_charge_event(X);
}
}
catch(...)
{
Expand All @@ -141,23 +145,25 @@ void interface_to_SE_groups::add_charge_events(std::vector<charge_event_data> ch
}


void interface_to_SE_groups::add_charge_events_by_SE_group(std::vector<SE_group_charge_event_data> SE_group_charge_events)
void interface_to_SE_groups::add_charge_events_by_SE_group( const std::vector<SE_group_charge_event_data>& SE_group_charge_events )
{
for(SE_group_charge_event_data& CE_data : SE_group_charge_events)
for( const SE_group_charge_event_data& CE_data : SE_group_charge_events)
{
if(this->SE_group_Id_to_ptr.count(CE_data.SE_group_id) == 0)
if( this->SE_group_Id_to_ptr.count(CE_data.SE_group_id) == 0 )
{
// Throw and Error or something ???
std::cout << "Houston we have a problem! Location: interface_to_SE_groups::add_charge_events_by_SE_group" << std::endl;
}
else
{
std::vector<charge_event_data>& charge_events = CE_data.charge_events;
const std::vector<charge_event_data>& charge_events = CE_data.charge_events;

try
{
for(charge_event_data& X : charge_events)
this->SEid_to_SE_ptr[X.SE_id]->add_charge_event(X);
for( const charge_event_data& X : charge_events )
{
this->SEid_to_SE_ptr.at(X.SE_id)->add_charge_event(X);
}
}
catch(...)
{
Expand All @@ -184,7 +190,7 @@ void interface_to_SE_groups::set_PQ_setpoints(double now_unix_time, std::vector<
}
else
{
SE_ptr = this->SEid_to_SE_ptr[X.SE_id];
SE_ptr = this->SEid_to_SE_ptr.at(X.SE_id);
Z = SE_ptr->get_control_strategy_enums();

if(SE_ptr->pev_is_connected_to_SE(now_unix_time) == false)
Expand Down Expand Up @@ -265,7 +271,7 @@ std::vector<CE_FICE_in_SE_group> interface_to_SE_groups::get_FICE_by_SE_groups(s
}
else
{
this->SE_group_Id_to_ptr[group_id]->get_CE_FICE(inputs, X);
this->SE_group_Id_to_ptr.at(group_id)->get_CE_FICE(inputs, X);
Y.SE_group_id = group_id;
Y.SE_FICE_vals = X;
return_val.push_back(Y);
Expand All @@ -292,7 +298,7 @@ std::vector<CE_FICE> interface_to_SE_groups::get_FICE_by_SEids(std::vector<int>
}
else
{
this->SEid_to_SE_ptr[SE_id]->get_CE_FICE(inputs, pev_is_connected_to_SE, FICE_val);
this->SEid_to_SE_ptr.at(SE_id)->get_CE_FICE(inputs, pev_is_connected_to_SE, FICE_val);

if(pev_is_connected_to_SE)
return_val.push_back(FICE_val);
Expand Down Expand Up @@ -374,7 +380,7 @@ std::map<int, std::vector<active_CE> > interface_to_SE_groups::get_active_CEs_by
}
else
{
this->SE_group_Id_to_ptr[group_id]->get_active_CEs(X);
this->SE_group_Id_to_ptr.at(group_id)->get_active_CEs(X);
return_val[group_id] = X;
}
}
Expand All @@ -399,7 +405,7 @@ std::vector<active_CE> interface_to_SE_groups::get_active_CEs_by_SEids(std::vect
}
else
{
this->SEid_to_SE_ptr[SE_id]->get_active_CE(pev_is_connected_to_SE, active_CE_val);
this->SEid_to_SE_ptr.at(SE_id)->get_active_CE(pev_is_connected_to_SE, active_CE_val);

if(pev_is_connected_to_SE)
return_val.push_back(active_CE_val);
Expand All @@ -422,7 +428,7 @@ std::vector<double> interface_to_SE_groups::get_SE_charge_profile_forecast_akW(S
else
{
bool pev_is_connected_to_SE;
this->SEid_to_SE_ptr[SE_id]->get_active_charge_profile_forecast_akW(setpoint_P3kW, time_step_mins, pev_is_connected_to_SE, charge_profile);
this->SEid_to_SE_ptr.at(SE_id)->get_active_charge_profile_forecast_akW(setpoint_P3kW, time_step_mins, pev_is_connected_to_SE, charge_profile);
}

return charge_profile;
Expand All @@ -439,7 +445,7 @@ std::vector<double> interface_to_SE_groups::get_SE_group_charge_profile_forecast
std::cout << "Houston we have a problem! Location: interface_to_SE_groups::get_SE_group_charge_profile_forecast_akW" << std::endl;
}
else
this->SE_group_Id_to_ptr[SE_group]->get_SE_group_charge_profile_forecast_akW(setpoint_P3kW, time_step_mins, charge_profile);
this->SE_group_Id_to_ptr.at(SE_group)->get_SE_group_charge_profile_forecast_akW(setpoint_P3kW, time_step_mins, charge_profile);

return charge_profile;
}
Expand All @@ -460,7 +466,7 @@ std::map<grid_node_id_type, std::pair<double, double>> interface_to_SE_groups::g
{
it = this->gridNodeId_to_SE_ptrs.find(pu_Vrms_pair.first);

if(it == this->gridNodeId_to_SE_ptrs.end())
if( it == this->gridNodeId_to_SE_ptrs.end() )
{
// There is no SE on this grid node. Just put zeros in there.
P3_kW = 0;
Expand All @@ -471,10 +477,13 @@ std::map<grid_node_id_type, std::pair<double, double>> interface_to_SE_groups::g
}
else
{
// Access the object the iterator is pointing to.
const std::pair< grid_node_id_type, std::vector<supply_equipment*> >& gridnodeid_SEvec_pair = *it;

// Iterate over each supply_equipment pointer and sum up the power used by each during this timestep.
P3_kW = 0;
Q3_kVAR = 0;

for(supply_equipment* SE_ptr : it->second)
for( supply_equipment* SE_ptr : gridnodeid_SEvec_pair.second )
{
SE_ptr->get_next(prev_unix_time, now_unix_time, pu_Vrms_pair.second, soc, ac_power_tmp);

Expand Down Expand Up @@ -518,8 +527,8 @@ SE_power interface_to_SE_groups::get_SE_power(SE_id_type SE_id, double prev_unix
//CE_status charge_status;
ac_power_metrics ac_power;

//this->SEid_to_SE_ptr[SE_id]->get_current_CE_status(pev_is_connected_to_SE, SE_status_val, charge_status);
this->SEid_to_SE_ptr[SE_id]->get_next(prev_unix_time, now_unix_time, pu_Vrms, soc, ac_power);
//this->SEid_to_SE_ptr.at(SE_id)->get_current_CE_status(pev_is_connected_to_SE, SE_status_val, charge_status);
this->SEid_to_SE_ptr.at(SE_id)->get_next(prev_unix_time, now_unix_time, pu_Vrms, soc, ac_power);

return_val.time_step_duration_hrs = ac_power.time_step_duration_hrs;
return_val.P1_kW = ac_power.P1_kW;
Expand Down Expand Up @@ -571,7 +580,7 @@ void interface_to_SE_groups::ES500_set_energy_setpoints(ES500_aggregator_e_step_
}
else
{
this->SEid_to_SE_ptr[SE_id[i]]->ES500_set_energy_setpoints(e3_step_kWh[i]);
this->SEid_to_SE_ptr.at(SE_id.at(i))->ES500_set_energy_setpoints(e3_step_kWh[i]);
}
}
}
Expand Down
Loading

0 comments on commit b7e96ed

Please sign in to comment.