trinitycrmod 0.2.6 → 0.3.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0877712c481a4fec5d91f15adc539a7e1fdb83a8
4
+ data.tar.gz: 1982d8891a6c0002d8fa0ef9ec7e10b157cc1252
5
+ SHA512:
6
+ metadata.gz: 047fbdde9d918bf6bfb0a3688101c12170c0f3bdbd06aea46d719d74ed357f7f50fd97226e9cebdbf6d9ffd867bf647ebcf729d84f90d8298158bdc43ce70d2a
7
+ data.tar.gz: 6340ce30b9d2bf792593f84feb303611b86ccd5182cf6258a8bcda4fb72bb5b3d52bd22ea80ed8e5592e422fcb05723d53957d5be88bed1148edf11fb78f6248
data/Gemfile CHANGED
@@ -1,8 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "coderunner", ">= 0.11.0"
4
+ gem "coderunner", ">= 0.14.0"
5
5
  gem "text-data-tools", ">= 1.1.3"
6
+ gem "gs2crmod", ">=0.11.10"
6
7
 
7
8
  # Add dependencies to develop your gem here.
8
9
  # Include everything needed to run rake, tests, features, etc.
@@ -10,5 +11,5 @@ group :development do
10
11
  gem "shoulda", ">= 0"
11
12
  gem "rdoc", "~> 3.12"
12
13
  gem "bundler", "> 1.0.0"
13
- gem "jeweler", ">= 1.8.4"
14
+ gem "jeweler", ">= 2.0.0"
14
15
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.3.0
@@ -15,8 +15,17 @@ class CodeRunner::Trinity
15
15
  def prof_graphkit(options)
16
16
  raise "Please specify t_index" unless options[:t_index]
17
17
  it = options[:t_index] - 1
18
- array = get_2d_array_float(options[:outfile], options[:header], /1.*time/)[it]
19
- rho_array = get_2d_array_float(options[:outfile], /2.*radius/, /1.*time/)[it]
18
+ if ta = options[:time_average]
19
+ if ta < 0
20
+ t_indices = (it+ta..it).to_a
21
+ else
22
+ t_indices = (it..it+ta).to_a
23
+ end
24
+ else
25
+ t_indices = [it]
26
+ end
27
+ array = t_indices.map{|i| get_2d_array_float(options[:outfile], options[:header], /1.*time/)[i].to_gslv}.mean.to_a
28
+ rho_array = t_indices.map{|i| get_2d_array_float(options[:outfile], /2.*radius/, /1.*time/)[i].to_gslv}.mean.to_a
20
29
  if options[:exclude_perturbed_fluxes]
21
30
  s = array.size
22
31
  array = array.slice(0...nrad-1)
@@ -26,13 +35,26 @@ class CodeRunner::Trinity
26
35
  kit = GraphKit.autocreate(x: {data: rho_array.to_gslv, title: 'rho', units: ''},
27
36
  y: {data: array.to_gslv, title: options[:title]||"", units: options[:units]||""}
28
37
  )
29
- kit.data[0].title += " at time = #{list(:t)[it+1]} s"
38
+ kit.data[0].title += " at time = #{list(:t)[it+1]} s for id #{id}"
39
+ kit.data[0].gp.with = 'lp'
30
40
  kit
31
41
  end
32
42
  # Graph of Qi in gyroBohm units against rho for a given t_index
33
43
  def ion_hflux_gb_prof_graphkit(options)
34
44
  fluxes_prof_graphkit(options.absorb({header: /Qi.*\(GB/, title: 'Ion Heat Flux', units: 'Q_gB'}))
35
45
  end
46
+ # Graph of Qi in MW against rho for a given t_index
47
+ def ion_hflux_prof_graphkit(options)
48
+ fluxes_prof_graphkit(options.absorb({header: /Qi.*\(MW/, title: 'Ion Heat Flux', units: 'MW'}))
49
+ end
50
+ # Graph of Qe in gyroBohm units against rho for a given t_index
51
+ def eln_hflux_gb_prof_graphkit(options)
52
+ fluxes_prof_graphkit(options.absorb({header: /Qe.*\(GB/, title: 'Electron Heat Flux', units: 'Q_gB'}))
53
+ end
54
+ # Graph of Qe in MW against rho for a given t_index
55
+ def eln_hflux_prof_graphkit(options)
56
+ fluxes_prof_graphkit(options.absorb({header: /Qe.*\(MW/, title: 'Electron Heat Flux', units: 'MW'}))
57
+ end
36
58
  # Graph of toroidal angular momentum flux in gyroBohm units against rho for a given t_index
37
59
  def lflux_gb_prof_graphkit(options)
38
60
  fluxes_prof_graphkit(options.absorb({header: /Pi.*\(GB/, title: 'Toroidal Angular Momentum Flux', units: 'Pi_gB'}))
@@ -45,18 +67,22 @@ class CodeRunner::Trinity
45
67
  def ion_temp_prof_graphkit(options)
46
68
  return nt_prof_graphkit(options.absorb({header: /i\+ temp/, title: 'Ti', units: 'keV'}))
47
69
  end
70
+ # Graph of Te against rho for a given t_index
71
+ def eln_temp_prof_graphkit(options)
72
+ return nt_prof_graphkit(options.absorb({header: /e\- temp/, title: 'Te', units: 'keV'}))
73
+ end
48
74
 
49
75
  # Graph of ion power integrated from the magnetic axis to rho vs rho
50
76
  def ion_pwr_prof_graphkit(options)
51
77
  return pbalance_prof_graphkit(options.absorb({header: /i\+ pwr/, title: 'Integrated ion power', units: 'MW'}))
52
78
  end
53
79
  # Graph of electron power integrated from the magnetic axis to rho vs rho
54
- def electron_pwr_prof_graphkit(options)
80
+ def eln_pwr_prof_graphkit(options)
55
81
  return pbalance_prof_graphkit(options.absorb({header: /e\- pwr/, title: 'Integrated electron power', units: 'MW'}))
56
82
  end
57
83
  # Graph of ion power integrated from the magnetic axis to rho vs rho
58
- def ion_pwr_prof_graphkit(options)
59
- return pbalance_prof_graphkit(options.absorb({header: /i\+ pwr/, title: 'Integrated ion power', units: 'MW'}))
84
+ def torque_prof_graphkit(options)
85
+ return pbalance_prof_graphkit(options.absorb({header: /torque/, title: 'Integrated torque', units: 'Nm'}))
60
86
  end
61
87
  end
62
88
 
@@ -820,7 +820,16 @@
820
820
  :explanation=>
821
821
  "This variable must be a fortran boolean. (In Ruby this is represented as a string: e.g. '.true.')"}],
822
822
  :type=>:Fortran_Bool,
823
- :autoscanned_defaults=>[".true."]}}},
823
+ :autoscanned_defaults=>[".true."]},
824
+ :subfolders=>
825
+ {:should_include=>"true",
826
+ :description=>"If true, run flux tubes in numbered subfolders.",
827
+ :help=>"If true, run flux tubes in numbered subfolders.",
828
+ :code_name=>:subfolders,
829
+ :must_pass=>
830
+ [{:test=>"kind_of? Integer",
831
+ :explanation=>"This variable must be an integer."}],
832
+ :type=>:Integer}}},
824
833
  :init=>
825
834
  {:description=>"",
826
835
  :should_include=>"true",
@@ -1201,78 +1210,70 @@
1201
1210
  :autoscanned_defaults=>[".false."]},
1202
1211
  :nbi_mult=>
1203
1212
  {:should_include=>"true",
1204
- :description=>
1205
- " multiplies QNBII, QNBIE and SNBIE when using the tokamak profile db, may not be self consistent when using TORQ for torque input (as opposed to pioq)",
1206
- :help=>
1207
- " multiplies QNBII, QNBIE and SNBIE when using the tokamak profile db, may not be self consistent when using TORQ for torque input (as opposed to pioq)",
1213
+ :description=>nil,
1214
+ :help=>nil,
1208
1215
  :code_name=>:nbi_mult,
1209
1216
  :must_pass=>
1210
1217
  [{:test=>"kind_of? Numeric",
1211
1218
  :explanation=>
1212
1219
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
1213
1220
  :type=>:Float,
1214
- :autoscanned_defaults=>[1.0]},
1221
+ :autoscanned_defaults=>[]},
1215
1222
  :icrh_mult=>
1216
1223
  {:should_include=>"true",
1217
- :description=>
1218
- " multiplies QICRHI and QICRHE when using the tokamak profile db",
1219
- :help=>
1220
- " multiplies QICRHI and QICRHE when using the tokamak profile db",
1224
+ :description=>nil,
1225
+ :help=>nil,
1221
1226
  :code_name=>:icrh_mult,
1222
1227
  :must_pass=>
1223
1228
  [{:test=>"kind_of? Numeric",
1224
1229
  :explanation=>
1225
1230
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
1226
1231
  :type=>:Float,
1227
- :autoscanned_defaults=>[1.0]},
1232
+ :autoscanned_defaults=>[]},
1228
1233
  :ech_mult=>
1229
1234
  {:should_include=>"true",
1230
- :description=>
1231
- " multiplies QECHI and QECHE when using the tokamak profile db",
1232
- :help=>" multiplies QECHI and QECHE when using the tokamak profile db",
1235
+ :description=>nil,
1236
+ :help=>nil,
1233
1237
  :code_name=>:ech_mult,
1234
1238
  :must_pass=>
1235
1239
  [{:test=>"kind_of? Numeric",
1236
1240
  :explanation=>
1237
1241
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
1238
1242
  :type=>:Float,
1239
- :autoscanned_defaults=>[1.0]},
1243
+ :autoscanned_defaults=>[]},
1240
1244
  :lh_mult=>
1241
1245
  {:should_include=>"true",
1242
- :description=>
1243
- " multiplies QLHI and QLHE when using the tokamak profile db",
1244
- :help=>" multiplies QLHI and QLHE when using the tokamak profile db",
1246
+ :description=>nil,
1247
+ :help=>nil,
1245
1248
  :code_name=>:lh_mult,
1246
1249
  :must_pass=>
1247
1250
  [{:test=>"kind_of? Numeric",
1248
1251
  :explanation=>
1249
1252
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
1250
1253
  :type=>:Float,
1251
- :autoscanned_defaults=>[1.0]},
1254
+ :autoscanned_defaults=>[]},
1252
1255
  :ibw_mult=>
1253
1256
  {:should_include=>"true",
1254
- :description=>
1255
- " multiplies QIBWI and QIBWE when using the tokamak profile db",
1256
- :help=>" multiplies QIBWI and QIBWE when using the tokamak profile db",
1257
+ :description=>nil,
1258
+ :help=>nil,
1257
1259
  :code_name=>:ibw_mult,
1258
1260
  :must_pass=>
1259
1261
  [{:test=>"kind_of? Numeric",
1260
1262
  :explanation=>
1261
1263
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
1262
1264
  :type=>:Float,
1263
- :autoscanned_defaults=>[1.0]},
1265
+ :autoscanned_defaults=>[]},
1264
1266
  :dwn_mult=>
1265
1267
  {:should_include=>"true",
1266
- :description=>
1267
- " multiplies DWIR, DWER, DNER when using the tokamak profile db",
1268
- :help=>" multiplies DWIR, DWER, DNER when using the tokamak profile db",
1268
+ :description=>nil,
1269
+ :help=>nil,
1269
1270
  :code_name=>:dwn_mult,
1270
1271
  :must_pass=>
1271
1272
  [{:test=>"kind_of? Numeric",
1272
1273
  :explanation=>
1273
1274
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
1274
1275
  :type=>:Float,
1275
- :autoscanned_defaults=>[1.0]}}},
1276
+ :autoscanned_defaults=>[]}}},
1276
1277
  :physics=>
1277
1278
  {:description=>"",
1278
1279
  :should_include=>"true",
@@ -17,6 +17,10 @@ class CodeRunner
17
17
  setup_namelists(@code_module_folder)
18
18
  require 'trinitycrmod/output_files'
19
19
  require 'trinitycrmod/graphs'
20
+ require 'trinitycrmod/trinity_gs2'
21
+
22
+ # Setup gs2 in case people are using it
23
+ CodeRunner.setup_run_class('gs2')
20
24
 
21
25
  ################################################
22
26
  # Quantities that are read or determined by CodeRunner
@@ -52,7 +56,7 @@ class CodeRunner
52
56
  @naming_pars = []
53
57
 
54
58
  # Any folders which are a number will contain the results from flux simulations.
55
- @excluded_sub_folders = (1...1000).to_a.map{|i| i.to_s}
59
+ @excluded_sub_folders = (1...1000).to_a.map{|i| "flux_tube_" + i.to_s}
56
60
 
57
61
  # A hook which gets called when printing the standard run information to the screen using the status command.
58
62
  def print_out_line
@@ -72,9 +76,52 @@ class CodeRunner
72
76
 
73
77
  # This is a hook which gets called just before submitting a simulation. It sets up the folder and generates any necessary input files.
74
78
  def generate_input_file
79
+ @run_name += "_t"
75
80
  write_input_file
81
+ generate_gs2_input_files if @flux_option == "gs2"
76
82
  end
77
83
 
84
+ # Writes the gs2 input files, creating separate subfolders
85
+ # for them if @subfolders is .true.
86
+ def generate_gs2_input_files
87
+ for i in 0...(@nrad-1)*2
88
+ gs2run = gs2_run(:base).dup
89
+ gs2_run(i).instance_variables.each do |var|
90
+ gs2run.instance_variable_set(var, gs2_run(i).instance_variable_get(var))
91
+ end
92
+ if @subfolders and @subfolders.fortran_true?
93
+ gs2run.directory = @directory + "/flux_tube_#{i+1}"
94
+ FileUtils.makedirs(gs2run.directory)
95
+ gs2run.relative_directory = @relative_directory + "/flux_tube_#{i+1}"
96
+ gs2run.restart_dir = gs2run.directory + "/nc"
97
+ else
98
+ gs2run.directory = @directory
99
+ gs2run.relative_directory = @relative_directory
100
+ end
101
+ gs2run.run_name = @run_name + (i+1).to_s
102
+ gs2run.nprocs = @nprocs
103
+ if i==0
104
+ block = Proc.new{ingen}
105
+ else
106
+ block = Proc.new{}
107
+ end
108
+ Dir.chdir(gs2run.directory){gs2run.generate_input_file(&block); gs2run.write_info}
109
+
110
+ ### Hack the input file so that gs2 gets the location of
111
+ # the restart dir correctly within trinity
112
+ if @subfolders and @subfolders.fortran_true?
113
+ infile = gs2run.directory + "/" + gs2run.run_name + ".in"
114
+ text = File.read(infile)
115
+ File.open(infile, 'w'){|f| f.puts text.sub(/restart_dir\s*=\s*"nc"/, "restart_dir = \"flux_tube_#{i+1}/nc\"")}
116
+ end
117
+ end
118
+ end
119
+
120
+ def vim_output
121
+ system "vim -Ro #{output_file} #{error_file} #@directory/#@run_name.error #@directory/#@run_name.out "
122
+ end
123
+ alias :vo :vim_output
124
+
78
125
  # This command uses the infrastructure provided by Run::FortranNamelist, provided by CodeRunner itself.
79
126
  def write_input_file
80
127
  File.open(@run_name + ".trin", 'w'){|file| file.puts input_file_text}
@@ -88,6 +135,55 @@ class CodeRunner
88
135
  def parameter_transition
89
136
  end
90
137
 
138
+ def generate_component_runs
139
+ #puts "HERE"
140
+ @component_runs = []
141
+ if @flux_option == "gs2"
142
+ #puts "HERE"
143
+ for i in 0...(@nrad-1)*2
144
+ component = gs2_run(i).create_component
145
+ component.component_runs = []
146
+ #component.runner = nil
147
+ #pp component; STDIN.gets
148
+ #component.instance_variables.each{|var| puts var; pp var; puts Marshal.dump(component.instance_variable_get(var)); STDIN.gets}
149
+ #puts Marshal.dump(component); STDIN.gets
150
+ #pp component; STDIN.gets
151
+ #p component.class
152
+ component.job_no = @job_no
153
+ Dir.chdir("flux_tube_#{i+1}"){component.process_directory}
154
+ component.component_runs = []
155
+ @component_runs.push component
156
+ component.real_id = @id
157
+ #@gs2_run_list[i] = component
158
+ #pp component; STDIN.gets
159
+ #component.runner = nil
160
+ #puts Marshal.dump(component); STDIN.gets
161
+ #pp component; STDIN.gets
162
+ #component.component_runs = []
163
+ end
164
+ end
165
+ end
166
+
167
+
168
+ def save
169
+ @gs2_run_list.values.each{|r| r.runner = nil; r.component_runs = []} if @gs2_run_list.kind_of? Hash
170
+ super
171
+
172
+ #logf(:save)
173
+ #raise CRFatal.new("Something has gone horribly wrong: runner.class is #{@runner.class} instead of CodeRunner") unless @runner.class.to_s == "CodeRunner"
174
+ #runner, @runner = @runner, nil
175
+ #@system_triers, old_triers = nil, @system_triers
176
+ #@component_runs.each{|run| run.runner = nil; run.component_runs = []} if @component_runs
177
+ ##@component_runs.each{|run| run.runner = nil} if @component_runs
178
+ ## logi(self)
179
+ ##pp self
180
+ ##@component_runs.each{|ph| ph.instance_variables.each{|var| puts var; pp ph.instance_variable_get(var); STDIN.gets; puts ph.Marshal.dump(instance_variable_get(var))}} if @component_runs
181
+ ##instance_variables.each{|var| puts var; instance_variable_get(var); puts Marshal.dump(instance_variable_get(var)); STDIN.gets}
182
+ #Dir.chdir(@directory){File.open(".code_runner_run_data", 'w'){|file| file.puts Marshal.dump(self)}}
183
+ #@runner = runner
184
+ #@component_runs.each{|run| run.runner = runner} if @component_runs
185
+ #@system_triers = old_triers
186
+ end
91
187
 
92
188
  @source_code_subfolders = []
93
189
 
@@ -189,7 +285,7 @@ class CodeRunner
189
285
  !
190
286
  ! See http://coderunner.sourceforge.net
191
287
  !
192
- ! Created on #{Time.now.to_s}
288
+ ! Created #{Time.now.to_s}
193
289
  ! by CodeRunner version #{CodeRunner::CODE_RUNNER_VERSION.to_s}
194
290
  !
195
291
  !==============================================================================
@@ -0,0 +1,68 @@
1
+ # This file contains methods which allow Trinity to use GS2 as
2
+ # the flux solver
3
+
4
+ #class NumRu::NetCDF
5
+ #def _dump_data
6
+ #Marshal.dump(nil)
7
+ #end
8
+ #end
9
+ class CodeRunner
10
+ class Trinity
11
+
12
+ # This function creates a new Trinity defaults file, with Trinity parameters taken from
13
+ # trinity_input_file, and GS2 parameters taken from gs2_input_file. The file is then moved
14
+ # to the CodeRunner central defaults location, the current folder is configured to use
15
+ # the defaults file.
16
+ def self.use_new_defaults_file_with_gs2(name = ARGV[-3], trinity_input_file = ARGV[-2], gs2_input_file = ARGV[-1])
17
+ raise "Please specify a name, a trinity input file and a gs2 input file" if name == "use_new_gs2_defaults_file"
18
+ defaults_filename = "#{name}_defaults.rb"
19
+ tmp_filename = "#{name}_gs2tmp_defaults.rb"
20
+ central_defaults_filename = rcp.user_defaults_location + "/" + defaults_filename
21
+ FileUtils.rm(name + '_defaults.rb') if FileTest.exist?(name + '_defaults.rb')
22
+ FileUtils.rm(central_defaults_filename) if FileTest.exist?(central_defaults_filename)
23
+ FileUtils.rm(tmp_filename) if FileTest.exist?(tmp_filename)
24
+ raise "Defaults file: #{central_defaults_filename} already exists" if FileTest.exist? central_defaults_filename
25
+
26
+
27
+ make_new_defaults_file(name, trinity_input_file)
28
+ CodeRunner::Gs2.make_new_defaults_file(name + '_gs2tmp', gs2_input_file)
29
+
30
+ File.open(defaults_filename, 'a'){|file| file.puts <<EOF2
31
+ gs2_run(:base).instance_eval do
32
+ #{File.read(tmp_filename).gsub(/\A|\n/, "\n ")}
33
+ end
34
+
35
+ EOF2
36
+
37
+ }
38
+ FileUtils.mv(defaults_filename, central_defaults_filename)
39
+ FileUtils.rm(tmp_filename)
40
+ CodeRunner.fetch_runner(C: rcp.code, m: (rcp.modlet? ? rcp.modlet : nil), D: name)
41
+
42
+ end
43
+
44
+ def gs2_run(key)
45
+ @gs2_run_list ||= {}
46
+ @gs2_run_list[key] ||= Gs2.new(@runner)
47
+ #if key != :base
48
+ #raise "key in gs2_run must be either :base or an integer" unless key.kind_of? Integer
49
+ #@gs2_run_list[key] ||= @gs2_run_list[:base].dup
50
+ #end
51
+ @gs2_run_list[key]
52
+ end
53
+
54
+ # Override standard CodeRunner method to allow for Gs2 variables
55
+ def evaluate_defaults_file(filename)
56
+ text = File.read(filename)
57
+ text.scan(/^\s*@(\w+)/) do
58
+ var_name = $~[1].to_sym
59
+ next if var_name == :defaults_file_description
60
+ unless rcp.variables.include? var_name or Gs2.rcp.variables.include? var_name
61
+ warning("---#{var_name}---, specified in #{File.expand_path(filename)}, is not a variable. This could be an error")
62
+ end
63
+ end
64
+ instance_eval(text)
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,186 @@
1
+ ! electrostatic, kinetic electrons
2
+
3
+ &parameters
4
+ beta = 0.0
5
+ zeff = 1.7
6
+ /
7
+
8
+ &theta_grid_knobs
9
+ equilibrium_option='eik'
10
+ /
11
+
12
+ &theta_grid_parameters
13
+ ntheta= 8
14
+ nperiod= 1
15
+
16
+ ! commented out parameters specified via Trinity
17
+ ! rhoc = 0.5
18
+ ! Rmaj = 5.0
19
+ ! R_geo = 5.0
20
+ ! qinp = 1.4
21
+ ! shat = 0.8
22
+ ! akappa = 1.0
23
+ ! akappri = 0.0
24
+ ! tri = 0.0
25
+ ! tripri = 0.0
26
+ ! shift = 0.0
27
+ /
28
+
29
+ &theta_grid_eik_knobs
30
+ itor = 1
31
+ iflux = 0
32
+ irho = 2
33
+
34
+ ppl_eq = F
35
+ gen_eq = F
36
+
37
+ efit_eq = F
38
+ local_eq = T
39
+
40
+ eqfile = 'dskeq.cdf'
41
+ equal_arc = T
42
+ bishop = 4
43
+ ! s_hat_input = 0.8
44
+ ! beta_prime_input = 0.0
45
+ delrho = 1.e-3
46
+ isym = 0
47
+ writelots = F
48
+ /
49
+
50
+ &collisions_knobs
51
+ collision_model='none'
52
+ /
53
+
54
+ &hyper_knobs
55
+ hyper_option = 'visc_only'
56
+ const_amp = .false.
57
+ isotropic_shear = .false.
58
+ D_hypervisc = 0.05
59
+ /
60
+
61
+ &species_knobs
62
+ nspec= 2
63
+ /
64
+
65
+ &species_parameters_1
66
+ z= 1.0
67
+ mass= 1.0
68
+ dens= 1.0
69
+ temp= 1.0
70
+ tprim= 4.0
71
+ fprim= 0.0
72
+ uprim= 0.0
73
+ vnewk= 0.0
74
+ type='ion'
75
+ /
76
+
77
+ &dist_fn_species_knobs_1
78
+ fexpr= 0.48
79
+ fexpi= 0.0
80
+ bakdif= 0.02
81
+ /
82
+
83
+ &species_parameters_2
84
+ z= -1.0
85
+ mass= 2.2e-4
86
+ dens= 1.0
87
+ temp= 1.0
88
+ tprim= 4.0
89
+ fprim= 0.0
90
+ uprim= 0.0
91
+ vnewk= 0.0
92
+ type='electron'
93
+ /
94
+
95
+ &dist_fn_species_knobs_2
96
+ fexpr= 0.48
97
+ fexpi= 0.0
98
+ bakdif= 0.02
99
+ /
100
+
101
+ &dist_fn_knobs
102
+ adiabatic_option="iphi00=2"
103
+ gridfac= 1.0
104
+ boundary_option="linked"
105
+ /
106
+
107
+ &init_g_knobs
108
+ chop_side = .false.
109
+ phiinit= 1.e-3
110
+ phifrac = 0.1
111
+ zf_init = 0.0
112
+ ginit_option= "noise"
113
+ /
114
+
115
+ &kt_grids_knobs
116
+ grid_option='box'
117
+ /
118
+
119
+ &kt_grids_box_parameters
120
+ ! (25-1)/3+1 = 9 ky values
121
+ ny = 8
122
+
123
+ ! 2*(40-1)/3 + 1 = 27 kx values
124
+ nx = 8
125
+
126
+ ! dky = 1/y0 = 0.1 => ky: 0 -> 0.8
127
+ y0 = 10.
128
+
129
+ ! default jtwist calculated in kt_grids to
130
+ ! make box lengths in x and y equal at
131
+ ! outboard midplane
132
+ ! jtwist = 5
133
+ /
134
+
135
+ &le_grids_knobs
136
+ ngauss = 3
137
+ negrid = 6
138
+ vcut= 2.5
139
+ /
140
+
141
+ &knobs
142
+ wstar_units = .false.
143
+ fphi = 1.0
144
+ fapar = 0.0
145
+ faperp = 0.0
146
+ delt = 0.01
147
+ nstep = 60
148
+ /
149
+
150
+ &fields_knobs
151
+ field_option='implicit'
152
+ /
153
+
154
+ &nonlinear_terms_knobs
155
+ nonlinear_mode='on'
156
+ cfl = 0.25
157
+ /
158
+
159
+ &reinit_knobs
160
+ delt_adj = 2.0
161
+ delt_minimum = 1.e-6
162
+ delt_cushion = 10.0
163
+ /
164
+
165
+ &layouts_knobs
166
+ layout = 'lxyes'
167
+ local_field_solve = F
168
+ /
169
+
170
+ &gs2_diagnostics_knobs
171
+ print_flux_line=.false.
172
+ write_nl_flux = .true.
173
+ print_line = F
174
+ write_line = F
175
+ write_final_moments= T
176
+ write_avg_moments = .true.
177
+ write_final_fields=.true.
178
+ write_verr = F
179
+ write_gyx = F
180
+ write_hrate = F
181
+ write_correlation = T
182
+ nwrite= 10
183
+ navg= 40
184
+ omegatinst = 500.0
185
+ save_for_restart = .true.
186
+ /
@@ -0,0 +1,57 @@
1
+
2
+
3
+
4
+ &geometry
5
+ geo_option = "iterdb"
6
+ geo_file = "../../pr08_jet_42982_2d.dat"
7
+ geo_time = 15.2
8
+ fluxlabel_option = "aminor"
9
+ rad_out = 0.85
10
+ nrad = 5
11
+ use_external_geo = .false.
12
+ write_dbinfo = .true.
13
+ /
14
+
15
+ &species
16
+ species_option = "iterdb"
17
+ ntspec = 2
18
+ qi = 1.0
19
+ mi = 2.5
20
+ deuterium = 1
21
+ /
22
+
23
+ &time
24
+ ntstep = 2
25
+ ntdelt = 0.1
26
+ impfac = 1.0
27
+ niter = 1
28
+ errtol = 0.01
29
+ errflr = 0.01
30
+ flrfac = 2.0
31
+ ntdelt_max = 100.0
32
+ /
33
+
34
+ &fluxes
35
+ flux_option = "gs2"
36
+ vtfac = 2.0
37
+ grad_option = "tigrad"
38
+ fork_flag = .true.
39
+ subfolders = .true.
40
+ /
41
+
42
+ &physics
43
+ include_neo = .true.
44
+ turb_heat = .false.
45
+ temp_equil = .true.
46
+ /
47
+
48
+ &sources
49
+ source_option = "iterdb"
50
+ write_pwr_profs = .true.
51
+ include_radiation = .true.
52
+ include_alphas = .true.
53
+ /
54
+
55
+ &init
56
+ init_option = "iterdb"
57
+ /
Binary file
@@ -16,7 +16,7 @@ class TestTrinitycrmodIFSPPPL < Test::Unit::TestCase
16
16
  FileUtils.mv('rake_test_defaults.rb', @runner.run_class.rcp.user_defaults_location)
17
17
  CodeRunner.submit(Y: 'test/ifspppl', T: true, D: 'rake_test')
18
18
  base_hash = @runner.run_class.parse_input_file('test/ifspppl/test.trin')
19
- test_hash = @runner.run_class.parse_input_file('test/ifspppl/v/id_1/v_id_1.trin')
19
+ test_hash = @runner.run_class.parse_input_file('test/ifspppl/v/id_1/v_id_1_t.trin')
20
20
  assert_equal(base_hash, test_hash)
21
21
  FileUtils.rm(@runner.run_class.rcp.user_defaults_location + '/rake_test_defaults.rb')
22
22
  FileUtils.rm('test/ifspppl/rake_test_defaults.rb')
@@ -24,6 +24,57 @@ class TestTrinitycrmodIFSPPPL < Test::Unit::TestCase
24
24
  end
25
25
  end
26
26
 
27
+ class TestTrinitycrmodGs2 < Test::Unit::TestCase
28
+ def setup
29
+ CodeRunner.setup_run_class('trinity')
30
+ Dir.chdir('test/gs2_42982'){
31
+ CodeRunner::Trinity.use_new_defaults_file_with_gs2('rake_test_gs2_42982', 'shot42982_jet.trin', 'shot42982_jet.in')
32
+ }
33
+ @runner = CodeRunner.fetch_runner(Y: 'test/gs2_42982', C: 'trinity', X: '/dev/null')
34
+ system("gunzip test/gs2_42982/pr08_jet_42982_1d.dat.gz -c > test/gs2_42982/pr08_jet_42982_1d.dat")
35
+ system("gunzip test/gs2_42982/pr08_jet_42982_2d.dat.gz -c > test/gs2_42982/pr08_jet_42982_2d.dat")
36
+ end
37
+ def test_submit
38
+ if ENV['TRINITY_EXEC']
39
+ CodeRunner.submit(Y: 'test/gs2_42982', X: ENV['TRINITY_EXEC'], n: '8')
40
+ else
41
+ CodeRunner.submit(Y: 'test/gs2_42982', T: true, X: '/dev/null', n: '8')
42
+ end
43
+ @runner.use_component = :component
44
+ @runner.recalc_all = true
45
+ @runner.update
46
+ CodeRunner.status(Y: 'test/gs2_42982', h: :component, A: true)
47
+ end
48
+ def teardown
49
+ FileUtils.rm(@runner.run_class.rcp.user_defaults_location + '/rake_test_gs2_42982_defaults.rb')
50
+ FileUtils.rm('test/gs2_42982/rake_test_gs2_42982_defaults.rb')
51
+ FileUtils.rm('test/gs2_42982/pr08_jet_42982_1d.dat')
52
+ FileUtils.rm('test/gs2_42982/pr08_jet_42982_2d.dat')
53
+ FileUtils.rm('test/gs2_42982/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
54
+ if ENV['TRINITY_EXEC'] and not FileTest.exist?('test/gs2_42982_results/v.tgz')
55
+ Dir.chdir('test/gs2_42982'){system("tar -czf v.tgz v/")}
56
+ FileUtils.mv('test/gs2_42982/v.tgz', 'test/gs2_42982_results/.')
57
+ end
58
+ FileUtils.rm_r('test/gs2_42982/v/')
59
+ end
60
+ end
61
+
62
+ class TestTrinitycrmodGs2Analysis < Test::Unit::TestCase
63
+ def setup
64
+ Dir.chdir('test/gs2_42982_results/'){system "tar -xzf v.tgz"}
65
+ @runner = CodeRunner.fetch_runner(Y: 'test/gs2_42982_results', C: 'trinity', A: true)
66
+ end
67
+ def test_analysis
68
+ CodeRunner.status(Y: 'test/gs2_42982_results')
69
+ CodeRunner.status(Y: 'test/gs2_42982_results', h: :component)
70
+ end
71
+ def teardown
72
+ FileUtils.rm_r('test/gs2_42982_results/v')
73
+ FileUtils.rm('test/gs2_42982_results/.code_runner_script_defaults.rb')
74
+ FileUtils.rm('test/gs2_42982_results/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
75
+ end
76
+ end
77
+
27
78
  class TestTrinitycrmodIFSPPPLAnalysis < Test::Unit::TestCase
28
79
  def setup
29
80
  #@runner = CodeRunner.fetch_runner(Y: 'test/ifspppl_results', C: 'trinity', X: '/dev/null')
@@ -57,6 +108,19 @@ class TestTrinitycrmodIFSPPPLAnalysis < Test::Unit::TestCase
57
108
  assert_equal(kit.data[0].y.data[0], 0.2412)
58
109
  #kit.gnuplot
59
110
  end
111
+
112
+ def test_average_graphs
113
+ kit = @runner.run_list[1].graphkit('ion_hflux_gb_prof', {t_index: 2})
114
+ #kit.gnuplot
115
+ assert_equal(kit.data[0].class, GraphKit::DataKit)
116
+ assert_equal(kit.data[0].y.data[0], 0.001944)
117
+ kit = @runner.run_list[1].graphkit('ion_hflux_gb_prof', {t_index: 1})
118
+ #kit.gnuplot
119
+ assert_equal(kit.data[0].class, GraphKit::DataKit)
120
+ assert_equal(kit.data[0].y.data[0], 0.001975)
121
+ kit = @runner.run_list[1].graphkit('ion_hflux_gb_prof', {t_index: 2, time_average: -1})
122
+ assert_equal([0.001975, 0.001944].sum/2.0, kit.data[0].y.data[0])
123
+ end
60
124
  def teardown
61
125
  FileUtils.rm('test/ifspppl_results/.code_runner_script_defaults.rb')
62
126
  FileUtils.rm_r('test/ifspppl_results/v/id_1/')
data/trinitycrmod.gemspec CHANGED
@@ -2,14 +2,16 @@
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: trinitycrmod 0.3.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "trinitycrmod"
8
- s.version = "0.2.6"
9
+ s.version = "0.3.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Edmund Highcock"]
12
- s.date = "2013-06-24"
14
+ s.date = "2014-02-04"
13
15
  s.description = "This module allows Trinity, the Multiscale Gyrokinetic Turbulent Transport solver for Fusion Reactors, to harness the power of CodeRunner, a framework for the automated running and analysis of simulations."
14
16
  s.email = "edmundhighcock@sourceforge.net"
15
17
  s.extra_rdoc_files = [
@@ -29,8 +31,14 @@ Gem::Specification.new do |s|
29
31
  "lib/trinitycrmod/namelists.rb",
30
32
  "lib/trinitycrmod/output_files.rb",
31
33
  "lib/trinitycrmod/trinity.rb",
34
+ "lib/trinitycrmod/trinity_gs2.rb",
32
35
  "sync_variables/helper.rb",
33
36
  "sync_variables/sync_variables.rb",
37
+ "test/gs2_42982/pr08_jet_42982_1d.dat.gz",
38
+ "test/gs2_42982/pr08_jet_42982_2d.dat.gz",
39
+ "test/gs2_42982/shot42982_jet.in",
40
+ "test/gs2_42982/shot42982_jet.trin",
41
+ "test/gs2_42982_results/v.tgz",
34
42
  "test/helper.rb",
35
43
  "test/ifspppl/test.trin",
36
44
  "test/ifspppl_results/v/id_1.tgz",
@@ -39,35 +47,37 @@ Gem::Specification.new do |s|
39
47
  ]
40
48
  s.homepage = "http://github.com/edmundhighcock/trinitycrmod"
41
49
  s.licenses = ["GPLv3"]
42
- s.require_paths = ["lib"]
43
- s.rubygems_version = "1.8.23"
50
+ s.rubygems_version = "2.2.1"
44
51
  s.summary = "CodeRunner module for the Trinity simulation software."
45
52
 
46
53
  if s.respond_to? :specification_version then
47
- s.specification_version = 3
54
+ s.specification_version = 4
48
55
 
49
56
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<coderunner>, [">= 0.11.0"])
57
+ s.add_runtime_dependency(%q<coderunner>, [">= 0.14.0"])
51
58
  s.add_runtime_dependency(%q<text-data-tools>, [">= 1.1.3"])
59
+ s.add_runtime_dependency(%q<gs2crmod>, [">= 0.11.10"])
52
60
  s.add_development_dependency(%q<shoulda>, [">= 0"])
53
61
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
54
62
  s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
55
- s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
63
+ s.add_development_dependency(%q<jeweler>, [">= 2.0.0"])
56
64
  else
57
- s.add_dependency(%q<coderunner>, [">= 0.11.0"])
65
+ s.add_dependency(%q<coderunner>, [">= 0.14.0"])
58
66
  s.add_dependency(%q<text-data-tools>, [">= 1.1.3"])
67
+ s.add_dependency(%q<gs2crmod>, [">= 0.11.10"])
59
68
  s.add_dependency(%q<shoulda>, [">= 0"])
60
69
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
61
70
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
62
- s.add_dependency(%q<jeweler>, [">= 1.8.4"])
71
+ s.add_dependency(%q<jeweler>, [">= 2.0.0"])
63
72
  end
64
73
  else
65
- s.add_dependency(%q<coderunner>, [">= 0.11.0"])
74
+ s.add_dependency(%q<coderunner>, [">= 0.14.0"])
66
75
  s.add_dependency(%q<text-data-tools>, [">= 1.1.3"])
76
+ s.add_dependency(%q<gs2crmod>, [">= 0.11.10"])
67
77
  s.add_dependency(%q<shoulda>, [">= 0"])
68
78
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
79
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
70
- s.add_dependency(%q<jeweler>, [">= 1.8.4"])
80
+ s.add_dependency(%q<jeweler>, [">= 2.0.0"])
71
81
  end
72
82
  end
73
83
 
metadata CHANGED
@@ -1,112 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trinitycrmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Edmund Highcock
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: coderunner
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 0.11.0
19
+ version: 0.14.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 0.11.0
26
+ version: 0.14.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: text-data-tools
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.1.3
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.1.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: gs2crmod
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.11.10
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.11.10
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: shoulda
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: rdoc
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
- - - ~>
73
+ - - "~>"
68
74
  - !ruby/object:Gem::Version
69
75
  version: '3.12'
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
- - - ~>
80
+ - - "~>"
76
81
  - !ruby/object:Gem::Version
77
82
  version: '3.12'
78
83
  - !ruby/object:Gem::Dependency
79
84
  name: bundler
80
85
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
- - - ! '>'
87
+ - - ">"
84
88
  - !ruby/object:Gem::Version
85
89
  version: 1.0.0
86
90
  type: :development
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
93
  requirements:
91
- - - ! '>'
94
+ - - ">"
92
95
  - !ruby/object:Gem::Version
93
96
  version: 1.0.0
94
97
  - !ruby/object:Gem::Dependency
95
98
  name: jeweler
96
99
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
100
  requirements:
99
- - - ! '>='
101
+ - - ">="
100
102
  - !ruby/object:Gem::Version
101
- version: 1.8.4
103
+ version: 2.0.0
102
104
  type: :development
103
105
  prerelease: false
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
107
  requirements:
107
- - - ! '>='
108
+ - - ">="
108
109
  - !ruby/object:Gem::Version
109
- version: 1.8.4
110
+ version: 2.0.0
110
111
  description: This module allows Trinity, the Multiscale Gyrokinetic Turbulent Transport
111
112
  solver for Fusion Reactors, to harness the power of CodeRunner, a framework for
112
113
  the automated running and analysis of simulations.
@@ -117,7 +118,7 @@ extra_rdoc_files:
117
118
  - LICENSE.txt
118
119
  - README.rdoc
119
120
  files:
120
- - .document
121
+ - ".document"
121
122
  - Gemfile
122
123
  - LICENSE.txt
123
124
  - README.rdoc
@@ -129,8 +130,14 @@ files:
129
130
  - lib/trinitycrmod/namelists.rb
130
131
  - lib/trinitycrmod/output_files.rb
131
132
  - lib/trinitycrmod/trinity.rb
133
+ - lib/trinitycrmod/trinity_gs2.rb
132
134
  - sync_variables/helper.rb
133
135
  - sync_variables/sync_variables.rb
136
+ - test/gs2_42982/pr08_jet_42982_1d.dat.gz
137
+ - test/gs2_42982/pr08_jet_42982_2d.dat.gz
138
+ - test/gs2_42982/shot42982_jet.in
139
+ - test/gs2_42982/shot42982_jet.trin
140
+ - test/gs2_42982_results/v.tgz
134
141
  - test/helper.rb
135
142
  - test/ifspppl/test.trin
136
143
  - test/ifspppl_results/v/id_1.tgz
@@ -139,29 +146,25 @@ files:
139
146
  homepage: http://github.com/edmundhighcock/trinitycrmod
140
147
  licenses:
141
148
  - GPLv3
149
+ metadata: {}
142
150
  post_install_message:
143
151
  rdoc_options: []
144
152
  require_paths:
145
153
  - lib
146
154
  required_ruby_version: !ruby/object:Gem::Requirement
147
- none: false
148
155
  requirements:
149
- - - ! '>='
156
+ - - ">="
150
157
  - !ruby/object:Gem::Version
151
158
  version: '0'
152
- segments:
153
- - 0
154
- hash: -1744466157144352750
155
159
  required_rubygems_version: !ruby/object:Gem::Requirement
156
- none: false
157
160
  requirements:
158
- - - ! '>='
161
+ - - ">="
159
162
  - !ruby/object:Gem::Version
160
163
  version: '0'
161
164
  requirements: []
162
165
  rubyforge_project:
163
- rubygems_version: 1.8.23
166
+ rubygems_version: 2.2.1
164
167
  signing_key:
165
- specification_version: 3
168
+ specification_version: 4
166
169
  summary: CodeRunner module for the Trinity simulation software.
167
170
  test_files: []