本文整理汇总了Python中scipy.special.jnp_zeros方法的典型用法代码示例。如果您正苦于以下问题:Python special.jnp_zeros方法的具体用法?Python special.jnp_zeros怎么用?Python special.jnp_zeros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.special
的用法示例。
在下文中一共展示了special.jnp_zeros方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def __init__(
self,
diameter=None,
diffusion_constant=CONSTANTS['water_in_axons_diffusion_constant'],
number_of_roots=20,
number_of_functions=50,
):
self.diameter = diameter
self.Dintra = diffusion_constant
self.alpha = np.empty((number_of_roots, number_of_functions))
self.alpha[0, 0] = 0
if number_of_roots > 1:
self.alpha[1:, 0] = special.jnp_zeros(0, number_of_roots - 1)
for m in range(1, number_of_functions):
self.alpha[:, m] = special.jnp_zeros(m, number_of_roots)
示例2: __init__
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def __init__(
self,
mu=None, lambda_par=None,
diameter=None,
diffusion_perpendicular=CONSTANTS['water_in_axons_diffusion_constant'],
number_of_roots=20,
number_of_functions=50,
):
self.mu = mu
self.lambda_par = lambda_par
self.diffusion_perpendicular = diffusion_perpendicular
self.diameter = diameter
self.alpha = np.empty((number_of_roots, number_of_functions))
self.alpha[0, 0] = 0
if number_of_roots > 1:
self.alpha[1:, 0] = special.jnp_zeros(0, number_of_roots - 1)
for m in range(1, number_of_functions):
self.alpha[:, m] = special.jnp_zeros(m, number_of_roots)
示例3: _ncrs_python
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def _ncrs_python(self, Delta, delta, d, R, G):
if R == 0 or R < np.finfo(float).eps:
return 0
GAMMA = 267.5987E6
alpha_roots = jnp_zeros(1, 16) / R
sum = 0
for i in range(alpha_roots.shape[0]):
alpha = alpha_roots[i]
num = (2 * d * alpha**2 * delta
- 2
+ 2 * np.exp(-d * alpha**2 * delta)
+ 2 * np.exp(-d * alpha**2 * Delta)
- np.exp(-d * alpha**2 * (Delta - delta))
- np.exp(-d * alpha**2 * (Delta + delta)))
dem = d**2 * alpha**6 * (R**2 * alpha**2 - 1)
sum += (num / dem)
return -2 * GAMMA**2 * G**2 * sum
示例4: test_jnp_zeros
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def test_jnp_zeros(self):
jnp = special.jnp_zeros(1,5)
assert_array_almost_equal(jnp, array([1.84118,
5.33144,
8.53632,
11.70600,
14.86359]),4)
jnp = special.jnp_zeros(443,5)
assert_tol_equal(special.jvp(443, jnp), 0, atol=1e-15)
示例5: disk_harmonic_energy
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def disk_harmonic_energy(n, m, bc='dirichlet'):
'''Get the energy of a disk harmonic function.
This allows for functions to sort a disk harmonic mode basis on energy.
Parameters
----------
n : int
Radial order
m : int
Azimuthal order
bc : string
The boundary conditions to use. This can be either 'dirichlet', or
'neumann' for a Dirichlet or Neumann boundary condition respectively.
Returns
-------
scalar
The energy corresponding to the mode.
Raises
------
ValueError
If the boundary condition is not recognized.
'''
m = abs(m)
if bc == 'dirichlet':
lambda_mn = jn_zeros(m, n)[-1]
elif bc == 'neumann':
lambda_mn = jnp_zeros(m, n)[-1]
else:
raise ValueError('Boundary condition not recognized.')
return lambda_mn**2
示例6: test_jnp_zeros
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def test_jnp_zeros(self):
jnp = special.jnp_zeros(1,5)
assert_array_almost_equal(jnp, array([1.84118,
5.33144,
8.53632,
11.70600,
14.86359]),4)
jnp = special.jnp_zeros(443,5)
assert_allclose(special.jvp(443, jnp), 0, atol=1e-15)
示例7: disk_harmonic
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import jnp_zeros [as 别名]
def disk_harmonic(n, m, D=1, bc='dirichlet', grid=None):
'''Create a disk harmonic.
Parameters
----------
n : int
Radial order
m : int
Azimuthal order
D : scalar
The diameter of the pupil.
bc : string
The boundary conditions to use. This can be either 'dirichlet', or
'neumann' for a Dirichlet or Neumann boundary condition respectively.
grid : Grid
The grid on which to evaluate the function.
Returns
-------
Field
The disk harmonic function evaluated on `grid`.
Raises
------
ValueError
If the boundary condition is not recognized.
'''
polar_grid = grid.as_('polar')
r = 2 * polar_grid.r / D
theta = polar_grid.theta
m_negative = m < 0
m = abs(m)
if bc == 'dirichlet':
lambda_mn = jn_zeros(m, n)[-1]
norm = 1
elif bc == 'neumann':
lambda_mn = jnp_zeros(m, n)[-1]
norm = 1
else:
raise ValueError('Boundary condition not recognized.')
if m_negative:
z = norm * jv(m, lambda_mn * r) * np.sin(m * theta)
else:
z = norm * jv(m, lambda_mn * r) * np.cos(m * theta)
# Do manual normalization for now...
mask = circular_aperture(D)(grid) > 0.5
norm = np.sqrt(np.sum(z[mask]**2))
return Field(z * mask / norm, grid)