Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.6%) to scientific vocabulary
Keywords
Repository
Allows python to interface with MESA
Basic Info
- Host: GitHub
- Owner: rjfarmer
- License: gpl-2.0
- Language: Python
- Default Branch: main
- Size: 774 KB
Statistics
- Stars: 24
- Watchers: 6
- Forks: 4
- Open Issues: 1
- Releases: 6
Topics
Metadata Files
README.md
pyMesa
Allows python to interface with MESA stellar evolution code.
Requirements:
Note: pyMesa currently only works on linux, Macs will fail to build.
Python dependencies can be installed with:
python -m pip install -r 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.MESADIR) # Print MESADIR
Loads the const module
constlib,constdef = 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 = constlib.constinit(pym.MESA_DIR,ierr)
Functions and subroutines return a namedtuple
print(res.result) # prints function result print(res.args) # prints all arguments
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:
constdef.mevto_ergs
If the variable is not a parameter then you can change it with:
constdef.standardcgrav = 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.
Procedure calls
Calling a function or a subroutine is handled the same way:
python
result = module.my_function(arg1, arg2)
Where every arg should be provided either with the value to be inputted (intent(in) or intent(inout)) or a dummy empty provided for intent(out) values.
The result of a procedure call is returned as a NamedTuple of (result, args). Thus a function result is accessed via:
````python result = module.my_function(arg1, arg2)
Function result
result.result ````
While all the arguments (both those that change and those that don't) are returned via:
````python result = module.my_function(arg1, arg2)
Arguments
result.args['arg1'] result.args['arg2'] ````
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). The current version's citation is in the CITATION file.
Known Projects using pyMesa
Owner
- Name: Robert Farmer
- Login: rjfarmer
- Kind: user
- Location: Germany
- Website: http://rjfarmer.io
- Repositories: 7
- Profile: https://github.com/rjfarmer
Citation (CITATION)
@misc{pymesa,
author = {Robert Farmer and
Evan B. Bauer},
title = {pyMesa},
month = mar,
year = 2018,
doi = {10.5281/zenodo.1205271},
url = {https://doi.org/10.5281/zenodo.1205271}
}
CodeMeta (codemeta.json)
{
"@context": "http://schema.org",
"@type": "Code",
"author": [
{
"@id": "https://orcid.org/0000-0003-3441-7624",
"@type": "Person",
"email": "robert.j.farmer37@gmail.com",
"name": "Robert Farmer"
},
{
"@id": "https://orcid.org/0000-0002-4791-6724",
"@type": "Person",
"email": "ebauer@physics.ucsb.edu",
"name": "Evan Bauer"
}
],
"citation": "https://doi.org/10.5281/zenodo.846304",
"codeRepository": "https://github.com/rjfarmer/pyMesa",
"dateCreated": "2017-07-25",
"description": "Python bindings for the 1-D stellar evolution code, MESA",
"keywords": "python, fortran, MESA, bindings",
"license": "https://opensource.org/licenses/GPL-2.0",
"name": "pyMesa"
}
GitHub Events
Total
- Watch event: 3
Last Year
- Watch event: 3
Packages
- Total packages: 1
-
Total downloads:
- pypi 31 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
pypi.org: pymesa
"Python bindings for MESA (Modules for Experiments in Stellar Astrophysics)"
- Homepage: https://github.com/rjfarmer/pyMesa
- Documentation: https://pymesa.readthedocs.io/
- License: GPLv2+
-
Latest release: 2.0.1
published over 2 years ago