Code documentation

Main

Main functions of pvcompare that can be used to run a full simulation.

main.apply_mvs(scenario_name[, …])

Starts the energy system optimization with MVS and stores results.

main.apply_pvcompare(storeys[, country, …])

Runs the main functionalities of pvcompare.

Area potential

Function for calculating the area potential of the rooftop and facades for a given population.

area_potential.calculate_area_potential(…)

Calculates the area potential for PV installations.

Demand

Functions for calculating the electrical demand profiles and heat demand profiles.

demand.calculate_load_profiles(country, lat, …)

Calculates electricity and heat load profiles for country, storeys, and year.

demand.calculate_power_demand(country, …)

Calculates electricity demand profile for country, storeys, and year.

demand.calculate_heat_demand(country, lat, …)

Calculates heat demand profile for storeys, country, year.

demand.adjust_heat_demand(temperature, …)

Adjust the hourly heat demands exceeding the heating limit temperature.

demand.shift_working_hours(country, ts)

Shift the demand time series ts`depending `country.

demand.get_workalendar_class(country)

Loads workalender for a given country.

Feed-in time series of photovoltaic installations

Functions for calculating the feed-in time series of different PV technologies.

pv_feedin.create_pv_components(lat, lon, …)

Creates feed-in time series for all surface types in pv_setup or ‘pv_setup.csv’.

pv_feedin.create_si_time_series(lat, lon, …)

Calculates feed-in time series for a silicon PV module.

pv_feedin.create_cpv_time_series(lat, lon, …)

Creates power time series of a hybrid CPV module.

pv_feedin.create_psi_time_series(lat, lon, …)

Creates power time series of a perovskite-silicone (PSI) module.

pv_feedin.nominal_values_pv(technology, …)

calculates the maximum installed capacity for each pv module.

pv_feedin.get_peak(technology, …)

This function returns the peak value for the given technology.

pv_feedin.set_up_system(technology, …)

Sets up pvlibPVSystems.

pv_feedin.get_optimal_pv_angle(lat)

Calculates the optimal tilt angle depending on the latitude.

CPV time series

Specific functions for calculating the feed-in time series of the CPV technology.

cpv.apply_cpvlib_StaticHybridSystem.create_cpv_time_series(…)

Calculates time series for a CPV module.

cpv.apply_cpvlib_StaticHybridSystem.calculate_efficiency_ref()

Calculates maximum power output and efficiency for the CPV and flat plate module.

PSI time series

Specific functions for calculating the feed-in time series of the perovskite-silicon technology.

perosi.perosi.create_pero_si_timeseries(…)

Creates a time series for the output power of a pero-si module.

perosi.perosi.create_timeseries(lat, lon, …)

Calculates a timeseries for each cell type in list cell_type.

perosi.perosi.calculate_smarts_parameters(…)

calculates the short current density Jsc for each timestep.

perosi.pvlib_smarts.SMARTSSpectra(IOUT, …)

Function that runs the smartsAll function to get a standard spectrum

perosi.pvlib_smarts._smartsAll(CMNT, ISPR, …)

Parameter

Heat pumps and chillers

Functions for implementing a sector-coupled system (electricity, heat) and for calculating the COPs/EERs of heat pumps and chillers.

heat_pump_and_chiller.calculate_cops_and_eers(…)

Calculates the COPs of a heat pump or EERs of a chiller depending on mode.

heat_pump_and_chiller.add_sector_coupling(…)

Add heat sector if heat pump or chiller are in energyConversion.csv.

Stratified thermal storage

Functions for calculating thermal losses of a stratified thermal storage and for adding it to the energy system.

stratified_thermal_storage.calc_strat_tes_param(weather)

This function does the precalculations of the stratified thermal storage.

stratified_thermal_storage.save_time_dependent_values(…)

This function saves time dependent values to ‘data/mvs_inputs/time_series’.

stratified_thermal_storage.add_strat_tes(…)

Adds stratified thermal storage if it exists either in ‘energyStorage.csv’.

stratified_thermal_storage.run_stratified_thermal_storage()

This function executes calc_strat_tes_param(input_data) with self selected input data series

Reading and Writing input csv’s

Functions that match manual inputs and calculated results with data/user_inputs/mvs_inputs/csv_elements/

check_inputs.add_parameter_to_mvs_file(…)

Overwrites a value from a file in ‘mvs_inputs/csv_elements’ with a user input.

check_inputs.load_parameter_from_mvs_file(…)

Loads a value from a file in ‘mvs_inputs/csv_elements’.

check_inputs.add_parameters_to_storage_xx_file(…)

Enters new parameters into ‘storage_xx.csv’.

check_inputs.add_scenario_name_to_project_data(…)

Matches user input scenario_name with scenario_name in ‘project_data.csv’.

check_inputs.add_location_and_year_to_project_data(…)

Matches user input for year, latitude, longitude and country with mvs_inputs.

check_inputs.add_local_grid_parameters(…)

Adds grid parameters such as electricity price or feed-in tariff to ‘energyProviders.csv’.

check_inputs.check_for_valid_country_year(…)

Checks static input files for valid countries and years.

check_inputs.overwrite_mvs_energy_production_file(…)

Inserts default values for PV technologies defined in ‘pv_setup.csv’.

check_inputs.add_parameters_to_energy_production_file(…)

Enters new parameters into ‘energyProduction.csv’.

check_inputs.add_file_name_to_energy_consumption_file(…)

Enters demand time series file name to ‘energyProduction.csv’.

check_inputs.add_evaluated_period_to_simulation_settings(…)

Adds number of days of the time series into ‘simulation_settings.csv’.

Loading ERA5 weather data

Functions that request the weather data of one year and one location from the ERA5 weather data set

era5.load_era5_weatherdata(lat, lon, year)

Loads era5 weather data and converts it into format required by pvlib.

era5.get_era5_data_from_datespan_and_position(…)

Send request for era5 data to the Climate Data Store (CDS)

era5.format_pvcompare(ds)

Format dataset to dataframe as required by the pvlib’s ModelChain.

era5.weather_df_from_era5(…[, start, end])

Gets ERA5 weather data from netcdf file and converts it to a pandas dataframe as required by the spcified lib.

Sensitivity analysis

Functions sensivity analysis, i.e. running simulations in a loop while adjusting one parameter at each loop.

analysis.create_loop_output_structure(…)

Defines the path of the loop_output_directory.

analysis.loop_pvcompare(scenario_name, …)

Starts multiple pvcompare simulations with a range of values for a specific loop type.

analysis.single_loop_pvcompare(…)

param scenario_name

name of the scenario.

analysis.loop_mvs(latitude, longitude, …)

Starts multiple MVS simulations with a range of values for a specific parameter.

Evaluation

Function for the post-processing of KPIs. It is recommended to post-process certain KPIs when sector-coupling electricity and heat sector with a heat pump and/or chiller.

analysis.postprocessing_kpi(scenario_name, …)

Overwrites all output excel files “timeseries_all_flows.xlsx” and “scalars.xlsx” in loop output directory of a scenario with modified KPI’s.

Visualization

Plotting function for visualization of simulation results.

plots.plot_all_flows([scenario_name, …])

Plots all flows of the energy system for a given period of time.

plots.plot_psi_matrix(scenario_dict, …)

Plots two matrix subplots (LCOE and total costs) over a number of scenarios.

plots.plot_kpi_loop(variable_name, kpi, …)

Plots list of key performance indicators (KPIs) of a ‘mvs_output/scalars_**.xlsx’ file.

plots.plot_facades(variable_name, scenario_name)

Plots barplot for KPI’s from the ‘mvs_output/scalars_**.xlsx’ files in loop_outputs for all facades.

plots.plot_compare_scenarios(variable_name, …)

Comparison of scenarios for specific KPI’s.

plots.plot_compare_technologies(…[, …])

Comparison of different technologies at different locations for specific KPI’s.