|
k-dot-p 0.1
|
00001 /* 00002 *Performs a self-consistent potential calculation 00003 00004 Copyright (C) 2010 Joseph Pingenot 00005 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Affero General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Affero General Public License for more details. 00015 00016 You should have received a copy of the GNU Affero General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 00022 #include <libmetacalc/calculation_self_consistent_potential.h++> 00023 00024 #include <math.h> 00025 #include <libkdotp/physical_constants.h++> 00026 00027 using namespace kdp::constants; 00028 00029 namespace kdotp { 00030 namespace libmetacalc { 00031 namespace self_consistent { 00032 00033 double get_Ef_2D(unsigned int Neigs, double* eigs, double* avg_ooms, int* last_eig, double total_density) { 00034 double sumA=0; 00035 double sumB=0; 00036 double Ef; 00037 for(unsigned int i=0; i<Neigs; i++) { 00038 /*Sum up from the individual subbands*/ 00039 fprintf(stderr, "i=%u\n", i); 00040 sumA = sumB = 0; 00041 for(int j=i; j>=0; j--) { 00042 fprintf(stderr, "\tj=%d sumA=%g sumB=%g avg_ooms[%d]=%g eigs[%d]=%g\n", j, sumA, sumB, j, avg_ooms[j], j, eigs[j]); 00043 sumA += eigs[j]/avg_ooms[j]; 00044 sumB += 1.0/avg_ooms[j]; 00045 } 00046 Ef = (total_density*hbar*hbar/(2*M_PI*m0) + sumA)/sumB; 00047 fprintf(stderr, " Ef=%g: ", Ef); 00048 if((i==(Neigs-1)) || (Ef <= eigs[i+1])) { 00049 if(i==(Neigs-1)) { 00050 fprintf(stderr, " <eigs[%d]=%g\n", i+1, eigs[i+1]); 00051 }else{ 00052 fprintf(stderr, " i==Neigs(%u)\n", Neigs); 00053 } 00054 *last_eig = i; 00055 return Ef; 00056 }else{ 00057 fprintf(stderr, "\n"); 00058 } 00059 } 00060 *last_eig=Neigs+1; 00061 return 0; 00062 } 00063 00064 /**callback for mixing the potentials (search for "Mix the potentials" below) 00065 *\note simple: just add the two together! 00066 */ 00067 void potential_mixing_callback(int X, unsigned N, double dx, double *restrict to, double from, void* mixing_pct) { 00068 *to = from + (*to - from)*(*(double*)mixing_pct); 00069 } 00070 00071 } 00072 } 00073 }