You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mesa_script/README.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,21 @@
1
1
MesaScript
2
2
==========
3
3
4
-
###MESA Requirement!
4
+
###MESA Requirement!
5
5
In its current state, MesaScript requires MESA rev. 5596 or above. This is due
6
6
to a sensitivity to where the `'.inc'` files are stored on earlier versions. If
7
7
there is demand for MesaScript for earlier revisions, I will look into making
8
-
it backward compatible.
8
+
it backward compatible. It has been updated to work in the `git` era (beyond
9
+
version 15140), including conditionally adding the `&kap` and `&eos` namelists
10
+
if they are present. It does not currently support `astero` inlists out of the
11
+
box.
9
12
10
-
###The Short Short Version
13
+
###The Short Short Version
11
14
To get up and running fast, skip to installation, then try and use the included
12
15
sample file, `sample.rb` (via running `ruby sample.rb` in the command line). The
13
16
comments in `sample.rb` should get you started, especially if you have at least
14
17
a little Ruby know-how.
15
-
###What is MesaScript?
18
+
###What is MesaScript?
16
19
Lightweight, Ruby-based language that provides a powerful way to make inlists
17
20
for MESA projects. Really, MesaScript is a DSL (domain-specific language) built
18
21
on top of Ruby, so Ruby code "just works" inside MesaScript (if you're familiar
@@ -43,7 +46,7 @@ are pretty wide open. You could easily make a script that starts with a given
43
46
set of parameters, run MESA star, then use the output of that run to dictate a
44
47
new inlist and run, creating a chain (maybe a MESA root find of sorts).
45
48
46
-
###Installation
49
+
###Installation
47
50
MesaScript is now available as a gem! Assuming you have the `gem` command up
48
51
and running (you probably do, but if not, check out
49
52
[RubyGems](https://rubygems.org) to get it up and running). Simply run
@@ -91,7 +94,7 @@ work. The `mesa_script.rb` file generates all the necessary data it needs from
91
94
the MESA source on the fly (this also makes it nearly MESA version
92
95
independent).
93
96
94
-
###Basic Usage
97
+
###Basic Usage
95
98
The `mesa_script.rb` file defines just one class, Inlist, which we'll interact
96
99
with primarily through one class method, `make_inlist`. Just put the following
97
100
in a file to make a blank inlist:
@@ -113,14 +116,14 @@ by the way). Then to actually generate the inlist, enter
113
116
MesaScript, and you did so using fewer lines than it would have taken to
114
117
actually make that inlist on your own (technically)!
115
118
116
-
###Entering Inlist Commands
119
+
###Entering Inlist Commands
117
120
Making blank inlists is boring, so now let's cover how you actually make useful
118
121
inlists. For mesa inlists, there are really only two types of declarations:
119
122
those for scalars and those for array. Let's talk about scalars first, since
120
123
they are far more common. Then we'll get to the more complicated array
121
124
assignments.
122
125
123
-
####Scalar Assignments
126
+
####Scalar Assignments
124
127
As an example, let's say we want to set the initial mass of our star to 2.0
125
128
solar masses. The inlist command for this is `initial_mass`. In a regular
126
129
inlist file, we would need to put this in the proper namelist, `&controls` as
@@ -143,7 +146,7 @@ called `initial_mass`. (For the person curious as to why I didn't program this
143
146
functionality in, google something like "instance_eval setter method" to
144
147
discover what took me too long to figure out.)
145
148
146
-
####Array Assignments
149
+
####Array Assignments
147
150
As an example, let's say we want to set a lower limit on a certain central
148
151
abundance as a stopping condition. Then we would, at the minimum, need to set
149
152
the inlist command `xa_central_lower_limit_species(1) = 'h1'`, for example. In MesaScript, there are three ways to do this:
@@ -160,7 +163,7 @@ work:
160
163
I tried to program this functionality in, and the kind people at
161
164
[StackOverflow](http://stackoverflow.com/questions/21036873/how-do-i-write-a-method-to-edit-an-array-hash-using-parentheses-instead-of-squar/21044781?noredirect=1#21044781) kindly but firmly convinced me it was utterly impossible to to with Ruby without writing a parser of my own. Just stick to the bracket syntax or the less natural parentheses/space notations.
162
165
163
-
####Other Details
166
+
####Other Details
164
167
That's really all you need to know to start making inlists with MesaScript,
165
168
though I should remind you, especially if you aren't familiar with Ruby, about
166
169
the basic types of entries you might use. Most inlist commands are one of the
@@ -218,10 +221,10 @@ inlist commands so you don't forget to change a particular command when you
218
221
move on to a different run (like forgetting to change a `LOG_dir`, which I've
219
222
done a few too many times and thus overwritten some data).
220
223
221
-
###Deeper and Deeper...
224
+
###Deeper and Deeper...
222
225
Are you still reading this? Well, you must want to do more.
223
226
224
-
###Using Custom Namelists
227
+
###Using Custom Namelists
225
228
You can also make MesaScript know about additional namelists (or forget about
226
229
the standard three). After requiring the `mesa_script` file, you can change the
227
230
namelists it cares about via the following commands (obviously subbing out any
@@ -252,7 +255,7 @@ That *should* set things up to work with custom namelists, so long as the
252
255
`.inc` and `.defaults` files are formatted more or less the same as the "stock"
253
256
ones.
254
257
255
-
###Accessing Current Values and Displaying Default Values
258
+
###Accessing Current Values and Displaying Default Values
256
259
Perhaps you want to display a default value in your inlist, but not actually
257
260
change it. Well, most of the assignment methods mentioned earlier
258
261
are also getter methods. I haven't mentioned how these methods actually work, so I'll do so now since you're still reading this manifesto.
@@ -297,5 +300,5 @@ Note that these array methods, as indicated, point to hashes (not arrays) of
297
300
values. So `xa_central_lower_limit_species[1] = 'h1'` would return
298
301
`{1 => 'h1'}`.
299
302
300
-
##Further Work
303
+
##Further Work
301
304
I warmly welcome bug reports, feature suggestions, and most all, pull requests!
0 commit comments