Closed
Description
Hello,
I generate a primitive lattice with random carbon atoms. If I remove an atom by RemoveScatterer(), the function GetFormula writes the original formula before removing an atom. If I use GetNbScatterer, I get a correct answer. It isn't practical, because I want to generate an electron density map, but I get the same result (before/after). I'm including my code.
Thanks for answers.
from pyobjcryst.crystal import *
# some lines
c = Crystal(5, 5, 5, pi/2, pi/2, pi/2, "P1")
# some lines
i = nbAtoms
at = list()
carbon = ScatteringPowerAtom("C", "C")
c.AddScatteringPower(carbon)
while i > 0:
# position = [random(), random(), random()]
at.append(Atom(random(), random(), random(), f"C{i}", carbon, 1.0))
c.AddScatterer(at[nbAtoms-i])
import numpy as np
darr = np.array(c.GetMinDistanceTable(0.0))
minimum = darr.min()
print(minimum)
if minimum < min_distance:
c.RemoveScatterer(at[nbAtoms-i])
del(at[nbAtoms-i])
i += 1
i -= 1
formula = c.GetFormula()
print("Molecular formula:", formula)
c.RemoveScatterer(at[0])
formula = c.GetFormula()
print("Molecular formula:", formula)
(Output after removing 2 atoms. The 1st line is GetNbScatterer and 2nd is GetFormula)