BioSimSpace.Types.Charge

class BioSimSpace.Types.Charge(*args)

A charge type.

__init__(*args)

Constructor.

*args can be a magnitude and unit, or a string representation of the charge, e.g. “0.2 e”.

Parameters:
  • magnitude (float) – The magnitude.
  • unit (str) – The unit.
  • string (str) – A string representation of the charge.

Examples

Create an object representing a charge of 27.8 electron charge print the charge in Coulomb.

>>> import BioSimSpace as BSS
>>> charge = BSS.Types.Charge(27.8, "e")
>>> print(charge.coulomb())

The same as above, except passing a string representation of the charge to the constructor.

>>> import BioSimSpace as BSS
>>> charge = BSS.Types.Charge("3.1 atm")
>>> print(charge.coulomb())

The string matching is extremeley flexible, so all of the following would be valid arguments: “27.8 e”, “27.8 electron charge”, “2.78e1 e”.

Methods

__init__(*args) Constructor.
coulomb() Return the charge in Coulomb.
electron_charge() Return the charge in electron charge.
magnitude() Return the magnitude.
unit() Return the unit.
coulomb()

Return the charge in Coulomb.

Returns:charge – The charge in Coulomb.
Return type:Charge
electron_charge()

Return the charge in electron charge.

Returns:charge – The charge in electron charge.
Return type:Charge
magnitude()

Return the magnitude.

Returns:magnitude – The magnitude of the type.
Return type:float
unit()

Return the unit.

Returns:unit – The unit of the type.
Return type:str