convmag


Nameconvmag JSON
Version 0.0.5 PyPI version JSON
download
home_page
Summaryconversion between units used in magnetism
upload_time2024-02-05 10:17:44
maintainer
docs_urlNone
authorThomas G. Woodcock
requires_python>=3.6
licenseMIT License Copyright (c) 2021 tgwoodcock Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords python conversion units magnetism magnetic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI Version](https://img.shields.io/pypi/v/convmag.svg)](https://pypi.python.org/pypi/convmag/)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/convmag.svg)](https://pypi.python.org/pypi/convmag/)

# convmag
Conversion between various units used in magnetism

The conversions between *base units* available are:
        
             T  <->  G         :    1e4
             T  <->  Oe        :    1e4
           A/m  <->  T         :    MU_0
           A/m  <->  G         :    1e4 * MU_0
             G  <->  Oe        :    1
           A/m  <->  Oe        :    1e4 * MU_0
      emu/cm^3  <->  T         :    1e3 * MU_0
    erg/Oecm^3  <->  A/m       :    1e3
         emu/g  <->  Am^2/kg   :    1
         J/m^3  <->  GOe       :    1e8 * MU_0
         J/m^3  <->  erg/cm^3  :    1e1
      erg/cm^3  <->  GOe       :    1e7 * MU_0
          Am^2  <->  emu       :    1e3
          Am^2  <->  erg/G     :    1e3
          Am^2  <->  erg/Oe    :    1e3
           emu  <->  erg/G     :    1
           muB  <->  Am^2      :    MU_B
           muB  <->  emu       :    1e3 * MU_B
        muB/fu  <->  T         :    requires user input of lattice parameters

(the factors given above are for the forward conversion)

- permeability of free space, MU_0 = 4 * 3.14159 * 1e-7 H/m  (== Vs/Am)

- Bohr magneton, MU_B =  9.274015e-24 Am^2
      (muB is the unit string for conversions with Bohr magnetons)

The *prefactors* available for any base unit are: M (1e6), k (1e3), m (1e-3), µ (1e-6)

You can combine *prefactors* and *base units* to give e.g. MA/m or kJ/m^3

<br>

### A word about emu

emu is not a unit but indicates the system of cgs units being used (emu == electromagnetic units)

The magnetisation data from magnetometers is very often given in emu, and in these cases emu implies the units erg/G. 
This is why the equivalence emu = erg/G is given above. Many authors still quote emu/g or emu/cm^3 and therefore,
these conversions are listed in the table above. convmag always assumes that emu has the units erg/G.

**In some cases emu may take other units, so it's always worth checking this!** 

<br>

## Installation:

### Pip
You can install the current release (0.0.3) with pip:
```bash
    pip install convmag
```

Pure python, no other dependencies.

Requires Python >= 3.6 because f-strings are used

<br>

## Usage options:

1) a console script is provided and should be located in the Scripts directory of
   your Python distribution after installation. If you have this directory in
   your Path (environment variable on Windows) you can start the program by
   typing "convmag" in the console. In this case only single values can be 
   converted (at one time).

2) the package can be imported into python and then you can pass numpy arrays
   into the function convert_unit(), making sure to keep the default verbose=False.
   That way many values can be converted at once. The converted
   values are returned as a numpy array for further processing.
   
```python
    >>> import numpy as np
    >>> import convmag as cm
    
    >>> vals_in_T = np.arange(0,130,20)
    
    >>> vals_in_T
    array([  0,  20,  40,  60,  80, 100, 120])
   
    >>> vals_in_Oe = cm.convert_unit(vals_in_T, "T", "Oe", verbose=False)
    
    >>> vals_in_Oe
    array([      0.,  200000.,  400000.,  600000.,  800000., 1000000., 1200000.])
```

<br>

## Converting between Bohr Magnetons per formula unit and Tesla (muB/fu <-> T)

This conversion requires user input of:

- the lattice parameters *a*, *b*, *c* and *gamma*, and

- the number of formula units per unit cell.

Only orthogonal (cubic, tetragonal and orthorhombic) and hexagonal unit cells can be handled
and therefore *gamma* = 90° or 120°.

As an example of the number of formula units per unit cell, Nd2Fe14B is the formula unit, which
has 17 atoms, and the unit cell contains 68 atoms, so in this case there are 4 formula units per unit cell.

Calling convmag in the console, the conversion from muB to T looks like this:

```
    Input: 2.3 muB/fu T

    ***INFO: muB per formula unit <-> T***

    Please enter lattice parameters: a b c in Angstrom
    a b c: 3.0 3.0 4.0

    Limited to orthogonal or hexagonal unit cells:
    Please enter gamma in deg. (90 or 120): 90
    Please enter the number of formula units per unit cell:
    f.u./unit cell: 2

    2.3 muB per f.u. = 1.48913 T (2 f.u./unit cell, cell volume = 3.600e-29 m^3)
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "convmag",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,conversion,units,magnetism,magnetic",
    "author": "Thomas G. Woodcock",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/cc/05/86450fd3e9c1b9fc05be2d33bc5e313589e52ea08d423a9a3d458c2a8839/convmag-0.0.5.tar.gz",
    "platform": null,
    "description": "[![PyPI Version](https://img.shields.io/pypi/v/convmag.svg)](https://pypi.python.org/pypi/convmag/)\r\n[![Supported Python Versions](https://img.shields.io/pypi/pyversions/convmag.svg)](https://pypi.python.org/pypi/convmag/)\r\n\r\n# convmag\r\nConversion between various units used in magnetism\r\n\r\nThe conversions between *base units* available are:\r\n        \r\n             T  <->  G         :    1e4\r\n             T  <->  Oe        :    1e4\r\n           A/m  <->  T         :    MU_0\r\n           A/m  <->  G         :    1e4 * MU_0\r\n             G  <->  Oe        :    1\r\n           A/m  <->  Oe        :    1e4 * MU_0\r\n      emu/cm^3  <->  T         :    1e3 * MU_0\r\n    erg/Oecm^3  <->  A/m       :    1e3\r\n         emu/g  <->  Am^2/kg   :    1\r\n         J/m^3  <->  GOe       :    1e8 * MU_0\r\n         J/m^3  <->  erg/cm^3  :    1e1\r\n      erg/cm^3  <->  GOe       :    1e7 * MU_0\r\n          Am^2  <->  emu       :    1e3\r\n          Am^2  <->  erg/G     :    1e3\r\n          Am^2  <->  erg/Oe    :    1e3\r\n           emu  <->  erg/G     :    1\r\n           muB  <->  Am^2      :    MU_B\r\n           muB  <->  emu       :    1e3 * MU_B\r\n        muB/fu  <->  T         :    requires user input of lattice parameters\r\n\r\n(the factors given above are for the forward conversion)\r\n\r\n- permeability of free space, MU_0 = 4 * 3.14159 * 1e-7 H/m  (== Vs/Am)\r\n\r\n- Bohr magneton, MU_B =  9.274015e-24 Am^2\r\n      (muB is the unit string for conversions with Bohr magnetons)\r\n\r\nThe *prefactors* available for any base unit are: M (1e6), k (1e3), m (1e-3), \u00b5 (1e-6)\r\n\r\nYou can combine *prefactors* and *base units* to give e.g. MA/m or kJ/m^3\r\n\r\n<br>\r\n\r\n### A word about emu\r\n\r\nemu is not a unit but indicates the system of cgs units being used (emu == electromagnetic units)\r\n\r\nThe magnetisation data from magnetometers is very often given in emu, and in these cases emu implies the units erg/G. \r\nThis is why the equivalence emu = erg/G is given above. Many authors still quote emu/g or emu/cm^3 and therefore,\r\nthese conversions are listed in the table above. convmag always assumes that emu has the units erg/G.\r\n\r\n**In some cases emu may take other units, so it's always worth checking this!** \r\n\r\n<br>\r\n\r\n## Installation:\r\n\r\n### Pip\r\nYou can install the current release (0.0.3) with pip:\r\n```bash\r\n    pip install convmag\r\n```\r\n\r\nPure python, no other dependencies.\r\n\r\nRequires Python >= 3.6 because f-strings are used\r\n\r\n<br>\r\n\r\n## Usage options:\r\n\r\n1) a console script is provided and should be located in the Scripts directory of\r\n   your Python distribution after installation. If you have this directory in\r\n   your Path (environment variable on Windows) you can start the program by\r\n   typing \"convmag\" in the console. In this case only single values can be \r\n   converted (at one time).\r\n\r\n2) the package can be imported into python and then you can pass numpy arrays\r\n   into the function convert_unit(), making sure to keep the default verbose=False.\r\n   That way many values can be converted at once. The converted\r\n   values are returned as a numpy array for further processing.\r\n   \r\n```python\r\n    >>> import numpy as np\r\n    >>> import convmag as cm\r\n    \r\n    >>> vals_in_T = np.arange(0,130,20)\r\n    \r\n    >>> vals_in_T\r\n    array([  0,  20,  40,  60,  80, 100, 120])\r\n   \r\n    >>> vals_in_Oe = cm.convert_unit(vals_in_T, \"T\", \"Oe\", verbose=False)\r\n    \r\n    >>> vals_in_Oe\r\n    array([      0.,  200000.,  400000.,  600000.,  800000., 1000000., 1200000.])\r\n```\r\n\r\n<br>\r\n\r\n## Converting between Bohr Magnetons per formula unit and Tesla (muB/fu <-> T)\r\n\r\nThis conversion requires user input of:\r\n\r\n- the lattice parameters *a*, *b*, *c* and *gamma*, and\r\n\r\n- the number of formula units per unit cell.\r\n\r\nOnly orthogonal (cubic, tetragonal and orthorhombic) and hexagonal unit cells can be handled\r\nand therefore *gamma* = 90\u00b0 or 120\u00b0.\r\n\r\nAs an example of the number of formula units per unit cell, Nd2Fe14B is the formula unit, which\r\nhas 17 atoms, and the unit cell contains 68 atoms, so in this case there are 4 formula units per unit cell.\r\n\r\nCalling convmag in the console, the conversion from muB to T looks like this:\r\n\r\n```\r\n    Input: 2.3 muB/fu T\r\n\r\n    ***INFO: muB per formula unit <-> T***\r\n\r\n    Please enter lattice parameters: a b c in Angstrom\r\n    a b c: 3.0 3.0 4.0\r\n\r\n    Limited to orthogonal or hexagonal unit cells:\r\n    Please enter gamma in deg. (90 or 120): 90\r\n    Please enter the number of formula units per unit cell:\r\n    f.u./unit cell: 2\r\n\r\n    2.3 muB per f.u. = 1.48913 T (2 f.u./unit cell, cell volume = 3.600e-29 m^3)\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021 tgwoodcock  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "conversion between units used in magnetism",
    "version": "0.0.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/tgwoodcock/convmag.git/issues",
        "Source": "https://github.com/tgwoodcock/convmag.git"
    },
    "split_keywords": [
        "python",
        "conversion",
        "units",
        "magnetism",
        "magnetic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6b2fa230877e268b718b5762759c08767b0d0a851666a79cd2af212eef97c0f",
                "md5": "0cd122ae6783607d6860d57a740891ba",
                "sha256": "c49545cce700b70ccad336621e4389664bff4a188d9d810e77c71e7535d797ab"
            },
            "downloads": -1,
            "filename": "convmag-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0cd122ae6783607d6860d57a740891ba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8874,
            "upload_time": "2024-02-05T10:17:42",
            "upload_time_iso_8601": "2024-02-05T10:17:42.893610Z",
            "url": "https://files.pythonhosted.org/packages/e6/b2/fa230877e268b718b5762759c08767b0d0a851666a79cd2af212eef97c0f/convmag-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc0586450fd3e9c1b9fc05be2d33bc5e313589e52ea08d423a9a3d458c2a8839",
                "md5": "6c24927ae18dc233b76aca222aa068a9",
                "sha256": "b8f418fc0f06265a732e5fcd558b69321ff249c61494d35d49c2be85443890e1"
            },
            "downloads": -1,
            "filename": "convmag-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "6c24927ae18dc233b76aca222aa068a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9267,
            "upload_time": "2024-02-05T10:17:44",
            "upload_time_iso_8601": "2024-02-05T10:17:44.680260Z",
            "url": "https://files.pythonhosted.org/packages/cc/05/86450fd3e9c1b9fc05be2d33bc5e313589e52ea08d423a9a3d458c2a8839/convmag-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-05 10:17:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tgwoodcock",
    "github_project": "convmag",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "convmag"
}
        
Elapsed time: 3.05018s