示例#1
0
文件: equation.py 项目: regmi/fipy
    def __iadd__(self, other):
        if other is not None:
            if not isinstance(other, Term):
                self._appendTerm(_ExplicitSourceTerm(coeff=other), "_ExplicitSourceTerm")
            elif isinstance(other, _Equation):
                for key in other.terms.keys():
                    self += other.terms[key]
            else:
                appended = False

                for key in self.terms.keys():

                    if eval("isinstance(other, %s)" % key):
                        self._appendTerm(other, key)
                        appended = True
                        break
                        
                if not appended:
                    if other._isAdditive():
                        self.terms[other.__class__.__name__] = other
                    else:

                        self.nonAdditiveTerms += [other]
        
        return self
示例#2
0
    def __init__(self, term, other):

        if not isinstance(other, Term):
            other = _ExplicitSourceTerm(coeff=other, var=term.var)

        self.term = term
        self.other = other

        if term.var is None:
            if other.var is None:
                pass
            else:
                raise ExplicitVariableError
        else:
            if other.var is None:
                if isinstance(other, _ExplicitSourceTerm):
                    other.var = term.var
                else:
                    raise ExplicitVariableError

        Term.__init__(self, var=self._vars[0])
示例#3
0
    def __init__(self, term, other):

        if not isinstance(other, Term):
            other = _ExplicitSourceTerm(coeff=other, var=term.var)

        self.term = term
        self.other = other

        if term.var is None:
            if other.var is None:
                pass
            else:
                raise ExplicitVariableError
        else:
            if other.var is None:
                if isinstance(other, _ExplicitSourceTerm):
                    other.var = term.var
                else:
                    raise ExplicitVariableError

        Term.__init__(self, var=self._vars[0])