コード例 #1
0
    def update(self, rho):
        """
        Calculate the probability function for the given state of an harmonic
        oscillator (as density matrix)
        """

        if isket(rho):
            rho = ket2dm(rho)

        self.data = np.zeros(len(self.xvecs[0]), dtype=complex)
        M, N = rho.shape

        for m in range(M):
            k_m = pow(self.omega / pi, 0.25) / \
                sqrt(2 ** m * factorial(m)) * \
                exp(-self.xvecs[0] ** 2 / 2.0) * \
                np.polyval(hermite(m), self.xvecs[0])

            for n in range(N):
                k_n = pow(self.omega / pi, 0.25) / \
                    sqrt(2 ** n * factorial(n)) * \
                    exp(-self.xvecs[0] ** 2 / 2.0) * \
                    np.polyval(hermite(n), self.xvecs[0])

                self.data += np.conjugate(k_n) * k_m * rho.data[m, n]
コード例 #2
0
ファイル: distributions.py プロジェクト: Marata459/qutip
    def update(self, rho):
        """
        Calculate the probability function for the given state of an harmonic
        oscillator (as density matrix)
        """

        if isket(rho):
            rho = ket2dm(rho)

        self.data = np.zeros(len(self.xvecs[0]), dtype=complex)
        M, N = rho.shape

        for m in range(M):
            k_m = pow(self.omega / pi, 0.25) / \
                sqrt(2 ** m * factorial(m)) * \
                exp(-self.xvecs[0] ** 2 / 2.0) * \
                np.polyval(hermite(m), self.xvecs[0])

            for n in range(N):
                k_n = pow(self.omega / pi, 0.25) / \
                    sqrt(2 ** n * factorial(n)) * \
                    exp(-self.xvecs[0] ** 2 / 2.0) * \
                    np.polyval(hermite(n), self.xvecs[0])

                self.data += np.conjugate(k_n) * k_m * rho.data[m, n]
コード例 #3
0
ファイル: distributions.py プロジェクト: markusbaden/qutip
    def update_rho(self, rho):
        """
        calculate probability distribution for quadrature measurement
        outcomes given a two-mode density matrix
        """

        X1, X2 = np.meshgrid(self.xvecs[0], self.xvecs[1])

        p = np.zeros((len(self.xvecs[0]), len(self.xvecs[1])), dtype=complex)
        N = rho.dims[0][0]

        M1 = np.zeros((N, N, len(self.xvecs[0]), len(self.xvecs[1])), dtype=complex)
        M2 = np.zeros((N, N, len(self.xvecs[0]), len(self.xvecs[1])), dtype=complex)

        for m in range(N):
            for n in range(N):
                M1[m,n] = exp(-1j * self.theta1 * (m - n)) / \
                    sqrt(pi * 2 ** (m + n) * factorial(n) * factorial(m)) * \
                    exp(-X1 ** 2) * np.polyval(hermite(m), X1) * np.polyval(hermite(n), X1)
                M2[m,n] = exp(-1j * self.theta2 * (m - n)) / \
                    sqrt(pi * 2 ** (m + n) * factorial(n) * factorial(m)) * \
                    exp(-X2 ** 2) * np.polyval(hermite(m), X2) * np.polyval(hermite(n), X2)

        for n1 in range(N):
            for n2 in range(N):
                i = state_number_index([N, N], [n1, n2])
                for p1 in range(N):
                    for p2 in range(N):
                        j = state_number_index([N, N], [p1, p2])
                        p += M1[n1, p1] * M2[n2, p2] * rho.data[i, j]

        self.data = p
コード例 #4
0
def HG_split_diode_coefficient_numerical(n1,n2):
    """ Compute beam coefficient between mode n1 and n2 on a split
    photo detector using numerical integration, tested up to n1,n2 = 40.
    This is primarily used by finesse_split_photodiode()"""
    A = 2.0 * np.sqrt(2.0/np.pi) * np.sqrt(1.0 / (2.0**(n1+n2) * factorial(n1) * factorial(n2)))
    f = lambda x: hermite(n1)(np.sqrt(2.0)*x) * math.exp(-2.0*x*x) * hermite(n2)(np.sqrt(2.0)*x)    
    c_n1n2= quad(f, 0.0, np.Inf, epsabs=1e-10, epsrel=1e-10, limit=200)
    return A*c_n1n2[0]
コード例 #5
0
def gen_hermite_array(n):
	pad_len = n
	# initial polynomial
	h = pad(hermite(0).coeffs,pad_len)
	for i in range(1,n):
		h_temp = pad(hermite(i).coeffs,pad_len)
		h = numpy.append(h,h_temp)

	return h
コード例 #6
0
def genHermiteMode(x, m, W, a1, b1, a2, b2):
    if a1 <= x <= b1:
        return ((1 / (np.sqrt(np.pi) * np.power(2, m - 0.5) * fact(m) * W))**
                0.5) * hermite(m)(np.sqrt(2) * (x / W)) * np.exp(-x**2 / W**2)

    elif a2 <= x <= b2:
        return ((1 / (np.sqrt(np.pi) * np.power(2, m - 0.5) * fact(m) * W))**
                0.5) * hermite(m)(np.sqrt(2) * (x / W)) * np.exp(-x**2 / W**2)
    else:
        return 0
コード例 #7
0
ファイル: two_d.py プロジェクト: JoshKarpel/ionization
    def eval_z_x(self, z, x):
        kz = self.ksi_z * z
        kx = self.ksi_x * x
        norm = np.sqrt(self.ksi_z * self.ksi_x) / np.sqrt(
            (2**(self.n_z + self.n_x)) * special.factorial(self.n_z) *
            special.factorial(self.n_x) * u.pi)
        gaussian = np.exp(-((kz**2) + (kx**2)) / 2)
        hermite = special.hermite(self.n_z)(kz) * special.hermite(self.n_x)(kx)

        return (norm * gaussian * hermite).astype(np.complex128)
コード例 #8
0
ファイル: schrodinger2.py プロジェクト: Anathapindika/MOR
def eigenstates(nx,ny,wx,wy,X,Y,m=1,hbar=1):
    betax = np.sqrt(m*wx/hbar)
    resx  = np.sqrt(betax)*np.exp(-(m*wx*X**2)/(2*hbar))*hermite(nx)(betax*X)*1.0/np.sqrt(2**nx*factorial(nx))
    
    betay = np.sqrt(m*wy/hbar)
    resy  = np.sqrt(betay)*np.exp(-(m*wy*Y**2)/(2*hbar))*hermite(ny)(betay*Y)*1.0/np.sqrt(2**ny*factorial(ny))
    
    res   = resx*resy*1/np.sqrt(np.pi)+0j
    
    normalizer = abs(res*res).sum()
    res = res/np.sqrt(normalizer)
    
    return res
コード例 #9
0
    def __init__(self, qx, qy=None, n=0, m=0):
        self._qx = copy.deepcopy(qx)
        self._2pi_qrt = math.pow(2.0/math.pi, 0.25)

        if qy is None:
            self._qy = copy.deepcopy(qx)
        else:
            self._qy = copy.deepcopy(qy)

        self._n = int(n)
        self._m = int(m)
        self._hn = hermite(self._n)
        self._hm = hermite(self._m)
        self._calc_constants()
コード例 #10
0
 def __init__(self, n, xshift=0, yshift=0):
     self.n = n
     self.xshift = xshift
     self.yshift = yshift
     self.E = n + 0.5
     self.coef = 1 / sqrt(2**n * factorial(n)) * (1 / pi)**(1 / 4)
     self.hermite = hermite(n)
コード例 #11
0
ファイル: mapmri.py プロジェクト: salma1601/dipy
def mapmri_phi_1d(n, q, mu):
    r""" One dimensional MAPMRI basis function from [1]_ Eq. 4.

    Parameters
    -------
    n : unsigned int
        order of the basis
    q : array, shape (N,)
        points in the q-space in which evaluate the basis
    mu : float
        scale factor of the basis

    References
    ----------
    .. [1] Ozarslan E. et. al, "Mean apparent propagator (MAP) MRI: A novel
    diffusion imaging method for mapping tissue microstructure",
    NeuroImage, 2013.
    """

    qn = 2 * np.pi * mu * q
    H = hermite(n)(qn)
    i = np.complex(0, 1)
    f = factorial(n)

    k = i**(-n) / np.sqrt(2**(n) * f)
    phi = k * np.exp(-qn**2 / 2) * H

    return phi
コード例 #12
0
ファイル: mapmri.py プロジェクト: salma1601/dipy
def mapmri_psi_1d(n, x, mu):
    r""" One dimensional MAPMRI propagator basis function from [1]_ Eq. 10.

    Parameters
    ----------
    n : unsigned int
        order of the basis
    x : array, shape (N,)
        points in the r-space in which evaluate the basis
    mu : float
        scale factor of the basis

    References
    ----------
    .. [1] Ozarslan E. et. al, "Mean apparent propagator (MAP) MRI: A novel
    diffusion imaging method for mapping tissue microstructure",
    NeuroImage, 2013.
    """

    H = hermite(n)(x / mu)
    f = factorial(n)
    k = 1 / (np.sqrt(2**(n + 1) * np.pi * f) * mu)
    psi = k * np.exp(-x**2 / (2 * mu**2)) * H

    return psi
コード例 #13
0
    def hermite(self, n, nx, a, b, c, amplitude, x):
        """
        ---------------------------------------------------------------------------
        constructe 1d hermite mode with hermite function.
        ref: "coherent-mode representations in optics"
        
        args: n         - 1d hermite mode index.
              nx        - sampling.
              a         - ref.equation 1.61
              b         - ref.equation 1.61
              c         - ref.equation 1.61
              amplitude - the gaussian sigma of spectral intensity.
        
        return: 1d hermite mode
        ---------------------------------------------------------------------------
        """

        from scipy import special

        ratio = self.ratio(n, nx, a, b, c, amplitude)

        # ref.equation 1.59

        hermite = ((2 * c / np.pi)**0.25 *
                   (1 / np.sqrt(2**n * special.factorial(n))) *
                   special.hermite(n)(x * np.sqrt(2 * c)) * np.exp(-c * x**2))

        return ratio, hermite
コード例 #14
0
 def get_eigenfunction(self, number=0):
     from scipy.special import hermite
     from math import factorial, sqrt, pi
     n = number
     w = self.frequency
     return lambda x: 0j + hermite(n)(sqrt(w) * x) * _np.exp(- 0.5 * w * x ** 2) * \
                      ((w / pi) ** 0.25) / sqrt(2 ** n * factorial(n))
コード例 #15
0
def sho_evec(n, params):
  m = params["C"]
  ω = 1/np.sqrt(params["C"]*params["Lo"])
  norm = 1/np.sqrt(2**n * factorial(n))*(m*ω/π/ħ)**0.25
  ψ = lambda Q: norm * np.exp(-m*ω*Φₒ**2*Q**2/4/π**2/2/ħ)*hermite(n)(Φₒ*Q/2/π) + 0j
  #* np.exp(1j*E_val*t/ħ)
  return ψ
def calculate_harmonic_oscillator_eigenfunctions(
        eigenfunction_positions,
        eigenfunction_index,
        harmonic_oscillator_width=1.0):
    """
    :param eigenfunction_positions:  x-values in a Numpy array
    :param eigenfunction_index: n
    :param harmonic_oscillator_width: a
    :return: psi_n(x) from x_minimum to x_maximum
    """
    # Assuming k = 4 / (2p) [2p = latus rectum of parabola], ω^2 = k/m (m = 1)
    force_constant = 1. / harmonic_oscillator_width
    angular_frequency = np.sqrt(force_constant)

    # A_n = (m ω / π ħ)^(1/4) (1 / sqrt(2^n n!)), m = ħ = 1
    normalization_factor = np.power(angular_frequency / np.pi, 1 / 4)
    normalization_factor /= np.sqrt(
        np.power(2., eigenfunction_index) * factorial(eigenfunction_index))
    print('A = {:.5f}'.format(normalization_factor))

    # ξ = sqrt(m ω / ħ) x, m = ħ = 1
    xi = np.sqrt(angular_frequency) * eigenfunction_positions

    # psi_n(x) = A_n H_n(xi) exp(-xi^2 / 2)
    harmonic_oscillator_eigenfunction_values = normalization_factor * hermite(
        eigenfunction_index)(xi)
    harmonic_oscillator_eigenfunction_values *= np.exp(-0.5 * xi**2)

    return harmonic_oscillator_eigenfunction_values
コード例 #17
0
 def Single_prof(self, nn, z, pos):
     """Returns the Hermite-Gaussian profile in a single x or y direction."""
     gouy = sp.sqrt(
         sp.exp(1j * (2 * nn + 1) * self.Gouy(z)) /
         (2**nn * math.factorial(nn) * self.Spot_size(z)))
     expon = sp.exp(-1j * self.k * z - 1j * self.k * pos**2 /
                    (2 * self.R_curve(z)) - pos**2 / self.Spot_size(z)**2)
     return (2 / sp.pi)**(0.25) * gouy * hermite(nn)(pos) * expon
コード例 #18
0
ファイル: example_HO.py プロジェクト: scasplte2/pyDiatomic
def phi(v, R, alpha):
    y = R * np.sqrt(alpha)
    Nv = ((alpha / np.pi)**0.25) / np.sqrt(2**v * np.math.factorial(v))
    Hv = hermite(v)
    sum = 0.0
    for i, h in enumerate(Hv.coeffs[::-1]):
        sum += h * (y**i)
    return (-1)**v * sum * Nv * np.exp(-y**2 / 2)
コード例 #19
0
ファイル: gateOps.py プロジェクト: ryuNagai/Photonqat
def _positionWaveFunc(n, q, theta, hbar = 1):
    #lim = np.sqrt(n * 2) + 3 # heuristic
    n_ = np.arange(n)[:, np.newaxis]
    H = hermite(n_, q)
    A = (np.pi * hbar) ** 0.25 / np.sqrt(2 ** n_ * fact(n))
    psi = A * H * np.exp(-q ** 2 / 2 / hbar) * np.exp(-1j * n_ * theta)
    C = np.sum(np.abs(psi) ** 2, axis=1) + 0j # sum of squeres
    psi = psi / np.sqrt(C)[:, np.newaxis] # normalized wave functions
    return psi
コード例 #20
0
ファイル: nuisance.py プロジェクト: esheldon/great3-public
def phin(n, x):
    """Routine to get shapelets basis functions at some NumPy array of position `x`."""
    # Get the H_n function from scipy.
    hn = spec.hermite(n)
    # Evaluate it at our values of x.
    hn_x = hn(x)
    # Now put in the exp factor.
    phi_n_x = hn_x * np.exp(-(x**2) / 2.)
    # Finally, normalize it.
    phi_n_x /= np.sqrt((2.**n) * np.sqrt(np.pi) * math.factorial(n))
    return phi_n_x
コード例 #21
0
ファイル: harmonics.py プロジェクト: stephenhky/pyqentangle
def harmonic_wavefcn(n):
    """ Return the normalized wavefunction of a harmonic oscillator, where $n$ denotes
    that it is an n-th excited state, or ground state for $n=0$.

    :param n: quantum number of the excited state
    :return: a normalized wavefunction
    :type n: int
    :rtype: function
    """
    const = 1/sqrt(2**n * tail_factorial(n)) * 1/sqrt(sqrt(pi))
    return lambda x: const * np.exp(-0.5*x*x) * hermite(n)(x)
コード例 #22
0
ファイル: one_d.py プロジェクト: JoshKarpel/ionization
    def __call__(self, x):
        """
        Warning: for large enough n (>= ~60) this will fail due to n! overflowing.
        """
        norm = ((self.mass * self.omega / (u.pi * u.hbar))
                **(1 / 4)) / (np.float64(2**(self.n / 2)) *
                              np.sqrt(np.float64(special.factorial(self.n))))
        exp = np.exp(-self.mass * self.omega * (x**2) / (2 * u.hbar))
        herm = special.hermite(self.n)(
            np.sqrt(self.mass * self.omega / u.hbar) * x)

        return self.amplitude * (norm * exp * herm).astype(np.complex128)
コード例 #23
0
    def _dog_function(order, x_in):
        """
        Returns
        -------
        float
            DOG function.
        """

        p_hpoly = hermite(order)[int(x_in / np.power(2, 0.5))]
        herm = p_hpoly / (np.power(2, float(order) / 2))

        return ((-1)**(order + 1)) / np.sqrt(gamma(order + 0.5)) * herm
コード例 #24
0
def harmonic_psi(x, m, om, n=0):
    s = (cnst.hbar / (m * om)) ** 0.5
    Hn = hermite(n)

    return (
        1.0
        / (2 ** n * factorial(n)) ** 0.5
        * (np.pi ** -0.25)
        * (s ** -0.5)
        * np.exp(-0.5 * (x / s) ** 2)
        * Hn(x / s)
    )
コード例 #25
0
def harmonic_oscillator_eigenfunc(x_arr, n, omega):
    """
    evaluate n-th energy eigenfunction of simple harmonic oscillator

    an atomic unit is used
    """

    hermite_n = hermite(n)
    _func = np.exp(-omega / 2.0 * np.square(x_arr)) * hermite_n(
        np.sqrt(omega) * x_arr)
    _func *= 1.0 / np.sqrt((2**n) * factorial(n)) * (omega / np.pi)**(0.25)

    return _func
コード例 #26
0
ファイル: test.py プロジェクト: annierak/var_sc_fgt
 def compute_C_beta(self, beta):
     #First, create hermite objects for the 1D components H_beta_1(), H_beta_2(), etc
     H_beta_is = [hermite(beta_i).c for beta_i in beta]
     #Then, make a list of the summands:
     #the evaluted h_beta for each source (indexed by j),
     #times the delta fraction coefficient
     summands = [(self.delta/delta_j)**(
         nd_abs(beta)/2)*evaluate_nd_hermite_function(H_beta_is,
         powers,hermite_coeff) \
          for (delta_j,powers,hermite_coeff) in \
          zip(self.delta_j_set,self.powers,self.hermite_coeffs)]
     output = (1. / (nd_factorial(beta))) * np.sum(summands)
     return output
コード例 #27
0
ファイル: stats.py プロジェクト: prashjet/dynclust
 def I(a, b, umax=5):
     # sqrt(pi)/2 * int_{-inf}^{inf} exp(-t^2) erf(at+b) dt
     # http://alumnus.caltech.edu/~amir/bivariate.pdf
     # n.b. need a<1 for convergence
     uarr = np.arange(umax + 1)
     I1 = np.pi * (0.5 - Phi(-np.sqrt(2) * b))
     H = np.array([special.hermite(2 * u + 1)(b) for u in uarr])
     # vectorize
     if hasattr(a, 'shape'):
         uarr = np.broadcast_to(uarr, a.shape[::-1] + (umax + 1, )).T
     summand = (a / 2.)**(2 * uarr + 2) / special.gamma(uarr + 2) * H
     I2 = np.sqrt(np.pi) * np.exp(-b**2.) * np.sum(summand, axis=0)
     return I1 - I2
コード例 #28
0
def diffFreqOverlap(Ln, Lm, d):
    """ Ln and Lm are lists where L[0] is the state number, L[1]
        is the frequency in wavenumbers.
        d is the change in normal coordinate (in bohr)
    """

    # If the excited state frequency (Ln[1]) is greater than the ground state
    # frequency (Lm[1]) then we must swap Ln and Lm for the program, but then
    # take the absolute value of the result.
    if (Ln[1] > Lm[1]):
        Ln, Lm = Lm, Ln

    n = Ln[0]
    m = Lm[0]
    wn_wavenumbers = Ln[1]
    wm_wavenumbers = Lm[1]

    wn = wn_wavenumbers / 8065.5 / 27.2116
    wm = wm_wavenumbers / 8065.5 / 27.2116
    f = wn / wm
    # w = wm

    # F is the (massless) force constant for the mode. But which w?
    # F = w ** 2

    #convertedQSquared = deltaQ**2/(6.02214*(10**23) * 9.1094*(10**-28))
    convertedQSquared = d**2

    # X is defined as such in Siders, Marcus 1981 Average frequency?
    X = convertedQSquared / 2
    P0 = (-1)**(m + n)  # Should data be alternating plus minus?

    P1 = sqrt(2 * sqrt(f) / (1.0 + f))
    P2 = ((2**(m + n) * factorial(m) * factorial(n))**(-0.5) * exp(-X * f /
                                                                   (1.0 + f)))
    P3 = (abs((1 - f) / (1 + f)))**((float(m) + n) / 2.0)

    l = min(m, n)
    P4 = 0
    for i in range(l + 1):
        #In Siders and Marcus's 'F_n(x)' is equal to my G(x)
        G = iHermite(n - i)
        # G = hermite(n-i)
        H = hermite(m - i)
        P4 += ((factorial(m) * factorial(n) /
                (float(factorial(i)) * float(factorial(m - i)) *
                 float(factorial(n - i)))) * (4 * sqrt(f) / abs(1 - f))**i *
               H(sqrt(abs(2 * X * f /
                          (1 - f**2)))) * G(f * sqrt(abs(2 * X / (1 - f**2)))))
    fc = P0 * P1 * P2 * P3 * P4
    return fc
コード例 #29
0
def GaussHermite(n, m, A, w0, Fin):
    """
    Fout = GaussHermite(m, n, A, w0, Fin)
    
    :ref:`Substitutes a Hermite-Gauss mode (beam waist) in the field. <GaussHermite>`

        :math:`F_{m,n}(x,y,z=0) = A H_m\\left(\\dfrac{\\sqrt{2}x}{w_0}\\right)H_n\\left(\\dfrac{\\sqrt{2}y}{w_0}\\right)e^{-\\frac{x^2+y^2}{w_0^2}}`

    Args::
        
        m, n: mode indices
        A: Amplitude
        w0: Guaussian spot size parameter in the beam waist (1/e amplitude point)
        Fin: input field
        
    Returns::
    
        Fout: output field (N x N square array of complex numbers).            
        
    Reference::
    
        A. Siegman, "Lasers", p. 642

    """

    Fout = Field.copy(Fin)

    Y, X = Fout.mgrid_cartesian
    #Y = Y - y_shift
    #X = X - x_shift

    sqrt2w0 = _np.sqrt(2.0) / w0
    w02 = w0 * w0

    Fout.field = A * hermite(m)(sqrt2w0 * X) * hermite(n)(
        sqrt2w0 * Y) * _np.exp(-(X * X + Y * Y) / w02)
    return Fout
コード例 #30
0
    def update_rho(self, rho):
        """
        calculate probability distribution for quadrature measurement
        outcomes given a two-mode density matrix
        """

        X1, X2 = np.meshgrid(self.xvecs[0], self.xvecs[1])

        p = np.zeros((len(self.xvecs[0]), len(self.xvecs[1])), dtype=complex)
        N = rho.dims[0][0]

        M1 = np.zeros((N, N, len(self.xvecs[0]), len(self.xvecs[1])),
                      dtype=complex)
        M2 = np.zeros((N, N, len(self.xvecs[0]), len(self.xvecs[1])),
                      dtype=complex)

        for m in range(N):
            for n in range(N):
                M1[m, n] = exp(-1j * self.theta1 * (m - n)) / \
                    sqrt(pi * 2 ** (m + n) * factorial(n) * factorial(m)) * \
                    exp(-X1 ** 2) * np.polyval(
                        hermite(m), X1) * np.polyval(hermite(n), X1)
                M2[m, n] = exp(-1j * self.theta2 * (m - n)) / \
                    sqrt(pi * 2 ** (m + n) * factorial(n) * factorial(m)) * \
                    exp(-X2 ** 2) * np.polyval(
                        hermite(m), X2) * np.polyval(hermite(n), X2)

        for n1 in range(N):
            for n2 in range(N):
                i = state_number_index([N, N], [n1, n2])
                for p1 in range(N):
                    for p2 in range(N):
                        j = state_number_index([N, N], [p1, p2])
                        p += M1[n1, p1] * M2[n2, p2] * rho.data[i, j]

        self.data = p
コード例 #31
0
    def update_psi(self, psi):
        """
        calculate probability distribution for quadrature measurement
        outcomes given a two-mode wavefunction
        """

        X1, X2 = np.meshgrid(self.xvecs[0], self.xvecs[1])

        p = np.zeros((len(self.xvecs[0]), len(self.xvecs[1])), dtype=complex)
        N = psi.dims[0][0]

        for n1 in range(N):
            kn1 = exp(-1j * self.theta1 * n1) / \
                sqrt(sqrt(pi) * 2 ** n1 * factorial(n1)) * \
                exp(-X1 ** 2 / 2.0) * np.polyval(hermite(n1), X1)

            for n2 in range(N):
                kn2 = exp(-1j * self.theta2 * n2) / \
                    sqrt(sqrt(pi) * 2 ** n2 * factorial(n2)) * \
                    exp(-X2 ** 2 / 2.0) * np.polyval(hermite(n2), X2)
                i = state_number_index([N, N], [n1, n2])
                p += kn1 * kn2 * psi.data[i, 0]

        self.data = abs(p)**2
コード例 #32
0
 def _hermite_mode(self, x: float):
     """ A normalised Hermite-Gaussian function """
     # On 22.11.2017, Matteo changed all the self.pump_width to self.__correct_pump_width
     # _result = hermite(self.pump_temporal_mode)((self.pump_center - x) /
     #                                            self.pump_width) *    \
     #     exp(-(self.pump_center - x)**2 / (2 * self.pump_width**2)) /\
     #     sqrt(factorial(self.pump_temporal_mode) * sqrt(pi) *
     #          2**self.pump_temporal_mode * self.pump_width)
     # TODO: Check the correctness of the __correct_pump_width parameter
     _result = hermite(self.pump_temporal_mode)((self.pump_centre - x) /
                                                self.__correct_pump_width) * \
               np.exp(-(self.pump_centre - x) ** 2 / (2 * self.__correct_pump_width ** 2)) / \
               np.sqrt(factorial(self.pump_temporal_mode) * np.sqrt(np.pi) *
                       2 ** self.pump_temporal_mode * self.__correct_pump_width)
     return _result
コード例 #33
0
    def phi(self, n, x):
        c_h_n = special.hermite(n)
        c = self.c()

        #res = np.sqrt(2.0*c)**0.5 * (1/np.pi)**0.25 * (1.0/np.sqrt(2**n * misc.factorial(n) ))
        #res =  (1.0/np.sqrt(np.sqrt(np.pi) * 2**n * misc.factorial(n) ))**0.5
        #h_n = np.polyval(c_h_n, x * np.sqrt(2*c))
        h_n = np.polyval(c_h_n, x * np.sqrt(2*c) )

#        h_n *= 2 ** -(n/2.0)

        res = ((2*c/np.pi) ** 0.25) * np.exp(-c * x**2)
        res *= h_n * (1.0/np.sqrt(2**n * misc.factorial(n) ))

        return res