Module: CodeRunner::Gs2::GSLVectorComplexes
- Included in:
- CodeRunner::Gs2
- Defined in:
- lib/gs2crmod/gsl_data.rb
Instance Method Summary collapse
- #phi_along_field_line_gsl_vector_complex(options) ⇒ Object
-
#phi_zonal_gsl_vector_complex(options) ⇒ Object
This function returns a complex GSL vector of the zonal (ky=0) component of phi/phi_t at a given theta index and time index if write_phi_over_time was enabled during the simulation.
Instance Method Details
#phi_along_field_line_gsl_vector_complex(options) ⇒ Object
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 |
# File 'lib/gs2crmod/gsl_data.rb', line 1068 def phi_along_field_line_gsl_vector_complex() Dir.chdir(@directory) do # eputs options[:ky] # eputs Dir.pwd #eputs "Start phi_along_field_line" .convert_to_index(self, :ky) if [:t_index] or [:t] #extra option required is t_index raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time .convert_to_index(self, :t) case @grid_option when "single" temp = GSL::Vector.alloc(netcdf_file.var('phi_t').get({'start' => [0,0,0,0, [:t_index] - 1], 'end' => [-1,-1,0,0, [:t_index] - 1]}).to_a[0][0][0].flatten) when "range" a = netcdf_file.var('phi_t').get({'start' => [0, 0, [:kx_index]-1, [:ky_index] - 1, [:t_index] - 1], 'end' => [-1, -1, [:kx_index]-1, [:ky_index] - 1, [:t_index]-1]}) #temp = GSL::Vector.alloc(a.to_a[0].values_at(*kx_elements).flatten) temp = GSL::Vector.alloc(a.to_a[0][0].flatten) when "box" .convert_to_index(self, :ky, :kx) kx_elements = gsl_vector('linked_kx_elements', ).to_a # pp kx_elements a = netcdf_file.var('phi_t').get({ 'start' => [0,0,0,[:ky_index] - 1, [:t_index] - 1], 'end' => [-1,-1,-1, [:ky_index] - 1, [:t_index] - 1] }).to_a[0][0].values_at(*kx_elements).flatten # pp a.index(nil) # temp = GSL::Vector.alloc(netcdf_file.var('phi').get.to_a[options[:ky_index] - 1 ].values_at(*kx_elements).flatten) #ep a temp = GSL::Vector.alloc(a) end #eputs "End phi_along_field_line" return GSL::Vector::Complex.alloc(temp.subvector_with_stride(0, 2), temp.subvector_with_stride(1, 2)) else case @grid_option when "single" temp = GSL::Vector.alloc(netcdf_file.var('phi').get({'start' => [0,0, 0, 0], 'end' => [-1,-1,0,0]}).to_a.flatten) when "range" a = netcdf_file.var('phi').get({'start' => [0, 0, 0, [:ky_index] - 1], 'end' => [-1, -1, -1, [:ky_index] - 1]}) #temp = GSL::Vector.alloc(a.to_a[0].values_at(*kx_elements).flatten) temp = GSL::Vector.alloc(a.to_a[0][0].flatten) when "box" ep 'kx_elements', kx_elements = gsl_vector('linked_kx_elements', ).to_a a = netcdf_file.var('phi').get({'start' => [0, 0, 0, [:ky_index] - 1], 'end' => [-1, -1, -1, [:ky_index] - 1]}) temp = GSL::Vector.alloc(a.to_a[0].values_at(*kx_elements).flatten) else raise "invalid grid option" end vector = GSL::Vector::Complex.alloc(temp.subvector_with_stride(0, 2), temp.subvector_with_stride(1, 2)) #ep 'vector', vector.real return vector end end # eputs data; gets end |
#phi_zonal_gsl_vector_complex(options) ⇒ Object
This function returns a complex GSL vector of the zonal (ky=0) component of phi/phi_t at a given theta index and time index if write_phi_over_time was enabled during the simulation
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 |
# File 'lib/gs2crmod/gsl_data.rb', line 1128 def phi_zonal_gsl_vector_complex() Dir.chdir(@directory) do if [:t_index] or [:t] #extra option required is t_index raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time .convert_to_index(self, :t) a = netcdf_file.var('phi_t').get({ 'start' => [0,[:theta_index],0,0, [:t_index] - 1], 'end' => [-1,[:theta_index],-1,0, [:t_index] - 1] }) vector = GSL::Vector::Complex.alloc(GSL::Vector.alloc(a[0,0,0..-1,0,0]), GSL::Vector.alloc(a[1,0,0..-1,0,0])) return vector else a = netcdf_file.var('phi').get({ 'start' => [0, [:theta_index], 0, 0], 'end' => [-1, [:theta_index], -1, 0] }) vector = GSL::Vector::Complex.alloc(GSL::Vector.alloc(a[0,0,0..-1,0]), GSL::Vector.alloc(a[1,0,0..-1,0])) return vector end end end |