def test_run(t_max=10.0, DEM_file='Animas_200.mat', SILENT=False): Toggles.VARIABLE_DT_TOGGLE = 0 # (or change to 1) ################################### print 'Starting GC2D test run...' print 'Reading input file...' (H, Zb, Zi, dx, dy) = load_state(DEM_file=DEM_file, RESTART_TOGGLE=0, INIT_COND_TOGGLE=1) ny, nx = Zb.shape #------------------ # Initialize vars #------------------ t = np.float64(0) conserveIce = np.float64(0) # (total ice mass ??) meltrate = np.zeros((ny, nx), dtype='Float64') ## fd_watch = {} ## fd_watch['thick'] = open( 'thickness_py.bin' , 'wb' ) ## counter = 0 while (t < t_max): (dt, t, H, Zi, meltrate, conserveIce) = gc2d.update(t, H, Zb, dx, dy, meltrate, conserveIce, SILENT=SILENT) ## COMPRESS_TOGGLE = Toggles.COMPRESS_TOGGLE, ## ICEFLOW_TOGGLE = Toggles.ICEFLOW_TOGGLE, ## ICESLIDE_TOGGLE = Toggles.ICESLIDE_TOGGLE, ## VARIABLE_DT_TOGGLE = Toggles.VARIABLE_DT_TOGGLE, ## dtDefault=Parameters.dtDefault, ## dtMax=Parameters.dtMax) #----------------------- # Print a short report #----------------------- print ' ' print '(nx, ny) =', nx, ny print '(dx, dy) =', dx, dy print '(Hmin, Hmax) =', H.min(), H.max() print '(Zbmin, Zbmax) =', Zb.min(), Zb.max() print '(Zimin, Zimax) =', Zi.min(), Zi.max() print '(MRmin, MRmax) =', meltrate.min(), meltrate.max() print 'conserveIce =', conserveIce print 'Finished.' print ' '
def test_run( t_max=10.0, DEM_file='Animas_200.mat', SILENT=False): Toggles.VARIABLE_DT_TOGGLE = 0 # (or change to 1) ################################### print 'Starting GC2D test run...' print 'Reading input file...' ( H, Zb, Zi, dx, dy ) = load_state(DEM_file=DEM_file, RESTART_TOGGLE = 0, INIT_COND_TOGGLE=1 ) ny, nx = Zb.shape #------------------ # Initialize vars #------------------ t = np.float64(0) conserveIce = np.float64(0) # (total ice mass ??) meltrate = np.zeros( (ny, nx), dtype='Float64' ) ## fd_watch = {} ## fd_watch['thick'] = open( 'thickness_py.bin' , 'wb' ) ## counter = 0 while (t < t_max): (dt, t, H, Zi, meltrate, conserveIce) = gc2d.update( t, H, Zb, dx, dy, meltrate, conserveIce, SILENT=SILENT) ## COMPRESS_TOGGLE = Toggles.COMPRESS_TOGGLE, ## ICEFLOW_TOGGLE = Toggles.ICEFLOW_TOGGLE, ## ICESLIDE_TOGGLE = Toggles.ICESLIDE_TOGGLE, ## VARIABLE_DT_TOGGLE = Toggles.VARIABLE_DT_TOGGLE, ## dtDefault=Parameters.dtDefault, ## dtMax=Parameters.dtMax) #----------------------- # Print a short report #----------------------- print ' ' print '(nx, ny) =', nx, ny print '(dx, dy) =', dx, dy print '(Hmin, Hmax) =', H.min(), H.max() print '(Zbmin, Zbmax) =', Zb.min(), Zb.max() print '(Zimin, Zimax) =', Zi.min(), Zi.max() print '(MRmin, MRmax) =', meltrate.min(), meltrate.max() print 'conserveIce =', conserveIce print 'Finished.' print ' '
def update(self, dt=-1.0): #------------------------------------------------- # Note: self.MR already set to 0 by initialize() #------------------------------------------------- if (self.comp_status == 'Disabled'): return self.status = 'updating' # (OpenMI) #------------------------- # Update computed values #------------------------- # print '### CALLING GC2D.update()...' (dt, t, H, Zi, MR, conserveIce) = gc2d.update( self.time, self.H, self.Zb, self.dx, self.dy, self.MR, ### self.dy, self.meltrate, self.conserveIce, ICEFLOW_TOGGLE=self.ICEFLOW_TOGGLE, ICESLIDE_TOGGLE=self.ICESLIDE_TOGGLE, VARIABLE_DT_TOGGLE=self.VARIABLE_DT_TOGGLE, dtDefault=self.dt_max, ### dtMax=self.dt_max) ## ICEFLOW_TOGGLE=self.Toggles.ICEFLOW_TOGGLE, ## ICESLIDE_TOGGLE=self.Toggles.ICESLIDE_TOGGLE, ## VARIABLE_DT_TOGGLE=self.Toggles.VARIABLE_DT_TOGGLE, ## dtDefault=self.Parameters.dtDefault, ## dtMax=self.Parameters.dtMax ) if (self.mode == 'driver'): self.print_time_and_value(H.max(), 'H_max', '[m]') #-------------- # For testing #-------------- ## print 'type(H) =', type(H) ## print 'type(Zi) =', type(Zi) ## print 'type(MR) =', type(MR) ## print ' ' #------------------------------------------ # Save computed vars in component's state #------------------------------------------ self.H = H self.Zi = Zi self.MR = MR ## self.meltrate = MR self.conserveIce = conserveIce ## self.update_meltrate() ## self.update_meltrate_integral() #------------------------ # Update internal clock #--------------------------------------------------- # GC2D's update() function updates the time and # optionally uses an adaptive timestep (in years). #--------------------------------------------------- self.dt = dt self.dt_min = np.minimum(dt, self.dt_min) ### #---------------------------------------- # Read next ice vars from input files ? #---------------------------------------- ## self.read_input_files() #---------------------------------------------- # Write user-specified data to output files ? #---------------------------------------------- # Components use own self.time_sec by default. #----------------------------------------------- self.write_output_files() ## self.write_output_files( time_seconds ) #----------------------------- # Update internal clock # after write_output_files() #----------------------------- self.update_time(dt) self.status = 'updated' # (OpenMI)
def update(self, dt=-1.0): #------------------------------------------------- # Note: self.MR already set to 0 by initialize() #------------------------------------------------- if (self.comp_status == 'Disabled'): return self.status = 'updating' # (OpenMI) #------------------------- # Update computed values #------------------------- # print '### CALLING GC2D.update()...' (dt, t, H, Zi, MR, conserveIce) = gc2d.update( self.time, self.H, self.Zb, self.dx, self.dy, self.MR, ### self.dy, self.meltrate, self.conserveIce, ICEFLOW_TOGGLE=self.ICEFLOW_TOGGLE, ICESLIDE_TOGGLE=self.ICESLIDE_TOGGLE, VARIABLE_DT_TOGGLE=self.VARIABLE_DT_TOGGLE, dtDefault=self.dt_max, ### dtMax=self.dt_max ) ## ICEFLOW_TOGGLE=self.Toggles.ICEFLOW_TOGGLE, ## ICESLIDE_TOGGLE=self.Toggles.ICESLIDE_TOGGLE, ## VARIABLE_DT_TOGGLE=self.Toggles.VARIABLE_DT_TOGGLE, ## dtDefault=self.Parameters.dtDefault, ## dtMax=self.Parameters.dtMax ) if (self.mode == 'driver'): self.print_time_and_value(H.max(), 'H_max', '[m]') #-------------- # For testing #-------------- ## print 'type(H) =', type(H) ## print 'type(Zi) =', type(Zi) ## print 'type(MR) =', type(MR) ## print ' ' #------------------------------------------ # Save computed vars in component's state #------------------------------------------ self.H = H self.Zi = Zi self.MR = MR ## self.meltrate = MR self.conserveIce = conserveIce ## self.update_meltrate() ## self.update_meltrate_integral() #------------------------ # Update internal clock #--------------------------------------------------- # GC2D's update() function updates the time and # optionally uses an adaptive timestep (in years). #--------------------------------------------------- self.dt = dt self.dt_min = np.minimum(dt, self.dt_min) ### #---------------------------------------- # Read next ice vars from input files ? #---------------------------------------- ## self.read_input_files() #---------------------------------------------- # Write user-specified data to output files ? #---------------------------------------------- # Components use own self.time_sec by default. #----------------------------------------------- self.write_output_files() ## self.write_output_files( time_seconds ) #----------------------------- # Update internal clock # after write_output_files() #----------------------------- self.update_time( dt ) self.status = 'updated' # (OpenMI)