I am completely new to fipy. I am trying to solve the following set of pdes across two different domains using fipy. The variables are p,n and ψ and q,Dn,Dp,un,up,e and N are all constants. N and e change values from domain 1 to domain 2. Domain 2 is a rectangular domain stacked above a similar rectangular domain 1. The variables p and n are to be solved for in domain 1 and ψ is to be solved for in both the domains- domain1 and domain 2.
qDn∇2n − qun∇.(n∇ψ) = q(n-10**11)/10**(-6), in Domain 1
qDp∇2p + qup∇.(p∇ψ) = -q(p-10**21)/10**(-6), in Domain 1
∇2ψ = −(p − n- N)/e in Domain 1
e∇2ψ = 0 in Domain 2
The code that I have written for solving the pdes has been attached below.
! pip install pyparse
from fipy import *
L= 10**(-6)
h= 20**(-6)
tox= 0.1*10**(-6)
q=1.6*10**(-19)
un=0.14
up=0.045
Vth=0.026
Dp= up*Vth
Dn=un*Vth
p0= 10**(21)
n0= 10**(11)
e0=8.854*10**(-12)
mesh1= Grid2D(dx= L/100,nx=100,dy=h/200,ny=200)
mesh2= Grid2D(dx= L/100,nx=100,dy=tox/10,ny=10)
mesh3= mesh1+(mesh2+[[0],[h]]) # final mesh
x,y= mesh3.cellCenters
N= 10**21*(y<=h) # N changes from Domain 1 to Domain 2
e= 11.9*e0*(y<=h)+ 3.9*e0*(y>h) # e changes from Domain 1 to Domain 2
p1=CellVariable(name='hole',mesh=mesh3,hasOld=True,value=p0)
n1=CellVariable(name='electron',mesh=mesh3,hasOld=True,value=n0)
psi=CellVariable(name='potential',mesh=mesh3,hasOld=True,value=1)
p=p1*(y<=h) # for domain separation
n=n1*(y<=h) # for domain separation
mask1=((y==0))
mask2=(y==h)
mask3=(y==(h+tox))
# 1e50 is the large value
# boundary conditions are p(x,0)= p0, n(x,0)= n0, psi(x,0)= 0, p(x,h)= p0*exp(-psi/Vth), n(x,h)= n0*exp(psi/Vth), psi(h+tox)= 5
eq1=(DiffusionTerm(coeff=q*Dn,var=n)-ConvectionTerm(coeff=q*un*psi.faceGrad,var=n)==ImplicitSourceTerm(coeff=q*(n-10**5)/10**(-6),var=n)-ImplicitSourceTerm(mask1*1e50)-ImplicitSourceTerm(mask2*1e50)+mask1*1e50*n0+mask2*1e50*n0*numerix.exp(psi/Vth))
eq2=(DiffusionTerm(coeff=q*Dp,var=p)+ConvectionTerm(coeff=q*up*psi.faceGrad,var=p)==ImplicitSourceTerm(coeff=-q*(p-10**15)/10**(-6),var=p)-ImplicitSourceTerm(mask1*1e50)-ImplicitSourceTerm(mask2*1e50)+mask1*1e50*p0+mask2*1e50*p0*numerix.exp(psi/Vth))
eq3=(DiffusionTerm(coeff=e,var=psi)==ImplicitSourceTerm(coeff=-q*(p-n-N),var=psi)-ImplicitSourceTerm(mask1*1e50)-ImplicitSourceTerm(mask2*1e50)-ImplicitSouceTerm(mask3*1e50)+mask1*1e50*0+mask2*1e50*psi+mask3*1e50*5)
eq= eq1 & eq2 & eq3
for t in range (50):
p.updateOld()
n.updateOld()
psi.updateOld()
eq.solve(dt=10) # Since the equation does not have any transient term, a large value of dt=5 has been chosen
Now, I am getting the following error: ExplicitVariableError: Terms with explicit Variables cannot mix with Terms with implicit Variables.
I am also not sure whether the coupling between the equations actually work out considering the way I have written the code.
Please note that I am actually solving a MOSCAP using the above pdes. Any help regarding this would be highly appreciated.