예제 #1
0
    def get_wavepacket(self, packetindex):
        r"""Get the wavepacket :math:`\Psi_j` from the linear combination.

        :param index: The index :math:`0 \leq j < J` of the packet to retrieve.
        :return: The wavepacket :math:`\Psi_j`.
        :type: A :py:class:`HagedornWavepacket` instance.
        """
        if packetindex > self._number_packets - 1 or packetindex < 0:
            raise ValueError("There is no packet with index {}.".format(packetindex))

        HAWP = HagedornWavepacket(self._dimension, self._number_components, self._eps)
        K = self._basis_shapes[self._basis_shapes_hashes[packetindex]]
        HAWP.set_basis_shapes([K])
        q = self._Pis[0][packetindex, :]
        p = self._Pis[1][packetindex, :]
        Q = self._Pis[2][packetindex, :, :]
        P = self._Pis[3][packetindex, :, :]
        S = self._Pis[4][packetindex, :]
        HAWP.set_parameters([q, p, Q, P, S])
        cj = self._wp_coefficients[packetindex, :]
        HAWP.set_coefficients(cj, component=0)
        return HAWP
    def overlap(self, D, Pi, eps):
        r"""Compute the overlap matrix:

        .. math::
            \mathbf{K}_{r,c} := \langle \psi_{\underline{e_r}}[\Pi] | \phi_{\underline{e_c}}[\Pi] \rangle

        :param D: The dimension :math:`D`.
        :param Pi: The parameter set :math:`\Pi`.
        :param eps: The semiclassical scaling parameter :math:`\varepsilon`.
        """
        ED = list(lattice_points_norm(D, 1))

        BS = SimplexShape(D, 1)

        WPo = HagedornWavepacket(D, 1, eps)
        WPo.set_parameters(Pi)
        WPo.set_basis_shapes([BS])

        WPn = HagedornWavepacketPsi(D, 1, eps)
        WPn.set_parameters(Pi)
        WPn.set_basis_shapes([BS])

        TPG = TensorProductQR(D * [GaussHermiteQR(2)])
        DHQ = DirectHomogeneousQuadrature(TPG)
        G = DHQ.transform_nodes(Pi, eps)
        W = TPG.get_weights()

        phi = WPo.evaluate_basis_at(G, component=0)
        psi = WPn.evaluate_basis_at(G, component=0)

        K = zeros((D, D), dtype=complexfloating)

        for r, er in enumerate(ED):
            for c, ec in enumerate(ED):
                K[r, c] = eps**D * sum(
                    conjugate(psi[BS[er], :]) * phi[BS[ec], :] * W)

        return K
예제 #3
0
    def overlap(self, D, Pi, eps):
        r"""Compute the overlap matrix:

        .. math::
            \mathbf{K}_{r,c} := \langle \psi_{\underline{e_r}}[\Pi] | \phi_{\underline{e_c}}[\Pi] \rangle

        :param D: The dimension :math:`D`.
        :param Pi: The parameter set :math:`\Pi`.
        :param eps: The semiclassical scaling parameter :math:`\varepsilon`.
        """
        ED = list(lattice_points_norm(D, 1))

        BS = SimplexShape(D, 1)

        WPo = HagedornWavepacket(D, 1, eps)
        WPo.set_parameters(Pi)
        WPo.set_basis_shapes([BS])

        WPn = HagedornWavepacketPsi(D, 1, eps)
        WPn.set_parameters(Pi)
        WPn.set_basis_shapes([BS])

        TPG = TensorProductQR(D * [GaussHermiteQR(2)])
        DHQ = DirectHomogeneousQuadrature(TPG)
        G = DHQ.transform_nodes(Pi, eps)
        W = TPG.get_weights()

        phi = WPo.evaluate_basis_at(G, component=0)
        psi = WPn.evaluate_basis_at(G, component=0)

        K = zeros((D, D), dtype=complexfloating)

        for r, er in enumerate(ED):
            for c, ec in enumerate(ED):
                K[r, c] = eps**D * sum(conjugate(psi[BS[er], :]) * phi[BS[ec], :] * W)

        return K
예제 #4
0
    def create_wavepacket(self, description):

        wp_type = description["type"]

        if wp_type == "HagedornWavepacket":
            from WaveBlocksND.HagedornWavepacket import HagedornWavepacket

            # Initialize a packet
            WP = HagedornWavepacket(description["dimension"],
                                    description["ncomponents"],
                                    description["eps"])

            # Set parameters
            if "Pi" in description:
                Pi = description["Pi"]
                WP.set_parameters(Pi)

            # Configure basis shapes
            if "basis_shapes" in description:
                for component, shapedescr in enumerate(
                        description["basis_shapes"]):
                    BS = self.create_basis_shape(shapedescr)
                    WP.set_basis_shapes(BS, component=component)

            # Set coefficients
            if "coefficients" in description:
                for component, data in enumerate(description["coefficients"]):
                    BS = WP.get_basis_shapes(component=component)
                    for index, value in data:
                        if BS.contains(index):
                            WP.set_coefficient(component, index, value)
                        else:
                            print("Warning: dropped coefficient with index {}".
                                  format(index))

            # And the inner product
            if "innerproduct" in description:
                IP = self.create_inner_product(description["innerproduct"])
                WP.set_innerproduct(IP)
            else:
                print("Warning: no inner product specified!")

        elif wp_type == "HagedornWavepacketInhomogeneous":
            from WaveBlocksND.HagedornWavepacketInhomogeneous import HagedornWavepacketInhomogeneous

            # Initialize a packet
            WP = HagedornWavepacketInhomogeneous(description["dimension"],
                                                 description["ncomponents"],
                                                 description["eps"])

            # Set parameters
            if "Pi" in description:
                Pi = description["Pi"]
                WP.set_parameters(Pi)

            # Configure basis shapes
            if "basis_shapes" in description:
                for component, shapedescr in enumerate(
                        description["basis_shapes"]):
                    BS = self.create_basis_shape(shapedescr)
                    WP.set_basis_shapes(BS, component=component)

            # Set coefficients
            if "coefficients" in description:
                for component, data in enumerate(description["coefficients"]):
                    for index, value in data:
                        WP.set_coefficient(component, index, value)

            # And the quadrature
            if "innerproduct" in description:
                IP = self.create_inner_product(description["innerproduct"])
                WP.set_innerproduct(IP)
            else:
                print("Warning: no inner product specified!")

        else:
            raise ValueError("Unknown wavepacket type {}".format(wp_type))

        return WP
예제 #5
0
    def create_wavepacket(self, description):

        wp_type = description["type"]

        if wp_type == "HagedornWavepacket":
            from WaveBlocksND.HagedornWavepacket import HagedornWavepacket

            # Initialize a packet
            WP = HagedornWavepacket(description["dimension"],
                                    description["ncomponents"],
                                    description["eps"])

            # Set parameters
            if "Pi" in description:
                Pi = description["Pi"]
                WP.set_parameters(Pi)

            # Configure basis shapes
            if "basis_shapes" in description:
                for component, shapedescr in enumerate(description["basis_shapes"]):
                    BS = self.create_basis_shape(shapedescr)
                    WP.set_basis_shapes(BS, component=component)

            # Set coefficients
            if "coefficients" in description:
                for component, data in enumerate(description["coefficients"]):
                    BS = WP.get_basis_shapes(component=component)
                    for index, value in data:
                        if BS.contains(index):
                            WP.set_coefficient(component, index, value)
                        else:
                            print("Warning: dropped coefficient with index {}".format(index))

            # And the inner product
            if "innerproduct" in description:
                IP = self.create_inner_product(description["innerproduct"])
                WP.set_innerproduct(IP)
            else:
                print("Warning: no inner product specified!")

        elif wp_type == "HagedornWavepacketInhomogeneous":
            from WaveBlocksND.HagedornWavepacketInhomogeneous import HagedornWavepacketInhomogeneous

            # Initialize a packet
            WP = HagedornWavepacketInhomogeneous(description["dimension"],
                                                 description["ncomponents"],
                                                 description["eps"])

            # Set parameters
            if "Pi" in description:
                Pi = description["Pi"]
                WP.set_parameters(Pi)

            # Configure basis shapes
            if "basis_shapes" in description:
                for component, shapedescr in enumerate(description["basis_shapes"]):
                    BS = self.create_basis_shape(shapedescr)
                    WP.set_basis_shapes(BS, component=component)

            # Set coefficients
            if "coefficients" in description:
                for component, data in enumerate(description["coefficients"]):
                    for index, value in data:
                        WP.set_coefficient(component, index, value)

            # And the quadrature
            if "innerproduct" in description:
                IP = self.create_inner_product(description["innerproduct"])
                WP.set_innerproduct(IP)
            else:
                print("Warning: no inner product specified!")

        else:
            raise ValueError("Unknown wavepacket type {}".format(wp_type))

        return WP