Exemplo n.º 1
0
    def get_truncated_com_operator_squared(
        self,
        xmin: float,
        xmax: float,
    ) -> MBOperatorSpecification:
        term = numpy.copy(self.grid.get_x())
        term[numpy.logical_or(term < xmin, term > xmax)] = 0.0

        term2 = term**2
        return MBOperatorSpecification(
            (1, ),
            (self.grid, ),
            {
                "com_squared_coeff_1": 1.0,
                "com_squared_coeff_2": 2.0,
            },
            {
                "com_squared_x": term,
                "com_squared_x^2": term2,
            },
            [
                "com_squared_coeff_1 | 1 com_squared_x^2",
                "com_squared_coeff_2 | 1 com_squared_x | 1* com_squared_x",
            ],
        )
Exemplo n.º 2
0
    def get_site_occupation_pair_operator(
        self,
        site_index_1: int,
        site_index_2: int,
    ) -> MBOperatorSpecification:
        n = self.grid.get().npoints
        term_1 = numpy.zeros(n)
        term_1[site_index_1] = 1
        term_2 = numpy.zeros(n)
        term_2[site_index_2] = 1

        terms = {
            "site_occupation_pair_1": term_1,
            "site_occupation_pair_2": term_2
        }
        coefficients = {"site_occupation_pair_2b_coeff": 2.0}
        table = [
            "site_occupation_pair_2b_coeff | 1 site_occupation_pair_1 | 1* site_occupation_pair_2",
        ]
        if site_index_1 == site_index_2:
            coefficients["site_occupation_pair_1b_coeff"] = 1.0
            table.append(
                "site_occupation_pair_1b_coeff | 1 site_occupation_pair_1")
        return MBOperatorSpecification((1, ), (self.grid, ), coefficients,
                                       terms, table)
Exemplo n.º 3
0
 def get_com_operator_A(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, 1),
         (self.grid, self.grid),
         {"com_coeff_A": 1.0 / self.parameters.N_A},
         {"com_A": self.grid.get_x()},
         ["com_coeff_A | 1 com_A"],
     )
Exemplo n.º 4
0
 def get_com_operator(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"com_coeff": 1.0 / self.parameters.N},
         {"com": self.grid.get_x()},
         "com_coeff | 1 com",
     )
Exemplo n.º 5
0
 def get_com_operator_B(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, 1),
         (self.grid, self.grid),
         {"com_coeff_B": 1.0 / self.parameters.N_B},
         {"com_B": self.grid.get_x()},
         ["com_coeff_B | 2 com_B"],
     )
Exemplo n.º 6
0
 def get_interaction_operator_AB(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, 1),
         (self.grid, self.grid),
         {"interaction_coeff_AB": self.parameters.g_AB},
         {"interaction_AB": self.grid.get_delta()},
         ["interaction_coeff_AB | {1:2} interaction_AB"],
     )
Exemplo n.º 7
0
 def get_particle_number_operator(self) -> MBOperatorSpecification:
     term = numpy.ones(self.grid.get().npoints)
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"particle_number_coeff": 1.0},
         {"particle_number": term},
         "particle_number_coeff | 1 particle_number",
     )
Exemplo n.º 8
0
 def create_correlator(self, site_a: int,
                       site_b: int) -> MBOperatorSpecification:
     matrix = numpy.zeros((self.parameters.sites, self.parameters.sites))
     matrix[site_a, site_b] = 1.0
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"correlator_coeff": 1.0},
         {"correlator": matrix},
         "correlator_coeff | 1 correlator",
     )
Exemplo n.º 9
0
 def get_potential_operator_left_B(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, 1),
         (self.grid, self.grid),
         {"potential_left_coeff_B": -self.parameters.V0L},
         {
             "potential_left_B":
             gaussian(self.grid.get_x(), self.parameters.x0L, 1.0)
         },
         "potential_left_coeff_B | 2 potential_left_B",
     )
Exemplo n.º 10
0
    def get_site_occupation_operator(
            self, site_index: int) -> MBOperatorSpecification:
        term = numpy.zeros(self.grid.get().npoints)
        term[site_index] = 1

        return MBOperatorSpecification(
            (1, ),
            (self.grid, ),
            {"site_occupation_coeff": 1.0},
            {"site_occupation": term},
            "site_occupation_coeff | 1 site_occupation",
        )
Exemplo n.º 11
0
 def get_kinetic_operator(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"kinetic_coeff": -0.5},
         {
             "kinetic": {
                 "value": self.grid.get_d2(),
                 "fft": self.grid.is_fft()
             }
         },
         "kinetic_coeff | 1 kinetic",
     )
Exemplo n.º 12
0
 def get_momentum_operator(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"momentum_coeff": -1j},
         {
             "momentum": {
                 "value": self.grid.get_d1(),
                 "fft": self.grid.is_fft()
             }
         },
         "momentum_coeff | 1 momentum",
     )
Exemplo n.º 13
0
 def get_truncated_com_operator(
     self,
     xmin: float,
     xmax: float,
 ) -> MBOperatorSpecification:
     term = numpy.copy(self.grid.get_x())
     term[numpy.logical_or(term < xmin, term > xmax)] = 0.0
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"com_coeff": 1.0},
         {"com": term},
         "com_coeff | 1 com",
     )
Exemplo n.º 14
0
 def get_truncated_unit_operator(
     self,
     xmin: float,
     xmax: float,
 ) -> MBOperatorSpecification:
     term = numpy.zeros_like(self.grid.get_x())
     term[numpy.logical_and(self.grid.get_x() >= xmin,
                            self.grid.get_x() <= xmax)] = 1.0
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {"norm": 1.0 / self.parameters["N"]},
         {"truncated_one": term},
         "norm | 1 truncated_one",
     )
Exemplo n.º 15
0
 def get_kinetic_operator_B(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, 1),
         (self.grid, self.grid),
         {
             "kinetic_coeff_B": -0.5 * self.parameters.mass_B,
         },
         {
             "kinetic_B": {
                 "value": self.grid.get_d2(),
                 "fft": self.grid.is_fft(),
             },
         },
         "kinetic_coeff_B | 2 kinetic_B",
     )
Exemplo n.º 16
0
 def get_potential_operator_right_B(self) -> MBOperatorSpecification:
     return MBOperatorSpecification(
         (1, 1),
         (self.grid, self.grid),
         {"potential_right_coeff_B": -self.parameters.V0R},
         {
             "potential_right_B":
             gaussian(
                 self.grid.get_x(),
                 self.parameters.x0R,
                 self.parameters.alpha,
             ),
         },
         "potential_right_coeff_B | 2 potential_right_B",
     )
Exemplo n.º 17
0
 def get_com_operator_squared(self) -> MBOperatorSpecification:
     N_squared = self.parameters.N**2
     return MBOperatorSpecification(
         (1, ),
         (self.grid, ),
         {
             "com_squared_coeff_1": 1.0,
             "com_squared_coeff_2": 2.0,
         },
         {
             "com_squared_x": self.grid.get_x() / N_squared,
             "com_squared_x^2": self.grid.get_x()**2 / N_squared,
         },
         [
             "com_squared_coeff_1 | 1 com_squared_x^2",
             "com_squared_coeff_2 | 1 com_squared_x | 1* com_squared_x",
         ],
     )
Exemplo n.º 18
0
    def create_hopping_term(self) -> MBOperatorSpecification:
        matrix = numpy.zeros((self.parameters.sites, self.parameters.sites))
        for i in range(self.parameters.sites - 1):
            matrix[i, i + 1] = 1.0
            matrix[i + 1, i] = 1.0

        if self.parameters.pbc:
            matrix[0, -1] = 1.0
            matrix[-1, 0] = 1.0

        return MBOperatorSpecification(
            (1, ),
            (self.grid, ),
            {
                "hopping_coeff": -self.parameters.J,
            },
            {"hopping": matrix},
            "hopping_coeff | 1 hopping",
        )
Exemplo n.º 19
0
    def get_site_occupation_operator_squared(
        self,
        site_index: int,
    ) -> MBOperatorSpecification:
        term = numpy.zeros(self.grid.get().npoints)
        term[site_index] = 1

        return MBOperatorSpecification(
            (1, ),
            (self.grid, ),
            {
                "site_occupation_coeff_1": 1.0,
                "site_occupation_coeff_2": 2.0
            },
            {"site_occupation": term},
            [
                "site_occupation_coeff_1 | 1 site_occupation",
                "site_occupation_coeff_2 | 1 site_occupation | 1* site_occupation",
            ],
        )
Exemplo n.º 20
0
    def create_interaction_term(self) -> MBOperatorSpecification:
        def create_delta_peak(n: int, i: int) -> numpy.ndarray:
            result = numpy.zeros(n)
            result[i] = 1.0
            return result

        n = self.grid.get().npoints

        return MBOperatorSpecification(
            (1, ),
            (self.grid, ),
            {"interaction_coeff": self.parameters.U},
            {
                f"interaction_term_{i}": create_delta_peak(n, i)
                for i in range(n)
            },
            [
                "interaction_coeff | 1 interaction_term_{} | 1* interaction_term_{}"
                .format(
                    i,
                    i,
                ) for i in range(n)
            ],
        )
Exemplo n.º 21
0
    def get_hamiltonian_colliding(
        self,
        vL: float = 1.0,
        aL: float = 0.0,
        vR: Optional[float] = None,
        aR: Optional[float] = None,
    ) -> MBOperatorSpecification:
        if vR is None:
            vR = -vL

        if aR is None:
            aR = -aL

        left_potential = MBOperatorSpecification(
            (1, 1),
            (self.grid, self.grid),
            {
                "potential_left_coeff_A": 1.0,
                "potential_left_coeff_B": 1.0
            },
            {
                "potential_left_A": {
                    "td_name": "moving_gaussian",
                    "td_args":
                    [-self.parameters.V0L, self.parameters.x0L, vL, aL],
                },
                "potential_left_B": {
                    "td_name": "moving_gaussian",
                    "td_args":
                    [-self.parameters.V0L, self.parameters.x0L, vL, aL],
                },
            },
            [
                "potential_left_coeff_A | 1 potential_left_A",
                "potential_left_coeff_B | 2 potential_left_B",
            ],
        )

        right_potential = MBOperatorSpecification(
            (1, 1),
            (self.grid, self.grid),
            {
                "potential_right_coeff_A": 1.0,
                "potential_right_coeff_B": 1.0
            },
            {
                "potential_right_A": {
                    "td_name": "moving_gaussian",
                    "td_args":
                    [-self.parameters.V0R, self.parameters.x0R, vR, aR],
                },
                "potential_right_B": {
                    "td_name": "moving_gaussian",
                    "td_args":
                    [-self.parameters.V0R, self.parameters.x0R, vR, aR],
                },
            },
            [
                "potential_right_coeff_A | 1 potential_right_A",
                "potential_right_coeff_B | 2 potential_right_B",
            ],
        )

        operator = self.get_kinetic_operator(
        ) + left_potential + right_potential
        if self.parameters.g_AB != 0.0:
            operator += self.get_interaction_operator_AB()

        if (self.parameters.N_A > 1) and (self.parameters.g_AA != 0.0):
            operator += self.get_interaction_operator_AA()

        if (self.parameters.N_B > 1) and (self.parameters.g_BB != 0.0):
            operator += self.get_interaction_operator_BB()

        return operator