def setUpClass(self): self.plugin_event1 = acnsim.PluginEvent( 10, acnsim.EV(10, 20, 30, "PS-001", "EV-001", acnsim.Battery(100, 50, 20))) self.plugin_event2 = acnsim.PluginEvent( 20, acnsim.EV(20, 30, 40, "PS-002", "EV-002", acnsim.Battery(100, 50, 20))) self.evse1 = acnsim.EVSE("PS-001", max_rate=32, min_rate=0) self.evse2 = acnsim.EVSE("PS-002", max_rate=32, min_rate=0) self.event_queue = acnsim.EventQueue() self.event_queue.add_events([self.plugin_event1, self.plugin_event2]) self.network = acnsim.ChargingNetwork() self.network.register_evse(self.evse1, 220, 30) self.network.register_evse(self.evse2, 220, 30) # Simulator with scheduler that always returns an empty # schedule. self.simulator = acnsim.Simulator( self.network, EmptyScheduler(), self.event_queue, datetime(2019, 1, 1), verbose=False, ) self.simulator.run()
def setUpClass(cls) -> None: timezone = pytz.timezone("America/Los_Angeles") start = timezone.localize(datetime(2018, 9, 1)) period = 5 # minute voltage = 208 # volts cn = acnsim.ChargingNetwork() cn.register_evse(acnsim.get_evse_by_type("PS-1", "BASIC"), voltage, 0) cn.add_constraint(acnsim.Current("PS-1"), 100) batt = acnsim.Battery(100, 0, 7) ev = acnsim.EV(5, 5 + 12, voltage * 32 / 1000, "PS-1", "test", batt) events = acnsim.EventQueue([acnsim.PluginEvent(ev.arrival, ev)]) quick_charge_obj = [ ObjectiveComponent(quick_charge), ObjectiveComponent(equal_share, 1e-12), ] cls.alg = AdaptiveChargingAlgorithmOffline(quick_charge_obj, solver=cp.ECOS) cls.alg.register_events(events) cls.sim = acnsim.Simulator( cn, cls.alg, events, start, period=period, verbose=False ) cls.alg.solve() cls.sim.run()
def setUpClass(cls): cls.battery = acnsim.Battery(100, 50, 20)
def setUpClass(cls): # Make instance of each class in registry. # Battery cls.battery1 = acnsim.Battery(100, 50, 20) cls.battery1._current_charging_power = 10 # Linear2StageBattery cls.battery2 = acnsim.Linear2StageBattery(100, 50, 20) cls.battery2._current_charging_power = 10 cls.battery2._noise_level = 0.1 cls.battery2._transition_soc = 0.85 # EVs staying_time = 10 ev1_arrival = 10 cls.ev1 = acnsim.EV( ev1_arrival, ev1_arrival + staying_time, 30, "PS-001", "EV-001", deepcopy(cls.battery1), estimated_departure=35, ) cls.ev1._energy_delivered = 0.05 cls.ev1._current_charging_rate = 10 ev2_arrival = 40 cls.ev2 = acnsim.EV( ev2_arrival, ev2_arrival + staying_time, 30, "PS-002", "EV-002", deepcopy(cls.battery2), estimated_departure=65, ) cls.ev2._energy_delivered = 0.05 cls.ev2._current_charging_rate = 10 ev3_arrival = 50 cls.ev3 = acnsim.EV( ev3_arrival, ev3_arrival + staying_time, 30, "PS-003", "EV-003", deepcopy(cls.battery2), estimated_departure=75, ) cls.ev3._energy_delivered = 0.05 cls.ev3._current_charging_rate = 10 # EVSEs cls.evse0 = acnsim.EVSE("PS-000", max_rate=32) cls.evse1 = acnsim.EVSE("PS-001", max_rate=32) cls.evse1.plugin(cls.ev1) cls.evse1.set_pilot(30, 220, 1) cls.evse2 = acnsim.DeadbandEVSE("PS-002", max_rate=32, deadband_end=4) cls.evse2.plugin(cls.ev2) cls.evse2.set_pilot(30, 220, 1) cls.evse3 = acnsim.FiniteRatesEVSE("PS-003", allowable_rates=[0, 8, 16, 24, 32]) cls.evse3.plugin(cls.ev3) cls.evse3.set_pilot(24, 220, 1) # Events cls.event = acnsim.Event(0) cls.plugin_event1 = acnsim.PluginEvent(10, cls.ev1) cls.unplug_event = acnsim.UnplugEvent(20, cls.ev1) cls.recompute_event1 = acnsim.RecomputeEvent(30) cls.plugin_event2 = acnsim.PluginEvent(40, cls.ev2) cls.plugin_event3 = acnsim.PluginEvent(50, cls.ev3) # Modify a default attribute to check if it's loaded correctly. cls.recompute_event2 = acnsim.RecomputeEvent(10) cls.recompute_event2.event_type = "Recompute Modified" # EventQueue cls.event_queue = acnsim.EventQueue() cls.event_queue.add_events([ cls.event, cls.plugin_event1, cls.recompute_event1, cls.plugin_event2, cls.plugin_event3, ]) # Network cls.network = acnsim.ChargingNetwork(violation_tolerance=1e-3, relative_tolerance=1e-5) cls.network.register_evse(cls.evse1, 220, 30) cls.network.register_evse(cls.evse2, 220, 150) cls.network.register_evse(cls.evse3, 220, -90) cls.network.constraint_matrix = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) cls.network.magnitudes = np.array([32, 32, 32]) cls.network.constraint_index = ["C1", "C2", "C3"] _ = cls.network._update_info_store() cls.empty_network = acnsim.ChargingNetwork() # Simulator cls.simulator = acnsim.Simulator( cls.network, UncontrolledCharging(), cls.event_queue, datetime(2019, 1, 1), verbose=False, store_schedule_history=True, ) # Make a copy of the simulator to run cls.simulator_run = deepcopy(cls.simulator) # Do necessary unplugs. for evse in cls.simulator_run.network._EVSEs.values(): if evse.ev is not None: evse.unplug() # Run simulation cls.simulator_run.run() # Make a copy of the simulator with signals cls.simulator_signal = deepcopy(cls.simulator) cls.simulator_signal.signals = {"a": [0, 1, 2], "b": [3, 4]} cls.simulator_hard_signal = deepcopy(cls.simulator) cls.simulator_hard_signal.signals = {"a": BaseAlgorithm()} cls.simulator_no_sch_hist = deepcopy(cls.simulator) cls.simulator_no_sch_hist.schedule_history = None # Class data used for testing. cls.simple_attributes = { "Battery": [ "_max_power", "_current_charging_power", "_current_charge", "_capacity", "_init_charge", ], "Linear2StageBattery": [ "_max_power", "_current_charging_power", "_current_charge", "_capacity", "_init_charge", "_noise_level", "_transition_soc", ], "EV": [ "_arrival", "_departure", "_requested_energy", "_estimated_departure", "_session_id", "_station_id", "_energy_delivered", "_current_charging_rate", ], "EVSE": [ "_station_id", "_max_rate", "_min_rate", "_current_pilot", "is_continuous", ], "DeadbandEVSE": [ "_station_id", "_max_rate", "_current_pilot", "_deadband_end", "is_continuous", ], "FiniteRatesEVSE": [ "_station_id", "_current_pilot", "is_continuous", "allowable_rates", ], "Event": ["timestamp", "event_type", "precedence"], "PluginEvent": ["timestamp", "event_type", "precedence"], "UnplugEvent": ["timestamp", "event_type", "precedence"], "RecomputeEvent": ["timestamp", "event_type", "precedence"], "EventQueue": ["_timestep"], "ChargingNetwork": [ "constraint_index", "violation_tolerance", "relative_tolerance", "_station_ids_dict", ], "Simulator": [ "period", "max_recompute", "verbose", "peak", "_iteration", "_resolve", "_last_schedule_update", "schedule_history", ], }
def setUpClass(cls): # Make instance of each class in registry. # Battery cls.battery1 = acnsim.Battery(100, 50, 20) cls.battery1._current_charging_power = 10 # Linear2StageBattery cls.battery2 = acnsim.Linear2StageBattery(100, 50, 20) cls.battery2._current_charging_power = 10 cls.battery2._noise_level = 0.1 cls.battery2._transition_soc = 0.85 # EVs staying_time = 10 ev1_arrival = 10 cls.ev1 = acnsim.EV(ev1_arrival, ev1_arrival + staying_time, 30, 'PS-001', 'EV-001', deepcopy(cls.battery1), estimated_departure=25) cls.ev1._energy_delivered = 0.05 cls.ev1._current_charging_rate = 10 ev2_arrival = 40 cls.ev2 = acnsim.EV(ev2_arrival, ev2_arrival + staying_time, 30, 'PS-002', 'EV-002', deepcopy(cls.battery2), estimated_departure=25) cls.ev2._energy_delivered = 0.05 cls.ev2._current_charging_rate = 10 ev3_arrival = 50 cls.ev3 = acnsim.EV(ev3_arrival, ev3_arrival + staying_time, 30, 'PS-003', 'EV-003', deepcopy(cls.battery2), estimated_departure=25) cls.ev3._energy_delivered = 0.05 cls.ev3._current_charging_rate = 10 # EVSEs cls.evse0 = acnsim.EVSE('PS-000', max_rate=32) cls.evse1 = acnsim.EVSE('PS-001', max_rate=32) cls.evse1.plugin(cls.ev1) cls.evse1.set_pilot(30, 220, 1) cls.evse2 = acnsim.DeadbandEVSE('PS-002', max_rate=32, deadband_end=4) cls.evse2.plugin(cls.ev2) cls.evse2.set_pilot(30, 220, 1) cls.evse3 = acnsim.FiniteRatesEVSE('PS-003', allowable_rates=[0, 8, 16, 24, 32]) cls.evse3.plugin(cls.ev3) cls.evse3.set_pilot(24, 220, 1) # Events cls.event = acnsim.Event(0) cls.plugin_event1 = acnsim.PluginEvent(10, cls.ev1) cls.unplug_event = acnsim.UnplugEvent(20, 'PS-001', 'EV-001') cls.recompute_event1 = acnsim.RecomputeEvent(30) cls.plugin_event2 = acnsim.PluginEvent(40, cls.ev2) cls.plugin_event3 = acnsim.PluginEvent(50, cls.ev3) # Modify a default attribute to check if it's loaded correctly. cls.recompute_event2 = acnsim.RecomputeEvent(10) cls.recompute_event2.event_type = 'Recompute Modified' # EventQueue cls.event_queue = acnsim.EventQueue() cls.event_queue.add_events([ cls.event, cls.plugin_event1, cls.recompute_event1, cls.plugin_event2, cls.plugin_event3 ]) # Network cls.network = acnsim.ChargingNetwork(violation_tolerance=1e-3, relative_tolerance=1e-5) cls.network.register_evse(cls.evse1, 220, 30) cls.network.register_evse(cls.evse2, 220, 150) cls.network.register_evse(cls.evse3, 220, -90) cls.network.constraint_matrix = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) cls.network.magnitudes = np.array([32, 32, 32]) cls.network.constraint_index = ['C1', 'C2', 'C3'] cls.empty_network = acnsim.ChargingNetwork() # Simulator cls.simulator = acnsim.Simulator(cls.network, UncontrolledCharging(), cls.event_queue, datetime(2019, 1, 1), verbose=False, store_schedule_history=True) # Make a copy of the simulator to run cls.simulator_run = deepcopy(cls.simulator) # Do necessary unplugs. for evse in cls.simulator_run.network._EVSEs.values(): if evse.ev is not None: evse.unplug() # Run simulation cls.simulator_run.run() # Make a copy of the simulator with signals cls.simulator_signal = deepcopy(cls.simulator) cls.simulator_signal.signals = {'a': [0, 1, 2], 'b': [3, 4]} cls.simulator_hard_signal = deepcopy(cls.simulator) cls.simulator_hard_signal.signals = {'a': BaseAlgorithm()} cls.simulator_no_sch_hist = deepcopy(cls.simulator) cls.simulator_no_sch_hist.schedule_history = None # Class data used for testing. cls.simple_attributes = { 'Battery': [ '_max_power', '_current_charging_power', '_current_charge', '_capacity', '_init_charge' ], 'Linear2StageBattery': [ '_max_power', '_current_charging_power', '_current_charge', '_capacity', '_init_charge', '_noise_level', '_transition_soc' ], 'EV': [ '_arrival', '_departure', '_requested_energy', '_estimated_departure', '_session_id', '_station_id', '_energy_delivered', '_current_charging_rate' ], 'EVSE': [ '_station_id', '_max_rate', '_min_rate', '_current_pilot', 'is_continuous' ], 'DeadbandEVSE': [ '_station_id', '_max_rate', '_current_pilot', '_deadband_end', 'is_continuous' ], 'FiniteRatesEVSE': [ '_station_id', '_current_pilot', 'is_continuous', 'allowable_rates' ], 'Event': ['timestamp', 'event_type', 'precedence'], 'PluginEvent': ['timestamp', 'event_type', 'precedence'], 'UnplugEvent': [ 'timestamp', 'event_type', 'precedence', 'station_id', 'session_id' ], 'RecomputeEvent': ['timestamp', 'event_type', 'precedence'], 'EventQueue': ['_timestep'], 'ChargingNetwork': ['constraint_index', 'violation_tolerance', 'relative_tolerance'], 'Simulator': [ 'period', 'max_recompute', 'verbose', 'peak', '_iteration', '_resolve', '_last_schedule_update', 'schedule_history' ] }