def shiftPlaquette(self, plaquette, plaqDir1, plaqDir2, shiftDir, sign):
        # Moving one site forwards is equivalent to shifting the whole field
        # backwards, hence the minus sign (active/passive transform)
        plaquetteShifted = tf.roll(plaquette, -sign, shiftDir)

        if shiftDir != 0:
            return plaquetteShifted

        indices = FieldTools.boundaryIndices(self.latShape, shiftDir, sign)

        if sign == -1 and (plaqDir1 == 0 or plaqDir2 == 0):
            # Set the plaquettes straddling the origin to the identity
            updates = tf.eye(2,
                             batch_shape=tf.shape(indices)[0:-1],
                             dtype=tf.complex128)
            plaquetteShifted = tf.tensor_scatter_nd_update(
                plaquetteShifted, indices, updates)
        else:
            # Apply reflecting BC's by setting links at the boundary to
            # corresponding values from unshifted field
            updates = tf.gather_nd(plaquette, indices)
            plaquetteShifted = tf.tensor_scatter_nd_update(
                plaquetteShifted, indices, updates)

        return plaquetteShifted
Example #2
0
    def shiftScalarField(self, scalarField, cpt, sign):
        scalarFieldShifted = tf.roll(scalarField, -sign, cpt)

        pauliMatNum = self.boundaryConditions[cpt]

        # Only requires flipping if third pauli matrix is used
        if pauliMatNum != 3:
            return scalarFieldShifted

        latShape = tf.shape(scalarField)[0:-2]
        indices = FieldTools.boundaryIndices(latShape, cpt, +1)
        updates = -1.0 * tf.gather_nd(scalarFieldShifted, indices)

        scalarFieldShifted = tf.tensor_scatter_nd_update(
            scalarFieldShifted, indices, updates)

        return scalarFieldShifted
    def shiftGaugeField(self, gaugeField, cpt, sign):
        gaugeFieldShifted = tf.roll(gaugeField, -sign, cpt)

        pauliMatNum = self.boundaryConditions[cpt]

        if pauliMatNum == 0:
            return gaugeFieldShifted

        latShape = tf.shape(gaugeField)[0:3]
        indices = FieldTools.boundaryIndices(latShape, cpt, sign)

        updates = tf.gather_nd(gaugeFieldShifted, indices)
        updates = FieldTools.pauliMatrix(pauliMatNum) @\
            updates @ FieldTools.pauliMatrix(pauliMatNum)

        gaugeFieldShifted = tf.tensor_scatter_nd_update(
            gaugeFieldShifted, indices, updates)
        return gaugeFieldShifted
    def shiftCovDeriv(self, covDeriv, cpt, sign):
        covDerivShifted = tf.roll(covDeriv, -sign, cpt)

        if cpt != 0:
            return covDerivShifted

        indices = FieldTools.boundaryIndices(self.latShape, cpt, sign)

        if sign == -1:
            updates = tf.zeros(tf.concat([tf.shape(indices)[0:-1], [2, 2]], 0),
                               dtype=tf.complex128)
        else:
            updates = tf.gather_nd(covDeriv, indices)

        covDerivShifted = tf.tensor_scatter_nd_update(covDerivShifted, indices,
                                                      updates)

        return covDerivShifted
    def shiftGaugeField(self, gaugeField, cpt, sign):
        # Moving one site forwards is equivalent to shifting the whole field
        # backwards, hence the minus sign (active/passive transform)
        gaugeFieldShifted = tf.roll(gaugeField, -sign, cpt)

        if cpt != 0:
            return gaugeFieldShifted

        # Apply reflecting BC's by setting links at the boundary to
        # corresponding values from unshifted field
        if sign == +1:
            slicePos = self.latShape[cpt] - 2
        else:
            slicePos = 1
        # For gathering from the shifted field (gathering from the variable is slow)
        indices = FieldTools.sliceIndices(self.latShape, cpt, slicePos)
        # For scattering onto the boundary
        boundaryIndices = FieldTools.boundaryIndices(self.latShape, cpt, sign)
        updates = tf.gather_nd(gaugeFieldShifted, indices)
        boundaryUpdates = tf.gather_nd(gaugeField, boundaryIndices)

        gaugeFieldShifted = tf.tensor_scatter_nd_update(
            gaugeFieldShifted, boundaryIndices, updates)

        if sign == -1:
            # Set the r-links at the origin to the identity
            rOriginIndices = tf.stack(
                tf.meshgrid(0,
                            tf.range(self.latShape[1]),
                            tf.range(self.latShape[2]),
                            0,
                            indexing="ij"), -1)
            rOriginUpdates = tf.eye(2,
                                    batch_shape=tf.shape(rOriginIndices)[0:-1],
                                    dtype=tf.complex128)
            gaugeFieldShifted = tf.tensor_scatter_nd_update(
                gaugeFieldShifted, rOriginIndices, rOriginUpdates)

        return gaugeFieldShifted
    def shiftScalarField(self, scalarField, cpt, sign):
        # Moving one site forwards is equivalent to shifting the whole field
        # backwards, hence the minus sign (active/passive transform)
        scalarFieldShifted = tf.roll(scalarField, -sign, cpt)

        if cpt != 0:
            return scalarFieldShifted

        # Apply reflecting BC's by setting links at the boundary to
        # corresponding values from unshifted field
        if sign == +1:
            slicePos = self.latShape[cpt] - 2
        else:
            slicePos = 1
        # For gathering from the shifted field (gathering from the variable is slow)
        indices = FieldTools.sliceIndices(self.latShape, cpt, slicePos)
        # For scattering onto the boundary
        boundaryIndices = FieldTools.boundaryIndices(self.latShape, cpt, sign)
        updates = tf.gather_nd(scalarFieldShifted, indices)
        scalarFieldShifted = tf.tensor_scatter_nd_update(
            scalarFieldShifted, boundaryIndices, updates)

        return scalarFieldShifted