{"id":13288293,"url":"https://github.com/rjfarmer/pyMesa","last_synced_at":"2025-03-10T06:33:21.913Z","repository":{"id":90893593,"uuid":"98320319","full_name":"rjfarmer/pyMesa","owner":"rjfarmer","description":"Allows python to interface with MESA","archived":false,"fork":false,"pushed_at":"2023-08-31T14:12:56.000Z","size":793,"stargazers_count":22,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-08-09T05:14:41.304Z","etag":null,"topics":["astrophysics","bindings","fortran","mesa","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rjfarmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json"}},"created_at":"2017-07-25T15:14:52.000Z","updated_at":"2024-07-10T11:53:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4dfacf5-056c-4ae5-ac6b-ae97cf1782bf","html_url":"https://github.com/rjfarmer/pyMesa","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjfarmer%2FpyMesa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjfarmer%2FpyMesa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjfarmer%2FpyMesa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjfarmer%2FpyMesa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjfarmer","download_url":"https://codeload.github.com/rjfarmer/pyMesa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242805420,"owners_count":20187995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astrophysics","bindings","fortran","mesa","python"],"created_at":"2024-07-29T16:56:17.582Z","updated_at":"2025-03-10T06:33:21.902Z","avatar_url":"https://github.com/rjfarmer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![pyMesa logo](images/logo.png)\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\nPython dependencies can be installed with:\n\n``\npython -m pip install -r 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\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# Functions and subroutines return a namedtuple\n\nprint(res.result) # prints function result\nprint(res.args) # prints all arguments\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## Procedure calls\n\nCalling a function or a subroutine is handled the same way:\n\n````python\nresult = module.my_function(arg1, arg2)\n````\n\nWhere 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.\n\nThe result of a procedure call is returned as a NamedTuple of ``(result, args)``. Thus a function result is accessed via:\n\n````python\nresult = module.my_function(arg1, arg2)\n\n#Function result\nresult.result\n````\n\nWhile all the arguments (both those that change and those that don't) are returned via:\n\n````python\nresult = module.my_function(arg1, arg2)\n\n#Arguments\nresult.args['arg1']\nresult.args['arg2']\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). The current version's 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjfarmer%2FpyMesa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frjfarmer%2FpyMesa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjfarmer%2FpyMesa/lists"}