Skip to content

Commit f2ca4ea

Browse files
committed
Merge branch 'main' into restore_convective_bdy_weight
2 parents a9c1b25 + 9eff49c commit f2ca4ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4580
-616
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@ testhub.yml
9898
.mesa_temp_cache/
9999
TAGS
100100
.vscode
101+
.idea

CITATIONS.bib

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,22 @@ @ARTICLE{Paxton2019
9494
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
9595
}
9696

97-
@ARTICLE{Jermyn2022,
98-
author = {{Jermyn}, Adam S. and {Bauer}, Evan B. and {Schwab}, Josiah and {Farmer}, R. and {Ball}, Warrick H. and {Bellinger}, Earl P. and {Dotter}, Aaron and {Joyce}, Meridith and {Marchant}, Pablo and {Mombarg}, Joey S.~G. and {Wolf}, William M. and {Wong}, Tin Long Sunny and {Cinquegrana}, Giulia C. and {Farrell}, Eoin and {Smolec}, R. and {Thoul}, Anne and {Cantiello}, Matteo and {Herwig}, Falk and {Toloza}, Odette and {Bildsten}, Lars and {Townsend}, Richard H.~D. and {Timmes}, F.~X.},
99-
title = "{Modules for Experiments in Stellar Astrophysics (MESA): Time-Dependent Convection, Energy Conservation, Automatic Differentiation, and Infrastructure}",
100-
journal = {arXiv e-prints},
101-
keywords = {Astrophysics - Solar and Stellar Astrophysics, Astrophysics - Earth and Planetary Astrophysics, Astrophysics - High Energy Astrophysical Phenomena, Astrophysics - Instrumentation and Methods for Astrophysics},
102-
year = 2022,
103-
month = {dec},
104-
eid = {arXiv:2208.03651},
105-
pages = {arXiv:2208.03651},
97+
@ARTICLE{Jermyn2023,
98+
author = {{Jermyn}, Adam S. and {Bauer}, Evan B. and {Schwab}, Josiah and {Farmer}, R. and {Ball}, Warrick H. and {Bellinger}, Earl P. and {Dotter}, Aaron and {Joyce}, Meridith and {Marchant}, Pablo and {Mombarg}, Joey S.~G. and {Wolf}, William M. and {Sunny Wong}, Tin Long and {Cinquegrana}, Giulia C. and {Farrell}, Eoin and {Smolec}, R. and {Thoul}, Anne and {Cantiello}, Matteo and {Herwig}, Falk and {Toloza}, Odette and {Bildsten}, Lars and {Townsend}, Richard H.~D. and {Timmes}, F.~X.},
99+
title = "{Modules for Experiments in Stellar Astrophysics (MESA): Time-dependent Convection, Energy Conservation, Automatic Differentiation, and Infrastructure}",
100+
journal = {\apjs},
101+
keywords = {Stellar physics, Stellar evolution, Stellar evolutionary models, Computational methods, 1621, 1599, 2046, 1965, Astrophysics - Solar and Stellar Astrophysics, Astrophysics - Earth and Planetary Astrophysics, Astrophysics - High Energy Astrophysical Phenomena, Astrophysics - Instrumentation and Methods for Astrophysics},
102+
year = 2023,
103+
month = mar,
104+
volume = {265},
105+
number = {1},
106+
eid = {15},
107+
pages = {15},
108+
doi = {10.3847/1538-4365/acae8d},
106109
archivePrefix = {arXiv},
107110
eprint = {2208.03651},
108111
primaryClass = {astro-ph.SR},
109-
adsurl = {https://ui.adsabs.harvard.edu/abs/2022arXiv220803651J},
112+
adsurl = {https://ui.adsabs.harvard.edu/abs/2023ApJS..265...15J},
110113
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
111114
}
112115

chem/public/chem_def.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module chem_def
117117
'californium','einsteinium','fermium','mendelevium', &
118118
'nobelium','lawrencium','rutherfordium','dubnium', &
119119
'seaborgium','bohrium','hassium','meitnerium','darmstadtium', &
120-
'roentgenium','copernicum' ]
120+
'roentgenium','copernicium' ]
121121

122122
! aluminum isomers
123123
character(len=iso_name_length), dimension(2:3) :: &

docs/source/about.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Developers
110110
* `Lars Bildsten <http://www.kitp.ucsb.edu/bildsten/>`__
111111
* `Matteo Cantiello <http://www.matteocantiello.com/>`__
112112
* Aaron Dotter
113+
* Matthias Fabry
113114
* `Robert Farmer <http://rjfarmer.io/>`__
114115
* Eoin Farrell
115116
* `Meridith Joyce <http://www.meridithjoyce.com/>`__

docs/source/changelog.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ like to see the changes without modifying the file.
4545

4646
``sed`` is a standard tool that is included with macOS and most Linux distributions.
4747

48+
Abundance-based timestep controls are now arrays
49+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50+
51+
The previous controls ::
52+
53+
dH_limit_min_H = 1d99
54+
dH_limit = 1d99
55+
dH_hard_limit = 1d99
56+
dH_decreases_only = .true.
57+
dH_div_H_limit_min_H = 1d-3
58+
dH_div_H_limit = 0.9d0
59+
dH_div_H_hard_limit = 1d99
60+
61+
and similar controls for ``He`` and ``He3`` have been replaced with
62+
arrays. This simplifies the code and allows the controls to be
63+
applied to any species in the net. A new control
64+
``dX_limit_species(...)`` specifies which elements will be checked.
65+
The previous behaviour for ``H``, for example, has been replaced with
66+
::
67+
68+
dX_limit_species(1) = 'h1'
69+
dX_limit_min_X(1) = 1d99
70+
dX_limit(1) = 1d99
71+
dX_hard_limit(1) = 1d99
72+
dX_decreases_only(1) = .true.
73+
dX_div_X_limit_min_X(1) = 1d-3
74+
dX_div_X_limit(1) = 0.9d0
75+
dX_div_X_hard_limit(1) = 1d99
76+
77+
The old ``H``, ``He`` and ``He3`` controls correspond to species
78+
``h1``, ``he4`` and ``he3``, respectively. You can also set the
79+
species to ``X``, ``Y`` or ``Z``, in which case the checks are applied
80+
*individually* to all isotopes of hydrogen, helium or metals,
81+
respectively.
4882

4983
Changes in r22.11.1
5084
===================

docs/source/test_suite.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ This test checks the counter and timing routines with a 1.5 Msun, Z=0.02 metalli
485485
This test case exercise the capability to simultaneously evolve two model stars.
486486
The test vehicle is a pair of 15 Msun, Z=0.02 metallicity, models one with overshooting and one without overshooting.
487487

488+
489+
:ref:`tzo`
490+
^^^^^^^^^^
491+
492+
This test case creates a Thorne-Zytkow object (TZO) and evolves until the NS has accreted a small amount of material.
493+
488494
:ref:`wd_c_core_ignition`
489495
^^^^^^^^^^^^^^^^^^^^^^^^^
490496

docs/source/test_suite/tzo.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../star/test_suite/tzo/README.rst

docs/source/using_mesa/best_practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ that is:
455455
.. code-block:: latex
456456

457457
Modules for Experiments in Stellar Astrophysics
458-
\citep[MESA][]{Paxton2011, Paxton2013, Paxton2015, Paxton2018, Paxton2019, Jermyn2022}.
458+
\citep[MESA][]{Paxton2011, Paxton2013, Paxton2015, Paxton2018, Paxton2019, Jermyn2023}.
459459

460460

461461
MESA critically rests on the hard work of many researchers who have

linters/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@ fix_inlists.py
9999
--------------
100100

101101
Fixes various controls in the test_suite inlists that should not be enabled by default.
102+
103+
104+
update_ctrls.py
105+
---------------
106+
107+
This handles the replacement of ``s%`` with ``s% ctrl%`` while being smart about only doing that to controls.

linters/update_ctrls.py

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
#!/usr/bin/env python
2+
3+
# This file is designed to handle moving controls from s% xx to s% ctrl %xx
4+
# While this replicates alot of check_defaults.py we want this to be standalone
5+
# and only depend on the python stdlib. This way users can easily use it to port their
6+
# run_star_extras.f90 files without needing to worry about python packaging.
7+
8+
# Usage: python update_ctrls.up file1.f90 file2.f90 ....
9+
10+
# Note this only works for s% (or s %) it does not work if you renamed the star_type varaible
11+
# to something other than s, for instance in the binary module.
12+
13+
import os
14+
import re
15+
from collections.abc import MutableSet
16+
import functools
17+
import operator
18+
import sys
19+
20+
21+
MESA_DIR = os.environ["MESA_DIR"]
22+
23+
ctrls_files = [ os.path.join("star_data","private","star_controls.inc"),
24+
os.path.join("star_data","private","star_controls_dev.inc")
25+
]
26+
27+
CRTL_NAME = 's% ctrl% '
28+
29+
# inspiration from https://stackoverflow.com/a/27531275
30+
class CaseInsensitiveSet(MutableSet):
31+
def __init__(self, iterable):
32+
self._values = {}
33+
self._fold = str.casefold
34+
for v in iterable:
35+
self.add(v)
36+
37+
def __repr__(self):
38+
return repr(self._values.values())
39+
40+
def __contains__(self, value):
41+
return self._fold(value) in self._values
42+
43+
def __iter__(self):
44+
return iter(self._values.values())
45+
46+
def __len__(self):
47+
return len(self._values)
48+
49+
def items(self):
50+
return self._values.items()
51+
52+
def add(self, value):
53+
if isinstance(value, CaseInsensitiveSet):
54+
for k,v in value.items():
55+
self._values[self._fold(k)] = v
56+
else:
57+
self._values[self._fold(value)] = value
58+
59+
60+
def discard(self, value):
61+
v = self._fold(value)
62+
if v in self._values:
63+
del self._values[v]
64+
65+
66+
def get_options(filename, regexp):
67+
"""Return a set of MESA option names"""
68+
r = re.compile(regexp)
69+
with open(os.path.join(MESA_DIR, filename)) as f:
70+
matches = r.finditer(f.read())
71+
return CaseInsensitiveSet(m.group(1) for m in matches)
72+
73+
74+
def get_columns(filename, regexp):
75+
"""Return a set of MESA column names"""
76+
r = re.compile(regexp)
77+
with open(os.path.join(MESA_DIR, filename)) as f:
78+
lines = f.readlines()
79+
matches = []
80+
for line in lines:
81+
m = r.match(line)
82+
if m is not None:
83+
matches.append(m.group(1))
84+
return CaseInsensitiveSet(matches)
85+
86+
def get_defaults(filename):
87+
# extract column names from defaults file
88+
89+
# these lines look like:
90+
# ! initial_mass = 1
91+
# ? ^^^^^^^^^
92+
# that is, they may or may not be commented out
93+
# and may or may not have a( )
94+
# and may or may not have space before a =
95+
96+
regexp = "^[ \t]*[ ]?(\w+)(\(.*\))*[ ^t]*="
97+
98+
return get_columns(filename, regexp)
99+
100+
def load_file(filename):
101+
with open(os.path.join(MESA_DIR, filename),"r") as f:
102+
lines = f.readlines()
103+
104+
return lines
105+
106+
107+
def get_inc(filename):
108+
# extract options from a inc file
109+
lines = load_file(filename)
110+
111+
# Remove line continutaion characters
112+
lines = [i.replace("&","").strip() for i in lines if i]
113+
114+
# Remove type defintion (i.e real(dp) :: x) leaves just x
115+
# as well as anything that starstwith a comment or has a comment embeded in it
116+
for idl,line in enumerate(lines):
117+
if "::" in line:
118+
lines[idl] = line.split("::")[1].strip()
119+
120+
lines = [i.split(",") for i in lines if i]
121+
122+
# Flatten list of lists
123+
lines = functools.reduce(operator.iconcat, lines, [])
124+
125+
# Remove array sizes from variables
126+
lines = [line.split("(")[0] for line in lines if line]
127+
128+
# Remove comments
129+
lines = [line.split("!")[0] for line in lines if line]
130+
131+
# Remove = x
132+
lines = [line.split("=")[0] for line in lines if line]
133+
134+
# Remove remaining empty strings
135+
lines = [line.strip() for line in lines if line]
136+
137+
return CaseInsensitiveSet(lines)
138+
139+
# Load controls names
140+
cinc = get_inc(ctrls_files[0])
141+
142+
for f in ctrls_files[1:]:
143+
cinc.add(get_inc(f))
144+
145+
146+
def update(filename):
147+
try:
148+
lines = load_file(filename)
149+
except (UnicodeDecodeError, IsADirectoryError):
150+
return
151+
152+
" s[0 or more space] % [0 or more space] [1 or more character or number or _]"
153+
# This wont match when s has been renamed
154+
regex_all = "(s[ \t]?[a-zA-Z0-9_]?%[ \t]?[a-zA-Z0-9_]*)"
155+
156+
" s [0 or more space] % [0 or more space] "
157+
regex_s = 's[ \ta-zA-Z0-9_]?%[ \t]?'
158+
159+
r_all = re.compile(regex_all)
160+
r_s = re.compile(regex_s)
161+
162+
for idl,line in enumerate(lines):
163+
# Split on s% something
164+
line_split = re.split(regex_all,line)
165+
for idm,match in enumerate(line_split):
166+
# Remove the s% so we can check if the variable is a control
167+
var = match.replace('s%','').strip()
168+
if var in cinc:
169+
# If it is a control then replace s% with CRTL_NAME
170+
line_split[idm] = re.sub(regex_s,CRTL_NAME,match)
171+
lines[idl] = ''.join(line_split)
172+
173+
with open(filename,'w') as f:
174+
f.writelines(lines)
175+
176+
if __name__ == "__main__":
177+
for i in sys.argv[1:]:
178+
update(i)
179+
180+
# Run over MESA_DIR
181+
182+
# python3 linters/update_ctrls.py star/test/src/*
183+
# python3 linters/update_ctrls.py star/work/src/*
184+
# python3 linters/update_ctrls.py star/job/*
185+
# python3 linters/update_ctrls.py star/p*/*.f90
186+
# python3 linters/update_ctrls.py star/test_suite/*/src/*.f90
187+
# python3 linters/update_ctrls.py star/other/*.f90
188+
# python3 linters/update_ctrls.py */test_suite/*/src/*.inc
189+
# python3 linters/update_ctrls.py */test_suite/*/src/*/*.inc
190+
191+
# python3 linters/update_ctrls.py binary/test/src/*
192+
# python3 linters/update_ctrls.py binary/work/src/*
193+
# python3 linters/update_ctrls.py binary/job/*
194+
# python3 linters/update_ctrls.py binary/p*/*.f90
195+
# python3 linters/update_ctrls.py binary/test_suite/*/src/*.f90
196+
# python3 linters/update_ctrls.py binary/other/*.f90
197+
198+
# python3 linters/update_ctrls.py astero/test/src/*
199+
# python3 linters/update_ctrls.py astero/work/src/*
200+
# python3 linters/update_ctrls.py astero/job/*
201+
# python3 linters/update_ctrls.py astero/p*/*.f90
202+
# python3 linters/update_ctrls.py astero/test_suite/*/src/*.f90
203+
# python3 linters/update_ctrls.py astero/other/*.f90

0 commit comments

Comments
 (0)