# This file contains methods which allow Trinity to use GS2 as # the flux solver #class NumRu::NetCDF #def _dump_data #Marshal.dump(nil) #end #end class CodeRunner class Trinity module TrinityComponent attr_accessor :trinity_run def initialize(runner, trinity_run, trinity_id) super(runner) @trinity_run = trinity_run @trinity_id = trinity_id self end def generate_run_name @run_name = @trinity_run.flux_run_name(@trinity_id) end def output_file #@output_file ||= '../' + self.class.to_s '../' + @trinity_run.output_file #'aa' end def error_file '../' + @trinity_run.error_file #'aa' end def dup return self.class.new(@runner, @trinity_run, @trinity_id).learn_from(self) end def save #p ['output_file', output_file] #p ['ancestors', self.class.ancestors] trinrun, @trinity_run = @trinity_run, nil component_runs.each{|cr| cr.trinity_run = nil} #@trinity_run = nil #@output_file = nil #GC.start #p self.instance_variables.find_all{|v| instance_variable_get(v).class.to_s =~ /NumRu::NetCDF/} super @trinity_run = trinrun end end class TrinityComponent::Gs2 < CodeRunner::Gs2 include TrinityComponent end class TrinityComponent::Gryfx < CodeRunner::Gryfx include TrinityComponent end # This function creates a new Trinity defaults file, with Trinity parameters taken from # trinity_input_file, and GS2 parameters taken from gs2_input_file. The file is then moved # to the CodeRunner central defaults location, the current folder is configured to use # the defaults file. def self.use_new_defaults_file_with_flux(name = ARGV[-4], trinity_input_file = ARGV[-3], flux_input_file = ARGV[-2], fluxcode=ARGV[-1]) raise "Please specify a name, a trinity input file and a flux code input file" if name == "use_new_defaults_file_with_flux" defaults_filename = "#{name}_defaults.rb" tmp_filename = "#{name}_flxtmp_defaults.rb" central_defaults_filename = rcp.user_defaults_location + "/" + defaults_filename #FileUtils.rm(name + '_defaults.rb') if FileTest.exist?(name + '_defaults.rb') #FileUtils.rm(central_defaults_filename) if FileTest.exist?(central_defaults_filename) FileUtils.rm(tmp_filename) if FileTest.exist?(tmp_filename) raise "Defaults file: #{central_defaults_filename} already exists" if FileTest.exist? central_defaults_filename flxclass = flux_class(fluxcode) make_new_defaults_file(name, trinity_input_file) flxclass.make_new_defaults_file(name + '_flxtmp', flux_input_file) File.open(defaults_filename, 'a'){|file| file.puts <= n_flux_tubes_jac jn = i - n_flux_tubes_jac + 1 run_name = "calibrate_" + @run_name + (jn).to_s else jn = i + 1 run_name = @run_name + (jn).to_s end run_name end def flux_folder_name(i) if i >= n_flux_tubes_jac jn = i - n_flux_tubes_jac + 1 folder = "calibrate_#{jn}" else jn = i + 1 folder = "flux_tube_#{jn}" end folder end end # Backwards compatibility Gs2::TrinityComponent = Trinity::TrinityComponent::Gs2 end