mesa_script 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -14
- data/lib/mesa_script.rb +41 -6
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7396508a25fdc1adcf8e7844ce0fe074e2ba9fa8a44e4eb72d15d1a44ef5c185
|
4
|
+
data.tar.gz: 9b71c2c407c51744b0061b89f2a1072f9274caab29ca3f998b01e6d5723533a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3540df671b3609627cff42f20ca156e2238f15c548f660ad365ecc7c539f3c3e1c09fc076d1b385434b9d04218968aead29bde765477f86cbcacf48a9913ff55
|
7
|
+
data.tar.gz: 5fa0b3ffde490b83340a25a5f6dbb983b2e9aab6b7234e9bb2c3fb9c2e82a8489407de133e38a8fbcc47ac5560300fd933d06529e128ed1628e1c453dc13a87a
|
data/README.md
CHANGED
@@ -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!
|
data/lib/mesa_script.rb
CHANGED
@@ -5,14 +5,20 @@ def namelist_sym(namelist)
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class Inlist
|
8
|
+
|
9
|
+
# check if this version came from a github repository (newer than 15140)
|
10
|
+
def self.version_is_git?
|
11
|
+
File.exist?(File.join(ENV['MESA_DIR'], '.gitignore')) or File.exist?(File.join(ENV['MESA_DIR'], '.github'))
|
12
|
+
end
|
13
|
+
|
8
14
|
# Get access to current MESA version.
|
9
15
|
def self.version
|
10
|
-
IO.read(File.join(ENV['MESA_DIR'], 'data', 'version_number')).
|
16
|
+
IO.read(File.join(ENV['MESA_DIR'], 'data', 'version_number')).sub('.', '').sub('r', '')
|
11
17
|
end
|
12
18
|
|
13
19
|
# Determine proper file suffix for fortran source
|
14
20
|
def self.f_end
|
15
|
-
if Inlist.version >= 7380
|
21
|
+
if Inlist.version_is_git? || Inlist.version.to_i >= 7380
|
16
22
|
'f90'
|
17
23
|
else
|
18
24
|
'f'
|
@@ -21,7 +27,7 @@ class Inlist
|
|
21
27
|
|
22
28
|
# Determine proper file location for star-related .inc files
|
23
29
|
def self.star_or_star_data
|
24
|
-
if Inlist.version >= 12245
|
30
|
+
if Inlist.version_is_git? || Inlist.version.to_i >= 12245
|
25
31
|
'star_data'
|
26
32
|
else
|
27
33
|
'star'
|
@@ -160,6 +166,30 @@ class Inlist
|
|
160
166
|
)
|
161
167
|
end
|
162
168
|
|
169
|
+
# short hand for adding kap namelist using sensible defaults as of 22.11.1
|
170
|
+
def self.add_kap_defaults(verbose: false)
|
171
|
+
config_namelist(
|
172
|
+
namelist: :kap,
|
173
|
+
source_files: [File.join(ENV['MESA_DIR'], 'kap', 'private',
|
174
|
+
"kap_ctrls_io.#{f_end}")],
|
175
|
+
defaults_file: File.join(ENV['MESA_DIR'], 'kap', 'defaults',
|
176
|
+
'kap.defaults'),
|
177
|
+
verbose: verbose
|
178
|
+
)
|
179
|
+
end
|
180
|
+
|
181
|
+
# short hand for adding eos namelist using sensible defaults as of 22.11.1
|
182
|
+
def self.add_eos_defaults(verbose: false)
|
183
|
+
config_namelist(
|
184
|
+
namelist: :eos,
|
185
|
+
source_files: [File.join(ENV['MESA_DIR'], 'eos', 'private',
|
186
|
+
"eos_ctrls_io.#{f_end}")],
|
187
|
+
defaults_file: File.join(ENV['MESA_DIR'], 'eos', 'defaults',
|
188
|
+
'eos.defaults'),
|
189
|
+
verbose: verbose
|
190
|
+
)
|
191
|
+
end
|
192
|
+
|
163
193
|
# short hand for adding pgstar namelist using sensible defaults as of 10108
|
164
194
|
def self.add_pgstar_defaults(verbose: false)
|
165
195
|
config_namelist(
|
@@ -198,10 +228,14 @@ class Inlist
|
|
198
228
|
)
|
199
229
|
end
|
200
230
|
|
201
|
-
# quickly add all three major namelists for star
|
202
|
-
# and pgstar)
|
231
|
+
# quickly add all five (three for older versions) major namelists for star
|
232
|
+
# module (star_job, controls, and pgstar)
|
203
233
|
def self.add_star_defaults
|
204
234
|
add_star_job_defaults
|
235
|
+
if Inlist.version_is_git? || Inlist.version.to_i > 15140
|
236
|
+
add_kap_defaults
|
237
|
+
add_eos_defaults
|
238
|
+
end
|
205
239
|
add_controls_defaults
|
206
240
|
add_pgstar_defaults
|
207
241
|
end
|
@@ -656,6 +690,7 @@ class Inlist
|
|
656
690
|
line.split('::').map(&:strip)
|
657
691
|
end
|
658
692
|
pairs.each do |pair|
|
693
|
+
next if pair[0] == 'public'
|
659
694
|
type = case pair[0]
|
660
695
|
when /logical/ then :bool
|
661
696
|
when /character/ then :string
|
@@ -663,7 +698,7 @@ class Inlist
|
|
663
698
|
when /integer/ then :int
|
664
699
|
when /type/ then :type
|
665
700
|
else
|
666
|
-
raise "Couldn't determine type of entry #{pair[0]} in " \
|
701
|
+
raise "Couldn't determine type of entry \"#{pair[0]}\" in " \
|
667
702
|
"#{source_file}."
|
668
703
|
end
|
669
704
|
name_chars = pair[1].split('')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mesa_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Wolf
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: MesaScript - a DSL for making dynamic inlists for the MESA stellar evolution
|
14
14
|
code.
|
@@ -25,7 +25,7 @@ homepage: https://billwolf.space/MesaScript/
|
|
25
25
|
licenses:
|
26
26
|
- MIT
|
27
27
|
metadata: {}
|
28
|
-
post_install_message:
|
28
|
+
post_install_message:
|
29
29
|
rdoc_options: []
|
30
30
|
require_paths:
|
31
31
|
- lib
|
@@ -40,14 +40,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
rubygems_version: 3.
|
44
|
-
signing_key:
|
43
|
+
rubygems_version: 3.4.12
|
44
|
+
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: MesaScript is a domain specific language (DSL) that allows the user to write
|
47
47
|
inlists for MESA that include variables, loops, conditionals, etc. For more detailed
|
48
48
|
instructions, see the readme on the github page at https://github.com/wmwolf/MesaScript This
|
49
49
|
software requires a relatively modern installation of MESA (version > 5596). It
|
50
|
-
has been tested on Ruby versions > 1.9, but there is no guarantee
|
51
|
-
older (or newer!) versions. Any bugs or requests should be
|
52
|
-
|
50
|
+
has been tested on Ruby versions > 1.9 and up to 3.2, but there is no guarantee
|
51
|
+
it will work on older (or newer!) versions. Any bugs or requests should be reported
|
52
|
+
to the github repository.
|
53
53
|
test_files: []
|