MRChemSoft/vampyr

Deadlock on projection of analytic functions

Closed this issue · 5 comments

The package deadlocks when analytic functions are projected when the library is build using omp

This is annoying and needs to be solved. Might be something with the global interpreter lock (GIL)

@bjorgve do you still have the example demonstrating the failure? I cannot access it anymore from the Slack chat...

import numpy as np
import vampyr as vp


min_scale = -4
max_depth = 25
order = 5
prec = 1e-3
beta = 100.0
mu = 10.0
corner = [-1, -1, -1]
boxes = [2, 2, 2]
world = vp.vampyr3d.BoundingBox(min_scale, corner, boxes)
basis = vp.InterpolatingBasis(order)
MRA = vp.vampyr3d.MultiResolutionAnalysis(world, basis, max_depth)
mid = 0.0

#gauss = vp.vampyr3d.GaussFunc(100, 1.0)

def gauss(x):
    return np.exp(100*(x[0]**2 + x[1]**2 + x[2]**2))


g_tree = vp.vampyr3d.FunctionTree(MRA)
vp.project(prec, g_tree, gauss)

Still deadlocking 😞 and I also get this warning: deadlock.py:26: RuntimeWarning: overflow encountered in exp return np.exp(beta * (x[0]**2 + x[1]**2 + x[2]**2))

import numpy as np

import vampyr as vp


# define bounding box
min_scale = -4
corner = [-1, -1, -1]
boxes = [2, 2, 2]
world = vp.vampyr3d.BoundingBox(min_scale, corner, boxes)

# define polynpomial basis
order=5
basis = vp.InterpolatingBasis(order)

# initialize multiresolution analysis
max_depth = 25
MRA = vp.vampyr3d.MultiResolutionAnalysis(world, basis, max_depth)

# gaussian exponent
beta = 100.0
# precision
prec = 1.0e-3

def gauss_2(*, beta, x):
    return np.exp(-beta * (x[0]**2 + x[1]**2 + x[2]**2))


gauss_1 = vp.vampyr3d.GaussFunc(beta, 1.0)
tree_1 = vp.vampyr3d.FunctionTree(MRA)
vp.project(prec, tree_1, gauss_1)
print(f"Gaussian defined with MRCPP primitive:\n{tree_1}")

tree_2 = vp.vampyr3d.FunctionTree(MRA)
vp.project(prec, tree_2, lambda x: gauss_2(beta=beta, x=x))
print(f"Gaussian defined analytically:\n{tree_2}")