Changeset 7492
- Timestamp:
- Sep 7, 2009, 4:19:23 PM (15 years ago)
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r7485 r7492 246 246 self.time = 0.0 247 247 self.finaltime = None 248 self. min_timestep = self.max_timestep = 0.0248 self.recorded_min_timestep = self.recorded_max_timestep = 0.0 249 249 self.starttime = 0 # Physical starttime if any 250 250 # (0 is 1 Jan 1970 00:00:00) … … 898 898 899 899 msg = '' 900 #if self. min_timestep == self.max_timestep:900 #if self.recorded_min_timestep == self.recorded_max_timestep: 901 901 # msg += 'Time = %.4f, delta t = %.8f, steps=%d (%d)'\ 902 # %(self.time, self. min_timestep, self.number_of_steps,902 # %(self.time, self.recorded_min_timestep, self.number_of_steps, 903 903 # self.number_of_first_order_steps) 904 #elif self. min_timestep > self.max_timestep:904 #elif self.recorded_min_timestep > self.recorded_max_timestep: 905 905 # msg += 'Time = %.4f, steps=%d (%d)'\ 906 906 # %(self.time, self.number_of_steps, … … 908 908 #else: 909 909 # msg += 'Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)'\ 910 # %(self.time, self. min_timestep,911 # self. max_timestep, self.number_of_steps,910 # %(self.time, self.recorded_min_timestep, 911 # self.recorded_max_timestep, self.number_of_steps, 912 912 # self.number_of_first_order_steps) 913 913 914 914 model_time = self.get_time() 915 if self. min_timestep == self.max_timestep:915 if self.recorded_min_timestep == self.recorded_max_timestep: 916 916 msg += 'Time = %.4f, delta t = %.8f, steps=%d' \ 917 % (model_time, self. min_timestep, self.number_of_steps)918 elif self. min_timestep > self.max_timestep:917 % (model_time, self.recorded_min_timestep, self.number_of_steps) 918 elif self.recorded_min_timestep > self.recorded_max_timestep: 919 919 msg += 'Time = %.4f, steps=%d' \ 920 920 % (model_time, self.number_of_steps) 921 921 else: 922 922 msg += 'Time = %.4f, delta t in [%.8f, %.8f], steps=%d' \ 923 % (model_time, self. min_timestep,924 self. max_timestep, self.number_of_steps)923 % (model_time, self.recorded_min_timestep, 924 self.recorded_max_timestep, self.number_of_steps) 925 925 926 926 msg += ' (%ds)' % (walltime() - self.last_walltime) … … 1310 1310 """ 1311 1311 1312 from anuga.config import min_timestep, max_timestep,epsilon1312 from anuga.config import epsilon 1313 1313 1314 1314 # FIXME: Maybe lump into a larger check prior to evolving … … 1321 1321 1322 1322 if yieldstep is None: 1323 yieldstep = max_timestep1323 yieldstep = self.evolve_max_timestep 1324 1324 else: 1325 1325 yieldstep = float(yieldstep) … … 1340 1340 1341 1341 # Initialise interval of timestep sizes (for reporting only) 1342 self. min_timestep =max_timestep1343 self. max_timestep =min_timestep1342 self.recorded_min_timestep = self.evolve_max_timestep 1343 self.recorded_max_timestep = self.evolve_min_timestep 1344 1344 self.number_of_steps = 0 1345 1345 self.number_of_first_order_steps = 0 … … 1409 1409 # Reinitialise 1410 1410 self.yieldtime += yieldstep # move to next yield 1411 self. min_timestep =max_timestep1412 self. max_timestep =min_timestep1411 self.recorded_min_timestep = self.evolve_max_timestep 1412 self.recorded_max_timestep = self.evolve_min_timestep 1413 1413 self.number_of_steps = 0 1414 1414 self.number_of_first_order_steps = 0 … … 1422 1422 """One Euler Time Step 1423 1423 Q^{n+1} = E(h) Q^n 1424 1425 Assumes that centroid values have been extrapolated to vertices and edges 1424 1426 """ 1425 1427 1426 1428 # Compute fluxes across each element edge 1427 1429 self.compute_fluxes() 1430 1431 # Compute forcing terms 1432 self.compute_forcing_terms() 1428 1433 1429 1434 # Update timestep to fit yieldstep and finaltime … … 1464 1469 self.compute_fluxes() 1465 1470 1471 # Compute forcing terms 1472 self.compute_forcing_terms() 1473 1466 1474 # Update timestep to fit yieldstep and finaltime 1467 1475 self.update_timestep(yieldstep, finaltime) … … 1483 1491 1484 1492 ###### 1485 # Second Euler step 1493 # Second Euler step using the same timestep 1494 # calculated in the first step. Might lead to 1495 # stability problems but we have not seen any 1496 # example. 1486 1497 ###### 1487 1498 1488 1499 # Compute fluxes across each element edge 1489 1500 self.compute_fluxes() 1501 1502 # Compute forcing terms 1503 self.compute_forcing_terms() 1490 1504 1491 1505 # Update conserved quantities … … 1531 1545 self.compute_fluxes() 1532 1546 1547 # Compute forcing terms 1548 self.compute_forcing_terms() 1549 1533 1550 # Update timestep to fit yieldstep and finaltime 1534 1551 self.update_timestep(yieldstep, finaltime) … … 1550 1567 1551 1568 ###### 1552 # Second Euler step 1569 # Second Euler step using the same timestep 1570 # calculated in the first step. Might lead to 1571 # stability problems but we have not seen any 1572 # example. 1553 1573 ###### 1554 1574 1555 1575 # Compute fluxes across each element edge 1556 1576 self.compute_fluxes() 1577 1578 # Compute forcing terms 1579 self.compute_forcing_terms() 1557 1580 1558 1581 # Update conserved quantities … … 1585 1608 # Compute fluxes across each element edge 1586 1609 self.compute_fluxes() 1610 1611 # Compute forcing terms 1612 self.compute_forcing_terms() 1587 1613 1588 1614 # Update conserved quantities … … 1675 1701 # @param finaltime 1676 1702 def update_timestep(self, yieldstep, finaltime): 1677 min_timestep = self.get_evolve_min_timestep()1678 max_timestep = self.get_evolve_max_timestep()1679 1703 1680 1704 # Protect against degenerate timesteps arising from isolated … … 1716 1740 # self.timestep is calculated from speed of characteristics 1717 1741 # Apply CFL condition here 1718 timestep = min(self.CFL*self.flux_timestep, max_timestep)1742 timestep = min(self.CFL*self.flux_timestep, self.evolve_max_timestep) 1719 1743 1720 1744 # Record maximal and minimal values of timestep for reporting 1721 self. max_timestep = max(timestep, self.max_timestep)1722 self. min_timestep = min(timestep, self.min_timestep)1745 self.recorded_max_timestep = max(timestep, self.recorded_max_timestep) 1746 self.recorded_min_timestep = min(timestep, self.recorded_min_timestep) 1723 1747 1724 1748 # Protect against degenerate time steps 1725 if timestep < min_timestep:1749 if timestep < self.evolve_min_timestep: 1726 1750 # Number of consecutive small steps taken b4 taking action 1727 1751 self.smallsteps += 1 … … 1736 1760 % self.max_smallsteps 1737 1761 log.critical(msg) 1738 timestep = min_timestep # Try enforcing min_step1762 timestep = self.evolve_min_timestep # Try enforcing min_step 1739 1763 1740 1764 log.critical(self.timestepping_statistics(track_speeds=True)) … … 1767 1791 """ 1768 1792 1793 # The parameter self.flux_timestep should be updated 1794 # by the forcing_terms to ensure stability 1795 1769 1796 for f in self.forcing_terms: 1770 1797 f(self) 1798 1771 1799 1772 1800 ## … … 1774 1802 def update_conserved_quantities(self): 1775 1803 """Update vectors of conserved quantities using previously 1776 computed fluxes specified forcing functions.1804 computed fluxes and specified forcing functions. 1777 1805 """ 1778 1806 … … 1782 1810 timestep = self.timestep 1783 1811 1784 # Compute forcing terms1785 self.compute_forcing_terms()1786 1812 1787 1813 # Update conserved_quantities -
anuga_core/source/anuga/culvert_flows/test_culvert_class.py
r7317 r7492 238 238 239 239 msg = 'Total volume has changed' 240 assert num.allclose(new_volume, ref_volume ), msg240 assert num.allclose(new_volume, ref_volume, rtol=1.0e-10), msg 241 241 pass 242 242 … … 338 338 for t in domain.evolve(yieldstep = 0.1, finaltime = 25): 339 339 new_volume = domain.get_quantity('stage').get_integral() 340 341 msg = ('Total volume has changed: Is %.2f m^3 should have been %.2f m^3' 340 341 342 msg = ('Total volume has changed: Is %.8f m^3 should have been %.8f m^3' 342 343 % (new_volume, ref_volume)) 343 assert num.allclose(new_volume, ref_volume ), msg344 345 346 344 assert num.allclose(new_volume, ref_volume, rtol=1.0e-10), msg 345 346 347 return 347 348 # Now try this for a range of other depths 348 349 for depth in [1.0, 0.5, 0.2, 0.1, 0.05]: … … 360 361 % (new_volume, ref_volume) 361 362 362 assert num.allclose(new_volume, ref_volume ), msg363 assert num.allclose(new_volume, ref_volume, rtol=1.0e-10), msg 363 364 364 365 … … 467 468 468 469 msg = 'Total volume has changed' 469 assert num.allclose(new_volume, ref_volume ), msg470 assert num.allclose(new_volume, ref_volume, rtol=1.0e-10), msg 470 471 pass 471 472 -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r7452 r7492 4097 4097 4098 4098 # Data from earlier version of abstract_2d_finite_volumes 4099 assert num.allclose(domain. min_timestep, 0.0396825396825)4100 assert num.allclose(domain. max_timestep, 0.0396825396825)4099 assert num.allclose(domain.recorded_min_timestep, 0.0396825396825) 4100 assert num.allclose(domain.recorded_max_timestep, 0.0396825396825) 4101 4101 4102 4102 msg = ("domain.quantities['stage'].centroid_values[:12]=%s" … … 4163 4163 4164 4164 # Data from earlier version of abstract_2d_finite_volumes 4165 #assert allclose(domain. min_timestep, 0.0396825396825)4166 #assert allclose(domain. max_timestep, 0.0396825396825)4165 #assert allclose(domain.recorded_min_timestep, 0.0396825396825) 4166 #assert allclose(domain.recorded_max_timestep, 0.0396825396825) 4167 4167 #print domain.quantities['stage'].centroid_values 4168 4168 … … 4194 4194 4195 4195 # FIXME: These numbers were from version before 25/10 4196 #assert allclose(domain. min_timestep, 0.0140413643926)4197 #assert allclose(domain. max_timestep, 0.0140947355753)4196 #assert allclose(domain.recorded_min_timestep, 0.0140413643926) 4197 #assert allclose(domain.recorded_max_timestep, 0.0140947355753) 4198 4198 4199 4199 for i in range(3): … … 4241 4241 pass 4242 4242 4243 msg = 'min step was %f instead of %f' % (domain. min_timestep,4243 msg = 'min step was %f instead of %f' % (domain.recorded_min_timestep, 4244 4244 0.0210448446782) 4245 4245 4246 assert num.allclose(domain. min_timestep, 0.0210448446782), msg4247 assert num.allclose(domain. max_timestep, 0.0210448446782)4246 assert num.allclose(domain.recorded_min_timestep, 0.0210448446782), msg 4247 assert num.allclose(domain.recorded_max_timestep, 0.0210448446782) 4248 4248 4249 4249 #FIXME: These numbers were from version before 25/10 … … 4295 4295 pass 4296 4296 4297 assert num.allclose(domain. min_timestep, 0.0210448446782)4298 assert num.allclose(domain. max_timestep, 0.0210448446782)4297 assert num.allclose(domain.recorded_min_timestep, 0.0210448446782) 4298 assert num.allclose(domain.recorded_max_timestep, 0.0210448446782) 4299 4299 4300 4300 #FIXME: These numbers were from version before 21/3/6 - … … 4390 4390 for t in domain.evolve(yieldstep=0.01, finaltime=0.03): 4391 4391 pass 4392 assert num.allclose(domain. min_timestep, 0.0210448446782)4393 assert num.allclose(domain. max_timestep, 0.0210448446782)4392 assert num.allclose(domain.recorded_min_timestep, 0.0210448446782) 4393 assert num.allclose(domain.recorded_max_timestep, 0.0210448446782) 4394 4394 4395 4395 #print domain.quantities['stage'].centroid_values[:4] … … 4470 4470 # FIXME (Ole): Need some other assertion here! 4471 4471 #print domain.min_timestep, domain.max_timestep 4472 #assert allclose(domain. min_timestep, 0.050010003001)4473 #assert allclose(domain. max_timestep, 0.050010003001)4472 #assert allclose(domain.recorded_min_timestep, 0.050010003001) 4473 #assert allclose(domain.recorded_max_timestep, 0.050010003001) 4474 4474 4475 4475 os.remove(domain.get_name() + '.sww') … … 4693 4693 4694 4694 # Data from earlier version of abstract_2d_finite_volumes ft=0.1 4695 assert num.allclose(domain. min_timestep, 0.0376895634803)4696 assert num.allclose(domain. max_timestep, 0.0415635655309)4695 assert num.allclose(domain.recorded_min_timestep, 0.0376895634803) 4696 assert num.allclose(domain.recorded_max_timestep, 0.0415635655309) 4697 4697 4698 4698 assert num.allclose(domain.quantities['stage'].centroid_values, -
anuga_core/source/pymetis/test_all.py
r7487 r7492 23 23 24 24 # Directories that should not be searched for test files. 25 exclude_dirs = ['metis ',# Special requirements25 exclude_dirs = ['metis-4.0','pymetis', # Special requirements 26 26 '.svn', # subversion 27 27 'props', 'wcprops', 'prop-base', 'text-base', 'tmp'] -
anuga_validation/okushiri_2005/run_okushiri.py
r6046 r7492 22 22 23 23 # Module imports 24 from anuga.shallow_water import Domain 25 from anuga.shallow_water import Reflective_boundary 26 from anuga.shallow_water import Transmissive_momentum_set_stage_boundary 27 from anuga.abstract_2d_finite_volumes.util import file_function 24 from anuga.interface import Domain 25 from anuga.interface import Reflective_boundary 26 from anuga.interface import Time_boundary 27 from anuga.interface import Transmissive_momentum_set_stage_boundary 28 from anuga.interface import Transmissive_n_momentum_zero_t_momentum_set_stage_boundary 29 from anuga.interface import file_function 28 30 29 31 import project … … 82 84 triangle_id = domain.get_triangle_containing_point([4.521, 1.196]) 83 85 # This should get triangle id 32833 with centroid (4.5244, 1.1972) 86 bdry_id = domain.get_triangle_containing_point([0.000, 1.696]) 87 print 'bdry_id = ',bdry_id 84 88 85 89 … … 92 96 for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): 93 97 domain.write_time() 98 print function(domain.get_time())[0],' bdry_d = ',bdry_id,' ',\ 99 domain.get_conserved_quantities(bdry_id, edge=0)[0],' ',\ 100 domain.get_conserved_quantities(bdry_id, edge=1)[0],' ',\ 101 domain.get_conserved_quantities(bdry_id, edge=2)[0] 102 94 103 95 104 print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracChangeset
for help on using the changeset viewer.