forked from qpv-research-group/solcore5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLight_sources_examples.py
executable file
·49 lines (40 loc) · 1.46 KB
/
Light_sources_examples.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
import numpy as np
import matplotlib.pyplot as plt
from solcore.light_source import LightSource
# TODO If SMARTS is not installed, it keeps trying and producing errors.
# LightSource is poorly designed...
# The wavelength range of the spectra
wl = np.linspace(300, 3000, 200)
# Now different types of light sources can be defined
gauss = LightSource(source_type='laser', x=wl, center=800, linewidth=50, power=200)
bb = LightSource(source_type='black body', x=wl, T=5800, entendue='Sun')
am15g = LightSource(source_type='standard', x=wl, version='AM1.5g')
spectral = LightSource(source_type='SPECTRAL2', x=wl)
# Plot comparing the different light sources
plt.figure(1)
plt.plot(*gauss.spectrum(), label='Gauss')
plt.plot(*bb.spectrum(), label='Black body')
plt.plot(*am15g.spectrum(), label='AM1.5G')
plt.plot(*spectral.spectrum(), label='SPECTRAL2')
try:
smarts = LightSource(source_type='SMARTS', x=wl)
plt.plot(*smarts.spectrum(), label='SMARTS')
except TypeError:
pass
plt.xlim(300, 3000)
plt.xlabel('Wavelength (nm)')
plt.ylabel('Power density (Wm$^{-2}$nm$^{-1}$)')
plt.tight_layout()
plt.legend()
try:
# Plot comparing the spectra calculated with SMARTS at different hours of the day
for h in range(8, 20):
plt.plot(*smarts.spectrum(HOUR=h), label='{} h'.format(h))
plt.xlim(300, 3000)
plt.xlabel('Wavelength (nm)')
plt.ylabel('Power density (Wm$^{-2}$nm$^{-1}$)')
plt.tight_layout()
plt.legend()
except TypeError:
pass
plt.show()