initial checkin, based on GSS 0.46 CVS
[gss-tcad.git] / src / solver / qddm1e / elecequ1q.cc
blob5ea861765e7f553379c0fe8798cc9156b09fd4a3
1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
3 /* 8 8 8 */
4 /* 8 8 8 */
5 /* 8 88888888 88888888 */
6 /* 8 8888 8 8 */
7 /* 8 8 8 8 */
8 /* 888888 888888888 888888888 */
9 /* */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
11 /* */
12 /* GSS 0.4x */
13 /* Last update: June 27, 2007 */
14 /* */
15 /* Gong Ding */
16 /* gdiso@ustc.edu */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
18 /* */
19 /*****************************************************************************/
21 #include "zonedata.h"
23 void ElZone::F1Q_ddm_inner(int i,PetscScalar *x,PetscScalar *f, ODE_Formula &ODE_F, vector<int> & zofs)
25 const VoronoiCell* pcell = &pzone->davcell[i];
26 PetscScalar Vi = x[zofs[zone_index]+i];
27 PetscScalar div_grad_P = 0;
28 for(int j=0;j<pcell->nb_num;j++)
30 int nb = pcell->nb_array[j];
31 PetscScalar Vr = x[zofs[zone_index]+nb]; //potential of nb node
32 div_grad_P += pcell->elen[j]/pcell->ilen[j]*(Vr-Vi)/pcell->area;
34 f[zofs[zone_index]+i] = div_grad_P;
37 void ElZone::F1Q_ddm_om_contact(int i,PetscScalar *x,PetscScalar *f, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,SMCZone *pz, int n)
39 f[zofs[zone_index]+i] = x[zofs[zone_index]+i] - x[zofs[pz->zone_index]+5*n+0];
42 void ElZone::F1Q_ddm_stk_contact(int i,PetscScalar *x,PetscScalar *f, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,SMCZone *pz, int n)
44 f[zofs[zone_index]+i] = x[zofs[zone_index]+i] - x[zofs[pz->zone_index]+5*n+0];
47 void ElZone::F1Q_ddm_gate_contact(int i,PetscScalar *x,PetscScalar *f, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,ISZone *pz, int n)
49 f[zofs[zone_index]+i] = x[zofs[zone_index]+i] - x[zofs[pz->zone_index]+n+0];
52 void ElZone::F1Q_ddm_charge_contact(int i,PetscScalar *x,PetscScalar *f, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,ISZone *pz, int n)
54 f[zofs[zone_index]+i] = x[zofs[zone_index]+i] - x[zofs[pz->zone_index]+n+0];
57 //------------------------------------------------------------------------------------------------
59 void ElZone::J1Q_ddm_inner(int i,PetscScalar *x,Mat *jac, ODE_Formula &ODE_F, vector<int> & zofs)
61 const VoronoiCell* pcell = &pzone->davcell[i];
62 PetscScalar d_div_grad_P = 0;
63 for(int j=0;j<pcell->nb_num;j++)
65 int nb = pcell->nb_array[j];
66 PetscScalar value = pcell->elen[j]/pcell->ilen[j]/pcell->area;
67 MatSetValue(*jac,zofs[zone_index]+i,zofs[zone_index]+nb,value,INSERT_VALUES);
68 d_div_grad_P += -pcell->elen[j]/pcell->ilen[j]/pcell->area;
70 MatSetValue(*jac,zofs[zone_index]+i,zofs[zone_index]+i,d_div_grad_P,INSERT_VALUES);
73 void ElZone::J1Q_ddm_om_contact(int i,PetscScalar *x,Mat *jac, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,
74 SMCZone *pz, int n)
76 MatSetValue(*jac,zofs[zone_index]+i,zofs[zone_index]+i,1.0,INSERT_VALUES);
77 MatSetValue(*jac,zofs[zone_index]+i,zofs[pz->zone_index]+5*n+0,-1.0,INSERT_VALUES);
80 void ElZone::J1Q_ddm_stk_contact(int i,PetscScalar *x,Mat *jac, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,
81 SMCZone *pz, int n)
83 MatSetValue(*jac,zofs[zone_index]+i,zofs[zone_index]+i,1.0,INSERT_VALUES);
84 MatSetValue(*jac,zofs[zone_index]+i,zofs[pz->zone_index]+5*n+0,-1.0,INSERT_VALUES);
87 void ElZone::J1Q_ddm_gate_contact(int i,PetscScalar *x,Mat *jac, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,
88 ISZone *pz, int n)
90 MatSetValue(*jac,zofs[zone_index]+i,zofs[zone_index]+i,1.0,INSERT_VALUES);
91 MatSetValue(*jac,zofs[zone_index]+i,zofs[pz->zone_index]+n,-1.0,INSERT_VALUES);
94 void ElZone::J1Q_ddm_charge_contact(int i,PetscScalar *x,Mat *jac, ODE_Formula &ODE_F, vector<int> & zofs, DABC &bc,
95 ISZone *pz, int n)
97 MatSetValue(*jac,zofs[zone_index]+i,zofs[zone_index]+i,1.0,INSERT_VALUES);
98 MatSetValue(*jac,zofs[zone_index]+i,zofs[pz->zone_index]+n,-1.0,INSERT_VALUES);