- Timestamp:
- Sep 19, 2014, 5:05:42 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/utilities/quantity_setting_functions.py
r9338 r9341 198 198 199 199 # Get indices fInds of points in pi which are not set 200 if(pi is'All'):200 if(pi == 'All'): 201 201 fInside=(1-isSet) 202 202 fInds=(fInside==1).nonzero()[0] 203 203 else: 204 if(pi is'Extent' and type(fi) is str and os.path.exists(fi)):204 if(pi == 'Extent' and type(fi) is str and os.path.exists(fi)): 205 205 # Here fi MUST be a gdal-compatible raster 206 206 # Then we get the extent from the raster itself … … 250 250 isSet[fInds]=1 251 251 252 if( not min(isSet)==1):252 if( min(isSet) != 1): 253 253 raise Exception, 'Some points were not inside any polygon' 254 254 -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami3/scripts/run_model.py
r9339 r9341 56 56 # Get key data for the simulation 57 57 58 import project 58 from prepare_data import PrepareData 59 project = PrepareData('ANUGA_setup.xls') 59 60 60 61 ############################################################################### -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami3/scripts/setup_boundary_conditions.py
r9339 r9341 13 13 import anuga 14 14 import anuga.utilities.spatialInputUtil as su 15 import anuga.shallow_water.boundaries as asb 15 16 16 17 … … 27 28 """ 28 29 29 # @@@@@@@@@@@@@@@@@# 30 # START EDITING HERE 31 # @@@@@@@@@@@@@@@@@# 30 # Dict to hold { boundary_tag: boundary_condition_function } 31 boundary_tags_and_conditions = {} 32 32 33 # Example: 34 # "Standard" boundary conditions 33 for i in range(len(project.boundary_data)): 34 bd = project.boundary_data[i] 35 boundary_tag = bd[0] 36 boundary_condition_type = bd[1] 35 37 36 br = anuga.Reflective_boundary(domain) 38 if boundary_condition_type == 'Reflective': 39 # Simple reflective boundary 40 boundary_tags_and_conditions[boundary_tag] = \ 41 anuga.Reflective_boundary(domain) 42 elif boundary_condition_type == 'Stage': 43 # Here we read a timeseries, offset the starttime, and then pass 44 # that function as a set stage transmissive n momentum ... boundary 45 boundary_data_file = bd[2] 46 start_time = bd[3] 47 # Read data 48 boundary_data = scipy.genfromtxt( 49 boundary_data_file, 50 delimiter=',', 51 skip_header=1) 52 # Make start time = 0 53 boundary_data[:,0]-=start_time 54 # Make interpolation function 55 stage_time_fun = scipy.interpolate.interp1d( 56 boundary_data[:,0], 57 boundary_data[:,1]) 58 # Make boundary condition 59 boundary_function = \ 60 asb.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( 61 domain, 62 stage_time_fun) 63 64 boundary_tags_and_conditions[boundary_tag] = \ 65 boundary_function 37 66 38 # Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Be 39 # careful with this one 67 else: 68 msg = 'Boundary condition type ' + boundary_condition_type +\ 69 ' for tag ' + boundary_tag + ' is not implemented' 40 70 41 # Example: 42 # Transmissive with stage being set by a function 'stage_function' 43 44 def stage_function(t): 45 return min(max(t - 60., 0.) / 60., 1.) 46 47 import anuga.shallow_water.boundaries as asb 48 b_t_stage_function = \ 49 asb.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( 50 domain, 51 stage_function) 52 53 # Here we associate each tag in boundary_info with its boundary condition 54 # defined above 55 56 boundary_tags_and_conditions = {'Ocean': b_t_stage_function, 57 'Br': br} 58 59 # @@@@@@@@@@@@@@@@@# 60 # STOP EDITING HERE 61 # @@@@@@@@@@@@@@@@@# 71 62 72 63 73 # Check that all tags in boundary_info have been set … … 70 80 raise Exception(msg) 71 81 82 # Set the boundary 83 72 84 domain.set_boundary(boundary_tags_and_conditions) 73 85 -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami3/scripts/setup_initial_conditions.py
r9339 r9341 69 69 # 70 70 71 # @@@@@@@@@@@@@@@@@#72 # START EDITING HERE73 # @@@@@@@@@@@@@@@@@#74 75 # #########################################################################76 #77 # PRELIMINARY DEFINITIONS78 #79 # #########################################################################80 81 # If the earthquake slip is given then convert to deformation here82 # So that we can add it to both elevation AND stage83 84 make_earthquake_deformation_from_source_model = False85 86 if make_earthquake_deformation_from_source_model:87 source_model = '../anuga/source/XXXXX.csv'88 89 # Make an earthquake source model90 91 eq_function = okada_tsunami.earthquake_source(92 source=None,93 filename=source_model,94 domain=domain,95 lon_lat_degrees=True,96 lon_before_lat=False,97 proj4string=project.proj4string,98 verbose=False,99 )100 else:101 102 # Make a function that is zero everywhere103 # If we pass this to add_quantity, nothing should happen104 105 def eq_function(x, y):106 return x * 0.107 108 # #########################################################################109 #110 # Set elevation.111 #112 # #########################################################################113 114 # The 'Patong 10m' dataset115 elevation_patong_10m = '../anuga/topographies/patong_10m_grid_msl_Project.txt'116 117 # The 'saddle 10m' dataset118 elevation_saddle_10m = \119 '../anuga/topographies/patong_10m_small_grid_for_anuga_sub_Project.txt'120 121 # The '1s grid' dataset122 elevation_patong_1s = \123 '../anuga/topographies/patong_bay_1s_grid_Project.txt'124 125 # The background data126 elevation_default = \127 '../anuga/topographies/andaman_3s_grid_Clip2_Project.txt'128 129 # Set_quantity data130 elevation_data = [['../anuga/polygons/patong_10m.txt',131 elevation_patong_10m],132 ['../anuga/polygons/saddle_10m.txt',133 elevation_saddle_10m],134 ['../anuga/polygons/patong_1s.txt',135 elevation_patong_1s],136 ['All', elevation_default]]137 138 # Define a function for add_quantity in the same way139 # [ ['All', 0.] ] will do nothing140 141 elevation_additions = [['All', eq_function]]142 143 # #############################################################################144 #145 # Set friction146 #147 # #############################################################################148 149 default_friction = 0.025150 151 # Set_quantity data152 153 friction_data = [['All', default_friction]]154 155 # Add_quantity data156 157 friction_additions = [['All', 0.]]158 159 # ##############################################################################160 #161 # Set stage162 #163 # ##############################################################################164 165 # Set_quantity data166 167 stage_data = [['All', 0.]]168 169 # Add_quantity data170 171 stage_additions = [['All', eq_function]]172 173 # ##############################################################################174 #175 # Set depth integrated velocity (called "momentum" in ANUGA although that176 # is incorrect")177 #178 # ##############################################################################179 180 # Set_quantity data181 182 xmomentum_data = [['All', 0.]]183 184 # Add_quantity data185 186 xmomentum_additions = [['All', 0.]]187 188 # Set_quantity data189 190 ymomentum_data = [['All', 0.]]191 192 # Add_quantity data193 194 ymomentum_additions = [['All', 0.]]195 196 # @@@@@@@@@@@@@@@@@#197 # STOP EDITING HERE198 # @@@@@@@@@@@@@@@@@#199 200 71 # ############################################################################### 201 72 # … … 208 79 209 80 elevation_function = \ 210 qs.composite_quantity_setting_function( elevation_data, domain)81 qs.composite_quantity_setting_function(project.elevation_data, domain) 211 82 domain.set_quantity('elevation', elevation_function, 212 83 location='vertices') 213 84 elevation_addition_function = \ 214 qs.composite_quantity_setting_function( elevation_additions,85 qs.composite_quantity_setting_function(project.elevation_additions, 215 86 domain) 216 87 domain.add_quantity('elevation', elevation_addition_function) 217 88 218 89 friction_function = \ 219 qs.composite_quantity_setting_function( friction_data, domain)90 qs.composite_quantity_setting_function(project.friction_data, domain) 220 91 domain.set_quantity('friction', friction_function, 221 92 location='centroids') 222 93 friction_addition_function = \ 223 qs.composite_quantity_setting_function( friction_additions,94 qs.composite_quantity_setting_function(project.friction_additions, 224 95 domain) 225 96 domain.add_quantity('friction', friction_addition_function) 226 97 227 stage_function = qs.composite_quantity_setting_function( stage_data,98 stage_function = qs.composite_quantity_setting_function(project.stage_data, 228 99 domain) 229 100 domain.set_quantity('stage', stage_function, location='centroids') 230 101 stage_addition_function = \ 231 qs.composite_quantity_setting_function( stage_additions, domain)102 qs.composite_quantity_setting_function(project.stage_additions, domain) 232 103 domain.add_quantity('stage', stage_addition_function) 233 104 234 105 xmomentum_function = \ 235 qs.composite_quantity_setting_function( xmomentum_data, domain)106 qs.composite_quantity_setting_function(project.xmomentum_data, domain) 236 107 domain.set_quantity('xmomentum', xmomentum_function, 237 108 location='centroids') 238 109 xmomentum_addition_function = \ 239 qs.composite_quantity_setting_function( xmomentum_additions,110 qs.composite_quantity_setting_function(project.xmomentum_additions, 240 111 domain) 241 112 domain.add_quantity('xmomentum', xmomentum_addition_function) 242 113 243 114 ymomentum_function = \ 244 qs.composite_quantity_setting_function( ymomentum_data, domain)115 qs.composite_quantity_setting_function(project.ymomentum_data, domain) 245 116 domain.set_quantity('ymomentum', ymomentum_function, 246 117 location='centroids') 247 118 ymomentum_addition_function = \ 248 qs.composite_quantity_setting_function( ymomentum_additions,119 qs.composite_quantity_setting_function(project.ymomentum_additions, 249 120 domain) 250 121 domain.add_quantity('ymomentum', ymomentum_addition_function) -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami3/scripts/setup_mesh.py
r9339 r9341 116 116 if myid == 0: 117 117 118 # Make sure files/folders to store everything are there119 120 project.setup_directory_structure()121 122 118 # Copy code files to output dir. This should be 'nearly the first' 123 119 # thing we do -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami3/scripts/user_functions.py
r9339 r9341 94 94 {boundary_line_and_tags[0][1]: range(len(bounding_polygon) - 1)} 95 95 96 #97 # import pdb98 # pdb.set_trace()99 100 96 for i in range(boundary_segnum - 1): 101 97
Note: See TracChangeset
for help on using the changeset viewer.