mooonpy.molspace.force_field module
- class mooonpy.molspace.force_field.ForceField(**kwargs)[source]
Bases:
object- condense_element(atoms, ele_list=None)[source]
Collapse
massesto one entry per element and remap everyatom.typeaccordingly.After
Molspace.combinehas stitched two systems together, the masses dict typically has duplicate elements at different type ids (e.g.{1: C, 2: H, 3: N, 4: C, 5: H, 6: O}). This method rewrites the table to one entry per element with the new type ids assigned inele_listorder.- Parameters:
atoms (Atoms) –
Molspace.atoms(or any dict of atom objects with atypeattribute) whose type ids will be remapped in place.ele_list (list[str] or None) – Element-symbol order for the output type ids (
ele_list[0]becomes type 1, etc.). IfNone, the elements present inmassesare collected and sorted by themooonpy.molspace.periodic_tableordering.
- Raises:
ValueError – If a mass entry’s element is not in
ele_list.
Element resolution per existing mass entry:
params.elementfirst, thenparams.comment, then a periodic-table lookup by mass.- Example:
>>> # After combining DETDA (C, H, N) with DGEBF (C, H, O): >>> mol.ff.condense_element(mol.atoms) >>> sorted(mol.ff.masses) # one entry per element, in ptable order [1, 2, 3, 4] # C, H, O, N
- elements2mass(atoms, elements=None, change_types=False)[source]
Update masses Coefficients using per-atom element labels :param Atoms: Input Atoms object to loop through :param elements: list of elements to be used (1 indexed in dict output), if None, will loop through atoms and use periodic_table.py ordering :param change_types: Bool, will update each Atom.type with the new type for each element