gs2crmod 0.12.11 → 0.12.12

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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/VERSION +1 -1
  3. data/gs2crmod.gemspec +7 -5
  4. data/lib/gs2crmod/gs2.rb +55 -58
  5. metadata +22 -40
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61537cc35dd202107beff6badd6a604b13052f65
4
+ data.tar.gz: 7c55bbdc2056518ba85a929c2e097f4f71b79ceb
5
+ SHA512:
6
+ metadata.gz: c595a7a35633a1b63b897760c2839e2c65b601efadf53af5112f6129530282c0c11f6eb918d427649ace1ce3bbea63ee6c0c9c0f6459459a1344706038223710
7
+ data.tar.gz: 246a78bc1351ba02fc936109ef48a7fb8c381c96248a7e891e742db6457ac971b096593d22f327ace84e844bc50af1aacc36574b4d30b0593ad8d7461c373aa9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.11
1
+ 0.12.12
data/gs2crmod.gemspec CHANGED
@@ -2,14 +2,17 @@
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.12.12 ruby lib
6
+ # stub: ext/extconf.rb
5
7
 
6
8
  Gem::Specification.new do |s|
7
9
  s.name = "gs2crmod"
8
- s.version = "0.12.11"
10
+ s.version = "0.12.12"
9
11
 
10
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
+ s.require_paths = ["lib"]
11
14
  s.authors = ["Edmund Highcock", "Ferdinand van Wyk"]
12
- s.date = "2015-09-16"
15
+ s.date = "2015-11-05"
13
16
  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."
14
17
  s.email = "edmundhighcock@sourceforge.net"
15
18
  s.extensions = ["ext/extconf.rb"]
@@ -76,13 +79,12 @@ Gem::Specification.new do |s|
76
79
  ]
77
80
  s.homepage = "http://gs2crmod.sourceforge.net"
78
81
  s.licenses = ["GSLv3"]
79
- s.require_paths = ["lib"]
80
82
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
81
- s.rubygems_version = "1.8.23"
83
+ s.rubygems_version = "2.2.2"
82
84
  s.summary = "Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes."
83
85
 
84
86
  if s.respond_to? :specification_version then
85
- s.specification_version = 3
87
+ s.specification_version = 4
86
88
 
87
89
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
88
90
  s.add_runtime_dependency(%q<coderunner>, [">= 0.15.5"])
data/lib/gs2crmod/gs2.rb CHANGED
@@ -17,20 +17,14 @@
17
17
  #
18
18
  # raw NumRu::NetCDF grids are in Fortran row-major order. This means that when you access grids using the NetCDF function NetCDF#get, you must specify the indices in fortran order (but 0-based!). The NetCDF#get function then returns a C-like NArray with the indices in the opposite order. You can convert this to a Ruby Array using the method NArray#to_a (the indices will still be in the same order).
19
19
 
20
-
21
- #
22
-
23
20
  begin
24
21
  require "numru/netcdf"
25
22
  rescue LoadError
26
23
  eputs "Error: No NetCDF: data analysis for gs2 not possible"
27
24
  end
28
25
 
29
-
30
26
  class CodeRunner
31
27
 
32
-
33
-
34
28
  # This is a customised subclass of CodeRunner::Run which allows CodeRunner to submit and analyse simulations from the gyrokinetic flux tube code GS2, which is principally used for simulating plasmas in magnetic confinement fusion.
35
29
  #
36
30
  # It performs two distinct roles: submitting simulations and analysing the data.
@@ -55,7 +49,6 @@ class Gs2 < Run::FortranNamelist
55
49
  #GS2_CRMOD_VERSION = Version.new(Gem.loaded_specs['gs2crmod'].version.to_s)
56
50
  GS2_CRMOD_VERSION = Version.new('0.5.0')
57
51
 
58
-
59
52
  def agk?
60
53
  false
61
54
  end
@@ -89,14 +82,12 @@ NaN = GSL::NAN
89
82
  eval(%[
90
83
  ], GLOBAL_BINDING)
91
84
 
92
-
93
85
  ################################################
94
86
  # Quantities that are calculated or determined by CodeRunner
95
87
  # after the simulation has ended, i.e. quantities
96
88
  # that are not available from the GS2 output files.
97
89
  ################################################
98
90
 
99
-
100
91
  @results = [
101
92
  :converged,
102
93
  :decaying,
@@ -151,7 +142,6 @@ eval(%[
151
142
  :vspace_check
152
143
  ]
153
144
 
154
-
155
145
  ###############################################
156
146
  # Other useful information about the run
157
147
  ###############################################
@@ -235,6 +225,7 @@ def process_directory_code_specific
235
225
  calculate_results
236
226
 
237
227
  end
228
+
238
229
  def calculate_results
239
230
  return if ENV['CODE_RUNNER_NO_ANALYSIS'] =~ /true/
240
231
 
@@ -257,7 +248,6 @@ def calculate_results
257
248
  end
258
249
 
259
250
  # Try to read the runtime in minutes from the GS2 standard out.
260
-
261
251
  def get_run_time
262
252
  logf(:get_run_time)
263
253
  output = @output_file || try_to_get_output_file
@@ -283,9 +273,6 @@ def ncdump(names=nil, values=nil, extension = '.out.nc')
283
273
  pp NumRu::NetCDF.open(@run_name + extension).vars(names).to_a.sort{|var1, var2| var1.name <=> var2.name}.map{|var| values ? [var.name, var.send(values)] : var.name.to_sym}
284
274
  end
285
275
 
286
-
287
- #
288
-
289
276
  def generate_component_runs
290
277
  @component_runs = []
291
278
  logf(:generate_component_runs)
@@ -332,8 +319,6 @@ def generate_component_runs
332
319
  end
333
320
  end
334
321
 
335
-
336
-
337
322
  def get_time
338
323
  begin
339
324
  lt = list(:t)
@@ -369,6 +354,7 @@ end
369
354
 
370
355
  def parameter_transition(run)
371
356
  end
357
+
372
358
  # @@executable_location = nil
373
359
  # def executable_location
374
360
  # return "~/gs2_newterm" #(@@executable_location || ($gs2_new_term ? "~/gs2_newterm" : "~/gs2"))
@@ -433,7 +419,6 @@ def print_out_line
433
419
 
434
420
  end
435
421
 
436
-
437
422
  def get_list_of(*args)
438
423
  #args can be any list of e.g. :ky, :kx, :theta, :t ...
439
424
  logf(:get_list_of)
@@ -468,7 +453,6 @@ def get_list_of(*args)
468
453
  logfc :get_list_of
469
454
  return cache[args[0] + :_list] if args.size == 1
470
455
  end
471
-
472
456
  alias :list :get_list_of
473
457
 
474
458
  def visually_check_growth_rate(ky=nil)
@@ -486,7 +470,6 @@ def visually_check_growth_rate(ky=nil)
486
470
 
487
471
  end
488
472
 
489
-
490
473
  def show_graph
491
474
  thegraph = special_graph('phi2tot_vs_time_all_kys')
492
475
  thegraph.title += " for g_exb = #{@g_exb.to_f.to_s}"
@@ -496,11 +479,6 @@ def show_graph
496
479
  thegraph.kill
497
480
  end
498
481
 
499
- # @@phi2tot_vs_time_template = {title: "Phi^2 Total vs Time", xlabel: " Time ", ylabel: "Phi^2 Total"})
500
-
501
-
502
-
503
-
504
482
  def restart(new_run)
505
483
  (rcp.variables).each{|v| new_run.set(v, send(v)) if send(v)}
506
484
  @naming_pars.delete(:preamble)
@@ -606,7 +584,6 @@ def diff_run_parameters(run_1, run_2)
606
584
  (col_widths.sum + col_widths.size*3 - 1) }
607
585
  end
608
586
 
609
-
610
587
  # Return a list of restart file paths (relative to the run directory).
611
588
  def list_of_restart_files
612
589
  Dir.chdir(@directory) do
@@ -625,7 +602,6 @@ def list_of_restart_files
625
602
  return files
626
603
  end # Dir.chdir(@directory) do
627
604
  end
628
-
629
605
  alias :lorf :list_of_restart_files
630
606
 
631
607
  # Return list of response files similar to method for restart files
@@ -644,7 +620,6 @@ def list_of_response_files
644
620
  end
645
621
 
646
622
  # Put restart files in the conventional location, i.e. nc/run_name.proc
647
-
648
623
  def standardize_restart_files
649
624
  Dir.chdir(@directory) do
650
625
  FileUtils.makedirs('nc')
@@ -666,10 +641,6 @@ def delete_restart_files(options={})
666
641
  list_of_restart_files.each{|file| FileUtils.rm file}
667
642
  end
668
643
 
669
-
670
-
671
-
672
-
673
644
  def species_letter
674
645
  species_type(1).downcase[0,1]
675
646
  end
@@ -684,15 +655,13 @@ def species_type(index)
684
655
  type
685
656
  end
686
657
 
687
-
688
- # Returns true if this run has not been restarted, false if it has. This allows one to get data from the final run of a series of restarts.
689
-
658
+ # Returns true if this run has not been restarted, false if it has. This
659
+ # allows one to get data from the final run of a series of restarts.
690
660
  def no_restarts
691
661
  raise NoRunnerError unless @runner
692
662
  !(@runner.runs.find{|run| run.restart_id == @id})
693
663
  end
694
664
 
695
-
696
665
  def restart_chain
697
666
  if @restart_id
698
667
  return @runner.run_list[@restart_id].restart_chain
@@ -707,11 +676,6 @@ def restart_chain
707
676
  return chain
708
677
  end
709
678
 
710
-
711
-
712
-
713
-
714
-
715
679
  def get_status
716
680
  # eputs 'Checking Status'
717
681
  logf(:get_status)
@@ -767,7 +731,6 @@ def get_status
767
731
  end
768
732
  end
769
733
 
770
-
771
734
  def self.modify_job_script(runner, runs_in, script)
772
735
  if CODE_OPTIONS[:gs2] and CODE_OPTIONS[:gs2][:list]
773
736
  if (list_size = CODE_OPTIONS[:gs2][:list]).kind_of? Integer
@@ -849,7 +812,6 @@ def recheck
849
812
  end
850
813
  end
851
814
 
852
-
853
815
  def generate_input_file(&block)
854
816
  raise CRFatal("No Input Module File Given or Module Corrupted") unless
855
817
  methods.include? (:input_file_text)
@@ -910,7 +872,6 @@ def generate_input_file(&block)
910
872
  ########
911
873
  end
912
874
 
913
-
914
875
  def write_input_file
915
876
  File.open(@run_name + ".in", 'w'){|file| file.puts input_file_text}
916
877
  end
@@ -937,7 +898,6 @@ def actual_number_of_processors
937
898
  raise "Please specify the processor layout using the -n or (n:) option" unless @nprocs
938
899
  @nprocs.split('x').map{|n| n.to_i}.inject(1){|ntot, n| ntot*n}
939
900
  end
940
-
941
901
  alias :anop :actual_number_of_processors
942
902
 
943
903
  def approximate_grid_size
@@ -948,7 +908,6 @@ def approximate_grid_size
948
908
  @ntheta * (2 * @ngauss + @ntheta/2).to_i * @negrid * 2 * @nspec
949
909
  end
950
910
  end
951
-
952
911
  alias :agridsze :approximate_grid_size
953
912
 
954
913
  # Gives a guess as to the maximum number of meshpoints which
@@ -964,17 +923,12 @@ end
964
923
  def estimated_nodes
965
924
  parallelizable_meshpoints / max_ppn
966
925
  end
967
-
968
926
  alias :estnod :estimated_nodes
969
927
 
970
-
971
-
972
-
973
928
  def parameter_string
974
929
  return "#{@run_name}.in"
975
930
  end
976
931
 
977
-
978
932
  def self.list_code_commands
979
933
  puts (methods - Run.methods).sort
980
934
  end
@@ -1025,9 +979,7 @@ def self.defaults_file_header
1025
979
  EOF1
1026
980
  end
1027
981
 
1028
-
1029
982
  # Customize this method from Run::FortranNamelist by saying when diagnostics are not switched on.
1030
-
1031
983
  #def namelist_text(namelist, enum = nil)
1032
984
  #hash = rcp.namelists[namelist]
1033
985
  #text = ""
@@ -1070,7 +1022,6 @@ end
1070
1022
  # save_namelists
1071
1023
  # end
1072
1024
 
1073
-
1074
1025
  def update_physics_parameters_from_miller_input_file(file)
1075
1026
  hash = self.class.parse_input_file(file)
1076
1027
  hash[:parameters].each do |var, val|
@@ -1099,14 +1050,16 @@ def update_physics_parameters_from_miller_input_file(file)
1099
1050
  end
1100
1051
  end
1101
1052
 
1102
-
1103
-
1104
1053
  def renew_info_file
1105
1054
  Dir.chdir(@directory){make_info_file("#@run_name.in")}
1106
1055
  end
1107
1056
 
1108
- # This method overrides a method defined in heuristic_run_methods.rb in the CodeRunner source. It is called when CodeRunner cannot find any of its own files in the folder being analysed. It takes a GS2 input file and generates a CodeRunner info file. This means that GS2 runs which were not run using CodeRunner can nonetheless be analysed by it. In order for it to be called the -H flag must be specified on the command line.
1109
-
1057
+ # This method overrides a method defined in heuristic_run_methods.rb in the
1058
+ # CodeRunner source. It is called when CodeRunner cannot find any of its own
1059
+ # files in the folder being analysed. It takes a GS2 input file and generates a
1060
+ # CodeRunner info file. This means that GS2 runs which were not run using
1061
+ # CodeRunner can nonetheless be analysed by it. In order for it to be called
1062
+ # the -H flag must be specified on the command line.
1110
1063
  def run_heuristic_analysis
1111
1064
  ep 'run_heuristic_analysis', Dir.pwd
1112
1065
  infiles = Dir.entries.grep(/^[^\.].*\.in$/)
@@ -1288,6 +1241,51 @@ folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file
1288
1241
 
1289
1242
  end
1290
1243
 
1244
+ def change_id(new_id)
1245
+ # Change names for GS2 output files
1246
+ Dir.chdir(@directory) do
1247
+ dir_entries = Dir.entries()
1248
+ dir_entries.each do |f|
1249
+ if f.include? 'v_'
1250
+ new_name = f.sub "id_#{@id}", "id_#{new_id}"
1251
+ `mv "#{f}" "#{new_name}"`
1252
+ next
1253
+ end
1254
+ if (f.include? 'v_' or f.include? 'gs2.')
1255
+ new_name = f.sub "gs2.#{@id}", "gs2.#{new_id}"
1256
+ `mv "#{f}" "#{new_name}"`
1257
+ next
1258
+ end
1259
+ end
1260
+ end
1261
+
1262
+ # Change names for GS2 restart files
1263
+ Dir.chdir(@directory + '/' + @restart_dir) do
1264
+ dir_entries = Dir.entries()
1265
+ dir_entries.each do |f|
1266
+ if f.include? 'v_'
1267
+ new_name = f.sub "id_#{@id}", "id_#{new_id}"
1268
+ `mv "#{f}" "#{new_name}"`
1269
+ end
1270
+ end
1271
+ end
1272
+
1273
+ new_run_dir = @directory.sub "id_#{@id}", "id_#{new_id}"
1274
+ `mv "#{@directory}" "#{new_run_dir}"`
1275
+ @directory = new_run_dir
1276
+
1277
+ # Rename variables which go in info and results file
1278
+ @run_name.sub! "id_#{@id}", "id_#{new_id}"
1279
+ @restart_file.sub! "id_#{@id}", "id_#{new_id}"
1280
+ @output_file.sub! "gs2.#{@id}", "gs2.#{new_id}"
1281
+ @error_file.sub! "gs2.#{@id}", "gs2.#{new_id}"
1282
+
1283
+ # Change instance variable and write info and results files again
1284
+ @id = new_id
1285
+ write_results
1286
+ write_info
1287
+ end
1288
+
1291
1289
  end # class GS2
1292
1290
  # For backwards compatibility
1293
1291
 
@@ -1296,7 +1294,6 @@ end # class CodeRunner
1296
1294
 
1297
1295
  # ep CodeRunner::Gs2CycloneRun.ancestors
1298
1296
 
1299
-
1300
1297
  class Float
1301
1298
  def <=>(other) # necessary because of netcdf quirks
1302
1299
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gs2crmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.11
5
- prerelease:
4
+ version: 0.12.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Edmund Highcock
@@ -10,60 +9,53 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2015-09-16 00:00:00.000000000 Z
12
+ date: 2015-11-05 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: coderunner
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 0.15.5
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 0.15.5
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rubyhacks
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: 0.1.2
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: 0.1.2
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: ruby-netcdf
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
48
  version: 0.7.1
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - ">="
61
54
  - !ruby/object:Gem::Version
62
55
  version: 0.7.1
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: shoulda
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
60
  - - '='
69
61
  - !ruby/object:Gem::Version
@@ -71,7 +63,6 @@ dependencies:
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
67
  - - '='
77
68
  - !ruby/object:Gem::Version
@@ -79,65 +70,57 @@ dependencies:
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: rdoc
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ~>
74
+ - - "~>"
85
75
  - !ruby/object:Gem::Version
86
76
  version: '3.12'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ~>
81
+ - - "~>"
93
82
  - !ruby/object:Gem::Version
94
83
  version: '3.12'
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: bundler
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>'
88
+ - - ">"
101
89
  - !ruby/object:Gem::Version
102
90
  version: 1.0.0
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>'
95
+ - - ">"
109
96
  - !ruby/object:Gem::Version
110
97
  version: 1.0.0
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: jeweler
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
- - - ! '>='
102
+ - - ">="
117
103
  - !ruby/object:Gem::Version
118
104
  version: 1.8.4
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
- - - ! '>='
109
+ - - ">="
125
110
  - !ruby/object:Gem::Version
126
111
  version: 1.8.4
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: minitest
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
- - - ~>
116
+ - - "~>"
133
117
  - !ruby/object:Gem::Version
134
118
  version: '4'
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
- - - ~>
123
+ - - "~>"
141
124
  - !ruby/object:Gem::Version
142
125
  version: '4'
143
126
  description: GS2 is a gyrokinetic flux tube initial value turbulence code which can
@@ -153,7 +136,7 @@ extra_rdoc_files:
153
136
  - README.md
154
137
  - README.rdoc
155
138
  files:
156
- - .document
139
+ - ".document"
157
140
  - Gemfile
158
141
  - LICENSE.txt
159
142
  - README.md
@@ -210,26 +193,25 @@ files:
210
193
  homepage: http://gs2crmod.sourceforge.net
211
194
  licenses:
212
195
  - GSLv3
196
+ metadata: {}
213
197
  post_install_message:
214
198
  rdoc_options: []
215
199
  require_paths:
216
200
  - lib
217
201
  required_ruby_version: !ruby/object:Gem::Requirement
218
- none: false
219
202
  requirements:
220
- - - ! '>='
203
+ - - ">="
221
204
  - !ruby/object:Gem::Version
222
205
  version: 1.9.1
223
206
  required_rubygems_version: !ruby/object:Gem::Requirement
224
- none: false
225
207
  requirements:
226
- - - ! '>='
208
+ - - ">="
227
209
  - !ruby/object:Gem::Version
228
210
  version: '0'
229
211
  requirements: []
230
212
  rubyforge_project:
231
- rubygems_version: 1.8.23
213
+ rubygems_version: 2.2.2
232
214
  signing_key:
233
- specification_version: 3
215
+ specification_version: 4
234
216
  summary: Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.
235
217
  test_files: []