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
def LevelizedCostofElectricity(HM, number_of_turbines, lifetime, K, Q, B, M, g, emergency_maintentance, installation, operations, filename=None, power_array=None, num=500): ''' 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) if power_array is None: power_array, time_array = calculate_power( HM, MCT, 0, 0, lifetime * 24 * 3600 * 365.25, ) # everything else is in years, need to convert to seconds for int time_array = time_array / (24. * 3600. * 365.25) else: time_array = np.linspace(0, lifetime, len(power_array)) ### # 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 ### power_array *= .95 #to account for voltage drop across cable maintenance_costs = np.zeros(num) power_losses = np.zeros_like(maintenance_costs) #time to run the simulation for i in range(num): end_loop = False time_tracker = 0. power_loss = 0. maintenance_cost = 0. for turbine in range(number_of_turbines): while not end_loop: maintenance_event, uptime = maintenance.monteCarlo( emergency_maintentance) end_time = time_tracker + uptime maintenance_cost += maintenance_event.event_cost time_tracker += uptime + maintenance_event.downtime.total_seconds( ) / (24 * 3600 * 365.25) if end_time >= lifetime or time_tracker >= lifetime: break start_index = np.searchsorted(time_array, time_tracker) end_index = np.searchsorted(time_array, end_time) energy_2 = interpolate(time_tracker, time_array[start_index - 1], time_array[start_index], power_array[start_index - 1], power_array[start_index]) energy_1 = interpolate(end_time, time_array[end_index - 1], time_array[end_index], power_array[end_index - 1], power_array[end_index]) power_loss += energy_2 - energy_1 power_losses[i] = power_loss maintenance_costs[i] = maintenance_cost installation_cost = calculate_Installation(installation) planned_maintenance = .05 * installation_cost ops_cost = calculate_ops(operations, lifetime) # Process the final costs and return the levelized cost total_cost = np.mean( maintenance_costs) + installation_cost + ops_cost + planned_maintenance total_power = (power_array[-1] * number_of_turbines - np.mean(power_losses)) / 3600 #to kWhr!! with open(filename, 'w') as f: with redirect_stdout(f): print('Ideal power output = {} MWhr '.format(power_array[-1] / (1000 * 3600))) print('Estimated total power loss - {:.2f} MJ, sigma = {:.2f}'. format( np.mean(power_losses) / 1000, np.std(power_losses) / 1000)) print( 'Estimated total maintenance cost - $ {:.2f}, sigma = $ {:.2f}' .format(np.mean(maintenance_costs), np.std(maintenance_costs))) print('Estimated installation cost - $ {:.2f}'.format( installation_cost)) print('Estimated operations cost - $ {:.2f}'.format(ops_cost)) print('LCOE - {:.2f}'.format(total_cost / total_power)) return total_cost / total_power, power_array
yaxis=dict(title='Velocity (m/s)', titlefont=dict(size=20, color='white'), tickfont=dict(size=16, color='white')), paper_bgcolor='transparent', plot_bgcolor='transparent') fig = go.Figure(data=trace, layout=layout) py.iplot(fig, filename='currentHarmonicConstituent') # In[ ]: # ### Testing for the power output generation # In[ ]: MCT = Turbine(1200., 0.1835, 3.55361367, 2.30706792, 1.05659521) Sagamore = TidalStation(8447173) results, times = calculate_power(Sagamore, MCT, 0, 0, 365 * 24 * 3600, 9.8, 3) plt.plot(times / (24 * 3600), results / 1000) plt.xlim(0, 365) plt.ylabel('Energy (MJ)') plt.xlabel('Time (day)') plt.savefig('PowerOutput.png', format='png', transparent=True, bbox_inches='tight') # ### Build power curve model # In[ ]: