1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
5 /* 8 88888888 88888888 */
8 /* 888888 888888888 888888888 */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
13 /* Last update: May 29, 2007 */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
19 /*****************************************************************************/
26 #include "petscsnes.h"
28 class EBM_Solver_L3E
: virtual public BSolver
31 int N
; // the scale of matrix
32 SNES snes
; // nonlinear solver context
33 KSP ksp
; // linear solver context
34 PC pc
; // preconditioner context
35 vector
<int> zofs
; // the offset value of each zone in solution vector
37 SNESConvergedReason reason
;
38 void solver_pre_compute() ;
39 void solution_update() ;
40 void diverged_recovery() ;
41 void LET_norm_estimat(PetscScalar
&);
43 Vec x
,r
; // solution, residual vectors
44 Vec x_n
,x_n1
,x_n2
; // privious solution vector for LET evaluation
45 Vec xp
; // predict solution vector;
46 Vec LTE
; // local truncation error vector;
47 Mat J
,JPrec
,JTmp
; // Jacobian matrix
48 PetscInt its
; // iteration number
51 PetscReal relative_toler
;
52 PetscReal toler_relax
;
53 PetscReal possion_abs_toler
;
54 PetscReal elec_continuty_abs_toler
;
55 PetscReal hole_continuty_abs_toler
;
56 PetscReal heat_equation_abs_toler
;
57 PetscReal elec_energy_abs_toler
;
58 PetscReal hole_energy_abs_toler
;
59 PetscReal electrode_abs_toler
;
61 PetscReal potential_norm
;
62 PetscReal electron_norm
;
64 PetscReal temperature_norm
;
65 PetscReal elec_temperature_norm
;
66 PetscReal hole_temperature_norm
;
67 PetscReal possion_norm
;
68 PetscReal elec_continuty_norm
;
69 PetscReal hole_continuty_norm
;
70 PetscReal heat_equation_norm
;
71 PetscReal elec_energy_equation_norm
;
72 PetscReal hole_energy_equation_norm
;
73 PetscReal electrode_norm
;
75 int init_solver(SolveDefine
&s
) ;
76 int do_solve(SolveDefine
&s
) ;
77 int solve_equ(SolveDefine
&s
) ;
78 int solve_steadystate(SolveDefine
&s
) ;
79 int solve_dcsweep(SolveDefine
&s
) ;
80 int solve_transient(SolveDefine
&s
) ;
81 int destroy_solver(SolveDefine
&s
) ;
82 void form_function_pn_3E(PetscScalar
*,PetscScalar
*) ;
83 void form_jacobian_pn_3E(PetscScalar
*, Mat
*, Mat
*) ;
84 void error_norm_pn_3E(PetscScalar
*,PetscScalar
*) ;
85 EBM_Solver_L3E():N(0),its(0),norm(0.0),mf_flg(PETSC_FALSE
){}