Python scipy.special.kn() Examples
The following are 14
code examples of scipy.special.kn().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.special
, or try the search function
.
Example #1
Source File: touschek.py From ocelot with GNU General Public License v3.0 | 6 votes |
def F(tm, B1, B2): #print B1, B2 Fi = 2. * np.sqrt(pi * (B1**2 - B2**2)) km = np.arctan( np.sqrt(tm) ) I2 = 0.0 Nk = 5000 ks = np.linspace(km, pi/2, Nk) dk = ks[1] - ks[0] for k in ks: t = np.tan(k)**2 dI = (2*t+1)**2 * (t/tm/(1+t)-1.)/t + t - np.sqrt(t*tm*(1+t)) - (2 + 0.5/t) * np.log(t/tm/(1+t)) #print t, kn(0, B2*t), B1, B2, B2*t, dI #print -B1*t #print t, B1, ':', exp(-B1*t) dI *= np.exp(-B1*t) * kn(0,B2*t) * np.sqrt(1 + t) I2 += dI * dk return Fi * I2
Example #2
Source File: LP_fiber_modes.py From hcipy with MIT License | 6 votes |
def eigenvalue_equation(u, m, V): '''Evaluates the eigenvalue equation for a circular step-index fiber. Parameters ---------- u : scalar The normalized propagation constant. m : int The azimuthal order V : scalar The normalized frequency parameter of the fiber. Returns ------- scalar The eigenvalue equation value ''' w = np.sqrt(V**2 - u**2) return jv(m, u) / (u * jv(m + 1, u)) - kn(m, w) / (w * kn(m + 1, w))
Example #3
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def test_legacy(): # Legacy behavior: truncating arguments to integers with suppress_warnings() as sup: sup.filter(RuntimeWarning, "floating point number truncated to an integer") assert_equal(special.bdtrc(1, 2, 0.3), special.bdtrc(1.8, 2.8, 0.3)) assert_equal(special.bdtr(1, 2, 0.3), special.bdtr(1.8, 2.8, 0.3)) assert_equal(special.bdtri(1, 2, 0.3), special.bdtri(1.8, 2.8, 0.3)) assert_equal(special.expn(1, 0.3), special.expn(1.8, 0.3)) assert_equal(special.hyp2f0(1, 2, 0.3, 1), special.hyp2f0(1, 2, 0.3, 1.8)) assert_equal(special.nbdtrc(1, 2, 0.3), special.nbdtrc(1.8, 2.8, 0.3)) assert_equal(special.nbdtr(1, 2, 0.3), special.nbdtr(1.8, 2.8, 0.3)) assert_equal(special.nbdtri(1, 2, 0.3), special.nbdtri(1.8, 2.8, 0.3)) assert_equal(special.pdtrc(1, 0.3), special.pdtrc(1.8, 0.3)) assert_equal(special.pdtr(1, 0.3), special.pdtr(1.8, 0.3)) assert_equal(special.pdtri(1, 0.3), special.pdtri(1.8, 0.3)) assert_equal(special.kn(1, 0.3), special.kn(1.8, 0.3)) assert_equal(special.yn(1, 0.3), special.yn(1.8, 0.3)) assert_equal(special.smirnov(1, 0.3), special.smirnov(1.8, 0.3)) assert_equal(special.smirnovi(1, 0.3), special.smirnovi(1.8, 0.3))
Example #4
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_kn(self): cephes.kn(1,1)
Example #5
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_kn(self): kn1 = special.kn(0,.2) assert_almost_equal(kn1,1.7527038555281462,8)
Example #6
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_kn_largeorder(self): assert_allclose(special.kn(32, 1), 1.7516596664574289e+43)
Example #7
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_kv_cephes_vs_amos(self): self.check_cephes_vs_amos(special.kv, special.kn, rtol=1e-9, atol=1e-305) self.check_cephes_vs_amos(special.kv, special.kv, rtol=1e-9, atol=1e-305)
Example #8
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_sph_kn(self): kn = special.sph_kn(2,.2) kn0 = -kn[0][1] kn1 = -kn[0][0]-2.0/0.2*kn[0][1] kn2 = -kn[0][1]-3.0/0.2*kn[0][2] assert_array_almost_equal(kn[0],[6.4302962978445670140, 38.581777787067402086, 585.15696310385559829],12) assert_array_almost_equal(kn[1],[kn0,kn1,kn2],9)
Example #9
Source File: test_mpmath.py From Computable with MIT License | 5 votes |
def test_besselk_int(self): assert_mpmath_equal(sc.kn, _exception_to_nan(lambda v, z: mpmath.besselk(v, z, **HYPERKW)), [IntArg(-1000, 1000), Arg()])
Example #10
Source File: LP_fiber_modes.py From hcipy with MIT License | 5 votes |
def LP_radial(m, u, w, r): '''Evaluates the radial profile of the LP modes. Parameters ---------- m : int The azimuthal order u : scalar The normalized inner propagation constant. w : scalar The normalized outer propagation constant. r : array_like The radial coordinates on which to evaluate the bessel modes. Returns ------- array_like An array that contains the radial profile. ''' # The scaling factor for the continuity condition scaling_factor = jv(m,u) /kn(m, w) # Find the grid inside and outside the core radius mask = r < 1 # Evaluate the radial mode profile mode_field = np.zeros_like(r) mode_field[mask] = jv(m, u * r[mask]) mode_field[~mask] = scaling_factor * kn(m, w * r[~mask]) return mode_field
Example #11
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_kn(self): cephes.kn(1,1)
Example #12
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_kn(self): kn1 = special.kn(0,.2) assert_almost_equal(kn1,1.7527038555281462,8)
Example #13
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_kn_largeorder(self): assert_allclose(special.kn(32, 1), 1.7516596664574289e+43)
Example #14
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_kv_cephes_vs_amos(self): self.check_cephes_vs_amos(special.kv, special.kn, rtol=1e-9, atol=1e-305) self.check_cephes_vs_amos(special.kv, special.kv, rtol=1e-9, atol=1e-305)