<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dict(self):
 """Return a dictionary containing Atom data."""

        data = {'aid': self.aid, 'number': self.number, 'element': self.element}
        for coord in {'x', 'y', 'z'}:
            if getattr(self, coord) is not None:
                data[coord] = getattr(self, coord)
        if self.charge is not 0:
            data['charge'] = self.charge
        return data