Maintenance_Rate('Shaft', 0.002, 0.007, .001, 1014. * 24. * 1, 1014 * 24. * 4, 3500 * 24. * 5, 1., 3 * 40.), Maintenance_Rate('Brake', 0.0153, 0.0325, 0.0025, 1014. * 24. * 1, 1014 * 24. * 4, 3500 * 24. * 5, 1., 3 * 40.), Maintenance_Rate('Cable', 0.225, 0.09247, 0.000002, 1014. * 24. * 1, 1014 * 24. * 4, 3500 * 24. * 5, 1., 3 * 40.), Maintenance_Rate('Control system', 0.1, 0.1, 0.0001, 1014. * 24. * 1, 1014 * 24. * 4, 3500 * 24. * 5, 1., 3 * 40.) ] emergency_events = [ maintenance.EmergencyMaintenance(e.minimal_rate, e.midlevel_rate, e.severe_rate, e.minimal_cost, e.midlevel_cost, e.severe_cost, number=e.number, labor=e.labor, partname=e.partname) for e in emergency_maintenance ] runs = 200 costs = np.zeros(runs) tracking_average = np.zeros(runs) tracking_error = np.zeros(runs) upper_quartile = np.zeros(runs) lower_quartile = np.zeros(runs) for i in range(runs):
def LevelizedCostofElectricity(station_id, grid_location, cap_ex, lifetime, K, Q, B, M, g, h_0, gravity, emergency_maintentance, installation): ''' This function will calculated the levelized cost of electricity given the parameters for maintenance, power generation, installation and lifetime station_id will determine the location due to the necessity to use harmonic constituents for the calculations grid_location is where the connections will be made cap_ex are the capital expenditures for the cost of the turbine and fixtures this function was written with a sensitivity analysis in mind ''' MCT = Turbine(K, Q, B, M, g) tidal_station = TidalStation(station_id) emergency_events = [ maintenance.EmergencyMaintenance( e['minimal_rate'], e['midlevel_rate'], e['severe_rate'], e['minimal_cost'], e['midlevel_cost'], e['severe_cost'], e['minimal_downtime'], e['midlevel_downtime'], e['severe_downtime'], e['number'], e['labor'], e['partname']) for e in emergency_maintentance ] #installation_cost = installation.calculateInstallation() ### # The following code is used to run the monte carlo simulation with feedback to the power generation functions # where the downtime requires the turbine to no longer generate an output ### time = [] results = [] end_loop = False time_tracker = 0. maintenance_costs = [] maintenance_times = [] #time to run the simulation while not end_loop: maintenance_event, uptime = monteCarlo(emergency_events) if time_tracker + uptime > lifetime: end_loop = True uptime = lifetime - time_tracker end_time = time_tracker + uptime results_array, time_array = calculate_power(tidal_station, MCT, results[-1][-1], time_tracker, end_time, gravity, h_0) maintenance_costs.append(maintenance_event.event_cost) maintenance_times.append(time_tracker + uptime) time_tracker += uptime + maintenance_event.downtime results.append(results_array) time.append(time_array) powerGen = np.concatenate(results) times = np.concatenate(time) # Process the final costs and return the levelized cost total_cost = maintenance_costs[-1] + installation_cost total_power = powerGen[-1] return total_cost / total_power