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 CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -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 = nt_outfile.get_2d_array_float(options[:header], /1.*time/)
7
- rho_array = nt_outfile.get_2d_array_float(/2.*radius/, /1.*time/)
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[it].to_gslv, title: 'rho', units: ''},
10
- y: {data: array[it].to_gslv, title: options[:title]||"", units: options[:units]||""}
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
- # this module provides easy access to the Trinity textbased output data
6
- # by defining a TextDataFile for every text output file. See the documentation
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
@@ -100,7 +100,7 @@ class CodeRunner
100
100
  get_global_results
101
101
  end
102
102
  #p ['fusionQ is ', fusionQ]
103
- @percent_complete = completed_timesteps / ntstep * 100.0
103
+ @percent_complete = completed_timesteps.to_f / ntstep.to_f * 100.0
104
104
  end
105
105
 
106
106
  def get_status
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "trinitycrmod"
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
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.1
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: 2739372725142217113
154
+ hash: -1326413784735556803
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements: