Changeset 7730 for anuga_core/source/anuga/interface/test_model.py
- Timestamp:
- May 17, 2010, 3:57:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/interface/test_model.py
r7728 r7730 11 11 class modelTestCase(unittest.TestCase): 12 12 def setUp(self): 13 self.model = Model() 13 # construct and name model 14 self.model = Model('test_model') 14 15 pass 15 16 … … 38 39 from anuga.shallow_water import Dirichlet_boundary 39 40 40 self.model.set_geometry(*rectangular_cross(10, 5, len1=10.0, len2=5.0)) # Create domain41 self.model.set_name('channel1') # Output name41 def topography(x, y): 42 return -x/10 42 43 43 #------------------------------------------------------------------------------ 44 # Setup initial conditions 45 #------------------------------------------------------------------------------ 46 def topography(x, y): 47 return -x/10 # linear bed slope 44 # set quantities 45 self.model.set_quantity('elevation', topography) 46 self.model.set_quantity('friction', 0.01) 47 self.model.set_quantity('stage', expression='elevation') 48 48 49 self.model.set_quantity('elevation', topography) # Use function for elevation 50 self.model.set_quantity('friction', 0.01) # Constant friction 49 # set properties of boundaries (reflective, flow in, etc.) 50 Bi = Dirichlet_boundary([0.4, 0, 0]) # Inflow 51 self.model.set_boundary({'left': Bi, 'right': Bi, 'top': Bi, 'bottom': Bi}) 52 53 # set the geometry to use (may be a mesh file, or points/vertices tuple) 54 self.model.set_geometry(*rectangular_cross(2, 2, len1=10.0, len2=5.0)) 55 56 # build, then run the simulation 57 self.model.build() 58 self.model.run(0.5, 1.0) 59 60 61 def test_wrong_input_order(self): 62 """The user tries to build before model is defined. """ 63 51 64 self.model.set_quantity('stage', # Dry bed 52 expression='elevation') 65 expression='elevation') 53 66 67 try: 68 self.model.build() 69 except: 70 pass 71 else: 72 msg = 'Should have raised exception for missing mesh' 73 raise Exception, msg 74 75 76 def test_duplicate_geometry(self): 77 """The user tries to assign geometry twice. """ 78 79 self.model.set_geometry(*rectangular_cross(2, 2, len1=10.0, len2=5.0)) 80 81 try: 82 self.model.set_geometry(*rectangular_cross(2, 2, len1=10.0, len2=5.0)) 83 except: 84 pass 85 else: 86 msg = 'Should have raised bad input exception' 87 raise Exception, msg 88 89 90 def test_input_after_build(self): 91 """The user tries to change built model. """ 92 93 self.model.set_geometry(*rectangular_cross(2, 2, len1=10.0, len2=5.0)) 54 94 self.model.build() 55 95 56 #------------------------------------------------------------------------------ 57 # Setup boundary conditions 58 #------------------------------------------------------------------------------ 59 Bi = Dirichlet_boundary([0.4, 0, 0]) # Inflow 60 # Br = Reflective_boundary(domain) # Solid reflective wall 96 try: 97 self.model.set_quantity('friction', 0.01) 98 except: 99 pass 100 else: 101 msg = 'Should have raised exception because model already built' 102 raise Exception, msg 61 103 62 # domain.set_boundary({'left': Bi, 'right': Bi, 'top': Bi, 'bottom': Bi})63 64 #------------------------------------------------------------------------------65 # Evolve system through time66 #------------------------------------------------------------------------------67 # for t in domain.evolve(yieldstep=0.2, finaltime=40.0):68 # print domain.timestepping_statistics()69 70 104 71 105
Note: See TracChangeset
for help on using the changeset viewer.