# -*- coding: utf-8 -*-
"""
Created on Mon Aug 18 11:31:46 2014

@author: Jens von der Linden

Collection of init functions to set initial xi and xi prime for newcomb
integrations.
"""

import numpy as np


def init_geometric_sing(r, k, m, b_z, b_z_prime, b_theta, b_theta_prime,
                        p_prime, q, q_prime, g_func):
    r"""
    Return xi found from Frobenius method at a geometric singularity (i.e. r=0)
    """
    y = np.zeros(2)

    g_params = {'r': r, 'k': k, 'm': m, 'b_z': b_z, 'b_z_prime': b_z_prime,
                'b_theta': b_theta, 'b_theta_prime': b_theta_prime,
                'p_prime': p_prime, 'q': q, 'q_prime': q_prime}

    if m == 0:
        y[0] = r
    else:
        y[0] = r**(abs(m) - 1)

    y[1] = g_func(**g_params)*y[0]

    return y


def init_f_sing():
    r"""
    Return xi found from Frobenius method at an f=0 singularity.
    """
    pass


def init_xi_zero(*args):
    r"""
    Return zero xi and xi_prime.
    """
    y = np.zeros(2)

    y[0] = 0.
    y[1] = 0.

    return y

@@ -1017,20 +1017,867 @@
  = 0.%0A%0A    return y%0A
+%0Adef init_r_sing_glasser(r, k, m, b_z, b_theta, *args):%0A    r%22%22%22%0A    Returns initial condition for r close to zero.%0A%0A    Parameters%0A    ----------%0A    r : float%0A        radial position%0A%0A    k : float%0A        axial periodicity number%0A%0A    m : float%0A        azimuthal periodicity number%0A%0A    b_z : scipy spline%0A        axial magnetic field%0A%0A    b_theta : scipy spline%0A        azimuthal magnetic field%0A%0A    Returns%0A    -------%0A    xi : ndarray%0A         newcomb's xi%0A%0A    Notes%0A    -----%0A    Implements initial condition Alan used in his code.%0A%0A    .. math ::%0A        u(0) &= r%5E%7Bm - 1%7D %5C%5C%0A        u(1) &= u(0) %5Cfrac%7B(k B_%7Bz%7D r + m B_%7B%5Ctheta%7D)%5E%7B2%7D%7D%7Bm%5E%7B2%7D%7D (m-1)%0A%0A    Reference%0A    ---------%0A    Alan Glasser's newcomb.f code.%0A    %22%22%22%0A    xi = np.zeros(2)%0A    xi%5B0%5D = r**(m - 1)%0A    xi%5B1%5D = xi%5B0%5D*((k*b_z(r)*r + m*b_theta(r))/m)**2*(m - 1)%0A    return xi

Add glasser init method for geometric singularity