Small issue with sqrt and multiprocessing

Hi All,

I’ve noticed a small issue when using coefficient functions containing square roots with Python’s multiprocessing library.
Passing a coefficient function with a square root (e.g. sqrt(x+1)) to multiprocessing results in a pickling error and a bad runtime call error.

As an example, I’ve attached a small example that recreates the issue on my Windows machine:

from ngsolve import *
import multiprocessing

def test_func(coeff):
    return coeff * 2

def main():
    coeff = CoefficientFunction(sqrt(x+1))

    runlist = (coeff, coeff, coeff, coeff)

    with multiprocessing.get_context("spawn").Pool(4) as pool:
        output =, runlist)

if __name__ == '__main__':

Replacing the sqrt with **0.5 seems to fix the issue, so I’ve been able to get my code working without further issues, it just seems a little odd.

Regards James

Hi James,

thank you for the bug report - the problem is fixed with the coming nightly release,