On Oct 12, 2006, at 10:51 AM, hzhatlboro wrote:

Hi, Daniel and Jon,

Thanks for your useful support and I've now reached a stage to choose a proper solver for my problem (there might be some hidden errors, though).  I did find that it is much easier to formulate my equations by using FiPy.

Good.

Attached please find the program and I have tried to use "sweep", which is a concept not quite familiar to me, to solve the equations.

That is the correct method to use in your case.

However, I got the following error.

You have "2 / p" in a number of your coefficients. Replace that with "2 / (p==0 * 1e-20 + p)". That will stop the divide by 0 error.

I would be grateful if you could advise what kind of solvers are available in FiPy and which one should be used for which circumstance.

The FiPy programmer's reference has some details on that. In your case the default solver (PCG) should be fine.

In particular, which solver I should choose for my problem.  I apologize if this info was in the manual already.

Thanks and regards,
hzhatlboro


Traceback (most recent call last):
  File "C:\Python24\hzh\pf2dtest.py", line 251, in ?
    phaseRes=phii.equation.sweep(var=phii, dt=dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\term.py", line 149, in sweep
    matrix, RHSvector = self.__buildMatrix(var, boundaryConditions, dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\term.py", line 95, in __buildMatrix
    return self._buildMatrix(var, boundaryConditions, dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\binaryTerm.py", line 66, in _buildMatrix
    termMatrix, termRHSvector = self.term2._buildMatrix(var, boundaryConditions, dt = dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\binaryTerm.py", line 64, in _buildMatrix
    matrix, RHSvector = self.term1._buildMatrix(var, boundaryConditions, dt = dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\binaryTerm.py", line 64, in _buildMatrix
    matrix, RHSvector = self.term1._buildMatrix(var, boundaryConditions, dt = dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\binaryTerm.py", line 64, in _buildMatrix
    matrix, RHSvector = self.term1._buildMatrix(var, boundaryConditions, dt = dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\binaryTerm.py", line 64, in _buildMatrix
    matrix, RHSvector = self.term1._buildMatrix(var, boundaryConditions, dt = dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\binaryTerm.py", line 66, in _buildMatrix
    termMatrix, termRHSvector = self.term2._buildMatrix(var, boundaryConditions, dt = dt)
  File "C:\Python24\Lib\site-packages\fipy\terms\cellTerm.py", line 121, in _buildMatrix
    inline._optionalInline(self._buildMatrixIn, self._buildMatrixPy, L, var.getOld(), b, dt, coeffVectors)
  File "C:\Python24\Lib\site-packages\fipy\tools\inline\inline.py", line 10, in _optionalInline
    return pythonFn(*args)
  File "C:\Python24\Lib\site-packages\fipy\terms\cellTerm.py", line 88, in _buildMatrixPy
    b += Numeric.array(oldArray) * Numeric.array(coeffVectors['old value']) / dt
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 162, in __array__
    return Numeric.array(self.getValue(), t)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1702, in _calcValue
    val1 = self.var[1].getValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\cellVariable.py", line 108, in getValue
    return Variable.getValue(self)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 342, in getValue
    value = self._calcValue()
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1708, in _calcValue
    return self.op(self.var[0].getValue(), val1)
  File "C:\Python24\Lib\site-packages\fipy\variables\variable.py", line 1753, in <lambda>
    return self._getBinaryOperatorVariable(lambda a,b: b/a, other)
ZeroDivisionError: divide by zero



Send instant messages to your online friends http://uk.messenger.yahoo.com 
<pf2dtest.py>

--

Daniel Wheeler



Reply via email to