Exemplo n.º 1
0
    def evaluate(self):
        """
        Evaluate the Equation or system of Equations.

        The RHS of the Equation is evaluated at the indices of the LHS if required.
        """
        try:
            lhs, rhs = self.lhs.evaluate, self.rhs._eval_at(self.lhs).evaluate
        except AttributeError:
            lhs, rhs = self._evaluate_args()
        eq = self.func(lhs,
                       rhs,
                       subdomain=self.subdomain,
                       coefficients=self.substitutions,
                       implicit_dims=self._implicit_dims)
        if eq._uses_symbolic_coefficients:
            # NOTE: As Coefficients.py is expanded we will not want
            # all rules to be expunged during this procress.
            rules = default_rules(eq, eq._symbolic_functions)
            try:
                eq = eq.xreplace({**eq.substitutions.rules, **rules})
            except AttributeError:
                if bool(rules):
                    eq = eq.xreplace(rules)
        return eq
Exemplo n.º 2
0
    def evaluate(self):
        eq = self.func(*self._evaluate_args(),
                       subdomain=self.subdomain,
                       coefficients=self.substitutions,
                       implicit_dims=self._implicit_dims)
        if eq._uses_symbolic_coefficients:
            # NOTE: As Coefficients.py is expanded we will not want
            # all rules to be expunged during this procress.
            rules = default_rules(eq, eq._symbolic_functions)
            try:
                eq = eq.xreplace({**eq.substitutions.rules, **rules})
            except AttributeError:
                if bool(rules):
                    eq = eq.xreplace(rules)

        return eq
Exemplo n.º 3
0
 def __new__(cls, *args, **kwargs):
     kwargs['evaluate'] = False
     subdomain = kwargs.pop('subdomain', None)
     substitutions = kwargs.pop('coefficients', None)
     obj = sympy.Eq.__new__(cls, *args, **kwargs)
     obj._subdomain = subdomain
     obj._substitutions = substitutions
     if obj._uses_symbolic_coefficients:
         # NOTE: As Coefficients.py is expanded we will not want
         # all rules to be expunged during this procress.
         rules = default_rules(obj, obj._symbolic_functions)
         try:
             obj = obj.xreplace({**substitutions.rules, **rules})
         except AttributeError:
             if bool(rules):
                 obj = obj.xreplace(rules)
     return obj
Exemplo n.º 4
0
 def __new__(cls, lhs, rhs=0, subdomain=None, coefficients=None, implicit_dims=None,
             **kwargs):
     kwargs['evaluate'] = False
     obj = sympy.Eq.__new__(cls, lhs, rhs, **kwargs)
     obj._subdomain = subdomain
     obj._substitutions = coefficients
     obj._implicit_dims = as_tuple(implicit_dims)
     if obj._uses_symbolic_coefficients:
         # NOTE: As Coefficients.py is expanded we will not want
         # all rules to be expunged during this procress.
         rules = default_rules(obj, obj._symbolic_functions)
         try:
             obj = obj.xreplace({**coefficients.rules, **rules})
         except AttributeError:
             if bool(rules):
                 obj = obj.xreplace(rules)
     return obj
Exemplo n.º 5
0
 def __new__(cls,
             lhs,
             rhs=0,
             implicit_dims=None,
             subdomain=None,
             coefficients=None,
             **kwargs):
     kwargs['evaluate'] = False
     obj = sympy.Eq.__new__(cls, lhs, rhs, **kwargs)
     obj._implicit_dims = as_tuple(implicit_dims)
     obj._subdomain = subdomain
     obj._substitutions = coefficients
     if obj._uses_symbolic_coefficients:
         # NOTE: As Coefficients.py is expanded we will not want
         # all rules to be expunged during this procress.
         rules = default_rules(obj, obj._symbolic_functions)
         try:
             obj = obj.xreplace({**coefficients.rules, **rules})
         except AttributeError:
             if bool(rules):
                 obj = obj.xreplace(rules)
     return obj