ISISNeutronMuon / ISISNeutronMuon/MDMC

Error thrown when trying to set charge to None of an Atom with charge None and Coulombic interaction.

Open
#213 0 comments 0 reactions 0 assignees View on GitHub
bug P1
Dominant language
Python
Stars
4
Forks
0
Avg merge
2d 4h
Merged PRs (30d)
5

Description

**Description of the error**
Upon creating an *Atom* object and initialising a Coulombic interaction for it without specifying the charge:

``H1 = Atom('H')``
``Coulombic(atoms=H1)``

The *Atom* object now has a charge of ``None`` and a Coulombic interaction. Currently, there is implementation in MDMC so that an error is thrown whenever there is an attempt to set the charge of the *Atom* to ``None`` when there exists a Coulombic interaction for that *Atom* object.

When trying to set the charge of *Atom* to ``None`` (when it's charge is already ``None``), this error is thrown:

``H1.charge = None``
``ValueError: Can't set charge to None when a Coulombic interaction exists.``

**Describe the expected result**
This problem arises as a result of very unexpected user behaviour, hence the low priority. However, an error should not be thrown in this particular case; initialising a Coulombic interaction with a charge of ``None`` does not create an associated interaction function so should not throw an error when the charge is set again to ``None``.

Setting the charge to ``None`` when it is already ``None`` should result in no change of the properties of *Atom*; it's charge should still be ``None`` and it should still have an initialised Coulombic interaction, but an interaction function should also not be created in the process.

**Suggested fix**
There should be a mechanism by which an error is thrown **only** when trying to set the charge of an *Atom* to ``None`` when it has a Coulombic interaction **and** an associated interaction (i.e. when it's charge is a ``float`` value).

**Additional Information**
This issue is linked to issue #212, so that the expected behaviour in both cases is as follows.
When the *Atom*'s charge is ``None`` and it has a Coulombic interaction but no interaction function:
* setting the charge to ``None`` shouldn't throw an error nor should it create an interaction function. The charge should remain as ``None`` and the *Atom* should still have a Coulombic interaction.
* setting the charge to a ``float`` value should create an interaction function associated to the Coulombic interaction.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.