xtb-python icon indicating copy to clipboard operation
xtb-python copied to clipboard

Strange segmentation fault

Open mvfbarrionuevo opened this issue 5 years ago • 3 comments

Describe the bug

Failed to run an optimization for a periodic cell by employing method GFN0-xTB with more than 2 adsorbed molecules within the MOF pore. The same run happens to show no error, and converge smoothly when using xTB without the xtb-python API.

To Reproduce

from ase.optimize.bfgslinesearch import BFGSLineSearch
from ase.build import molecule
from ase.atoms import Atoms
from numpy import loadtxt
from xtb.ase.calculator import XTB
from ase.constraints import FixAtoms
from ase.data.pubchem import pubchem_atoms_search
from ase.io import write

def runmole(adsorbate, name, calc):
    adsorbate.calc = calc
    adsorbateopt = BFGSLineSearch(adsorbate, trajectory = '%sads.trj' % name, logfile = '%sads.log' % name)
    adsorbateopt.run(fmax=0.0005)
    write('%s.xyz' % name, adsorbate)
    return adsorbate.get_potential_energy()

def runopt(name, natom, Eadsorbate, Emof, lattice, calc):
    e = 0
    for i in range(4):
        S = loadtxt('%s.ads.%d.xyz' % (name, i), usecols = [0], dtype = str)
        P = loadtxt('%s.ads.%d.xyz' % (name, i), usecols = [1, 2, 3], dtype = float)
        ads = Atoms(symbols = S, positions = P, cell = lattice, pbc = [True, True, True])
        fixed = list(range(len(ads) - (i+1)*natom))
        ads.constraints = [FixAtoms(indices=fixed)]
        ads.calc = calc
        opt = BFGSLineSearch(ads, trajectory = '%sads%d.trj' % (name, i), logfile = '%sads%d.log' % (name, i))
        opt.run(fmax=0.0005)
        write('%sads%d.cif' % (name, i), ads)
        eads = ads.get_potential_energy() - (i+1)*Eadsorbate - Emof
        e = eads - e
        print('%sads%d = %10.8f %10.8f' % (name, i, eads, e))

lattice = loadtxt('CELL_PARAMETERS_MOF_4x3x1', usecols = [0, 1, 2], dtype = float)
calc = XTB(method='GFN0-xTB', accuracy = 1.0)
Emof = -10207.074487838794
Edmf = runmole(pubchem_atoms_search(name = 'dmf'), 'dmf', calc)
runopt('dmf', 12, Edmf, Emof, lattice, calc)
  1. What is your setup, which version are you running (current master is subject to change) xtb-6.3.2 xtb-python (API_VERSION: 1.0.0) ase 3.19.1.

  2. output showing the error Segmentation fault (core dumped)

All input and output file to verify this report.--> test.gz

Expected behaviour

Printing a table of adsorption energy.

mvfbarrionuevo avatar Jul 14 '20 15:07 mvfbarrionuevo

I am also having issues with running geometry optimization with xTB and ASE. With the current implementation is it possible to do a relaxation like this?

atoms.calc = XTB(method="GFN2-xTB")
relax = BFGSLineSearch(atoms)

I know it was possible before xtb-python. Now it seems only a single point calculation runs when relax is called.

Thanks for help!

wood-b avatar Jul 16 '20 04:07 wood-b

@mvfbarrionuevo Seems like a memory issue on the xtb API side, but the system is a bit to large to test it on a local workstation.

@wood-b it should be still possible using the code your provided.

awvwgk avatar Jul 16 '20 08:07 awvwgk

Try add this in your script: export OMP_STACKSIZE=5G

hellozhaoming avatar Jan 11 '22 01:01 hellozhaoming