gs2crmod 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/ext/gs2crmod_ext.c +1 -1
- data/gs2crmod.gemspec +7 -5
- data/lib/gs2crmod/graphs.rb +111 -48
- data/lib/gs2crmod/gs2.rb +12 -3
- data/lib/gs2crmod/gsl_data.rb +32 -3
- data/lib/gs2crmod/gsl_data_3d.rb +44 -3
- data/lib/gs2crmod/gsl_tools.rb +11 -0
- data/test/cyclone_low_res.in +236 -0
- data/test/cyclone_low_res.tgz +0 -0
- data/test/test_gs2crmod.rb +125 -1
- metadata +6 -4
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
|
-
gem "coderunner", ">= 0.11
|
4
|
+
gem "coderunner", ">= 0.12.11"
|
5
5
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/ext/gs2crmod_ext.c
CHANGED
@@ -211,7 +211,7 @@ VALUE gs2crmod_tensor_field_gsl_tensor(VALUE self, VALUE options)
|
|
211
211
|
/* We are converting a complex array
|
212
212
|
* to a half complex array in
|
213
213
|
* preparation for transforming
|
214
|
-
* it to real space, and so
|
214
|
+
* it to real space, and so there
|
215
215
|
* are one or two elements we leave
|
216
216
|
* unfilled.*/
|
217
217
|
if (i==0 || (c_shape[0]%2==0 && i == c_shape[0]/2 + 1)) continue;
|
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.
|
8
|
+
s.version = "0.7.0"
|
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-06-
|
12
|
+
s.date = "2013-06-28"
|
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"]
|
@@ -62,6 +62,8 @@ Gem::Specification.new do |s|
|
|
62
62
|
"lib/gs2crmod/species_dependent_namelists.rb",
|
63
63
|
"lib/gs2crmod/test_gs2.rb",
|
64
64
|
"lib/gs2crmod_extension.rb",
|
65
|
+
"test/cyclone_low_res.in",
|
66
|
+
"test/cyclone_low_res.tgz",
|
65
67
|
"test/helper.rb",
|
66
68
|
"test/test_gs2crmod.rb"
|
67
69
|
]
|
@@ -76,20 +78,20 @@ Gem::Specification.new do |s|
|
|
76
78
|
s.specification_version = 3
|
77
79
|
|
78
80
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
79
|
-
s.add_runtime_dependency(%q<coderunner>, [">= 0.11
|
81
|
+
s.add_runtime_dependency(%q<coderunner>, [">= 0.12.11"])
|
80
82
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
81
83
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
82
84
|
s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
|
83
85
|
s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
|
84
86
|
else
|
85
|
-
s.add_dependency(%q<coderunner>, [">= 0.11
|
87
|
+
s.add_dependency(%q<coderunner>, [">= 0.12.11"])
|
86
88
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
87
89
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
88
90
|
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
89
91
|
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
90
92
|
end
|
91
93
|
else
|
92
|
-
s.add_dependency(%q<coderunner>, [">= 0.11
|
94
|
+
s.add_dependency(%q<coderunner>, [">= 0.12.11"])
|
93
95
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
94
96
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
95
97
|
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
data/lib/gs2crmod/graphs.rb
CHANGED
@@ -615,25 +615,25 @@ module GraphKits
|
|
615
615
|
end
|
616
616
|
end
|
617
617
|
|
618
|
-
def
|
618
|
+
def field_flux_tube_boundary_surface_graphkit(options={})
|
619
619
|
case options[:command]
|
620
620
|
when :help
|
621
|
-
return "The
|
621
|
+
return "The field options[:field_name] as a function of cartesian coordinates, on one specified side of the flux tube (specified using the options :coordinate (:x, :y, :theta) and :side (:min, :max))"
|
622
622
|
when :options
|
623
623
|
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :gs2_coordinate_factor, :xmax, :xmin, :ymax, :ymin, :thetamax, :thetamin, :ncopies, :side, :coordinate, :torphi_values]
|
624
624
|
else
|
625
|
-
|
625
|
+
field = options[:field] || field_real_space_gsl_tensor(options)
|
626
626
|
if options[:ncopies]
|
627
627
|
ops = options.dup
|
628
628
|
ops.delete(:ncopies)
|
629
629
|
return (options[:ncopies].times.map do |n|
|
630
630
|
ops[:ncopy] = n
|
631
|
-
|
631
|
+
field_flux_tube_boundary_surface_graphkit(ops)
|
632
632
|
end).sum
|
633
633
|
end
|
634
634
|
side = options[:side]
|
635
635
|
coord = options[:coordinate]
|
636
|
-
shp =
|
636
|
+
shp = field.shape
|
637
637
|
#raise " asdfal" unless shp
|
638
638
|
opside = side == :max ? :min : :max
|
639
639
|
ops = options.dup
|
@@ -669,7 +669,7 @@ module GraphKits
|
|
669
669
|
else
|
670
670
|
coords = cartesian_coordinates_gsl_tensor(ops)
|
671
671
|
end
|
672
|
-
#ep ['coords', coords.shape,
|
672
|
+
#ep ['coords', coords.shape, field.shape]; gets
|
673
673
|
newshape = coords.shape.slice(1..3)
|
674
674
|
x = coords[0, false]; x.reshape!(*newshape)
|
675
675
|
y = coords[1, false]; y.reshape!(*newshape)
|
@@ -683,12 +683,12 @@ module GraphKits
|
|
683
683
|
#((ops[:thetamin]||0) - (options[:thetamin]||0))..((ops[:thetamax]||shp[2]-1) - (options[:thetamin]||0))
|
684
684
|
]
|
685
685
|
|
686
|
-
#ep ['range', range, '
|
687
|
-
|
688
|
-
#ep ['coords', x.shape,
|
689
|
-
kit = GraphKit.quick_create([x,y,z,
|
686
|
+
#ep ['range', range, 'field.shape', field.shape]
|
687
|
+
fieldside = field[*range ]
|
688
|
+
#ep ['coords', x.shape, fieldside.shape]; gets
|
689
|
+
kit = GraphKit.quick_create([x,y,z,fieldside])
|
690
690
|
|
691
|
-
# Create a map of this surface onto a continuous surface between two poloidal planes if ops[:
|
691
|
+
# Create a map of this surface onto a continuous surface between two poloidal planes if ops[:torfield_values] is specified
|
692
692
|
if torphi_values = ops[:torphi_values]
|
693
693
|
raise "Can't take a poloidal cut at constant y or theta" if coord == :y #or coord == :theta
|
694
694
|
raise "Can't take a poloidal cut with a limited y range (Remove :ymin and :ymax from ops)" if options[:ymin] or options[:ymax]
|
@@ -721,13 +721,13 @@ module GraphKits
|
|
721
721
|
#ysize = (torphi_const0[-1] - torphi_const1[0] ).abs + 1
|
722
722
|
#case coord
|
723
723
|
#when :x
|
724
|
-
shpside =
|
725
|
-
|
724
|
+
shpside = fieldside.shape
|
725
|
+
fieldcut = GSL::Tensor.float(ysize, shpside[1], shpside[2])
|
726
726
|
xcut = GSL::Tensor.float(ysize, shpside[1], shpside[2])
|
727
727
|
ycut = GSL::Tensor.float(ysize, shpside[1], shpside[2])
|
728
728
|
zcut = GSL::Tensor.float(ysize, shpside[1], shpside[2])
|
729
729
|
#ep shpside
|
730
|
-
shpcut =
|
730
|
+
shpcut = fieldcut.shape
|
731
731
|
for k in 0...shpcut[2] # 1 of these 2 loops
|
732
732
|
for j in 0...shpcut[1] # will have size 1
|
733
733
|
|
@@ -765,9 +765,9 @@ module GraphKits
|
|
765
765
|
dfac = 0
|
766
766
|
end
|
767
767
|
|
768
|
-
#ep [(
|
768
|
+
#ep [(fieldside[i%ny,j,k] * (1-dfac) + fieldside[(i+1)%ny,j,k] * dfac).class, i,j,k, fieldside.shape, ny ]
|
769
769
|
|
770
|
-
|
770
|
+
fieldcut[n,j,k] = fieldside[i%ny,j,k] * (1-dfac) + fieldside[((i+1)%ny),j,k] * dfac
|
771
771
|
|
772
772
|
rad = cyls[0,i%ny,j,k]
|
773
773
|
xcut[n,j,k] = rad * c
|
@@ -780,7 +780,7 @@ module GraphKits
|
|
780
780
|
end
|
781
781
|
end
|
782
782
|
|
783
|
-
kit = GraphKit.quick_create([xcut,ycut,zcut,
|
783
|
+
kit = GraphKit.quick_create([xcut,ycut,zcut,fieldcut])
|
784
784
|
end
|
785
785
|
|
786
786
|
|
@@ -793,6 +793,16 @@ module GraphKits
|
|
793
793
|
end
|
794
794
|
|
795
795
|
end
|
796
|
+
def density_real_space_standard_representation_graphkit(options={})
|
797
|
+
case options[:command]
|
798
|
+
when :help
|
799
|
+
return "The density as a function of cartesian coordinates showing showing the standard way of representing the turbulence, with two poloidal cuts and the inner and outer radial surfaces. Multiple copies of the flux tube are used to fill the space."
|
800
|
+
when :options
|
801
|
+
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :xmax, :xmin, :thetamax, :thetamin, :torphi_values, :species_index]
|
802
|
+
else
|
803
|
+
field_real_space_standard_representation_graphkit(options.absorb({field_name: :density}))
|
804
|
+
end
|
805
|
+
end
|
796
806
|
def phi_real_space_standard_representation_graphkit(options={})
|
797
807
|
case options[:command]
|
798
808
|
when :help
|
@@ -800,29 +810,39 @@ module GraphKits
|
|
800
810
|
when :options
|
801
811
|
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :xmax, :xmin, :thetamax, :thetamin, :torphi_values]
|
802
812
|
else
|
803
|
-
|
804
|
-
|
813
|
+
field_real_space_standard_representation_graphkit(options.absorb({field_name: :phi}))
|
814
|
+
end
|
815
|
+
end
|
816
|
+
def field_real_space_standard_representation_graphkit(options={})
|
817
|
+
case options[:command]
|
818
|
+
when :help
|
819
|
+
return "The field options[:field_name] as a function of cartesian coordinates showing showing the standard way of representing the turbulence, with two poloidal cuts and the inner and outer radial surfaces. Multiple copies of the flux tube are used to fill the space."
|
820
|
+
when :options
|
821
|
+
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :xmax, :xmin, :thetamax, :thetamin, :torphi_values]
|
822
|
+
else
|
823
|
+
field = field_real_space_gsl_tensor(options)
|
824
|
+
options[:field] = field
|
805
825
|
poloidal_planes = options[:torphi_values]
|
806
826
|
#ep poloidal_planes; gets
|
807
827
|
raise "Please set options[:torphi_values] to an array of two values" unless poloidal_planes.kind_of? Array and poloidal_planes.size==2
|
808
828
|
options[:torphi] = poloidal_planes[0]
|
809
|
-
kit1 =
|
829
|
+
kit1 = field_real_space_poloidal_plane_graphkit(options)
|
810
830
|
options[:torphi] = poloidal_planes[1]
|
811
|
-
kit2 =
|
831
|
+
kit2 = field_real_space_poloidal_plane_graphkit(options)
|
812
832
|
options[:coordinate] = :x
|
813
833
|
options[:side] = :min
|
814
|
-
kit3 =
|
834
|
+
kit3 = field_flux_tube_boundary_surface_graphkit(options)
|
815
835
|
options[:side] = :max
|
816
|
-
kit4 =
|
836
|
+
kit4 = field_flux_tube_boundary_surface_graphkit(options)
|
817
837
|
#kit= kit1+kit2
|
818
838
|
#kit = kit3 +kit4
|
819
839
|
kit = kit1+kit2+kit3+kit4
|
820
840
|
if options[:thetamax] or options[:thetamin]
|
821
841
|
options[:coordinate] = :theta
|
822
842
|
options[:side] = :min
|
823
|
-
kit5 =
|
843
|
+
kit5 = field_flux_tube_boundary_surface_graphkit(options)
|
824
844
|
options[:side] = :max
|
825
|
-
kit6 =
|
845
|
+
kit6 = field_flux_tube_boundary_surface_graphkit(options)
|
826
846
|
kit += kit5+kit6
|
827
847
|
end
|
828
848
|
kit.gp.pm3d = "depthorder"
|
@@ -850,7 +870,7 @@ module GraphKits
|
|
850
870
|
when :options
|
851
871
|
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :xmax, :xmin, :thetamax, :thetamin, :torphi]
|
852
872
|
else
|
853
|
-
return field_real_space_poloidal_plane_graphkit(options.absorb(
|
873
|
+
return field_real_space_poloidal_plane_graphkit(options.absorb({field_name: :density}))
|
854
874
|
end
|
855
875
|
end
|
856
876
|
def field_real_space_poloidal_plane_graphkit(options={})
|
@@ -865,26 +885,26 @@ module GraphKits
|
|
865
885
|
#ops.delete(:ncopies)
|
866
886
|
#return (options[:ncopies].times.map do |n|
|
867
887
|
#ops[:ncopy] = n
|
868
|
-
#
|
888
|
+
#field_real_space_surface_graphkit(ops)
|
869
889
|
#end).sum
|
870
890
|
#end
|
871
|
-
#zaxis = axiskit('
|
891
|
+
#zaxis = axiskit('field0_over_x_over_y', options)
|
872
892
|
#zaxis.data = zaxis.data.transpose
|
873
893
|
#shape = zaxis.data.shape
|
874
894
|
#carts = cartesian_coordinates_gsl_tensor(options)
|
875
895
|
#torphiout = 2.6
|
876
896
|
torphiout = options[:torphi]
|
877
|
-
|
897
|
+
field = options[:field] || field_real_space_gsl_tensor(options)
|
878
898
|
torphi_const = constant_torphi_surface_gsl_tensor(options)
|
879
899
|
cyls = cylindrical_coordinates_gsl_tensor(options.absorb({extra_points: true}))
|
880
900
|
#p torphi_const[0,true].to_a;
|
881
901
|
#p 'sh', cyls.shape[1], '','','','';
|
882
902
|
#exit
|
883
903
|
#carts = cartesian_coordinates_gsl_tensor(options)
|
884
|
-
shp =
|
904
|
+
shp = field.shape
|
885
905
|
shpc = cyls.shape
|
886
906
|
#ep 'shapes', shp, cyls.shape
|
887
|
-
|
907
|
+
new_field = GSL::Tensor.alloc(shp[1], shp[2])
|
888
908
|
new_X = GSL::Tensor.alloc(shp[1], shp[2])
|
889
909
|
new_Y = GSL::Tensor.alloc(shp[1], shp[2])
|
890
910
|
new_Z = GSL::Tensor.alloc(shp[1], shp[2])
|
@@ -895,10 +915,10 @@ module GraphKits
|
|
895
915
|
#theta_vec = gsl_vector('theta', options)
|
896
916
|
#x_vec = gsl_vector('x', options)
|
897
917
|
#y_vec = gsl_vector('y', options)
|
898
|
-
#
|
918
|
+
#field.iterate do |i,j,k|
|
899
919
|
#lastbracketed = nil
|
900
920
|
#lastj = -1
|
901
|
-
#
|
921
|
+
#field.iterate_row_maj do |i,j,k|
|
902
922
|
for k in 0...shp[2] #theta loop
|
903
923
|
for j in 0...shp[1] #xloop
|
904
924
|
#raise "Missed #{[j,k].inspect}, #{lastj}" unless lastj == j-1
|
@@ -973,9 +993,9 @@ module GraphKits
|
|
973
993
|
#raise "Missed: #{i},#{j}, #{lastbracketed.inspect} " unless lastbracketed == [j-1,k] or lastbracketed == [shp[1]-1, k-1] if lastbracketed
|
974
994
|
#ep bracketed,"********"
|
975
995
|
#ep ['bracketed', i, j, k]
|
976
|
-
#ep ['
|
996
|
+
#ep ['field', field[i,j,k]]
|
977
997
|
#new_phi[j,k] = theta_vec[k]
|
978
|
-
|
998
|
+
new_field[j,k] = field[i,j,k] * (1-dfac) + field[(i+1)%shp[0],j,k] * dfac
|
979
999
|
#raise "Mismatched radii" unless
|
980
1000
|
#new_X[j,k] = cyls[0,i,j,k] * Math.cos(cyls[2,i,j,k])
|
981
1001
|
#new_X[j,k] = x_vec[j]
|
@@ -991,7 +1011,7 @@ module GraphKits
|
|
991
1011
|
end # xloop
|
992
1012
|
end # theta loop
|
993
1013
|
#exit
|
994
|
-
kit = GraphKit.quick_create([new_X, new_Y, new_Z,
|
1014
|
+
kit = GraphKit.quick_create([new_X, new_Y, new_Z, new_field])
|
995
1015
|
kit.xlabel = 'X'
|
996
1016
|
kit.ylabel = 'Y'
|
997
1017
|
kit.data[0].gp.with = "pm3d"
|
@@ -1014,12 +1034,12 @@ module GraphKits
|
|
1014
1034
|
#[0].each do |toroidalphi|
|
1015
1035
|
#raise unless i.kind_of? Integer
|
1016
1036
|
#return kit if coord + side == :xmax
|
1017
|
-
options[:
|
1037
|
+
options[:field] = field
|
1018
1038
|
options[:side] = side
|
1019
1039
|
options[:coordinate] = coord
|
1020
1040
|
options[:toroidal_projection] = coord == :x ? nil : toroidalphi
|
1021
1041
|
next if coord == :x and toroidalphi == Math::PI
|
1022
|
-
kit =
|
1042
|
+
kit = field_flux_tube_boundary_surface_graphkit(options)
|
1023
1043
|
kits.push kit
|
1024
1044
|
end
|
1025
1045
|
#end
|
@@ -1523,36 +1543,57 @@ module GraphKits
|
|
1523
1543
|
end
|
1524
1544
|
|
1525
1545
|
|
1546
|
+
def density_real_space_surface_graphkit(options={})
|
1547
|
+
case options[:command]
|
1548
|
+
when :help
|
1549
|
+
return "The density as a function of cartesian coordinates, plotted on the six outer surfaces of constant x, y and theta."
|
1550
|
+
when :options
|
1551
|
+
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :gs2_coordinate_factor, :xmax, :xmin, :ymax, :ymin, :thetamax, :thetamin, :ncopies]
|
1552
|
+
else
|
1553
|
+
return field_real_space_surface_graphkit(options.absorb({field_name: :density}))
|
1554
|
+
end
|
1555
|
+
end
|
1526
1556
|
def phi_real_space_surface_graphkit(options={})
|
1527
1557
|
case options[:command]
|
1528
1558
|
when :help
|
1529
1559
|
return "The potential as a function of cartesian coordinates, plotted on the six outer surfaces of constant x, y and theta."
|
1530
1560
|
when :options
|
1531
1561
|
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :gs2_coordinate_factor, :xmax, :xmin, :ymax, :ymin, :thetamax, :thetamin, :ncopies]
|
1562
|
+
else
|
1563
|
+
return field_real_space_surface_graphkit(options.absorb({field_name: :phi}))
|
1564
|
+
end
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
def field_real_space_surface_graphkit(options={})
|
1568
|
+
case options[:command]
|
1569
|
+
when :help
|
1570
|
+
return "The field options[:field_name] as a function of cartesian coordinates, plotted on the six outer surfaces of constant x, y and theta."
|
1571
|
+
when :options
|
1572
|
+
return [:Rgeo, :n0, :rho_star, :t_index, :nakx, :naky, :gs2_coordinate_factor, :xmax, :xmin, :ymax, :ymin, :thetamax, :thetamin, :ncopies]
|
1532
1573
|
else
|
1533
1574
|
if options[:ncopies]
|
1534
1575
|
ops = options.dup
|
1535
1576
|
ops.delete(:ncopies)
|
1536
1577
|
return (options[:ncopies].times.map do |n|
|
1537
1578
|
ops[:ncopy] = n
|
1538
|
-
|
1579
|
+
field_real_space_surface_graphkit(ops)
|
1539
1580
|
end).sum
|
1540
1581
|
end
|
1541
|
-
#zaxis = axiskit('
|
1582
|
+
#zaxis = axiskit('field0_over_x_over_y', options)
|
1542
1583
|
#zaxis.data = zaxis.data.transpose
|
1543
1584
|
#shape = zaxis.data.shape
|
1544
1585
|
#carts = cartesian_coordinates_gsl_tensor(options)
|
1545
|
-
|
1586
|
+
field = options[:field] || field_real_space_gsl_tensor(options)
|
1546
1587
|
sides = [:max, :min]
|
1547
1588
|
kits = []
|
1548
1589
|
[:y, :x, :theta].each_with_index do |coord,i|
|
1549
1590
|
sides.each_with_index do |side,j|
|
1550
1591
|
raise unless i.kind_of? Integer
|
1551
1592
|
#return kit if coord + side == :xmax
|
1552
|
-
options[:
|
1593
|
+
options[:field] = field
|
1553
1594
|
options[:side] = side
|
1554
1595
|
options[:coordinate] = coord
|
1555
|
-
kit =
|
1596
|
+
kit = field_flux_tube_boundary_surface_graphkit(options)
|
1556
1597
|
kits.push kit
|
1557
1598
|
end
|
1558
1599
|
end
|
@@ -1577,26 +1618,48 @@ module GraphKits
|
|
1577
1618
|
|
1578
1619
|
end
|
1579
1620
|
end
|
1621
|
+
def density_real_space_graphkit(options={})
|
1622
|
+
case options[:command]
|
1623
|
+
when :help
|
1624
|
+
return "The potential as a function of cartesian coordinates"
|
1625
|
+
when :options
|
1626
|
+
return [:rgbformulae, :limit, :t_index]
|
1627
|
+
else
|
1628
|
+
kit = field_real_space_graphkit(options.absorb({field_name: :density}))
|
1629
|
+
kit.title = 'Density'
|
1630
|
+
kit
|
1631
|
+
end
|
1632
|
+
end
|
1580
1633
|
def phi_real_space_graphkit(options={})
|
1581
1634
|
case options[:command]
|
1582
1635
|
when :help
|
1583
1636
|
return "The potential as a function of cartesian coordinates"
|
1584
1637
|
when :options
|
1585
1638
|
return [:rgbformulae, :limit, :t_index]
|
1639
|
+
else
|
1640
|
+
return field_real_space_graphkit(options.absorb({field_name: :phi}))
|
1641
|
+
end
|
1642
|
+
end
|
1643
|
+
def field_real_space_graphkit(options={})
|
1644
|
+
case options[:command]
|
1645
|
+
when :help
|
1646
|
+
return "The field options[:field_name] as a function of cartesian coordinates"
|
1647
|
+
when :options
|
1648
|
+
return [:rgbformulae, :limit, :t_index]
|
1586
1649
|
else
|
1587
1650
|
if options[:ncopies]
|
1588
1651
|
ops = options.dup
|
1589
1652
|
ops.delete(:ncopies)
|
1590
1653
|
return (options[:ncopies].times.map do |n|
|
1591
1654
|
ops[:ncopy] = n
|
1592
|
-
|
1655
|
+
field_real_space_graphkit(ops)
|
1593
1656
|
end).sum
|
1594
1657
|
end
|
1595
|
-
#zaxis = axiskit('
|
1658
|
+
#zaxis = axiskit('field0_over_x_over_y', options)
|
1596
1659
|
#zaxis.data = zaxis.data.transpose
|
1597
1660
|
#shape = zaxis.data.shape
|
1598
1661
|
#carts = cartesian_coordinates_gsl_tensor(options)
|
1599
|
-
|
1662
|
+
field = field_real_space_gsl_tensor(options)
|
1600
1663
|
if options[:cyl]
|
1601
1664
|
carts = cylindrical_coordinates_gsl_tensor(options) #.transpose(0,1,2,3)
|
1602
1665
|
else
|
@@ -1613,7 +1676,7 @@ module GraphKits
|
|
1613
1676
|
#x = x.transpose(2,1,0)
|
1614
1677
|
#y = y.transpose(2,1,0)
|
1615
1678
|
#z = z.transpose(2,1,0)
|
1616
|
-
#
|
1679
|
+
#field = field.transpose(2,1,0)
|
1617
1680
|
end
|
1618
1681
|
|
1619
1682
|
|
@@ -1621,7 +1684,7 @@ module GraphKits
|
|
1621
1684
|
x: GraphKit::AxisKit.autocreate({data: x, title: "X", units: "m"}),
|
1622
1685
|
y: GraphKit::AxisKit.autocreate({data: y, title: "Y", units: "m"}),
|
1623
1686
|
z: GraphKit::AxisKit.autocreate({data: z, title: "Z", units: "m"}),
|
1624
|
-
f: GraphKit::AxisKit.autocreate({data:
|
1687
|
+
f: GraphKit::AxisKit.autocreate({data: field, title: "Phi"})
|
1625
1688
|
})
|
1626
1689
|
# kit.xrange = [0,shape[0]]
|
1627
1690
|
# kit.yrange = [0,shape[1]]
|
data/lib/gs2crmod/gs2.rb
CHANGED
@@ -449,10 +449,18 @@ def get_list_of(*args)
|
|
449
449
|
next if (cache[list_name] and [:Failed, :Complete].include? status and not refresh)
|
450
450
|
|
451
451
|
cache[list_name] = {}
|
452
|
-
netcdf_file.var(var.to_s)
|
453
|
-
|
454
|
-
|
452
|
+
if netcdf_file.var(var.to_s)
|
453
|
+
netcdf_file.var(var.to_s).get.to_a.each_with_index do |value, element|
|
454
|
+
# print '.'
|
455
|
+
cache[list_name][element+1]=value
|
456
|
+
end
|
457
|
+
|
458
|
+
else
|
459
|
+
netcdf_file.dim(var.to_s).length.times.each do |element|
|
460
|
+
cache[list_name][element+1]='unknown'
|
461
|
+
end
|
455
462
|
end
|
463
|
+
|
456
464
|
# eputs send(var+:_list)
|
457
465
|
end
|
458
466
|
end
|
@@ -1152,6 +1160,7 @@ class Hash
|
|
1152
1160
|
p self[:ky_index] = ky_element + 1
|
1153
1161
|
self[:strongest_non_zonal_mode] = false
|
1154
1162
|
end
|
1163
|
+
raise "No names specified" if names.size == 0
|
1155
1164
|
|
1156
1165
|
|
1157
1166
|
# ep run
|
data/lib/gs2crmod/gsl_data.rb
CHANGED
@@ -117,10 +117,36 @@ def gsl_vector(name, options={})
|
|
117
117
|
options[:t_index_window] ||= @scan_index_window
|
118
118
|
options.setup_time_window
|
119
119
|
if [:ky, :kx].include? name.to_sym
|
120
|
-
|
120
|
+
vec = fix_norm(
|
121
121
|
GSL::Vector.alloc(netcdf_file.var(name.to_s).get.to_a.sort),
|
122
122
|
-1, options
|
123
123
|
) # ky, ky are normalised to 1 / rho_i
|
124
|
+
if i = options[:interpolate_ + name.to_s.sub(/k/, '').to_sym]
|
125
|
+
if name.to_sym == :ky
|
126
|
+
s = (vec.size - 1)*i + 1
|
127
|
+
#return vec.connect(GSL::Vector.alloc((vec.size-1)*(i-1)) * 0.0)
|
128
|
+
return (0...s).map{|k| k.to_f * vec[1]}.to_gslv
|
129
|
+
else
|
130
|
+
size = vec.size
|
131
|
+
#vec = vec.to_box_order
|
132
|
+
raise "Hmmm, kx.size should be odd" unless size%2 == 1
|
133
|
+
s = (size-1)/2 * i
|
134
|
+
return (-s..s).to_a.map{|i| i.to_f * vec.to_box_order[1]}.to_gslv
|
135
|
+
#new_vec = GSL::Vector.alloc((s-1)*i + 1)
|
136
|
+
#new_vec *= 0.0
|
137
|
+
#for j in 0...((s-1)/2+1)
|
138
|
+
#new_vec[j] = vec[j]
|
139
|
+
#end
|
140
|
+
#for j in 0...((s-1)/2)
|
141
|
+
#new_vec[-j-1] = vec[-j-1]
|
142
|
+
#end
|
143
|
+
#return new_vec.from_box_order
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
else
|
148
|
+
return vec
|
149
|
+
end
|
124
150
|
elsif [:theta].include? name.to_sym
|
125
151
|
#ep options; gets
|
126
152
|
#vec = GSL::Vector.alloc(netcdf_file.var(name.to_s).get({'start' => [options[:thetamin]||0], 'end' => [options[:thetamax]||-1]}).to_a)
|
@@ -731,13 +757,16 @@ module GSLVectors
|
|
731
757
|
end
|
732
758
|
end
|
733
759
|
def x_gsl_vector(options)
|
734
|
-
|
760
|
+
raise "options nakx and interpolate_x are incompatible" if options[:nakx] and options[:interpolate_x]
|
761
|
+
kx = gsl_vector(:kx, options)
|
735
762
|
lx = 2*Math::PI/kx.to_box_order[1]
|
763
|
+
#ep 'lx', lx
|
736
764
|
nx = options[:nakx]||kx.size
|
737
765
|
GSL::Vector.indgen(nx, 0, lx/nx)
|
738
766
|
end
|
739
767
|
def y_gsl_vector(options)
|
740
|
-
|
768
|
+
raise "options naky and interpolate_y are incompatible" if options[:naky] and options[:interpolate_y]
|
769
|
+
ky = gsl_vector(:ky, options)
|
741
770
|
ly = 2*Math::PI/ky[1]
|
742
771
|
ny = options[:naky]||ky.size
|
743
772
|
ysize = ny*2-2+ny%2
|
data/lib/gs2crmod/gsl_data_3d.rb
CHANGED
@@ -152,18 +152,59 @@ class CodeRunner::Gs2
|
|
152
152
|
return arr
|
153
153
|
|
154
154
|
end
|
155
|
+
def field_netcdf_name(field_name, time_varying = false)
|
156
|
+
#p field_name.to_s
|
157
|
+
name = case field_name.to_s
|
158
|
+
when /phi/
|
159
|
+
time_varying ? 'phi_t' : 'phi'
|
160
|
+
when /density/
|
161
|
+
time_varying ? raise("") : 'density'
|
162
|
+
end
|
163
|
+
#p name
|
164
|
+
return name
|
165
|
+
end
|
166
|
+
def field_species_element(options)
|
167
|
+
case options[:field_name].to_s
|
168
|
+
when /density/
|
169
|
+
options.convert_to_index(self, :species)
|
170
|
+
ep 'options', options
|
171
|
+
options[:species_index] - 1
|
172
|
+
else
|
173
|
+
nil
|
174
|
+
end
|
175
|
+
end
|
155
176
|
def field_gsl_tensor(options)
|
177
|
+
species_element = field_species_element(options)
|
178
|
+
ep 'species_element', species_element
|
156
179
|
if options[:t_index]
|
157
180
|
#ep options; gets
|
158
181
|
raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time
|
159
|
-
arr = GSL::Tensor.new(netcdf_file.var(options[:field_name]
|
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]}))
|
160
183
|
#ep 'arr.shape', arr.shape
|
161
184
|
arr.reshape!(*arr.shape.slice(1...arr.shape.size))
|
162
185
|
|
163
186
|
else
|
164
|
-
arr = GSL::Tensor.new(netcdf_file.var(options[:field_name]).get({'start' => [0,(options[:thetamin]||0),0,0], 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1]}))
|
187
|
+
arr = GSL::Tensor.new(netcdf_file.var(field_netcdf_name(options[:field_name])).get({'start' => [0,(options[:thetamin]||0),0,0, species_element].compact, 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1, species_element].compact}))
|
165
188
|
#ep 'arr.shape', arr.shape
|
166
189
|
end
|
190
|
+
if species_element
|
191
|
+
arr.reshape!(*arr.shape.slice(1...arr.shape.size))
|
192
|
+
end
|
193
|
+
if options[:interpolate_x]
|
194
|
+
shape = arr.narray.shape
|
195
|
+
#p 'shape', shape
|
196
|
+
shape[2] = (shape[2]-1)*options[:interpolate_x] + 1
|
197
|
+
#p shape
|
198
|
+
arr = GSL::Tensor.new(arr.narray.expand(*shape, 0.0))
|
199
|
+
end
|
200
|
+
if options[:interpolate_y]
|
201
|
+
shape = arr.narray.shape
|
202
|
+
#p 'shape', shape
|
203
|
+
shape[3] = (shape[3]-1)*options[:interpolate_y] + 1
|
204
|
+
#p shape
|
205
|
+
arr = GSL::Tensor.new(arr.narray.expand(*shape, 0.0))
|
206
|
+
end
|
207
|
+
|
167
208
|
arr[0, true, true, true] = 0.0 if options[:no_zonal]
|
168
209
|
#arr = arr[options[:nakx] ? 0...options[:nakx] : true, options[:naky] ? 0...options[:naky] : true, true, true] if options[:nakx] or options[:naky]
|
169
210
|
return arr
|
@@ -496,7 +537,7 @@ class CodeRunner::Gs2
|
|
496
537
|
#return torphi_const
|
497
538
|
#end
|
498
539
|
|
499
|
-
FIELD_VALUES = [:phi]
|
540
|
+
FIELD_VALUES = [:phi, :density, :apar, :bpar]
|
500
541
|
TRIVIAL_INDICES = [:graphkit_name]
|
501
542
|
TIME_VARYING_INDICES = [:t_index, :begin_element, :end_element, :frame_index, :t_index_window]
|
502
543
|
IRRELEVANT_INDICES = FIELD_VALUES + TRIVIAL_INDICES + TIME_VARYING_INDICES
|
data/lib/gs2crmod/gsl_tools.rb
CHANGED
@@ -185,3 +185,14 @@ def forward_rows_r2cc
|
|
185
185
|
end
|
186
186
|
|
187
187
|
end
|
188
|
+
|
189
|
+
|
190
|
+
class NArray
|
191
|
+
def expand(*new_shape, empty_value)
|
192
|
+
na = NArray.new(self.typecode,*new_shape)
|
193
|
+
na[true] = empty_value
|
194
|
+
range = self.shape.map{|n| 0...n}
|
195
|
+
na[*range] = self
|
196
|
+
return na
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
!==============================================================================
|
2
|
+
! GS2 INPUT FILE automatically generated by CodeRunner
|
3
|
+
!==============================================================================
|
4
|
+
!
|
5
|
+
! GS2 is a gyrokinetic flux tube initial value turbulence code
|
6
|
+
! which can be used for fusion or astrophysical plasmas.
|
7
|
+
!
|
8
|
+
! See http://gyrokinetics.sourceforge.net
|
9
|
+
!
|
10
|
+
! CodeRunner is a framework for the automated running and analysis
|
11
|
+
! of large simulations.
|
12
|
+
!
|
13
|
+
! See http://coderunner.sourceforge.net
|
14
|
+
! by CodeRunner version 0.12.6.0
|
15
|
+
!
|
16
|
+
!==============================================================================
|
17
|
+
|
18
|
+
!==============================
|
19
|
+
!GENERAL PARAMETERS
|
20
|
+
!==============================
|
21
|
+
¶meters
|
22
|
+
beta = 0.0 ! Ratio of particle to magnetic pressure (reference Beta, not total beta): beta=n_0 T_0 /( B^2 / (8 pi))
|
23
|
+
zeff = 1.0 ! Effective ionic charge.
|
24
|
+
/
|
25
|
+
|
26
|
+
&kt_grids_knobs
|
27
|
+
grid_option = "box" ! The general layout of the perpendicular grid.
|
28
|
+
/
|
29
|
+
|
30
|
+
!==============================
|
31
|
+
!
|
32
|
+
!==============================
|
33
|
+
&kt_grids_box_parameters
|
34
|
+
nx = 8 ! The number of kx modes: the number of kx modes actually simulated (ntheta0) is equal to 2*(nx - 1)/3 + 1, due to the need to prevent aliasing.
|
35
|
+
ny = 8 ! The number of ky modes: the number of ky modes actually simulated (naky) is equal to (ny - 1)/3 + 1, due to the need to prevent aliasing.
|
36
|
+
jtwist = 1 ! L_x = L_y jtwist / (2 pi shat)
|
37
|
+
y0 = 2.0 ! The length of the box in the y direction (measured in the Larmour radius of species 1)
|
38
|
+
x0 = 10.0 ! The length of the box in the x direction (measured in the Larmour radius of species 1) if shat is 0 (ie 1e-6)
|
39
|
+
/
|
40
|
+
|
41
|
+
!==============================
|
42
|
+
!
|
43
|
+
!==============================
|
44
|
+
&theta_grid_parameters
|
45
|
+
ntheta = 8 ! Number of points along field line (theta) per 2 pi segment
|
46
|
+
nperiod = 1 ! Number of 2 pi segments along equilibrium magnetic field.
|
47
|
+
eps = 0.18 ! eps=r/R
|
48
|
+
epsl = 2.0 ! epsl=2 a/R
|
49
|
+
shat = 0.8 !
|
50
|
+
pk = 1.44 ! pk = 2 a / q R
|
51
|
+
shift = 0.0 ! shift = -R q**2 dbeta/drho (>0)
|
52
|
+
/
|
53
|
+
|
54
|
+
!==============================
|
55
|
+
!
|
56
|
+
!==============================
|
57
|
+
&theta_grid_knobs
|
58
|
+
equilibrium_option = "s-alpha" ! Controls which geometric assumptions are used in the run.
|
59
|
+
/
|
60
|
+
|
61
|
+
!==============================
|
62
|
+
!
|
63
|
+
!==============================
|
64
|
+
&theta_grid_salpha_knobs
|
65
|
+
model_option = "default"
|
66
|
+
/
|
67
|
+
|
68
|
+
!==============================
|
69
|
+
!PITCH ANGLE/ENERGY GRID SETUP
|
70
|
+
!==============================
|
71
|
+
&le_grids_knobs
|
72
|
+
ngauss = 5 ! Number of untrapped pitch-angles moving in one direction along field line.
|
73
|
+
negrid = 8 ! Total number of energy grid points
|
74
|
+
/
|
75
|
+
|
76
|
+
!==============================
|
77
|
+
!BOUNDARY CONDITIONS
|
78
|
+
!==============================
|
79
|
+
&dist_fn_knobs
|
80
|
+
gridfac = 1.0 ! Affects boundary condition at end of theta grid.
|
81
|
+
omprimfac = 1.0
|
82
|
+
boundary_option = "linked" ! Sets the boundary condition along the field line (i.e. the boundary conditions at theta = +- pi).
|
83
|
+
adiabatic_option = "iphi00=2" ! The form of the adiabatic response (if a species is being modeled as adiabatic).
|
84
|
+
g_exb = 0.0
|
85
|
+
nonad_zero = .true. ! If true switches on new parallel boundary condition where h=0 at incoming boundary instead of g=0.
|
86
|
+
/
|
87
|
+
|
88
|
+
!==============================
|
89
|
+
!ALGORITHMIC CHOICES
|
90
|
+
!==============================
|
91
|
+
&fields_knobs
|
92
|
+
field_option = "implicit" ! Controls which time-advance algorithm is used for the linear terms.
|
93
|
+
/
|
94
|
+
|
95
|
+
!==============================
|
96
|
+
!
|
97
|
+
!==============================
|
98
|
+
&knobs
|
99
|
+
wstar_units = .false. ! For linear runs only. Evolves each k_y with a different timestep.
|
100
|
+
fphi = 1.0 ! Multiplies Phi (electrostatic potential).
|
101
|
+
fapar = 0.0 ! Multiplies A_par. Use 1 for finite beta (electromagnetic), 0 otherwise (electrostatic)
|
102
|
+
faperp = 0.0 ! Multiplies A_perp. Use 1 for high beta, 0 otherwise. Deprecated: use fbpar instead
|
103
|
+
delt = 0.5 ! Time step
|
104
|
+
nstep = 50 ! Maximum number of timesteps
|
105
|
+
/
|
106
|
+
|
107
|
+
!==============================
|
108
|
+
!
|
109
|
+
!==============================
|
110
|
+
&reinit_knobs
|
111
|
+
delt_adj = 2.0 ! When the time step needs to be changed, it is adjusted
|
112
|
+
delt_minimum = 1.0e-06 ! The minimum time step is delt_minimum.
|
113
|
+
/
|
114
|
+
|
115
|
+
!==============================
|
116
|
+
!
|
117
|
+
!==============================
|
118
|
+
&layouts_knobs
|
119
|
+
layout = "lexys" ! 'yxles', 'lxyes', 'lyxes', 'lexys' Determines the way the grids are laid out in memory.
|
120
|
+
/
|
121
|
+
|
122
|
+
!==============================
|
123
|
+
!COLLISIONS
|
124
|
+
!==============================
|
125
|
+
&collisions_knobs
|
126
|
+
collision_model = "default" ! Collision model used in the simulation. Options: 'default', 'none', 'lorentz', 'ediffuse'
|
127
|
+
/
|
128
|
+
|
129
|
+
!==============================
|
130
|
+
!NONLINEARITY
|
131
|
+
!==============================
|
132
|
+
&nonlinear_terms_knobs
|
133
|
+
nonlinear_mode = "off" ! Include nonlinear terms? ('on','off')
|
134
|
+
flow_mode = "off"
|
135
|
+
cfl = 0.5 ! The maximum delt < cfl * min(Delta_perp/v_perp)
|
136
|
+
/
|
137
|
+
|
138
|
+
!==============================
|
139
|
+
!EVOLVED SPECIES
|
140
|
+
!==============================
|
141
|
+
&species_knobs
|
142
|
+
nspec = 1 ! Number of kinetic species evolved.
|
143
|
+
/
|
144
|
+
|
145
|
+
!==============================
|
146
|
+
!SPECIES PARAMETERS 1
|
147
|
+
!==============================
|
148
|
+
&species_parameters_1
|
149
|
+
z = 1.0 ! Charge
|
150
|
+
mass = 1.0 ! Mass
|
151
|
+
dens = 1.0 ! Density
|
152
|
+
temp = 1.0 ! Temperature
|
153
|
+
tprim = 6.9 ! -1/T (dT/drho)
|
154
|
+
fprim = 2.2 ! -1/n (dn/drho)
|
155
|
+
uprim = 0.0 ! ?
|
156
|
+
vnewk = 0.01 ! collisionality parameter
|
157
|
+
type = "ion" ! Type of species, e.g. 'ion', 'electron', 'beam'
|
158
|
+
/
|
159
|
+
|
160
|
+
!==============================
|
161
|
+
! 1
|
162
|
+
!==============================
|
163
|
+
&dist_fn_species_knobs_1
|
164
|
+
fexpr = 0.45 ! Temporal implicitness parameter. Recommended value: 0.48
|
165
|
+
bakdif = 0.05 ! Spatial implicitness parameter. Recommended value: 0.05
|
166
|
+
/
|
167
|
+
|
168
|
+
!==============================
|
169
|
+
!INITIAL CONDITIONS
|
170
|
+
!==============================
|
171
|
+
&init_g_knobs
|
172
|
+
chop_side = .false. ! Rarely needed. Forces asymmetry into initial condition.
|
173
|
+
phiinit = 0.001 ! Average amplitude of initial perturbation of each Fourier mode.
|
174
|
+
restart_file = "v_nstep_50_delt_0.5_nwrite_1_nsave_100_nonlinear_mode_off_g_exb_0.0_y0_2.0_nonad_zero_.true._jtwist_1_id_16.nc" ! Base of filenames with restart data.
|
175
|
+
ginit_option = "noise" ! Sets the way that the distribution function is initialized.
|
176
|
+
restart_dir = "nc"
|
177
|
+
/
|
178
|
+
|
179
|
+
!==============================
|
180
|
+
!DIAGNOSTICS
|
181
|
+
!==============================
|
182
|
+
&gs2_diagnostics_knobs
|
183
|
+
print_flux_line = .F. ! Instantaneous fluxes output to screen
|
184
|
+
write_nl_flux = .true. ! Write nonlinear fluxes as a function of time.
|
185
|
+
print_line = .false. ! Estimated frequencies and growth rates to the screen/stdout
|
186
|
+
write_verr = .true. ! Write velocity space diagnostics to '.lpc' and '.verr' files
|
187
|
+
! write_g not specified --- Write the distribution function to the '.dist' (NetCDF?)
|
188
|
+
write_line = .false. ! If (write_ascii = T) write estimated frequencies and growth rates to the output file
|
189
|
+
! write_gyx not specified --- Write dist fn at a given physical spacial point to a file
|
190
|
+
write_hrate = .false. ! Write heating rate, collisonal entropy generation etc to '.heat'
|
191
|
+
! write_final_epar not specified --- If (write_ascii = T) E_parallel(theta) written to runname.eigenfunc
|
192
|
+
write_avg_moments = .F. ! Write flux surface averaged low-order moments of g to runname.out.nc and runname.moments (if write_ascii = T)
|
193
|
+
! write_lorentzian not specified --- Frequency Sweep Data
|
194
|
+
write_omega = .false. ! If (write_ascii = T) instantaneous omega to output file. Very heavy output
|
195
|
+
write_omavg = .false. ! If (write_ascii = T) time-averaged growth rate and frequency to the output file.
|
196
|
+
write_eigenfunc = .true. ! If (write_ascii = T) Normalized phi written to runname.eigenfunc
|
197
|
+
write_final_fields = .true. ! If (write_ascii = T) Phi(theta) written to '.fields'
|
198
|
+
write_final_moments = .true. ! write final n, T
|
199
|
+
! write_parity not specified --- Writes parities in dist fn and particle fluxes
|
200
|
+
nsave = 100 ! Write restart files every nsave timesteps
|
201
|
+
nwrite = 1 ! Output diagnostic data every nwrite
|
202
|
+
navg = 10 ! Any time averages performed over navg
|
203
|
+
omegatol = -0.001 ! The convergence has to be better than one part in 1/omegatol
|
204
|
+
omegatinst = 500.0 ! Recommended value: 500.
|
205
|
+
save_for_restart = .false. ! Write restart files.
|
206
|
+
! write_flux_line not specified ---
|
207
|
+
! write_ascii not specified ---
|
208
|
+
! write_kpar not specified ---
|
209
|
+
! write_gs not specified ---
|
210
|
+
! write_gg not specified ---
|
211
|
+
! write_lpoly not specified ---
|
212
|
+
! write_fields not specified ---
|
213
|
+
! write_final_antot not specified ---
|
214
|
+
! write_cerr not specified ---
|
215
|
+
! write_max_verr not specified ---
|
216
|
+
! nmovie not specified ---
|
217
|
+
! igomega not specified ---
|
218
|
+
! exit_when_converged not specified ---
|
219
|
+
! write_full_moments_notgc not specified ---
|
220
|
+
! write_cross_phase not specified ---
|
221
|
+
! dump_check1 not specified ---
|
222
|
+
! dump_check2 not specified ---
|
223
|
+
! dump_fields_periodically not specified ---
|
224
|
+
! make_movie not specified ---
|
225
|
+
write_phi_over_time = .true. ! Write entire Phi field to NetCDF file every nwrite.
|
226
|
+
! write_apar_over_time not specified --- Write entire A_parallel field to NetCDF file every nwrite.
|
227
|
+
! write_bpar_over_time not specified --- Write entire B_parallel field to NetCDF file every nwrite.
|
228
|
+
! write_symmetry not specified --- Test the symmetry properties of the GK eqn.
|
229
|
+
! save_distfn not specified --- Save dist_fn with lots of detail.
|
230
|
+
! write_correlation_extend not specified --- Extend domain of correlation function calculation.
|
231
|
+
! nwrite_mult not specified --- Large datasets written every nwrite_mult * nwrite timesteps.
|
232
|
+
! write_correlation not specified --- Write parallel correlation.
|
233
|
+
! write_moments not specified ---
|
234
|
+
! write_final_db not specified --- Write final delta B.
|
235
|
+
/
|
236
|
+
|
Binary file
|
data/test/test_gs2crmod.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
3
|
+
CYCLONE_LOW_RES_FOLDER = 'test/cyclone_low_res'
|
4
|
+
class TestBasics < Test::Unit::TestCase
|
4
5
|
def setup
|
5
6
|
@runner = CodeRunner.fetch_runner(Y: 'test/slab_itg', C: 'gs2', X: '/dev/null')
|
6
7
|
end
|
@@ -12,3 +13,126 @@ class TestGs2crmod < Test::Unit::TestCase
|
|
12
13
|
assert_equal(@runner.run_class, CodeRunner::Gs2)
|
13
14
|
end
|
14
15
|
end
|
16
|
+
if ENV['GS2_EXEC']
|
17
|
+
class TestSubmission < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
CodeRunner.setup_run_class('gs2')
|
20
|
+
CodeRunner::Gs2.make_new_defaults_file('test_gs2crmod', 'test/cyclone_low_res.in')
|
21
|
+
FileUtils.mv('test_gs2crmod_defaults.rb', CodeRunner::Gs2.rcp.user_defaults_location + '/.')
|
22
|
+
FileUtils.makedirs(tfolder)
|
23
|
+
end
|
24
|
+
def tfolder
|
25
|
+
CYCLONE_LOW_RES_FOLDER
|
26
|
+
end
|
27
|
+
def teardown
|
28
|
+
FileUtils.rm(CodeRunner::Gs2.rcp.user_defaults_location + '/' + 'test_gs2crmod_defaults.rb')
|
29
|
+
FileUtils.rm(tfolder + '/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
|
30
|
+
FileUtils.rm(tfolder + '/v/id_1/.code_runner_run_data')
|
31
|
+
FileUtils.rm(tfolder + '/v/id_1/code_runner_results.rb')
|
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
|
+
#Dir.chdir('test'){system "tar -czf cyclone_low_res.tgz cyclone_low_res/" unless FileTest.exist?('cyclone_low_res.tgz')}
|
34
|
+
FileUtils.rm_r(tfolder)
|
35
|
+
end
|
36
|
+
def test_submission
|
37
|
+
CodeRunner.submit(C: 'gs2', X: ENV['GS2_EXEC'], D: 'test_gs2crmod', n: '4', Y: tfolder)
|
38
|
+
CodeRunner.status(Y: tfolder)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
puts "\n************************************\nWarning: submission tests not run. Please specify the evironment variable GS2_EXEC (the path to the gs2 executable) if you wish to test submission.\n************************************\n"
|
43
|
+
sleep 0.1
|
44
|
+
end
|
45
|
+
class TestAnalysis < Test::Unit::TestCase
|
46
|
+
def setup
|
47
|
+
Dir.chdir('test'){assert(system "tar -xzf cyclone_low_res.tgz")}
|
48
|
+
@runner = CodeRunner.fetch_runner(Y: tfolder)
|
49
|
+
@run = @runner.run_list[1]
|
50
|
+
end
|
51
|
+
def test_analysis
|
52
|
+
assert_equal(1, @runner.run_list.size)
|
53
|
+
assert_equal(0.13066732664774272, @runner.run_list[1].max_growth_rate)
|
54
|
+
assert_equal(0.13066732664774272, @runner.run_list[1].growth_rate_at_ky[0.5])
|
55
|
+
assert_equal(:Complete, @runner.run_list[1].status)
|
56
|
+
end
|
57
|
+
def test_interpolation
|
58
|
+
assert_equal(5, @run.gsl_vector('kx').size)
|
59
|
+
assert_equal(17, @run.gsl_vector('kx', interpolate_x: 4).size)
|
60
|
+
kxvec = @run.gsl_vector('kx', interpolate_x: 4)
|
61
|
+
assert_equal(0.0, kxvec[(kxvec.size-1)/2])
|
62
|
+
xvec4 = @run.gsl_vector('x', interpolate_x: 4)
|
63
|
+
s = kxvec.size
|
64
|
+
assert_equal((-(s-1)/2..(s-1)/2).to_a.map{|i| i.to_f * kxvec.to_box_order[1]}.to_gslv, kxvec)
|
65
|
+
#p xvec4.to_a
|
66
|
+
xvec = @run.gsl_vector('x')
|
67
|
+
# The vectors don't contain the periodic point, but we can construct them
|
68
|
+
# and they should be equal
|
69
|
+
assert_equal(xvec[-1] + xvec[-1] - xvec[-2], xvec4[-1] + xvec4[-1] - xvec4[-2])
|
70
|
+
#p @run.gsl_vector('kx', interpolate_x: 4).to_a
|
71
|
+
kyvec4 = @run.gsl_vector('ky', interpolate_y: 4)
|
72
|
+
#p kyvec4
|
73
|
+
s = kyvec4.size
|
74
|
+
assert_equal((0...s).to_a.map{|i| i.to_f * kyvec4[1]}.to_gslv, kyvec4)
|
75
|
+
yvec4 = @run.gsl_vector('y', interpolate_y: 4)
|
76
|
+
#p yvec4.to_a
|
77
|
+
yvec = @run.gsl_vector('y')
|
78
|
+
assert_equal(yvec[-1] + yvec[-1] - yvec[-2], yvec4[-1] + yvec4[-1] - yvec4[-2])
|
79
|
+
#kit = @runner.run_list[1].graphkit('phi_real_space_poloidal_plane', {n0: 1, Rgeo: 3, interpolate_theta: 8, torphi: Math::PI/4.0, interpolate_x: 8})
|
80
|
+
kit1 = @runner.run_list[1].graphkit('phi_real_space_surface', {n0: 1, Rgeo: 3, gs2_coordinate_factor: 1.0})
|
81
|
+
shape = kit1.data[0].x.data.shape
|
82
|
+
shape = shape.map{|s| (s-1)*2 +1}
|
83
|
+
kit = @runner.run_list[1].graphkit('phi_real_space_surface', {n0: 1, Rgeo: 3, interpolate_theta: 2, interpolate_x: 2, interpolate_y: 2, gs2_coordinate_factor: 1.0})
|
84
|
+
assert_equal(shape, kit.data[0].x.data.shape)
|
85
|
+
assert_equal(shape, kit.data[0].f.data.shape)
|
86
|
+
#kit.gp.view = ["equal xyz", ",,5.0"]
|
87
|
+
#kit.gnuplot
|
88
|
+
end
|
89
|
+
def test_graphs
|
90
|
+
kit = @runner.run_list[1].graphkit('phi2_by_ky_vs_time', {ky_index: 2})
|
91
|
+
#kit.gnuplot
|
92
|
+
assert_equal(51, kit.data[0].y.data.size)
|
93
|
+
assert_equal(@runner.run_list[1].netcdf_file.var('phi2_by_ky').get('start' => [1,4], 'end' => [1,4]).to_a[0][0], kit.data[0].y.data[4])
|
94
|
+
end
|
95
|
+
def test_3d_graphs
|
96
|
+
kit = @runner.run_list[1].graphkit('phi_real_space', {n0: 3, Rgeo: 3})
|
97
|
+
assert_equal([5,5,9], kit.data[0].f.data.shape)
|
98
|
+
assert_equal(-0.00402, kit.data[0].f.data[2,3,6].round(5))
|
99
|
+
kit = @runner.run_list[1].graphkit('density_real_space', {n0: 3, Rgeo: 3, species_index: 1, gs2_coordinate_factor: 0.9})
|
100
|
+
#kit.gnuplot
|
101
|
+
assert_equal([5,5,9], kit.data[0].f.data.shape)
|
102
|
+
assert_equal(-0.00985, kit.data[0].f.data[2,3,6].round(5))
|
103
|
+
kit = @runner.run_list[1].graphkit('phi_real_space', {n0: 3, Rgeo: 3, t_index: 2})
|
104
|
+
assert_equal([5,5,9], kit.data[0].f.data.shape)
|
105
|
+
assert_equal(0.00031, kit.data[0].f.data[2,3,6].round(5))
|
106
|
+
kit = @runner.run_list[1].graphkit('phi_real_space_surface', {n0: 3, Rgeo: 3, interpolate_theta: 2})
|
107
|
+
assert_equal([5,5,1], kit.data[0].f.data.shape)
|
108
|
+
assert_equal([5,1,17], kit.data[2].f.data.shape)
|
109
|
+
assert_equal(-0.00153, kit.data[0].f.data[1,4,0].round(5))
|
110
|
+
#kit.gnuplot
|
111
|
+
kit = @runner.run_list[1].graphkit('phi_real_space_poloidal_plane', {n0: 1, Rgeo: 3, interpolate_theta: 8, torphi: Math::PI/4.0})
|
112
|
+
assert_equal(-0.00208, kit.data[0].f.data[-1,1].round(5))
|
113
|
+
assert_equal(1.707, kit.data[0].x.data[-1,1].round(3))
|
114
|
+
kit.gp.view = ["equal xyz", ",,4.0"]
|
115
|
+
#kit.gnuplot
|
116
|
+
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})
|
117
|
+
assert_equal(-0.00352, kit.data[0].f.data[-1,1].round(5))
|
118
|
+
assert_equal(1.707, kit.data[0].x.data[-1,1].round(3))
|
119
|
+
kit.gp.view = ["equal xyz", ",,4.0"]
|
120
|
+
#kit.gnuplot
|
121
|
+
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
|
+
assert_equal([5,17], kit.data[0].f.data.shape)
|
123
|
+
assert_equal([3,1,17], kit.data[2].f.data.shape)
|
124
|
+
assert_equal([3,1,17], kit.data[2].y.data.shape)
|
125
|
+
assert_equal(-0.00038, kit.data[0].f.data[-1,1].round(5))
|
126
|
+
assert_equal(2.12132, kit.data[2].y.data[2,0,12].round(5))
|
127
|
+
#kit.gnuplot
|
128
|
+
end
|
129
|
+
|
130
|
+
def tfolder
|
131
|
+
CYCLONE_LOW_RES_FOLDER
|
132
|
+
end
|
133
|
+
def teardown
|
134
|
+
FileUtils.rm_r(tfolder)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
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.
|
4
|
+
version: 0.7.0
|
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-06-
|
13
|
+
date: 2013-06-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: coderunner
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.11
|
22
|
+
version: 0.12.11
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ! '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 0.11
|
30
|
+
version: 0.12.11
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: shoulda
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,6 +148,8 @@ files:
|
|
148
148
|
- lib/gs2crmod/species_dependent_namelists.rb
|
149
149
|
- lib/gs2crmod/test_gs2.rb
|
150
150
|
- lib/gs2crmod_extension.rb
|
151
|
+
- test/cyclone_low_res.in
|
152
|
+
- test/cyclone_low_res.tgz
|
151
153
|
- test/helper.rb
|
152
154
|
- test/test_gs2crmod.rb
|
153
155
|
homepage: http://gs2crmod.sourceforge.net
|