Structures and support classes¶
While Solcore is mostly about physics, it also needs a lot of tools that keep everiting working together properly or that support the creation and management of solar cell structure. Here you can find (some) information about all those extra bits and pieces Solcore is made of.
Structure¶
Solcore calculates optical and electrical properties of solar cells or, in other words, of a certain combination of layers made of different materials and serving to specific purposes. The structure module contains tha basic building blocks that allow you to make a solar cell structure and calculate their properties. Their use will be explained with examples in other packages - such as in the quantum efficiency calculator or the Poisson-drift-diffusion solver.
-
class
solcore.structure.
Structure
(*args, **kwargs)[source]¶ Subclass of lists that stores information of a ‘sample’ consisting of several ‘layers’.
-
class
solcore.structure.
Layer
(width, material, role=None, geometry=None, **kwargs)[source]¶ Class that stores the information about layers of materials, such as thickness and composition. It is the building block of the ‘Structures’
-
class
solcore.structure.
Junction
(*args, **kwargs)[source]¶ Class that groups together the layers that make a junction. Essentially, it is just a list with attributes you can update.
-
class
solcore.structure.
TunnelJunction
(*args, **kwargs)[source]¶ Class that contains the minimum definitions for a tunnel junction, ie. a series resistance in our case.
-
solcore.structure.
InLineComposition
(layer)[source]¶ Hack to use the Adachi-alfa calculator, provinding the composition as a single string
Parameters: layer – A layer as defined in the Device structures of the PDD solver Returns: A mterial string
-
solcore.structure.
SolcoreMaterialToStr
(material_input)[source]¶ Translate a solcore material into something than can be easily stored in a file and read
Parameters: material_input – A solcore material Returns: A dictionary with the name, consituents and composition of the material
-
solcore.structure.
ToSolcoreMaterial
(comp, T, execute=False, **kwargs)[source]¶ It provides a solcore material out of its string composition. The output can be a string with the command or a solcore material itself.
Parameters: - comp – A Solcore material as a string
- T – The temperature
- execute – If a Solcore material must be provided or just a string that would do that.
Returns: A Solcore material or a string with the command to calculate the solcore material
-
solcore.structure.
ToLayer
(width, material, role)[source]¶ Creates a Layer based on strings containing the width, the material and the role
Parameters: - width – Width of the layer
- material – Material of the layer, as a string
- role – The role of the layer
Returns: A Solcore Layer
-
solcore.structure.
ToStructure
(device)[source]¶ Translate the device object (as used by the PDD solver) into a list of solcore Structure that can be used in other plugings. Only translate the composition, for now. It works only on non-nested device structures (QW, for example, but not in devices with QW)
Parameters: device – A solcore device structure as used by the PDD solver Returns: A Solcore Structure
Another, very useful class is the state_object which makes the use of dictionaries very easy.
Solar Cells¶
Finally, the higher level building block of solar cells is contained in the solar_cell module.
-
class
solcore.solar_cell.
SolarCell
(layers=None, T=298, cell_area=1, reflectivity=None, shading=0, substrate=None, incidence=None, R_series=0, **kwargs)[source]¶ This class is almost identical to the basic Structure class in Solcore (it is a subclass of it, actually) but implementing some default parameter values and control about the types of layers. It should work anywhere where a Structure object works.
-
sort_layer_type
(layer, i)[source]¶ Sorts the layer in different categories, depending on its type, and keeps record on the indices of that type of layer.
Parameters: - layer – The layer to check
- i – The index of that layer
Returns: None
-
append
(new_layer, layer_label=None, repeats=1)[source]¶ Appends a layer to the structure a certain number of times to the structure.
Parameters: - new_layer – The layer to append.
- layer_label – An optional label for that layer.
- repeats – Number of times to repeat add the layer.
Returns: None
-
append_multiple
(layers, layer_labels=None, repeats=1)[source]¶ Appends multiple layers a certain umber of times to the structure.
Parameters: - layers – A list with the layers to append.
- layer_labels – An optional list with the labels. If present, it must have the same length that the layers list.
- repeats – Number of times to add this set of layers.
Returns: None
-
Science tracker¶
Solcore is an original work, but the equations it implements and the data it uses have been often published elsewere. The Science tracker allows you to keep track of those references and check yourself their origin and assumpions.
-
solcore.science_tracker.
science_reference
(short_purpose: str, reference: str) → None[source]¶ Marker acting as a reference for the origin of specific information
Acts as a marker in code where particular algorithms/data/… originates. General execution of code silently passes these markers, but remembers how and where they were called. Which markers were passed in a particular program run can be recalled with print_references().
Arguments: short_purpose: Identify the thing being referenced (string) reference: The reference itself, in any sensible format.
Other classes¶
Solcore depends on many other classes and functions that work in the background and keep everything together. Some of them are used directly, others are completely transparent but make Solcore work they way it does. Unfortunately, their documentation is not very extensive or explicit, so feel free to explore the source code to understand what they are doing and how.
-
class
solcore.interpolate.
interp1d
(x: numpy.ndarray, y: numpy.ndarray, kind: str = 'linear', axis: int = -1, copy: bool = True, bounds_error: bool = False, fill_value: float = nan)[source]¶ Interpolate a 1D function.
splrep, splev - spline interpolation based on FITPACK UnivariateSpline - a more recent wrapper of the FITPACK routines
-
class
solcore.interpolate.
BilinearInterpolation
(x: Union[list, numpy.ndarray], y: Union[list, numpy.ndarray], z: Union[list, numpy.ndarray], fill_value: float = 0.0)[source]¶ docstring for BilinearInterpolation
Calculates the k-points of the Brillouin zone in a given direction
-
solcore.crystals.
traverse_brillouin
(a: float, traverse_order: tuple = ('L', 'Gamma', 'X', 'W', 'K', 'Gamma'), steps: int = 30) → Tuple[numpy.ndarray, float, List[Tuple[float, str]]][source]¶
-
solcore.crystals.
kvector
(a: float, t: float = 0, p: float = 3.141592653589793, fraction: float = 0.2, points: int = 50, vin: numpy.ndarray = None) → numpy.ndarray[source]¶ Calculates the k points in a direction given by the spheric angles theta (t) and phi (p).
The fraction of the Brilluin zone calculated is given by “fraction” and the number of points by “points”. If “vin” is given, the direction of interest is taken from this vector.
-
solcore.smooth.
smooth
(x: numpy.ndarray, window_len: int, window: str = 'hanning', blurmode: str = 'even') → numpy.ndarray[source]¶ smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal.
- input:
x: the input signal window_len: the dimension of the smoothing window; should be an odd integer window: the type of window from ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’
flat window will produce a moving average smoothing.- output:
- the smoothed signal
example:
t=linspace(-2,2,0.1) x=sin(t)+randn(len(t))*0.1 y=smooth(x)
see also:
numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve scipy.signal.lfilter
TODO: the window parameter could be the window itself if an array instead of a string
-
class
solcore.singleton.
Singleton
[source]¶ A metaclass that restricts children to one instance. Attempting to create a second instance simply returns the first instance.
-
breakout
() → solcore.singleton.Singleton[source]¶ Decorator for singleton methods that should be available in global scope
-
class
Redirect_to_singleton_method
(cls: solcore.singleton.Singleton, function: Callable)[source]¶ Class that wraps the method that has been defined as ‘breakout’ with its own class, so it can be called as a standalone function.
-
class
breakoutFunctions
(namespace: str)[source]¶ Decorator for singletons which should make some of their methods available in a certain namespace. This is identical to the ‘breakoutClass’ function defined in ‘source_managed_class’, but has the option of making the function available not in the global scope but somewhere else.
-
Another short python 3.4 travesty by Markus. Updated by Diego
-
class
solcore.source_managed_class.
SourceManagedClassDeprecated
[source]¶ Base class that manages the sources of Solcore, from the materials to the unit conversion system. It must be defined as a derived class from Singleton so only one instance of this class containing all sources exists at any time.