Changeset 9273 for trunk/anuga_core/validation_tests/analytical_exact
- Timestamp:
- Jul 20, 2014, 10:32:49 PM (11 years ago)
- Location:
- trunk/anuga_core/validation_tests/analytical_exact
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py
r9241 r9273 26 26 pass 27 27 28 def test_ simulation(self):28 def test_avalanche_dry(self): 29 29 30 30 … … 87 87 88 88 89 if verbose:90 89 print 90 print indent+'Errors in stage: ',eh10, eh30 91 91 92 assert eh10 < 0.01, 'L^1 error %g greater than 1 percent'% eh1093 assert eh30 < 0.01, 'L^1 error %g greater than 1 percent'% eh3094 92 95 93 … … 98 96 euh10 = numpy.sum(numpy.abs(uh10_n-u10*h10))/numpy.sum(numpy.abs(u10*h10)) 99 97 euh30 = numpy.sum(numpy.abs(uh30_n-u30*h30))/numpy.sum(numpy.abs(u30*h30)) 100 98 101 99 102 if verbose: 103 print indent+'Errors in xmomentum: ',euh10, euh30 104 105 106 assert euh10 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh10 107 assert euh30 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh30 108 109 100 print indent+'Errors in xmomentum: ',euh10, euh30 110 101 111 102 #Test xvelocity … … 114 105 eu30 = numpy.sum(numpy.abs(u30_n-u30))/numpy.sum(numpy.abs(u30)) 115 106 116 if verbose: 117 print indent+'Errors in xvelocity: ', eu10, eu30 107 108 print indent+'Errors in xvelocity: ', eu10, eu30 109 110 111 assert eh10 < 0.01, 'L^1 error %g greater than 1 percent'% eh10 112 assert eh30 < 0.01, 'L^1 error %g greater than 1 percent'% eh30 113 114 assert euh10 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh10 115 assert euh30 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh30 116 118 117 119 118 assert eu10 < 0.2, 'L^1 error %g greater than 20 percent'% eu10 -
trunk/anuga_core/validation_tests/analytical_exact/avalanche_wet/numerical_avalanche_wet.py
r9241 r9273 7 7 # Import necessary modules 8 8 #------------------------------------------------------------------------------ 9 import sys10 9 import anuga 11 from anuga import Domain as Domain 12 from math import cos 10 from anuga import Domain 11 from anuga import Operator 12 13 13 from numpy import zeros 14 from time import localtime, strftime , gmtime15 from numpy import sin, cos, tan, arctan14 from time import localtime, strftime 15 from numpy import cos, arctan 16 16 from anuga import myid, finalize, distribute 17 17 … … 45 45 verbose = args.verbose 46 46 47 class Coulomb_friction: 48 49 def __init__(self, 47 48 49 50 class Coulomb_friction(object): 51 52 def __init__(self, 50 53 friction_slope=0.05, 51 54 bed_slope=0.1): … … 57 60 self.F = g*cos(thet)*cos(thet)*friction_slope 58 61 self.m = -1.0*g*bed_slope + self.F 59 60 def __call__(self, domain): 61 62 w = domain.quantities['stage'].centroid_values 63 z = domain.quantities['elevation'].centroid_values 64 h = w-z 65 66 xmom_update = domain.quantities['xmomentum'].explicit_update 67 #ymom_update = domain.quantities['ymomentum'].explicit_update 68 69 xmom_update[:] = xmom_update + self.F*h 62 63 64 class Friction_operator(Operator): 65 66 def __init__(self, 67 domain, 68 friction=None, 69 description = None, 70 label = None, 71 logging = False, 72 verbose = False): 73 74 Operator.__init__(self, domain, description, label, logging, verbose) 75 76 77 self.friction = friction 78 self.F = self.friction.F 79 self.m = self.friction.m 80 81 def __call__(self): 82 83 timestep = self.domain.get_timestep() 84 85 h = self.stage_c - self.elev_c 86 87 self.xmom_c[:] = self.xmom_c + timestep* self.F*h 88 89 def parallel_safe(self): 90 """Operator is applied independently on each cell and 91 so is parallel safe. 92 """ 93 return True 94 95 96 70 97 71 98 72 99 bed_slope = 0.1 73 100 friction_slope = 0.05 74 Coulomb_forcing_term = Coulomb_friction(friction_slope, bed_slope) 101 coulomb_friction = Coulomb_friction(friction_slope, bed_slope) 102 #coulomb_forcing_term = Coulomb_friction(friction_slope, bed_slope) 75 103 76 104 def stage(X,Y): … … 95 123 h_r = h_0 #+ bed_slope*cell_len 96 124 w_r = z_r + h_r 97 u_r = Coulomb_forcing_term.m*t125 u_r = coulomb_friction.m*t 98 126 #['stage', 'xmomentum', 'ymomentum'] 99 127 return [w_r, u_r*h_r, 0.0] … … 103 131 h_l = h_1 #+ bed_slope*cell_len 104 132 w_l = z_l + h_l 105 u_l = Coulomb_forcing_term.m*t133 u_l = coulomb_friction.m*t 106 134 #['stage', 'xmomentum', 'ymomentum'] 107 135 return [w_l, u_l*h_l, 0.0] … … 132 160 domain.set_quantity('friction', 0.0) 133 161 134 domain.forcing_terms.append(Coulomb_forcing_term)135 162 136 163 domain.set_quantity('stage', stage) … … 146 173 #=============================================================================== 147 174 domain = distribute(domain) 175 176 177 #------------------------------------------------------------------------------ 178 # Setup Operators 179 #------------------------------------------------------------------------------ 180 Friction_operator(domain, friction=coulomb_friction) 148 181 149 182 #----------------------------------------------------------------------------- -
trunk/anuga_core/validation_tests/analytical_exact/avalanche_wet/validate_avalanche_wet.py
r9241 r9273 26 26 pass 27 27 28 def test_ simulation(self):28 def test_avalanche_wet(self): 29 29 30 30 … … 84 84 85 85 86 if verbose:87 86 print 87 print indent+'Errors in stage: ',eh20, eh40 88 88 89 assert eh20 < 0.01, 'L^1 error %g greater than 1 percent'% eh20 90 assert eh40 < 0.01, 'L^1 error %g greater than 1 percent'% eh40 89 91 90 92 91 … … 97 96 98 97 99 if verbose: 100 print indent+'Errors in xmomentum: ',euh20, euh40 101 102 103 assert euh20 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh20 104 assert euh40 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh40 105 106 98 print indent+'Errors in xmomentum: ',euh20, euh40 107 99 108 100 #Test xvelocity … … 111 103 eu40 = numpy.sum(numpy.abs(u40_n-u40))/numpy.sum(numpy.abs(u40)) 112 104 113 if verbose: 114 print indent+'Errors in xvelocity: ', eu20, eu40 105 print indent+'Errors in xvelocity: ', eu20, eu40 115 106 107 assert eh20 < 0.01, 'L^1 error %g greater than 1 percent'% eh20 108 assert eh40 < 0.01, 'L^1 error %g greater than 1 percent'% eh40 109 110 assert euh20 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh20 111 assert euh40 < 0.025, 'L^1 error %g greater than 2.5 percent'% euh40 112 116 113 assert eu20 < 0.02, 'L^1 error %g greater than 2 percent'% eu20 117 114 assert eu40 < 0.01, 'L^1 error %g greater than 2 percent'% eu40 -
trunk/anuga_core/validation_tests/analytical_exact/carrier_greenspan_periodic/numerical_carrier_greenspan.py
r9179 r9273 173 173 #------------------------------------------------------------------------------ 174 174 for t in domain.evolve(yieldstep = Tp/48., finaltime = 7000.): 175 if myid == 0 : print domain.timestepping_statistics()175 if myid == 0 and verbose: print domain.timestepping_statistics() 176 176 177 177 -
trunk/anuga_core/validation_tests/analytical_exact/carrier_greenspan_periodic/validate_carrier_greenspan_periodic.py
r9241 r9273 26 26 pass 27 27 28 def test_ simulation(self):28 def test_carrier_greenspan_periodic(self): 29 29 30 30 … … 89 89 ew[i] = numpy.sum(numpy.abs(W_n[i]-W[i]))/numpy.sum(numpy.abs(W[i])) 90 90 91 if verbose:92 print indent+'L^1 Errors in stage: ', ew93 91 94 for i, id in enumerate(ids): 95 assert ew[i] < 0.01, 'L^1 error %g greater than 1 percent'% ew[i] 96 92 print 93 print indent+'L^1 Errors in stage: ', ew 97 94 98 95 #Test xmomenta … … 106 103 107 104 108 109 if verbose: 110 print indent+'L^1 Errors in xmomentum: ',euh 111 112 for i, id in enumerate(ids): 113 assert euh[i] < 0.02, 'L^1 error %g greater than 2 percent'% euh[i] 114 105 print indent+'L^1 Errors in xmomentum: ',euh 115 106 116 107 #Test xvelocity … … 124 115 eu[i] = numpy.sum(numpy.abs(U_n[i]-U[i]))/numpy.sum(numpy.abs(U[i])) 125 116 126 if verbose: 127 print indent+'L^1 Errors in xvelocity: ', eu 117 print indent+'L^1 Errors in xvelocity: ', eu 128 118 119 for i, id in enumerate(ids): 120 assert ew[i] < 0.01, 'L^1 error %g greater than 1 percent'% ew[i] 121 122 for i, id in enumerate(ids): 123 assert euh[i] < 0.02, 'L^1 error %g greater than 2 percent'% euh[i] 124 129 125 for i, id in enumerate(ids): 130 126 assert eu[i] < 0.1, 'L^1 error %g greater than 10 percent'% eu[i] -
trunk/anuga_core/validation_tests/analytical_exact/carrier_greenspan_transient/validate_carrier_greenspan_transient.py
r9155 r9273 15 15 indent = anuga.indent 16 16 17 verbose = True 17 args = anuga.get_args() 18 verbose = args.verbose 18 19 19 20 class Test_results(unittest.TestCase): … … 30 31 pass 31 32 32 def test_ simulation(self):33 def test_carrier_greenspan_transient(self): 33 34 34 35 … … 38 39 39 40 s = 'numerical_cg_transient.py' 40 res = os.system('python %s > validate_output.stdout' %s)41 41 res = anuga.run_anuga_script(s,args=args) 42 42 43 # Test that script runs ok 43 44 assert res == 0 … … 103 104 ew[i] = numpy.sum(numpy.abs(W_n[i]-W[i]))/numpy.sum(numpy.abs(W[i])) 104 105 105 if verbose:106 106 print 107 print indent+'L^1 Errors in stage: ', ew 107 108 108 for i, id in enumerate(ids):109 assert ew[i] < 0.01, 'L^1 error %g greater than 1 percent'% ew[i]110 109 111 110 … … 117 116 118 117 119 120 if verbose: 121 print indent+'L^1 Errors in xmomentum: ',euh 122 123 for i, id in enumerate(ids): 124 assert euh[i] < 0.025, 'L^1 error %g greater than 2 percent'% euh[i] 125 118 print indent+'L^1 Errors in xmomentum: ',euh 126 119 127 120 #Test xvelocity … … 135 128 eu[i] = numpy.sum(numpy.abs(U_n[i]-U[i]))/numpy.sum(numpy.abs(U[i])) 136 129 137 if verbose: 138 print indent+'L^1 Errors in xvelocity: ', eu 130 print indent+'L^1 Errors in xvelocity: ', eu 139 131 140 132 for i, id in enumerate(ids): 141 assert eu[i] < 0.02, 'L^1 error %g greater than 2 percent'% eu[i] 133 assert ew[i] < 0.01, 'L^1 error %g greater than 1 percent'% ew[i] 134 135 for i, id in enumerate(ids): 136 assert euh[i] < 0.025, 'L^1 error %g greater than 2.5 percent'% euh[i] 137 138 for i, id in enumerate(ids): 139 assert eu[i] < 0.025, 'L^1 error %g greater than 2.5 percent'% eu[i] 142 140 143 141 -
trunk/anuga_core/validation_tests/analytical_exact/dam_break_dry/validate_dam_break_dry.py
r9174 r9273 28 28 pass 29 29 30 def test_ simulation(self):30 def test_dam_break_dry(self): 31 31 32 32 … … 70 70 eh100 = numpy.sum(numpy.abs(p2_st.stage[100,v2]-h100))/numpy.sum(numpy.abs(h100)) 71 71 72 if verbose: 73 print indent+'Errors in stage: ',eh10, eh50, eh100 74 75 assert eh10 < 0.1, 'Relative L^1 error %g greater than 0.1'% eh10 76 assert eh50 < 0.1, 'Relative L^1 error %g greater than 0.1'% eh50 77 assert eh100 < 0.15, 'Relative L^1 error %g greater than 0.15'% eh100 72 print 73 print indent+'Errors in stage: ',eh10, eh50, eh100 78 74 79 75 … … 84 80 euh100 = numpy.sum(numpy.abs(p2_st.xmom[100,v2]-u100*h100))/numpy.sum(numpy.abs(u100*h100)) 85 81 86 if verbose: 87 print indent+'Errors in xmomentum: ',euh10, euh50, euh100 88 89 90 assert euh10 < 0.25, 'Relative L^1 error %g greater than 0.25'% euh10 91 assert euh50 < 0.25, 'Relative L^1 error %g greater than 0.25'% euh50 92 assert euh100 < 0.25, 'Relative L^1 error %g greater than 0.25'% euh100 93 82 print indent+'Errors in xmomentum: ',euh10, euh50, euh100 94 83 95 84 #Test xvelocity … … 99 88 eu100 = numpy.sum(numpy.abs(p2_st.xvel[100,v2]-u100))/numpy.sum(numpy.abs(u100)) 100 89 101 if verbose: 102 print indent+'Errors in xvelocity: ', eu10, eu50, eu100 90 print indent+'Errors in xvelocity: ', eu10, eu50, eu100 91 92 93 assert eh10 < 0.1, 'Relative L^1 error %g greater than 0.1'% eh10 94 assert eh50 < 0.1, 'Relative L^1 error %g greater than 0.1'% eh50 95 assert eh100 < 0.15, 'Relative L^1 error %g greater than 0.15'% eh100 96 97 assert euh10 < 0.25, 'Relative L^1 error %g greater than 0.25'% euh10 98 assert euh50 < 0.25, 'Relative L^1 error %g greater than 0.25'% euh50 99 assert euh100 < 0.25, 'Relative L^1 error %g greater than 0.25'% euh100 103 100 104 101 assert eu10 < 2.0, 'Relative L^1 error %g greater than 2.0'% eu10 -
trunk/anuga_core/validation_tests/analytical_exact/dam_break_wet/validate_dam_break_wet.py
r9174 r9273 27 27 pass 28 28 29 def test_ simulation(self):29 def test_dam_break_wet(self): 30 30 31 31 … … 69 69 eh100 = numpy.sum(numpy.abs(p2_st.stage[100,v2]-h100))/numpy.sum(numpy.abs(h100)) 70 70 71 if verbose: 72 print indent+'Errors in stage: ',eh10, eh50, eh100 73 74 assert eh10 < 0.01, 'L^1 error %g greater than 1\%'% eh10 75 assert eh50 < 0.01, 'L^1 error %g greater than 1\%'% eh50 76 assert eh100 < 0.01, 'L^1 error %g greater than 1\%'% eh100 77 71 print 72 print indent+'Errors in stage: ',eh10, eh50, eh100 78 73 79 74 #Test xmomenta … … 83 78 euh100 = numpy.sum(numpy.abs(p2_st.xmom[100,v2]-u100*h100))/numpy.sum(numpy.abs(u100*h100)) 84 79 85 if verbose: 86 print indent+'Errors in xmomentum: ',euh10, euh50, euh100 87 88 89 assert euh10 < 0.02, 'L^1 error %g greater than 2\%'% euh10 90 assert euh50 < 0.01, 'L^1 error %g greater than 1\%'% euh50 91 assert euh100 < 0.01, 'L^1 error %g greater than 1\%'% euh100 92 80 print indent+'Errors in xmomentum: ',euh10, euh50, euh100 93 81 94 82 #Test xvelocity … … 98 86 eu100 = numpy.sum(numpy.abs(p2_st.xvel[100,v2]-u100))/numpy.sum(numpy.abs(u100)) 99 87 100 if verbose: 101 print indent+'Errors in xvelocity: ', eu10, eu50, eu100 88 print indent+'Errors in xvelocity: ', eu10, eu50, eu100 89 90 assert eh10 < 0.01, 'L^1 error %g greater than 1\%'% eh10 91 assert eh50 < 0.01, 'L^1 error %g greater than 1\%'% eh50 92 assert eh100 < 0.01, 'L^1 error %g greater than 1\%'% eh100 93 94 assert euh10 < 0.02, 'L^1 error %g greater than 2\%'% euh10 95 assert euh50 < 0.01, 'L^1 error %g greater than 1\%'% euh50 96 assert euh100 < 0.01, 'L^1 error %g greater than 1\%'% euh100 102 97 103 98 assert eu10 < 0.02, 'L^1 error %g greater than 2\%'% eu10
Note: See TracChangeset
for help on using the changeset viewer.