Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimental solve_mp doesn't seem to work anymore #51

Closed
mbakker7 opened this issue Sep 15, 2022 · 4 comments
Closed

experimental solve_mp doesn't seem to work anymore #51

mbakker7 opened this issue Sep 15, 2022 · 4 comments
Assignees

Comments

@mbakker7
Copy link
Owner

experimental solve_mp doesn't seem to work anymore. I wonder if it ever worked since the move to numba.

@mbakker7
Copy link
Owner Author

Maybe Huite can help.

@mbakker7
Copy link
Owner Author

Suggested solution (from Joost Delsman and in Dutch): Het lag aan het referencen van de module besselaesnumba vanuit elk element. Dan kan python m blijkbaar niet meer picklen er daarmee werkt de multiprocessing niet meer. Oplossing is de switch fy2p / numba niet meer intern in elk element te hebben, maar in de globale namespace. Heb de linesink.py aangepast, daarmee werkt het voor mij (gebruik geen andere elementen, maar daar geldt vast hetzelfde voor).

@jdelsman
Copy link

Solved it by moving the switch between numba f2py to the global namespace, instead of inline in the element classes:

from .besselaesnumba import besselaesnumba as bessel
bessel.initialize()
try:
from .src import besselaesnew
bessel = besselaesnew.besselaesnew
bessel.initialize()
#print('succes on f2py')
except:
pass

and then in the class remove the self.bessel, and instead refer to the global bessel

def __init__(self, .....):
    Element.__init__(self, model, nparam=1, nunknowns=0, layers=layers, \
                     name=name, label=label)
    .....
    # if self.model.f2py:
    #     self.bessel = besselaesnew.besselaesnew
    # else:
    #     self.bessel = besselaesnumba

def disvecinf(self, x, y, aq=None):
    '''Can be called with only one x,y value
    Returns array(nparam, self.aq.naq) with order
    order 0, layer[0]
    order 0, layer[1]
    ...
    order 1, layer[0]
    order 1, layer[1]
    etc
    '''
    if aq is None: aq = self.model.aq.find_aquifer_data(x, y)
    rv = np.zeros((2, self.nparam, aq.naq))
    if aq == self.aq:
        qxqyrv = rv.reshape((2, self.order + 1, self.nlayers, aq.naq))
        qxqy = np.zeros((2 * (self.order + 1), aq.naq))

--> qxqy[:, :] = bessel.disbeslsv(float(x), float(y), self.z1,
self.z2, aq.lab, self.order, aq.ilap, aq.naq)
qxqyrv[0, :] = self.aq.coef[self.layers] * qxqy[:self.order + 1,
np.newaxis, :]
qxqyrv[1, :] = self.aq.coef[self.layers] * qxqy[self.order + 1:,
np.newaxis, :]
return rv

@jdelsman
Copy link

linesink.zip

dbrakenhoff added a commit that referenced this issue Nov 9, 2022
- remove f2py from elements and model class
- move besselaes module logic to bessel.py
- refactor bessel function calls
- set bessel method in init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants