diff --git a/examples/heat_pump/heat_pump.py b/examples/heat_pump/heat_pump.py new file mode 100644 index 00000000..ca9e36e7 --- /dev/null +++ b/examples/heat_pump/heat_pump.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +""" +author: pyosch +""" +import pandas as pd +import numpy as np +import oemof.thermal.heat_pump as heat_pump + + +# generate test data +temperature = pd.DataFrame(np.random.randint(-10, 20, size=(96, 1)), + columns=["temperature"], + index=pd.date_range(start='2017', periods=96, + freq='15 min', name='index')) + +print(temperature.head()) + +# cop calculation for heat pumps +cop = heat_pump.get_cop(temperature.temperature) + +print(cop.head()) diff --git a/oemof_heat_components/heat_pump/heat_pump.py b/oemof_heat_components/heat_pump/heat_pump.py deleted file mode 100644 index e69de29b..00000000 diff --git a/oemof_heat_components/solar_thermal_collectors.py b/oemof_heat_components/solar_thermal_collectors.py deleted file mode 100644 index 4ad4d9dc..00000000 --- a/oemof_heat_components/solar_thermal_collectors.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Solar thermal collectors - -authors: - -SPDX-License-Identifier: GPL-3.0-or-later -""" - -from oemof import solph - -my_bus = solph.Bus(label='my_bus') diff --git a/oemof_heat_components/variable_chp/__init__.py b/oemof_heat_components/variable_chp/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/oemof_heat_components/variable_chp/variable_chp.csv b/oemof_heat_components/variable_chp/variable_chp.csv deleted file mode 100644 index 55952149..00000000 --- a/oemof_heat_components/variable_chp/variable_chp.csv +++ /dev/null @@ -1,193 +0,0 @@ -timestep,demand_el,demand_th -3001,219326.3596653,0.1727238027 -3002,216566.3764352,0.1878310716 -3003,217332.5256261,0.1804246049 -3004,224057.1001518,0.1981005066 -3005,235780.105845,0.2678339407 -3006,265447.6178909,0.3986349305 -3007,292641.298814,0.4266527212 -3008,308153.512253,0.4065678067 -3009,313124.2512812,0.3898818859 -3010,320001.1325737,0.3657894985 -3011,326901.0906491,0.3492507454 -3012,326762.6299519,0.3378068049 -3013,323808.8017457,0.3317344638 -3014,317698.0696442,0.3280835878 -3015,312330.4099508,0.3303205282 -3016,302315.0861892,0.3414078718 -3017,301364.3227354,0.3597969674 -3018,300607.4042575,0.3795626418 -3019,298387.4177463,0.393969169 -3020,289147.4738889,0.402659952 -3021,281107.5227402,0.3951436745 -3022,263864.5505866,0.3557170404 -3023,241936.9915123,0.289906173 -3024,227652.4629215,0.2154520719 -3025,221458.6544017,0.176145504 -3026,218117.1362434,0.1915453098 -3027,219409.4360836,0.1840098428 -3028,223674.0255563,0.2020476605 -3029,231783.2070536,0.2731709261 -3030,257490.7431605,0.40657481 -3031,285409.0350654,0.4352439372 -3032,299430.4883316,0.4147384562 -3033,303053.5432408,0.3976907726 -3034,308656.5861194,0.373107622 -3035,311158.1093815,0.3562243743 -3036,306293.5235544,0.3445497148 -3037,296088.9701734,0.3383569053 -3038,287615.1755069,0.3346376719 -3039,283198.2792674,0.3369290734 -3040,278015.2338368,0.3482452967 -3041,278112.1563248,0.3669999869 -3042,276441.3972457,0.3871647703 -3043,273487.5690395,0.4018536166 -3044,266287.612787,0.4107080896 -3045,262281.4832824,0.4030259254 -3046,250120.0187147,0.3627933587 -3047,229637.0662475,0.2956128913 -3048,213363.3189741,0.2196950837 -3049,205318.7524688,0.189264 -3050,200329.5520143,0.2057833745 -3051,201723.3896991,0.197758568 -3052,204104.9136904,0.2171874117 -3053,203624.9166069,0.2936416466 -3054,204954.1392996,0.4370282483 -3055,214341.7745674,0.4682229911 -3056,228123.2292918,0.4460983954 -3057,238470.8587266,0.4276545248 -3058,242924.6778187,0.4011858477 -3059,250281.5561948,0.3829768579 -3060,246561.5787976,0.3704164574 -3061,236490.8707572,0.3637617314 -3062,225035.5557451,0.359781594 -3063,221906.3439892,0.3622847923 -3064,220161.7392049,0.3744812489 -3065,223701.7176957,0.3946379804 -3066,227537.0790072,0.4163351416 -3067,228423.227469,0.4321054648 -3068,224597.0968707,0.4415850059 -3069,227200.1579774,0.4332618281 -3070,222797.1078076,0.3899320372 -3071,206874.1276336,0.3174811853 -3072,194671.1248569,0.2359549812 -3073,184235.8036472,0.1909107542 -3074,181826.5875166,0.2075704456 -3075,180691.2097998,0.1994847952 -3076,182620.428847,0.2190886395 -3077,182643.5056298,0.2962123426 -3078,176200.4678551,0.4408524512 -3079,179560.4474396,0.4723673973 -3080,193563.4392796,0.45003881 -3081,201778.773978,0.4314186515 -3082,208461.8102945,0.4047128425 -3083,216903.2974649,0.3863368793 -3084,212500.2472951,0.3736651606 -3085,201921.8500317,0.3669524449 -3086,195100.3530181,0.3629396868 -3087,191518.8363181,0.3654698053 -3088,191758.8348598,0.3777770604 -3089,200108.0148989,0.3981098319 -3090,212043.3269945,0.4199995992 -3091,216566.3764352,0.4359055781 -3092,218878.6700778,0.4454633049 -3093,225815.5510058,0.4370591029 -3094,224906.3257611,0.3933397023 -3095,207095.6647491,0.3202250984 -3096,196572.6517646,0.2379952465 -3097,192483.4458417,0.1751658076 -3098,191449.6059695,0.1904818768 -3099,193900.3603093,0.1829832869 -3100,202734.1527884,0.2009174429 -3101,214461.7738383,0.2716427465 -3102,247498.4961817,0.4043013353 -3103,276778.3182755,0.4327836573 -3104,293264.3719512,0.4123986666 -3105,297427.4235793,0.3954546647 -3106,302795.0832727,0.3710120728 -3107,307982.7440598,0.3542275156 -3108,307996.5901295,0.3426189283 -3109,304858.1476605,0.3364606117 -3110,294759.7474806,0.3327609373 -3111,288972.0903391,0.3350367124 -3112,280465.9881766,0.3462873729 -3113,281167.5223756,0.3649373823 -3114,284273.6573487,0.3849878687 -3115,283825.9677612,0.3995958919 -3116,274059.8732545,0.4084035252 -3117,270127.589455,0.4007689131 -3118,255335.3716413,0.3607671813 -3119,232604.7405234,0.2939790715 -3120,217849.4455622,0.2184803133 -3121,210446.4136205,0.1216880281 -3122,207455.6625617,0.118857931 -3123,209034.1145094,0.115470415 -3124,216510.9921563,0.1284898265 -3125,227246.3115431,0.1949240462 -3126,254352.3006914,0.3111847349 -3127,279141.3808404,0.3627909661 -3128,290185.9291176,0.3288837741 -3129,292142.8403042,0.3061464629 -3130,296250.5076534,0.2833839939 -3131,300533.5585524,0.2663462221 -3132,294307.4425365,0.2523876379 -3133,290421.3123028,0.2458779321 -3134,286059.8003421,0.2379917189 -3135,287130.5630668,0.2308690131 -3136,283004.4342913,0.2349859566 -3137,285353.6507866,0.2437342604 -3138,288381.3246979,0.2587521015 -3139,288464.4011162,0.2797348083 -3140,280447.5267504,0.2985990013 -3141,276422.9358194,0.3021621826 -3142,263799.9355946,0.2834432318 -3143,239744.6971405,0.2231101978 -3144,222210.9575229,0.1586869867 -3145,217581.754881,0.1041164911 -3146,214014.0842508,0.1016558883 -3147,216317.1471803,0.0987045341 -3148,222746.3388853,0.1097822534 -3149,230412.4461516,0.1665093554 -3150,259115.3486739,0.2655809059 -3151,287661.3290726,0.3094147232 -3152,300556.6353352,0.2803784964 -3153,301945.8576634,0.2611607205 -3154,305342.7601005,0.2417781347 -3155,310590.4205231,0.2273270231 -3156,306030.4482298,0.2154565713 -3157,303422.7717665,0.2099177116 -3158,297122.8100455,0.2031948874 -3159,293605.9083376,0.1970760257 -3160,286059.8003421,0.2005455145 -3161,283309.0478251,0.2079683977 -3162,283692.1224206,0.2207311016 -3163,281347.5212819,0.2386243187 -3164,273764.4904339,0.2547330317 -3165,268922.9813897,0.257873156 -3166,252404.6202179,0.2420287723 -3167,226503.239135,0.1907754948 -3168,206269.5159227,0.1358157824 -3169,195663.4265199,0.0856907647 -3170,189460.3872869,0.0836292494 -3171,191311.1452723,0.0811509961 -3172,194920.3541118,0.0902109601 -3173,190000.3840059,0.1367929551 -3174,180335.8273438,0.2179589412 -3175,184489.6482587,0.2537377094 -3176,197352.6470253,0.2298167116 -3177,211424.8692138,0.2142193866 -3178,220849.4273341,0.1983533623 -3179,231049.3653586,0.1865771063 -3180,228737.0717159,0.1768747538 -3181,220618.6595055,0.1723447719 -3182,213589.4714461,0.166834576 -3183,209675.6490729,0.1617756812 -3184,208697.1934796,0.1645819733 -3185,213321.7807649,0.1706334702 -3186,218975.5925658,0.1810571239 -3187,219963.2788723,0.1957283711 -3188,218758.6708069,0.208957016 -3189,221246.3479993,0.2116263567 -3190,218814.0550858,0.1987453238 -3191,202244.9249918,0.1569039713 -3192,191648.0663021,0.1118200156 diff --git a/oemof_heat_components/variable_chp/variable_chp.py b/oemof_heat_components/variable_chp/variable_chp.py deleted file mode 100644 index 2534e143..00000000 --- a/oemof_heat_components/variable_chp/variable_chp.py +++ /dev/null @@ -1,363 +0,0 @@ -# -*- coding: utf-8 -*- -""" -General description -------------------- -This example is not a real use case of an energy system but an example to show -how a combined heat and power plant (chp) with an extraction turbine works in -contrast to a chp (eg. block device) with a fixed heat fraction. Both chp plants -distribute power and heat to a separate heat and power Bus with a heat and power -demand. The i/o balance plot shows that the fixed chp plant produces heat and -power excess and therefore needs more natural gas. The bar plot just shows the -difference in the usage of natural gas. - -Requirements ------------- -pip install "oemof>=0.2,<0.3" -pip install matplotlib (to see the bar plot) -pip install git+https://github.com/oemof/oemof_visio.git (to see the i/o balance - plot) - -Installation requirements -------------------------- -This example requires the latest version of oemof and matplotlib. Install by: - - pip install oemof - pip install oemof - -""" - -__copyright__ = "oemof developer group" -__license__ = "GPLv3" - -############################################################################### -# imports -############################################################################### - -# Outputlib -from oemof import outputlib - -# Default logger of oemof -from oemof.tools import logger -from oemof.tools import helpers -import oemof.solph as solph - -# import oemof base classes to create energy system objects -import logging -import os -import pandas as pd -import matplotlib.pyplot as plt - -# import oemof plots -try: - from oemof_visio import plot as oeplot -except ImportError: - oeplot = None - - -def shape_legend(node, reverse=True, **kwargs): - handels = kwargs['handles'] - labels = kwargs['labels'] - axes = kwargs['ax'] - parameter = {} - - new_labels = [] - for label in labels: - label = label.replace('(', '') - label = label.replace('), flow)', '') - label = label.replace(node, '') - label = label.replace(',', '') - label = label.replace(' ', '') - new_labels.append(label) - labels = new_labels - - parameter['bbox_to_anchor'] = kwargs.get('bbox_to_anchor', (1, 0.5)) - parameter['loc'] = kwargs.get('loc', 'center left') - parameter['ncol'] = kwargs.get('ncol', 1) - plotshare = kwargs.get('plotshare', 0.9) - - if reverse: - handels.reverse() - labels.reverse() - - box = axes.get_position() - axes.set_position([box.x0, box.y0, box.width * plotshare, box.height]) - - parameter['handles'] = handels - parameter['labels'] = labels - axes.legend(**parameter) - return axes - - -def write_lp_file(): - filename = os.path.join( - helpers.extend_basic_path('lp_files'), 'variable_chp.lp') - logging.info('Store lp-file in {0}.'.format(filename)) - om.write(filename, io_options={'symbolic_solver_labels': True}) - - -logger.define_logging() -logging.info('Initialize the energy system') - -# create time index for 192 hours in May. -date_time_index = pd.date_range('5/5/2012', periods=192, freq='H') - -energysystem = solph.EnergySystem(timeindex=date_time_index) - -# Read data file with heat and electrical demand (192 hours) -full_filename = os.path.join(os.path.dirname(__file__), 'variable_chp.csv') -data = pd.read_csv(full_filename, sep=",") - -########################################################################## -# Create oemof.solph objects -########################################################################## -logging.info('Create oemof.solph objects') - -# container for instantiated nodes -noded = {} - -# create natural gas bus -noded['bgas'] = solph.Bus(label="natural_gas") - -# create commodity object for gas resource -noded['rgas'] = solph.Source( - label='rgas', outputs={noded['bgas']: solph.Flow(variable_costs=50)}) - -# create two electricity buses and two heat buses -noded['bel'] = solph.Bus(label="electricity") -noded['bel2'] = solph.Bus(label="electricity_2") -noded['bth'] = solph.Bus(label="heat") -noded['bth2'] = solph.Bus(label="heat_2") - -# create excess components for the elec/heat bus to allow overproduction -noded['excess_bth_2'] = solph.Sink( - label='excess_bth_2', inputs={noded['bth2']: solph.Flow()}) -noded['excess_therm'] = solph.Sink( - label='excess_therm', inputs={noded['bth']: solph.Flow()}) -noded['excess_bel_2'] = solph.Sink( - label='excess_bel_2', inputs={noded['bel2']: solph.Flow()}) -noded['excess_elec'] = solph.Sink( - label='excess_elec', inputs={noded['bel']: solph.Flow()}) - -# create simple sink object for electrical demand for each electrical bus -noded['demand_elec'] = solph.Sink( - label='demand_elec', inputs={noded['bel']: solph.Flow( - actual_value=data['demand_el'], fixed=True, nominal_value=1)}) -noded['demand_el_2'] = solph.Sink( - label='demand_el_2', inputs={noded['bel2']: solph.Flow( - actual_value=data['demand_el'], fixed=True, nominal_value=1)}) - -# create simple sink object for heat demand for each thermal bus -noded['demand_therm'] = solph.Sink( - label='demand_therm', inputs={noded['bth']: solph.Flow( - actual_value=data['demand_th'], fixed=True, nominal_value=741000)}) -noded['demand_therm_2'] = solph.Sink( - label='demand_th_2', inputs={noded['bth2']: solph.Flow( - actual_value=data['demand_th'], fixed=True, nominal_value=741000)}) - -# This is just a dummy transformer with a nominal input of zero -noded['fixed_chp_gas'] = solph.Transformer( - label='fixed_chp_gas', - inputs={noded['bgas']: solph.Flow(nominal_value=0)}, - outputs={noded['bel']: solph.Flow(), noded['bth']: solph.Flow()}, - conversion_factors={noded['bel']: 0.3, noded['bth']: 0.5}) - -# create a fixed transformer to distribute to the heat_2 and elec_2 buses -noded['fixed_chp_gas_2'] = solph.Transformer( - label='fixed_chp_gas_2', - inputs={noded['bgas']: solph.Flow(nominal_value=10e10)}, - outputs={noded['bel2']: solph.Flow(), noded['bth2']: solph.Flow()}, - conversion_factors={noded['bel2']: 0.3, noded['bth2']: 0.5}) - -# create a fixed transformer to distribute to the heat and elec buses -noded['variable_chp_gas'] = solph.components.ExtractionTurbineCHP( - label='variable_chp_gas', - inputs={noded['bgas']: solph.Flow(nominal_value=10e10)}, - outputs={noded['bel']: solph.Flow(), noded['bth']: solph.Flow()}, - conversion_factors={noded['bel']: 0.3, noded['bth']: 0.5}, - conversion_factor_full_condensation={noded['bel']: 0.5} - ) - -########################################################################## -# Optimise the energy system -########################################################################## - -logging.info('Optimise the energy system') - -energysystem.add(*noded.values()) - -om = solph.Model(energysystem) - -# If uncomment the following line you can store the lp file but you should use -# less timesteps (3) to make it better readable and smaller. -# write_lp_file() - -logging.info('Solve the optimization problem') -om.solve(solver='cbc', solve_kwargs={'tee': False}) - -results = outputlib.processing.results(om) - -########################################################################## -# Plot the results -########################################################################## - -myresults = outputlib.views.node(results, 'natural_gas') -myresults = myresults['sequences'].sum(axis=0) -myresults = myresults.drop(myresults.index[0]).reset_index(drop=True) -myresults.rename({0: 'fixed', 1: 'variable', 2: 'total'}, inplace=True) -myresults.plot(kind='bar', rot=0, title="Usage of natural gas") -plt.show() - -# Create a plot with 6 tiles that shows the difference between the -# Transformer and the ExtractionTurbineCHP used for chp plants. -smooth_plot = True - -if oeplot: - logging.info('Plot the results') - - cdict = { - (('variable_chp_gas', 'electricity'), 'flow'): '#42c77a', - (('fixed_chp_gas_2', 'electricity_2'), 'flow'): '#20b4b6', - (('fixed_chp_gas', 'electricity'), 'flow'): '#20b4b6', - (('fixed_chp_gas', 'heat'), 'flow'): '#20b4b6', - (('variable_chp_gas', 'heat'), 'flow'): '#42c77a', - (('heat', 'demand_therm'), 'flow'): '#5b5bae', - (('heat_2', 'demand_th_2'), 'flow'): '#5b5bae', - (('electricity', 'demand_elec'), 'flow'): '#5b5bae', - (('electricity_2', 'demand_el_2'), 'flow'): '#5b5bae', - (('heat', 'excess_therm'), 'flow'): '#f22222', - (('heat_2', 'excess_bth_2'), 'flow'): '#f22222', - (('electricity', 'excess_elec'), 'flow'): '#f22222', - (('electricity_2', 'excess_bel_2'), 'flow'): '#f22222', - (('fixed_chp_gas_2', 'heat_2'), 'flow'): '#20b4b6'} - - fig = plt.figure(figsize=(18, 9)) - plt.rc('legend', **{'fontsize': 13}) - plt.rcParams.update({'font.size': 13}) - fig.subplots_adjust(left=0.07, bottom=0.12, right=0.86, top=0.93, - wspace=0.03, hspace=0.2) - - # subplot of electricity bus (fixed chp) [1] - electricity_2 = outputlib.views.node(results, 'electricity_2') - x_length = len(electricity_2['sequences'].index) - myplot = oeplot.io_plot( - bus_label='electricity_2', df=electricity_2['sequences'], - cdict=cdict, smooth=smooth_plot, - line_kwa={'linewidth': 4}, ax=fig.add_subplot(3, 2, 1), - inorder=[(('fixed_chp_gas_2', 'electricity_2'), 'flow')], - outorder=[(('electricity_2', 'demand_el_2'), 'flow'), - (('electricity_2', 'excess_bel_2'), 'flow')]) - myplot['ax'].set_ylabel('Power in MW') - myplot['ax'].set_xlabel('') - myplot['ax'].get_xaxis().set_visible(False) - myplot['ax'].set_xlim(0, x_length) - myplot['ax'].set_title("Electricity output (fixed chp)") - myplot['ax'].legend_.remove() - - # subplot of electricity bus (variable chp) [2] - electricity = outputlib.views.node(results, 'electricity') - myplot = oeplot.io_plot( - bus_label='electricity', df=electricity['sequences'], - cdict=cdict, smooth=smooth_plot, - line_kwa={'linewidth': 4}, ax=fig.add_subplot(3, 2, 2), - inorder=[(('fixed_chp_gas', 'electricity'), 'flow'), - (('variable_chp_gas', 'electricity'), 'flow')], - outorder=[(('electricity', 'demand_elec'), 'flow'), - (('electricity', 'excess_elec'), 'flow')]) - myplot['ax'].get_yaxis().set_visible(False) - myplot['ax'].set_xlabel('') - myplot['ax'].get_xaxis().set_visible(False) - myplot['ax'].set_title("Electricity output (variable chp)") - myplot['ax'].set_xlim(0, x_length) - shape_legend('electricity', plotshare=1, **myplot) - - # subplot of heat bus (fixed chp) [3] - heat_2 = outputlib.views.node(results, 'heat_2') - myplot = oeplot.io_plot( - bus_label='heat_2', df=heat_2['sequences'], - cdict=cdict, smooth=smooth_plot, - line_kwa={'linewidth': 4}, ax=fig.add_subplot(3, 2, 3), - inorder=[(('fixed_chp_gas_2', 'heat_2'), 'flow')], - outorder=[(('heat_2', 'demand_th_2'), 'flow'), - (('heat_2', 'excess_bth_2'), 'flow')]) - myplot['ax'].set_ylabel('Power in MW') - myplot['ax'].set_ylim([0, 600000]) - myplot['ax'].get_xaxis().set_visible(False) - myplot['ax'].set_title("Heat output (fixed chp)") - myplot['ax'].set_xlim(0, x_length) - myplot['ax'].legend_.remove() - - # subplot of heat bus (variable chp) [4] - heat = outputlib.views.node(results, 'heat') - myplot = oeplot.io_plot( - bus_label='heat', df=heat['sequences'], - cdict=cdict, smooth=smooth_plot, - line_kwa={'linewidth': 4}, ax=fig.add_subplot(3, 2, 4), - inorder=[(('fixed_chp_gas', 'heat'), 'flow'), - (('variable_chp_gas', 'heat'), 'flow')], - outorder=[(('heat', 'demand_therm'), 'flow'), - (('heat', 'excess_therm'), 'flow')]) - myplot['ax'].set_ylim([0, 600000]) - myplot['ax'].get_yaxis().set_visible(False) - myplot['ax'].get_xaxis().set_visible(False) - myplot['ax'].set_title("Heat output (variable chp)") - myplot['ax'].set_xlim(0, x_length) - shape_legend('heat', plotshare=1, **myplot) - - if smooth_plot: - style = None - else: - style = 'steps-mid' - - # subplot of efficiency (fixed chp) [5] - fix_chp_gas2 = outputlib.views.node(results, 'fixed_chp_gas_2') - ngas = fix_chp_gas2['sequences'][ - (('natural_gas', 'fixed_chp_gas_2'), 'flow')] - elec = fix_chp_gas2['sequences'][ - (('fixed_chp_gas_2', 'electricity_2'), 'flow')] - heat = fix_chp_gas2['sequences'][(('fixed_chp_gas_2', 'heat_2'), 'flow')] - e_ef = elec.div(ngas) - h_ef = heat.div(ngas) - df = pd.DataFrame(pd.concat([h_ef, e_ef], axis=1)) - my_ax = df.reset_index(drop=True).plot( - drawstyle=style, ax=fig.add_subplot(3, 2, 5), linewidth=2) - my_ax.set_ylabel('efficiency') - my_ax.set_ylim([0, 0.55]) - my_ax.set_xlabel('May 2012') - my_ax = oeplot.set_datetime_ticks(my_ax, df.index, tick_distance=24, - date_format='%d', offset=12, - tight=True) - my_ax.set_title('Efficiency (fixed chp)') - my_ax.legend_.remove() - - # subplot of efficiency (variable chp) [6] - var_chp_gas = outputlib.views.node(results, 'variable_chp_gas') - ngas = var_chp_gas['sequences'][ - (('natural_gas', 'variable_chp_gas'), 'flow')] - elec = var_chp_gas['sequences'][ - (('variable_chp_gas', 'electricity'), 'flow')] - heat = var_chp_gas['sequences'][(('variable_chp_gas', 'heat'), 'flow')] - e_ef = elec.div(ngas) - h_ef = heat.div(ngas) - e_ef.name = 'electricity ' - h_ef.name = 'heat' - df = pd.DataFrame(pd.concat([h_ef, e_ef], axis=1)) - my_ax = df.reset_index(drop=True).plot( - drawstyle=style, ax=fig.add_subplot(3, 2, 6), linewidth=2) - my_ax.set_ylim([0, 0.55]) - my_ax = oeplot.set_datetime_ticks(my_ax, df.index, tick_distance=24, - date_format='%d', offset=12, - tight=True) - my_ax.get_yaxis().set_visible(False) - my_ax.set_xlabel('May 2012') - - my_ax.set_title('Efficiency (variable chp)') - my_box = my_ax.get_position() - my_ax.set_position([my_box.x0, my_box.y0, my_box.width * 1, my_box.height]) - my_ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), ncol=1) - - plt.show() - -else: - logging.warning("You have to install 'oemof-visio' to see the i/o-plot") - logging.warning( - "Use: pip install git+https://github.com/oemof/oemof_visio.git") diff --git a/oemof_heat_components/__init__.py b/src/oemof/thermal/__init__.py similarity index 100% rename from oemof_heat_components/__init__.py rename to src/oemof/thermal/__init__.py diff --git a/src/oemof/thermal/heat_pump.py b/src/oemof/thermal/heat_pump.py new file mode 100644 index 00000000..e0290dc5 --- /dev/null +++ b/src/oemof/thermal/heat_pump.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +import pandas as pd +import warnings + + +def get_cop(temperature, heatpump_type="Air", water_temp=60): + """ Calculation of the coefficient of performance depending + on the outside temperature + + Parameters + ---------- + temperature: time series + containing the outside temperature + heatpump_type: string + defines the technology used. Ground is more efficient than Air. + water_temp: int + temperature needed for the heating system + + References + ---------- + .. [1]: 'https://www.researchgate.net/publication/ + 255759857_A_review_of_domestic_heat_pumps' + Research paper about domestic heatpumps, containing the formulas used + """ + + cop_lst = [] + + if heatpump_type == "Air": + for tmp in temperature: + if (water_temp - tmp) < 15 or (water_temp - tmp) > 60: + msg = "'{0}'°C exceeds the limit of the formula used:\ + 15 <= (water_temp - tmp) <= 60" + warnings.warn(msg.format((water_temp - tmp))) + + cop = (6.81 - 0.121 * (water_temp - tmp) + + 0.00063 * (water_temp - tmp)**2) + cop_lst.append(cop) + + elif heatpump_type == "Ground": + for tmp in temperature: + if (water_temp - tmp) < 20 or (water_temp - tmp) > 60: + msg = "'{0}'°C exceeds the limit of the formula used:\ + 20 <= (water_temp - tmp) <= 60" + warnings.warn(msg.format((water_temp - tmp))) + + cop = (8.77 - 0.15 * (water_temp - tmp) + + 0.000734 * (water_temp - tmp)**2) + cop_lst.append(cop) + + else: + msg = "'{0}' is not a valid heatpump type. Use 'Air' or 'Ground'." + raise ValueError(msg.format(heatpump_type)) + + cop = pd.DataFrame({"cop": cop_lst}, index=temperature.index) + + return cop