gs2crmod 0.11.45 → 0.11.46

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.45
1
+ 0.11.46
data/gs2crmod.gemspec CHANGED
@@ -2,17 +2,14 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: gs2crmod 0.11.45 ruby lib
6
- # stub: ext/extconf.rb
7
5
 
8
6
  Gem::Specification.new do |s|
9
7
  s.name = "gs2crmod"
10
- s.version = "0.11.45"
8
+ s.version = "0.11.46"
11
9
 
12
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
- s.require_paths = ["lib"]
14
11
  s.authors = ["Edmund Highcock", "Ferdinand van Wyk"]
15
- s.date = "2014-03-27"
12
+ s.date = "2014-04-07"
16
13
  s.description = "GS2 is a gyrokinetic flux tube initial value turbulence code which can be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated running and analysis of large simulations. This module allows GS2 (and its sister code AstroGK) to harness the power of the CodeRunner framework."
17
14
  s.email = "edmundhighcock@sourceforge.net"
18
15
  s.extensions = ["ext/extconf.rb"]
@@ -85,12 +82,13 @@ Gem::Specification.new do |s|
85
82
  ]
86
83
  s.homepage = "http://gs2crmod.sourceforge.net"
87
84
  s.licenses = ["GSLv3"]
85
+ s.require_paths = ["lib"]
88
86
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
89
- s.rubygems_version = "2.2.1"
87
+ s.rubygems_version = "1.8.11"
90
88
  s.summary = "Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes."
91
89
 
92
90
  if s.respond_to? :specification_version then
93
- s.specification_version = 4
91
+ s.specification_version = 3
94
92
 
95
93
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
96
94
  s.add_runtime_dependency(%q<coderunner>, [">= 0.14.10"])
@@ -996,7 +996,7 @@ module GraphKits
996
996
  when :help
997
997
  return "The potential as a function of cartesian coordinates showing a cut at one toroidal angle, with multiple periodic copies of the flux tube used to fill the whole circle.."
998
998
  when :options
999
- return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :xmax, :xmin, :thetamax, :thetamin, :torphi]
999
+ return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :xmax, :xmin, :thetamax, :thetamin, :torphi, :constant_torphi, :no_flux_tube_copies]
1000
1000
  else
1001
1001
  #if options[:ncopies]
1002
1002
  #ops = options.dup
data/lib/gs2crmod/gs2.rb CHANGED
@@ -1250,6 +1250,144 @@ end
1250
1250
  '.in'
1251
1251
  end
1252
1252
 
1253
+ #This function will interpolate and output either phi or density at the outboard midplane
1254
+ #on a 40x40 grid appropriate to analyse as experimental data. It called as a run_command
1255
+ #e.g. rc 'bes_output(options)', j:<run number>. It will call field_real_space_poloidal_plane_graphkit
1256
+ #for every time step, interpolate at outboard midplane, and write fields and grids out to NetCDF file.
1257
+ #
1258
+ #Options: Same as field_real_space_poloidal_plane, field name must also be specified for generality. New options:
1259
+ #
1260
+ # no_flux_tube_copies: ensures only one flux tube is printed out with zeroes everywhere else.
1261
+ # amin: Minor radius (to which R,Z are normalized) so that grid is in right units
1262
+ # output_box_size: Array of sizes of output box (in units of amin) either side of middle of fluxtube at outboard midplane
1263
+ # in R direction and either side of outboard midplane in Z direction.
1264
+ # output_box_points: Array of number of points in output box (R,Z). Default will be 50x50.
1265
+ #
1266
+ #The interpolation routine used will only interpolate correctly inside the fluxtube and produce garbage outside. Regular points are checked
1267
+ #for being inside or outside the fluxtube and values of the field outside the fluxtube are set to zero.
1268
+ def bes_output(options={})
1269
+ #******************
1270
+ # Read in options *
1271
+ #******************
1272
+ #In order to interpolate on constant grids, ensure constant_torphi is set to some value (default 0.0)
1273
+ if options[:constant_torphi] == nil
1274
+ p 'constant_torphi not set! Setting it to 0.0.'
1275
+ options[:constant_torphi] = 0.0
1276
+ end
1277
+ #Check whether t_index_window is specified, if not, set to entire t range
1278
+ if options[:t_index_window] == nil
1279
+ t_index_beg = 1
1280
+ t_index_end = gsl_vector(:t).length
1281
+ else
1282
+ t_index_beg = options[:t_index_window][0]
1283
+ t_index_end = options[:t_index_window][1]
1284
+ end
1285
+ if options[:amin] == nil
1286
+ amin = 1.0
1287
+ else
1288
+ amin = options[:amin]
1289
+ end
1290
+ if options[:output_box_size] and options[:output_box_size].kind_of?Array
1291
+ r_box_size = options[:output_box_size][0]
1292
+ z_box_size = options[:output_box_size][1]
1293
+ else
1294
+ raise 'Option output_box_size must be specified (in units of amin) and must be an Array.'
1295
+ end
1296
+ if options[:output_box_points] and options[:output_box_points].kind_of?Array
1297
+ r_box_pts = options[:output_box_points][0]
1298
+ z_box_pts = options[:output_box_points][1]
1299
+ else
1300
+ r_box_pts = 50
1301
+ z_box_pts = 50
1302
+ end
1303
+
1304
+ #Call at first time step to set up arrays and grids
1305
+ options[:t_index] = t_index_beg
1306
+ kit = field_real_space_poloidal_plane_graphkit(options)
1307
+ x = kit.data[0].x.data
1308
+ y = kit.data[0].y.data
1309
+ z = kit.data[0].z.data
1310
+
1311
+ #Set up NetCDf file
1312
+ file = NumRu::NetCDF.create(@run_name + "_bes_output.nc")
1313
+ xdim = file.def_dim('y', x.shape[0])
1314
+ zdim = file.def_dim('z', z.shape[1])
1315
+ tdim = file.def_dim('t', 0) #zero means unlimited
1316
+ x_var = file.def_var("x", 'sfloat', [xdim, zdim])
1317
+ z_var = file.def_var("z", 'sfloat', [xdim, zdim])
1318
+ t_var = file.def_var("t", 'sfloat', [tdim])
1319
+ field_var = file.def_var("field", 'sfloat', [xdim, zdim, tdim])
1320
+ file.enddef
1321
+ #Write dimensions to file
1322
+ x_var.put(NArray.to_na(x.to_a))
1323
+ z_var.put(NArray.to_na(z.to_a))
1324
+
1325
+ #Loop over time, load field as function of space at each time index, write to file
1326
+ for i in t_index_beg...t_index_end #inclusive of end
1327
+ Terminal.erewind(1) #go back one line in terminal
1328
+ eputs sprintf("Writing time index = %d of %d#{Terminal::CLEAR_LINE}", i, t_index_end-t_index_beg+1) #clear line and print time index
1329
+ options[:t_index] = i
1330
+ kit = field_real_space_poloidal_plane_graphkit(options)
1331
+ t_var.put(gsl_vector(:t)[i], 'index'=>[i-t_index_beg]) #Write time to unlimited time NetCDF variable
1332
+ field_var.put(NArray.to_na((kit.data[0].f.data).to_a), 'start'=>[0,0,i-t_index_beg], 'end'=>[-1,-1,i-t_index_beg])
1333
+ end
1334
+ file.close
1335
+
1336
+ #Ignore this until interpolation issue is sorted
1337
+ =begin
1338
+ #**************************
1339
+ # Set up new regular grid *
1340
+ #**************************
1341
+ th_grid_size = x.shape[1]
1342
+ flux_tube_midpt = x[0, (th_grid_size-1)/2] + (x[-1, (th_grid_size-1)/2] - x[1, (th_grid_size-1)/2])/2
1343
+ x_vec_reg = GSL::Vector.linspace(flux_tube_midpt - r_box_size, flux_tube_midpt + r_box_size, r_box_pts)
1344
+ z_vec_reg = GSL::Vector.linspace(-z_box_size, z_box_size, z_box_pts)
1345
+ x_reg = GSL::Matrix.alloc(r_box_pts, z_box_pts)
1346
+ z_reg = GSL::Matrix.alloc(r_box_pts, z_box_pts)
1347
+ field_reg = GSL::Matrix.alloc(r_box_pts, z_box_pts)
1348
+ for i in 0...r_box_pts
1349
+ for j in 0...z_box_pts
1350
+ x_reg[i,j] = x_vec_reg[i]
1351
+ z_reg[i,j] = z_vec_reg[j]
1352
+ end
1353
+ end
1354
+
1355
+ #************************************************
1356
+ # Find the field at every point on regular grid *
1357
+ #************************************************
1358
+ #To evaluate field on a regular grid given the field on an irregular grid, need to interpolate. The rubygem
1359
+ #gsl_extras contains an interpolation routine called ScatterInterp which does exactly this based on a
1360
+ #'Radial Basis Function' method.
1361
+
1362
+ #Have R, Z, and field on an irregular grid in the form of matrices. ScatterInterp only takes in GSL vectors
1363
+ #so simply convert these matrices to vectors (of size row*col) since the order of the pts don't matter.
1364
+ x_vec = GSL::Vector.alloc(x.shape[0]*x.shape[1])
1365
+ z_vec = GSL::Vector.alloc(x.shape[0]*x.shape[1])
1366
+ field_vec = GSL::Vector.alloc(x.shape[0]*x.shape[1])
1367
+ for i in 0...x.shape[0]
1368
+ for j in 0...x.shape[1]
1369
+ x_vec[x.shape[1]*i + j] = x[i,j]
1370
+ z_vec[x.shape[1]*i + j] = z[i,j]
1371
+ field_vec[x.shape[1]*i + j] = field[i,j]
1372
+ end
1373
+ end
1374
+
1375
+ #Now pass these vectors to ScatterInterp. This creates an object with instance method 'eval' which can be given an x,z coord
1376
+ #at which to evaluate the interpolated function.
1377
+ p 'Interpolating'
1378
+ interp = GSL::ScatterInterp.alloc(:linear, [x_vec, z_vec, field_vec], false, r0=0.1)
1379
+ p 'Finished interpolating'
1380
+ for i in 0...x_vec_reg.size
1381
+ for j in 0...z_vec_reg.size
1382
+ field_reg[i,j] = interp.eval(x_vec_reg[i], z_vec_reg[j])
1383
+ end
1384
+ end
1385
+
1386
+ kit = GraphKit.quick_create([x_vec_reg, z_vec_reg, field_reg])
1387
+ #kit2 = GraphKit.quick_create([x_vec, z_vec, field_vec])
1388
+ =end
1389
+
1390
+ end
1253
1391
  end # class GS2
1254
1392
  # For backwards compatibility
1255
1393
 
@@ -396,7 +396,7 @@ class CodeRunner::Gs2
396
396
  opts = options.dup
397
397
  opts[:interpolate_theta] = nil
398
398
  theta_vec_short = gsl_vector(:theta, {})
399
- p 'sizes', [theta_vec_short.size, values[i+1].to_gslv.size]
399
+ #p 'sizes', [theta_vec_short.size, values[i+1].to_gslv.size]
400
400
  interp = GSL::ScatterInterp.alloc(:linear, [theta_vec_short, values[i+1].to_gslv], true)
401
401
  for j in 0...theta_vec.size
402
402
  factors[i,j] = interp.eval(theta_vec[j])
@@ -71,6 +71,9 @@ class TestAnalysis < Test::Unit::TestCase
71
71
  corr_file = NumRu::NetCDF.open("#{tfolder}/v/id_1/v_write_moments_.true._write_line_.true._id_1_correlation_analysis_full.nc")
72
72
  corr_function = corr_file.var('correlation').get
73
73
  assert_equal([4,4,4,25], corr_function.shape)
74
+
75
+ #BES output test
76
+ CodeRunner.run_command('bes_output(field_name:"density", n0:1, Rgeo:3, species_index:1, no_flux_tube_copies:true, torphi:0.0, constant_torphi:0.0, output_box_size:[0.05, 0.1], output_box_points:[10,10], t_index_window:[1,10])', {j:1, Y:tfolder})
74
77
  end
75
78
  def test_interpolation
76
79
  assert_equal(5, @run.gsl_vector('kx').size)
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gs2crmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.45
4
+ version: 0.11.46
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Edmund Highcock
@@ -9,106 +10,85 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-03-27 00:00:00.000000000 Z
13
+ date: 2014-04-07 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: coderunner
16
- requirement: !ruby/object:Gem::Requirement
17
+ requirement: &17224740 !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - ">="
20
+ - - ! '>='
19
21
  - !ruby/object:Gem::Version
20
22
  version: 0.14.10
21
23
  type: :runtime
22
24
  prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: 0.14.10
25
+ version_requirements: *17224740
28
26
  - !ruby/object:Gem::Dependency
29
27
  name: rubyhacks
30
- requirement: !ruby/object:Gem::Requirement
28
+ requirement: &17224160 !ruby/object:Gem::Requirement
29
+ none: false
31
30
  requirements:
32
- - - ">="
31
+ - - ! '>='
33
32
  - !ruby/object:Gem::Version
34
33
  version: 0.1.2
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: 0.1.2
36
+ version_requirements: *17224160
42
37
  - !ruby/object:Gem::Dependency
43
38
  name: ruby-netcdf-updated
44
- requirement: !ruby/object:Gem::Requirement
39
+ requirement: &17223520 !ruby/object:Gem::Requirement
40
+ none: false
45
41
  requirements:
46
- - - ">="
42
+ - - ! '>='
47
43
  - !ruby/object:Gem::Version
48
44
  version: 0.6.6.1
49
45
  type: :runtime
50
46
  prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 0.6.6.1
47
+ version_requirements: *17223520
56
48
  - !ruby/object:Gem::Dependency
57
49
  name: shoulda
58
- requirement: !ruby/object:Gem::Requirement
50
+ requirement: &17222980 !ruby/object:Gem::Requirement
51
+ none: false
59
52
  requirements:
60
- - - ">="
53
+ - - ! '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  type: :development
64
57
  prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
58
+ version_requirements: *17222980
70
59
  - !ruby/object:Gem::Dependency
71
60
  name: rdoc
72
- requirement: !ruby/object:Gem::Requirement
61
+ requirement: &17222180 !ruby/object:Gem::Requirement
62
+ none: false
73
63
  requirements:
74
- - - "~>"
64
+ - - ~>
75
65
  - !ruby/object:Gem::Version
76
66
  version: '3.12'
77
67
  type: :development
78
68
  prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '3.12'
69
+ version_requirements: *17222180
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: bundler
86
- requirement: !ruby/object:Gem::Requirement
72
+ requirement: &17302140 !ruby/object:Gem::Requirement
73
+ none: false
87
74
  requirements:
88
- - - ">"
75
+ - - ! '>'
89
76
  - !ruby/object:Gem::Version
90
77
  version: 1.0.0
91
78
  type: :development
92
79
  prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">"
96
- - !ruby/object:Gem::Version
97
- version: 1.0.0
80
+ version_requirements: *17302140
98
81
  - !ruby/object:Gem::Dependency
99
82
  name: jeweler
100
- requirement: !ruby/object:Gem::Requirement
83
+ requirement: &17300100 !ruby/object:Gem::Requirement
84
+ none: false
101
85
  requirements:
102
- - - ">="
86
+ - - ! '>='
103
87
  - !ruby/object:Gem::Version
104
88
  version: 1.8.4
105
89
  type: :development
106
90
  prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: 1.8.4
91
+ version_requirements: *17300100
112
92
  description: GS2 is a gyrokinetic flux tube initial value turbulence code which can
113
93
  be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated
114
94
  running and analysis of large simulations. This module allows GS2 (and its sister
@@ -122,7 +102,7 @@ extra_rdoc_files:
122
102
  - README.md
123
103
  - README.rdoc
124
104
  files:
125
- - ".document"
105
+ - .document
126
106
  - Gemfile
127
107
  - LICENSE.txt
128
108
  - README.md
@@ -185,25 +165,26 @@ files:
185
165
  homepage: http://gs2crmod.sourceforge.net
186
166
  licenses:
187
167
  - GSLv3
188
- metadata: {}
189
168
  post_install_message:
190
169
  rdoc_options: []
191
170
  require_paths:
192
171
  - lib
193
172
  required_ruby_version: !ruby/object:Gem::Requirement
173
+ none: false
194
174
  requirements:
195
- - - ">="
175
+ - - ! '>='
196
176
  - !ruby/object:Gem::Version
197
177
  version: 1.9.1
198
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
+ none: false
199
180
  requirements:
200
- - - ">="
181
+ - - ! '>='
201
182
  - !ruby/object:Gem::Version
202
183
  version: '0'
203
184
  requirements: []
204
185
  rubyforge_project:
205
- rubygems_version: 2.2.1
186
+ rubygems_version: 1.8.11
206
187
  signing_key:
207
- specification_version: 4
188
+ specification_version: 3
208
189
  summary: Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.
209
190
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 357729508f2ef9c91e16109da5a3de819a86b0dc
4
- data.tar.gz: a75eb30afeb7a17ab25b763c044625dea60b3d34
5
- SHA512:
6
- metadata.gz: e7eb5852bde6e6d394967093abde675dc8cb1ee6399b0c95aee113e6fdc745d6ad7c23d4ec4b9a3a81738d9ba603f4a572d8139bec81c747f64933df0d95664a
7
- data.tar.gz: c33b874e7e861392dc8f43fba04977a701776377d721ddec6c6934598b26fcf4c7478107e89a61ea7a510bd2ece43785719e528bce098ef78a2f6ea77cda6ed0