(*
Upconversion LED calculator
Laszlo Frazer 2018 laszlo@laszlofrazer.com

If you use this program, please cite the paper which describes it:

Frazer, L., (2018). Photochemical Upconversion Light Emitting Diode (LED): Theory of Triplet Annihilation Enhanced by a Cavity. Advanced Theory and Simulations. 10.1002/adts.201800099.

Tested in Mathematica 11.3
*)

(*These are the physical properties of your upconversion LED.  This is probably the part you want to edit.*)
Pd=6.6;(*W*)
k1=10^4;(*per s*)
k2=10^(-12);(*cm3 per s*)
S=10^(-3);(*M*)
Ns=10^(-10);(*mol*)
Ev=0.37;(*eV*)
Ea=-1;(*eV*)
Ed=1.88;(*eV*)
EU=2.5;(*eV*)
epsilon=58000;(*/M/cm*)
length=10^(-3);(*cm also known as x*)
AL=10^(-6);(*m*m*)
Ac=10^(-3);(*m*m*)
alphaL=0.5; (*dimensionless*)
alphac=0.01 (*dimensionless*)
E0r=.44; (*dimensionless*)
ke=-.005; (*dimensionless*)
kh=.56; (*dimensionless*)
T0=300;(*K*)
Ta=300;(*K*)
Rjc=2.8;(*K/W*)
Rhs=1;(*K/W*)
RUc=10;(*K/W*)
RUj=10;(*K/W*)

(*Well-known constants*)
eVinJ=1.60218*10^(-19);(*J per eV*)
avogadro=6.02214*10^(23);
litreincm=1000;(*litre/cm^3*)
kB=8.61733034*10^(-5);(*eV/K*)

(*convert units*)
Ed=Ed*eVinJ;
EU=EU*eVinJ;
k2=10^(-6)*k2;(*m^3 per s*)
Sinmolperm3=S*10^(3);(*mol per m^3*)

(*this part is the theory*)system={-PhiUC+.5*PhiTTA,-PhiTTA+k2*boltzmann2*A/(k2*boltzmann2*A+k1*boltzmann1),-A+(-k1*boltzmann1+Sqrt[(k1*boltzmann1)^2+4.*k2*boltzmann2*kphi*Sinmolperm3])/(2.*k2*boltzmann2),-kphi+PhicL*phir/(Ed*Ns),-PUC+phir*((1-PhicL)+PhicL*(1-2*PhiUC)+PhicL*PhiUC*s),-phir+E0r*(1.+ke*(Ta-T0+Rjc*(kh*Pd-PUC)+Rhs*kh*Pd))*Pd,-TU+Ta+Rhs*kh*Pd+RUc*PUC,-boltzmann1+Exp[-Ev/(kB*TU)]/Exp[-Ev/(kB*T0)],-boltzmann2+TU*Exp[-Ea/(kB*TU)]/(T0*Exp[-Ea/(kB*T0)]) };

(*This part solves the theory.*)
s=(2*Ed-EU)/(2*Ed);
PhicL=(1-Exp[-epsilon*S*length])/(1-(Exp[-epsilon*S*length])*(1-(AL*alphaL+Ac*alphac)/(AL+Ac)));

(*You will likely need to adjust the initialization of FindRoot.*)
solution=FindRoot[system,{{PhiUC,.457},{PhiTTA,0.914},{A,3.11*10^(24)},{kphi,4.59*10^(30)},{PUC,1.7},{phir,2.76},{TU,320.},{boltzmann1,2.53},{boltzmann2,.086}},MaxIterations->10000000];

(*Results*)
(*Now we will print out the interesting parts of the solution.
First, the upconversion quantum efficiency (dimensionless)*)
PhiUC/.solution

(*The upconverion LED spectral irradiance (in Watts)*)
(PhiUC/.solution)*(phir/.solution)*PhicL*EU/Ed

(*The cavity yield (dimensionless)*)
PhicL

(*The anabathmophore temperature (Kelvin)*)
TU/.solution

(*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*)