Files
CACER-simulator/Fotovoltaico.py
2025-06-18 10:04:08 +02:00

48 lines
2.0 KiB
Python

from src.Functions_Energy_Model import *
from src.Functions_General import *
import subprocess
location_ita = 'Biella' # location in Italian
capacity = 100 # kWp
tilt_angle = 30 # degrees
azimuth = 0 # degrees
num_years = 1 # number of years to simulate
derating_factor_percent = 1 # derating factor that reduce the efficiency of the modules in percentage [%]
config = yaml.safe_load(open("config.yml", 'r'))
path_export = str(config['filename_output_csv_gen_pv']) # path to save the results
joe = config['joe_fight']
if(joe == True):
if shutil.which('wmplayer') is not None:
proc = subprocess.Popen(['ffplay', 'assets/joefight.mp4'])
else:
print("ffplay non installato, no joe fight.")
# INIZIALIZZAZIONE PARAMETRI PER SIMULAZIONE
location_eng = location_italian_to_english(location_ita)
path = "config.yml"
filename = ""
key = "project_lifetime_yrs"
value = num_years
add_to_file_yml(path, filename, key, value)
suppress_printing(generate_calendar) # generate the calendar for the location
coordinates_dataset = suppress_printing(create_coordinates_dataset, [location_eng]) # create a dataset with the coordinates of all the locations
derating_factor = derating_factor_percent / 100
# CALCOLO PRODUTTIVITA'
result_ac_energies_resampled = suppress_printing(simulate_1_kWp_generators, coordinates_dataset, tilt_angle, azimuth)
# SCALING PRODUTTIVITA'
result_ac_energies_gens = {} # initialization of the output dictionary
result_ac_energies_gens['gen_pv_' + str(capacity) + '_kWp'] = result_ac_energies_resampled[location_eng] * capacity
# DERATING PRODUTTIVITA'
result_ac_energies_gens_derated = suppress_printing(simulate_gens_derated_productivity, derating_factor, result_ac_energies_gens)
# GENERAZIONE DATAFRAME
result_ac_energies_to_csv_df = suppress_printing(simulate_unstacked_productivity, result_ac_energies_gens_derated) # create two unstacked dataframe (the other functions work with dictionaries)
# ESPORTAZIONE RISULTATI IN CSV
result_ac_energies_to_csv_df.to_csv(path_export, encoding='utf-8')
os.startfile(path_export)