MCPcopy Create free account
hub / github.com/SINGROUP/dscribe / integral

Function integral

tests/testutils.py:291–373  ·  view source on GitHub ↗
(args, n, l, m, elem_pos, rbf_function)

Source from the content-addressed store, hash-verified

289
290
291def integral(args, n, l, m, elem_pos, rbf_function):
292 r_cut = args["r_cut"]
293 sigma = args["sigma"]
294 weighting = args.get("weighting")
295
296 # Integration limits for radius
297 r1 = 0.0
298 r2 = r_cut + 5
299
300 # Integration limits for theta
301 t1 = 0
302 t2 = np.pi
303
304 # Integration limits for phi
305 p1 = 0
306 p2 = 2 * np.pi
307
308 def soap_coeff(phi, theta, r):
309 # Regular spherical harmonic, notice the abs(m)
310 # needed for constructing the real form
311 ylm_comp = scipy.special.sph_harm(
312 np.abs(m), l, phi, theta
313 ) # NOTE: scipy swaps phi and theta
314
315 # Construct real (tesseral) spherical harmonics for
316 # easier integration without having to worry about
317 # the imaginary part. The real spherical harmonics
318 # span the same space, but are just computationally
319 # easier.
320 ylm_real = np.real(ylm_comp)
321 ylm_imag = np.imag(ylm_comp)
322 if m < 0:
323 ylm = np.sqrt(2) * (-1) ** m * ylm_imag
324 elif m == 0:
325 ylm = ylm_comp
326 else:
327 ylm = np.sqrt(2) * (-1) ** m * ylm_real
328
329 # Atomic density
330 rho = 0
331 ix = elem_pos[:, 0]
332 iy = elem_pos[:, 1]
333 iz = elem_pos[:, 2]
334 ri_squared = ix**2 + iy**2 + iz**2
335 rho = np.exp(
336 -1
337 / (2 * sigma**2)
338 * (
339 r**2
340 + ri_squared
341 - 2
342 * r
343 * (
344 np.sin(theta) * np.cos(phi) * ix
345 + np.sin(theta) * np.sin(phi) * iy
346 + np.cos(theta) * iz
347 )
348 )

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected