Changeset 8092
- Timestamp:
- Dec 7, 2010, 5:03:30 PM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga/structures
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/inlet.py
r8081 r8092 235 235 236 236 # find the number of cells which will be filled 237 index = num.nonzero(summed_volume< volume)[0][-1]237 index = num.nonzero(summed_volume<=volume)[0][-1] 238 238 239 239 # calculate stage needed to fill chosen cells with given volume of water -
trunk/anuga_core/source/anuga/structures/inlet_operator.py
r8080 r8092 35 35 self.Q = Q 36 36 37 38 37 if description == None: 39 38 self.description = ' ' … … 50 49 self.verbose = verbose 51 50 52 53 51 # Keep count of inlet operator 54 52 Inlet_operator.counter += 1 55 53 56 import pdb57 #pdb.set_trace()58 59 54 self.enquiry_point = 0.5*(self.line[0] + self.line[1]) 60 55 self.outward_vector = self.line … … 66 61 67 62 timestep = self.domain.get_timestep() 63 64 t = self.domain.get_time() 65 Q1 = self.update_Q(t) 66 Q2 = self.update_Q(t + timestep) 68 67 69 Q = self.Q 70 71 volume = Q*timestep 72 73 assert Q >= 0.0, 'Q < 0: Water to be removed from an inlet!' 74 75 68 volume = 0.5*(Q1+Q2)*timestep 69 70 assert 0.5*(Q1+Q2) >= 0.0, 'Q < 0: Water to be removed from an inlet!' 71 76 72 # Distribute volume so as to obtain flat surface 77 73 self.inlet.set_stages_evenly(volume) … … 79 75 # Distribute volume evenly over all cells 80 76 #self.inlet.set_depths_evenly(volume) 77 78 def update_Q(self, t): 79 """Virtual method allowing local modifications by writing an 80 overriding version in descendant 81 """ 82 83 if callable(self.Q): 84 Q = self.Q(t)[0] 85 else: 86 Q = self.Q 87 88 return Q 81 89 82 83 90 def statistics(self): 84 91 -
trunk/anuga_core/source/anuga/structures/test_inlet_operator.py
r8079 r8092 9 9 import anuga 10 10 11 from anuga.utilities.system_tools import get_pathname_from_package12 from anuga.structures.boyd_box_operator import Boyd_box_operator13 11 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 14 12 from anuga.shallow_water.shallow_water_domain import Domain 15 from anuga. shallow_water.forcing import Rainfall, Inflow13 from anuga.abstract_2d_finite_volumes.util import file_function 16 14 17 15 from anuga.structures.inlet_operator import Inlet_operator … … 83 81 return domain 84 82 85 def test_inlet_ Q(self):83 def test_inlet_constant_Q(self): 86 84 """test_inlet_Q 87 85 … … 129 127 assert numpy.allclose((Q1+Q2)*finaltime, vol1-vol0, rtol=1.0e-8) 130 128 129 def test_inlet_variable_Q(self): 130 """test_inlet_Q 131 131 132 This tests that the inlet operator adds the correct amount of water 133 """ 134 135 stage_0 = 11.0 136 stage_1 = 10.0 137 elevation_0 = 10.0 138 elevation_1 = 10.0 139 140 domain_length = 200.0 141 domain_width = 200.0 142 143 144 domain = self._create_domain(d_length=domain_length, 145 d_width=domain_width, 146 dx = 10.0, 147 dy = 10.0, 148 elevation_0 = elevation_0, 149 elevation_1 = elevation_1, 150 stage_0 = stage_0, 151 stage_1 = stage_1) 152 153 vol0 = domain.compute_total_volume() 154 155 finaltime = 3.0 156 line1 = [[95.0, 10.0], [105.0, 10.0]] 157 Q1 = file_function('inlet_operator_test1.tms', quantities=['hydrograph']) 158 159 line2 = [[10.0, 90.0], [20.0, 90.0]] 160 Q2 = file_function('inlet_operator_test2.tms', quantities=['hydrograph']) 161 162 Inlet_operator(domain, line1, Q1) 163 Inlet_operator(domain, line2, Q2) 164 165 for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime): 166 #domain.write_time() 167 #print domain.volumetric_balance_statistics() 168 pass 169 170 171 vol1 = domain.compute_total_volume() 172 173 print vol1 - vol0 174 175 assert numpy.allclose(13.5, vol1-vol0, rtol=1.0e-8) 176 132 177 133 178
Note: See TracChangeset
for help on using the changeset viewer.