Skip to content

After using RemoveScatterer, the catalogue of athoms doesn't update #41

Closed
@ji-ze

Description

@ji-ze

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)

image
(Output after removing 2 atoms. The 1st line is GetNbScatterer and 2nd is GetFormula)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions