trinitycrmod 0.2.1 → 0.2.2
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.
- data/VERSION +1 -1
- data/lib/trinitycrmod/graphs.rb +27 -4
- data/lib/trinitycrmod/output_files.rb +9 -2
- data/lib/trinitycrmod/trinity.rb +1 -1
- data/test/test_trinitycrmod.rb +5 -0
- data/trinitycrmod.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/trinitycrmod/graphs.rb
CHANGED
@@ -1,18 +1,41 @@
|
|
1
1
|
class CodeRunner::Trinity
|
2
2
|
module TrinityGraphKits
|
3
|
+
# Graphs plotting quantities from the '.nt' file vs rho for a given t_index
|
3
4
|
def nt_prof_graphkit(options)
|
5
|
+
prof_graphkit(options.dup.absorb({outfile: nt_outfile}))
|
6
|
+
end
|
7
|
+
# Graphs plotting quantities from the '.fluxes' file vs rho for a given t_index
|
8
|
+
def fluxes_prof_graphkit(options)
|
9
|
+
prof_graphkit(options.dup.absorb({outfile: fluxes_outfile, exclude_perturbed_fluxes: true}))
|
10
|
+
end
|
11
|
+
def prof_graphkit(options)
|
4
12
|
raise "Please specify t_index" unless options[:t_index]
|
5
13
|
it = options[:t_index] - 1
|
6
|
-
array =
|
7
|
-
rho_array =
|
14
|
+
array = options[:outfile].get_2d_array_float(options[:header], /1.*time/)[it]
|
15
|
+
rho_array = options[:outfile].get_2d_array_float(/2.*radius/, /1.*time/)[it]
|
16
|
+
if options[:exclude_perturbed_fluxes]
|
17
|
+
s = array.size
|
18
|
+
array = array.slice(0...nrad-1)
|
19
|
+
rho_array = rho_array.slice(0...nrad-1)
|
20
|
+
end
|
8
21
|
#p rho_array, array
|
9
|
-
GraphKit.autocreate(x: {data: rho_array
|
10
|
-
y: {data: array
|
22
|
+
GraphKit.autocreate(x: {data: rho_array.to_gslv, title: 'rho', units: ''},
|
23
|
+
y: {data: array.to_gslv, title: options[:title]||"", units: options[:units]||""}
|
11
24
|
)
|
12
25
|
end
|
26
|
+
# Graph of Qi in gyroBohm units against rho for a given t_index
|
27
|
+
def ion_hflux_gb_prof_graphkit(options)
|
28
|
+
fluxes_prof_graphkit(options.dup.absorb({header: /Qi.*\(GB/, title: 'Ion Heat Flux', units: 'Q_gB'}))
|
29
|
+
end
|
30
|
+
# Graph of toroidal angular momentum flux in gyroBohm units against rho for a given t_index
|
31
|
+
def lflux_gb_prof_graphkit(options)
|
32
|
+
fluxes_prof_graphkit(options.dup.absorb({header: /Pi.*\(GB/, title: 'Toroidal Angular Momentum Flux', units: 'Pi_gB'}))
|
33
|
+
end
|
34
|
+
# Graph of toroidal angular momentum against rho for a given t_index
|
13
35
|
def ang_mom_prof_graphkit(options)
|
14
36
|
return nt_prof_graphkit(options.dup.absorb({header: /ang\s+mom/, title: 'Angular Momentum', units: ''}))
|
15
37
|
end
|
38
|
+
# Graph of Ti against rho for a given t_index
|
16
39
|
def ion_temp_prof_graphkit(options)
|
17
40
|
return nt_prof_graphkit(options.dup.absorb({header: /i\+ temp/, title: 'Ti', units: 'keV'}))
|
18
41
|
end
|
@@ -2,13 +2,20 @@ require 'text-data-tools'
|
|
2
2
|
|
3
3
|
class CodeRunner
|
4
4
|
class Trinity
|
5
|
-
#
|
6
|
-
# by defining a
|
5
|
+
# This module provides easy access to the Trinity textbased output data
|
6
|
+
# by defining a TextDataTools::Named::DataFile or TextDataTools::Column::DataFile
|
7
|
+
# for every text output file. See the documentation
|
7
8
|
# for TextDataTools for more information.
|
8
9
|
module OutputFiles
|
10
|
+
# File ending in '.info': contains global results.
|
9
11
|
def info_outfile
|
10
12
|
TextDataTools::Named::DataFile.new(@directory + '/' + @run_name + '.info', ':')
|
11
13
|
end
|
14
|
+
# File ending in '.fluxes': contains heat flux, momentum flux etc.
|
15
|
+
def fluxes_outfile
|
16
|
+
TextDataTools::Column::DataFile.new(@directory + '/' + @run_name + '.fluxes', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
|
17
|
+
end
|
18
|
+
# File ending in '.nt': contains profiles: Ti, Te etc.
|
12
19
|
def nt_outfile
|
13
20
|
TextDataTools::Column::DataFile.new(@directory + '/' + @run_name + '.nt', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
|
14
21
|
end
|
data/lib/trinitycrmod/trinity.rb
CHANGED
data/test/test_trinitycrmod.rb
CHANGED
@@ -44,6 +44,11 @@ class TestTrinitycrmodIFSPPPLAnalysis < Test::Unit::TestCase
|
|
44
44
|
#kit.gnuplot
|
45
45
|
assert_equal(kit.data[0].class, GraphKit::DataKit)
|
46
46
|
assert_equal(kit.data[0].x.data[0], 0.05)
|
47
|
+
kit = @runner.run_list[1].graphkit('ion_hflux_gb_prof', {t_index: 2})
|
48
|
+
#kit.gnuplot
|
49
|
+
assert_equal(kit.data[0].class, GraphKit::DataKit)
|
50
|
+
assert_equal(8,kit.data[0].y.data.size)
|
51
|
+
assert_equal(kit.data[0].y.data[0], 0.001944)
|
47
52
|
end
|
48
53
|
def teardown
|
49
54
|
FileUtils.rm('test/ifspppl_results/.code_runner_script_defaults.rb')
|
data/trinitycrmod.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinitycrmod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
segments:
|
153
153
|
- 0
|
154
|
-
hash:
|
154
|
+
hash: -1326413784735556803
|
155
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
156
|
none: false
|
157
157
|
requirements:
|