pyMesa


NamepyMesa JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/rjfarmer/pyMesa
Summary"Python bindings for MESA (Modules for Experiments in Stellar Astrophysics)"
upload_time2023-06-26 09:10:36
maintainer
docs_urlNone
authorRobert Farmer
requires_python>=3.7
licenseGPLv2+
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![pyMesa logo](images/logo.png)

[![DOI](https://zenodo.org/badge/98320319.svg)](https://zenodo.org/badge/latestdoi/98320319)


# pyMesa
Allows python to interface with MESA stellar evolution code.


## Requirements:
Note: pyMesa currently only works on linux, Macs will fail to build.

[gfort2py](https://github.com/rjfarmer/gfort2py) (Also available via pip) (needs version >= 2.0.0)


Python dependencies can be installed with:

``
python -m pip install requirements.txt
``

We also need the following tool from installed by you system package manager or other means:

``
chrpath
`` 


## Installing pyMesa

The preferred way is via pip:

``
python -m pip install --upgrade pyMesa
``


## Building MESA

Go to ``$MESA_DIR/utils/makefile_header`` and find ``USE_SHARED=no`` and switch that to ``USE_SHARED=yes``

Then:

````
cd $MESA_DIR
./clean
./install
````


## Supported MESA versions

Any post github version: that is a version that starts with 'r2' or is from a git checkout.


## Running

Make sure you set ``MESA_DIR`` and ``MESASDK_ROOT`` before starting Python.


## Usage

Here is a basic example of talking to the ``const`` module.

````python
import pyMesa as pym

# pyMesa module defines a number of useful MESA paths as pym.SOMETHING.
print(pym.MESA_DIR) # Print MESA_DIR
print(pym.MESA_VERSION) # Print MESA version number

# Loads the const module
const_lib,const_def = pym.loadMod("const")

# When calling a function we must either set the value we want (for intent(in/inout) variables) or an empty variable for intent(out).
ierr=0
# Calls a function
res = const_lib.const_init(pym.MESA_DIR,ierr)


# If the call was a subroutine then res is a dict with the intent out variables in there
# else it contains the result of the function call

# Accessing a variable defined in a module is simply:
const_def.mev_to_ergs

# If the variable is not a parameter then you can change it with:
const_def.standard_cgrav = 5.0

# When passing a derived type, you should pass a dict to the function (filled with anything you want set)
x = {}
# or
x = {'a':1,'b':'abc','c':{'d':1}}

# Functions accepting arrays should pass a numpy array of the size it expects (if the function allocates the array, then just pass None)
x = np.zeros(size)

````

The folder ``mesa_models`` shows some examples of accessing different MESA modules. Note some may not work depending on whether MESA 
has changed the interface since the code was written.


## Arrays

Remember that Fortran has 1-based arrays while Numpy uses 0-based. This comes
up if you're accessing an array via a mesa constant:

````python
mesa_array[mesa_module.i_mesa_const]
````
 should instead be accessed as:
 
 ````python
mesa_array[mesa_module.i_mesa_const-1]
````

## Bug reports:

Bug reports should go to the issue tracker on github. Please include mesa version, gfortran version, gfort2py version and pyMesa version 

## Contributing

In general most of the development should go towards the gfort2py project to add new
fortran features. This repository just handles building mesa for python support. 

Bug reports, if mesa versions don't work, or new examples are welcome as either pull requests
or issues on the github tracker.

## Citations

People who use pyMESA in papers should cite this using the zenodo link for the version they used. If you use pyMesa in a project (research or teaching), let me know and i can help advertise here (also useful for me to help
with funding requests). Current versions citation is in the CITATION file.

## Known Projects using pyMesa

[Poelarends et al 2017](https://ui.adsabs.harvard.edu/#abs/2017ApJ...850..197P/abstract)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rjfarmer/pyMesa",
    "name": "pyMesa",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Robert Farmer",
    "author_email": "robert.j.farmer37@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fe/4f/17de62e4d790066e1aeb1a38e1f2d11b9fc30a9661d757adfd89b7c69423/pyMesa-2.0.0.tar.gz",
    "platform": "unix",
    "description": "![pyMesa logo](images/logo.png)\n\n[![DOI](https://zenodo.org/badge/98320319.svg)](https://zenodo.org/badge/latestdoi/98320319)\n\n\n# pyMesa\nAllows python to interface with MESA stellar evolution code.\n\n\n## Requirements:\nNote: pyMesa currently only works on linux, Macs will fail to build.\n\n[gfort2py](https://github.com/rjfarmer/gfort2py) (Also available via pip) (needs version >= 2.0.0)\n\n\nPython dependencies can be installed with:\n\n``\npython -m pip install requirements.txt\n``\n\nWe also need the following tool from installed by you system package manager or other means:\n\n``\nchrpath\n`` \n\n\n## Installing pyMesa\n\nThe preferred way is via pip:\n\n``\npython -m pip install --upgrade pyMesa\n``\n\n\n## Building MESA\n\nGo to ``$MESA_DIR/utils/makefile_header`` and find ``USE_SHARED=no`` and switch that to ``USE_SHARED=yes``\n\nThen:\n\n````\ncd $MESA_DIR\n./clean\n./install\n````\n\n\n## Supported MESA versions\n\nAny post github version: that is a version that starts with 'r2' or is from a git checkout.\n\n\n## Running\n\nMake sure you set ``MESA_DIR`` and ``MESASDK_ROOT`` before starting Python.\n\n\n## Usage\n\nHere is a basic example of talking to the ``const`` module.\n\n````python\nimport pyMesa as pym\n\n# pyMesa module defines a number of useful MESA paths as pym.SOMETHING.\nprint(pym.MESA_DIR) # Print MESA_DIR\nprint(pym.MESA_VERSION) # Print MESA version number\n\n# Loads the const module\nconst_lib,const_def = pym.loadMod(\"const\")\n\n# When calling a function we must either set the value we want (for intent(in/inout) variables) or an empty variable for intent(out).\nierr=0\n# Calls a function\nres = const_lib.const_init(pym.MESA_DIR,ierr)\n\n\n# If the call was a subroutine then res is a dict with the intent out variables in there\n# else it contains the result of the function call\n\n# Accessing a variable defined in a module is simply:\nconst_def.mev_to_ergs\n\n# If the variable is not a parameter then you can change it with:\nconst_def.standard_cgrav = 5.0\n\n# When passing a derived type, you should pass a dict to the function (filled with anything you want set)\nx = {}\n# or\nx = {'a':1,'b':'abc','c':{'d':1}}\n\n# Functions accepting arrays should pass a numpy array of the size it expects (if the function allocates the array, then just pass None)\nx = np.zeros(size)\n\n````\n\nThe folder ``mesa_models`` shows some examples of accessing different MESA modules. Note some may not work depending on whether MESA \nhas changed the interface since the code was written.\n\n\n## Arrays\n\nRemember that Fortran has 1-based arrays while Numpy uses 0-based. This comes\nup if you're accessing an array via a mesa constant:\n\n````python\nmesa_array[mesa_module.i_mesa_const]\n````\n should instead be accessed as:\n \n ````python\nmesa_array[mesa_module.i_mesa_const-1]\n````\n\n## Bug reports:\n\nBug reports should go to the issue tracker on github. Please include mesa version, gfortran version, gfort2py version and pyMesa version \n\n## Contributing\n\nIn general most of the development should go towards the gfort2py project to add new\nfortran features. This repository just handles building mesa for python support. \n\nBug reports, if mesa versions don't work, or new examples are welcome as either pull requests\nor issues on the github tracker.\n\n## Citations\n\nPeople who use pyMESA in papers should cite this using the zenodo link for the version they used. If you use pyMesa in a project (research or teaching), let me know and i can help advertise here (also useful for me to help\nwith funding requests). Current versions citation is in the CITATION file.\n\n## Known Projects using pyMesa\n\n[Poelarends et al 2017](https://ui.adsabs.harvard.edu/#abs/2017ApJ...850..197P/abstract)\n\n\n",
    "bugtrack_url": null,
    "license": "GPLv2+",
    "summary": "\"Python bindings for MESA (Modules for Experiments in Stellar Astrophysics)\"",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/rjfarmer/pyMesa"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c861647e5da89b1445817d5bf1bcc44dab108a6720b9d86d628e958bd50d85bc",
                "md5": "ec7d16e651edc49e2a18899e4a179195",
                "sha256": "7c12ebe7fdf247ec0052ed540fa034b8d09b2624d2d065a503bd02fbf56e6550"
            },
            "downloads": -1,
            "filename": "pyMesa-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ec7d16e651edc49e2a18899e4a179195",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5452,
            "upload_time": "2023-06-26T09:10:33",
            "upload_time_iso_8601": "2023-06-26T09:10:33.863733Z",
            "url": "https://files.pythonhosted.org/packages/c8/61/647e5da89b1445817d5bf1bcc44dab108a6720b9d86d628e958bd50d85bc/pyMesa-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe4f17de62e4d790066e1aeb1a38e1f2d11b9fc30a9661d757adfd89b7c69423",
                "md5": "19c423d7731d99fe37c3b8ba82916323",
                "sha256": "9393a6666e8217b3873fa7f87a3d8ee885b7d692726740bdd239457ca582675c"
            },
            "downloads": -1,
            "filename": "pyMesa-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "19c423d7731d99fe37c3b8ba82916323",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 98819,
            "upload_time": "2023-06-26T09:10:36",
            "upload_time_iso_8601": "2023-06-26T09:10:36.229173Z",
            "url": "https://files.pythonhosted.org/packages/fe/4f/17de62e4d790066e1aeb1a38e1f2d11b9fc30a9661d757adfd89b7c69423/pyMesa-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-26 09:10:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rjfarmer",
    "github_project": "pyMesa",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pymesa"
}
        
Elapsed time: 0.24190s