当前位置: 首页>>代码示例>>Python>>正文


Python numpy.cosh函数代码示例

本文整理汇总了Python中numpy.cosh函数的典型用法代码示例。如果您正苦于以下问题:Python cosh函数的具体用法?Python cosh怎么用?Python cosh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cosh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _fenton1985_dispersion_step

def _fenton1985_dispersion_step(w,k,H,d):
    """ Solve eqn 23 in Fenton1985, assuming no mean current (i.e., c_E = 0) using Newton's method.
    NOTE: This approach was found to be numerically unstable unless a relaxation factor was applied at each iteration; however this required > 100 iterations for convergence in the cases tested. 
    """
    kd = k*d
    S = 1./np.cosh(2*kd)
    C0 = np.tanh(kd)**0.5
    dC0 = d/(2*C0*np.cosh(kd)**2)
    C2expr = (2.+7.*S**2)/(4.*(1.-S)**2)
    C2 = C0 * C2expr
    t2kd = np.tanh(2*kd)
    dC2 = \
            dC0 * C2expr \
            + C0 *( -7.*d*t2kd*S**2/(1.-S)**2 - d*t2kd*(7*S**2+2.)*S/(1.-S)**3 )
    C4expr = (4. + 32.*S - 116.*S**2 - 400.*S**3 - 71.*S**4 + 146.*S**5) / (32*(1.-S)**5)
    C4 = C0 * C4expr
    dC4 = \
            dC0 * C4expr \
            + C0 * ( -1460*d*t2kd*S**5 + 568*d*t2kd*S**4 \
                + 2400*d*t2kd*S**3 + 464*d*t2kd*S**2 - 64*d*t2kd*S ) / (32*(1.-S)**5) \
            - C0 * ( 5*d*t2kd*S*(146*S**5-71*S**4-400*S**3-116*S**2+32*S+4) ) \
                    / (16*(1.-S)**6)
    kH_2 = k*H/2.
    F = -w/(g*k)**0.5 + C0 + kH_2**2*C2 + kH_2**4*C4
    J = dC0 + H*kH_2*C2 + kH_2**2*dC2 + 2*H*kH_2**3*C4 + kH_2**4*dC4

    if DEBUG:
        print ' C0:',C0
        print ' C2:',C2
        print ' C4:',C4
        print 'dC0:',dC0
        print 'dC2:',dC2
        print 'dC4:',dC4
    return F,J
开发者ID:ewquon,项目名称:pylib,代码行数:34,代码来源:waves.py

示例2: chainPoints

def chainPoints(hh, dd, aa, numberOfPoints) :
    """Generate numberOfPoints points (x,y) along a hanging chain from -dd 
    to dd, given parameter aa. Return lists of x values and y values, each of 
    length numberOfPoints."""
    xs = np.linspace(-dd,dd,numberOfPoints) # [m] x location of points
    ys = aa * np.cosh(xs/aa) + (hh - aa * np.cosh(dd / aa)) # [m] y locations
    return xs, ys
开发者ID:jmding0714,项目名称:uiowapythonproj,代码行数:7,代码来源:Instructors2016A_A5Q1V1.py

示例3: test_abcd_lossy_line

    def test_abcd_lossy_line(self):
        '''
        Lossy transmission line of characteristic impedance Z0, length l
        and propagation constant gamma = alpha + j beta

        ○---------○

        ○---------○

        has ABCD matrix of the form:

        [ cosh(gamma l)       Z0 sinh(gamma l) ]
        [ 1/Z0 sinh(gamma l)  cosh(gamma l) ]
        '''
        l = 5.0
        z0 = 30.0
        alpha = 0.5
        beta = 2.0
        lossy_media = DefinedGammaZ0(
            frequency=Frequency(1, 100, 21, 'GHz'),
            gamma=alpha + 1j*beta,
            z0=z0
            )
        ntw = lossy_media.line(d=l, unit='m', z0=z0)
        gamma = lossy_media.gamma
        npy.testing.assert_array_almost_equal(ntw.a[:,0,0], npy.cosh(gamma*l))
        npy.testing.assert_array_almost_equal(ntw.a[:,0,1], z0*npy.sinh(gamma*l))
        npy.testing.assert_array_almost_equal(ntw.a[:,1,0], 1.0/z0*npy.sinh(gamma*l))
        npy.testing.assert_array_almost_equal(ntw.a[:,1,1], npy.cosh(gamma*l))
开发者ID:scikit-rf,项目名称:scikit-rf,代码行数:29,代码来源:test_media.py

示例4: velocity_u

    def velocity_u(self,x,t):
        """ Defines a linearized solution to the potential flow
            model in two dimensions (x,y,z) for finite depth,
            as well as, deep and shllow water limits, for slowly
            varying regular wavetrains.

            .. todo:: implement deep & shallow water limits. """
        theta =  self.k[0]*x[0] - self.omega*t # ~ NOTE: x[0] is a vector here!
        dtheta = self.diff*theta
        z = x[2] - self.h
        u = np.zeros(x[0].shape)

        # Finite Depth (0 < kh < infty)
        for i in range(self.N):
            diffPos = (1+self.diff*(i+1))
            diffNeg = (1-self.diff*(i+1))
            u = u + (-self.g[2]*diffPos*self.k[0]*self.A / (diffPos*self.omega)) * \
                np.cosh(diffPos*self.k[0]*(z+self.h))/np.cosh(diffPos*self.k[0]*self.h) * \
                np.exp(1j*(i+1)*(theta+(i+1)*dtheta)) + \
                (-self.g[2]*diffNeg*self.k[0]*self.A / (diffNeg*self.omega)) * \
                np.cosh(diffNeg*self.k[0]*(z+self.h))/np.cosh(diffNeg*self.k[0]*self.h) * \
                np.exp(1j*(i+1)*(theta-(i+1)*dtheta))
        # Deep water (kh >> 1)
        # ... TODO
                 
        # Shallow water (kh << 1)
        # ... TODO

        return np.real(u)
开发者ID:erdc-cm,项目名称:proteus-mprans,代码行数:29,代码来源:waveModules_Matt.py

示例5: Kw_gelenk_kik

def Kw_gelenk_kik(E, A, I, l, u, w):
    """dyn. Steifigkeit Gelenk an k

    :E: @todo
    :A: @todo
    :I: @todo
    :l: @todo
    :u: @todo
    :w: @todo
    :returns: @todo

    """
    lam = l * (u * w**2 / E / I) ** (1/4)
    eps = l * np.sqrt(u * w**2 / E / A)

    o1 = (np.cosh(lam) + np.cos(lam)) / 2
    o2 = (np.sinh(lam) + np.sin(lam)) / 2
    o3 = (np.cosh(lam) - np.cos(lam)) / 2
    o4 = (np.sinh(lam) - np.sin(lam)) / 2

    kik = np.matrix([[E*A/l * eps/np.tan(eps), 0, 0],
                     [0, E*I*lam**3/l**3 * (o1**2 - o2*o4)/(o2*o3 - o1*o4), 0],
                     [0, 0, 0]])

    return kik
开发者ID:p-friedrich,项目名称:myNotebooks,代码行数:25,代码来源:statik.py

示例6: pressure

 def pressure(self,x,t):
     """ Gives linearized pressured with P_atm = 0 """
     g = (0.0,0.0,-9.81)
     z = x[2] - self.h
     p = self.rho_0*g[2]*self.A* np.cosh(self.k[0]*(z+self.h))/np.cosh(self.k[0]*self.h) \
         * np.exp(1j*self.theta(x,t))
     return np.real(p)
开发者ID:erdc-cm,项目名称:waveSolutions,代码行数:7,代码来源:defaultWaveModules.py

示例7: grad

def grad(data, QofI='U_avg'):
    M = data.shape[0]

    mu = data[:, 0].reshape((M, 1))
    rho = data[:, 1].reshape((M, 1))
    dpdx = data[:, 2].reshape((M, 1))
    eta = data[:, 3].reshape((M, 1))
    B0 = data[:, 4].reshape((M, 1))

    Ha = B0 / np.sqrt(eta * mu)
    mu0 = 1.0

    if (QofI == 'U_avg'):
        df_dmu = -dpdx * (np.sqrt(eta * mu) / np.tanh(Ha) -
                          B0 / np.sinh(Ha)**2) / (2 * B0 * mu**2)
        df_drho = np.random.uniform(1.0e-8, 1.0e-10, (M, 1))
        df_ddpdx = -(eta * mu - Ha * eta * mu / np.tanh(Ha)) / (mu * B0**2)
        df_deta = -dpdx * (2 * eta * mu - Ha * eta * mu / np.tanh(Ha) -
                           (B0 / np.sinh(Ha))**2) / (2 * eta * mu * B0**2)
        df_dB0 = -dpdx * (-2 * eta * mu + Ha * eta * mu / np.tanh(Ha) +
                          (B0 / np.sinh(Ha))**2) / (mu * B0**3)
    elif (QofI == 'B_ind'):
        df_dmu = -dpdx * mu0 * (np.sqrt(eta * mu) * np.sinh(Ha) - B0) / (
            4 * mu * (B0 * np.cosh(Ha / 2))**2)
        df_drho = np.random.uniform(1.0e-8, 1.0e-10, (M, 1))
        df_ddpdx = mu0 * (B0 - 2 * np.sqrt(eta * mu) * np.tanh(Ha / 2)) / (
            2 * B0**2)
        df_deta = -dpdx * mu0 * (np.sqrt(eta * mu) * np.sinh(Ha) - B0) / (
            4 * eta * (B0 * np.cosh(Ha / 2))**2)
        df_dB0 = -dpdx * mu0 * (B0 + B0 / np.cosh(Ha / 2)**2 - 4 * np.sqrt(
            eta * mu) * np.tanh(Ha / 2)) / (2 * B0**3)

    return np.concatenate((df_dmu, df_drho, df_ddpdx, df_deta, df_dB0), axis=1)
开发者ID:PaulMDiaz,项目名称:active_subspaces,代码行数:33,代码来源:utils_analytic.py

示例8: init

def init(U, U_hat, X, FST, ST, SN, t=0.):
    Ha = config.Ha
    B_strength = config.B_strength
    for i in range(U.shape[1]):
        x = X[0, i, 0, 0]
        for j in range(U.shape[2]):
            y = X[1, i, j, 0]
            u = 0. 
            v = (cosh(Ha)-cosh(Ha*x))/(cosh(Ha)-1.0)
            Bx = (sinh(Ha*x)-Ha*x*cosh(Ha))/(Ha**2*cosh(Ha))
            By = B_strength
            U[0, i, j, :] = u
            U[1, i, j, :] = v
            U[3, i, j, :] = Bx
            U[4, i, j, :] = By
    U[2] = 0
    U[5] = 0
    for i in range(6):
        if i<3:
            U_hat[i] = FST.fst(U[i], U_hat[i], ST)
        else:
            U_hat[i] = FST.fst(U[i], U_hat[i], SN)
        
    for i in range(6):
        if i<3:
            U[i] = FST.ifst(U_hat[i], U[i], ST)
        else:
            U[i] = FST.ifst(U_hat[i], U[i], SN)
            
    for i in range(6):
        if i<3:
            U_hat[i] = FST.fst(U[i], U_hat[i], ST)
        else:
            U_hat[i] = FST.fst(U[i], U_hat[i], SN)
开发者ID:glwagner,项目名称:spectralDNS,代码行数:34,代码来源:Hartmann.py

示例9: update

def update(rank, X, U, P, N, comm, L, **kw):
    
    Ha = config.Ha
    if config.tstep % config.compute_energy == 0: 
        u_exact = ( cosh(Ha) - cosh(Ha*X[0,:,0,0]))/(cosh(Ha) - 1.0)
        if rank == 0:
            print "Time %2.5f Error %2.12e" %(config.t, linalg.norm(u_exact-U[1,:,0,0],inf))
开发者ID:glwagner,项目名称:spectralDNS,代码行数:7,代码来源:Hartmann.py

示例10: reflection_theory

    def reflection_theory(self, f):
        """
        Return the theoretical reflection of the taper.
        As a theoreticalk result this reflection doesn't take into account the
        impedance of the LJPA.

        Parameters
        ----------
        f : float, np.ndarray
            Frequency in GHz.
        """

        v = (self.beta(f)*self.l)**2. - self.A()**2.

        if type(f) is float:
            if v < 0:
                c = np.cosh(np.sqrt(self.A()**2. - (self.beta(f)*self.l)**2.))
            else:
                c = np.cos(np.sqrt((self.beta(f)*self.l)**2. - self.A()**2.))
        else:
            c = np.ones_like(v)
            c[v<0] = np.cosh(np.sqrt(self.A()**2. - (self.beta(f[v<0])*self.l)**2.))
            c[v>0] = np.cos(np.sqrt((self.beta(f[v>0])*self.l)**2. - self.A()**2.))

        return self.gm*np.exp(-1j*self.beta(f)*self.l)*c
开发者ID:edumur,项目名称:paramp,代码行数:25,代码来源:KLJPA.py

示例11: intxfxcoshcurve

def intxfxcoshcurve(x, m):
    # measured in x direction (towards point end of curve) from zero
    # equation for the integral of xf(x)
    intxfx = ( 1/( np.cosh( m*np.pi )-1))*((( np.cosh( m*np.pi )-( m*np.pi )*np.sinh( m*np.pi ))/(( m*np.pi )**2))+(( 1/2 )*np.cosh( m*np.pi ))-( 1/(( m*np.pi )**2 )))
    # multiply calculated intxfx by actual dimension in x direction
    intxfx = x*intxfx
    return intxfx
开发者ID:BenHowett,项目名称:sim,代码行数:7,代码来源:hullgeneratorOLD.py

示例12: get_ind_potential

def get_ind_potential(mesh,num,amp,omeg,depth,wk): 
    '''
       for cylinder in indefinite water ???
    '''
    import numpy as np
    from dutwav.analytical import bj
    from scipy.special import jv
    mesh.nodes[1]
    g=9.801
    res={}
    for i in range(num):
        x=mesh.nodes[i+1][0]
        y=mesh.nodes[i+1][1]
        z=mesh.nodes[i+1][2]
        theta = np.arctan2(y,x)
        r=np.sqrt(x**2+y**2)
        tmp=0.
        for m in range(10):
            eps=2.
            if m==0:
                eps=1.
            tp=-1j*g*amp/omeg
            tp=tp*np.cosh(wk*(z+depth))/np.cosh(wk*depth)
            tp=tp*eps*(1j)**m*bj(wk*r,m)*np.cos(m*theta)
            # tp=tp*eps*(1j)**m*jv(m,wk*r)*np.cos(m*theta)
            tmp+=tp
        res[i+1]=tmp
    return res
开发者ID:gaofrank1986,项目名称:dutwav,代码行数:28,代码来源:util.py

示例13: process

    def process(self, specificLoudness):

        # convolution with weighting function
        self.smoothSpecificLoudness = np.zeros(specificLoudness.shape)
        nFilters = specificLoudness.shape[0]
        for ear in range(2):
            self.smoothSpecificLoudness[:, ear] = \
                np.convolve(
                    self.fullGaussian, specificLoudness[:, ear]
                )[nFilters-1:-nFilters+1]

        # Gain computation
        self.smoothSpecificLoudness[self.smoothSpecificLoudness < 1e-12] = \
            1e-12
        inhibLeft = \
            2.0 / (1 + (1.0 / np.cosh(
                self.smoothSpecificLoudness[:, 1] /
                self.smoothSpecificLoudness[:, 0]
            )) ** 1.5978)
        inhibRight = 2.0 / (1 + (1.0 / np.cosh(
            self.smoothSpecificLoudness[:, 0] /
            self.smoothSpecificLoudness[:, 1]
        )) ** 1.5978)

        # Apply gains to original specific loudness
        self.inhibitedSpecificLoudness = specificLoudness.copy()
        self.inhibitedSpecificLoudness[:, 0] /= inhibLeft
        self.inhibitedSpecificLoudness[:, 1] /= inhibRight
开发者ID:deeuu,项目名称:loudness,代码行数:28,代码来源:test_BinauralInhibitionMG2007.py

示例14: N2sol

def N2sol(t,z,b2,gamma, t0):
    """
    complete field for the N=2 soliton
    """
    p01 = np.abs(b2) / gamma / t0**2
    ld = t0**2 / np.abs(b2)  
    return np.sqrt(p01) * 4 * (np.cosh(3*t/t0) + 3 * np.exp(1.0j * 4 * z/ld ) * np.cosh(t/t0)) / (np.cosh(4*t/t0)+4*np.cosh(2*t/t0)+ 3*np.cos(4*z/ld)) * np.exp( 1.0j * z/ld /2.)  
开发者ID:xmhk,项目名称:optictools,代码行数:7,代码来源:optictools.py

示例15: fgrad_y_psi

    def fgrad_y_psi(self, y, psi, return_covar_chain = False):
        """
        gradient of f w.r.t to y and psi

        returns: NxIx4 tensor of partial derivatives

        """

        mpsi = psi.copy()
        mpsi = mpsi[:self.num_parameters-1].reshape(self.n_terms, 3)

        w, s, r, d = self.fgrad_y(y, psi, return_precalc = True)

        gradients = np.zeros((y.shape[0], y.shape[1], len(mpsi), 4))
        for i in range(len(mpsi)):
            a,b,c  = mpsi[i]
            gradients[:,:,i,0] = (b*(1.0/np.cosh(s[i]))**2).T
            gradients[:,:,i,1] = a*(d[i] - 2.0*s[i]*r[i]*(1.0/np.cosh(s[i]))**2).T
            gradients[:,:,i,2] = (-2.0*a*(b**2)*r[i]*((1.0/np.cosh(s[i]))**2)).T
        gradients[:,:,0,3] = 1.0

        if return_covar_chain:
            covar_grad_chain = np.zeros((y.shape[0], y.shape[1], len(mpsi), 4))

            for i in range(len(mpsi)):
                a,b,c = mpsi[i]
                covar_grad_chain[:, :, i, 0] = (r[i]).T
                covar_grad_chain[:, :, i, 1] = (a*(y + c) * ((1.0/np.cosh(s[i]))**2).T)
                covar_grad_chain[:, :, i, 2] = a*b*((1.0/np.cosh(s[i]))**2).T
            covar_grad_chain[:, :, 0, 3] = y

            return gradients, covar_grad_chain

        return gradients
开发者ID:dasabir,项目名称:GPy,代码行数:34,代码来源:warping_functions.py


注:本文中的numpy.cosh函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。