(* Given potential A-, B-, and X-site constituent elements, this code finds every alloy with 1 A-site, 1 B-site, and 3 X-site constituents. It saves the alloy if it consists entirely of experimentally-observed end-members, and computes the configurational entropy stabilization (ES) term at 300 K. If the unit cell volumes of all end-members are known, it calculates their mean, standard deviation, and coefficient of variation. If the band gaps of all end-members are known, it calculates their mean.*)
dat={{"Na","Ni","F",235.03`,""},{"Na","Mg","F",234.87`,""},{"Na","Cu","F",245.83`,""},{"Na","Zn","F",246.26`,""},{"Na","Co","F",245.3`,""},{"Na","Fe","F",254.63`,""},{"Na","V","F",257.7`,""},{"Na","Cr","F",255.915`,""},{"Na","Mn","F",266.54`,""},{"Ag","Co","F",264.72`,""},{"Ag","Ni","F",256.76`,""},{"Ag","Mg","F",253.76`,""},{"Ag","Zn","F",270.28`,""},{"Ag","Mn","F",343.04`,""},{"K","Co","F",276.76`,""},{"K","Ni","F",269.52`,""},{"K","Mg","F",266.4`,""},{"K","Cu","F",269.4`,""},{"K","Zn","F",282.12`,""},{"K","Fe","F",289.08`,""},{"K","V","F",301.76`,""},{"K","Cr","F",308.4`,""},{"K","Mn","F",308.`,""},{"K","Cd","F",342.48`,""},{"K","Ca","F",346.66`,""},{"K","Hg","F",389.64`,""},{"Tl","Co","F",296.44`,""},{"Tl","Cu","F",288.96`,""},{"Tl","Fe","F",308.04`,""},{"Tl","Cr","F","",""},{"Tl","Mn","F",321.64`,""},{"Tl","Cd","F",357.5`,""},{"Rb","Co","F",307.3333333333333`,""},{"Rb","Cu","F",284.08`,""},{"Ag","Cu","F",257.64`,""},{"Rb","Zn","F",307.5133333333333`,""},{"Rb","Fe","F",300.76`,""},{"Rb","V","F",312.48`,""},{"Rb","Cr","F",319.48`,""},{"Rb","Mn","F",320.76`,""},{"Rb","Cd","F",365.2`,""},{"Rb","Ca","F",368.68`,""},{"Rb","Hg","F",395.8`,""},{"Rb","Pb","F",459.64`,""},{"Cs","Be","F",388.93`,""},{"Cs","Mg","F",307.56`,""},{"Cs","Cd","F",380.`,""},{"Cs","Ca","F",384.76`,""},{"Cs","Hg","F",408.76`,""},{"Cs","Sr","F",451.6`,""},{"Cs","Pb","F",471.32`,""},{"K","Fe","Cl",492.97`,""},{"K","Mn","Cl",509.05`,""},{"K","Cd","Cl",546.83`,""},{"K","Ca","Cl",587.95`,""},{"Tl","Mn","Cl",525.89`,""},{"Tl","Cd","Cl",563.38`,""},{"Rb","Cr","Cl",573.17`,""},{"Rb","Mn","Cl",543.`,""},{"Rb","Cd","Cl",581.1`,""},{"Rb","Ca","Cl",638.78`,""},{"Cs","Mn","Cl",585.4755555555555`,""},{"Cs","Cd","Cl",625.2666666666667`,""},{"Cs","Ca","Cl",654.16`,8.1`},{"Cs","Hg","Cl",630.84`,""},{"Cs","Sn","Cl",711.88`,2.8`},{"Cs","Eu","Cl",722.69`,3.09`},{"Cs","Sr","Cl",732.88`,7.7`},{"Cs","Pb","Cl",754.08`,2.85`},{"Rb","Cd","Br",675.15`,""},{"Cs","Cd","Br",711.24`,""},{"Cs","Hg","Br",738.84`,3.`},{"Cs","Sn","Br",815.68`,1.75`},{"Cs","Pb","Br",805.45`,2.36`},{"Tl","Mn","I",727.35`,""},{"Tl","Pb","I",871.24`,2.25`},{"Rb","Sn","I",893.32`,1.62`},{"Cs","Sn","I",993.64`,1.31`},{"Rb","Tm","I",795.51`,""},{"Rb","Dy","I",860.52`,""},{"Cs","Ca","I",932.4`,""},{"Cs","Yb","I",933.6`,""},{"Cs","Tm","I",880.11`,""},{"Cs","Dy","I",891.96`,""},{"Cs","Pb","I",960.71`,1.73`},{"Cs","Ge","Cl",672.1466666666668`,3.43`},{"Cs","Ge","Br",741.9600000000002`,2.38`},{"Cs","Ge","I",906.5733333333333`,1.63`},{"Cs","Au","I",895.13`,1.31`},{"Cs","Ni","Cl",552.86`,""},{"Cs","Ga","Cl","",""},{"Cs","In","Cl",696.73`,""},{"Cs","Mn","Br",705.64`,""},{"Cs","Ni","Br",650.02`,""},{"Cs","In","Br",795.52`,""},{"Cs","Mg","I",865.54`,""},{"Cs","V","I",828.9`,""},{"Cs","Mn","I",848.66`,""},{"Cs","Cd","I","",""},{"K","Ge","Cl",612.`,""},{"K","Sn","Cl",700.959794944`,""},{"Rb","Ge","Br",742.79`,2.74`},{"K","Pb","Br",784.4917639999999`,""},{"K","Sn","Br",710.1`,""},{"Rb","Cd","I","",""},{"Rb","Hg","I",959.4`,""},{"K","Sn","I",862.75`,""},{"Li","Ba","F",266.24`,""},{"In","Ca","Br",678.51`,""},{"In","Cd","Br",632.19`,""},{"In","Cr","Br",617.05`,""},{"Cs","Ag","Cl",603.61`,""},{"Cs","Ag","F",376.36`,""},{"Cs","Au","Br",737.38`,""},{"Cs","Au","Cl",654.19`,""},{"Cs","Ca","Br",769.44`,""},{"Cs","Co","Cl",555.38`,""},{"Cs","Co","F",345.67111111111114`,""},{"Cs","Cr","Br",677.16`,""},{"Cs","Cr","Cl",584.74`,""},{"Cs","Cu","Br",665.265`,""},{"Cs","Cu","Cl",581.3733333333333`,""},{"Cs","Dy","Br",736.62`,""},{"Cs","Eu","Br",832.7`,""},{"Cs","Eu","F",453.36`,""},{"Cs","Fe","Br",618.2`,""},{"Cs","Fe","Cl",569.82`,""},{"Cs","Fe","F",340.32666666666665`,""},{"Cs","Mg","Br",701.44`,""},{"Cs","Mg","Cl",596.78`,""},{"Cs","Mn","F",355.9266666666667`,""},{"Cs","Ni","F",367.84`,""},{"Cs","Pd","Cl",689.47`,""},{"Cs","Sc","Cl",607.48`,""},{"Cs","Sm","Cl",665.44`,""},{"Cs","Sr","I",999.33`,""},{"Cs","Ti","Br",678.8`,""},{"Cs","Ti","Cl",575.92`,""},{"Cs","Ti","I",843.44`,""},{"Cs","Tl","F",464.775`,""},{"Cs","Tm","Cl",599.64`,""},{"Cs","V","Br",680.72`,""},{"Cs","V","Cl",590.08`,""},{"Cs","Yb","Br",755.4`,""},{"Cs","Yb","Cl",638.92`,""},{"Cs","Yb","F",366.64`,""},{"In","Fe","Br",523.77`,""},{"K","Ag","F",340.09`,""},{"K","Au","I",843.44`,""},{"K","Cu","Cl",523.89`,""},{"K","Fe","Br",584.01`,""},{"K","In","Br",739.45`,""},{"K","Mg","Cl",498.96`,""},{"K","Mn","Br",599.18`,""},{"K","Ni","Cl",488.6066666666666`,""},{"K","Pd","F",320.08`,""},{"K","Sn","F",402.485`,""},{"K","Tc","Cl",549.345`,""},{"K","Ti","Br",614.6266666666667`,""},{"K","Ti","Cl",518.9333333333333`,""},{"K","Ti","I",794.7533333333334`,""},{"K","Tm","I",773.85`,""},{"Li","Ga","Br",578.93`,""},{"Li","Ga","Cl",471.295`,""},{"Li","Ga","I",726.11`,""},{"Li","Sc","I",650.72`,""},{"In","Mg","Br",605.54`,""},{"In","Mn","Br",596.85`,""},{"Na","Hg","Cl",573.54`,""},{"Na","Mn","Cl",480.6933333333333`,""},{"Rb","Ag","F",349.55`,""},{"Rb","Au","Br",729.83`,""},{"Rb","Au","I",875.14`,""},{"Rb","Ca","I",878.95`,""},{"Rb","Co","Cl",523.3`,""},{"Rb","Cr","I",793.27`,""},{"Rb","Cu","Cl",548.07`,""},{"Rb","Ge","Cl",678.48`,""},{"Rb","Ge","I",823.34`,""},{"Rb","Mg","Cl",539.81`,""},{"Rb","Mg","F",281.4`,""},{"Rb","Mn","Br",663.28`,""},{"Rb","Ni","Br",602.52`,""},{"Rb","Ni","Cl",512.56`,""},{"Rb","Ni","F",442.23`,""},{"Rb","Pb","I",919.08`,2.`},{"Rb","Pd","F",328.28`,""},{"Rb","Ti","Br",629.6`,""},{"Rb","Ti","Cl",533.96`,""},{"Rb","Ti","I",808.7866666666667`,""},{"Rb","V","Br",646.9933333333333`,""},{"Rb","V","Cl",552.42`,""},{"Rb","V","I",798.9266666666667`,""},{"Rb","Yb","Br",713.9`,""},{"Rb","Yb","F",352.16`,""},{"Rb","Yb","I",869.74`,""},{"Tl","Cd","Br",641.98`,""},{"Tl","Cd","I",777.88`,""},{"Tl","Co","Cl",496.56`,""},{"Tl","Fe","Br",562.1266666666667`,""},{"Tl","Fe","I",635.31`,""},{"Tl","Ge","I",768.29`,""},{"Li","Co","Br",227.67292943968118`,""},{"Na","Cr","Cl","",""},{"Cs","Zn","Cl",467.14702028799996`,""},{"Ag","Pb","Br",560.5495464347999`,""},{"Cs","Ba","Br",1019.360416`,""},{"Cs","Ba","Cl",838.3383360000003`,""},{"Cs","Ni","I",744.78`,""},{"Cu","Cd","Cl",450.92249999999996`,""},{"K","Ba","F",433.8525`,""},{"K","Cd","I","",""},{"K","Co","Br","",""},{"K","Sr","Cl",682.7072092919999`,""},{"Li","Ca","Br",734.9391764999998`,""},{"Li","Ca","Cl",634.2401328124998`,""},{"Li","Mg","Br",469.3005`,""},{"Li","Mg","Cl",397.14`,""},{"Li","Mg","F",220.47717828477198`,""},{"Li","Mn","F",241.505`,""},{"Li","Pb","Br",117.48455852697764`,""},{"Li","V","Cl","",""},{"Na","Ca","Br",281.0512880296336`,""},{"Na","Ca","Cl","",""},{"Na","Cd","Cl","",""},{"Na","Ni","Cl","",""},{"Rb","Be","Cl",242.328798`,""},{"Rb","Be","F",231.24945199747606`,""},{"Rb","Eu","Cl",723.68`,""},{"Rb","Fe","Cl",495.54`,""},{"Rb","Sr","Cl",697.65`,""},{"Rb","Sr","F",477.8358125`,""},{"Tl","Mg","Cl",511.7`,""},{"Tl","Pb","Cl",576.63`,""},{"Tl","Sr","Cl","",""},{"Cs","Eu","I",777.259456512`,""},{"Cs","Pd","F",344.08`,""},{"Cs","Sr","Br",844.87`,""},{"Cs","Tl","Cl",730.22`,""},{"Cs","Tm","Br",704.68`,""},{"K","Ca","Br",674.88`,""},{"K","Ca","I",842.54`,""},{"K","Dy","Br",682.28`,""},{"K","Ge","F",352.7221834039999`,""},{"K","Sr","F","",""},{"Li","Zn","F","",""},{"Na","Sr","F","",""},{"Rb","Ca","Br",723.13`,""},{"Rb","Pb","Br",771.86`,""},{"Rb","Pb","Cl",749.8`,""},{"Rb","Sr","Br",805.749140304`,""},{"Rb","Tm","Cl",619.030872292`,""},{"Tl","Hg","F",379.445`,""},{"Tl","Mg","F",285.24`,""},{"Tl","V","Cl",537.1`,""},{"K","Cd","Br",595.047532872`,""},{"K","Dy","I",798.22`,""},{"K","Pb","F","",""},{"K","Pb","I",882.24`,""},{"K","V","Cl",527.86`,""},{"K","Yb","I",834.62`,""},{"Na","Ti","Cl","",""},{"Tl","Ca","Br",685.09`,""},{"Tl","Fe","Cl","",""},{"Tl","Hg","Br",635.1970215652921`,2.44`},{"Tl","Hg","Cl",604.96`,""},{"Tl","Mn","Br",578.7014979899999`,""},{"Tl","Zn","F",296.36`,""},{"Cs","Pd","Br",607.52`,""},{"Cs","Sc","Br",700.82`,""},{"Cs","Sn","F",966.04`,""},{"In","Sn","Br",785.0733333333333`,""},{"In","Sn","Cl",738.56`,""},{"K","Cr","Cl",489.50666666666666`,""},{"Rb","Cu","Br",558.08`,""},{"Rb","Sn","Br",740.72`,""},{"Rb","Sn","Cl",702.0466666666666`,""},{"Rb","Sn","F",444.06`,""},{"Tl","Ca","Cl",592.61`,""},{"Tl","Cu","Cl",535.32`,""},{"Tl","Ni","F",284.44`,""},{"Tl","Pd","F",329.52`,""},{"Tl","Sn","F",408.2625`,""}};(*this is the table of experimentally observed inorganic halide perovskite end-members: A-site constituent, B-site constituent, X-site constituent, unit cell volume (A^3), experimental band gap*)
apot={"Ag","Cs","Cu","In","K","Li","Na","Rb","Tl"};(*apot, potential A-site constituents*)
bpot={"Ag","Au","Ba","Be","Ca","Cd","Co","Cr","Cu","Dy","Eu","Fe","Ga","Ge","Hg","In","Mg","Mn","Ni","Pb","Pd","Sc","Sm","Sn","Sr","Tc","Ti","Tl","Tm","V","Yb","Zn"};(*bpot, potential B-site constituents*)
xpot={"Br","Cl","F","I"};(*xpot, potential X-site constituents*)
alist=apot;(*alist, list of A-site constituents*)
blist=bpot;(*blist, list of B-site constituents*)
xlist=DeleteCases[Flatten[Table[Sort[{xpot[[i]],xpot[[j]],xpot[[k]]}],{i,1,Length[xpot],1},{j,1,Length[xpot],1},{k,1,Length[xpot],1}],2],{col1_,col2_,col3_}/;(col1==col2)||(col1==col3)||(col2==col3)];
xlist=DeleteDuplicates[xlist];(*xlist, list of X-site constituents = {{Br,Cl,F},{Br,Cl,I},{Br,F,I},{Cl,F,I}}*)
results={{"Composition","Unit cell volume mean (A^3)","Unit cell volume standard deviation (A^3)","Unit cell volume coefficient of variation (UCV)", "Entropy stabilization (ES) term at 300 K (kJ/mol)","Band gap mean (eV)"}};
SetSharedVariable[results];
ParallelDo[
a1=alist[[anum]];
achem=a1;
acomp=1;
b1=blist[[bnum]];
bchem=b1;
bcomp=1;
x1=xlist[[xnum,1]];x2=xlist[[xnum,2]];x3=xlist[[xnum,3]];
xchem=x1<>x2<>x3;
xcomp=3;
vlist=Cases[dat,{a_,b_,x_,v_,e_}/;(a==a1&&b==b1&&x==x1)||(a==a1&&b==b1&&x==x2)||(a==a1&&b==b1&&x==x3)][[All,4]];(*finds the alloy's constitive end-members in the table of experimentally-observed halide perovskites and saves each unit cell volume*)eglist=Cases[dat,{a_,b_,x_,v_,e_}/;(a==a1&&b==b1&&x==x1)||(a==a1&&b==b1&&x==x2)||(a==a1&&b==b1&&x==x3)][[All,5]];(*finds the alloy's constitive end-members in the table of experimentally-observed halide perovskites and saves each band gap*)
If[Length[vlist]==acomp*bcomp*xcomp(*if the number of end-members found in the experimentally-observed table is equal to the number of end-members, then add a new row to the results*),vmean=Mean[vlist];(*unit cell volume mean (A^3)*)vstdev=StandardDeviation[vlist]*((1-(1/(acomp*bcomp*xcomp)))^0.5);(*unit cell volume standard deviation (A^3), where sample standard deviation is converted to population standard deviation*)ucv=vstdev/vmean;(*unit cell volume coefficient of variation (UCV)*)If[NumberQ[vmean],0,vmean="NA";vstdev="NA";ucv="NA";];egmean=Mean[eglist];(*band gap mean (eV)*)If[NumberQ[egmean],0,egmean="NA"];AppendTo[Unevaluated[results],{achem<>bchem<>xchem(*alloy composition*),vmean,vstdev,ucv,300*8.31446261815324*(0.2*(acomp*(1/acomp)*Log[1/acomp])+0.2*(bcomp*(1/bcomp)*Log[1/bcomp])+0.6*(xcomp*(1/xcomp)*Log[1/xcomp]))/1000(*entropy stabilization (ES) term at 300 K*),egmean(*band gap mean*)}];,0];,{anum,1,Length[alist],1},{bnum,1,Length[blist],1},{xnum,1,Length[xlist],1}];(*check every possible combination of constitutive elements against the table of experimentally-observed halide perovskites*)
TableForm[results]