Skip to content

Adapt to Psydac solvers and linear operations

Stefan Possanner requested to merge psydac-integration into devel

Use psydac.linalg.solvers.inverse() for solving Ax=b from now on.

Availbale solvers as for now are: cg, pcg, bicg, bicgstab, pbicgstab, minres, lsmr, gmres.

All inverse operators have been adapted.
Deleted struphy/linear_algebra/iterative_solvers.py

All inverse operators have a setter method for changing the matrix A (struphy-branch, psydac 0.1.4).

Preconditioners are passed as usual as LinearOperators to inverse() (struphy-branch, psydac 0.1.4).

Removed Sum, Multiply and Compose, use Psydac magic commands +, * and @ instead.

Use a new Psydac IdentityOperator that does not change the type of a LinearOperator under composition (struphy-branch, psydac 0.1.4).

Added the factor sqrt(2) in particle drawing - thanks Dominik for spotting this:

self.velocities = sp.erfinv(2*self.velocities - 1) * np.sqrt(2) * v_th + u_mean

In the old version of Struphy there was no factor 2 in the denominator of exp of Gaussian.

Use "good practice" for out= statement: instead of

        info = self._schur_solver(en, self._byn, dt, out=self._e_tmp1)[1]  
  
        en.copy(out=self._e_tmp2)
        self._e_tmp2 += self._e_tmp1
        self._C.dot(self._e_tmp2, out=self._b_tmp1)
        self._b_tmp1 *= -dt
        self._b_tmp1 += bn

we can increase readability by writing

        en1, info = self._schur_solver(en, self._byn, dt, out=self._e_tmp1)
       
        _e = en.copy(out=self._e_tmp2)
        _e += en1
        bn1 = self._C.dot(_e, out=self._b_tmp1)
        bn1 *= -dt
        bn1 += bn

Here, en1, _e and bn1 are just pointers to self._e_tmp1, self._e_tmp2 and self._b_tmp1, respectively.

Edited by Stefan Possanner

Merge request reports