Photoelectrochemical Solar Cell Simulator in 1D
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PhotoElectrochemical Cell Simulator


Photoelectrochemical Solar Cells

Large-scale utilization of photovoltaic (PV) devices, or solar cells, has been hampered for years due to high costs and lack of energy storage mechanisms. Photoelectrochemical solar cells (PECs), are an attractive alternative to conventional solid state PV devices. PECs such as those depicted below are able to directly convert solar energy into hydrogen fuel. The hydrogen fuel can then be used at a later time to generate electricity. The typical setup of a PEC is shown below,

Photoelectrochemical Solar Cell

A PEC consists of four main components: the solid semiconductor electrode, the liquid electrolyte component, the semiconductor-electrolyte interface and the counter (metal or semiconductor) electrode. When sunlight shines on the semiconductor component, photons are absorbed and generate electron-hole pairs. These electrons and holes are separated by a built-in electric field within the semiconductor. The separation of the electrons and holes leads to an electrical current in the cell and the accumulation of charges at the semiconductor-electrolyte interface. At the interface, the photo-generated electrons or holes induce a chemical reaction at the semiconductor electrode. A similar chemical reaction also occurs at the counter electrode. These chemical reactions at the electrode interfaces create or eliminate reductant-oxidant (redox) species in the electrolyte leading to the generation of hydrogen fuel.

Software Overview

This software is designed to simulate the dynamics of the reactive interface between a semiconductor and electrolyte in a 1D. The interface of between the semiconductor and electrolyte make up a "half cell" of a photoelectrochemical cell. The main challenges in constructing a numerical algorithms that produces reliable simulations of PECs are due to the highly nonlinear nature of the system and the different time scales of the semicondcutor and electrolye charge carriers. Furthermore, regions of stiffness caused by boundary layer formation where sharp transitions in densities and electric potential occur near the interface (as shown below) and pose severe constraints on the choice of discretization strategy in order to maintain numerical stability.

The resulting output files from the simulation are in .dat format and can viewed using the python script in /run/ directoy. The results of one simulation are shown below,


This code will automatically run in parallel using the OpenMP for multithreading if the library is present.

For much more background on the model and algorithms used in this project please see the 2D documentation page.


  1. CMAKE 2.8 (Required)
  2. GSL 1.16 (Required)
  3. EIGEN 3.0 (Required)
  4. BOOST (Required)
  5. OpenMP (Optional)
  6. Python, NumPy and matplotlib for visualization. (Optional)


After installing all the dependencies for this code, go into the PECS-1D/ directory. Then use the following command in the terminal,

mkdir build
cd build 
cmake  ..
make solar_cell_app
mv solar_cell_app ../run

Using the software

From your terminal, cd in to the run directory. If you want to use multi-threading you need to first type into your terminal,

	export OMP_NUM_THREADS=num_threads

where num_threads is the number of cores on your machine.

To set the paremeter values into you need to change the values in the input file,


see the documentation page for more datails on parameter values.

To run the code, type the following command from the run/ directory,


If you want to change the doping/concentration profiles change the file the ConcentrationProfile directory. All units (densities and space) in these files are in non-dimensional form. You will need to recompile if you change any of these files, i.e. use the steps,

make solar_cell_app mv solar_cell_app ../run

The data output files are labeled StateXXXX.dat where XXXX are specific numbers and contain the information,

 when (xvalues < 0)
	 xvalues, electron density, hole density, electric field, potential, current, time

 when	(xvalues > 0)
	 xvalues, reductant density, oxidante density, electric field, potential, current, time

To make visualizations of the simulations use the Python script in directory run by typing the command,


To get rid of simulation produced files .dats, .png, .mp4 invoke:


Edit and use if you want to run this over multiple bias values.


To test the code run the following commands from the build/ directory,

make test_System

You will then receive a report back of whether the code passed all the tests.


If you want to build the documentation for this code tou must have doxygen and latex installed. Once it is has been obtained, from the documentation directory type the command,

doxygen dox

and a html file website we be built in the directory html/. This can be viewed from any web browser by opening the index.html file within the directory.

Trouble Shooting

  • If oscillations appear in semiconductor domain (usually on the electron densities) use a smaller value for the timeStepFactor.

NOTE: will slow down run time.

  • If you see negative values/spikes/stability issues (NANs) in your results then increase the numBoundaryElements (make sure to increase numElements so that numBoundaryElementsremains less than numElements). Also, if this issue area is outside of the boundaryLayerWidth region, increase boundaryLayerWidth so that it covers these issue areas.

NOTE: will slow down run time