def gradient_S3_pullback(gamma, psi, sigma):
    """
    Compute the gradient on S3 by first calculating the gradient on S2
    and pulling back the result to S3.

    """

    x = hopf(psi)
    grad_S2 = gradient_S2_slow(gamma, x, sigma)
    
    return np.einsum('ij, abj, ib -> ia', grad_S2, pauli, psi)
    def setUp(self):
        # Random initial conditions
        self.gamma = np.random.rand(self.N)        
        
        phi = np.random.rand(self.N, 2) + 1j*np.random.rand(self.N, 2)

        # Normalize phi
        norms = np.sum(phi.conj()*phi, axis=1)**.5
        phi = row_product(1./norms, phi)

        # Perturb away from the unit sphere somewhat
        phi *= 1.01

        self.phi = phi

        # Compute projected point
        self.x = hopf(phi)
Example #3
0
import numpy as np

from hopf.lie_algebras.su2_geometry import hopf
from hopf.util.vectors import row_product
from hopf.util.matlab_io import save_variables


def create_random_initial_conditions(N):
    """
    Create an ensemble of `N` randomly chosen vortices and vortex strengths.

    """
    phi = np.random.rand(N, 2) + 1j*np.random.rand(N, 2)
    gamma = np.random.rand(N)
    
    # Normalize
    norms = np.sum(phi.conj()*phi, axis=1)**.5
    phi = row_product(1./norms, phi)

    return phi, gamma

if __name__ == '__main__':
    print "Creating 40 random vortices of strength 1/8..."

    phi, _ = create_random_initial_conditions(40)
    gamma = 1./8 * np.ones(40)
    sigma = 0.1
    x = hopf(phi)

    save_variables('random40.mat', {'gamma': gamma, 'X0': x, 'sigma': sigma})