Changeset 2605 for trunk

Show
Ignore:
Timestamp:
06/19/2008 06:02:50 PM (7 months ago)
Author:
wd15
Message:

sweep now calculates the L2 residual normalized by the L2 norm of the b vector

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/convection/robin.py

    r2574 r2605  
    122122 
    123123    >>> res = 1e+10 
    124     >>> while res > 1e-3: 
     124    >>> while res > 1e-5: 
    125125    ...     res = eq.sweep(var=C, boundaryConditions=BCs) 
    126126    ...     if __name__ == '__main__': 
  • trunk/fipy/terms/term.py

    r2573 r2605  
    8383    def _calcResidual(self, var, matrix, RHSvector): 
    8484 
    85         return abs(self._calcResidualVector(var, matrix, RHSvector)).max() 
     85        L2norm = numerix.sqrt(numerix.sum(self._calcResidualVector(var, matrix, RHSvector)**2)) 
     86        RHSL2norm = numerix.sqrt(numerix.sum(RHSvector**2)) 
     87         
     88        if RHSL2norm == 0: 
     89            return L2norm 
     90        else: 
     91            return L2norm / RHSL2norm  
     92 
     93##        return abs(self._calcResidualVector(var, matrix, RHSvector)).max() 
    8694 
    8795    def __buildMatrix(self, var, SparseMatrix, boundaryConditions, dt):