Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/nomad_simulations/schema_packages/atoms_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,16 @@ class AtomsState(ParticleState):
""",
)

partial_charge = Quantity(
type=np.float64,
unit='elementary_charge',
description="""
Atom-centered partial charge used in force fields or population analyses
(e.g., Mulliken, Hirshfeld, CM5, NPA, RESP). This quantity is distinct from
the formal integer oxidation-like `charge`.
""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your definition better than mine, great!

)

spin = Quantity(
type=np.int32,
default=0,
Expand Down
15 changes: 15 additions & 0 deletions tests/test_atoms_state.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the dedication to testing. Since we do not have any automated systems to populate one charge from the other, this test could also be safely removed. This marginally reduces the test stack. Conversely, if you want to safeguard against future normalization improperly deriving one from the other, you can leave it in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversely, if you want to safeguard against future normalization improperly deriving one from the other, you can leave it in.

Thanks alot, that makes sense. I think i will indeed keep this one test as a lightweight regression guard for the future 👍

Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,21 @@ def test_atomic_number_to_symbol(self, atomic_number: int, chemical_symbol: str)
atom_state.normalize(EntryArchive(), logger)
assert atom_state.chemical_symbol == chemical_symbol

def test_partial_charge_is_independent_of_formal_charge(self):
atom_state = AtomsState(
chemical_symbol='O',
charge=-1,
partial_charge=-0.42 * ureg.elementary_charge,
)
atom_state.normalize(EntryArchive(), logger)

assert atom_state.charge == -1
assert atom_state.partial_charge is not None
assert (
pytest.approx(atom_state.partial_charge.to('elementary_charge').magnitude)
== -0.42
)


class TestCGBeadState:
"""
Expand Down
Loading