gs2crmod 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/gs2crmod.gemspec +2 -2
- data/lib/gs2crmod/graphs.rb +113 -0
- data/lib/gs2crmod/gsl_data_3d.rb +2 -2
- data/lib/gs2crmod/ingen.rb +2 -2
- data/test/cyclone_low_res.tgz +0 -0
- data/test/test_gs2crmod.rb +37 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/gs2crmod.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gs2crmod"
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.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", "Ferdinand van Wyk"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-07-02"
|
13
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."
|
14
14
|
s.email = "edmundhighcock@sourceforge.net"
|
15
15
|
s.extensions = ["ext/extconf.rb"]
|
data/lib/gs2crmod/graphs.rb
CHANGED
@@ -1958,6 +1958,119 @@ module GraphKits
|
|
1958
1958
|
kit
|
1959
1959
|
end
|
1960
1960
|
end
|
1961
|
+
def g2_by_energy_by_all_k_graphkit(options={})
|
1962
|
+
case options[:command]
|
1963
|
+
when :help
|
1964
|
+
return "Plots g**2 vs Hankel mode for fixed wavenumber and Hankel mode. JTP"
|
1965
|
+
when :options
|
1966
|
+
return []
|
1967
|
+
else
|
1968
|
+
#raise "Velocity space diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vpg"
|
1969
|
+
raise "Velocity space diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vpx#{'%02d'%options[:kx_index]}y#{'%02d'%options[:ky_index]}z#{'%02d'%options[:kz_index]}g"
|
1970
|
+
g2 = []
|
1971
|
+
x_axis = []
|
1972
|
+
File.open("#@directory/#@run_name.vpx#{'%02d'%options[:kx_index]}y#{'%02d'%options[:ky_index]}z#{'%02d'%options[:kz_index]}g","r").each_line do | line |
|
1973
|
+
#File.open("#@directory/#@run_name.vpg","r").each_line do | line |
|
1974
|
+
line_array = line.split(/\s+/).map{|v| v.to_f}
|
1975
|
+
if( options[:il_index] == line_array[4] )
|
1976
|
+
g2.push line_array[1] # **2+line_array[2]**2
|
1977
|
+
x_axis.push line_array[3]
|
1978
|
+
end
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
return GraphKit.quick_create([x_axis,g2])
|
1982
|
+
end
|
1983
|
+
end
|
1984
|
+
def g2_by_energy_by_kx_by_ky_graphkit(options={})
|
1985
|
+
case options[:command]
|
1986
|
+
when :help
|
1987
|
+
return "Plots g**2 vs Hankel mode for fixed wavenumber and Hankel mode. JTP"
|
1988
|
+
when :options
|
1989
|
+
return []
|
1990
|
+
else
|
1991
|
+
raise "Velocity space diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vpg"
|
1992
|
+
g2 = []
|
1993
|
+
x_axis = []
|
1994
|
+
File.open("#@directory/#@run_name.vpx#{'%02d'%options[:kx_index]}y#{'%02d'%options[:ky_index]}g","r").each_line do | line |
|
1995
|
+
#File.open("#@directory/#@run_name.vpg","r").each_line do | line |
|
1996
|
+
line_array = line.split(/\s+/).map{|v| v.to_f}
|
1997
|
+
if( options[:il_index] == line_array[4] )
|
1998
|
+
g2.push line_array[1] # **2+line_array[2]**2
|
1999
|
+
x_axis.push line_array[3]
|
2000
|
+
end
|
2001
|
+
end
|
2002
|
+
|
2003
|
+
return GraphKit.quick_create([x_axis,g2])
|
2004
|
+
end
|
2005
|
+
end
|
2006
|
+
def g2_by_energy_graphkit(options={})
|
2007
|
+
case options[:command]
|
2008
|
+
when :help
|
2009
|
+
return "Plots g**2 vs Hankel mode for fixed wavenumber and Hankel mode. JTP"
|
2010
|
+
when :options
|
2011
|
+
return []
|
2012
|
+
else
|
2013
|
+
raise "Velocity space diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vpg"
|
2014
|
+
g2 = []
|
2015
|
+
x_axis = []
|
2016
|
+
#File.open("#@directory/#@run_name.vpx#{options[:kx_index]}y#{options[:ky_index]}g","r").each_line do | line |
|
2017
|
+
File.open("#@directory/#@run_name.vpg","r").each_line do | line |
|
2018
|
+
line_array = line.split(/\s+/).map{|v| v.to_f}
|
2019
|
+
if( options[:il_index] == line_array[4] )
|
2020
|
+
g2.push line_array[1] # **2+line_array[2]**2
|
2021
|
+
x_axis.push line_array[3]
|
2022
|
+
end
|
2023
|
+
end
|
2024
|
+
|
2025
|
+
return GraphKit.quick_create([x_axis,g2])
|
2026
|
+
end
|
2027
|
+
end
|
2028
|
+
def g2_by_lambda_by_all_k_graphkit(options={})
|
2029
|
+
case options[:command]
|
2030
|
+
when :help
|
2031
|
+
return "Plots g**2 vs Hermite mode for fixed wavenumber and Hankel mode. JTP"
|
2032
|
+
when :options
|
2033
|
+
return []
|
2034
|
+
else
|
2035
|
+
#raise "Velocity space diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vpg"
|
2036
|
+
g2 = []
|
2037
|
+
x_axis = []
|
2038
|
+
#File.open("#@directory/#@run_name.vpx#{options[:kx_index]}y#{options[:ky_index]}g","r").each_line do | line |
|
2039
|
+
#File.open("#@directory/#@run_name.vpg","r").each_line do | line |
|
2040
|
+
File.open("#@directory/#@run_name.vpx#{'%02d'%options[:kx_index]}y#{'%02d'%options[:ky_index]}z#{'%02d'%options[:kz_index]}g","r").each_line do | line |
|
2041
|
+
line_array = line.split(/\s+/).map{|v| v.to_f}
|
2042
|
+
if( options[:e_index] == line_array[3] )
|
2043
|
+
g2.push line_array[1] # **2+line_array[2]**2
|
2044
|
+
x_axis.push line_array[4]
|
2045
|
+
end
|
2046
|
+
end
|
2047
|
+
|
2048
|
+
return GraphKit.quick_create([x_axis,g2])
|
2049
|
+
end
|
2050
|
+
end
|
2051
|
+
def g2_by_lambda_graphkit(options={})
|
2052
|
+
case options[:command]
|
2053
|
+
when :help
|
2054
|
+
return "Plots g**2 vs Hermite mode for fixed wavenumber and Hankel mode. JTP"
|
2055
|
+
when :options
|
2056
|
+
return []
|
2057
|
+
else
|
2058
|
+
raise "Velocity space diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vpg"
|
2059
|
+
g2 = []
|
2060
|
+
x_axis = []
|
2061
|
+
#File.open("#@directory/#@run_name.vpx#{options[:kx_index]}y#{options[:ky_index]}g","r").each_line do | line |
|
2062
|
+
File.open("#@directory/#@run_name.vpg","r").each_line do | line |
|
2063
|
+
line_array = line.split(/\s+/).map{|v| v.to_f}
|
2064
|
+
if( options[:e_index] == line_array[3] )
|
2065
|
+
g2.push line_array[1] # **2+line_array[2]**2
|
2066
|
+
x_axis.push line_array[4]
|
2067
|
+
end
|
2068
|
+
end
|
2069
|
+
|
2070
|
+
return GraphKit.quick_create([x_axis,g2])
|
2071
|
+
end
|
2072
|
+
end
|
2073
|
+
|
1961
2074
|
def vspace_diagnostics_graphkit(options={})
|
1962
2075
|
case options[:command]
|
1963
2076
|
when :help
|
data/lib/gs2crmod/gsl_data_3d.rb
CHANGED
@@ -158,7 +158,7 @@ class CodeRunner::Gs2
|
|
158
158
|
when /phi/
|
159
159
|
time_varying ? 'phi_t' : 'phi'
|
160
160
|
when /density/
|
161
|
-
time_varying ?
|
161
|
+
time_varying ? 'ntot_t' : 'density'
|
162
162
|
end
|
163
163
|
#p name
|
164
164
|
return name
|
@@ -179,7 +179,7 @@ class CodeRunner::Gs2
|
|
179
179
|
if options[:t_index]
|
180
180
|
#ep options; gets
|
181
181
|
raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time
|
182
|
-
arr = GSL::Tensor.new(netcdf_file.var(field_netcdf_name(options[:field_name], true)).get({'start' => [0,(options[:thetamin]||0),0,0, options[:t_index] - 1], 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1, options[:t_index] - 1]}))
|
182
|
+
arr = GSL::Tensor.new(netcdf_file.var(field_netcdf_name(options[:field_name], true)).get({'start' => [0,(options[:thetamin]||0),0,0, species_element, options[:t_index] - 1].compact, 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1, species_element, options[:t_index] - 1].compact}))
|
183
183
|
#ep 'arr.shape', arr.shape
|
184
184
|
arr.reshape!(*arr.shape.slice(1...arr.shape.size))
|
185
185
|
|
data/lib/gs2crmod/ingen.rb
CHANGED
@@ -120,8 +120,8 @@ def ingen
|
|
120
120
|
|
121
121
|
error("Boundary options should not be periodic with finite magnetic shear") if @boundary_option == "periodic" and ((@s_hat_input and @s_hat_input.abs > 1.0e-6) or (@shat and @shat.abs > 1.0e-6))
|
122
122
|
|
123
|
-
error("abs(shat) should not be less that 1.0e-6") if @shat and @shat.abs < 1.0e-6
|
124
|
-
error("abs(s_hat_input) should not be less that 1.0e-6") if @s_hat_input and @s_hat_input.abs < 1.0e-6
|
123
|
+
error("abs(shat) should not be less that 1.0e-6") if @shat and @shat.abs < 1.0e-6 and not agk?
|
124
|
+
error("abs(s_hat_input) should not be less that 1.0e-6") if @s_hat_input and @s_hat_input.abs < 1.0e-6 and not agk?
|
125
125
|
|
126
126
|
# delt
|
127
127
|
|
data/test/cyclone_low_res.tgz
CHANGED
Binary file
|
data/test/test_gs2crmod.rb
CHANGED
@@ -30,11 +30,11 @@ if ENV['GS2_EXEC']
|
|
30
30
|
FileUtils.rm(tfolder + '/v/id_1/.code_runner_run_data')
|
31
31
|
FileUtils.rm(tfolder + '/v/id_1/code_runner_results.rb')
|
32
32
|
# Don't uncomment the line below unless you *really* know what you are doing! Replacing the test archive will break many of the tests
|
33
|
-
|
33
|
+
Dir.chdir('test'){system "tar -czf cyclone_low_res.tgz cyclone_low_res/" unless FileTest.exist?('cyclone_low_res.tgz')}
|
34
34
|
FileUtils.rm_r(tfolder)
|
35
35
|
end
|
36
36
|
def test_submission
|
37
|
-
CodeRunner.submit(C: 'gs2', X: ENV['GS2_EXEC'], D: 'test_gs2crmod', n: '4', Y: tfolder)
|
37
|
+
CodeRunner.submit(C: 'gs2', X: ENV['GS2_EXEC'], D: 'test_gs2crmod', n: '4', Y: tfolder, p: '{write_moments: ".true."}')
|
38
38
|
CodeRunner.status(Y: tfolder)
|
39
39
|
end
|
40
40
|
end
|
@@ -117,6 +117,11 @@ class TestAnalysis < Test::Unit::TestCase
|
|
117
117
|
assert_equal(-0.00352, kit.data[0].f.data[-1,1].round(5))
|
118
118
|
assert_equal(1.707, kit.data[0].x.data[-1,1].round(3))
|
119
119
|
kit.gp.view = ["equal xyz", ",,4.0"]
|
120
|
+
|
121
|
+
kit = @runner.run_list[1].graphkit('density_real_space_poloidal_plane', {n0: 1, Rgeo: 3, interpolate_theta: 8, torphi: Math::PI/4.0, species_index: 1, t_index: 50})
|
122
|
+
assert_equal(-0.00208, kit.data[0].f.data[-1,1].round(5))
|
123
|
+
assert_equal(1.707, kit.data[0].x.data[-1,1].round(3))
|
124
|
+
kit.gp.view = ["equal xyz", ",,4.0"]
|
120
125
|
#kit.gnuplot
|
121
126
|
kit = @runner.run_list[1].graphkit('phi_real_space_standard_representation', {n0: 1, Rgeo: 3, interpolate_theta: 2, torphi_values: [Math::PI/4.0,3.0*Math::PI/4.0], interpolate_y: 2})
|
122
127
|
assert_equal([5,17], kit.data[0].f.data.shape)
|
@@ -137,6 +142,36 @@ end
|
|
137
142
|
|
138
143
|
AGK_SLAB_ITG_LOW_KPERP_FOLDER = 'test/agk_slab_itg_low_kperp'
|
139
144
|
|
145
|
+
class TestAgkAnalysis < Test::Unit::TestCase
|
146
|
+
|
147
|
+
def setup
|
148
|
+
Dir.chdir('test'){assert(system "tar -xzf agk_slab_itg_low_kperp.tgz")}
|
149
|
+
@runner = CodeRunner.fetch_runner(Y: tfolder)
|
150
|
+
@run = @runner.run_list[1]
|
151
|
+
end
|
152
|
+
def tfolder
|
153
|
+
AGK_SLAB_ITG_LOW_KPERP_FOLDER
|
154
|
+
end
|
155
|
+
def test_graphs
|
156
|
+
kit = @runner.run_list[1].graphkit('phi2_by_ky_vs_time', {ky_index: 2})
|
157
|
+
#kit.gnuplot
|
158
|
+
assert_equal(126, kit.data[0].y.data.size)
|
159
|
+
assert_equal(@runner.run_list[1].netcdf_file.var('phi2').get('start' => [4], 'end' => [4]).to_a[0], kit.data[0].y.data[4])
|
160
|
+
end
|
161
|
+
def test_analysis
|
162
|
+
assert_equal(1, @runner.run_list.size)
|
163
|
+
assert_equal(0.03224, @runner.run_list[1].max_growth_rate.round(5))
|
164
|
+
#p @runner.run_list[1].growth_rate_at_ky
|
165
|
+
assert_equal(0.03224, @runner.run_list[1].growth_rate_at_ky[0.01].round(5))
|
166
|
+
assert_equal(:Complete, @runner.run_list[1].status)
|
167
|
+
end
|
168
|
+
def teardown
|
169
|
+
FileUtils.rm_r(tfolder)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
|
140
175
|
if ENV['AGK_EXEC']
|
141
176
|
class TestAstrogkSubmission < Test::Unit::TestCase
|
142
177
|
def setup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gs2crmod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: coderunner
|