changeset 9872:e567b7ac3d1f octave-forge

new version of secs1d
author cdf
date Sun, 25 Mar 2012 22:44:30 +0000
parents 75c61ad0e76b
children 03c9c820682e
files extra/secs1d/DESCRIPTION extra/secs1d/INDEX extra/secs1d/README extra/secs1d/bak/DDG/DDGelectron_driftdiffusion.m extra/secs1d/bak/DDG/DDGgummelmap.m extra/secs1d/bak/DDG/DDGhole_driftdiffusion.m extra/secs1d/bak/DDG/DDGn2phin.m extra/secs1d/bak/DDG/DDGnlpoisson.m extra/secs1d/bak/DDG/DDGp2phip.m extra/secs1d/bak/DDG/DDGphin2n.m extra/secs1d/bak/DDG/DDGphip2p.m extra/secs1d/bak/DDG/DDGplotresults.m extra/secs1d/bak/DDN/DDNnewtonmap.m extra/secs1d/bak/PKG_ADD extra/secs1d/bak/Utilities/Ubern.m extra/secs1d/bak/Utilities/Ubernoulli.m extra/secs1d/bak/Utilities/Ucompconst.m extra/secs1d/bak/Utilities/Ucomplap.m extra/secs1d/bak/Utilities/Ucompmass.m extra/secs1d/bak/Utilities/Udriftdiffusion.m extra/secs1d/bak/Utilities/Umediaarmonica.m extra/secs1d/bak/Utilities/Uscharfettergummel.m extra/secs1d/bak/Utilities/constants.m extra/secs1d/bak/secs1d_demo_pndiode.m extra/secs1d/bak/src/Makefile extra/secs1d/bak/src/Ubern.cc extra/secs1d/doc/COPYING.tex extra/secs1d/doc/function/images/secs1d_dd_gummel_map_205.png extra/secs1d/doc/function/images/secs1d_dd_newton_819.png extra/secs1d/doc/function/images/secs1d_nlpoisson_newton_85.png extra/secs1d/doc/function/secs1d_dd_gummel_map.tex extra/secs1d/doc/function/secs1d_dd_newton.tex extra/secs1d/doc/function/secs1d_nlpoisson_newton.tex extra/secs1d/doc/function/secs1d_physical_constants.m.tex extra/secs1d/doc/function/secs1d_silicon_material_properties.m.tex extra/secs1d/doc/manual.pdf extra/secs1d/doc/manual.tex extra/secs1d/inst/DDG/DDGelectron_driftdiffusion.m extra/secs1d/inst/DDG/DDGgummelmap.m extra/secs1d/inst/DDG/DDGhole_driftdiffusion.m extra/secs1d/inst/DDG/DDGn2phin.m extra/secs1d/inst/DDG/DDGnlpoisson.m extra/secs1d/inst/DDG/DDGp2phip.m extra/secs1d/inst/DDG/DDGphin2n.m extra/secs1d/inst/DDG/DDGphip2p.m extra/secs1d/inst/DDG/DDGplotresults.m extra/secs1d/inst/DDN/DDNnewtonmap.m extra/secs1d/inst/Utilities/Ubern.m extra/secs1d/inst/Utilities/Ubernoulli.m extra/secs1d/inst/Utilities/Ucompconst.m extra/secs1d/inst/Utilities/Ucomplap.m extra/secs1d/inst/Utilities/Ucompmass.m extra/secs1d/inst/Utilities/Udriftdiffusion.m extra/secs1d/inst/Utilities/Umediaarmonica.m extra/secs1d/inst/Utilities/Uscharfettergummel.m extra/secs1d/inst/Utilities/constants.m extra/secs1d/inst/secs1d.m extra/secs1d/inst/secs1d_dd_gummel_map.m extra/secs1d/inst/secs1d_dd_newton.m extra/secs1d/inst/secs1d_demo_pndiode.m extra/secs1d/inst/secs1d_nlpoisson_newton.m extra/secs1d/inst/secs1d_physical_constants.m extra/secs1d/inst/secs1d_silicon_material_properties.m extra/secs1d/src/Makefile extra/secs1d/src/Ubern.cc
diffstat 65 files changed, 3827 insertions(+), 1783 deletions(-) [+]
line wrap: on
line diff
--- a/extra/secs1d/DESCRIPTION	Sun Mar 25 22:35:18 2012 +0000
+++ b/extra/secs1d/DESCRIPTION	Sun Mar 25 22:44:30 2012 +0000
@@ -1,12 +1,12 @@
 Name: SECS1D
-Version: 0.0.8
-Date: 2008-08-23
+Version: 0.0.9
+Date: 2012-03-25
 Author: Carlo de Falco
 Maintainer: Carlo de Falco
 Title: SEmi Conductor Simulator in 1D 
 Description: A Drift-Diffusion simulator for 1d semiconductor devices
 Categories: Electrical Engineering
-Depends: octave (>= 2.9.17)
+Depends: octave (>= 3.0), bim
 Autoload: no
 License: GPL version 2 or later
 
--- a/extra/secs1d/INDEX	Sun Mar 25 22:35:18 2012 +0000
+++ b/extra/secs1d/INDEX	Sun Mar 25 22:44:30 2012 +0000
@@ -1,23 +1,9 @@
 secs1D >> SEmiConductor Simulator in 1D
-DDG
- DDGelectron_driftdiffusion
- DDGgummelmap
- DDGhole_driftdiffusion
- DDGn2phin
- DDGnlpoisson
- DDGp2phip
- DDGphin2n
- DDGphip2p
- DDGplotresults
-DDN
- DDNnewtonmap
-Utilities
- constants
- Ubern
- Ubernoulli
- Ucompconst
- Ucomplap
- Ucompmass
- Udriftdiffusion
- Umediaarmonica
- Uscharfettergummel
+Drift-Diffusion solvers
+ secs1d_dd_gummel_map
+ secs1d_dd_newton
+non-linear Poisson solver
+ secs1d_nlpoisson_newton
+Physical constants and material data
+ secs1d_physical_constants.m
+ secs1d_silicon_material_properties.m
\ No newline at end of file
--- a/extra/secs1d/README	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-
            SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator 
         -------------------------------------------------------------------
            Copyright (C) 2004-2007  Carlo de Falco

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.

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.

You should have received a copy of the GNU General Public License
along with this program (see the file COPYING); if not, see
<http://www.gnu.org/licenses/>.

For more information, you may also contact me by email at

          defalco@math.uni-wuppertal.de
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGelectron_driftdiffusion.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,89 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{n}} = DDGelectron_driftdiffusion(@var{psi},@var{x},@var{ng},@var{p},@var{ni},@var{tn},@var{tp},@var{un})
+##
+## Solve the continuity equation for electrons
+##
+## Input:
+## @itemize @minus
+## @item psi: electric potential
+## @item x: integration domain
+## @item ng: initial guess and BCs for electron density
+## @item p: hole density (for SRH recombination)
+## @end itemize
+##
+## Output:
+## @itemize @minus
+## @item n: updated electron density
+## @end itemize
+##
+## @end deftypefn
+
+function n = DDGelectron_driftdiffusion(psi,x,ng,p,ni,tn,tp,un)
+
+nodes        = x;
+Nnodes     =length(nodes);
+
+elements   = [[1:Nnodes-1]' [2:Nnodes]'];
+Nelements=size(elements,1);
+
+Bcnodes = [1;Nnodes];
+
+nl = ng(1);
+nr = ng(Nnodes);
+h=nodes(elements(:,2))-nodes(elements(:,1));
+
+c=1./h;
+Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
+Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
+
+
+d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
+d1    = [1000;-c.* Bpos];
+dm1   = [-c.* Bneg;1000];
+
+A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
+b = zeros(Nnodes,1);%- A * ng;
+
+  ## SRH Recombination term
+SRHD = tp * (ng + ni) + tn * (p + ni);
+SRHL = p ./ SRHD;
+SRHR = ni.^2 ./ SRHD;
+
+ASRH = Ucompmass (nodes,Nnodes,elements,Nelements,SRHL,ones(Nelements,1));
+bSRH = Ucompconst (nodes,Nnodes,elements,Nelements,SRHR,ones(Nelements,1));
+
+A = A + ASRH;
+b = b + bSRH;
+
+  ## Boundary conditions
+b(Bcnodes)   = [];
+b(1)         = - A(2,1) * nl;
+b(end)       = - A(end-1,end) * nr;
+A(Bcnodes,:) = [];
+A(:,Bcnodes) = [];
+
+n = [nl; A\b ;nr];
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGgummelmap.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,153 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{odata},@var{it},@var{res}} =  DDGgummelmap(@var{x},@var{idata},@var{toll},@var{maxit},@var{ptoll},@var{pmaxit},@var{verbose})
+##
+## Solve the scaled stationary bipolar DD equation system using Gummel
+## algorithm
+##
+## Input:
+## @itemize @minus
+## @item x: spatial grid
+## @item idata.D: doping profile
+## @item idata.p: initial guess for hole concentration
+## @item idata.n: initial guess for electron concentration
+## @item idata.V: initial guess for electrostatic potential
+## @item idata.Fn: initial guess for electron Fermi potential
+## @item idata.Fp: initial guess for hole Fermi potential
+## @item idata.l2: scaled electric permittivity (diffusion coefficient in Poisson equation)
+## @item idata.un: scaled electron mobility
+## @item idata.up: scaled electron mobility
+## @item idata.nis: scaled intrinsic carrier density
+## @item idata.tn: scaled electron lifetime
+## @item idata.tp: scaled hole lifetime
+## @item toll: tolerance for Gummel iterarion convergence test
+## @item maxit: maximum number of Gummel iterarions
+## @item ptoll: tolerance for Newton iterarion convergence test for non linear Poisson
+## @item pmaxit: maximum number of Newton iterarions
+## @item verbose: verbosity level (0,1,2)
+## @end itemize
+##
+## Output:
+## @itemize @minus
+## @item odata.n: electron concentration
+## @item odata.p: hole concentration
+## @item odata.V: electrostatic potential
+## @item odata.Fn: electron Fermi potential
+## @item odata.Fp: hole Fermi potential
+## @item it: number of Gummel iterations performed
+## @item res: total potential increment at each step
+## @end itemize
+##
+## @end deftypefn
+
+function [odata,it,res] = DDGgummelmap (x,idata,toll,maxit,ptoll,pmaxit,verbose)
+
+  odata  = idata;
+Nnodes=rows(x);
+
+D         = idata.D;
+vout(:,1) = idata.V;
+
+hole_density (:,1) = idata.p;
+electron_density (:,1)= idata.n;
+fermin (:,1)=idata.Fn;
+fermip (:,1)=idata.Fp;
+
+for i=1:1:maxit
+	if (verbose>1)
+      fprintf(1,"*****************************************************************\n");  
+      fprintf(1,"****    start of gummel iteration number: %d\n",i);
+      fprintf(1,"*****************************************************************\n");  
+    endif
+    
+    if (verbose>1)
+      fprintf(1,"solving non linear poisson equation\n\n");
+    endif
+
+    [vout(:,2),electron_density(:,2),hole_density(:,2)] =\
+	DDGnlpoisson (x,[1:Nnodes],vout(:,1),electron_density(:,1),hole_density(:,1),fermin(:,1),fermip(:,1),D,idata.l2,ptoll,pmaxit,verbose);
+	
+    if (verbose>1)
+      fprintf (1,"\n\nupdating electron qfl\n\n");
+    endif
+    electron_density(:,3)=\
+	DDGelectron_driftdiffusion(vout(:,2), x, electron_density(:,2),hole_density(:,2),idata.nis,idata.tn,idata.tp,idata.un);
+    
+    fermin(:,2) = DDGn2phin(vout(:,2),electron_density(:,3));
+    fermin(1,2)   = idata.Fn(1);
+    fermin(end:2) = idata.Fn(end);
+    
+	if (verbose>1)
+      fprintf(1,"updating hole qfl\n\n");
+    endif
+
+    hole_density(:,3) = \
+    DDGhole_driftdiffusion(vout(:,2), x, hole_density(:,2),electron_density(:,2),idata.nis,idata.tn,idata.tp,idata.up);
+
+    fermip(:,2) = DDGp2phip(vout(:,2),hole_density(:,3));
+    fermip(1,2)   = idata.Fp(1);
+    fermip(end,2) = idata.Fp(end);
+    
+    if (verbose>1)
+      fprintf(1,"checking for convergence\n\n");
+    endif
+
+	nrfn= norm(fermin(:,2)-fermin(:,1),inf);
+	nrfp= norm (fermip(:,2)-fermip(:,1),inf);
+	nrv = norm (vout(:,2)-vout(:,1),inf);
+	nrm(i) = max([nrfn;nrfp;nrv]);
+	
+	if (verbose>1)
+      fprintf (1," max(|phin_(k+1)-phinn_(k)| , |phip_(k+1)-phip_(k)| , |v_(k+1)- v_(k)| )= %d\n",nrm(i));
+    endif
+
+	if (nrm(i)<toll)
+		break
+    endif
+
+	vout(:,1) = vout(:,end);
+	hole_density (:,1) = hole_density (:,end) ;
+	electron_density (:,1)= electron_density (:,end);
+	fermin (:,1)= fermin (:,end);
+	fermip (:,1)= fermip (:,end);
+	
+	
+	if(verbose)
+		DDGplotresults(x,electron_density,hole_density,vout,fermin,fermip);		
+    endif
+  endfor
+
+it = i;
+res = nrm;
+
+if (verbose>0)
+    fprintf(1,"\n\nInitial guess computed by DD: # of Gummel iterations = %d\n\n",it);
+  endif
+
+odata.n     = electron_density(:,end);
+odata.p     = hole_density(:,end);
+odata.V     = vout(:,end);
+odata.Fn    = fermin(:,end);
+odata.Fp    = fermip(:,end);
+
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGhole_driftdiffusion.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,87 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{p}} = DDGhole_driftdiffusio(@var{psi},@var{x},@var{pg},@var{n},@var{ni},@var{tn},@var{tp},@var{up})
+##
+## Solve the continuity equation for holes
+##
+## Input:
+## @itemize @minus
+## @item psi: electric potential
+## @item x: spatial grid
+## @item ng: initial guess and BCs for electron density
+## @item n: electron density (for SRH recombination)
+## @end itemize
+##
+## Output:
+## @itemize @minus
+## @item p: updated hole density
+## @end itemize
+##
+## @end deftypefn
+
+function p = DDGhole_driftdiffusion(psi,x,pg,n,ni,tn,tp,up)
+
+nodes        = x;
+Nnodes     =length(nodes);
+elements   = [[1:Nnodes-1]' [2:Nnodes]'];
+Nelements=size(elements,1);
+Bcnodes = [1;Nnodes];
+
+pl = pg(1);
+pr = pg(Nnodes);
+h=nodes(elements(:,2))-nodes(elements(:,1));
+c=up./h;
+Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
+Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
+
+
+d0    = [c(1).*Bpos(1); c(1:end-1).*Bneg(1:end-1)+c(2:end).*Bpos(2:end); c(end)*Bneg(end)];
+d1    = [1000;-c.* Bneg];
+dm1   = [-c.* Bpos;1000];
+
+A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
+  b = zeros(Nnodes,1);## - A * pg;
+
+  ## SRH Recombination term
+SRHD = tp * (n + ni) + tn * (pg + ni);
+SRHL = n ./ SRHD;
+SRHR = ni.^2 ./ SRHD;
+
+ASRH = Ucompmass (nodes,Nnodes,elements,Nelements,SRHL,ones(Nelements,1));
+bSRH = Ucompconst (nodes,Nnodes,elements,Nelements,SRHR,ones(Nelements,1));
+
+A = A + ASRH;
+b = b + bSRH;
+
+  ## Boundary conditions
+b(Bcnodes)   = [];
+b(1)         = - A(2,1) * pl;
+b(end)       = - A(end-1,end) * pr;
+A(Bcnodes,:) = [];
+A(:,Bcnodes) = [];
+
+p = [pl; A\b ;pr];
+
+endfunction
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGn2phin.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,36 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+  
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{phin}} = DDGn2phin(@var{V},@var{n})
+##
+## Compute the qfl for electrons using Maxwell-Boltzmann statistics.
+##
+## @end deftypefn
+  
+function phin = DDGn2phin (V,n);
+
+  ## Load constants
+  nmin = 0;
+n    = n .* (n>nmin) + nmin * (n<=nmin); 
+phin = V - log(n) ;
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGnlpoisson.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,212 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{V},@var{n},@var{p},@var{res},@var{niter}} = @
+## DDGnlpoisson(@var{x},@var{sinodes},@var{Vin},@var{nin},@var{pin},@var{Fnin},@var{Fpin},@var{D},@var{l2},@var{toll},@var{maxit},@var{verbose})
+##
+## Solve the non linear Poisson equation
+## 
+## - lamda^2 *V'' + (n(V,Fn) - p(V,Fp) -D) = 0 
+##
+## Input:
+## @itemize @minus
+## @item x: spatial grid
+## @item sinodes: index of the nodes of the grid which are in the
+## semiconductor subdomain (remaining nodes are assumed to be in the oxide subdomain)
+## @item Vin: initial guess for the electrostatic potential
+## @item nin: initial guess for electron concentration
+## @item pin: initial guess for hole concentration
+## @item Fnin: initial guess for electron Fermi potential
+## @item Fpin: initial guess for hole Fermi potential
+## @item D: doping profile
+## @item l2: scaled electric permittivity (diffusion coefficient)
+## @item toll: tolerance for convergence test
+## @item maxit: maximum number of Newton iterations
+## @item verbose: verbosity level (0,1,2)
+## @end itemize
+##
+## Output:
+## @itemize @minus
+## @item V: electrostatic potential
+## @item n: electron concentration
+## @item p: hole concentration
+## @item res: residual norm at each step
+## @item niter: number of Newton iterations
+## @end itemize
+##
+## @end deftypefn
+
+function [V,n,p,res,niter] = DDGnlpoisson (x,sinodes,Vin,nin,pin,Fnin,Fpin,D,l2,toll,maxit,verbose)
+
+  ## Set some useful constants
+dampit 		= 10;
+dampcoeff	= 2;
+
+  ## Convert grid info to FEM form
+Ndiricheletnodes 	= 2;
+nodes 		        = x;
+sielements          = sinodes(1:end-1);
+Nnodes		        = length(nodes);
+totdofs             = Nnodes - Ndiricheletnodes ;
+elements            = [[1:Nnodes-1]' , [2:Nnodes]'];
+Nelements           = size(elements,1);
+BCnodes             = [1;Nnodes];
+
+  ## Initialization
+V = Vin;
+Fn = Fnin;
+Fp = Fpin;
+n = DDGphin2n(V(sinodes),Fn);
+p = DDGphip2p(V(sinodes),Fp);
+if (sinodes(1)==1)
+    n(1)=nin(1);
+    p(1)=pin(1);
+  endif
+if (sinodes(end)==Nnodes)
+    n(end)=nin(end);
+    p(end)=pin(end);
+  endif
+
+  ## Compute LHS matrices
+L      = Ucomplap (nodes,Nnodes,elements,Nelements,l2.*ones(Nelements,1));
+
+  ## Compute Mv =  ( n + p)
+Mv            =  zeros(Nnodes,1);
+Mv(sinodes)   =  (n + p);
+Cv            =  zeros(Nelements,1);
+Cv(sielements)=  1;
+M             =  Ucompmass (nodes,Nnodes,elements,Nelements,Mv,Cv);
+
+  ## Compute RHS vector
+Tv0            =  zeros(Nnodes,1);
+Tv0(sinodes)   = (n - p - D);
+Cv            =  zeros(Nelements,1);
+Cv(sielements)=  1;
+T0             =  Ucompconst (nodes,Nnodes,elements,Nelements,Tv0,Cv);
+
+  ## Build LHS matrix and RHS of the linear system for 1st Newton step
+A 		= L + M;
+R 		= L * V  + T0; 
+
+  ## Apply boundary conditions
+A(BCnodes,:)	= [];
+A(:,BCnodes)	= [];
+R(BCnodes)	= [];
+
+
+normr(1)		=  norm(R,inf);
+relresnorm 	= 1;
+reldVnorm   = 1;
+normrnew	= normr(1);
+
+
+  ## Start of the newton cycle
+for newtit=1:maxit
+    if verbose
+        fprintf(1,"\n newton iteration: %d, reldVnorm = %e",newtit,reldVnorm);
+    endif
+    dV =[0;(A)\(-R);0];
+    
+    ## Start of the damping procedure
+    tk = 1;
+    for dit = 1:dampit
+        if verbose
+        fprintf(1,"\n damping iteration: %d, residual norm = %e",dit,normrnew);
+      endif
+        Vnew   = V + tk * dV;
+        n = DDGphin2n(Vnew(sinodes),Fn);
+        p = DDGphip2p(Vnew(sinodes),Fp);
+        if (sinodes(1)==1)
+            n(1)=nin(1);
+            p(1)=pin(1);
+      endif
+        if (sinodes(end)==Nnodes)
+            n(end)=nin(end);
+            p(end)=pin(end);
+      endif
+        
+      ## Compute LHS matrices
+        Mv            =  zeros(Nnodes,1);
+        Mv(sinodes)   =  (n + p);
+        Cv            =  zeros(Nelements,1);
+        Cv(sielements)=  1;        
+        M    = Ucompmass (nodes,Nnodes,elements,Nelements,Mv,Cv);
+        
+      ## Compute RHS vector (-residual)
+        Tv0            =  zeros(Nnodes,1);
+        Tv0(sinodes)   =  (n - p - D);
+        Cv            =  zeros(Nelements,1);
+        Cv(sielements)=  1;
+        T0     = Ucompconst (nodes,Nnodes,elements,Nelements,Tv0,Cv);
+        
+      ## Build LHS matrix and RHS of the linear system for 1st Newton step
+        Anew 		= L + M;
+        Rnew 		= L * Vnew  + T0; 
+        
+      ## Apply boundary conditions
+        Anew(BCnodes,:)	= [];
+        Anew(:,BCnodes)	= [];
+        Rnew(BCnodes)	= [];
+        
+        if ((dit>1)&(norm(Rnew,inf)>=norm(R,inf)))
+            if verbose
+          fprintf(1,"\nexiting damping cycle \n");
+        endif
+            break
+        else
+            A = Anew;
+            R = Rnew;
+      endif
+    
+      ## Compute | R_{k+1} | for the convergence test
+        normrnew= norm(R,inf);
+        
+      ## Check if more damping is needed
+        if (normrnew > normr(newtit))
+            tk = tk/dampcoeff;
+        else
+            if verbose
+          fprintf(1,"\nexiting damping cycle because residual norm = %e \n",normrnew);
+        endif		
+            break
+      endif	
+    endfor
+
+    V		            = Vnew;	
+    normr(newtit+1) 	= normrnew;
+    dVnorm              = norm(tk*dV,inf);
+
+    ## Check if convergence has been reached
+    reldVnorm           = dVnorm / norm(V,inf);
+    if (reldVnorm <= toll)
+        if(verbose)
+        fprintf(1,"\nexiting newton cycle because reldVnorm= %e \n",reldVnorm);
+      endif
+        break
+    endif
+
+  endfor
+
+res = normr;
+niter = newtit;
+
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGp2phip.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,36 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+## SECS1D 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.
+##
+## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{phip}} = DDGn2phin(@var{V},@var{p})
+##
+## Compute the qfl for holes using Maxwell-Boltzmann statistics
+##
+## @end deftypefn
+  
+function phip = DDGp2phip (V,p);
+
+  ## Load constants
+  pmin = 0;
+  p    = p .* (p>pmin) + pmin * (p<=pmin);
+  phip = V + log(p) ;
+  
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGphin2n.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,35 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{n}} = DDGphin2n(@var{V},@var{phin})
+##
+## Compute the electron density using Maxwell-Boltzmann statistics
+##
+## @end deftypefn
+  
+function n = DDGphin2n (V,phin);
+  
+  nmin = 0;
+  n =  exp ((V-phin));
+  n = n .* (n>nmin) + nmin * (n<=nmin);
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGphip2p.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,36 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+  
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{p}} = DDGphip2p(@var{V},@var{phip})
+##
+## Compute the hole density using Maxwell-Boltzmann statistic
+##
+## @end deftypefn
+  
+function p = DDGphip2p (V,phip);
+
+## Load constants
+pmin = 0;
+p = exp ((phip-V));
+p = p .* (p>pmin) + pmin * (p<=pmin);
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDG/DDGplotresults.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,52 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## DDGplotresults(@var{x},@var{n},@var{p},@var{V},@var{Fn},@var{Fp})
+##
+## Plot densities and potentials
+##
+## @end deftypefn
+
+function DDGplotresults(x,n,p,V,Fn,Fp);
+  
+subplot(2,3,1)
+title('Electron Density')
+semilogy(x,n)
+
+subplot(2,3,2)
+title('Hole Density')
+semilogy(x,p)
+
+subplot(2,3,4)
+title('Electron QFL')
+plot(x,Fn)
+
+subplot(2,3,5)
+title('Hole QFL')
+plot(x,Fp)
+
+subplot(2,3,6)
+title('Electric Potential')
+plot(x,V)
+pause(.1)
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/DDN/DDNnewtonmap.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,230 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+##  SECS1D 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.
+##
+##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{odata},@var{it},@var{res}} = DDNnewtonmap(@var{x},@var{idata},@var{toll},@var{maxit},@var{verbose})
+##
+## Solve the scaled stationary bipolar DD equation system using a
+## coupled Newton algorithm
+##
+## Input:
+## @itemize @minus
+## @item x: spatial grid
+## @item idata.D: doping profile
+## @item idata.p: initial guess for hole concentration
+## @item idata.n: initial guess for electron concentration
+## @item idata.V: initial guess for electrostatic potential
+## @item idata.Fn: initial guess for electron Fermi potential
+## @item idata.Fp: initial guess for hole Fermi potential
+## @item idata.l2: scaled electric permittivity (diffusion coefficient in Poisson equation)
+## @item idata.un: scaled electron mobility
+## @item idata.up: scaled electron mobility
+## @item idata.nis: scaled intrinsic carrier density
+## @item idata.tn: scaled electron lifetime
+## @item idata.tp: scaled hole lifetime
+## @item toll: tolerance for Newton iterarion convergence test
+## @item maxit: maximum number of Newton iterarions
+## @item verbose: verbosity level: 0,1,2
+## @end itemize
+##
+## Output:
+## @itemize @minus
+## @item odata.n: electron concentration
+## @item odata.p: hole concentration
+## @item odata.V: electrostatic potential
+## @item odata.Fn: electron Fermi potential
+## @item odata.Fp: hole Fermi potential
+## @item it: number of Newton iterations performed
+## @item res: residual at each step
+## @end itemize
+##
+## @end deftypefn
+
+function [odata,it,res] = DDNnewtonmap (x,idata,toll,maxit,verbose)
+
+  odata     = idata;
+  Nnodes    = rows(x);
+Nelements=Nnodes-1;
+elements=[1:Nnodes-1;2:Nnodes]';
+BCnodesp = [1,Nnodes];
+BCnodes = [BCnodesp,BCnodesp+Nnodes,BCnodesp+2*Nnodes];
+totaldofs= Nnodes-2;
+dampcoef = 2;
+maxdamp  = 2;
+
+V = idata.V;
+n = idata.n;
+p = idata.p;
+D = idata.D;
+
+  ## Create the complete unknown vector
+u = [V; n; p];
+
+  ## Build fem matrices
+L = Ucomplap (x,Nnodes,elements,Nelements,idata.l2*ones(Nelements,1));
+M = Ucompmass (x,Nnodes,elements,Nelements,ones(Nnodes,1),ones(Nelements,1));
+DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,V);
+DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-V);
+
+  ## Initialise RHS 
+r1  = L * V + M * (n - p - D); 
+r2  = DDn * n;
+r3  = DDp * p;
+  RHS = - [ r1; r2; r3 ];
+
+  ##  Apply BCs
+RHS(BCnodes,:)= [];
+nrm = norm(RHS,inf);
+res(1) = nrm;
+
+  ## Begin Newton Cycle
+for count = 1: maxit
+  if verbose
+      fprintf (1,"\n\n\nNewton Iteration Number:%d\n",count);	
+    endif
+    Ln = Ucomplap (x,Nnodes,elements,Nelements,Umediaarmonica(idata.un*n));
+    Lp = Ucomplap (x,Nnodes,elements,Nelements,Umediaarmonica(idata.up*p));
+    Z  = sparse(zeros(Nnodes));    
+    DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,V);
+    DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-V);
+    
+    A 	= L;
+    B	= M;
+    C	= -M;
+    DDD	= -Ln;
+    E	= DDn;
+    F	= Z;
+    G	= Lp;
+    H	= Z;
+    I	= DDp;
+    
+    ## Build LHS
+    LHS =sparse([
+	[A	B C];
+	[DDD    E F];
+	[G      H I];
+    ]);
+    
+    ## Apply BCs
+    LHS(BCnodes,:)=[];    
+    LHS(:,BCnodes)=[];
+    
+    ## Solve the linearised system
+    dutmp = (LHS) \ (RHS);
+    dv    = dutmp(1:totaldofs);
+    dn    = dutmp(totaldofs+1:2*totaldofs);
+    dp    = dutmp(2*totaldofs+1:3*totaldofs);
+    du    = [0;dv;0;0;dn;0;0;dp;0];
+    
+    ## Check Convergence
+    nrm_u = norm(u,inf);
+    nrm_du = norm(du,inf);
+	
+    ratio = nrm_du/nrm_u; 
+    if verbose
+      fprintf (1,"ratio = %e\n", ratio);		
+    endif
+    
+    if (ratio <= toll)
+        V 	    = u(1:Nnodes);
+        n	    = u(Nnodes+1:2*Nnodes);
+        p	    = u(2*Nnodes+1:end);
+        res(count)  = nrm;
+        break;
+    endif
+
+    ## Begin damping cycle
+    tj = 1;
+    
+    for cc = 1:maxdamp
+      if verbose
+        fprintf (1,"\ndamping iteration number:%d\n",cc);
+        fprintf (1,"reference residual norm:%e\n",nrm);
+      endif
+      ## Update the unknown vector		
+        utmp    = u + tj*du;
+        Vnew 	    = utmp(1:Nnodes);
+        nnew	    = utmp(Nnodes+1:2*Nnodes);
+        pnew	    = utmp(2*Nnodes+1:end);
+      ## Try a new RHS
+        DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,Vnew);
+        DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-Vnew);
+        
+        r1  = L * V + M * (nnew - pnew - D); 
+        r2  = DDn * nnew;
+        r3  = DDp * pnew;
+        
+      RHS =- [r1;r2;r3];
+        
+      ## Apply BCs
+      RHS(BCnodes,:) = [];
+        nrmtmp=norm(RHS,inf);
+        
+      ## Update the damping coefficient
+        if verbose
+	fprintf(1,"residual norm:%e\n\n", nrmtmp);
+      endif
+        
+		if (nrmtmp>nrm)
+			tj = tj/(dampcoef*cc);
+			if verbose
+	  fprintf (1,"\ndamping coefficients = %e",tj);    
+	endif
+        else
+			break;
+      endif
+    endfor
+
+    nrm_du = norm(tj*du,inf);
+    u 	= utmp;
+    
+    if (count>1)
+        ratio = nrm_du/nrm_du_old;
+        if (ratio<.005)
+            V 	    = u(1:Nnodes);
+            n	    = u(Nnodes+1:2*Nnodes);
+            p	    = u(2*Nnodes+1:end);            
+            res(count)  = nrm;
+            break;           
+      endif
+    endif
+    nrm = nrmtmp;
+    res(count)  = nrm;
+	
+    ## Convert result vector into distinct output vectors 
+    V 	    = u(1:Nnodes);
+    n	    = u(Nnodes+1:2*Nnodes);
+    p	    = u(2*Nnodes+1:end);    
+    nrm_du_old = nrm_du;
+  endfor
+
+odata.V = V;
+odata.n = n;
+odata.p = p;
+Fn   = V - log(n);
+Fp   = V + log(p);
+it   = count; 
+
+endfunction
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/PKG_ADD	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,19 @@
+dirlist        = {"Utilities","DDG","DDN"};
+
+dir = fileparts (mfilename ("fullpath"));
+
+if (! exist (fullfile (dir, "inst"), "dir"))
+  ## Run this if the package is installed
+  for ii=1:length(dirlist)
+    addpath ( [ canonicalize_file_name([dir "/.."]) "/" dirlist{ii}])
+  endfor
+else
+  ## Run this if we are testing the package without installation        
+  for ii=1:length(dirlist)
+    addpath ([ canonicalize_file_name(dir) "/inst/" dirlist{ii}])
+  endfor
+endif
+
+warning ("off", "Octave:fopen-file-in-path");
+warning ("off", "Octave:load-file-in-path");
+clear dirlist dir
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Ubern.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,87 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File} {@var{bp},@var{bn}} = Ubern(@var{x})
+##
+## Compute Bernoulli function for scalar x:
+##
+## @itemize @minus
+## @item @var{bp} = @var{x}/(exp(@var{x})-1)
+## @item @var{bn} = @var{x} + B( @var{x} )
+## @end itemize
+##
+## @end deftypefn
+
+function [bp,bn] = Ubern(x)
+     
+xlim=1e-2;
+ax=abs(x);
+
+  ## Compute Bernoulli function for x = 0
+
+if (ax == 0)
+   bp=1.;
+   bn=1.;
+   return
+  endif
+
+  ## Compute Bernoulli function for asymptotic values
+
+  if (ax > 80)
+    if (x > 0)
+      bp=0.;
+      bn=x;
+      return
+   else
+      bp=-x;
+      bn=0.;
+      return
+    endif
+  endif
+
+  ## Compute Bernoulli function for intermediate values
+
+  if (ax > xlim)
+   bp=x/(exp(x)-1);
+   bn=x+bp;
+   return
+else
+    ## Compute Bernoulli function for small x
+    ## via Taylor expansion
+
+   ii=1;
+   fp=1.;
+   fn=1.;
+   df=1.;
+   segno=1.;
+   while (abs(df) > eps),
+     ii=ii+1;
+     segno=-segno;
+     df=df*x/ii;
+     fp=fp+df;
+     fn=fn+segno*df;
+     bp=1./fp;
+     bn=1./fn;
+    endwhile
+   return
+  endif
+
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Ubernoulli.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,47 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File} {@var{b}} = Ubernoulli(@var{x},@var{sg})
+##
+## Compute Bernoulli function for vector x:
+##
+## @itemize @minus
+## @item @var{b} = @var{x}/(exp(@var{x})-1) if @var{sg} == 1
+## @item @var{b} = @var{x} + B( @var{x} ) if @var{sg} == 0
+## @end itemize
+##
+## @end deftypefn
+
+function b=Ubernoulli(x,sg)
+  
+  for count=1:length(x)
+    [bp,bn] = Ubern(x(count));
+    bernp(count,1)=bp;
+    bernn(count,1)=bn;
+  endfor
+  
+  if (sg ==1)
+    b=bernp;
+  elseif (sg ==0)
+    b=bernn;
+  endif
+  
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Ucompconst.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,43 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+  
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{R}} = Ucompconst(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{D},@var{C})
+##
+## Compute P1 finite element rhs:
+##
+## @itemize @minus
+## @item @var{nodes}: list of mesh nodes
+## @item @var{Nnodes}: number of mesh nodes
+## @item @var{elements}: list of mesh elements 
+## @item @var{Nelements}: number of mesh elements
+## @item @var{D}: piecewise linear reaction coefficient
+## @item @var{C}: piecewise constant reaction coefficient
+## @end itemize
+##
+## @end deftypefn
+  
+function R = Ucompconst (nodes,Nnodes,elements,Nelements,D,C)
+  
+  h = (nodes(2:end)-nodes(1:end-1)).*C;
+  R = D.*[h(1)/2; (h(1:end-1)+h(2:end))/2; h(end)/2];
+  
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Ucomplap.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,49 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+  
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{R}} = Ucomplap(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{coeff})
+##
+## Compute P1 finite element approximation of the differential operator:
+## 
+##  - d ( coeff d (.)\dx)\dx
+##
+## @itemize @minus
+## @item @var{nodes}: list of mesh nodes
+## @item @var{Nnodes}: number of mesh nodes
+## @item @var{elements}: list of mesh elements 
+## @item @var{Nelements}: number of mesh elements
+## @item @var{coeff}: piecewise linear reaction coefficient
+## @end itemize
+##
+## @end deftypefn
+  
+function L = Ucomplap (nodes,Nnodes,elements,Nelements,coeff)
+  
+  h 	= nodes(2:end)-nodes(1:end-1);
+  d0 	= [ coeff(1)./h(1); 
+            (coeff(1:end-1)./h(1:end-1))+(coeff(2:end)./h(2:end));
+            coeff(end)./h(end)];
+  d1	= [1000; -coeff./h];
+  dm1	= [ -coeff./h;1000];
+  L	= spdiags([dm1, d0, d1],-1:1,Nnodes,Nnodes);
+  
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Ucompmass.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,45 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.  
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{R}} = Ucompmass(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{Bvect},@var{Cvect})
+##
+## Compute P1 finite element mass-matrix:
+##
+## @itemize @minus
+## @item @var{nodes}: list of mesh nodes
+## @item @var{Nnodes}: number of mesh nodes
+## @item @var{elements}: list of mesh elements 
+## @item @var{Nelements}: number of mesh elements
+## @item @var{Bvect}: piecewise linear reaction coefficient
+## @item @var{Cvect}: piecewise constant reaction coefficient
+## @end itemize
+##
+## @end deftypefn
+
+function Bmat	= Ucompmass (nodes,Nnodes,elements,Nelements,Bvect,Cvect);
+  
+  h 	= (nodes(2:end)-nodes(1:end-1)).*Cvect;
+  d0	= Bvect.*[h(1)/2; (h(1:end-1)+h(2:end))/2; h(end)/2];
+  Bmat  = spdiags(d0, 0, Nnodes,Nnodes);
+  
+endfunction
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Udriftdiffusion.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,61 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{A}} = Udriftdiffusion(@var{x},@var{psi},@var{coeff})
+##
+## Builds the Scharfetter-Gummel approximation of the differential
+## operator
+##
+## - (coeff (n' - n psi'))'
+##
+## @itemize @minus
+## @item @var{x}: list of mesh nodes
+## @item @var{psi}: piecewise linear potential values
+## @item @var{coeff}: piecewise linear diffusion coefficient
+## @end itemize
+##
+## @end deftypefn
+
+function A = Udriftdiffusion(x,psi,coeff)  
+  
+  nodes        = x;
+  Nnodes     =length(nodes);
+  
+  elements   = [[1:Nnodes-1]' [2:Nnodes]'];
+  Nelements=size(elements,1);
+  
+  Bcnodes = [1;Nnodes];
+  
+  h=nodes(elements(:,2))-nodes(elements(:,1));
+  
+  c=coeff./h;
+  Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
+  Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
+  
+  
+  d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
+  d1    = [1000;-c.* Bpos];
+  dm1   = [-c.* Bneg;1000];
+  
+  A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
+  
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Umediaarmonica.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,34 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+  ##  SECS1D 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.
+  ##
+  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.     
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+    
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{m}} = Umediarmonica(@var{w})
+##
+## Return the harmonic mean value of @var{w}
+##
+## @end deftypefn
+     
+function m = Umediaarmonica(w);
+     
+  dw = (1./w(1:end-1))+(1./w(2:end));
+  m  = 2 ./ dw; 
+     
+endfunction     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/Uscharfettergummel.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,57 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+  ##
+  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+  ##
+## SECS1D 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.
+  ##
+## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Function File}@
+## {@var{R}} = Uscharfettergummel(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{acoeff},@var{bcoeff},@var{v})
+##
+## Build the Scharfetter-Gummel matrix for the the discretization of
+## the LHS of the Drift-Diffusion equation:
+##
+##  -(a(x) (u' - b v'(x) u))'= f
+##
+## @itemize @minus
+## @item @var{nodes}: list of mesh nodes
+## @item @var{Nnodes}: number of mesh nodes
+## @item @var{elements}: list of mesh elements 
+## @item @var{Nelements}: number of mesh elements
+## @item @var{acoeff}: piecewise linear diffusion coefficient
+## @item @var{bcoeff}: piecewise constant drift constant coefficient
+## @item @var{v}: piecewise linear drift potential
+## @end itemize
+##
+## @end deftypefn
+
+function A = Uscharfettergummel(nodes,Nnodes,elements,Nelements,acoeff,bcoeff,v)
+
+  h=nodes(elements(:,2))-nodes(elements(:,1));
+  
+  c=acoeff./h;
+  Bneg=Ubernoulli(-(v(2:Nnodes)-v(1:Nnodes-1))*bcoeff,1);
+  Bpos=Ubernoulli( (v(2:Nnodes)-v(1:Nnodes-1))*bcoeff,1);
+  
+  
+  d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
+  d1    = [1000;-c.* Bpos];
+  dm1   = [-c.* Bneg;1000];
+  
+  A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
+  
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/Utilities/constants.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,74 @@
+## Copyright (C) 2004-2008  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+## SECS1D 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.
+##
+## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+## -*- texinfo -*-
+##
+## @deftypefn {Script File} constants
+##
+## Compute global constants needed for Drift-Diffusion simulation
+##
+## @end deftypefn
+
+
+
+Kb           = 1.3806503e-23;
+q            = 1.602176462e-19;
+e0           = 8.854187817e-12;
+esir 	     = 11.7;
+esio2r 	     = 3.9;
+esi 	     = e0 * esir;
+esio2 	     = e0 * esio2r;
+hplanck	     = 6.626e-34;
+hbar         = ( hplanck/ (2*pi));
+mn0          = 9.11e-31;
+mn           = 0.26*mn0;
+mh           = 0.18*mn0;
+
+
+qsue         = q / esi;
+T0           = 300 ;
+Vth 	     = Kb * T0 / q;
+un           = 1417e-4;
+up           = 480e-4;
+tp           = 1e-7;
+tn           = 1e-7;
+
+mnl          = 0.98*mn0;
+mnt          = 0.19*mn0;
+mndos        = (mnl*mnt*mnt)^(1/3); 
+
+mhh             = 0.49*mn0;
+mlh             = 0.16*mn0;
+mhdos           = (mhh^(3/2)+mlh^(3/2))^(2/3);
+
+rn              = .1;
+aleph           = hbar^2/(4*rn*q*mn);
+alephn          = aleph;
+rp              = .1;
+alephp          = hbar^2/(4*rp*q*mh);
+
+Nc              = (6/4)*(2*mndos*Kb*T0/(hbar^2*pi))^(3/2);   
+Nv              = (1/4)*(2*mhdos*Kb*T0/(hbar^2*pi))^(3/2);
+Eg0             = 1.16964*q;
+alfaEg          = 4.73e-4*q;
+betaEg          = 6.36e2;
+Egap            = Eg0-alfaEg*((T0^2)/(T0+betaEg));
+
+ni              = sqrt(Nc*Nv)*exp(-Egap/(2*(Kb * T0)));
+Phims           = - Egap /(2*q);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/secs1d_demo_pndiode.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,138 @@
+## Copyright (C) 2009  Carlo de Falco
+##
+## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+##
+## SECS1D 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.
+##
+## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+##
+## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
+
+function secs1d_demo_pndiode ()
+
+  constants
+
+  len = 1e-6;
+  Nnodes = 1000;
+
+  vmin = -2;
+  vmax =  2;
+
+  vstep=.4;
+
+  istep = 1;
+  va = vmin
+  
+  x = linspace(0,len,Nnodes)';
+  xm = mean(x);
+  
+  Nd=1e25;
+  Na=1e25;
+  
+  D = Nd * (x>xm) - Na * (x<=xm);
+
+  nn = (Nd + sqrt(Nd^2+4*ni^2))/2;
+  pp = (Na + sqrt(Na^2+4*ni^2))/2;
+    
+  xn = xm+1e-7;
+  xp = xm-1e-7;
+
+  %% Scaling coefficients
+  xs  = len;
+  ns  = norm(D,inf);
+  idata.D = D/ns;
+  Vs  = Vth;
+  us  = un;
+  Js  = xs / (us * Vs * q * ns);
+
+
+  while va <= vmax
+    
+    vvect(istep) = va;
+    
+    n(:,istep) = nn * (x>=xn) + (ni^2)/pp * (x<xn);
+    p(:,istep) = (ni^2)/nn * (x>xp) + pp * (x<=xp);
+    
+    Fn = va*(x<=xm);
+    Fp = Fn;
+    
+    V(:,istep) = (Fn - Vth * log(p(:,istep)/ni)); 
+  
+    %% Scaling    
+    xin   = x/xs;
+    idata.n   = n(:,istep)/ns;
+    idata.p   = p(:,istep)/ns;
+    idata.V   = V(:,istep)/Vs;
+    idata.Fn  = (Fn - Vs * log(ni/ns))/Vs;
+    idata.Fp  = (Fp + Vs * log(ni/ns))/Vs;
+    
+    lambda2(istep) = idata.l2 = (Vs*esi)/(q*ns*xs^2);
+    idata.nis   = ni/ns;
+    idata.un   = un/us;
+    idata.up   = up/us;
+    
+    %% Solution of DD system
+    
+    %% Algorithm parameters
+    toll  = 1e-3;
+    maxit = 20;
+    ptoll  = 1e-10;
+    pmaxit = 100;
+    verbose = 0;
+    sinodes = [1:length(x)];
+    idata.tn = inf;
+    idata.tp = inf;
+    
+    [odata,it,res] = DDGgummelmap (xin,idata,toll,maxit,ptoll,pmaxit,verbose);
+    [odata,it,res] = DDNnewtonmap (xin,odata,toll, maxit,verbose);
+
+    n(:,istep) = odata.n;
+    p(:,istep) = odata.p;
+    V(:,istep) = odata.V;
+    
+    DV(istep)  = odata.V(end) - odata.V(1);
+    Emax(istep) = max(abs(diff(odata.V)./diff(xin)))
+
+    Bp = Ubernoulli(diff (V(:, istep)),1);
+    Bm = Ubernoulli(diff (V(:, istep)),0);
+    Jn(:,istep) = -odata.un * (n(2:end, istep).*Bp-n(1:end-1, istep).*Bm)./diff (xin);
+    Jp(:,istep) =  odata.up * (p(2:end, istep).*Bm-p(1:end-1, istep).*Bp)./diff (xin);
+
+    va = va+vstep
+    istep = istep+1;
+    
+  endwhile
+
+  %% Descaling
+  n     = n*ns;
+  p     = p*ns;
+  V     = V*Vs;
+  J     = abs (Jp+Jn)*Js;
+
+  close all
+  
+  figure();
+  plot(x, n.')
+  xlabel("x")
+  ylabel("n")
+ 
+  figure();
+  plot(vvect, J)
+  xlabel("V")
+  ylabel("J")
+
+  figure();
+  plot(vvect, Emax)
+  xlabel("V")
+  ylabel("max(abs(\\phi^\'))")
+  
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/src/Makefile	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,10 @@
+PROGS = $(patsubst %.cc,%.oct,$(wildcard *.cc))
+
+all: $(PROGS)
+
+$(PROGS): Makefile
+
+%.oct: %.cc
+	mkoctfile $<
+
+clean: ; -$(RM) *.o core octave-core *.oct *~
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/bak/src/Ubern.cc	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,131 @@
+/*
+% 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <iostream>
+#include <octave/oct.h>
+
+////////////////////////////////////////////
+//   Ubern function
+//   this function, though it does make use 
+//   of liboctave, is not an octve command
+//   the wrapper to make the command is defined
+//   below
+////////////////////////////////////////////
+
+
+int Ubern(const double x, double &bp, double &bn )
+{
+
+double xlim=1e-2;
+int ii;
+double fp,fn,df,segno;
+double ax;
+
+ax=fabs(x);
+
+
+if (ax == 0.0) {
+bp=1.;
+bn=1.;
+goto theend ;
+}
+
+if (ax > 80.0){
+if (x >0.0){
+  bp=0.0;
+  bn=x;
+  goto theend ;
+}else{
+  bp=-x;
+  bn=0.0;
+  goto theend ;
+}
+}
+
+if (ax > xlim){
+bp=x/(exp(x)-1.0);
+bn=x+bp;
+goto theend ;
+}
+
+ii=1;
+fp=1.0;fn=1.0;df=1.0;segno=1.0;
+while (fabs(df) > 2.2204e-16){
+ii++;
+segno= -segno;
+df=df*x/ii;
+fp=fp+df;
+fn=fn+segno*df;
+bp=1/fp;
+bn=1/fn;
+}
+
+
+theend:
+return 0;
+
+}
+
+
+////////////////////////////////////
+//   WRAPPER
+////////////////////////////////////
+// DEFUN_DLD and the macros that it 
+// depends on are defined in the
+// files defun-dld.h, defun.h,
+// and defun-int.h.
+//
+// Note that the third parameter 
+// (nargout) is not used, so it is
+// omitted from the list of arguments 
+// to DEFUN_DLD in order to avoid
+// the warning from gcc about an 
+// unused function parameter. 
+////////////////////////////////////
+
+DEFUN_DLD (Ubern, args, ,
+" [bp,bn]=Ubern(x)\n \
+computes Bernoulli function\n \
+B(x)=x/(exp(x)-1) corresponding to \n \
+to input values Z and -Z, recalling that\n \
+B(-Z)=Z+B(Z)\n")
+{
+  // The list of values to return.  See the declaration in oct-obj.h
+  octave_value_list retval;
+
+
+  NDArray X ( args(0).array_value() );
+  octave_idx_type lx = X.length();
+
+  NDArray BP(X),BN(X);  
+ 
+  for (octave_idx_type jj=0; jj<lx; jj++)
+    Ubern(X(jj),BP(jj),BN(jj));
+
+  retval (0) = BP;
+  retval (1) = BN;
+  
+  return retval	;
+  
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/COPYING.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,345 @@
+
+\begin{verbatim}
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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; either version 2 of the License, or
+    (at your option) any later version.
+
+    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.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+
+
+\end{verbatim}
+\null
+
Binary file extra/secs1d/doc/function/images/secs1d_dd_gummel_map_205.png has changed
Binary file extra/secs1d/doc/function/images/secs1d_dd_newton_819.png has changed
Binary file extra/secs1d/doc/function/images/secs1d_nlpoisson_newton_85.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/function/secs1d_dd_gummel_map.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,183 @@
+\begin{verbatim}
+
+
+ [n, p, V, Fn, Fp, Jn, Jp, it, res] = secs1d_dd_gummel_map (x, D, Na, Nd, 
+                                                       pin, nin, Vin, Fnin, 
+                                                       Fpin, l2, er, u0n, 
+                                                       uminn, vsatn, betan, 
+                                                       Nrefn, u0p, uminp, vsatp, 
+                                                       betap, Nrefp, theta, tn, tp, 
+                                                       Cn, Cp, an, ap, Ecritnin, Ecritpin, 
+                                                       toll, maxit, ptoll, pmaxit)         
+
+ This function solves the scaled stationary bipolar DD 
+ equation system using Gummel algorithm
+
+     input: 
+            x                        spatial grid
+            D, Na, Nd                doping profile
+            pin                      initial guess for hole concentration
+            nin                      initial guess for electron concentration
+            Vin                      initial guess for electrostatic potential
+            Fnin                     initial guess for electron Fermi potential
+            Fpin                     initial guess for hole Fermi potential
+            l2                       scaled Debye length squared
+            er                       relative electric permittivity
+            u0n, uminn, vsatn, Nrefn electron mobility model coefficients
+            u0p, uminp, vsatp, Nrefp hole mobility model coefficients
+            theta                    intrinsic carrier density
+            tn, tp, Cn, Cp, 
+            an, ap, 
+            Ecritnin, Ecritpin       generation recombination model parameters
+            toll                     tolerance for Gummel iterarion convergence test
+            maxit                    maximum number of Gummel iterarions
+            ptoll                    convergence test tolerance for the non linear
+                                     Poisson solver
+            pmaxit                   maximum number of Newton iterarions
+
+     output: 
+             n     electron concentration
+             p     hole concentration
+             V     electrostatic potential
+             Fn    electron Fermi potential
+             Fp    hole Fermi potential
+             Jn    electron current density
+             Jp    hole current density
+             it    number of Gummel iterations performed
+             res   total potential increment at each step
+
+
+\end{verbatim}
+
+
+
+
+\subsection{Demo 1 for unction secs1d\_dd\_gummel\_map}
+\begin{verbatim}
+
+ % physical constants and parameters
+ secs1d_physical_constants;
+ secs1d_silicon_material_properties;
+ 
+ % geometry
+ L  = 10e-6;          % [m] 
+ xm = L/2;
+ 
+ Nelements = 1000;
+ x         = linspace (0, L, Nelements+1)';
+ sinodes   = [1:length(x)];
+ 
+ % dielectric constant (silicon)
+ er = esir * ones (Nelements, 1);
+ 
+ % doping profile [m^{-3}]
+ Na = 1e23 * (x <= xm);
+ Nd = 1e23 * (x > xm);
+ 
+ % avoid zero doping
+ D  = Nd - Na;  
+  
+ % initial guess for n, p, V, phin, phip
+ V_p = -1;
+ V_n =  0;
+ 
+ Fp = V_p * (x <= xm);
+ Fn = Fp;
+ 
+ p = abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni./abs(D)) .^2)) .* (x <= xm) + ...
+     ni^2 ./ (abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni ./ abs (D)) .^2))) .* (x > xm);
+ 
+ n = abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni ./ abs (D)) .^ 2)) .* (x > xm) + ...
+     ni ^ 2 ./ (abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni ./ abs (D)) .^2))) .* (x <= xm);
+ 
+ V = Fn + Vth * log (n / ni);
+ 
+ % scaling factors
+ xbar = L;                       % [m]
+ nbar = norm(D, 'inf');          % [m^{-3}]
+ Vbar = Vth;                     % [V]
+ mubar = max (u0n, u0p);         % [m^2 V^{-1} s^{-1}]
+ tbar = xbar^2 / (mubar * Vbar); % [s]
+ Rbar = nbar / tbar;             % [m^{-3} s^{-1}]
+ Ebar = Vbar / xbar;             % [V m^{-1}]
+ Jbar = q * mubar * nbar * Ebar; % [A m^{-2}]
+ CAubar = Rbar / nbar^3;         % [m^6 s^{-1}]
+ abar = 1/xbar;                  % [m^{-1}]
+ 
+ % scaling procedure
+ l2 = e0 * Vbar / (q * nbar * xbar^2);
+ theta = ni / nbar;
+ 
+ xin = x / xbar;
+ Din = D / nbar;
+ Nain = Na / nbar;
+ Ndin = Nd / nbar;
+ pin = p / nbar;
+ nin = n / nbar;
+ Vin = V / Vbar;
+ Fnin = Vin - log (nin);
+ Fpin = Vin + log (pin);
+ 
+ tnin = tn / tbar;
+ tpin = tp / tbar;
+ 
+ u0nin = u0n / mubar;
+ uminnin = uminn / mubar;
+ vsatnin = vsatn / (mubar * Ebar);
+ 
+ u0pin = u0p / mubar;
+ uminpin = uminp / mubar;
+ vsatpin = vsatp / (mubar * Ebar);
+ 
+ Nrefnin = Nrefn / nbar;
+ Nrefpin = Nrefp / nbar;
+ 
+ Cnin     = Cn / CAubar;
+ Cpin     = Cp / CAubar;
+ 
+ anin     = an / abar;
+ apin     = ap / abar;
+ Ecritnin = Ecritn / Ebar;
+ Ecritpin = Ecritp / Ebar;
+ 
+ % tolerances for convergence checks
+ toll  = 1e-3;
+ maxit = 1000;
+ ptoll = 1e-12;
+ pmaxit = 1000;
+ 
+ % solve the problem using the full DD model
+ [nout, pout, Vout, Fnout, Fpout, Jnout, Jpout, it, res] = ...
+       secs1d_dd_gummel_map (xin, Din, Nain, Ndin, pin, nin, Vin, Fnin, Fpin, ...
+                             l2, er, u0nin, uminnin, vsatnin, betan, Nrefnin, ...
+ 	                       u0pin, uminpin, vsatpin, betap, Nrefpin, theta, ...
+ 		               tnin, tpin, Cnin, Cpin, anin, apin, ...
+ 		               Ecritnin, Ecritpin, toll, maxit, ptoll, pmaxit); 
+ 
+ % Descaling procedure
+ n    = nout*nbar;
+ p    = pout*nbar;
+ V    = Vout*Vbar;
+ Fn   = V - Vth*log(n/ni);
+ Fp   = V + Vth*log(p/ni);
+ dV   = diff(V);
+ dx   = diff(x);
+ E    = -dV./dx;
+ 
+ % band structure
+ Efn  = -Fn;
+ Efp  = -Fp;
+ Ec   = Vth*log(Nc./n)+Efn;
+ Ev   = -Vth*log(Nv./p)+Efp;
+ 
+ plot (x, Efn, x, Efp, x, Ec, x, Ev)
+ legend ('Efn', 'Efp', 'Ec', 'Ev')
+ axis tight
+\end{verbatim}
+
+\begin{figure}\centering
+\includegraphics[width=.7\linewidth]{function/images/secs1d_dd_gummel_map_205.png}
+\caption{Figure produced by demo number 1 for function secs1d\_dd\_gummel\_map}
+\label{fig:secs1d_dd_gummel_map_figure_1}
+\end{figure}
+\clearpage
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/function/secs1d_dd_newton.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,169 @@
+\begin{verbatim}
+
+
+ [n, p, V, Fn, Fp, Jn, Jp, it, res] = secs1d_dd_newton (x, D, Vin, nin, 
+                                                        pin, l2, er, un, 
+                                                        up, theta, tn, tp, 
+                                                        Cn, Cp, toll, maxit)
+
+ Solve the scaled stationary bipolar DD equation system using Newton's method
+
+     input: 
+       x                spatial grid
+       D                doping profile
+       pin              initial guess for hole concentration
+       nin              initial guess for electron concentration
+       Vin              initial guess for electrostatic potential
+       l2               scaled Debye length squared
+       er               relative electric permittivity
+       un               electron mobility model coefficients
+       up               electron mobility model coefficients
+       theta            intrinsic carrier density
+       tn, tp, Cn, Cp   generation recombination model parameters
+       toll             tolerance for Gummel iterarion convergence test
+       maxit            maximum number of Gummel iterarions
+
+     output: 
+       n     electron concentration
+       p     hole concentration
+       V     electrostatic potential
+       Fn    electron Fermi potential
+       Fp    hole Fermi potential
+       Jn    electron current density
+       Jp    hole current density
+       it    number of Gummel iterations performed
+       res   total potential increment at each step
+
+
+\end{verbatim}
+
+
+
+
+\subsection{Demo 1 for function secs1d\_dd\_newton}
+\begin{verbatim}
+
+ % physical constants and parameters
+ secs1d_physical_constants;
+ secs1d_silicon_material_properties;
+ 
+ % geometry
+ L  = 1e-6; % [m] 
+ x  = linspace (0, L, 10)';
+ sinodes = [1:length(x)];
+ 
+ % dielectric constant (silicon)
+ er = esir * ones (numel (x) - 1, 1);
+ 
+ % doping profile [m^{-3}]
+ Na = 1e20 * ones(size(x));
+ Nd = 1e24 * ones(size(x));
+ D  = Nd-Na;  
+ 
+ % externally applied voltages
+ V_p = 10;
+ V_n = 0;
+  
+ % initial guess for phin, phip, n, p, V
+ Fp = V_p * (x <= L/2);
+ Fn = Fp;
+ 
+ p = abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2)).*(D<0)+...
+     ni^2./(abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2))).*(D>0);
+ 
+ n = abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2)).*(D>0)+...
+     ni^2./(abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2))).*(D<0);
+ 
+ V  = Fn + Vth*log(n/ni);
+
+ % scaling factors
+ xbar = L;                         % [m]
+ nbar = norm(D, 'inf');            % [m^{-3}]
+ Vbar = Vth;                       % [V]
+ mubar = max(u0n, u0p);            % [m^2 V^{-1} s^{-1}]
+ tbar = xbar^2/(mubar*Vbar);       % [s]
+ Rbar = nbar/tbar;                 % [m^{-3} s^{-1}]
+ Ebar = Vbar/xbar;                 % [V m^{-1}]
+ Jbar = q*mubar*nbar*Ebar;         % [A m^{-2}]
+ CAubar = Rbar/nbar^3;             % [m^6 s^{-1}]
+ abar = xbar^(-1);                 % [m^{-1}]
+ 
+ % scaling procedure
+ l2 = e0*Vbar/(q*nbar*xbar^2);     
+ theta = ni/nbar;                  
+ 
+ xin = x/xbar;
+ Din = D/nbar;
+ Nain = Na/nbar;
+ Ndin = Nd/nbar;
+ pin = p/nbar;
+ nin = n/nbar;
+ Vin = V/Vbar;
+ Fnin = Vin - log(nin);
+ Fpin = Vin + log(pin);
+ 
+ tnin = tn/tbar;
+ tpin = tp/tbar;
+ 
+ % mobility model accounting scattering from ionized impurities
+ u0nin = u0n/mubar;
+ uminnin = uminn/mubar;
+ vsatnin = vsatn/(mubar*Ebar);
+ 
+ u0pin = u0p/mubar;
+ uminpin = uminp/mubar;
+ vsatpin = vsatp/(mubar*Ebar);
+ 
+ Nrefnin = Nrefn/nbar;
+ Nrefpin = Nrefp/nbar;
+ 
+ Cnin     = Cn/CAubar;
+ Cpin     = Cp/CAubar;
+ 
+ anin     = an/abar;
+ apin     = ap/abar;
+ Ecritnin = Ecritn/Ebar;
+ Ecritpin = Ecritp/Ebar;
+ 
+ % tolerances for convergence checks
+ ptoll = 1e-12;
+ pmaxit = 1000;
+ 
+ % solve the problem using the Newton fully coupled iterative algorithm
+ [nout, pout, Vout, Fnout, Fpout, Jnout, Jpout, it, res] = secs1d_dd_newton (xin, Din, 
+                                                                Vin, nin, pin, l2, er, 
+                                                                u0nin, u0pin, theta, tnin, 
+                                                                tpin, Cnin, Cpin, ptoll, pmaxit);
+ % Descaling procedure
+ n    = nout*nbar;
+ p    = pout*nbar;
+ V    = Vout*Vbar;
+ Fn   = V - Vth*log(n/ni);
+ Fp   = V + Vth*log(p/ni);
+ dV   = diff(V);
+ dx   = diff(x);
+ E    = -dV./dx;
+ 
+ % compute current densities 
+ [Bp, Bm] = bimu_bernoulli (dV/Vth);
+ Jn       =  q*u0n*Vth .* (n(2:end) .* Bp - n(1:end-1) .* Bm) ./ dx; 
+ Jp       = -q*u0p*Vth .* (p(2:end) .* Bm - p(1:end-1) .* Bp) ./ dx;
+ Jtot     =  Jn+Jp;
+ 
+ % band structure
+ Efn  = -Fn;
+ Efp  = -Fp;
+ Ec   = Vth*log(Nc./n)+Efn;
+ Ev   = -Vth*log(Nv./p)+Efp;
+
+ plot (x, Efn, x, Efp, x, Ec, x, Ev)
+ legend ('Efn', 'Efp', 'Ec', 'Ev')
+ axis tight
+\end{verbatim}
+
+\begin{figure}\centering
+\includegraphics[width=.7\linewidth]{function/images/secs1d_dd_newton_819.png}
+\caption{Figure produced by demo number 1 for function secs1d\_dd\_newton}
+\label{fig:secs1d_dd_newton_figure_1}
+\end{figure}
+\clearpage
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/function/secs1d_nlpoisson_newton.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,121 @@
+\begin{verbatim}
+
+
+ [V, n, p, res, niter] = secs1d_nlpoisson_newton (x, sinodes, Vin, nin, pin,
+                                                  Fnin, Fpin, D, l2, er, toll, maxit)
+
+     input:  
+             x       spatial grid
+             sinodes index of the nodes of the grid which are in the semiconductor subdomain
+                     (remaining nodes are assumed to be in the oxide subdomain)
+             Vin     initial guess for the electrostatic potential
+             nin     initial guess for electron concentration
+             pin     initial guess for hole concentration
+             Fnin    initial guess for electron Fermi potential
+             Fpin    initial guess for hole Fermi potential
+             D       doping profile
+             l2      scaled Debye length squared
+             er      relative electric permittivity
+             toll    tolerance for convergence test
+             maxit   maximum number of Newton iterations
+
+     output: 
+             V       electrostatic potential
+             n       electron concentration
+             p       hole concentration
+             res     residual norm at each step
+             niter   number of Newton iterations
+
+
+\end{verbatim}
+
+
+
+
+\subsection{Demo 1 for function secs1d\_nlpoisson\_newton}
+\begin{verbatim}
+
+ secs1d_physical_constants
+ secs1d_silicon_material_properties
+ 
+ tbulk= 1.5e-6;
+ tox = 90e-9;
+ L = tbulk + tox;
+ cox = esio2/tox;
+ 
+ Nx  = 50;
+ Nel = Nx - 1;
+ 
+ x = linspace (0, L, Nx)';
+ sinodes = find (x <= tbulk);
+ xsi = x(sinodes);
+ 
+ Nsi = length (sinodes);
+ Nox = Nx - Nsi;
+ 
+ NelSi   = Nsi - 1;
+ NelSiO2 = Nox - 1;
+ 
+ Na = 1e22;
+ D = - Na * ones (size (xsi));
+ p = Na * ones (size (xsi));
+ n = (ni^2) ./ p;
+ Fn = Fp = zeros (size (xsi));
+ Vg = -10;
+ Nv = 80;
+ for ii = 1:Nv
+     Vg = Vg + 0.2;
+     vvect(ii) = Vg; 
+     
+     V = - Phims + Vg * ones (size (x));
+     V(sinodes) = Fn + Vth * log (n/ni);
+     
+     % Scaling
+     xs  = L;
+     ns  = norm (D, inf);
+     Din = D / ns;
+     Vs  = Vth;
+     xin   = x / xs;
+     nin   = n / ns;
+     pin   = p / ns;
+     Vin   = V / Vs;
+     Fnin  = (Fn - Vs * log (ni / ns)) / Vs;
+     Fpin  = (Fp + Vs * log (ni / ns)) / Vs;
+     
+     er    = esio2r * ones(Nel, 1);
+     l2(1:NelSi) = esi;
+     l2    = (Vs*e0)/(q*ns*xs^2);
+     
+     % Solution of Nonlinear Poisson equation
+     
+     % Algorithm parameters
+     toll  = 1e-10;
+     maxit = 1000;
+     
+     [V, nout, pout, res, niter] = secs1d_nlpoisson_newton (xin, sinodes, 
+                                                            Vin, nin, pin,
+                                                            Fnin, Fpin, Din, l2,
+                                                            er, toll, maxit);
+ 
+     % Descaling
+     n     = nout*ns;
+     p     = pout*ns;
+     V     = V*Vs;
+     
+     qtot(ii) = q * trapz (xsi, p + D - n);
+ end
+ 
+ vvectm = (vvect(2:end)+vvect(1:end-1))/2;
+ C = - diff (qtot) ./ diff (vvect);
+ plot(vvectm, C)
+ xlabel('Vg [V]')
+ ylabel('C [Farad]')
+ title('C-V curve')
+\end{verbatim}
+
+\begin{figure}\centering
+\includegraphics[width=.7\linewidth]{function/images/secs1d_nlpoisson_newton_85.png}
+\caption{Figure produced by demo number 1 for function secs1d\_nlpoisson\_newton}
+\label{fig:secs1d_nlpoisson_newton_figure_1}
+\end{figure}
+\clearpage
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/function/secs1d_physical_constants.m.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,18 @@
+\begin{verbatim}
+
+
+ some useful physical constants 
+
+ Kb       = Boltzman constant
+ q        = quantum of charge
+ e0       = permittivity of free space
+ hplanck  = Plank constant
+ hbar     = Plank constant by 2 pi
+ mn0      = free electron mass
+ T0       = temperature
+ Vth 	   = thermal voltage
+
+
+\end{verbatim}
+
+\clearpage
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/function/secs1d_silicon_material_properties.m.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,42 @@
+\begin{verbatim}
+
+
+ material properties for silicon and silicon dioxide
+
+ esir       = relative electric permittivity of silicon
+ esio2r     = relative electric permittivity of silicon dioxide
+ esi 	      = electric permittivity of silicon
+ esio2      = electric permittivity of silicon dioxide
+ mn         = effective mass of electrons in silicon
+ mh         = effective mass of holes in silicon
+ 
+ u0n        = low field electron mobility
+ u0p        = low field hole mobility
+ uminn      = parameter for doping-dependent electron mobility
+ betan      = idem
+ Nrefn      = idem
+ uminp      = parameter for doping-dependent hole mobility
+ betap      = idem
+ Nrefp      = idem
+ vsatn      = electron saturation velocity
+ vsatp      = hole saturation velocity
+ tp         = electron lifetime
+ tn         = hole lifetime
+ Cn         = electron Auger coefficient
+ Cp         = hole Auger coefficient
+ an         = impact ionization rate for electrons
+ ap         = impact ionization rate for holes
+ Ecritn     = critical field for impact ionization of electrons
+ Ecritp     = critical field for impact ionization of holes 
+ Nc         = effective density of states in the conduction band
+ Nv         = effective density of states in the valence band
+ Egap       = bandgap in silicon
+ EgapSio2   = bandgap in silicon dioxide
+ 
+ ni         = intrinsic carrier density
+ Phims      = metal to semiconductor potential barrier
+
+
+\end{verbatim}
+
+\clearpage
Binary file extra/secs1d/doc/manual.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/doc/manual.tex	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,266 @@
+\documentclass[10pt]{article} 
+\usepackage{geometry} 
+\geometry{a4paper}
+\hoffset=-1cm 
+\usepackage{graphicx} 
+\usepackage{amssymb} 
+\usepackage{epstopdf} 
+\usepackage{cprotect} 
+\usepackage{float} 
+\floatstyle{plain} 
+\newfloat{demo}{thp}{dem} 
+\floatname{demo}{Demo} 
+\newfloat{demoout}{thp}{deo} 
+\floatname{demoout}{Demo Output} 
+\newcommand{\unit}[1]{\mathrm{#1}}
+\newcommand{\electronvolt}{\unit{eV}}
+\newcommand{\kelvin}{\unit{K}}
+\newcommand{\nano}{\unit{n}}
+\newcommand{\meter}{\unit{m}}
+\newcommand{\second}{\unit{s}}
+\newcommand{\volt}{\unit{V}}
+\newcommand{\Ampere}{\unit{A}}
+
+
+\title{secs1d}
+\author{Carlo de Falco \and Riccardo Sacco}
+\begin{document}
+\maketitle
+\tableofcontents
+
+\begin{table}
+\caption{secs1d Package Description}
+\centering
+\begin{tabular}{|l|l|}
+\hline
+{\bf Name: } & secs1d\\  \hline
+{\bf Description: } &
+A Drift-Diffusion simulator for 1d semiconductor devices\\  \hline
+{\bf Version: } & 0.0.9\\  \hline
+{\bf Release Date: } & 2012-03-25\\  \hline
+{\bf Author: } & Carlo de Falco\\   \hline
+{\bf Maintainer: } & Carlo de Falco\\  \hline
+{\bf License: } & GPL version 2 or later\\  \hline
+{\bf Depends on: } &
+octave ($>=$ 3.0.0), bim ($>=$ 0.0.0), \\  \hline
+{\bf Autoload: } &No\\  \hline
+\end{tabular}
+\end{table}
+
+\part{Mathematical models}
+
+\section{Full model}
+\subsection{Conservation laws}
+
+\begin{equation}\label{eq:conservation}
+\left\{
+\begin{array}{ll}
+-\lambda^{2}\mathrm{div}\ \left(\varepsilon_{r} \mathrm{grad}\ 
+\varphi \right) = p - n + N_{D} - N_{A} \\[5mm]
+-\mathrm{div}\ \left(J_{n} \right) + R_{n} \, n = G_{n} \\[5mm]
+\phantom{-}\mathrm{div}\ \left(J_{p} \right) + R_{p} \, p = G_{p}
+\end{array}
+\right.
+\end{equation}
+
+\section{Constitutive relations}
+
+\subsection{Currents}
+
+\begin{equation}\label{eq:currents}
+\left\{
+\begin{array}{ll}
+J_{n} = \phantom{-}\mu_{n} \left( \mathrm{grad}\ n - n\ \mathrm{grad}\ \varphi\right) 
+\\[5mm]
+J_{p} = -\mu_{p} \left( \mathrm{grad}\ p + p\ \mathrm{grad}\ \varphi\right)  
+\end{array}
+\right.
+\end{equation}
+
+\subsection{Mobilities}
+
+\begin{equation}\label{eq:mobilities}
+\left\{
+\begin{array}{ll}
+\mu_{n} = \displaystyle \frac{2\bar{\mu}_{n}}
+{1 + \sqrt{1 + 4 \left( \displaystyle \frac{\bar{\mu}_{n}|E|}{v_{sat,n}}\right)^{2}}}
+; \qquad
+\bar{\mu}_{n} = \mu_{min, n} + 
+\displaystyle \frac{\mu_{0,n} - \mu_{min,n}}
+{1 +\displaystyle \left(\frac{N_{D}+N_{A}}{N_{ref,n}}\right)^{\beta_{n}}}
+\\[10mm]
+\mu_{p} = \displaystyle \frac{2\bar{\mu}_{p}}
+{1 + \sqrt{1 + 4 \left( \displaystyle \frac{\bar{\mu}_{p}|E|}{v_{sat,p}}\right)^{2}}}
+; \qquad
+\bar{\mu}_{p} = \mu_{min, p} + 
+\displaystyle \frac{\mu_{0,p} - \mu_{min,p}}
+{1 +\displaystyle \left(\frac{N_{D}+N_{A}}{N_{ref,p}}\right)^{\beta_{p}}}
+\end{array}
+\right.
+\end{equation}
+
+\subsection{Production terms}
+
+\begin{equation}\label{eq:recombination}
+\left\{
+\begin{array}{ll}
+R_{n} = \displaystyle 
+\frac{p}{\tau_{n} (p + \theta) + \tau_{p} (n + \theta)}
++ p \left(C_{n} n + C_{p} p \right)
+\\[5mm]
+R_{p} = \displaystyle 
+\frac{n}{\tau_{n} (p + \theta) + \tau_{p} (n + \theta)}
++ n \left (C_{n} n + C_{p} p \right)
+\end{array}
+\right.
+\end{equation}
+
+\begin{equation}\label{eq:generation}
+G_{n} = G_{p} = 
+\displaystyle 
+\frac{\theta^{2}}{\tau_{n} (p + \theta) + \tau_{p} (n + \theta)}
++ \theta^{2} \left(C_{n} n + C_{p} p \right)
++ \left(\alpha_{n} |J_{n}|+ \alpha_{p} |J_{p}| \right)
+\end{equation}
+
+%\subsection{Ionization coefficients}
+
+\begin{equation}\label{eq:ioniz_coeff}
+\left\{
+\begin{array}{ll}
+\alpha_{n} = \displaystyle 
+\alpha_{n}^{\infty} \exp \left( -\frac{E_{crit,n}}{|E|} \right)
+\\[5mm]
+\alpha_{p} = \displaystyle 
+\alpha_{p}^{\infty} \exp \left( -\frac{E_{crit,p}}{|E|} \right)
+\end{array}
+\right.
+\end{equation}
+
+\newpage
+
+\section{Simplified model used for Newton's method}
+\subsection{Conservation laws}
+
+\begin{equation}\label{eq:conservationN}
+\left\{
+\begin{array}{ll}
+-\lambda^{2}\mathrm{div}\ \left(\varepsilon_{r} 
+\mathrm{grad}\ \varphi \right) = p - n + N_{D} - N_{A} \\[5mm]
+-\mathrm{div}\ \left(J_{n} \right) + R_{n} \, n = G_{n} \\[5mm]
+\phantom{-}\mathrm{div}\ \left(J_{p} \right) + R_{p} \, p = G_{p}
+\end{array}
+\right.
+\end{equation}
+
+\section{Constitutive relations}
+
+\subsection{Currents}
+
+\begin{equation}\label{eq:currentsN}
+\left\{
+\begin{array}{ll}
+J_{n} = \phantom{-}\mu_{n} \left( \mathrm{grad}\ n - n\ \mathrm{grad}\ \varphi\right) 
+\\[5mm]
+J_{p} = -\mu_{p} \left( \mathrm{grad}\ p + p\ \mathrm{grad}\ \varphi\right)  
+\end{array}
+\right.
+\end{equation}
+
+\subsection{Production terms}
+
+\begin{equation}\label{eq:recombinationN}
+\left\{
+\begin{array}{ll}
+R_{n} = \displaystyle \frac{p}{\tau_{n} (p + \theta) + \tau_{p} (n + \theta)}
++ p \left(C_{n} n + C_{p} p \right)
+\\[5mm]
+R_{p} = \displaystyle \frac{n}{\tau_{n} (p + \theta) + \tau_{p} (n + \theta)}
++ n \left (C_{n} n + C_{p} p \right)
+\end{array}
+\right.
+\end{equation}
+
+\begin{equation}\label{eq:generationN}
+G_{n} = G_{p} = 
+\displaystyle \frac{\theta^{2}}{\tau_{n} (p + \theta) + \tau_{p} (n + \theta)}
++ \theta^{2} \left(C_{n} n + C_{p} p \right)
+\end{equation}
+
+\newpage
+
+\section{Scaling factors/adimensional parameters}
+
+Given any generic quantity $u$ having units $U$, we
+define the {\em scaled} quantity $\widehat{u}$ as
+$$
+\widehat{u} : = \displaystyle \frac{u}{\overline{u}}
+$$
+where $\overline{u}$ is the scaling factor associated with $u$
+and having the same units as $u$. 
+
+\begin{table}[h!]
+\begin{center}
+\begin{tabular}{lll}\hline
+\textbf{Scaling factor}	& \textbf{Value} & \textbf{Units}\\ \hline
+$\overline{x}$            & $L$            & $\meter$ \\[1mm]
+$\overline{n}$            & $\| N_D^+ - N_A^-\|_{L^{\infty}(0,L)}$  
+& $\meter^{-3}$ \\[1mm]
+$\overline{\varphi}$      & $K_B T / q \simeq 26 \cdot 10^{-3}$ 
+& $\volt$ \\[1mm]
+$\overline{\mu}$          & $\max\left\{ \mu_{0,n}, \, \mu_{0,p}\right\}$ 
+&  $\meter^2\,\volt^{-1}\,\second^{-1}$ \\[1mm]
+$\overline{t}$          & $\overline{x}^2/(\overline{\mu} \, \overline{\varphi})$
+&  $\second$ \\[1mm]
+$\overline{R}$          & $\overline{n}/\overline{t}$
+&  $\meter^{-3} \second^{-1}$ \\[1mm]
+$\overline{E}$          & $\overline{\varphi}/\overline{x}$
+&  $\volt \meter^{-1}$  \\[1mm]
+$\overline{J}$          & $q \, \overline{\mu} \, \overline{n} \, 
+\overline{E}$ &  $\Ampere \meter^{-2}$  \\[1mm]
+$\overline{\alpha}$ & $\overline{x}^{-1}$ & $\meter^{-1}$ \\[1mm]
+$\overline{C}_{Au}$ & $\overline{R}/\overline{n}^3$ & 
+$\meter^{6} \second^{-1}$ \\[1mm]
+\hline
+\end{tabular}
+\caption{Scaling factors for the Drift-Diffusion model equations.}
+\label{tab:model_param_1d}
+\end{center}
+\end{table}
+
+We also introduce the following adimensional numbers
+$$
+\lambda^2:= \displaystyle \frac{\varepsilon_0 \overline{\varphi}}
+{q \, \overline{n} \, \overline{x}^2}, \qquad
+\theta:= \displaystyle \frac{n_i}{\overline{n}}
+$$
+having the meaning of squared normalized Debye length and
+normalized intrinsic concentration, respectively.
+
+\part{Function reference}
+
+\section{Drift-Diffusion solvers}
+
+\subsection{secs1d\_dd\_gummel\_map}
+\input{function/secs1d_dd_gummel_map.tex}
+
+\subsection{secs1d\_dd\_newton}
+\input{function/secs1d_dd_newton.tex}
+
+\section{Non-linear Poisson solver}
+\subsection{secs1d\_nlpoisson\_newton}
+\input{function/secs1d_nlpoisson_newton.tex}
+
+\section{Physical constants and material properties}
+\subsection{secs1d\_physical\_constants.m}
+\input{function/secs1d_physical_constants.m.tex}
+
+\subsection{secs1d\_silicon\_material\_properties.m}
+\input{function/secs1d_silicon_material_properties.m.tex}
+
+\appendix
+\section{Licence}
+\input{COPYING.tex}
+
+ 
+\end{document}
\ No newline at end of file
--- a/extra/secs1d/inst/DDG/DDGelectron_driftdiffusion.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{n}} = DDGelectron_driftdiffusion(@var{psi},@var{x},@var{ng},@var{p},@var{ni},@var{tn},@var{tp},@var{un})
-##
-## Solve the continuity equation for electrons
-##
-## Input:
-## @itemize @minus
-## @item psi: electric potential
-## @item x: integration domain
-## @item ng: initial guess and BCs for electron density
-## @item p: hole density (for SRH recombination)
-## @end itemize
-##
-## Output:
-## @itemize @minus
-## @item n: updated electron density
-## @end itemize
-##
-## @end deftypefn
-
-function n = DDGelectron_driftdiffusion(psi,x,ng,p,ni,tn,tp,un)
-
-nodes        = x;
-Nnodes     =length(nodes);
-
-elements   = [[1:Nnodes-1]' [2:Nnodes]'];
-Nelements=size(elements,1);
-
-Bcnodes = [1;Nnodes];
-
-nl = ng(1);
-nr = ng(Nnodes);
-h=nodes(elements(:,2))-nodes(elements(:,1));
-
-c=1./h;
-Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
-Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
-
-
-d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
-d1    = [1000;-c.* Bpos];
-dm1   = [-c.* Bneg;1000];
-
-A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
-b = zeros(Nnodes,1);%- A * ng;
-
-  ## SRH Recombination term
-SRHD = tp * (ng + ni) + tn * (p + ni);
-SRHL = p ./ SRHD;
-SRHR = ni.^2 ./ SRHD;
-
-ASRH = Ucompmass (nodes,Nnodes,elements,Nelements,SRHL,ones(Nelements,1));
-bSRH = Ucompconst (nodes,Nnodes,elements,Nelements,SRHR,ones(Nelements,1));
-
-A = A + ASRH;
-b = b + bSRH;
-
-  ## Boundary conditions
-b(Bcnodes)   = [];
-b(1)         = - A(2,1) * nl;
-b(end)       = - A(end-1,end) * nr;
-A(Bcnodes,:) = [];
-A(:,Bcnodes) = [];
-
-n = [nl; A\b ;nr];
-
-endfunction
-
--- a/extra/secs1d/inst/DDG/DDGgummelmap.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{odata},@var{it},@var{res}} =  DDGgummelmap(@var{x},@var{idata},@var{toll},@var{maxit},@var{ptoll},@var{pmaxit},@var{verbose})
-##
-## Solve the scaled stationary bipolar DD equation system using Gummel
-## algorithm
-##
-## Input:
-## @itemize @minus
-## @item x: spatial grid
-## @item idata.D: doping profile
-## @item idata.p: initial guess for hole concentration
-## @item idata.n: initial guess for electron concentration
-## @item idata.V: initial guess for electrostatic potential
-## @item idata.Fn: initial guess for electron Fermi potential
-## @item idata.Fp: initial guess for hole Fermi potential
-## @item idata.l2: scaled electric permittivity (diffusion coefficient in Poisson equation)
-## @item idata.un: scaled electron mobility
-## @item idata.up: scaled electron mobility
-## @item idata.nis: scaled intrinsic carrier density
-## @item idata.tn: scaled electron lifetime
-## @item idata.tp: scaled hole lifetime
-## @item toll: tolerance for Gummel iterarion convergence test
-## @item maxit: maximum number of Gummel iterarions
-## @item ptoll: tolerance for Newton iterarion convergence test for non linear Poisson
-## @item pmaxit: maximum number of Newton iterarions
-## @item verbose: verbosity level (0,1,2)
-## @end itemize
-##
-## Output:
-## @itemize @minus
-## @item odata.n: electron concentration
-## @item odata.p: hole concentration
-## @item odata.V: electrostatic potential
-## @item odata.Fn: electron Fermi potential
-## @item odata.Fp: hole Fermi potential
-## @item it: number of Gummel iterations performed
-## @item res: total potential increment at each step
-## @end itemize
-##
-## @end deftypefn
-
-function [odata,it,res] = DDGgummelmap (x,idata,toll,maxit,ptoll,pmaxit,verbose)
-
-  odata  = idata;
-Nnodes=rows(x);
-
-D         = idata.D;
-vout(:,1) = idata.V;
-
-hole_density (:,1) = idata.p;
-electron_density (:,1)= idata.n;
-fermin (:,1)=idata.Fn;
-fermip (:,1)=idata.Fp;
-
-for i=1:1:maxit
-	if (verbose>1)
-      fprintf(1,"*****************************************************************\n");  
-      fprintf(1,"****    start of gummel iteration number: %d\n",i);
-      fprintf(1,"*****************************************************************\n");  
-    endif
-    
-    if (verbose>1)
-      fprintf(1,"solving non linear poisson equation\n\n");
-    endif
-
-    [vout(:,2),electron_density(:,2),hole_density(:,2)] =\
-	DDGnlpoisson (x,[1:Nnodes],vout(:,1),electron_density(:,1),hole_density(:,1),fermin(:,1),fermip(:,1),D,idata.l2,ptoll,pmaxit,verbose);
-	
-    if (verbose>1)
-      fprintf (1,"\n\nupdating electron qfl\n\n");
-    endif
-    electron_density(:,3)=\
-	DDGelectron_driftdiffusion(vout(:,2), x, electron_density(:,2),hole_density(:,2),idata.nis,idata.tn,idata.tp,idata.un);
-    
-    fermin(:,2) = DDGn2phin(vout(:,2),electron_density(:,3));
-    fermin(1,2)   = idata.Fn(1);
-    fermin(end:2) = idata.Fn(end);
-    
-	if (verbose>1)
-      fprintf(1,"updating hole qfl\n\n");
-    endif
-
-    hole_density(:,3) = \
-    DDGhole_driftdiffusion(vout(:,2), x, hole_density(:,2),electron_density(:,2),idata.nis,idata.tn,idata.tp,idata.up);
-
-    fermip(:,2) = DDGp2phip(vout(:,2),hole_density(:,3));
-    fermip(1,2)   = idata.Fp(1);
-    fermip(end,2) = idata.Fp(end);
-    
-    if (verbose>1)
-      fprintf(1,"checking for convergence\n\n");
-    endif
-
-	nrfn= norm(fermin(:,2)-fermin(:,1),inf);
-	nrfp= norm (fermip(:,2)-fermip(:,1),inf);
-	nrv = norm (vout(:,2)-vout(:,1),inf);
-	nrm(i) = max([nrfn;nrfp;nrv]);
-	
-	if (verbose>1)
-      fprintf (1," max(|phin_(k+1)-phinn_(k)| , |phip_(k+1)-phip_(k)| , |v_(k+1)- v_(k)| )= %d\n",nrm(i));
-    endif
-
-	if (nrm(i)<toll)
-		break
-    endif
-
-	vout(:,1) = vout(:,end);
-	hole_density (:,1) = hole_density (:,end) ;
-	electron_density (:,1)= electron_density (:,end);
-	fermin (:,1)= fermin (:,end);
-	fermip (:,1)= fermip (:,end);
-	
-	
-	if(verbose)
-		DDGplotresults(x,electron_density,hole_density,vout,fermin,fermip);		
-    endif
-  endfor
-
-it = i;
-res = nrm;
-
-if (verbose>0)
-    fprintf(1,"\n\nInitial guess computed by DD: # of Gummel iterations = %d\n\n",it);
-  endif
-
-odata.n     = electron_density(:,end);
-odata.p     = hole_density(:,end);
-odata.V     = vout(:,end);
-odata.Fn    = fermin(:,end);
-odata.Fp    = fermip(:,end);
-
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/DDG/DDGhole_driftdiffusion.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{p}} = DDGhole_driftdiffusio(@var{psi},@var{x},@var{pg},@var{n},@var{ni},@var{tn},@var{tp},@var{up})
-##
-## Solve the continuity equation for holes
-##
-## Input:
-## @itemize @minus
-## @item psi: electric potential
-## @item x: spatial grid
-## @item ng: initial guess and BCs for electron density
-## @item n: electron density (for SRH recombination)
-## @end itemize
-##
-## Output:
-## @itemize @minus
-## @item p: updated hole density
-## @end itemize
-##
-## @end deftypefn
-
-function p = DDGhole_driftdiffusion(psi,x,pg,n,ni,tn,tp,up)
-
-nodes        = x;
-Nnodes     =length(nodes);
-elements   = [[1:Nnodes-1]' [2:Nnodes]'];
-Nelements=size(elements,1);
-Bcnodes = [1;Nnodes];
-
-pl = pg(1);
-pr = pg(Nnodes);
-h=nodes(elements(:,2))-nodes(elements(:,1));
-c=up./h;
-Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
-Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
-
-
-d0    = [c(1).*Bpos(1); c(1:end-1).*Bneg(1:end-1)+c(2:end).*Bpos(2:end); c(end)*Bneg(end)];
-d1    = [1000;-c.* Bneg];
-dm1   = [-c.* Bpos;1000];
-
-A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
-  b = zeros(Nnodes,1);## - A * pg;
-
-  ## SRH Recombination term
-SRHD = tp * (n + ni) + tn * (pg + ni);
-SRHL = n ./ SRHD;
-SRHR = ni.^2 ./ SRHD;
-
-ASRH = Ucompmass (nodes,Nnodes,elements,Nelements,SRHL,ones(Nelements,1));
-bSRH = Ucompconst (nodes,Nnodes,elements,Nelements,SRHR,ones(Nelements,1));
-
-A = A + ASRH;
-b = b + bSRH;
-
-  ## Boundary conditions
-b(Bcnodes)   = [];
-b(1)         = - A(2,1) * pl;
-b(end)       = - A(end-1,end) * pr;
-A(Bcnodes,:) = [];
-A(:,Bcnodes) = [];
-
-p = [pl; A\b ;pr];
-
-endfunction
-
-
--- a/extra/secs1d/inst/DDG/DDGn2phin.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-  
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{phin}} = DDGn2phin(@var{V},@var{n})
-##
-## Compute the qfl for electrons using Maxwell-Boltzmann statistics.
-##
-## @end deftypefn
-  
-function phin = DDGn2phin (V,n);
-
-  ## Load constants
-  nmin = 0;
-n    = n .* (n>nmin) + nmin * (n<=nmin); 
-phin = V - log(n) ;
-
-endfunction
--- a/extra/secs1d/inst/DDG/DDGnlpoisson.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{V},@var{n},@var{p},@var{res},@var{niter}} = @
-## DDGnlpoisson(@var{x},@var{sinodes},@var{Vin},@var{nin},@var{pin},@var{Fnin},@var{Fpin},@var{D},@var{l2},@var{toll},@var{maxit},@var{verbose})
-##
-## Solve the non linear Poisson equation
-## 
-## - lamda^2 *V'' + (n(V,Fn) - p(V,Fp) -D) = 0 
-##
-## Input:
-## @itemize @minus
-## @item x: spatial grid
-## @item sinodes: index of the nodes of the grid which are in the
-## semiconductor subdomain (remaining nodes are assumed to be in the oxide subdomain)
-## @item Vin: initial guess for the electrostatic potential
-## @item nin: initial guess for electron concentration
-## @item pin: initial guess for hole concentration
-## @item Fnin: initial guess for electron Fermi potential
-## @item Fpin: initial guess for hole Fermi potential
-## @item D: doping profile
-## @item l2: scaled electric permittivity (diffusion coefficient)
-## @item toll: tolerance for convergence test
-## @item maxit: maximum number of Newton iterations
-## @item verbose: verbosity level (0,1,2)
-## @end itemize
-##
-## Output:
-## @itemize @minus
-## @item V: electrostatic potential
-## @item n: electron concentration
-## @item p: hole concentration
-## @item res: residual norm at each step
-## @item niter: number of Newton iterations
-## @end itemize
-##
-## @end deftypefn
-
-function [V,n,p,res,niter] = DDGnlpoisson (x,sinodes,Vin,nin,pin,Fnin,Fpin,D,l2,toll,maxit,verbose)
-
-  ## Set some useful constants
-dampit 		= 10;
-dampcoeff	= 2;
-
-  ## Convert grid info to FEM form
-Ndiricheletnodes 	= 2;
-nodes 		        = x;
-sielements          = sinodes(1:end-1);
-Nnodes		        = length(nodes);
-totdofs             = Nnodes - Ndiricheletnodes ;
-elements            = [[1:Nnodes-1]' , [2:Nnodes]'];
-Nelements           = size(elements,1);
-BCnodes             = [1;Nnodes];
-
-  ## Initialization
-V = Vin;
-Fn = Fnin;
-Fp = Fpin;
-n = DDGphin2n(V(sinodes),Fn);
-p = DDGphip2p(V(sinodes),Fp);
-if (sinodes(1)==1)
-    n(1)=nin(1);
-    p(1)=pin(1);
-  endif
-if (sinodes(end)==Nnodes)
-    n(end)=nin(end);
-    p(end)=pin(end);
-  endif
-
-  ## Compute LHS matrices
-L      = Ucomplap (nodes,Nnodes,elements,Nelements,l2.*ones(Nelements,1));
-
-  ## Compute Mv =  ( n + p)
-Mv            =  zeros(Nnodes,1);
-Mv(sinodes)   =  (n + p);
-Cv            =  zeros(Nelements,1);
-Cv(sielements)=  1;
-M             =  Ucompmass (nodes,Nnodes,elements,Nelements,Mv,Cv);
-
-  ## Compute RHS vector
-Tv0            =  zeros(Nnodes,1);
-Tv0(sinodes)   = (n - p - D);
-Cv            =  zeros(Nelements,1);
-Cv(sielements)=  1;
-T0             =  Ucompconst (nodes,Nnodes,elements,Nelements,Tv0,Cv);
-
-  ## Build LHS matrix and RHS of the linear system for 1st Newton step
-A 		= L + M;
-R 		= L * V  + T0; 
-
-  ## Apply boundary conditions
-A(BCnodes,:)	= [];
-A(:,BCnodes)	= [];
-R(BCnodes)	= [];
-
-
-normr(1)		=  norm(R,inf);
-relresnorm 	= 1;
-reldVnorm   = 1;
-normrnew	= normr(1);
-
-
-  ## Start of the newton cycle
-for newtit=1:maxit
-    if verbose
-        fprintf(1,"\n newton iteration: %d, reldVnorm = %e",newtit,reldVnorm);
-    endif
-    dV =[0;(A)\(-R);0];
-    
-    ## Start of the damping procedure
-    tk = 1;
-    for dit = 1:dampit
-        if verbose
-        fprintf(1,"\n damping iteration: %d, residual norm = %e",dit,normrnew);
-      endif
-        Vnew   = V + tk * dV;
-        n = DDGphin2n(Vnew(sinodes),Fn);
-        p = DDGphip2p(Vnew(sinodes),Fp);
-        if (sinodes(1)==1)
-            n(1)=nin(1);
-            p(1)=pin(1);
-      endif
-        if (sinodes(end)==Nnodes)
-            n(end)=nin(end);
-            p(end)=pin(end);
-      endif
-        
-      ## Compute LHS matrices
-        Mv            =  zeros(Nnodes,1);
-        Mv(sinodes)   =  (n + p);
-        Cv            =  zeros(Nelements,1);
-        Cv(sielements)=  1;        
-        M    = Ucompmass (nodes,Nnodes,elements,Nelements,Mv,Cv);
-        
-      ## Compute RHS vector (-residual)
-        Tv0            =  zeros(Nnodes,1);
-        Tv0(sinodes)   =  (n - p - D);
-        Cv            =  zeros(Nelements,1);
-        Cv(sielements)=  1;
-        T0     = Ucompconst (nodes,Nnodes,elements,Nelements,Tv0,Cv);
-        
-      ## Build LHS matrix and RHS of the linear system for 1st Newton step
-        Anew 		= L + M;
-        Rnew 		= L * Vnew  + T0; 
-        
-      ## Apply boundary conditions
-        Anew(BCnodes,:)	= [];
-        Anew(:,BCnodes)	= [];
-        Rnew(BCnodes)	= [];
-        
-        if ((dit>1)&(norm(Rnew,inf)>=norm(R,inf)))
-            if verbose
-          fprintf(1,"\nexiting damping cycle \n");
-        endif
-            break
-        else
-            A = Anew;
-            R = Rnew;
-      endif
-    
-      ## Compute | R_{k+1} | for the convergence test
-        normrnew= norm(R,inf);
-        
-      ## Check if more damping is needed
-        if (normrnew > normr(newtit))
-            tk = tk/dampcoeff;
-        else
-            if verbose
-          fprintf(1,"\nexiting damping cycle because residual norm = %e \n",normrnew);
-        endif		
-            break
-      endif	
-    endfor
-
-    V		            = Vnew;	
-    normr(newtit+1) 	= normrnew;
-    dVnorm              = norm(tk*dV,inf);
-
-    ## Check if convergence has been reached
-    reldVnorm           = dVnorm / norm(V,inf);
-    if (reldVnorm <= toll)
-        if(verbose)
-        fprintf(1,"\nexiting newton cycle because reldVnorm= %e \n",reldVnorm);
-      endif
-        break
-    endif
-
-  endfor
-
-res = normr;
-niter = newtit;
-
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/DDG/DDGp2phip.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-## SECS1D 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.
-##
-## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{phip}} = DDGn2phin(@var{V},@var{p})
-##
-## Compute the qfl for holes using Maxwell-Boltzmann statistics
-##
-## @end deftypefn
-  
-function phip = DDGp2phip (V,p);
-
-  ## Load constants
-  pmin = 0;
-  p    = p .* (p>pmin) + pmin * (p<=pmin);
-  phip = V + log(p) ;
-  
-endfunction
--- a/extra/secs1d/inst/DDG/DDGphin2n.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{n}} = DDGphin2n(@var{V},@var{phin})
-##
-## Compute the electron density using Maxwell-Boltzmann statistics
-##
-## @end deftypefn
-  
-function n = DDGphin2n (V,phin);
-  
-  nmin = 0;
-  n =  exp ((V-phin));
-  n = n .* (n>nmin) + nmin * (n<=nmin);
-
-endfunction
--- a/extra/secs1d/inst/DDG/DDGphip2p.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-  
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{p}} = DDGphip2p(@var{V},@var{phip})
-##
-## Compute the hole density using Maxwell-Boltzmann statistic
-##
-## @end deftypefn
-  
-function p = DDGphip2p (V,phip);
-
-## Load constants
-pmin = 0;
-p = exp ((phip-V));
-p = p .* (p>pmin) + pmin * (p<=pmin);
-
-endfunction
--- a/extra/secs1d/inst/DDG/DDGplotresults.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## DDGplotresults(@var{x},@var{n},@var{p},@var{V},@var{Fn},@var{Fp})
-##
-## Plot densities and potentials
-##
-## @end deftypefn
-
-function DDGplotresults(x,n,p,V,Fn,Fp);
-  
-subplot(2,3,1)
-title('Electron Density')
-semilogy(x,n)
-
-subplot(2,3,2)
-title('Hole Density')
-semilogy(x,p)
-
-subplot(2,3,4)
-title('Electron QFL')
-plot(x,Fn)
-
-subplot(2,3,5)
-title('Hole QFL')
-plot(x,Fp)
-
-subplot(2,3,6)
-title('Electric Potential')
-plot(x,V)
-pause(.1)
-
-endfunction
--- a/extra/secs1d/inst/DDN/DDNnewtonmap.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-##  SECS1D 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.
-##
-##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{odata},@var{it},@var{res}} = DDNnewtonmap(@var{x},@var{idata},@var{toll},@var{maxit},@var{verbose})
-##
-## Solve the scaled stationary bipolar DD equation system using a
-## coupled Newton algorithm
-##
-## Input:
-## @itemize @minus
-## @item x: spatial grid
-## @item idata.D: doping profile
-## @item idata.p: initial guess for hole concentration
-## @item idata.n: initial guess for electron concentration
-## @item idata.V: initial guess for electrostatic potential
-## @item idata.Fn: initial guess for electron Fermi potential
-## @item idata.Fp: initial guess for hole Fermi potential
-## @item idata.l2: scaled electric permittivity (diffusion coefficient in Poisson equation)
-## @item idata.un: scaled electron mobility
-## @item idata.up: scaled electron mobility
-## @item idata.nis: scaled intrinsic carrier density
-## @item idata.tn: scaled electron lifetime
-## @item idata.tp: scaled hole lifetime
-## @item toll: tolerance for Newton iterarion convergence test
-## @item maxit: maximum number of Newton iterarions
-## @item verbose: verbosity level: 0,1,2
-## @end itemize
-##
-## Output:
-## @itemize @minus
-## @item odata.n: electron concentration
-## @item odata.p: hole concentration
-## @item odata.V: electrostatic potential
-## @item odata.Fn: electron Fermi potential
-## @item odata.Fp: hole Fermi potential
-## @item it: number of Newton iterations performed
-## @item res: residual at each step
-## @end itemize
-##
-## @end deftypefn
-
-function [odata,it,res] = DDNnewtonmap (x,idata,toll,maxit,verbose)
-
-  odata     = idata;
-  Nnodes    = rows(x);
-Nelements=Nnodes-1;
-elements=[1:Nnodes-1;2:Nnodes]';
-BCnodesp = [1,Nnodes];
-BCnodes = [BCnodesp,BCnodesp+Nnodes,BCnodesp+2*Nnodes];
-totaldofs= Nnodes-2;
-dampcoef = 2;
-maxdamp  = 2;
-
-V = idata.V;
-n = idata.n;
-p = idata.p;
-D = idata.D;
-
-  ## Create the complete unknown vector
-u = [V; n; p];
-
-  ## Build fem matrices
-L = Ucomplap (x,Nnodes,elements,Nelements,idata.l2*ones(Nelements,1));
-M = Ucompmass (x,Nnodes,elements,Nelements,ones(Nnodes,1),ones(Nelements,1));
-DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,V);
-DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-V);
-
-  ## Initialise RHS 
-r1  = L * V + M * (n - p - D); 
-r2  = DDn * n;
-r3  = DDp * p;
-  RHS = - [ r1; r2; r3 ];
-
-  ##  Apply BCs
-RHS(BCnodes,:)= [];
-nrm = norm(RHS,inf);
-res(1) = nrm;
-
-  ## Begin Newton Cycle
-for count = 1: maxit
-  if verbose
-      fprintf (1,"\n\n\nNewton Iteration Number:%d\n",count);	
-    endif
-    Ln = Ucomplap (x,Nnodes,elements,Nelements,Umediaarmonica(idata.un*n));
-    Lp = Ucomplap (x,Nnodes,elements,Nelements,Umediaarmonica(idata.up*p));
-    Z  = sparse(zeros(Nnodes));    
-    DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,V);
-    DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-V);
-    
-    A 	= L;
-    B	= M;
-    C	= -M;
-    DDD	= -Ln;
-    E	= DDn;
-    F	= Z;
-    G	= Lp;
-    H	= Z;
-    I	= DDp;
-    
-    ## Build LHS
-    LHS =sparse([
-	[A	B C];
-	[DDD    E F];
-	[G      H I];
-    ]);
-    
-    ## Apply BCs
-    LHS(BCnodes,:)=[];    
-    LHS(:,BCnodes)=[];
-    
-    ## Solve the linearised system
-    dutmp = (LHS) \ (RHS);
-    dv    = dutmp(1:totaldofs);
-    dn    = dutmp(totaldofs+1:2*totaldofs);
-    dp    = dutmp(2*totaldofs+1:3*totaldofs);
-    du    = [0;dv;0;0;dn;0;0;dp;0];
-    
-    ## Check Convergence
-    nrm_u = norm(u,inf);
-    nrm_du = norm(du,inf);
-	
-    ratio = nrm_du/nrm_u; 
-    if verbose
-      fprintf (1,"ratio = %e\n", ratio);		
-    endif
-    
-    if (ratio <= toll)
-        V 	    = u(1:Nnodes);
-        n	    = u(Nnodes+1:2*Nnodes);
-        p	    = u(2*Nnodes+1:end);
-        res(count)  = nrm;
-        break;
-    endif
-
-    ## Begin damping cycle
-    tj = 1;
-    
-    for cc = 1:maxdamp
-      if verbose
-        fprintf (1,"\ndamping iteration number:%d\n",cc);
-        fprintf (1,"reference residual norm:%e\n",nrm);
-      endif
-      ## Update the unknown vector		
-        utmp    = u + tj*du;
-        Vnew 	    = utmp(1:Nnodes);
-        nnew	    = utmp(Nnodes+1:2*Nnodes);
-        pnew	    = utmp(2*Nnodes+1:end);
-      ## Try a new RHS
-        DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,Vnew);
-        DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-Vnew);
-        
-        r1  = L * V + M * (nnew - pnew - D); 
-        r2  = DDn * nnew;
-        r3  = DDp * pnew;
-        
-      RHS =- [r1;r2;r3];
-        
-      ## Apply BCs
-      RHS(BCnodes,:) = [];
-        nrmtmp=norm(RHS,inf);
-        
-      ## Update the damping coefficient
-        if verbose
-	fprintf(1,"residual norm:%e\n\n", nrmtmp);
-      endif
-        
-		if (nrmtmp>nrm)
-			tj = tj/(dampcoef*cc);
-			if verbose
-	  fprintf (1,"\ndamping coefficients = %e",tj);    
-	endif
-        else
-			break;
-      endif
-    endfor
-
-    nrm_du = norm(tj*du,inf);
-    u 	= utmp;
-    
-    if (count>1)
-        ratio = nrm_du/nrm_du_old;
-        if (ratio<.005)
-            V 	    = u(1:Nnodes);
-            n	    = u(Nnodes+1:2*Nnodes);
-            p	    = u(2*Nnodes+1:end);            
-            res(count)  = nrm;
-            break;           
-      endif
-    endif
-    nrm = nrmtmp;
-    res(count)  = nrm;
-	
-    ## Convert result vector into distinct output vectors 
-    V 	    = u(1:Nnodes);
-    n	    = u(Nnodes+1:2*Nnodes);
-    p	    = u(2*Nnodes+1:end);    
-    nrm_du_old = nrm_du;
-  endfor
-
-odata.V = V;
-odata.n = n;
-odata.p = p;
-Fn   = V - log(n);
-Fp   = V + log(p);
-it   = count; 
-
-endfunction
-
-
-
-
--- a/extra/secs1d/inst/Utilities/Ubern.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File} {@var{bp},@var{bn}} = Ubern(@var{x})
-##
-## Compute Bernoulli function for scalar x:
-##
-## @itemize @minus
-## @item @var{bp} = @var{x}/(exp(@var{x})-1)
-## @item @var{bn} = @var{x} + B( @var{x} )
-## @end itemize
-##
-## @end deftypefn
-
-function [bp,bn] = Ubern(x)
-     
-xlim=1e-2;
-ax=abs(x);
-
-  ## Compute Bernoulli function for x = 0
-
-if (ax == 0)
-   bp=1.;
-   bn=1.;
-   return
-  endif
-
-  ## Compute Bernoulli function for asymptotic values
-
-  if (ax > 80)
-    if (x > 0)
-      bp=0.;
-      bn=x;
-      return
-   else
-      bp=-x;
-      bn=0.;
-      return
-    endif
-  endif
-
-  ## Compute Bernoulli function for intermediate values
-
-  if (ax > xlim)
-   bp=x/(exp(x)-1);
-   bn=x+bp;
-   return
-else
-    ## Compute Bernoulli function for small x
-    ## via Taylor expansion
-
-   ii=1;
-   fp=1.;
-   fn=1.;
-   df=1.;
-   segno=1.;
-   while (abs(df) > eps),
-     ii=ii+1;
-     segno=-segno;
-     df=df*x/ii;
-     fp=fp+df;
-     fn=fn+segno*df;
-     bp=1./fp;
-     bn=1./fn;
-    endwhile
-   return
-  endif
-
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/Utilities/Ubernoulli.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File} {@var{b}} = Ubernoulli(@var{x},@var{sg})
-##
-## Compute Bernoulli function for vector x:
-##
-## @itemize @minus
-## @item @var{b} = @var{x}/(exp(@var{x})-1) if @var{sg} == 1
-## @item @var{b} = @var{x} + B( @var{x} ) if @var{sg} == 0
-## @end itemize
-##
-## @end deftypefn
-
-function b=Ubernoulli(x,sg)
-  
-  for count=1:length(x)
-    [bp,bn] = Ubern(x(count));
-    bernp(count,1)=bp;
-    bernn(count,1)=bn;
-  endfor
-  
-  if (sg ==1)
-    b=bernp;
-  elseif (sg ==0)
-    b=bernn;
-  endif
-  
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/Utilities/Ucompconst.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-  
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{R}} = Ucompconst(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{D},@var{C})
-##
-## Compute P1 finite element rhs:
-##
-## @itemize @minus
-## @item @var{nodes}: list of mesh nodes
-## @item @var{Nnodes}: number of mesh nodes
-## @item @var{elements}: list of mesh elements 
-## @item @var{Nelements}: number of mesh elements
-## @item @var{D}: piecewise linear reaction coefficient
-## @item @var{C}: piecewise constant reaction coefficient
-## @end itemize
-##
-## @end deftypefn
-  
-function R = Ucompconst (nodes,Nnodes,elements,Nelements,D,C)
-  
-  h = (nodes(2:end)-nodes(1:end-1)).*C;
-  R = D.*[h(1)/2; (h(1:end-1)+h(2:end))/2; h(end)/2];
-  
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/Utilities/Ucomplap.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-  
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{R}} = Ucomplap(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{coeff})
-##
-## Compute P1 finite element approximation of the differential operator:
-## 
-##  - d ( coeff d (.)\dx)\dx
-##
-## @itemize @minus
-## @item @var{nodes}: list of mesh nodes
-## @item @var{Nnodes}: number of mesh nodes
-## @item @var{elements}: list of mesh elements 
-## @item @var{Nelements}: number of mesh elements
-## @item @var{coeff}: piecewise linear reaction coefficient
-## @end itemize
-##
-## @end deftypefn
-  
-function L = Ucomplap (nodes,Nnodes,elements,Nelements,coeff)
-  
-  h 	= nodes(2:end)-nodes(1:end-1);
-  d0 	= [ coeff(1)./h(1); 
-            (coeff(1:end-1)./h(1:end-1))+(coeff(2:end)./h(2:end));
-            coeff(end)./h(end)];
-  d1	= [1000; -coeff./h];
-  dm1	= [ -coeff./h;1000];
-  L	= spdiags([dm1, d0, d1],-1:1,Nnodes,Nnodes);
-  
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/Utilities/Ucompmass.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.  
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{R}} = Ucompmass(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{Bvect},@var{Cvect})
-##
-## Compute P1 finite element mass-matrix:
-##
-## @itemize @minus
-## @item @var{nodes}: list of mesh nodes
-## @item @var{Nnodes}: number of mesh nodes
-## @item @var{elements}: list of mesh elements 
-## @item @var{Nelements}: number of mesh elements
-## @item @var{Bvect}: piecewise linear reaction coefficient
-## @item @var{Cvect}: piecewise constant reaction coefficient
-## @end itemize
-##
-## @end deftypefn
-
-function Bmat	= Ucompmass (nodes,Nnodes,elements,Nelements,Bvect,Cvect);
-  
-  h 	= (nodes(2:end)-nodes(1:end-1)).*Cvect;
-  d0	= Bvect.*[h(1)/2; (h(1:end-1)+h(2:end))/2; h(end)/2];
-  Bmat  = spdiags(d0, 0, Nnodes,Nnodes);
-  
-endfunction
-  
--- a/extra/secs1d/inst/Utilities/Udriftdiffusion.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{A}} = Udriftdiffusion(@var{x},@var{psi},@var{coeff})
-##
-## Builds the Scharfetter-Gummel approximation of the differential
-## operator
-##
-## - (coeff (n' - n psi'))'
-##
-## @itemize @minus
-## @item @var{x}: list of mesh nodes
-## @item @var{psi}: piecewise linear potential values
-## @item @var{coeff}: piecewise linear diffusion coefficient
-## @end itemize
-##
-## @end deftypefn
-
-function A = Udriftdiffusion(x,psi,coeff)  
-  
-  nodes        = x;
-  Nnodes     =length(nodes);
-  
-  elements   = [[1:Nnodes-1]' [2:Nnodes]'];
-  Nelements=size(elements,1);
-  
-  Bcnodes = [1;Nnodes];
-  
-  h=nodes(elements(:,2))-nodes(elements(:,1));
-  
-  c=coeff./h;
-  Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
-  Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
-  
-  
-  d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
-  d1    = [1000;-c.* Bpos];
-  dm1   = [-c.* Bneg;1000];
-  
-  A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
-  
-endfunction
\ No newline at end of file
--- a/extra/secs1d/inst/Utilities/Umediaarmonica.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-  ##  SECS1D 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.
-  ##
-  ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.     
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-    
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{m}} = Umediarmonica(@var{w})
-##
-## Return the harmonic mean value of @var{w}
-##
-## @end deftypefn
-     
-function m = Umediaarmonica(w);
-     
-  dw = (1./w(1:end-1))+(1./w(2:end));
-  m  = 2 ./ dw; 
-     
-endfunction     
--- a/extra/secs1d/inst/Utilities/Uscharfettergummel.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-  ##
-  ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-  ##
-## SECS1D 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.
-  ##
-## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Function File}@
-## {@var{R}} = Uscharfettergummel(@var{nodes},@var{Nnodes},@var{elements},@var{Nelements},@var{acoeff},@var{bcoeff},@var{v})
-##
-## Build the Scharfetter-Gummel matrix for the the discretization of
-## the LHS of the Drift-Diffusion equation:
-##
-##  -(a(x) (u' - b v'(x) u))'= f
-##
-## @itemize @minus
-## @item @var{nodes}: list of mesh nodes
-## @item @var{Nnodes}: number of mesh nodes
-## @item @var{elements}: list of mesh elements 
-## @item @var{Nelements}: number of mesh elements
-## @item @var{acoeff}: piecewise linear diffusion coefficient
-## @item @var{bcoeff}: piecewise constant drift constant coefficient
-## @item @var{v}: piecewise linear drift potential
-## @end itemize
-##
-## @end deftypefn
-
-function A = Uscharfettergummel(nodes,Nnodes,elements,Nelements,acoeff,bcoeff,v)
-
-  h=nodes(elements(:,2))-nodes(elements(:,1));
-  
-  c=acoeff./h;
-  Bneg=Ubernoulli(-(v(2:Nnodes)-v(1:Nnodes-1))*bcoeff,1);
-  Bpos=Ubernoulli( (v(2:Nnodes)-v(1:Nnodes-1))*bcoeff,1);
-  
-  
-  d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
-  d1    = [1000;-c.* Bpos];
-  dm1   = [-c.* Bneg;1000];
-  
-  A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
-  
-endfunction
--- a/extra/secs1d/inst/Utilities/constants.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-## Copyright (C) 2004-2008  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-## SECS1D 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.
-##
-## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-## -*- texinfo -*-
-##
-## @deftypefn {Script File} constants
-##
-## Compute global constants needed for Drift-Diffusion simulation
-##
-## @end deftypefn
-
-
-
-Kb           = 1.3806503e-23;
-q            = 1.602176462e-19;
-e0           = 8.854187817e-12;
-esir 	     = 11.7;
-esio2r 	     = 3.9;
-esi 	     = e0 * esir;
-esio2 	     = e0 * esio2r;
-hplanck	     = 6.626e-34;
-hbar         = ( hplanck/ (2*pi));
-mn0          = 9.11e-31;
-mn           = 0.26*mn0;
-mh           = 0.18*mn0;
-
-
-qsue         = q / esi;
-T0           = 300 ;
-Vth 	     = Kb * T0 / q;
-un           = 1417e-4;
-up           = 480e-4;
-tp           = 1e-7;
-tn           = 1e-7;
-
-mnl          = 0.98*mn0;
-mnt          = 0.19*mn0;
-mndos        = (mnl*mnt*mnt)^(1/3); 
-
-mhh             = 0.49*mn0;
-mlh             = 0.16*mn0;
-mhdos           = (mhh^(3/2)+mlh^(3/2))^(2/3);
-
-rn              = .1;
-aleph           = hbar^2/(4*rn*q*mn);
-alephn          = aleph;
-rp              = .1;
-alephp          = hbar^2/(4*rp*q*mh);
-
-Nc              = (6/4)*(2*mndos*Kb*T0/(hbar^2*pi))^(3/2);   
-Nv              = (1/4)*(2*mhdos*Kb*T0/(hbar^2*pi))^(3/2);
-Eg0             = 1.16964*q;
-alfaEg          = 4.73e-4*q;
-betaEg          = 6.36e2;
-Egap            = Eg0-alfaEg*((T0^2)/(T0+betaEg));
-
-ni              = sqrt(Nc*Nv)*exp(-Egap/(2*(Kb * T0)));
-Phims           = - Egap /(2*q);
--- a/extra/secs1d/inst/secs1d.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-# Run this only if the package is installed
-## PKG_ADD: if (! exist (fullfile (fileparts (mfilename ("fullpath")), "inst"), "dir"))
-## PKG_ADD:  dirlist= {"Utilities","DDG","DDN"};
-## PKG_ADD:  for ii=1:length(dirlist)
-## PKG_ADD:     addpath ( [ fileparts( mfilename("fullpath")) "/" dirlist{ii}])
-## PKG_ADD:  end
-## PKG_ADD: end
-
-# Run this only if the package is installed
-## PKG_DEL: if (! exist (fullfile (fileparts (mfilename ("fullpath")), "inst"), "dir"))
-## PKG_DEL:  dirlist= {"Utilities","DDG","DDN"};
-## PKG_DEL:  for ii=1:length(dirlist)
-## PKG_DEL:     rmpath ( [ fileparts( mfilename("fullpath")) "/" dirlist{ii}])
-## PKG_DEL:  end
-## PKG_DEL: end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/inst/secs1d_dd_gummel_map.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,302 @@
+%% Copyright (C) 2004-2012  Carlo de Falco
+%%
+%% This file is part of 
+%% SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+%%
+%% SECS1D 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 3 of the License, or
+%% (at your option) any later version.
+%%
+%% SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+
+%% [n, p, V, Fn, Fp, Jn, Jp, it, res] = secs1d_dd_gummel_map (x, D, Na, Nd, 
+%%                                                       pin, nin, Vin, Fnin, 
+%%                                                       Fpin, l2, er, u0n, 
+%%                                                       uminn, vsatn, betan, 
+%%                                                       Nrefn, u0p, uminp, vsatp, 
+%%                                                       betap, Nrefp, theta, tn, tp, 
+%%                                                       Cn, Cp, an, ap, Ecritnin, Ecritpin, 
+%%                                                       toll, maxit, ptoll, pmaxit)         
+%%
+%% This function solves the scaled stationary bipolar DD 
+%% equation system using Gummel algorithm
+%%
+%%     input: 
+%%            x                        spatial grid
+%%            D, Na, Nd                doping profile
+%%            pin                      initial guess for hole concentration
+%%            nin                      initial guess for electron concentration
+%%            Vin                      initial guess for electrostatic potential
+%%            Fnin                     initial guess for electron Fermi potential
+%%            Fpin                     initial guess for hole Fermi potential
+%%            l2                       scaled Debye length squared
+%%            er                       relative electric permittivity
+%%            u0n, uminn, vsatn, Nrefn electron mobility model coefficients
+%%            u0p, uminp, vsatp, Nrefp hole mobility model coefficients
+%%            theta                    intrinsic carrier density
+%%            tn, tp, Cn, Cp, 
+%%            an, ap, 
+%%            Ecritnin, Ecritpin       generation recombination model parameters
+%%            toll                     tolerance for Gummel iterarion convergence test
+%%            maxit                    maximum number of Gummel iterarions
+%%            ptoll                    convergence test tolerance for the non linear
+%%                                     Poisson solver
+%%            pmaxit                   maximum number of Newton iterarions
+%%
+%%     output: 
+%%             n     electron concentration
+%%             p     hole concentration
+%%             V     electrostatic potential
+%%             Fn    electron Fermi potential
+%%             Fp    hole Fermi potential
+%%             Jn    electron current density
+%%             Jp    hole current density
+%%             it    number of Gummel iterations performed
+%%             res   total potential increment at each step
+
+function [n, p, V, Fn, Fp, Jn, Jp, it, res] = secs1d_dd_gummel_map (x, D, Na, Nd, pin, nin, Vin, 
+                                                                    Fnin, Fpin, l2, er, u0n, uminn,
+                                                                    vsatn,betan,Nrefn, u0p, 
+                                                                    uminp,vsatp,betap,Nrefp,
+                                                                    theta, tn, tp, Cn, Cp, an, ap, 
+		                                                    Ecritnin, Ecritpin, toll, maxit, 
+                                                                    ptoll, pmaxit)         
+
+  p  = pin;
+  n  = nin;
+  V  = Vin;
+  Fp = Fpin;
+  Fn = Fnin;
+  dx  = diff (x);
+  dxm = (dx(1:end-1) + dx(2:end));
+
+  Nnodes = numel (x);
+  Nelements = Nnodes -1;
+
+  Jn = zeros (Nelements, 1);
+  Jp = zeros (Nelements, 1);
+
+  for it = 1:maxit
+  
+    [V(:,2), n(:,2), p(:,2)] = secs1d_nlpoisson_newton (x, [1:Nnodes], V(:,1), n(:, 1), 
+                                                        p(:,1), Fn(:,1), Fp(:,1), D, l2, 
+                                                        er, ptoll, pmaxit); 
+  
+    dV = diff (V(:, 2));
+    E  = - dV ./ dx;
+    [Bp, Bm] = bimu_bernoulli (dV);
+
+    [Rn, Rp, Gn, Gp, II] = generation_recombination_model (x, n(:, end), p(:, end),
+	                                                   E, Jn, Jp, tn, tp, theta, 
+                                                           Cn, Cp, an, ap, Ecritnin, Ecritpin); 
+    
+    mobility = mobility_model (x, Na, Nd, Nrefn, E, u0n, uminn, vsatn, betan);
+    
+    A = bim1a_advection_diffusion (x, mobility, 1, 1, V(:, 2));
+    M = bim1a_reaction (x, 1, Rn) + bim1a_reaction (x, II, 1);
+    
+    R = bim1a_rhs (x, 1, Gn);
+  
+    A = A + M;
+  
+    n(:,3) = nin;
+    n(2:end-1,3) = A(2:end-1, 2:end-1) \ (R(2:end-1) - A(2:end-1, [1 end]) * nin ([1 end]));
+    Fn(:,2) = V(:,2) - log (n(:, 3));
+    Jn =  mobility .* (n(2:end, 2) .* Bp - n(1:end-1, 2) .* Bm) ./ dx; 
+
+    [Rn, Rp, Gn, Gp, II] = generation_recombination_model (x, n(:, end), p(:, end), 
+	                                                   E, Jn, Jp, tn, tp, theta, 
+                                                           Cn, Cp, an, ap, Ecritnin, Ecritpin);
+
+    mobility = mobility_model (x, Na, Nd, Nrefp, E, u0p, uminp, vsatp, betap);
+
+    A = bim1a_advection_diffusion (x, mobility, 1, 1, -V(:, 2));
+    M = bim1a_reaction (x, 1, Rp) + bim1a_reaction (x, II, 1);
+    R = bim1a_rhs (x, 1, Gp);
+    A = A + M;
+  
+    p(:,3) = pin;
+    p(2:end-1,3) = A(2:end-1, 2:end-1) \ (R(2:end-1) - A(2:end-1, [1 end]) * pin ([1 end]));
+    Fp(:,2) = V(:,2) + log (p(:,3));
+    Jp = -mobility .* (p(2:end, 2) .* Bm - p(1:end-1, 2) .* Bp) ./ dx;
+
+    nrfn   = norm (Fn(:,2) - Fn(:,1), inf);
+    nrfp   = norm (Fp(:,2) - Fp(:,1), inf);
+    nrv    = norm (V(:,2)  - V(:,1),  inf);
+    res(it) = max  ([nrfn; nrfp; nrv]);
+
+    if (res(it) < toll)
+      break
+    endif
+    
+    V(:,1)  = V(:,end);
+    p(:,1)  = p(:,end) ;
+    n(:,1)  = n(:,end);
+    Fn(:,1) = Fn(:,end);
+    Fp(:,1) = Fp(:,end);  
+    
+  endfor
+
+  n  = n(:,end);
+  p  = p(:,end);
+  V  = V(:,end);
+  Fn = Fn(:,end);
+  Fp = Fp(:,end);
+  
+endfunction
+
+function u = mobility_model (x, Na, Nd, Nref, E, u0, umin, vsat, beta)
+
+  Neff = Na + Nd;
+  Neff = (Neff(1:end-1) + Neff(2:end)) / 2;
+  
+  ubar = umin + (u0 - umin) ./ (1 + (Neff ./ Nref) .^ beta);
+  u    = 2 * ubar ./ (1 + sqrt (1 + 4 * (ubar .* abs (E) ./ vsat) .^ 2));
+
+endfunction
+
+function [Rn, Rp, Gn, Gp, II] = generation_recombination_model (x, n, p, E, Jn, Jp, tn, tp, 
+                                                                theta, Cn, Cp, an, ap, Ecritn, 
+                                                                Ecritp)
+  
+  denomsrh   = tn .* (p + theta) + tp .* (n + theta);
+  factauger  = Cn .* n + Cp .* p;
+  fact       = (1 ./ denomsrh + factauger);
+
+  Rn = p .* fact;
+  Rp = n .* fact;
+
+  Gn = theta .^ 2 .* fact;
+  Gp = Gn;
+
+  II = an * exp(-Ecritn./abs(E)) .* abs (Jn) + ap * exp(-Ecritp./abs(E)) .* abs (Jp);
+
+endfunction
+
+
+%!demo
+%! % physical constants and parameters
+%! secs1d_physical_constants;
+%! secs1d_silicon_material_properties;
+%! 
+%! % geometry
+%! L  = 10e-6;          % [m] 
+%! xm = L/2;
+%! 
+%! Nelements = 1000;
+%! x         = linspace (0, L, Nelements+1)';
+%! sinodes   = [1:length(x)];
+%! 
+%! % dielectric constant (silicon)
+%! er = esir * ones (Nelements, 1);
+%! 
+%! % doping profile [m^{-3}]
+%! Na = 1e23 * (x <= xm);
+%! Nd = 1e23 * (x > xm);
+%! 
+%! % avoid zero doping
+%! D  = Nd - Na;  
+%!  
+%! % initial guess for n, p, V, phin, phip
+%! V_p = -1;
+%! V_n =  0;
+%! 
+%! Fp = V_p * (x <= xm);
+%! Fn = Fp;
+%! 
+%! p = abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni./abs(D)) .^2)) .* (x <= xm) + ...
+%!     ni^2 ./ (abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni ./ abs (D)) .^2))) .* (x > xm);
+%! 
+%! n = abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni ./ abs (D)) .^ 2)) .* (x > xm) + ...
+%!     ni ^ 2 ./ (abs (D) / 2 .* (1 + sqrt (1 + 4 * (ni ./ abs (D)) .^2))) .* (x <= xm);
+%! 
+%! V = Fn + Vth * log (n / ni);
+%! 
+%! % scaling factors
+%! xbar = L;                       % [m]
+%! nbar = norm(D, 'inf');          % [m^{-3}]
+%! Vbar = Vth;                     % [V]
+%! mubar = max (u0n, u0p);         % [m^2 V^{-1} s^{-1}]
+%! tbar = xbar^2 / (mubar * Vbar); % [s]
+%! Rbar = nbar / tbar;             % [m^{-3} s^{-1}]
+%! Ebar = Vbar / xbar;             % [V m^{-1}]
+%! Jbar = q * mubar * nbar * Ebar; % [A m^{-2}]
+%! CAubar = Rbar / nbar^3;         % [m^6 s^{-1}]
+%! abar = 1/xbar;                  % [m^{-1}]
+%! 
+%! % scaling procedure
+%! l2 = e0 * Vbar / (q * nbar * xbar^2);
+%! theta = ni / nbar;
+%! 
+%! xin = x / xbar;
+%! Din = D / nbar;
+%! Nain = Na / nbar;
+%! Ndin = Nd / nbar;
+%! pin = p / nbar;
+%! nin = n / nbar;
+%! Vin = V / Vbar;
+%! Fnin = Vin - log (nin);
+%! Fpin = Vin + log (pin);
+%! 
+%! tnin = tn / tbar;
+%! tpin = tp / tbar;
+%! 
+%! u0nin = u0n / mubar;
+%! uminnin = uminn / mubar;
+%! vsatnin = vsatn / (mubar * Ebar);
+%! 
+%! u0pin = u0p / mubar;
+%! uminpin = uminp / mubar;
+%! vsatpin = vsatp / (mubar * Ebar);
+%! 
+%! Nrefnin = Nrefn / nbar;
+%! Nrefpin = Nrefp / nbar;
+%! 
+%! Cnin     = Cn / CAubar;
+%! Cpin     = Cp / CAubar;
+%! 
+%! anin     = an / abar;
+%! apin     = ap / abar;
+%! Ecritnin = Ecritn / Ebar;
+%! Ecritpin = Ecritp / Ebar;
+%! 
+%! % tolerances for convergence checks
+%! toll  = 1e-3;
+%! maxit = 1000;
+%! ptoll = 1e-12;
+%! pmaxit = 1000;
+%! 
+%! % solve the problem using the full DD model
+%! [nout, pout, Vout, Fnout, Fpout, Jnout, Jpout, it, res] = ...
+%!       secs1d_dd_gummel_map (xin, Din, Nain, Ndin, pin, nin, Vin, Fnin, Fpin, ...
+%!                             l2, er, u0nin, uminnin, vsatnin, betan, Nrefnin, ...
+%! 	                       u0pin, uminpin, vsatpin, betap, Nrefpin, theta, ...
+%! 		               tnin, tpin, Cnin, Cpin, anin, apin, ...
+%! 		               Ecritnin, Ecritpin, toll, maxit, ptoll, pmaxit); 
+%! 
+%! % Descaling procedure
+%! n    = nout*nbar;
+%! p    = pout*nbar;
+%! V    = Vout*Vbar;
+%! Fn   = V - Vth*log(n/ni);
+%! Fp   = V + Vth*log(p/ni);
+%! dV   = diff(V);
+%! dx   = diff(x);
+%! E    = -dV./dx;
+%! 
+%! % band structure
+%! Efn  = -Fn;
+%! Efp  = -Fp;
+%! Ec   = Vth*log(Nc./n)+Efn;
+%! Ev   = -Vth*log(Nv./p)+Efp;
+%! 
+%! plot (x, Efn, x, Efp, x, Ec, x, Ev)
+%! legend ('Efn', 'Efp', 'Ec', 'Ev')
+%! axis tight
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/inst/secs1d_dd_newton.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,263 @@
+%% Copyright (C) 2004-2012  Carlo de Falco
+%%
+%% This file is part of 
+%% SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+%%
+%% SECS1D 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 3 of the License, or
+%% (at your option) any later version.
+%%
+%% SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+
+%% [n, p, V, Fn, Fp, Jn, Jp, it, res] = secs1d_dd_newton (x, D, Vin, nin, 
+%%                                                        pin, l2, er, un, 
+%%                                                        up, theta, tn, tp, 
+%%                                                        Cn, Cp, toll, maxit)
+%%
+%% Solve the scaled stationary bipolar DD equation system using Newton's method
+%%
+%%     input: 
+%%       x                spatial grid
+%%       D                doping profile
+%%       pin              initial guess for hole concentration
+%%       nin              initial guess for electron concentration
+%%       Vin              initial guess for electrostatic potential
+%%       l2               scaled Debye length squared
+%%       er               relative electric permittivity
+%%       un               electron mobility model coefficients
+%%       up               electron mobility model coefficients
+%%       theta            intrinsic carrier density
+%%       tn, tp, Cn, Cp   generation recombination model parameters
+%%       toll             tolerance for Gummel iterarion convergence test
+%%       maxit            maximum number of Gummel iterarions
+%%
+%%     output: 
+%%       n     electron concentration
+%%       p     hole concentration
+%%       V     electrostatic potential
+%%       Fn    electron Fermi potential
+%%       Fp    hole Fermi potential
+%%       Jn    electron current density
+%%       Jp    hole current density
+%%       it    number of Gummel iterations performed
+%%       res   total potential increment at each step
+
+function [n, p, V, Fn, Fp, Jn, Jp, it, normr] = secs1d_dd_newton (x, D, Vin, nin, pin, l2, er, un, up, theta, tn, tp, Cn, Cp, toll, maxit)
+
+  dampit     = 10;
+  dampcoeff  = 2;
+  Nnodes     = numel (x);
+
+  V  = Vin;
+  n  = nin;
+  p  = pin;
+
+  [res, jac] = residual_jacobian (x, D, V, n, p, l2, er, un, up, theta, tn, tp, Cn, Cp);
+
+  normr(1)   = norm (res, inf);
+  normrnew   = normr(1);
+
+  for it = 1:maxit
+	    
+    delta = - jac \ res;
+  
+    tk = 1;
+    for dit = 1:dampit
+
+      Vnew          = Vin;
+      Vnew(2:end-1) = V(2:end-1) + tk * delta(1:Nnodes-2);
+
+      nnew          = nin;
+      nnew(2:end-1) = n(2:end-1) + tk * delta((Nnodes-2)+(1:Nnodes-2));
+
+      pnew          = pin;
+      pnew(2:end-1) = p(2:end-1) + tk * delta(2*(Nnodes-2)+(1:Nnodes-2));
+
+      [resnew, jacnew] = residual_jacobian (x, D, Vnew, nnew, pnew, l2, er, un, up, theta, tn, tp, Cn, Cp);
+
+      normrnew = norm (resnew, inf);
+      if (normrnew > normr(it))
+        tk = tk / dampcoeff;
+      else
+        jac = jacnew;
+        res = resnew;
+        break
+      endif
+
+    endfor
+
+    V = Vnew; n = nnew; p = pnew;
+    normr(it+1) = normrnew;
+
+    if (normr(it+1) <= toll)
+      break
+    endif
+  endfor
+
+  dV = diff (V);
+  dx = diff (x);
+  [Bp, Bm] = bimu_bernoulli (dV);
+  Jn = un  .* (n(2:end) .* Bp - n(1:end-1) .* Bm) ./ dx; 
+  Jp = -up .* (p(2:end) .* Bm - p(1:end-1) .* Bp) ./ dx;
+  Fp = V + log (p);
+  Fn = V - log (n);
+endfunction
+
+function [res, jac] = residual_jacobian (x, D, V, n, p, l2, er, un, up, theta, tn, tp, Cn, Cp)
+
+  denomsrh   = tn .* (p + theta) + tp .* (n + theta);
+  factauger  = Cn .* n + Cp .* p;
+  fact       = (1 ./ denomsrh + factauger); 
+  nm         = (n(2:end) + n(1:end-1))/2;
+  pm         = (p(2:end) + p(1:end-1))/2;
+
+  Nnodes = numel (x);
+
+  A11 = bim1a_laplacian (x, l2 .* er, 1);
+  A12 = bim1a_reaction (x, 1, 1);
+  A13 = - A12;
+  R1  = A11 * V + bim1a_rhs (x, 1, n-p-D);
+
+  A21 = - bim1a_laplacian (x, un .* nm, 1);
+  A22 = bim1a_advection_diffusion (x, un, 1, 1, V) + bim1a_reaction (x, 1, p .* fact);
+  A23 = bim1a_reaction (x, 1, n .* fact);
+  R2  = A22 * n + bim1a_rhs (x, 1, (p .* n - theta .^ 2) .* fact);
+
+  A31 = bim1a_laplacian (x, up .* pm, 1);
+  A32 = bim1a_reaction (x, 1, p .* fact);
+  A33 = bim1a_advection_diffusion (x, up, 1, 1, -V) + bim1a_reaction (x, 1, n .* fact);
+  R3  = A33 * p + bim1a_rhs (x, 1, (p .* n - theta .^ 2) .* fact);
+
+  res = [R1(2:end-1); R2(2:end-1); R3(2:end-1)];
+
+  jac = [A11(2:end-1, 2:end-1), A12(2:end-1, 2:end-1), A13(2:end-1, 2:end-1);
+         A21(2:end-1, 2:end-1), A22(2:end-1, 2:end-1), A23(2:end-1, 2:end-1);
+         A31(2:end-1, 2:end-1), A32(2:end-1, 2:end-1), A33(2:end-1, 2:end-1)];
+
+endfunction
+
+
+%!demo
+%! % physical constants and parameters
+%! secs1d_physical_constants;
+%! secs1d_silicon_material_properties;
+%! 
+%! % geometry
+%! L  = 1e-6; % [m] 
+%! x  = linspace (0, L, 10)';
+%! sinodes = [1:length(x)];
+%! 
+%! % dielectric constant (silicon)
+%! er = esir * ones (numel (x) - 1, 1);
+%! 
+%! % doping profile [m^{-3}]
+%! Na = 1e20 * ones(size(x));
+%! Nd = 1e24 * ones(size(x));
+%! D  = Nd-Na;  
+%! 
+%! % externally applied voltages
+%! V_p = 10;
+%! V_n = 0;
+%!  
+%! % initial guess for phin, phip, n, p, V
+%! Fp = V_p * (x <= L/2);
+%! Fn = Fp;
+%! 
+%! p = abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2)).*(D<0)+...
+%!     ni^2./(abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2))).*(D>0);
+%! 
+%! n = abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2)).*(D>0)+...
+%!     ni^2./(abs(D)/2.*(1+sqrt(1+4*(ni./abs(D)).^2))).*(D<0);
+%! 
+%! V  = Fn + Vth*log(n/ni);
+%!
+%! % scaling factors
+%! xbar = L;                         % [m]
+%! nbar = norm(D, 'inf');            % [m^{-3}]
+%! Vbar = Vth;                       % [V]
+%! mubar = max(u0n, u0p);            % [m^2 V^{-1} s^{-1}]
+%! tbar = xbar^2/(mubar*Vbar);       % [s]
+%! Rbar = nbar/tbar;                 % [m^{-3} s^{-1}]
+%! Ebar = Vbar/xbar;                 % [V m^{-1}]
+%! Jbar = q*mubar*nbar*Ebar;         % [A m^{-2}]
+%! CAubar = Rbar/nbar^3;             % [m^6 s^{-1}]
+%! abar = xbar^(-1);                 % [m^{-1}]
+%! 
+%! % scaling procedure
+%! l2 = e0*Vbar/(q*nbar*xbar^2);     
+%! theta = ni/nbar;                  
+%! 
+%! xin = x/xbar;
+%! Din = D/nbar;
+%! Nain = Na/nbar;
+%! Ndin = Nd/nbar;
+%! pin = p/nbar;
+%! nin = n/nbar;
+%! Vin = V/Vbar;
+%! Fnin = Vin - log(nin);
+%! Fpin = Vin + log(pin);
+%! 
+%! tnin = tn/tbar;
+%! tpin = tp/tbar;
+%! 
+%! % mobility model accounting scattering from ionized impurities
+%! u0nin = u0n/mubar;
+%! uminnin = uminn/mubar;
+%! vsatnin = vsatn/(mubar*Ebar);
+%! 
+%! u0pin = u0p/mubar;
+%! uminpin = uminp/mubar;
+%! vsatpin = vsatp/(mubar*Ebar);
+%! 
+%! Nrefnin = Nrefn/nbar;
+%! Nrefpin = Nrefp/nbar;
+%! 
+%! Cnin     = Cn/CAubar;
+%! Cpin     = Cp/CAubar;
+%! 
+%! anin     = an/abar;
+%! apin     = ap/abar;
+%! Ecritnin = Ecritn/Ebar;
+%! Ecritpin = Ecritp/Ebar;
+%! 
+%! % tolerances for convergence checks
+%! ptoll = 1e-12;
+%! pmaxit = 1000;
+%! 
+%! % solve the problem using the Newton fully coupled iterative algorithm
+%! [nout, pout, Vout, Fnout, Fpout, Jnout, Jpout, it, res] = secs1d_dd_newton (xin, Din, 
+%!                                                                Vin, nin, pin, l2, er, 
+%!                                                                u0nin, u0pin, theta, tnin, 
+%!                                                                tpin, Cnin, Cpin, ptoll, pmaxit);
+%! % Descaling procedure
+%! n    = nout*nbar;
+%! p    = pout*nbar;
+%! V    = Vout*Vbar;
+%! Fn   = V - Vth*log(n/ni);
+%! Fp   = V + Vth*log(p/ni);
+%! dV   = diff(V);
+%! dx   = diff(x);
+%! E    = -dV./dx;
+%! 
+%! % compute current densities 
+%! [Bp, Bm] = bimu_bernoulli (dV/Vth);
+%! Jn       =  q*u0n*Vth .* (n(2:end) .* Bp - n(1:end-1) .* Bm) ./ dx; 
+%! Jp       = -q*u0p*Vth .* (p(2:end) .* Bm - p(1:end-1) .* Bp) ./ dx;
+%! Jtot     =  Jn+Jp;
+%! 
+%! % band structure
+%! Efn  = -Fn;
+%! Efp  = -Fp;
+%! Ec   = Vth*log(Nc./n)+Efn;
+%! Ev   = -Vth*log(Nv./p)+Efp;
+%!
+%! plot (x, Efn, x, Efp, x, Ec, x, Ev)
+%! legend ('Efn', 'Efp', 'Ec', 'Ev')
+%! axis tight
\ No newline at end of file
--- a/extra/secs1d/inst/secs1d_demo_pndiode.m	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-## Copyright (C) 2009  Carlo de Falco
-##
-## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
-##
-## SECS1D 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.
-##
-## SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
-##
-## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
-
-function secs1d_demo_pndiode ()
-
-  constants
-
-  len = 1e-6;
-  Nnodes = 1000;
-
-  vmin = -2;
-  vmax =  2;
-
-  vstep=.4;
-
-  istep = 1;
-  va = vmin
-  
-  x = linspace(0,len,Nnodes)';
-  xm = mean(x);
-  
-  Nd=1e25;
-  Na=1e25;
-  
-  D = Nd * (x>xm) - Na * (x<=xm);
-
-  nn = (Nd + sqrt(Nd^2+4*ni^2))/2;
-  pp = (Na + sqrt(Na^2+4*ni^2))/2;
-    
-  xn = xm+1e-7;
-  xp = xm-1e-7;
-
-  %% Scaling coefficients
-  xs  = len;
-  ns  = norm(D,inf);
-  idata.D = D/ns;
-  Vs  = Vth;
-  us  = un;
-  Js  = xs / (us * Vs * q * ns);
-
-
-  while va <= vmax
-    
-    vvect(istep) = va;
-    
-    n(:,istep) = nn * (x>=xn) + (ni^2)/pp * (x<xn);
-    p(:,istep) = (ni^2)/nn * (x>xp) + pp * (x<=xp);
-    
-    Fn = va*(x<=xm);
-    Fp = Fn;
-    
-    V(:,istep) = (Fn - Vth * log(p(:,istep)/ni)); 
-  
-    %% Scaling    
-    xin   = x/xs;
-    idata.n   = n(:,istep)/ns;
-    idata.p   = p(:,istep)/ns;
-    idata.V   = V(:,istep)/Vs;
-    idata.Fn  = (Fn - Vs * log(ni/ns))/Vs;
-    idata.Fp  = (Fp + Vs * log(ni/ns))/Vs;
-    
-    lambda2(istep) = idata.l2 = (Vs*esi)/(q*ns*xs^2);
-    idata.nis   = ni/ns;
-    idata.un   = un/us;
-    idata.up   = up/us;
-    
-    %% Solution of DD system
-    
-    %% Algorithm parameters
-    toll  = 1e-3;
-    maxit = 20;
-    ptoll  = 1e-10;
-    pmaxit = 100;
-    verbose = 0;
-    sinodes = [1:length(x)];
-    idata.tn = inf;
-    idata.tp = inf;
-    
-    [odata,it,res] = DDGgummelmap (xin,idata,toll,maxit,ptoll,pmaxit,verbose);
-    [odata,it,res] = DDNnewtonmap (xin,odata,toll, maxit,verbose);
-
-    n(:,istep) = odata.n;
-    p(:,istep) = odata.p;
-    V(:,istep) = odata.V;
-    
-    DV(istep)  = odata.V(end) - odata.V(1);
-    Emax(istep) = max(abs(diff(odata.V)./diff(xin)))
-
-    Bp = Ubernoulli(diff (V(:, istep)),1);
-    Bm = Ubernoulli(diff (V(:, istep)),0);
-    Jn(:,istep) = -odata.un * (n(2:end, istep).*Bp-n(1:end-1, istep).*Bm)./diff (xin);
-    Jp(:,istep) =  odata.up * (p(2:end, istep).*Bm-p(1:end-1, istep).*Bp)./diff (xin);
-
-    va = va+vstep
-    istep = istep+1;
-    
-  endwhile
-
-  %% Descaling
-  n     = n*ns;
-  p     = p*ns;
-  V     = V*Vs;
-  J     = abs (Jp+Jn)*Js;
-
-  close all
-  
-  figure();
-  plot(x, n.')
-  xlabel("x")
-  ylabel("n")
- 
-  figure();
-  plot(vvect, J)
-  xlabel("V")
-  ylabel("J")
-
-  figure();
-  plot(vvect, Emax)
-  xlabel("V")
-  ylabel("max(abs(\\phi^\'))")
-  
-endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/inst/secs1d_nlpoisson_newton.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,205 @@
+%% Copyright (C) 2004-2012  Carlo de Falco
+%%
+%% This file is part of 
+%% SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+%%
+%% SECS1D 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 3 of the License, or
+%% (at your option) any later version.
+%%
+%% SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+
+%% [V, n, p, res, niter] = secs1d_nlpoisson_newton (x, sinodes, Vin, nin, pin,
+%%                                                  Fnin, Fpin, D, l2, er, toll, maxit)
+%%
+%%     input:  
+%%             x       spatial grid
+%%             sinodes index of the nodes of the grid which are in the semiconductor subdomain
+%%                     (remaining nodes are assumed to be in the oxide subdomain)
+%%             Vin     initial guess for the electrostatic potential
+%%             nin     initial guess for electron concentration
+%%             pin     initial guess for hole concentration
+%%             Fnin    initial guess for electron Fermi potential
+%%             Fpin    initial guess for hole Fermi potential
+%%             D       doping profile
+%%             l2      scaled Debye length squared
+%%             er      relative electric permittivity
+%%             toll    tolerance for convergence test
+%%             maxit   maximum number of Newton iterations
+%%
+%%     output: 
+%%             V       electrostatic potential
+%%             n       electron concentration
+%%             p       hole concentration
+%%             res     residual norm at each step
+%%             niter   number of Newton iterations
+
+function [V, n, p, res, niter] = secs1d_nlpoisson_newton (x, sinodes, Vin, nin, pin, 
+                                                          Fnin, Fpin, D, l2, er, toll, maxit)
+
+  dampit     = 10;
+  dampcoeff  = 2;
+
+  sielements = sinodes(1:end-1);
+  Nnodes     = numel (x);
+  Nelements  = Nnodes - 1;
+
+  V  = Vin;
+  Fn = Fnin;
+  Fp = Fpin;
+  n  = exp ( V(sinodes) - Fn);
+  p  = exp (-V(sinodes) + Fp);
+
+  L  = bim1a_laplacian (x, l2 .* er, 1);
+  
+  b =  zeros (Nelements, 1); 
+  b(sielements) = 1;
+  
+  a =  zeros (Nnodes, 1);
+  a(sinodes) = (n + p);
+
+  M = bim1a_reaction (x, b, a);
+
+  a = zeros (Nnodes,1);    
+  a(sinodes) = (n - p - D);
+
+  N = bim1a_rhs (x, b, a);
+
+  A = L + M;
+  R = L * V + N; 
+
+  normr(1)   = norm (R(2:end-1), inf);
+  normrnew   = normr(1);
+
+  for newtit = 1:maxit
+    
+    dV = zeros (Nnodes, 1);
+    dV(2:end-1) = - A(2:end-1, 2:end-1) \ R(2:end-1) ;
+  
+    tk = 1;
+    for dit = 1:dampit
+      Vnew   = V + tk * dV;
+    
+      n  = exp ( Vnew(sinodes) - Fn);
+      p  = exp (-Vnew(sinodes) + Fp);
+
+      a  = zeros (Nnodes, 1); 
+      a(sinodes) =  (n + p);
+      M  = bim1a_reaction (x, b, a);
+      Anew  = L + M;
+
+      a = zeros (Nnodes,1); 
+      a(sinodes) = (n - p - D);
+      N = bim1a_rhs (x, b, a);
+      Rnew = L * Vnew  + N; 
+    
+      normrnew = norm (Rnew(2:end-1), inf);
+      if (normrnew > normr(newtit))
+        tk = tk / dampcoeff;
+      else
+        A = Anew;
+        R = Rnew;
+        break
+      endif	
+      
+    endfor
+
+    V               = Vnew;	
+    normr(newtit+1) = normrnew;
+    reldVnorm       = norm (tk*dV, inf) / norm (V, inf);
+    
+    if (reldVnorm <= toll)
+      break
+    endif
+
+  endfor
+
+  res   = normr;
+  niter = newtit;
+
+endfunction
+
+%!demo
+%! secs1d_physical_constants
+%! secs1d_silicon_material_properties
+%! 
+%! tbulk= 1.5e-6;
+%! tox = 90e-9;
+%! L = tbulk + tox;
+%! cox = esio2/tox;
+%! 
+%! Nx  = 50;
+%! Nel = Nx - 1;
+%! 
+%! x = linspace (0, L, Nx)';
+%! sinodes = find (x <= tbulk);
+%! xsi = x(sinodes);
+%! 
+%! Nsi = length (sinodes);
+%! Nox = Nx - Nsi;
+%! 
+%! NelSi   = Nsi - 1;
+%! NelSiO2 = Nox - 1;
+%! 
+%! Na = 1e22;
+%! D = - Na * ones (size (xsi));
+%! p = Na * ones (size (xsi));
+%! n = (ni^2) ./ p;
+%! Fn = Fp = zeros (size (xsi));
+%! Vg = -10;
+%! Nv = 80;
+%! for ii = 1:Nv
+%!     Vg = Vg + 0.2;
+%!     vvect(ii) = Vg; 
+%!     
+%!     V = - Phims + Vg * ones (size (x));
+%!     V(sinodes) = Fn + Vth * log (n/ni);
+%!     
+%!     % Scaling
+%!     xs  = L;
+%!     ns  = norm (D, inf);
+%!     Din = D / ns;
+%!     Vs  = Vth;
+%!     xin   = x / xs;
+%!     nin   = n / ns;
+%!     pin   = p / ns;
+%!     Vin   = V / Vs;
+%!     Fnin  = (Fn - Vs * log (ni / ns)) / Vs;
+%!     Fpin  = (Fp + Vs * log (ni / ns)) / Vs;
+%!     
+%!     er    = esio2r * ones(Nel, 1);
+%!     l2(1:NelSi) = esi;
+%!     l2    = (Vs*e0)/(q*ns*xs^2);
+%!     
+%!     % Solution of Nonlinear Poisson equation
+%!     
+%!     % Algorithm parameters
+%!     toll  = 1e-10;
+%!     maxit = 1000;
+%!     
+%!     [V, nout, pout, res, niter] = secs1d_nlpoisson_newton (xin, sinodes, 
+%!                                                            Vin, nin, pin,
+%!                                                            Fnin, Fpin, Din, l2,
+%!                                                            er, toll, maxit);
+%! 
+%!     % Descaling
+%!     n     = nout*ns;
+%!     p     = pout*ns;
+%!     V     = V*Vs;
+%!     
+%!     qtot(ii) = q * trapz (xsi, p + D - n);
+%! end
+%! 
+%! vvectm = (vvect(2:end)+vvect(1:end-1))/2;
+%! C = - diff (qtot) ./ diff (vvect);
+%! plot(vvectm, C)
+%! xlabel('Vg [V]')
+%! ylabel('C [Farad]')
+%! title('C-V curve')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/inst/secs1d_physical_constants.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,37 @@
+%% Copyright (C) 2004-2012  Carlo de Falco
+%%
+%% This file is part of 
+%% SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+%%
+%% SECS1D 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 3 of the License, or
+%% (at your option) any later version.
+%%
+%% SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+
+%% some useful physical constants 
+%%
+%% Kb       = Boltzman constant
+%% q        = quantum of charge
+%% e0       = permittivity of free space
+%% hplanck  = Plank constant
+%% hbar     = Plank constant by 2 pi
+%% mn0      = free electron mass
+%% T0       = temperature
+%% Vth 	   = thermal voltage
+
+Kb       = 1.3806503e-23;
+q        = 1.602176462e-19;
+e0       = 8.854187817e-12;
+hplanck	 = 6.626e-34;
+hbar     = hplanck/ (2*pi);
+mn0      = 9.11e-31;
+T0       = 300;
+Vth 	 = Kb * T0 / q;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/secs1d/inst/secs1d_silicon_material_properties.m	Sun Mar 25 22:44:30 2012 +0000
@@ -0,0 +1,104 @@
+%% Copyright (C) 2004-2012  Carlo de Falco
+%%
+%% This file is part of 
+%% SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
+%%
+%% SECS1D 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 3 of the License, or
+%% (at your option) any later version.
+%%
+%% SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
+
+%% material properties for silicon and silicon dioxide
+%%
+%% esir       = relative electric permittivity of silicon
+%% esio2r     = relative electric permittivity of silicon dioxide
+%% esi 	      = electric permittivity of silicon
+%% esio2      = electric permittivity of silicon dioxide
+%% mn         = effective mass of electrons in silicon
+%% mh         = effective mass of holes in silicon
+%% 
+%% u0n        = low field electron mobility
+%% u0p        = low field hole mobility
+%% uminn      = parameter for doping-dependent electron mobility
+%% betan      = idem
+%% Nrefn      = idem
+%% uminp      = parameter for doping-dependent hole mobility
+%% betap      = idem
+%% Nrefp      = idem
+%% vsatn      = electron saturation velocity
+%% vsatp      = hole saturation velocity
+%% tp         = electron lifetime
+%% tn         = hole lifetime
+%% Cn         = electron Auger coefficient
+%% Cp         = hole Auger coefficient
+%% an         = impact ionization rate for electrons
+%% ap         = impact ionization rate for holes
+%% Ecritn     = critical field for impact ionization of electrons
+%% Ecritp     = critical field for impact ionization of holes 
+%% Nc         = effective density of states in the conduction band
+%% Nv         = effective density of states in the valence band
+%% Egap       = bandgap in silicon
+%% EgapSio2   = bandgap in silicon dioxide
+%% 
+%% ni         = intrinsic carrier density
+%% Phims      = metal to semiconductor potential barrier
+
+esir 	       = 11.7;
+esio2r 	     = 3.9;
+esi 	       = e0 * esir;
+esio2 	     = e0 * esio2r;
+mn           = 0.26*mn0;
+mh           = 0.18*mn0;
+
+qsue         = q / esi;
+
+u0n          = 1417e-4;
+u0p          = 480e-4;
+uminn        = u0n;            % ref. value: 65e-4;
+uminp        = u0p;            % ref. value: 47.7e-4;
+betan        = 0.72;
+betap        = 0.76;
+Nrefn        = 8.5e22;
+Nrefp        = 6.3e22;
+vsatn        = inf;            % ref. value: 1.1e5;
+vsatp        = inf;            % ref. value: 9.5e4;
+
+tp           = inf;            % ref. value: 1e-6;
+tn           = inf;            % ref. value: 1e-6;
+
+Cn           = 0;              % ref. value: 2.8e-31*1e-12; 
+Cp           = 0;              % ref. value: 9.9e-32*1e-12;   
+an           = 0;              % ref. value: 7.03e7;
+ap           = 0;              % ref. value: 6.71e7;
+Ecritn       = 1.231e8; 
+Ecritp       = 1.693e8;
+
+mnl          = 0.98*mn0;
+mnt          = 0.19*mn0;
+mndos        = (mnl*mnt*mnt)^(1/3); 
+
+mhh         = 0.49*mn0;
+mlh         = 0.16*mn0;
+mhdos       = (mhh^(3/2)+mlh^(3/2))^(2/3);
+
+Nc          = (6/4)*(2*mndos*Kb*T0/(hbar^2*pi))^(3/2);   
+Nv          = (1/4)*(2*mhdos*Kb*T0/(hbar^2*pi))^(3/2);
+Eg0         = 1.16964*q;
+alfaEg      = 4.73e-4*q;
+betaEg      = 6.36e2;
+Egap        = Eg0-alfaEg*((T0^2)/(T0+betaEg));
+Ei          = Egap/2+Kb*T0/2*log(Nv/Nc);
+EgapSio2    = 9*q;
+deltaEcSio2 = 3.1*q;
+deltaEvSio2 = EgapSio2-Egap-deltaEcSio2;
+
+ni          = sqrt(Nc*Nv)*exp(-Egap/(2*(Kb * T0)));
+Phims       = - Egap /(2*q);
--- a/extra/secs1d/src/Makefile	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-PROGS = $(patsubst %.cc,%.oct,$(wildcard *.cc))
-
-all: $(PROGS)
-
-$(PROGS): Makefile
-
-%.oct: %.cc
-	mkoctfile $<
-
-clean: ; -$(RM) *.o core octave-core *.oct *~
\ No newline at end of file
--- a/extra/secs1d/src/Ubern.cc	Sun Mar 25 22:35:18 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
-% 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <iostream>
-#include <octave/oct.h>
-
-////////////////////////////////////////////
-//   Ubern function
-//   this function, though it does make use 
-//   of liboctave, is not an octve command
-//   the wrapper to make the command is defined
-//   below
-////////////////////////////////////////////
-
-
-int Ubern(const double x, double &bp, double &bn )
-{
-
-double xlim=1e-2;
-int ii;
-double fp,fn,df,segno;
-double ax;
-
-ax=fabs(x);
-
-
-if (ax == 0.0) {
-bp=1.;
-bn=1.;
-goto theend ;
-}
-
-if (ax > 80.0){
-if (x >0.0){
-  bp=0.0;
-  bn=x;
-  goto theend ;
-}else{
-  bp=-x;
-  bn=0.0;
-  goto theend ;
-}
-}
-
-if (ax > xlim){
-bp=x/(exp(x)-1.0);
-bn=x+bp;
-goto theend ;
-}
-
-ii=1;
-fp=1.0;fn=1.0;df=1.0;segno=1.0;
-while (fabs(df) > 2.2204e-16){
-ii++;
-segno= -segno;
-df=df*x/ii;
-fp=fp+df;
-fn=fn+segno*df;
-bp=1/fp;
-bn=1/fn;
-}
-
-
-theend:
-return 0;
-
-}
-
-
-////////////////////////////////////
-//   WRAPPER
-////////////////////////////////////
-// DEFUN_DLD and the macros that it 
-// depends on are defined in the
-// files defun-dld.h, defun.h,
-// and defun-int.h.
-//
-// Note that the third parameter 
-// (nargout) is not used, so it is
-// omitted from the list of arguments 
-// to DEFUN_DLD in order to avoid
-// the warning from gcc about an 
-// unused function parameter. 
-////////////////////////////////////
-
-DEFUN_DLD (Ubern, args, ,
-" [bp,bn]=Ubern(x)\n \
-computes Bernoulli function\n \
-B(x)=x/(exp(x)-1) corresponding to \n \
-to input values Z and -Z, recalling that\n \
-B(-Z)=Z+B(Z)\n")
-{
-  // The list of values to return.  See the declaration in oct-obj.h
-  octave_value_list retval;
-
-
-  NDArray X ( args(0).array_value() );
-  octave_idx_type lx = X.length();
-
-  NDArray BP(X),BN(X);  
- 
-  for (octave_idx_type jj=0; jj<lx; jj++)
-    Ubern(X(jj),BP(jj),BN(jj));
-
-  retval (0) = BP;
-  retval (1) = BN;
-  
-  return retval	;
-  
-}
-