function [GMinput]=PNDIODE_data(Ln,Lp,Td,vn,vp,Na,Nd);

% [GMinput]=PNDIODE_data(Ln,Lp,Td,Na,Nd,vn,vp);
%

% This file is part of 
%
%            SECS2D - A 2-D Drift--Diffusion Semiconductor Device Simulator
%         -------------------------------------------------------------------
%            Copyright (C) 2004-2006  Carlo de Falco
%
%
%
%  SECS2D 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; either version 2 of the License, or
%  (at your option) any later version.
%
%  SECS2D 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.
%
%  You should have received a copy of the GNU General Public License
%  along with SECS2D; if not, write to the Free Software
%  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
%  USA

% mesh

mesh = PNDIODE(Ln,Lp,Td);


load (file_in_path(LOADPATH,"constants.mat")); 

NSides  = [4]; %N-contact
PSides  = [6]; %P-contact

Dsides   = [ NSides PSides]; 
SiDsides = Dsides;
Sisides =  [ 1:7 ];

x         = mesh.p(1,:)';
Nnodes    = size(mesh.p,2);
Nelements = size(mesh.t,2);
Simesh    = mesh;
Sinodes   = 1:Nnodes;
Sielements= 1:Nelements;

[tmpmesh,nside] =Usubmesh(Simesh,2,1,1); %mesh elements and nodes in the N-doped region
clear tmpmesh;

[tmpmesh,pside] =Usubmesh(Simesh,2,2,1); %mesh elements and nodes in the P-doped region
clear tmpmesh;

data.D            = 0*x+Nd; %Net doping profile (N-region)
data.D(pside)     = -Na;    %Net doping profile (P-region)

data.n = data.D .* (data.D > 0);  %Initial guess for majority charge carriers
data.p = -data.D .* (data.D < 0);

data.n = data.n - (ni^2 ./ data.D) .* (data.D < 0); %Initial guess for minority charge carriers
data.p = data.p + (ni^2 ./ data.D) .* (data.D > 0);

data.Fn             = 0*x+vn; %Initial guess for Fermi levels
data.Fn(pside)      = vp;

data.Fp= data.Fn;


data.V = data.Fn + Vth * log(data.n/ni); %Initial guess for electric potential

data.un=Udopdepmob (Simesh,un,mudopparn,abs(data.D)); %mobilities
data.up=Udopdepmob (Simesh,up,mudopparp,abs(data.D));

data.n0 = data.n*0+ni; %intrinsic densities (they can be different for quantum corrected models but are the same for classical models)
data.p0 = data.n*0+ni;

[idata,imesh]= Uscaling(mesh,data);    %adimensionalization
imesh        = Umeshproperties(imesh); %pre-computation of mesh properties
Simesh       = imesh;

%put all input data in one struct
GMinput.toll          = 1e-3;
GMinput.ptoll         = 1e-10;
GMinput.maxit         = 10;
GMinput.pmaxit        = 100;
GMinput.verbose       = 2;
GMinput.options.holes = 1;
GMinput.options.SRH   = 1;

GMinput.mesh       = imesh;
GMinput.Dsides     = Dsides;
GMinput.Simesh     = Simesh;
GMinput.Sinodes    = Sinodes;
GMinput.Sielements = Sielements;
GMinput.SiDsides   = SiDsides;
GMinput.data       = idata;

GMinput.NSides  = NSides;
GMinput.PSides  = PSides;

