gryfxcrmod 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem "coderunner", ">= 0.13.0"
6
- gem "gs2crmod", ">= 0.9.9"
6
+ gem "gs2crmod", ">= 0.10.1"
7
7
  gem "ruby-netcdf", ">= 0.6.6"
8
8
 
9
9
  # Add dependencies to develop your gem here.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/gryfxcrmod.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gryfxcrmod"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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"]
12
- s.date = "2013-08-15"
12
+ s.date = "2013-08-19"
13
13
  s.description = "This is a customised subclass of the CodeRunner::Run class which allows CodeRunner to run and analyse the gyrofluid GPU turbulent transport solver Gryfx."
14
14
  s.email = "edmundhighcock@users.sourceforge.net"
15
15
  s.extra_rdoc_files = [
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
 
50
50
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
51
  s.add_runtime_dependency(%q<coderunner>, [">= 0.13.0"])
52
- s.add_runtime_dependency(%q<gs2crmod>, [">= 0.9.9"])
52
+ s.add_runtime_dependency(%q<gs2crmod>, [">= 0.10.1"])
53
53
  s.add_runtime_dependency(%q<ruby-netcdf>, [">= 0.6.6"])
54
54
  s.add_development_dependency(%q<shoulda>, [">= 0"])
55
55
  s.add_development_dependency(%q<shoulda-context>, [">= 1.1.5"])
@@ -58,7 +58,7 @@ Gem::Specification.new do |s|
58
58
  s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
59
59
  else
60
60
  s.add_dependency(%q<coderunner>, [">= 0.13.0"])
61
- s.add_dependency(%q<gs2crmod>, [">= 0.9.9"])
61
+ s.add_dependency(%q<gs2crmod>, [">= 0.10.1"])
62
62
  s.add_dependency(%q<ruby-netcdf>, [">= 0.6.6"])
63
63
  s.add_dependency(%q<shoulda>, [">= 0"])
64
64
  s.add_dependency(%q<shoulda-context>, [">= 1.1.5"])
@@ -68,7 +68,7 @@ Gem::Specification.new do |s|
68
68
  end
69
69
  else
70
70
  s.add_dependency(%q<coderunner>, [">= 0.13.0"])
71
- s.add_dependency(%q<gs2crmod>, [">= 0.9.9"])
71
+ s.add_dependency(%q<gs2crmod>, [">= 0.10.1"])
72
72
  s.add_dependency(%q<ruby-netcdf>, [">= 0.6.6"])
73
73
  s.add_dependency(%q<shoulda>, [">= 0"])
74
74
  s.add_dependency(%q<shoulda-context>, [">= 1.1.5"])
@@ -43,9 +43,22 @@ class CodeRunner
43
43
  name = @run_name
44
44
  name += " (res: #@restart_id)" if @restart_id
45
45
  name += " real_id: #@real_id" if @real_id
46
- beginning = sprintf("%2d:%d %-60s %1s:%2.1f(%s) %3s%1s", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, "%")
46
+ beginning = sprintf("%2d:%d %-60s %1s:%2.1f(%s) %3s%1s ", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, "%")
47
47
  if ctd
48
48
  #beginning += sprintf("Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20", fusionQ, pfus, ti0, te0, ne0)
49
+ if @nonlinear_mode == "off"
50
+ beginning += sprintf("%3.2e %3.2e %4s",
51
+ @fastest_growing_mode, @max_growth_rate,
52
+ @freq_of_max_growth_rate||0.0) rescue ""
53
+ elsif @nonlinear_mode == "on"
54
+ # p @hflux_tot_stav
55
+ beginning += " sat:#{saturated.to_s[0]}" if not @saturated.nil?
56
+ beginning += sprintf(" hflux:%1.2e", @hflux_tot_stav) if @hflux_tot_stav
57
+ beginning += sprintf("+/-%1.2e", @hflux_tot_stav_error) if @hflux_tot_stav_error
58
+ beginning += sprintf(" momflux:%1.2e", @es_mom_flux_stav.values.sum) if @es_mom_flux_stav and @es_mom_flux_stav.values[0]
59
+ beginning += ' SC:' + @spectrum_check.map{|c| c.to_s}.join(',') if @spectrum_check
60
+ beginning += ' VC:' + @vspace_check.map{|c| sprintf("%d", ((c*10.0).to_i rescue -1))}.join(',') if @vspace_check
61
+ end
49
62
  end
50
63
  beginning += " ---#{@comment}" if @comment
51
64
  beginning
@@ -76,6 +89,8 @@ class CodeRunner
76
89
  # This method, as its name suggests, is called whenever CodeRunner is asked to analyse a run directory. This happens if the run status is not :Complete, or if the user has specified recalc_all(-A on the command line) or reprocess_all (-a on the command line).
77
90
  #
78
91
  def process_directory_code_specific
92
+ @grid_option = "box" # For compatibility with the GS2 routines
93
+ @write_phi_over_time = "true" # For compatibility with the GS2 routines
79
94
  get_status
80
95
  #p ['id is', id, 'ctd is ', ctd]
81
96
  if ctd
@@ -89,7 +104,7 @@ class CodeRunner
89
104
  @status = :Incomplete
90
105
  else
91
106
  get_completed_timesteps
92
- if percent_complete = 100.0*@completed_timesteps.to_f/(nstep/nwrite) > 5.0
107
+ if (@percent_complete = 100.0*@completed_timesteps.to_f/(nstep/nwrite)) > 5.0
93
108
  @status = :Complete
94
109
  else
95
110
  @status = :Failed
@@ -109,8 +124,49 @@ class CodeRunner
109
124
  @directory + '/' + @run_name + '.cdf'
110
125
  end
111
126
 
112
- def calculate_results
127
+ #def calculate_results
128
+ #end
129
+
130
+ def calculate_frequencies
131
+ @real_frequencies = FloatHash.new
132
+ end
133
+
134
+ def gryfx?
135
+ true
113
136
  end
114
137
 
138
+
139
+ def geometric_factors_gsl_tensor(options)
140
+ theta_vec = gsl_vector(:theta, options)
141
+ factors = GSL::Tensor.alloc(6,theta_vec.size)
142
+ values = [:Rplot, :Zplot, :aplot, :Rprime, :Zprime, :aprime].map do |name|
143
+ arr = netcdf_file.var(name).get.to_a
144
+ if options[:periodic]
145
+ arr += [arr[0]]
146
+ end
147
+ arr
148
+ end
149
+ #ep values
150
+ shape = factors.shape
151
+ for i in 0...shape[0]
152
+ unless options[:interpolate_theta]
153
+ for j in 0...shape[1]
154
+ factors[i,j] = values[i][j]
155
+ end
156
+ else
157
+ opts = options.dup
158
+ opts[:interpolate_theta] = nil
159
+ opts[:thetamax] = opts[:thetamin] = nil
160
+ theta_vec_short = gsl_vector(:theta, opts)
161
+ #p 'sizes', [theta_vec_short.size, values[i].to_gslv.size]
162
+ interp = GSL::ScatterInterp.alloc(:cubic, [theta_vec_short, values[i].to_gslv], true, [3.0].to_gslv)
163
+ for j in 0...theta_vec.size
164
+ factors[i,j] = interp.eval(theta_vec[j])
165
+ end
166
+ end
167
+ end
168
+ #ep factors
169
+ return factors
170
+ end
115
171
  end
116
172
  end
Binary file
@@ -27,11 +27,13 @@ if ENV['GRYFX_EXEC']
27
27
  FileUtils.rm(tfolder + '/v/id_1/.code_runner_run_data')
28
28
  FileUtils.rm(tfolder + '/v/id_1/code_runner_results.rb')
29
29
  ## Don't uncomment the line below unless you *really* know what you are doing! Replacing the test archive will break many of the tests
30
- Dir.chdir('test'){system "tar -czf cyclone_miller_ke.tgz cyclone_miller_ke/" unless FileTest.exist?('cyclone_miller_ke.tgz')}
30
+ Dir.chdir('test'){system "rm cyclone_miller_ke.tgz; tar -czf cyclone_miller_ke.tgz cyclone_miller_ke/" unless FileTest.exist?('cyclone_miller_ke.tgz')}
31
+ #Dir.chdir('test'){system "rm cyclone_miller_ke.tgz; tar -czf cyclone_miller_ke.tgz cyclone_miller_ke/"} #unless FileTest.exist?('cyclone_miller_ke.tgz')}
31
32
  FileUtils.rm_r(tfolder)
32
33
  end
33
34
  def test_submission
34
35
  CodeRunner.submit(T: false, C: 'gryfx', X: ENV['GRYFX_EXEC'], D: 'test_gryfxcrmod', n: '1', Y: tfolder, p: '{}')
36
+ CodeRunner.submit(T: false, C: 'gryfx', X: ENV['GRYFX_EXEC'], D: 'test_gryfxcrmod', n: '1', Y: tfolder, p: '{nstep: 7000, init_amp: 0.5, nonlinear_mode: "on"}')
35
37
  CodeRunner::Gryfx.diff_input_files(tfolder + '/v/id_1/v_id_1.in', 'test/cyclone_miller_ke.in')
36
38
  CodeRunner.status(Y: tfolder)
37
39
  end
@@ -44,16 +46,33 @@ end
44
46
  class TestAnalysis < Test::Unit::TestCase
45
47
  def setup
46
48
  Dir.chdir('test'){assert(system "tar -xzf cyclone_miller_ke.tgz")}
49
+ CodeRunner.run_command('ctaf', j: 2, Y: tfolder)
47
50
  @runner = CodeRunner.fetch_runner(Y: tfolder)
48
51
  @run = @runner.run_list[1]
49
52
  end
50
53
  def test_analysis
51
54
  CodeRunner.status(Y: tfolder)
52
- assert_equal(1, @runner.run_list.size)
53
- #assert_equal(0.13066732664774272, @runner.run_list[1].max_growth_rate)
55
+ assert_equal(2, @runner.run_list.size)
56
+ assert_equal(0.129, @runner.run_list[1].max_growth_rate.round(3))
57
+ assert_equal(2.0, (@runner.run_list[2].hflux_tot_stav/1.0e4).round(0))
54
58
  #assert_equal(0.13066732664774272, @runner.run_list[1].growth_rate_at_ky[0.5])
55
59
  #assert_equal(:Complete, @runner.run_list[1].status)
56
60
  end
61
+ def test_graphs
62
+ kit = @run.graphkit('phi2_by_ky_vs_time', {ky_index: :all})
63
+ kit.gp.logscale = "y"
64
+ #kit.gnuplot
65
+ kit = @run.graphkit('phi_real_space_surface', {n0: 2})
66
+ assert_equal(6, kit.data.size)
67
+ #kit.gnuplot
68
+ kit = @run.graphkit('phi_real_space_poloidal_plane', {n0: 2, interpolate_theta: 16, interpolate_x: 4, torphi: 0.0})
69
+ kit.gp.view = ["equal xyz", "90,0,3"]
70
+ assert_equal(2, kit.data[0].y.data.shape.size)
71
+ assert_equal(177, kit.data[0].y.data.shape[1])
72
+
73
+ #kit.gnuplot
74
+
75
+ end
57
76
  def tfolder
58
77
  'test/cyclone_miller_ke'
59
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gryfxcrmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-15 00:00:00.000000000 Z
12
+ date: 2013-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coderunner
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.9.9
37
+ version: 0.10.1
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.9.9
45
+ version: 0.10.1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: ruby-netcdf
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  segments:
185
185
  - 0
186
- hash: -2691510310459698350
186
+ hash: 1954477338330875732
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements: