static const double cm=1;
static const double volt=1;
static const double e=1.6e-19*
C;
double V(double *coordinates, double *parameters)
{
double r = coordinates[0];
double ri= parameters[0];
double ro= parameters[1];
double vi= parameters[2];
double vo= parameters[3];
double rho=parameters[4];
double c1= a*ri*ro*(ro+ri)/6-(vo-vi)*ri*ro/(ro-ri);
double c2= (vo*ro-vi*ri)/(ro-ri)-a*(ro*ro+ro*ri+ri*ri)/6;
return a*r*r/6 + c1/r + c2;
}
double E(double *coordinates, double *parameters)
{
double r = coordinates[0];
double ri= parameters[0];
double ro= parameters[1];
double vi= parameters[2];
double vo= parameters[3];
double rho=parameters[4];
double c1= a*ri*ro*(ro+ri)/6-(vo-vi)*ri*ro/(ro-ri);
return -a*r/3 + c1/r/r;
}
const int n=5;
double rho[n]={-1.5e10*e/
cm3, 0, 1.5e10*e/
cm3, 3.5e10*e/
cm3, 6e10*e/
cm3};
void drawV()
{
TLegend *l = new TLegend(0.75,0.55,0.98,0.98);
l->SetHeader("Impurity [cm^{-3}]");
TF1 *fV[n]={0};
double ri[n], ro[n], vi[n], vo[n]={0};
for (int i=0; i<n; i++) {
fV[i] = new TF1(Form("fV%d",i), V, ri[i], ro[i], 5);
fV[i]->SetParameters(ri[i],ro[i],vi[i],vo[i],rho[i]);
fV[i]->SetLineStyle(i+1);
fV[i]->SetLineColor(i+1);
if (i+1==5) fV[i]->SetLineColor(28);
if (i==0) fV[i]->Draw();
else fV[i]->Draw("same");
l->AddEntry(fV[i],Form(
"%8.1e",-rho[i]/e*
cm3),
"l");
}
fV[0]->SetTitle("");
fV[0]->GetXaxis()->SetTitle("Radius [cm]");
fV[0]->GetYaxis()->SetTitle("Voltage [V]");
l->Draw();
gPad->Print("Vr.png");
}
void drawE()
{
TCanvas *c = new TCanvas;
TLegend *l = new TLegend(0.75,0.55,0.98,0.98);
l->SetHeader("Impurity [cm^{-3}]");
TF1 *fE[n]={0};
double ri[n], ro[n], vi[n], vo[n]={0};
for (int i=0; i<n; i++) {
fE[i] = new TF1(Form("fE%d",i), E, ri[i], ro[i], 5);
fE[i]->SetParameters(ri[i],ro[i],vi[i],vo[i],rho[i]);
fE[i]->SetLineStyle(i+1);
fE[i]->SetLineColor(i+1);
if (i+1==5) fE[i]->SetLineColor(28);
if (i==0) fE[i]->Draw();
else fE[i]->Draw("same");
l->AddEntry(fE[i],Form(
"%8.1e",-rho[i]/e*
cm3),
"l");
}
fE[0]->SetTitle("");
fE[0]->GetXaxis()->SetTitle("Radius [cm]");
fE[0]->GetYaxis()->SetTitle("Electric field [V/cm]");
l->Draw();
c->Print("Er.png");
}
void spherical()
{
gROOT->SetStyle("GeFiCa");
gStyle->SetTitleOffset(1.2,"Y");
gStyle->SetPadRightMargin(0.01);
gStyle->SetPadLeftMargin(0.12);
gStyle->SetPadTopMargin(0.01);
gStyle->SetPadBottomMargin(0.11);
drawV();
drawE();
}