Example #1
0
 def val(self):
     "The value of the impedance matrix"
     Z = LookupArray(
         (self.sources, (self.part_o, self.basis_container), self.unknowns,
          (self.part_s, self.basis_container)),
         dtype=np.complex128)
     Z.simple_view()[:] = self.matrices['Z']
     return Z
Example #2
0
 def val(self):
     "The value of the impedance matrix"
     s = self.md['s']
     Z = LookupArray((self.sources, (self.part_o, self.basis_container),
                      self.unknowns, (self.part_s, self.basis_container)),
                     dtype=np.complex128)
     Z.simple_view()[:] = self.matrices['S']/s + s*self.matrices['L']
     return Z
Example #3
0
 def val(self):
     "The value of the impedance matrix"
     s = self.md['s']
     alpha = self.md['alpha']
     Z = LookupArray(
         (self.sources, (self.part_o, self.basis_container), self.unknowns,
          (self.part_s, self.basis_container)),
         dtype=np.complex128)
     Z.simple_view()[:] = (
         alpha * (self.matrices['S'] / s + s * self.matrices['L']) +
         (1.0 - alpha) * self.matrices['M'])
     return Z
Example #4
0
    def solve(self, vec):
        """Solve the impedance matrix for a source vector. Caches the
        factorised matrix for efficiently solving multiple vectors"""
        if self.part_o != self.part_s:
            raise ValueError("Can only invert a self-impedance matrix")

        Z_lu = self.factored()
        if isinstance(vec, LookupArray):
            vec = vec.simple_view()

        lookup = (self.unknowns, (self.part_s, self.basis_container))

        if len(vec.shape) > 1:
            lookup = lookup + (vec.shape[1], )

        I = LookupArray(lookup, dtype=np.complex128)
        I_simp = I.simple_view()
        I_simp[:] = la.lu_solve(Z_lu, vec)
        return I
Example #5
0
    def solve(self, vec):
        """Solve the impedance matrix for a source vector. Caches the
        factorised matrix for efficiently solving multiple vectors"""
        if self.part_o != self.part_s:
            raise ValueError("Can only invert a self-impedance matrix")

        Z_lu = self.factored()
        if isinstance(vec, LookupArray):
            vec = vec.simple_view()

        lookup = (self.unknowns, (self.part_s, self.basis_container))

        if len(vec.shape) > 1:
            lookup = lookup+(vec.shape[1],)

        I = LookupArray(lookup, dtype=np.complex128)
        I_simp = I.simple_view()
        I_simp[:] = la.lu_solve(Z_lu, vec)
        return I