Omer,
I just ran the script with a few changes and it seemed to converge to
something reasonable
Anyway, when I run the script below with a few modifications I don't
get an error (didn't get an error
without the modifications). Which version of FiPy are you using? I
tested this on version 1.1.
Which version of Numeric? I'm using 24.2.
The new script is as follows:
#!/usr/bin/env python
# define a 1D mesh
# total length 3um
Lx = 3e-6
nx = 6000
dx = Lx / nx
print nx
# define mesh
from fipy.meshes.grid1D import Grid1D
mesh = Grid1D(dx=dx, nx=nx)
# declare the problem variable (potential across the device)
from fipy.variables.cellVariable import CellVariable
psy = CellVariable(name="psy", mesh=mesh, hasOld=1)
from fipy.tools.numerix import exp
Kb = 1.38e-23
T = 300
q = 1.6e-19
B = q/(Kb*T)
ni = 1.5e10
Na = 5e15
np0 = (ni**2)/Na
eps_0 = 8.854e-14
eps_si = 11.8*eps_0
Vref=0.2
Ho=6.02e17
eps_aqa=81*eps_0
dbulk=1e-4
dh=1.001e-4
# calculate the charge density in the semiconductor
x = mesh.getCellCenters()[...,0]
s1_semi =( -((q*B)/(eps_si))*(Na*exp(-B*psy)+np0*exp(B*psy))) * (x <=
dbulk)
s0_semi= ((q/eps_si)*(Na*(exp(-B*psy)-1)-np0*(exp(B*psy)-1))-
s1_semi*psy) * (x <= dbulk)
from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
implicitSource_semi = ImplicitSourceTerm(coeff = s1_semi)
# calculate the charge density in the diffuse layer
psyD=psy-Vref
s1_electrolyte=-(((q*Ho*B)/(eps_aqa))*(exp(-B*psyD)+exp(B*psyD))) *
(x >= dh)
s0_electrolyte=(((q*Ho)/(eps_aqa))*(exp(-B*psyD)-exp(B*psyD))-
s1_electrolyte*psyD) * (x >= dh)
from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
implicitSource_electrolyte = ImplicitSourceTerm(coeff = s1_electrolyte)
# boundary condition
from fipy.boundaryConditions.fixedValue import FixedValue
from fipy.boundaryConditions.fixedFlux import FixedFlux
bcs = (FixedValue(faces=mesh.getFacesRight(), value=Vref),
FixedFlux(faces=mesh.getFacesLeft(), value=0))
from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
diffCoeff = 1.
diffTerm = ImplicitDiffusionTerm(coeff=diffCoeff)
# poisson equation
samfet_eq = diffTerm + s0_semi + implicitSource_semi + s0_electrolyte
+ implicitSource_electrolyte == 0
# solve the equation
res = 1e+10
if __name__ == '__main__':
from fipy.viewers import make
viewer = make(vars=(psy), limits={'datamax' : 0.23, 'datamin' :
0.17})
viewer.plot()
while res > 1e-10:
res = samfet_eq.sweep(var=psy,boundaryConditions=bcs)
print 'res',res,'min(psy)',min(psy),'max(psy)',max(psy)
viewer.plot()
## raw_input()
## if __name__ == '__main__':
## from fipy.viewers import make
## viewer = make(vars=(psy))
## viewer.plot()
##from fipy.viewers.tsvViewer import TSVViewer
##TSVViewer(vars=(psy)).plot(filename=".\out\samfet.tsv")
On Nov 15, 2006, at 4:42 PM, Omer Yassur wrote:
Hi Daniel,
I tried to work with the debugger in order to trace the error,
unfortunately with no success.
You can find below, the original script and the Traceback.
Short glance at the division terms show that order of math operators
is rational and seems o.k.
Can you please advice me on how to debug this problem?
Many thanks,
--
Daniel Wheeler