-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdegradation.py
1066 lines (863 loc) · 31.7 KB
/
degradation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Collection of functions for degradation calculations."""
import numpy as np
import pandas as pd
from numba import jit, njit
from rex import NSRDBX
from rex import Outputs
from pathlib import Path
from concurrent.futures import ProcessPoolExecutor, as_completed
from typing import Union
from . import temperature
from . import spectral
from . import weather
from typing import Optional
from pvdeg.decorators import geospatial_quick_shape, deprecated
# TODO: Clean up all those functions and add gaps functionality
def _deg_rate_env(poa_global, temp, temp_chamber, p, Tf):
"""
Helper function. Find the rate of degradation kenetics using the Fischer model.
Degradation kentics model interpolated 50 coatings with respect to
color shift, cracking, gloss loss, fluorescense loss,
retroreflectance loss, adhesive transfer, and shrinkage.
(ADD IEEE reference)
Parameters
------------
poa_global : float
(Global) Plan of Array irradiance [W/m²]
temp : float
Solar module temperature [°C]
temp_chamber : float
Reference temperature [°C] "Chamber Temperature"
p : float
Fit parameter
Tf : float
Multiplier for the increase in degradation
for every 10[°C] temperature increase
Returns
-------/
degradationrate : float
rate of Degradation (NEED TO ADD METRIC)
"""
# poa_global ** (p) * Tf ** ((temp - temp_chamber) / 10)
return np.multiply(
np.power(poa_global, p),
np.power(Tf, np.divide(np.subtract(temp, temp_chamber), 10)),
)
def _deg_rate_chamber(I_chamber, p):
"""
Helper function. Find the rate of degradation kenetics of a simulated chamber. Mike Kempe's
calculation of the rate of degradation inside a accelerated degradation chamber.
(ADD IEEE reference)
Parameters
----------
I_chamber : float
Irradiance of Controlled Condition W/m²
p : float
Fit parameter
Returns
--------
chamberdegradationrate : float
Degradation rate of chamber
"""
# chamberdegradationrate = I_chamber ** (p)
chamberdegradationrate = np.power(I_chamber, p)
return chamberdegradationrate
def _acceleration_factor(numerator, denominator):
"""
Helper Function. Find the acceleration factor
(ADD IEEE reference)
Parameters
----------
numerator : float
Typically the numerator is the chamber settings
denominator : float
Typically the TMY data summation
Returns
-------
chamberAccelerationFactor : float
Acceleration Factor of chamber (NEED TO ADD METRIC)
"""
chamberAccelerationFactor = np.divide(numerator, denominator)
# chamberAccelerationFactor = numerator / denominator
return chamberAccelerationFactor
def vantHoff_deg(
weather_df,
meta,
I_chamber,
temp_chamber,
poa=None,
temp=None,
p=0.5,
Tf=1.41,
temp_model="sapm",
conf="open_rack_glass_polymer",
wind_factor=0.33,
irradiance_kwarg={},
model_kwarg={},
):
"""
Van't Hoff Irradiance Degradation
Parameters
-----------
weather_df : pd.dataframe
Dataframe containing at least dni, dhi, ghi, temperature, wind_speed
meta : dict
Location meta-data containing at least latitude, longitude, altitude
I_chamber : float
Irradiance of Controlled Condition [W/m²]
temp_chamber : float
Reference temperature [°C] "Chamber Temperature"
poa : series or data frame, optional
dataframe containing 'poa_global', Global Plane of Array Irradiance [W/m²]
temp : pandas series, optional
Solar module temperature or Cell temperature [°C]. If no cell temperature is given, it will
be generated using the default paramters of pvdeg.temperature.cell
p : float
fit parameter
Tf : float
Multiplier for the increase in degradation for every 10[°C] temperature increase
temp_model : (str, optional)
Specify which temperature model from pvlib to use. Current options:
conf : (str)
The configuration of the PV module architecture and mounting
configuration. Currently only used for 'sapm' and 'pvsys'.
With different options for each.
'sapm' options: ``open_rack_glass_polymer`` (default),
``open_rack_glass_glass``, ``close_mount_glass_glass``,
``insulated_back_glass_polymer``
'pvsys' options: ``freestanding``, ``insulated``
wind_factor : float, optional
Wind speed correction exponent to account for different wind speed measurement heights
between weather database (e.g. NSRDB) and the tempeature model (e.g. SAPM)
The NSRDB provides calculations at 2 m (i.e module height) but SAPM uses a 10 m height.
It is recommended that a power-law relationship between height and wind speed of 0.33
be used*. This results in a wind speed that is 1.7 times higher. It is acknowledged that
this can vary significantly.
irradiance_kwarg : (dict, optional)
keyword argument dictionary used for the poa irradiance caluation.
options: ``sol_position``, ``tilt``, ``azimuth``, ``sky_model``. See ``pvdeg.spectral.poa_irradiance``.
model_kwarg : (dict, optional)
keyword argument dictionary used for the pvlib temperature model calculation.
See https://pvlib-python.readthedocs.io/en/stable/reference/pv_modeling/temperature.html for more.
Returns
-------
accelerationFactor : float or series
Degradation acceleration factor
"""
if poa is None:
poa = spectral.poa_irradiance(weather_df, meta, **irradiance_kwarg)
if isinstance(poa, pd.DataFrame):
poa_global = poa["poa_global"]
if temp is None:
# temp = temperature.cell(weather_df=weather_df, meta=meta, poa=poa)
temp = temperature.temperature(
cell_or_mod="cell",
temp_model=temp_model,
weather_df=weather_df,
meta=meta,
poa=poa,
conf=conf,
wind_factor=wind_factor,
model_kwarg=model_kwarg,
)
rateOfDegEnv = _deg_rate_env(
poa_global=poa_global, temp=temp, temp_chamber=temp_chamber, p=p, Tf=Tf
)
# sumOfDegEnv = rateOfDegEnv.sum(axis = 0, skipna = True)
avgOfDegEnv = rateOfDegEnv.mean()
rateOfDegChamber = _deg_rate_chamber(I_chamber, p)
accelerationFactor = _acceleration_factor(rateOfDegChamber, avgOfDegEnv)
return accelerationFactor
def _to_eq_vantHoff(temp, Tf=1.41):
"""
Function to obtain the Vant Hoff temperature equivalent [°C]
Parameters
----------
Tf : float
Multiplier for the increase in degradation for every 10[°C] temperature increase. Default value of 1.41.
temp : pandas series
Solar module surface or Cell temperature [°C]
Returns
-------
Toeq : float
Vant Hoff temperature equivalent [°C]
"""
# toSum = Tf ** (temp / 10)
toSum = np.power(Tf, np.divide(temp, 10))
summation = toSum.sum(axis=0, skipna=True)
Toeq = (10 / np.log(Tf)) * np.log(summation / len(temp))
return Toeq
@geospatial_quick_shape(0, ["Iwa"])
def IwaVantHoff(
weather_df,
meta,
poa=None,
temp=None,
Teq=None,
p=0.5,
Tf=1.41,
temp_model="sapm",
conf="open_rack_glass_polymer",
wind_factor=0.33,
model_kwarg={},
irradiance_kwarg={},
):
"""
IWa : Environment Characterization [W/m²]
For one year of degredation the controlled environmnet lamp settings will
need to be set to IWa.
Parameters
-----------
weather_df : pd.dataframe
Dataframe containing at least dni, dhi, ghi, temperature, wind_speed
meta : dict
Location meta-data containing at least latitude, longitude, altitude
poa : float series or dataframe
Series or dataframe containing 'poa_global', Global Plane of Array Irradiance W/m²
temp : float series
Solar module temperature or Cell temperature [°C]
Teq : series
VantHoff equivalent temperature [°C]
p : float
Fit parameter
Tf : float
Multiplier for the increase in degradation for every 10[°C] temperature increase
temp_model : (str, optional)
Specify which temperature model from pvlib to use. Current options:
conf : (str)
The configuration of the PV module architecture and mounting
configuration. Currently only used for 'sapm' and 'pvsys'.
With different options for each.
'sapm' options: ``open_rack_glass_polymer`` (default),
``open_rack_glass_glass``, ``close_mount_glass_glass``,
``insulated_back_glass_polymer``
'pvsys' options: ``freestanding``, ``insulated``
wind_factor : float, optional
Wind speed correction exponent to account for different wind speed measurement heights
between weather database (e.g. NSRDB) and the tempeature model (e.g. SAPM)
The NSRDB provides calculations at 2 m (i.e module height) but SAPM uses a 10 m height.
It is recommended that a power-law relationship between height and wind speed of 0.33
be used*. This results in a wind speed that is 1.7 times higher. It is acknowledged that
this can vary significantly.
irradiance_kwarg : (dict, optional)
keyword argument dictionary used for the poa irradiance caluation.
options: ``sol_position``, ``tilt``, ``azimuth``, ``sky_model``. See ``pvdeg.spectral.poa_irradiance``.
model_kwarg : (dict, optional)
keyword argument dictionary used for the pvlib temperature model calculation.
See https://pvlib-python.readthedocs.io/en/stable/reference/pv_modeling/temperature.html for more.
Returns
--------
Iwa : float
Environment Characterization [W/m²[]
"""
if poa is None:
poa = spectral.poa_irradiance(weather_df, meta, **irradiance_kwarg)
if temp is None:
# temp = temperature.cell(weather_df, meta, poa)
temp = temperature.temperature(
cell_or_mod="cell",
temp_model=temp_model,
weather_df=weather_df,
meta=meta,
poa=poa,
conf=conf,
wind_factor=wind_factor,
model_kwarg=model_kwarg,
)
if Teq is None:
Teq = _to_eq_vantHoff(temp, Tf)
if isinstance(poa, pd.DataFrame):
poa_global = poa["poa_global"]
else:
poa_global = poa
# toSum = (poa_global**p) * (Tf ** ((temp - Teq) / 10))
toSum = np.multiply(
np.power(poa_global, p), np.power(Tf, np.divide(np.subtract(temp, Teq), 10))
)
summation = toSum.sum(axis=0, skipna=True)
# Iwa = (summation / len(poa_global)) ** (1 / p)
Iwa = np.power(np.divide(summation, len(poa_global)), np.divide(1, p))
return Iwa
def _arrhenius_denominator(poa_global, rh_outdoor, temp, Ea, p, n):
"""
Helper function. Calculates the rate of degredation of the Environmnet
Parameters
----------
poa_global : float series
(Global) Plan of Array irradiance [W/m²]
p : float
Fit parameter
rh_outdoor : pandas series
Relative Humidity of material of interest. Acceptable relative
humiditys can be calculated from these functions: rh_backsheet(),
rh_back_encap(); rh_front_encap(); rh_surface_outside()
n : float
Fit parameter for relative humidity
temp : pandas series
Solar module temperature or Cell temperature [°C]
Ea : float
Degredation Activation Energy [kJ/mol]
Returns
-------
environmentDegradationRate : pandas series
Degradation rate of environment
"""
# environmentDegradationRate = (
# poa_global ** (p)
# * rh_outdoor ** (n)
# * np.exp(-(Ea / (0.00831446261815324 * (temp + 273.15))))
# )
environmentDegradationRate = np.multiply(
np.multiply(np.power(poa_global, p), np.power(rh_outdoor, n)),
np.exp(
np.negative(
np.divide(Ea, np.multiply(0.00831446261815324, np.add(temp, 273.15)))
)
),
)
return environmentDegradationRate
def _arrhenius_numerator(I_chamber, rh_chamber, temp_chamber, Ea, p, n):
"""
Helper function. Find the rate of degradation of a simulated chamber.
Parameters
----------
I_chamber : float
Irradiance of Controlled Condition [W/m²]
Rhchamber : float
Relative Humidity of Controlled Condition [%]
EXAMPLE: "50 = 50% NOT .5 = 50%"
temp_chamber : float
Reference temperature [°C] "Chamber Temperature"
Ea : float
Degredation Activation Energy [kJ/mol]
p : float
Fit parameter
n : float
Fit parameter for relative humidity
Returns
--------
arrheniusNumerator : float
Degradation rate of the chamber
"""
# arrheniusNumerator = (
# I_chamber ** (p)
# * rh_chamber ** (n)
# * np.exp(-(Ea / (0.00831446261815324 * (temp_chamber + 273.15))))
# )
arrheniusNumerator = np.multiply(
np.multiply(np.power(I_chamber, p), np.power(rh_chamber, n)),
np.exp(
np.negative(
np.divide(
Ea, np.multiply(0.00831446261815324, np.add(temp_chamber, 273.15))
)
)
),
)
return arrheniusNumerator
def arrhenius_deg(
weather_df: pd.DataFrame,
meta: dict,
rh_outdoor,
I_chamber,
rh_chamber,
Ea,
temp_chamber,
poa=None,
temp=None,
p=0.5,
n=1,
temp_model="sapm",
conf="open_rack_glass_polymer",
wind_factor=0.33,
model_kwarg={},
irradiance_kwarg={},
):
"""
Calculate the Acceleration Factor between the rate of degredation of a
modeled environmnet versus a modeled controlled environmnet. Example: "If the AF=25 then 1 year
of Controlled Environment exposure is equal to 25 years in the field"
Parameters
----------
weather_df : pd.dataframe
Dataframe containing at least dni, dhi, ghi, temperature, wind_speed
meta : dict
Location meta-data containing at least latitude, longitude, altitude
rh_outdoor : float series
Relative Humidity of material of interest
Acceptable relative humiditys can be calculated
from these functions: rh_backsheet(), rh_back_encap(), rh_front_encap(),
rh_surface_outside()
I_chamber : float
Irradiance of Controlled Condition [W/m²]
rh_chamber : float
Relative Humidity of Controlled Condition [%].
EXAMPLE: "50 = 50% NOT .5 = 50%"
temp_chamber : float
Reference temperature [°C] "Chamber Temperature"
Ea : float
Degredation Activation Energy [kJ/mol]
if Ea=0 is used there will be not dependence on temperature and degradation will proceed according to the amount of light and humidity.
poa : pd.dataframe, optional
Global Plane of Array Irradiance [W/m²]
temp : pd.series, optional
Solar module temperature or Cell temperature [°C]. If no cell temperature is given, it will
be generated using the default parameters from pvdeg.temperature.cell
p : float
Fit parameter
When p=0 the dependence on light will be ignored and degradation will happen both day an night. As a caution or a feature, a very small value of p (e.g. p=0.0001) will provide very little degradation dependence on irradiance, but degradation will only be accounted for during daylight. i.e. averages will be computed over half of the time only.
n : float
Fit parameter for relative humidity
When n=0 the degradation rate will not be dependent on humidity.
temp_model : (str, optional)
Specify which temperature model from pvlib to use. Current options:
conf : (str)
The configuration of the PV module architecture and mounting
configuration. Currently only used for 'sapm' and 'pvsys'.
With different options for each.
'sapm' options: ``open_rack_glass_polymer`` (default),
``open_rack_glass_glass``, ``close_mount_glass_glass``,
``insulated_back_glass_polymer``
'pvsys' options: ``freestanding``, ``insulated``
wind_factor : float, optional
Wind speed correction exponent to account for different wind speed measurement heights
between weather database (e.g. NSRDB) and the tempeature model (e.g. SAPM)
The NSRDB provides calculations at 2 m (i.e module height) but SAPM uses a 10 m height.
It is recommended that a power-law relationship between height and wind speed of 0.33
be used*. This results in a wind speed that is 1.7 times higher. It is acknowledged that
this can vary significantly.
irradiance_kwarg : (dict, optional)
keyword argument dictionary used for the poa irradiance caluation.
options: ``sol_position``, ``tilt``, ``azimuth``, ``sky_model``. See ``pvdeg.spectral.poa_irradiance``.
model_kwarg : (dict, optional)
keyword argument dictionary used for the pvlib temperature model calculation.
See https://pvlib-python.readthedocs.io/en/stable/reference/pv_modeling/temperature.html for more.
Returns
--------
accelerationFactor : pandas series
Degradation acceleration factor
"""
if poa is None:
poa = spectral.poa_irradiance(weather_df, meta, **irradiance_kwarg)
if temp is None:
# temp = temperature.cell(weather_df, meta, poa)
temp = temperature.temperature(
cell_or_mod="cell",
temp_model=temp_model,
weather_df=weather_df,
meta=meta,
poa=poa,
conf=conf,
wind_factor=wind_factor,
model_kwarg=model_kwarg,
)
if isinstance(poa, pd.DataFrame):
poa_global = poa["poa_global"]
else:
poa_global = poa
arrheniusDenominator = _arrhenius_denominator(
poa_global=poa_global, rh_outdoor=rh_outdoor, temp=temp, Ea=Ea, p=p, n=n
)
AvgOfDenominator = arrheniusDenominator.mean()
arrheniusNumerator = _arrhenius_numerator(
I_chamber=I_chamber,
rh_chamber=rh_chamber,
temp_chamber=temp_chamber,
Ea=Ea,
p=p,
n=n,
)
accelerationFactor = _acceleration_factor(arrheniusNumerator, AvgOfDenominator)
return accelerationFactor
def _T_eq_arrhenius(temp, Ea):
"""
Get the Temperature equivalent required for the settings of the controlled environment
Calculation is used in determining Arrhenius Environmental Characterization
Parameters
-----------
temp : pandas series
Solar module temperature or Cell temperature [°C]
Ea : float
Degredation Activation Energy [kJ/mol]
Returns
-------
Teq : float
Temperature equivalent (Celsius) required
for the settings of the controlled environment
"""
summationFrame = np.exp(-(Ea / (0.00831446261815324 * (temp + 273.15))))
sumForTeq = summationFrame.sum(axis=0, skipna=True)
Teq = -((Ea) / (0.00831446261815324 * np.log(sumForTeq / len(temp))))
# Convert to celsius
Teq = Teq - 273.15
return Teq
def _RH_wa_arrhenius(rh_outdoor, temp, Ea, Teq=None, n=1):
"""
NOTE
Get the Relative Humidity Weighted Average.
Calculation is used in determining Arrhenius Environmental Characterization
Parameters
-----------
rh_outdoor : pandas series
Relative Humidity of material of interest. Acceptable relative
humiditys can be calculated from the below functions:
rh_backsheet(), rh_back_encap(), rh_front_encap(), rh_surface_outside()
temp : pandas series
solar module temperature or Cell temperature [°C]
Ea : float
Degredation Activation Energy [kJ/mol]
Teq : series
Equivalent Arrhenius temperature [°C]
n : float
Fit parameter for relative humidity
Returns
--------
RHwa : float
Relative Humidity Weighted Average [%]
"""
if Teq is None:
Teq = _T_eq_arrhenius(temp, Ea)
summationFrame = (rh_outdoor**n) * np.exp(
-(Ea / (0.00831446261815324 * (temp + 273.15)))
)
sumForRHwa = summationFrame.sum(axis=0, skipna=True)
RHwa = (
sumForRHwa
/ (len(summationFrame) * np.exp(-(Ea / (0.00831446261815324 * (Teq + 273.15)))))
) ** (1 / n)
return RHwa
# TODO: CHECK
# STANDARDIZE
def IwaArrhenius(
weather_df: pd.DataFrame,
meta: dict,
rh_outdoor: pd.Series,
Ea: float,
poa: pd.DataFrame = None,
temp: pd.Series = None,
RHwa: float = None,
Teq: float = None,
p: float = 0.5,
n: float = 1,
temp_model="sapm",
conf="open_rack_glass_polymer",
wind_factor=0.33,
model_kwarg={},
irradiance_kwarg={},
) -> float:
"""
Function to calculate IWa, the Environment Characterization [W/m²].
For one year of degredation the controlled environmnet lamp settings will
need to be set at IWa.
Parameters
----------
weather_df : pd.dataframe
Dataframe containing at least dni, dhi, ghi, temperature, wind_speed
meta : dict
Location meta-data containing at least latitude, longitude, altitude
rh_outdoor : pd.series
Relative Humidity of material of interest
Acceptable relative humiditys include: rh_backsheet(), rh_back_encap(), rh_front_encap(),
rh_surface_outside()
Ea : float
Degradation Activation Energy [kJ/mol]
poa : pd.dataframe, optional
must contain 'poa_global', Global Plan of Array irradiance [W/m²]
temp : pd.series, optional
Solar module temperature or Cell temperature [°C]
RHwa : float, optional
Relative Humidity Weighted Average [%]
Teq : float, optional
Temperature equivalent (Celsius) required
for the settings of the controlled environment
p : float
Fit parameter
n : float
Fit parameter for relative humidity
temp_model : (str, optional)
Specify which temperature model from pvlib to use. Current options:
conf : (str)
The configuration of the PV module architecture and mounting
configuration. Currently only used for 'sapm' and 'pvsys'.
With different options for each.
'sapm' options: ``open_rack_glass_polymer`` (default),
``open_rack_glass_glass``, ``close_mount_glass_glass``,
``insulated_back_glass_polymer``
'pvsys' options: ``freestanding``, ``insulated``
wind_factor : float, optional
Wind speed correction exponent to account for different wind speed measurement heights
between weather database (e.g. NSRDB) and the tempeature model (e.g. SAPM)
The NSRDB provides calculations at 2 m (i.e module height) but SAPM uses a 10 m height.
It is recommended that a power-law relationship between height and wind speed of 0.33
be used*. This results in a wind speed that is 1.7 times higher. It is acknowledged that
this can vary significantly.
irradiance_kwarg : (dict, optional)
keyword argument dictionary used for the poa irradiance caluation.
options: ``sol_position``, ``tilt``, ``azimuth``, ``sky_model``. See ``pvdeg.spectral.poa_irradiance``.
model_kwarg : (dict, optional)
keyword argument dictionary used for the pvlib temperature model calculation.
See https://pvlib-python.readthedocs.io/en/stable/reference/pv_modeling/temperature.html for more.
Returns
--------
Iwa : float
Environment Characterization [W/m²]
"""
if poa is None:
poa = spectral.poa_irradiance(weather_df, meta, **irradiance_kwarg)
if temp is None:
# temp = temperature.cell(weather_df, meta, poa)
temp = temperature.temperature(
cell_or_mod="cell",
temp_model=temp_model,
weather_df=weather_df,
meta=meta,
poa=poa,
conf=conf,
wind_factor=wind_factor,
model_kwarg=model_kwarg,
)
if Teq is None:
Teq = _T_eq_arrhenius(temp, Ea)
if RHwa is None:
RHwa = _RH_wa_arrhenius(rh_outdoor, temp, Ea)
if isinstance(poa, pd.DataFrame):
poa_global = poa["poa_global"]
else:
poa_global = poa
numerator = (
poa_global ** (p)
* rh_outdoor ** (n)
* np.exp(-(Ea / (0.00831446261815324 * (temp + 273.15))))
)
sumOfNumerator = numerator.sum(axis=0, skipna=True)
denominator = (
(len(numerator))
* ((RHwa) ** n)
* (np.exp(-(Ea / (0.00831446261815324 * (Teq + 273.15)))))
)
IWa = (sumOfNumerator / denominator) ** (1 / p)
return IWa
############
# Misc. Functions for Energy Calcs
############
def _rh_Above85(rh):
"""
Helper function. Determines if the relative humidity is above 85%.
Parameters
----------
rh : float
Relative Humidity %
Returns
--------
rhabove85 : boolean
True if the relative humidity is above 85% or False if the relative
humidity is below 85%
"""
if rh > 85:
rhabove85 = True
else:
rhabove85 = False
return rhabove85
def _hoursRH_Above85(df):
"""
Helper Function. Count the number of hours relative humidity is above 85%.
Parameters
----------
df : dataframe
DataFrame, dataframe containing Relative Humidity %
Returns
-------
numhoursabove85 : int
Number of hours relative humidity is above 85%
"""
booleanDf = df.apply(lambda x: _rh_Above85(x))
numhoursabove85 = booleanDf.sum()
return numhoursabove85
def _whToGJ(wh):
"""
NOTE: unused, remove?
Helper Function to convert Wh/m² to GJ/m²
Parameters
-----------
wh : float
Input Value in Wh/m²
Returns
-------
gj : float
Value in GJ/m²
"""
gj = 0.0000036 * wh
return gj
def _gJtoMJ(gJ):
"""
NOTE: unused, remove?
Helper Function to convert GJ/m² to MJ/y
Parameters
-----------
gJ : float
Value in GJ/m^-2
Returns
-------
MJ : float
Value in MJ/m^-2
"""
MJ = gJ * 1000
return MJ
# new version of degradation
def degradation(
spectra_df: pd.DataFrame,
conditions_df: pd.DataFrame = None,
temp_module: pd.Series = None,
rh_module: pd.Series = None,
Ea: float = 40.0,
n: float = 1.0,
p: float = 0.5,
C2: float = 0.07,
C: float = 1.0,
)-> float:
"""
Compute degredation as double integral of Arrhenius (Activation
Energy, RH, Temperature) and spectral (wavelength, irradiance)
functions over wavelength and time.
.. math::
D = C \\int_{0}^{t} RH(t)^n \\cdot e^{\\frac{-E_a}{RT(t)}} \\int_{\\lambda} [e^{-C_2 \\lambda} \\cdot G(\\lambda, t)]^p d\\lambda dt
Parameters
----------
spectra_df : pd.DataFrame
front or rear irradiance data in dataframe format
- `data`: Spectral irradiance values for each wavelength [W/m^2 nm].
- `index`: pd.DateTimeIndex
- `columns`: Wavelengths as floats (e.g., 280, 300, etc.) [nm].
Example::
timestamp 280 300 320 340 360 380 400
2021-03-09 10:00:00 0.6892 0.4022 0.6726 0.0268 0.3398 0.9432 0.7411
2021-03-09 11:00:00 0.1558 0.5464 0.6896 0.7828 0.5050 0.9336 0.4652
2021-03-09 12:00:00 0.2278 0.9057 0.2639 0.0572 0.9906 0.9370 0.1800
2021-03-09 13:00:00 0.3742 0.0358 0.4052 0.9578 0.1044 0.8917 0.4876
conditions_df : pd.DataFrame, optional
Environmental conditions including temperature and relative humidity.
- `index`: pd.DateTimeIndex
- `columns`: (required)
- "temperature" [°C or K]
- "relative_humidity" [%]
Example::
timestamp temperature relative_humidity
2021-03-09 10:00:00 298.0 45.0
2021-03-09 11:00:00 303.0 50.0
2021-03-09 12:00:00 310.0 55.0
2021-03-09 13:00:00 315.0 60.0
temp_module : pd.Series, optional
Module temperatures [°C]. Required if `conditions_df` is not provided. Time indexed same as spectra_df
rh_module : pd.Series, optional
Relative humidity values [%]. Required if `conditions_df` is not provided. Time indexed same as spectra_df
Example::
30 = 30%
Ea : float
Arrhenius activation energy. The default is 40. [kJ/mol]
n : float
Fit paramter for RH sensitivity. The default is 1.
p : float
Fit parameter for irradiance sensitivity. Typically
0.6 +- 0.22
C2 : float
Fit parameter for sensitivity to wavelength exponential.
Typically 0.07
C : float
Fit parameter for the Degradation equaiton
Typically 1.0
Returns
-------
degradation : float
Total degredation factor over time and wavelength.
"""
if conditions_df is not None and (temp_module is not None or rh_module is not None):
raise ValueError("Provide either conditions_df or temp_module and rh_module")
if conditions_df is not None:
rh = conditions_df["relative_humidity"].values
temps = conditions_df["temperature"].values
else:
rh = rh_module.values
temps = temp_module.values
wavelengths = spectra_df.columns.values.astype(float)
irr = spectra_df.values # irradiance as array
# call numba compiled function
return deg(
wavelengths=wavelengths,
irr=irr,
rh=rh,
temps=temps,
Ea=Ea,
C2=C2,
p=p,
n=n,
C=C
)
@njit
def deg(
wavelengths: np.ndarray,
irr: np.ndarray,
rh: np.ndarray,
temps: np.ndarray,
Ea: float,
C2: float,
p: float,
n: float,
C: float
) -> float:
R = 0.0083145 # Gas Constant in [kJ/mol*K]
wav_bin = np.diff(wavelengths)
wav_bin = np.append(wav_bin, wav_bin[-1]) # Extend last bin
# inner integral
# wavelength d lambda
irr_weighted = irr * np.exp(-C2 * wavelengths) # weight irradiances
irr_weighted *= wav_bin
irr_pow = irr_weighted ** p
wavelength_integral = np.sum(irr_pow, axis=1) # sum over wavelengths