Class: CodeRunner::Gs2::Astrogk
- Inherits:
-
CodeRunner::Gs2
- Object
- Run::FortranNamelist
- CodeRunner::Gs2
- CodeRunner::Gs2::Astrogk
- Includes:
- AGKGraphKits, AstrogkGSLVectors
- Defined in:
- lib/gs2crmod/astrogk.rb,
lib/gs2crmod/astrogk/ingen.rb,
lib/gs2crmod/astrogk/graphs.rb,
lib/gs2crmod/astrogk/astrogk.rb,
lib/gs2crmod/astrogk/gsl_data.rb,
lib/gs2crmod/astrogk/test_gs2.rb,
lib/gs2crmod/astrogk/properties.rb,
lib/gs2crmod/astrogk/calculations.rb,
lib/gs2crmod/astrogk/namelist_tools.rb,
lib/gs2crmod/astrogk/input_file_tools.rb,
lib/gs2crmod/astrogk/check_convergence.rb
Direct Known Subclasses
Defined Under Namespace
Modules: AGKGraphKits, AstrogkGSLVectors, TestAstrogk
Constant Summary collapse
- NaN =
GSL::NAN
- ASTROGK_CRMOD_VERSION =
Version.new('0.3.0')
Constants inherited from CodeRunner::Gs2
AxisKit, CODE_SCRIPT_FOLDER, DataKit, GRAPHKIT_OPTIONS_HELP, GS2_CRMOD_VERSION, MAX_NAME_SIZE, SPECIES_DEPENDENT_NAMELISTS, SPECIES_DEPENDENT_VARIABLES, SPECIES_DEPENDENT_VARIABLES_WITH_HELP
Constants included from GSLTensors
GSLTensors::FIELD_VALUES, GSLTensors::IRRELEVANT_INDICES, GSLTensors::TIME_VARYING_INDICES, GSLTensors::TRIVIAL_INDICES
Instance Attribute Summary
Attributes inherited from CodeRunner::Gs2
#eigenfunctions, #iphi00, #ky_graphs, #ky_list, #saturation_time, #scan_index_window, #scan_parameter_value, #t_list, #theta_list
Class Method Summary collapse
- .defaults_file_header ⇒ Object
-
.test_gs2(*args) ⇒ Object
See TestAstrogk.
- .transfer_gs2_docs ⇒ Object
Instance Method Summary collapse
- #agk? ⇒ Boolean
- #correct_3d_options(options) ⇒ Object
- #diagnostics_namelist ⇒ Object
- #geometric_factors_gsl_tensor(options) ⇒ Object
- #ingen ⇒ Object
- #input_file_header ⇒ Object
- #read_transfers ⇒ Object
- #run_namelist_backwards_compatibility ⇒ Object
- #set_nprocs ⇒ Object
Methods included from AstrogkGSLVectors
#etrans_by_kfrom_by_kto_over_time_gsl_vector
Methods inherited from CodeRunner::Gs2
#actual_number_of_processors, add_variable_to_namelist, #approximate_grid_size, #auto_axiskits, #axiskit, #box_kx_index, cache, #calculate_frequencies, #calculate_growth_rate, #calculate_growth_rates_and_frequencies, #calculate_results, #calculate_saturation_time_index, #calculate_spectral_checks, #calculate_time_averaged_fluxes, #calculate_transient_amplification, #calculate_transient_amplifications, #calculate_transient_es_heat_flux_amplifications, #calculate_vspace_checks, check_and_update, #check_converged, #check_parameters, #copy_response_files, #copy_restart_files, #corrected_mom_flux_stav, #ctan, #cumulative_gridpoints, #data_string, #delete_restart_files, #diff_run_parameters, #error, #estimated_nodes, #eulerian_kx_index, #generate_component_runs, generate_graphs_rdoc_file, #generate_input_file, #get_completed_timesteps, #get_list_of, #get_run_time, #get_status, #get_time, #graphkit, #gridpoints, #gryfx?, #gsl_complex, #gsl_matrix, #gsl_tensor, #gsl_vector, #gsl_vector_complex, #has_electrons?, help_graphs, #hypercoll_graphkit, #hyperviscosity_graphkit, #incomplete, #input_file_extension, #jump, #kx_indexed, #kx_shift, #latex_graphs, #lenardbern_graphkit, list_code_commands, #list_of_response_files, #list_of_restart_files, #max_es_heat_amp, #max_nprocs_no_x, #max_trans_phi, modify_job_script, #namelist_test_failed, #ncclose, #ncdump, #netcdf_file, #netcdf_filename, #netcdf_smart_reader, #no_restarts, #old_smart_graphkit, #optimisation_flags, #parallelizable_meshpoints, #parameter_string, #parameter_transition, #percent_complete, #physical_kx_index, #plot_efit_file, #print_out_line, #process_directory_code_specific, #recheck, #renew_info_file, #restart, #restart_chain, #run_heuristic_analysis, #run_namelist_tests, #saturated_time_average, #saturated_time_average_error, #saturated_time_average_std_dev, #sc, #show_graph, #smart_graphkit, #spec_chec, #species_letter, #species_type, #spectrogk?, #standardize_restart_files, #stop, #test_failed, #test_variable, #update_physics_parameters_from_miller_input_file, #vim_input, #vim_output, #vim_stdout, #visually_check_growth_rate, #warning, #write_input_file
Methods included from GSLMatrices
#es_heat_flux_over_ky_over_kx_gsl_matrix, #growth_rate_over_ky_over_kx_gsl_matrix, #phi0_over_x_over_y_gsl_matrix, #spectrum_over_ky_over_kpar_gsl_matrix, #spectrum_over_ky_over_kx_gsl_matrix, #transient_amplification_over_ky_over_kx_gsl_matrix
Methods included from GSLVectorComplexes
#phi_along_field_line_gsl_vector_complex, #phi_zonal_gsl_vector_complex
Methods included from GSLVectors
#apar2_over_time_gsl_vector, #dt_gsl_vector, #es_heat_by_kx_over_time_gsl_vector, #es_heat_by_ky_over_time_gsl_vector, #es_heat_flux_over_time_gsl_vector, #es_heat_over_kx_gsl_vector, #es_heat_over_kxy_gsl_vector, #es_heat_over_ky_gsl_vector, #es_heat_par_over_time_gsl_vector, #es_heat_perp_over_time_gsl_vector, #es_mom_flux_over_time_gsl_vector, #es_part_flux_over_time_gsl_vector, #frequency_by_kx_over_time_gsl_vector, #frequency_by_kxy_over_time_gsl_vector, #frequency_by_ky_over_time_gsl_vector, #frequency_over_ky_gsl_vector, #grho_gsl_vector, #growth_rate_by_kx_over_time_gsl_vector, #growth_rate_by_kxy_over_time_gsl_vector, #growth_rate_by_ky_over_time_gsl_vector, #growth_rate_over_kx_gsl_vector, #growth_rate_over_kx_slice_gsl_vector, #growth_rate_over_ky_gsl_vector, #growth_rate_over_ky_slice_gsl_vector, #hflux_tot_over_time_gsl_vector, #kpar_gsl_vector, #linked_kx_elements_gsl_vector, #lpc_energy_gsl_vector, #lpc_pitch_angle_gsl_vector, #mean_flow_velocity_over_x_gsl_vector, #par_mom_flux_over_time_gsl_vector, #perp_mom_flux_over_time_gsl_vector, #phi0_by_kx_by_ky_over_time_gsl_vector, #phi2_by_kx_over_time_gsl_vector, #phi2_by_ky_over_time_gsl_vector, #phi2_by_mode_over_time_gsl_vector, #phi2tot_over_time_gsl_vector, #phi_along_field_line_gsl_vector, #phi_for_eab_movie_gsl_vector, #scan_parameter_value_gsl_vector, #spectrum_over_kpar_gsl_vector, #spectrum_over_kx_avg_gsl_vector, #spectrum_over_kx_gsl_vector, #spectrum_over_kxy_avg_gsl_vector, #spectrum_over_kxy_gsl_vector, #spectrum_over_ky_avg_gsl_vector, #spectrum_over_ky_gsl_vector, #theta_along_field_line_gsl_vector, #tpar2_by_mode_over_time_gsl_vector, #tperp2_by_mode_over_time_gsl_vector, #transient_amplification_over_kx_gsl_vector, #transient_amplification_over_ky_gsl_vector, #transient_es_heat_flux_amplification_over_kx_gsl_vector, #transient_es_heat_flux_amplification_over_kxy_gsl_vector, #transient_es_heat_flux_amplification_over_ky_gsl_vector, #vres_energy_gsl_vector, #vres_pitch_angle_gsl_vector, #x_gsl_vector, #y_gsl_vector, #zf_velocity_over_x_gsl_vector, #zonal_spectrum_gsl_vector
Methods included from FixNormOption
#fix_heat_flux_norm, #fix_norm, #fix_norm_action
Methods included from ReadNetcdf
#new_ncclose, #new_netcdf_file, #new_netcdf_filename
Methods included from GSLComplexTensors
#field_gsl_tensor_complex, #phi_gsl_tensor_complex
Methods included from GSLTensors
#apar_gsl_tensor, #bpar_gsl_tensor, #cartesian_coordinates_gsl_tensor, #constant_torphi_surface_gsl_tensor, #cylindrical_coordinates_gsl_tensor, #field_gsl_tensor, #field_netcdf_name, #field_real_space_gsl_tensor, #field_real_space_gsl_tensor_2, #field_species_element, #moment_gsl_tensor, #phi_real_space_gsl_tensor
Class Method Details
.defaults_file_header ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/gs2crmod/astrogk.rb', line 151 def self.defaults_file_header <<EOF1 ###################################################################### # Automatically generated defaults file for AstroGK CodeRunner module# # # # This defaults file specifies a set of defaults for AstroGK which are# # used by CodeRunner to set up and run GS2 simulations. # # # # Created #{Time.now.to_s} # # # ###################################################################### @defaults_file_description = "" EOF1 end |
.test_gs2(*args) ⇒ Object
See TestAstrogk
6 7 8 |
# File 'lib/gs2crmod/astrogk/test_gs2.rb', line 6 def self.test_gs2(*args) TestAstrogk.test_gs2(*args) end |
.transfer_gs2_docs ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/gs2crmod/astrogk.rb', line 171 def self.transfer_gs2_docs CodeRunner.setup_run_class('gs2') p CodeRunner::Astrogk.ancestors intersection = (CodeRunner::Gs2.rcp.namelists.keys&CodeRunner::Astrogk.rcp.namelists.keys) gs2namelists=CodeRunner::Gs2.rcp.namelists intersection.each do | namelist | p namelist gs2namelist=gs2namelists[namelist] next unless gs2namelist self.rcp.namelists[namelist][:variables].each do | varname, varhash | p varname if match = (gs2namelist[:variables][varname]) # or gs2namelist[:variables].find{|gs2varname,gs2varhash| gs2varhash[:code_name]==varhash[:code_name]}[1]) puts "Found corresponding variable #{varname}" #p match puts "Found help: #{match[:help]}" varhash[:help] = match[:help] if match[:help] varhash[:description] = match[:description] save_namelists end end end end |
Instance Method Details
#agk? ⇒ Boolean
54 55 56 |
# File 'lib/gs2crmod/astrogk.rb', line 54 def agk? true end |
#correct_3d_options(options) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/gs2crmod/astrogk/gsl_data.rb', line 20 def () eputs "Info: setting options[:gs2_coordinate_factor] to 1.0 (for slab geometry)" [:gs2_coordinate_factor] = 1.0 #raise "Please specify options[:rho_star]" unless options[:rho_star] [:rho_star_actual] = 1.0 [:q_actual] = 1.0 [:rhoc_actual] = 1.0 end |
#diagnostics_namelist ⇒ Object
13 14 15 |
# File 'lib/gs2crmod/astrogk/ingen.rb', line 13 def diagnostics_namelist :diagnostics end |
#geometric_factors_gsl_tensor(options) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/gs2crmod/astrogk/gsl_data.rb', line 12 def geometric_factors_gsl_tensor() #ops = options.dup; ops.delete :phi #ep ops; gets theta_vec = gsl_vector(:theta, ) factors = GSL::Tensor.alloc(6,theta_vec.size) factors[true, true] = 1.0 factors end |
#ingen ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/gs2crmod/astrogk/ingen.rb', line 4 def ingen # Misc Errors warning("Write k energy transfer currently only works with layout = 'yxles'") if @write_ktrans and @write_ktrans.fortran_true? and not @layout == "yxles" super # call GS2 ingen end |
#input_file_header ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/gs2crmod/astrogk.rb', line 130 def input_file_header <<EOF !============================================================================== ! AstroGK INPUT FILE automatically generated by CodeRunner !============================================================================== ! ! AstroGK is a gyrokinetic flux tube initial value turbulence code ! which can be used for fusion or astrophysical plasmas. ! ! See http://gyrokinetics.sourceforge.net ! ! CodeRunner is a framework for the automated running and analysis ! of large simulations. ! ! See http://coderunner.sourceforge.net ! by CodeRunner version #{CodeRunner::CODE_RUNNER_VERSION.to_s} ! !============================================================================== EOF end |
#read_transfers ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gs2crmod/astrogk/calculations.rb', line 18 def read_transfers Dir.chdir(@directory) do raise "No ktrans file" unless FileTest.exist? "#@run_name.ktrans" file = File.open("#@run_name.ktrans", "r") wtr_hash = {} etr_hash = {} while line = file.gets #p line; arr = line.split(/\s+/).map{|w| w.to_f} #p arr dud, t, kf, kt, w, e = arr next unless t etr_hash[t] ||= {} etr_hash[t][kf] ||= {} etr_hash[t][kf][kt] = e wtr_hash[t] ||= {} wtr_hash[t][kf] ||= {} wtr_hash[t][kf][kt] = w end #p etr_hash File.open('energy_transfer.rb', 'w'){|file| file.puts etr_hash.pretty_inspect} File.open('w_transfer.rb', 'w'){|file| file.puts wtr_hash.pretty_inspect} end # Dir.chdir(@directory) end |
#run_namelist_backwards_compatibility ⇒ Object
104 105 |
# File 'lib/gs2crmod/astrogk.rb', line 104 def run_namelist_backwards_compatibility end |
#set_nprocs ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/gs2crmod/astrogk.rb', line 106 def set_nprocs if (nprocs_in = @nprocs) =~ /^x/ max = max_nprocs_no_x #Astrogk seems to not like you actually having naky * nspec * negrid processors.. reduce it for i in 2...max if max%i ==0 max = max / i break end end nodes = 0 @nprocs = "#{nodes}#{nprocs_in}" loop do nodes += 1 @nprocs = "#{nodes}#{nprocs_in}" if actual_number_of_processors > max nodes -= 1 @nprocs = "#{nodes}#{nprocs_in}" break end end end end |