Changeset 8874
- Timestamp:
- May 24, 2013, 12:06:00 PM (12 years ago)
- Location:
- trunk/anuga_core/source/anuga/structures
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/inlet_enquiry.py
r8873 r8874 83 83 def get_enquiry_depth(self): 84 84 85 return max(self.get_enquiry_stage() - self.get_enquiry_invert_elevation(), 0.0) 86 87 88 def get_enquiry_water_depth(self): 89 85 90 return self.get_enquiry_stage() - self.get_enquiry_elevation() 86 91 … … 96 101 def get_enquiry_velocity(self): 97 102 98 depth = self.get_enquiry_ depth()103 depth = self.get_enquiry_water_depth() 99 104 u = self.get_enquiry_xmom()/(depth + velocity_protection/depth) 100 105 v = self.get_enquiry_ymom()/(depth + velocity_protection/depth) … … 105 110 def get_enquiry_xvelocity(self): 106 111 107 depth = self.get_enquiry_ depth()112 depth = self.get_enquiry_water_depth() 108 113 return self.get_enquiry_xmom()/(depth + velocity_protection/depth) 109 114 110 115 def get_enquiry_yvelocity(self): 111 116 112 depth = self.get_enquiry_ depth()117 depth = self.get_enquiry_water_depth() 113 118 return self.get_enquiry_ymom()/(depth + velocity_protection/depth) 114 119 -
trunk/anuga_core/source/anuga/structures/inlet_operator.py
r8849 r8874 18 18 def __init__(self, 19 19 domain, 20 line,20 poly, 21 21 Q = 0.0, 22 22 velocity = None, … … 30 30 anuga.Operator.__init__(self, domain, description, label, logging, verbose) 31 31 32 self. line = numpy.array(line, dtype='d')32 self.poly = numpy.array(poly, dtype='d') 33 33 34 34 # should set this up to be a function of time and or space) … … 38 38 #print self.Q 39 39 40 self.enquiry_point = 0.5*(self.line[0] + self.line[1]) 40 41 self.inlet = inlet.Inlet(self.domain, self.poly, verbose= verbose) 42 43 n = len(self.poly) 44 45 self.enquiry_point = numpy.sum(self.poly,axis=1)/n 46 47 41 48 #self.outward_vector = self.line 42 self.inlet = inlet.Inlet(self.domain, self.line, verbose= verbose)43 49 44 50 if velocity is not None: -
trunk/anuga_core/source/anuga/structures/run_inlet_operator.py
r8361 r8874 104 104 line0 = [[0.0, 5.0], [0.0, 10.0]] 105 105 106 106 107 Q = file_function('test_hydrograph.tms', quantities=['hydrograph']) 107 108 108 inlet0 = Inlet_operator(domain, line0, Q, label='first inlet')109 #inlet0 = Inlet_operator(domain, line0, Q, label='first inlet') 109 110 110 111 111 112 line1 = [[1.0, 5.0], [2.0, 10.0]] 112 inlet1 = Inlet_operator(domain, line1, 2.0) 113 poly1 = [[1.0, 5.0], [2.0, 5.0], [2.0, 10.0], [1.0, 10.0]] 114 inlet1 = Inlet_operator(domain, poly1, 2.0) 113 115 114 116 … … 154 156 print domain.volumetric_balance_statistics() 155 157 156 inlet0.print_timestepping_statistics()157 print inlet1.timestepping_statistics()158 #inlet0.print_timestepping_statistics() 159 inlet1.print_timestepping_statistics() 158 160 pass 159 161 -
trunk/anuga_core/source/anuga/structures/structure_operator.py
r8873 r8874 298 298 n_exchange_1 = len(self.exchange_lines[1]) 299 299 300 assert n_exchange_0 == n_exchange_1, 'There sho iuld be the same number of points in both exchange_lines'300 assert n_exchange_0 == n_exchange_1, 'There should be the same number of points in both exchange_lines' 301 301 302 302 if n_exchange_0 == 2: -
trunk/anuga_core/source/anuga/structures/test_inlet_operator.py
r8828 r8874 126 126 127 127 assert numpy.allclose((Q1+Q2)*finaltime, vol1-vol0, rtol=1.0e-8) 128 129 def test_inlet_variable_Q(self): 128 129 130 131 def test_inlet_constant_Q_polygon(self): 130 132 """test_inlet_Q 131 133 132 134 This tests that the inlet operator adds the correct amount of water 133 135 """ … … 140 142 domain_length = 200.0 141 143 domain_width = 200.0 142 144 143 145 144 146 domain = self._create_domain(d_length=domain_length, … … 154 156 155 157 finaltime = 3.0 156 157 #Make sure we are inthe right directory to find the 158 #time series data for the inlets 159 import os 160 baseDir = os.getcwd() 161 162 try: 163 os.chdir('structures') 164 except: 165 pass 166 167 line1 = [[95.0, 10.0], [105.0, 10.0]] 168 Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph']) 169 170 line2 = [[10.0, 90.0], [20.0, 90.0]] 171 Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph']) 172 173 os.chdir(baseDir) 174 175 Inlet_operator(domain, line1, Q1) 176 Inlet_operator(domain, line2, Q2) 158 poly1 = [[95.0, 10.0], [105.0, 10.0], [105, 20.0], [95.0, 20.0]] 159 Q1 = 5.00 160 161 162 Inlet_operator(domain, poly1, Q1, logging=True) 163 177 164 178 165 for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime): … … 180 167 #print domain.volumetric_balance_statistics() 181 168 pass 182 169 183 170 184 171 vol1 = domain.compute_total_volume() 185 172 186 #print vol1-vol0187 188 assert numpy.allclose(13.5, vol1-vol0, rtol=1.0e-8) 189 190 def test_inlet_variable_Q _default(self):173 assert numpy.allclose((Q1)*finaltime, vol1-vol0, rtol=1.0e-8) 174 175 176 177 def test_inlet_variable_Q(self): 191 178 """test_inlet_Q 192 179 193 180 This tests that the inlet operator adds the correct amount of water 194 181 """ … … 201 188 domain_length = 200.0 202 189 domain_width = 200.0 203 190 204 191 205 192 domain = self._create_domain(d_length=domain_length, … … 214 201 vol0 = domain.compute_total_volume() 215 202 216 finaltime = 5.0203 finaltime = 3.0 217 204 218 205 #Make sure we are inthe right directory to find the … … 228 215 line1 = [[95.0, 10.0], [105.0, 10.0]] 229 216 Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph']) 230 217 231 218 line2 = [[10.0, 90.0], [20.0, 90.0]] 232 219 Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph']) 233 220 234 221 os.chdir(baseDir) 235 236 Inlet_operator(domain, line1, Q1 , default=6)237 Inlet_operator(domain, line2, Q2 , default=3)222 223 Inlet_operator(domain, line1, Q1) 224 Inlet_operator(domain, line2, Q2) 238 225 239 226 for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime): … … 241 228 #print domain.volumetric_balance_statistics() 242 229 pass 230 231 232 vol1 = domain.compute_total_volume() 233 234 #print vol1-vol0 235 236 assert numpy.allclose(13.5, vol1-vol0, rtol=1.0e-8) 237 238 def test_inlet_variable_Q_default(self): 239 """test_inlet_Q 240 241 This tests that the inlet operator adds the correct amount of water 242 """ 243 244 stage_0 = 11.0 245 stage_1 = 10.0 246 elevation_0 = 10.0 247 elevation_1 = 10.0 248 249 domain_length = 200.0 250 domain_width = 200.0 251 252 253 domain = self._create_domain(d_length=domain_length, 254 d_width=domain_width, 255 dx = 10.0, 256 dy = 10.0, 257 elevation_0 = elevation_0, 258 elevation_1 = elevation_1, 259 stage_0 = stage_0, 260 stage_1 = stage_1) 261 262 vol0 = domain.compute_total_volume() 263 264 finaltime = 5.0 265 266 #Make sure we are inthe right directory to find the 267 #time series data for the inlets 268 import os 269 baseDir = os.getcwd() 270 271 try: 272 os.chdir('structures') 273 except: 274 pass 275 276 line1 = [[95.0, 10.0], [105.0, 10.0]] 277 Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph']) 278 279 line2 = [[10.0, 90.0], [20.0, 90.0]] 280 Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph']) 281 282 os.chdir(baseDir) 283 284 Inlet_operator(domain, line1, Q1, default=6) 285 Inlet_operator(domain, line2, Q2, default=3) 286 287 for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime): 288 #domain.write_time() 289 #print domain.volumetric_balance_statistics() 290 pass 243 291 244 292 … … 251 299 # ========================================================================= 252 300 if __name__ == "__main__": 253 suite = unittest.makeSuite(Test_inlet_operator, 'test ')301 suite = unittest.makeSuite(Test_inlet_operator, 'test_inlet_constant_Q_polygon') 254 302 runner = unittest.TextTestRunner() 255 303 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.