def test_initial_state_grid(): """Test passing in an initial array of node states.""" nr = 4 nc = 3 hg = HexModelGrid(shape=(nr, nc), node_layout='rect', orientation='vertical') ins = hg.add_zeros('node', 'node_state', dtype=np.int) ins[hg.y_of_node < 2] = 8 params = { 'grid_size': (nr, nc), 'report_interval': 5.0, 'output_interval': 1.0e99, 'disturbance_rate': 0.0, 'weathering_rate': 0.0, 'dissolution_rate': 1.0, 'run_duration': 3.0e3, 'plot_interval': 1.0e99, 'uplift_interval': 1.0e7, 'friction_coef': 1.0, 'fault_x': -0.001, 'cell_width': 1.0, 'grav_accel': 9.8, 'plot_file_name': 'test_column_dissolution', 'init_state_grid': ins, 'seed': 0, } gfs = GrainFacetSimulator(**params) assert_equal(np.count_nonzero(gfs.ca.node_state), 6)
def initialize(self, filename=None): """Initialize the GrainHill model. Parameters ---------- filename : str, optional Path to name of input file, or dict. """ if isinstance(filename, str): p = load_params(filename) elif isinstance(filename, dict): p = filename else: p = _DEFAULT_PARAMETERS if ('number_of_node_rows' in p and 'number_of_node_columns' in p): p['grid_size'] = (p['number_of_node_rows'], p['number_of_node_columns']) p.pop('number_of_node_rows') p.pop('number_of_node_columns') # Handle model type if 'model_type' in p: model_type = p.pop('model_type') else: model_type = 'grain_hill' # Instantiate model and get handle to grid if 'block' in model_type.lower(): self._model = BlockHill(**p) elif 'facet' in model_type.lower(): self._model = GrainFacetSimulator(**p) else: self._model = GrainHill(**p) self.grid = self._model.grid # Landlab grid as public attribute self._values = {"node_state": self.grid.at_node['node_state']} self._var_units = {"node_state": "-"} self._var_loc = {"node_state": "node"} self._grids = {0: ["node_state"]} self._grid_type = { 0: "unstructured" } # closest BMI category to hexagona self._initialized = True
'weathering_rate': 0.0, 'dissolution_rate': 0.0, 'uplift_interval': 866.0, 'plot_interval': 1300.0, 'friction_coef': 1.0, 'fault_x': 23.0, 'cell_width': 0.5, 'grav_accel': 9.8, } # Sweep through a range of parameters for dist_exp in np.arange(-4, 0): for weath_exp in np.arange(-4, 0): weath_rate = 10.0**weath_exp dist_rate = 10.0**dist_exp params['disturbance_rate'] = dist_rate params['weathering_rate'] = weath_rate print('Disturbance rate: ' + str(params['disturbance_rate']) + ' 1/y') print('Weathering rate: ' + str(params['weathering_rate']) + ' 1/y') opname = ('d' + str(int(10 * dist_exp)) + 'w' + str(int(10 * weath_exp))) create_folder(opname) params['plot_file_name'] = opname + '/' + opname gfs = GrainFacetSimulator(**params) gfs.run() save_grid(gfs.grid, opname + '.grid', clobber=True)
params['opt_rock_collapse'] = 1.0 params['opt_track_grains'] = True # Cosmo parameters cosmo_interval = 50.0 cosmo_prod_rate = 1.0 cosmo_decay_depth = 0.6 next_cosmo = cosmo_interval # Create a field for cosmo concentration params['prop_reset_value'] = 0.0 params['prop_data'] = 'cosmogenic_nuclide__concentration' # instantiate a GrainFacet model gh = GrainFacetSimulator((num_rows, num_cols), **params) # instantiate a Cosmo handler ci = CosmogenicIrradiator(gh, cosmo_prod_rate, cosmo_decay_depth) #run the model #current_time = 0.0 #while current_time < params['run_duration']: # run_to = min(next_cosmo, params['run_duration']) # print('current time ' + str(current_time)) # print('running to ' + str(run_to)) # gh.run(to=run_to) # ci.add_cosmos(run_to - current_time, delta) # next_cosmo += cosmo_interval # current_time = run_to