Changeset 8985
- Timestamp:
- Sep 23, 2013, 5:29:05 PM (11 years ago)
- Location:
- trunk/anuga_core/source/anuga/structures
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/boyd_box_operator.py
r8876 r8985 145 145 self.driving_energy = self.inflow.get_enquiry_depth() 146 146 147 verbose = False 148 if verbose: 149 print 50*'=' 150 print 'width ',self.culvert_width 151 print 'depth ',self.culvert_height 152 print 'flow_width ',self.culvert_width 153 print 'length ' ,self.culvert_length 154 print 'driving_energy ',self.driving_energy 155 print 'delta_total_energy ',self.delta_total_energy 156 print 'outlet_enquiry_depth ',self.outflow.get_enquiry_depth() 157 print 'sum_loss ',self.sum_loss 158 print 'manning ',self.manning 147 159 148 160 Q, barrel_velocity, outlet_culvert_depth, flow_area, case = \ … … 177 189 # define separately so that can be imported in parallel code. 178 190 #============================================================================= 179 def boyd_box_function(width, depth, flow_width, length, driving_energy, delta_total_energy, outlet_enquiry_depth, sum_loss, manning): 191 def boyd_box_function(width, 192 depth, 193 flow_width, 194 length, 195 driving_energy, 196 delta_total_energy, 197 outlet_enquiry_depth, 198 sum_loss, 199 manning): 180 200 181 201 # intially assume the culvert flow is controlled by the inlet -
trunk/anuga_core/source/anuga/structures/test_boyd_box_operator.py
r8828 r8985 6 6 7 7 from anuga.structures.boyd_box_operator import Boyd_box_operator 8 from anuga.structures.boyd_box_operator import boyd_box_function 9 8 10 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 9 11 from anuga.shallow_water.shallow_water_domain import Domain 10 12 import numpy 13 14 verbose = False 11 15 12 16 … … 30 34 elevation_1, 31 35 stage_0, 32 stage_1): 36 stage_1, 37 xvelocity_0 = 0.0, 38 xvelocity_1 = 0.0, 39 yvelocity_0 = 0.0, 40 yvelocity_1 = 0.0): 33 41 34 42 points, vertices, boundary = rectangular_cross(int(d_length/dx), int(d_width/dy), … … 67 75 68 76 return z 77 78 def xmom(x,y): 79 """Set up xmomentum 80 """ 81 z = numpy.zeros(x.shape,dtype='d') 82 z[:] = xvelocity_0*(stage_0-elevation_0) 83 84 numpy.putmask(z, x > d_length/2, xvelocity_1*(stage_1-elevation_1) ) 85 86 return z 87 88 def ymom(x,y): 89 """Set up ymomentum 90 """ 91 z = numpy.zeros(x.shape,dtype='d') 92 z[:] = yvelocity_0*(stage_0-elevation_0) 93 94 numpy.putmask(z, x > d_length/2, yvelocity_1*(stage_1-elevation_1) ) 95 96 return z 69 97 70 98 #print 'Setting Quantities....' 71 99 domain.set_quantity('elevation', elevation) # Use function for elevation 72 100 domain.set_quantity('stage', stage) # Use function for elevation 101 domain.set_quantity('xmomentum', xmom) 102 domain.set_quantity('ymomentum', ymom) 73 103 74 104 return domain … … 96 126 97 127 culvert_apron = 0.0 98 enquiry_gap = 10.0128 enquiry_gap = 5.0 99 129 100 130 … … 138 168 ( Q, v, d ) = culvert.discharge_routine() 139 169 140 #print 'test_boyd_non_skew' 141 #print 'Q: ', Q, 'expected_Q: ', expected_Q 170 if verbose: 171 print 'test_boyd_non_skew' 172 print 'Q: ', Q, 'expected_Q: ', expected_Q 142 173 143 174 … … 147 178 148 179 180 181 182 183 149 184 def test_boyd_skew(self): 150 185 """test_boyd_skew … … 169 204 170 205 culvert_apron = 0.0 171 enquiry_gap = 10.0206 enquiry_gap = 5.0 172 207 173 208 expected_Q = 6.23 … … 210 245 ( Q, v, d ) = culvert.discharge_routine() 211 246 212 #print 'test_boyd_skew' 213 #print 'Q: ', Q, 'expected_Q: ', expected_Q 247 if verbose: 248 print 'test_boyd_skew' 249 print 'Q: ', Q, 'expected_Q: ', expected_Q 214 250 215 251 assert numpy.allclose(Q, expected_Q, rtol=1.0e-2) #inflow … … 240 276 241 277 culvert_apron = 0.0 242 enquiry_gap = 10.0278 enquiry_gap = 5.0 243 279 244 280 expected_Q = 6.23 … … 283 319 verbose=False) 284 320 285 #culvert.determine_inflow_outflow() 321 286 322 287 323 ( Q, v, d ) = culvert.discharge_routine() 288 324 289 #print 'test_boyd_non_skew_enquiry_points' 290 #print 'Q: ', Q, 'expected_Q: ', expected_Q 291 #print 'v: ', v, 'expected_v: ', expected_v 292 #print 'd: ', d, 'expected_d: ', expected_d 325 if verbose: 326 print 'test_boyd_non_skew_enquiry_points' 327 print 'Q: ', Q, 'expected_Q: ', expected_Q 328 print 'v: ', v, 'expected_v: ', expected_v 329 print 'd: ', d, 'expected_d: ', expected_d 293 330 294 331 assert numpy.allclose(Q, expected_Q, rtol=1.0e-2) #inflow … … 296 333 assert numpy.allclose(d, expected_d, rtol=1.0e-2) #depth at outlet used to calc v 297 334 298 335 def test_boyd_1(self): 336 """test_boyd_1 337 338 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 339 calculation code by MJ Boyd 340 """ 341 342 343 g=9.81 344 345 346 inlet_depth=0.150 347 outlet_depth=0.15 348 inlet_velocity=1.00 349 outlet_velocity=0.5 350 351 culvert_length=10.0 352 culvert_width=3.6 353 culvert_height=1.20 354 355 culvert_type='box' 356 manning=0.013 357 sum_loss=1.5 358 359 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 360 culvert_slope=10.0 # % Downward 361 z_in = 10.0 362 z_out = z_in-culvert_length*culvert_slope/100 363 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 364 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 365 delta_total_energy = E_in-E_out 366 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 367 368 369 if verbose: 370 print 50*'=' 371 print 'width ',culvert_width 372 print 'depth ',culvert_height 373 print 'flow_width ',culvert_width 374 print 'length ' ,culvert_length 375 print 'driving_energy ',inlet_specific_energy 376 print 'delta_total_energy ',delta_total_energy 377 print 'outlet_enquiry_depth ',outlet_depth 378 print 'sum_loss ',sum_loss 379 print 'manning ',manning 380 381 382 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 383 culvert_height, 384 culvert_width, 385 culvert_length, 386 inlet_specific_energy, 387 delta_total_energy, 388 outlet_depth, 389 sum_loss, 390 manning) 391 392 393 if verbose: 394 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d)) 395 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.5526, 1.146, 0.1339)) 396 397 assert numpy.allclose(Q, 0.5526, rtol=1.0e-1) #inflow 398 assert numpy.allclose(v, 1.146, rtol=1.0e-1) #outflow velocity 399 assert numpy.allclose(d, 0.1339, rtol=1.0e-1) #depth at outlet used to calc v 400 401 402 403 404 def test_boyd_1_operator(self): 405 """test_boyd_non_skew 406 407 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 408 calculation code by MJ Boyd 409 """ 410 411 g=9.81 412 413 414 inlet_depth=0.150 415 outlet_depth=0.150 416 inlet_velocity=1.00 417 outlet_velocity=0.5 418 419 culvert_length=10.0 420 culvert_width=3.6 421 culvert_height=1.20 422 423 culvert_type='box' 424 425 #sum_loss=1.5 426 427 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 428 culvert_slope=10.0 # % Downward 429 z_in = 10.0 430 z_out = z_in-culvert_length*culvert_slope/100 431 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 432 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 433 delta_total_energy = E_in-E_out 434 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 435 436 437 elevation_0 = z_in 438 elevation_1 = z_out 439 440 stage_0 = elevation_0 + inlet_depth 441 stage_1 = elevation_1 + outlet_depth 442 443 444 domain_length = 200.0 445 domain_width = 200.0 446 447 #culvert_length = 20.0 448 #culvert_width = 3.66 449 #culvert_height = 3.66 450 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 451 culvert_mannings = 0.013 452 453 culvert_apron = 0.0 454 enquiry_gap = 5.0 455 456 457 expected_Q = 0.55 458 expected_v = 1.15 459 expected_d = 0.13 460 461 462 domain = self._create_domain(d_length=domain_length, 463 d_width=domain_width, 464 dx = 5.0, 465 dy = 5.0, 466 elevation_0 = elevation_0, 467 elevation_1 = elevation_1, 468 stage_0 = stage_0, 469 stage_1 = stage_1, 470 xvelocity_0 = inlet_velocity, 471 xvelocity_1 = outlet_velocity) 472 473 474 #print 'Defining Structures' 475 476 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 477 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 478 479 480 culvert = Boyd_box_operator(domain, 481 losses=culvert_losses, 482 width=culvert_width, 483 end_points=[ep0, ep1], 484 height=culvert_height, 485 apron=culvert_apron, 486 enquiry_gap=enquiry_gap, 487 use_momentum_jet=False, 488 use_velocity_head=True, 489 manning=culvert_mannings, 490 logging=True, 491 label='3.6x1.2RCBC', 492 verbose=False) 493 494 #culvert.determine_inflow_outflow() 495 496 ( Q, v, d ) = culvert.discharge_routine() 497 498 if verbose: 499 print 'test_boyd_operator_1' 500 print 'expected ',expected_Q,expected_v, expected_d 501 print 'calc ',Q,v,d 502 503 504 assert numpy.allclose(Q, expected_Q, rtol=5.0e-2) #inflow 505 assert numpy.allclose(v, expected_v, rtol=5.0e-2) #outflow velocity 506 assert numpy.allclose(d, expected_d, rtol=5.0e-2) #depth at outlet used to calc v 507 508 509 510 511 def test_boyd_2(self): 512 """test_boyd_2 513 514 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 515 calculation code by MJ Boyd 516 """ 517 518 519 g=9.81 520 culvert_slope=10 # Downward 521 522 inlet_depth=0.500 523 outlet_depth=0.700 524 inlet_velocity=1.0 525 outlet_velocity=0.50 526 527 culvert_length=10.0 528 culvert_width=3.60 529 culvert_height=1.20 530 531 culvert_type='box' 532 manning=0.013 533 sum_loss=1.5 534 535 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 536 z_in = 0.0 537 z_out = z_in-culvert_length*culvert_slope/100 538 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 539 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 540 delta_total_energy = E_in-E_out 541 542 Q_expected = 2.50 543 v_expected = 1.897 544 d_expected = 0.367 545 546 if verbose: 547 print 50*'=' 548 print 'width ',culvert_width 549 print 'depth ',culvert_height 550 print 'flow_width ',culvert_width 551 print 'length ' ,culvert_length 552 print 'driving_energy ',inlet_specific_energy 553 print 'delta_total_energy ',delta_total_energy 554 print 'outlet_enquiry_depth ',outlet_depth 555 print 'sum_loss ',sum_loss 556 print 'manning ',manning 557 558 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 559 culvert_height, 560 culvert_width, 561 culvert_length, 562 inlet_specific_energy, 563 delta_total_energy, 564 outlet_depth, 565 sum_loss, 566 manning) 567 568 569 570 if verbose: 571 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST02 Q-v-d',Q,v,d)) 572 print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 2.508, 1.897, 0.367)) 573 574 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 575 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 576 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 577 578 579 def test_boyd_2_operator(self): 580 """test_boyd_non_skew 581 582 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 583 calculation code by MJ Boyd 584 """ 585 586 g=9.81 587 culvert_slope=10 # Downward 588 589 inlet_depth=0.500 590 outlet_depth=0.700 591 inlet_velocity=1.0 592 outlet_velocity=0.50 593 594 culvert_length=10.0 595 culvert_width=3.60 596 culvert_height=1.20 597 598 culvert_type='box' 599 manning=0.013 600 sum_loss=1.5 601 602 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 603 z_in = 0.0 604 z_out = z_in-culvert_length*culvert_slope/100 605 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 606 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 607 delta_total_energy = E_in-E_out 608 609 610 611 elevation_0 = z_in 612 elevation_1 = z_out 613 614 stage_0 = elevation_0 + inlet_depth 615 stage_1 = elevation_1 + outlet_depth 616 617 618 domain_length = 200.0 619 domain_width = 200.0 620 621 #culvert_length = 20.0 622 #culvert_width = 3.66 623 #culvert_height = 3.66 624 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 625 culvert_mannings = 0.013 626 627 culvert_apron = 0.0 628 enquiry_gap = 5.0 629 630 Q_expected = 2.50 631 v_expected = 1.897 632 d_expected = 0.367 633 634 635 domain = self._create_domain(d_length=domain_length, 636 d_width=domain_width, 637 dx = 5.0, 638 dy = 5.0, 639 elevation_0 = elevation_0, 640 elevation_1 = elevation_1, 641 stage_0 = stage_0, 642 stage_1 = stage_1, 643 xvelocity_0 = inlet_velocity, 644 xvelocity_1 = outlet_velocity) 645 646 647 #print 'Defining Structures' 648 649 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 650 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 651 652 653 culvert = Boyd_box_operator(domain, 654 losses=culvert_losses, 655 width=culvert_width, 656 end_points=[ep0, ep1], 657 height=culvert_height, 658 apron=culvert_apron, 659 enquiry_gap=enquiry_gap, 660 use_momentum_jet=False, 661 use_velocity_head=True, 662 manning=culvert_mannings, 663 logging=True, 664 label='3.6x1.2RCBC', 665 verbose=False) 666 667 #culvert.determine_inflow_outflow() 668 669 ( Q, v, d ) = culvert.discharge_routine() 670 671 if verbose: 672 print 'test_boyd_operator_2' 673 print 'expected ',Q_expected,v_expected, d_expected 674 print 'calc ',Q,v,d 675 676 677 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 678 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 679 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 680 681 682 683 684 685 def test_boyd_3(self): 686 """test_boyd_3 687 688 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 689 calculation code by MJ Boyd 690 """ 691 692 693 g=9.81 694 culvert_slope=10 # Downward 695 696 inlet_depth=1.800 697 outlet_depth=0.80 698 inlet_velocity=1.0 699 outlet_velocity=0.5 700 701 culvert_length=10.0 702 culvert_width=3.60 703 culvert_height=1.20 704 705 culvert_type='box' 706 manning=0.013 707 sum_loss=1.5 708 709 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 710 z_in = 0.0 711 z_out = z_in-culvert_length*culvert_slope/100 712 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 713 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 714 delta_total_energy = E_in-E_out 715 716 717 Q_expected = 13.554 718 v_expected = 3.329 719 d_expected = 1.131 720 721 if verbose: 722 print 50*'=' 723 print 'width ',culvert_width 724 print 'depth ',culvert_height 725 print 'flow_width ',culvert_width 726 print 'length ' ,culvert_length 727 print 'driving_energy ',inlet_specific_energy 728 print 'delta_total_energy ',delta_total_energy 729 print 'outlet_enquiry_depth ',outlet_depth 730 print 'sum_loss ',sum_loss 731 print 'manning ',manning 732 733 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 734 culvert_height, 735 culvert_width, 736 culvert_length, 737 inlet_specific_energy, 738 delta_total_energy, 739 outlet_depth, 740 sum_loss, 741 manning) 742 743 744 745 746 if verbose: 747 print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy)) 748 print ('%s,%.2f'%('Delta E = ',delta_total_energy)) 749 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST03 Q-v-d',Q,v,d)) 750 print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 13.554, 3.329, 1.131)) 751 752 assert numpy.allclose(Q, Q_expected, rtol=1.0e-2) #inflow 753 assert numpy.allclose(v, v_expected, rtol=1.0e-2) #outflow velocity 754 assert numpy.allclose(d, d_expected, rtol=1.0e-2) #depth at outlet used to calc v 755 756 757 def test_boyd_3_operator(self): 758 """test_boyd_non_skew 759 760 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 761 calculation code by MJ Boyd 762 """ 763 764 g=9.81 765 culvert_slope=10 # Downward 766 767 inlet_depth=1.800 768 outlet_depth=0.80 769 inlet_velocity=1.0 770 outlet_velocity=0.5 771 772 culvert_length=10.0 773 culvert_width=3.60 774 culvert_height=1.20 775 776 culvert_type='box' 777 manning=0.013 778 sum_loss=1.5 779 780 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 781 z_in = 0.0 782 z_out = z_in-culvert_length*culvert_slope/100 783 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 784 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 785 delta_total_energy = E_in-E_out 786 787 788 Q_expected = 13.554 789 v_expected = 3.329 790 d_expected = 1.131 791 792 793 794 elevation_0 = z_in 795 elevation_1 = z_out 796 797 stage_0 = elevation_0 + inlet_depth 798 stage_1 = elevation_1 + outlet_depth 799 800 801 domain_length = 200.0 802 domain_width = 200.0 803 804 #culvert_length = 20.0 805 #culvert_width = 3.66 806 #culvert_height = 3.66 807 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 808 culvert_mannings = 0.013 809 810 culvert_apron = 0.0 811 enquiry_gap = 5.0 812 813 814 815 816 domain = self._create_domain(d_length=domain_length, 817 d_width=domain_width, 818 dx = 5.0, 819 dy = 5.0, 820 elevation_0 = elevation_0, 821 elevation_1 = elevation_1, 822 stage_0 = stage_0, 823 stage_1 = stage_1, 824 xvelocity_0 = inlet_velocity, 825 xvelocity_1 = outlet_velocity) 826 827 828 #print 'Defining Structures' 829 830 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 831 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 832 833 834 culvert = Boyd_box_operator(domain, 835 losses=culvert_losses, 836 width=culvert_width, 837 end_points=[ep0, ep1], 838 height=culvert_height, 839 apron=culvert_apron, 840 enquiry_gap=enquiry_gap, 841 use_momentum_jet=False, 842 use_velocity_head=True, 843 manning=culvert_mannings, 844 logging=True, 845 label='3.6x1.2RCBC', 846 verbose=False) 847 848 #culvert.determine_inflow_outflow() 849 850 ( Q, v, d ) = culvert.discharge_routine() 851 852 if verbose: 853 print 'test_boyd_operator_1' 854 print 'expected ',Q_expected,v_expected, d_expected 855 print 'calc ',Q,v,d 856 857 858 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 859 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 860 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 861 862 863 864 865 866 867 #NOTE FROM HERE DOWN THE UNITS TEST HAVE NOT BEEN AMENDED TO ALLOW VELOCITY COMPONENT TO BE USED. ONLY ABOVE 3 TESTS WORK. PM WILL FIX THE ONES BELOW WHEN THE ABOVE 3 ARE WORKING 868 def test_boyd_4(self): 869 """test_boyd_4 870 871 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 872 calculation code by MJ Boyd 873 """ 874 # FIXME(Ole): This test fails (20 Feb 2009) 875 876 g=9.81 877 culvert_slope=10 # Downward 878 879 inlet_depth=1.00 880 outlet_depth=0.8 881 inlet_velocity=1.0 882 outlet_velocity=0.5 883 culvert_length=10.0 884 culvert_width=3.60 885 culvert_height=1.20 886 887 culvert_type='box' 888 manning=0.013 889 sum_loss=1.5 890 891 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 892 z_in = 10.0 893 z_out = 10.0-culvert_length*culvert_slope/100 894 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 895 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 896 delta_total_energy = E_in-E_out 897 898 899 900 Q_expected = 6.609 901 v_expected = 2.621 902 d_expected = 0.70 903 904 905 if verbose: 906 print 50*'=' 907 print 'width ',culvert_width 908 print 'depth ',culvert_height 909 print 'flow_width ',culvert_width 910 print 'length ' ,culvert_length 911 print 'driving_energy ',inlet_specific_energy 912 print 'delta_total_energy ',delta_total_energy 913 print 'outlet_enquiry_depth ',outlet_depth 914 print 'sum_loss ',sum_loss 915 print 'manning ',manning 916 917 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 918 culvert_height, 919 culvert_width, 920 culvert_length, 921 inlet_specific_energy, 922 delta_total_energy, 923 outlet_depth, 924 sum_loss, 925 manning) 926 927 928 if verbose: 929 print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy)) 930 print ('%s,%.2f'%('Delta E = ',delta_total_energy)) 931 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST04 Q-v-d',Q,v,d)) 932 print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 6.609, 2.621, 0.70)) 933 934 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 935 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 936 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 937 938 939 def test_boyd_4_operator(self): 940 """test_boyd_non_skew 941 942 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 943 calculation code by MJ Boyd 944 """ 945 946 g=9.81 947 culvert_slope=10 # Downward 948 949 inlet_depth=1.00 950 outlet_depth=0.8 951 inlet_velocity=1.0 952 outlet_velocity=0.5 953 culvert_length=10.0 954 culvert_width=3.60 955 culvert_height=1.20 956 957 culvert_type='box' 958 manning=0.013 959 sum_loss=1.5 960 961 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 962 z_in = 10.0 963 z_out = 10.0-culvert_length*culvert_slope/100 964 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 965 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 966 delta_total_energy = E_in-E_out 967 968 969 970 Q_expected = 6.609 971 v_expected = 2.621 972 d_expected = 0.70 973 974 975 976 elevation_0 = z_in 977 elevation_1 = z_out 978 979 stage_0 = elevation_0 + inlet_depth 980 stage_1 = elevation_1 + outlet_depth 981 982 983 domain_length = 200.0 984 domain_width = 200.0 985 986 #culvert_length = 20.0 987 #culvert_width = 3.66 988 #culvert_height = 3.66 989 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 990 culvert_mannings = 0.013 991 992 culvert_apron = 0.0 993 enquiry_gap = 5.0 994 995 996 997 998 domain = self._create_domain(d_length=domain_length, 999 d_width=domain_width, 1000 dx = 5.0, 1001 dy = 5.0, 1002 elevation_0 = elevation_0, 1003 elevation_1 = elevation_1, 1004 stage_0 = stage_0, 1005 stage_1 = stage_1, 1006 xvelocity_0 = inlet_velocity, 1007 xvelocity_1 = outlet_velocity) 1008 1009 1010 #print 'Defining Structures' 1011 1012 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 1013 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 1014 1015 1016 culvert = Boyd_box_operator(domain, 1017 losses=culvert_losses, 1018 width=culvert_width, 1019 end_points=[ep0, ep1], 1020 height=culvert_height, 1021 apron=culvert_apron, 1022 enquiry_gap=enquiry_gap, 1023 use_momentum_jet=False, 1024 use_velocity_head=True, 1025 manning=culvert_mannings, 1026 logging=True, 1027 label='3.6x1.2RCBC', 1028 verbose=False) 1029 1030 #culvert.determine_inflow_outflow() 1031 1032 ( Q, v, d ) = culvert.discharge_routine() 1033 1034 if verbose: 1035 print 'test_boyd_operator_1' 1036 print 'expected ',Q_expected,v_expected, d_expected 1037 print 'calc ',Q,v,d 1038 1039 1040 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1041 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1042 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1043 1044 def test_boyd_5(self): 1045 """test_boyd_5 1046 1047 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1048 calculation code by MJ Boyd 1049 """ 1050 # FIXME(Ole): This test fails (20 Feb 2009) 1051 1052 g=9.81 1053 culvert_slope=10 # Downward 1054 1055 inlet_depth=1.50 1056 inlet_velocity= 1.0 1057 outlet_depth=2.5 1058 outlet_velocity=0.5 1059 culvert_length=10.0 1060 culvert_width=3.60 1061 culvert_height=1.20 1062 1063 culvert_type='box' 1064 manning=0.013 1065 sum_loss=1.5 1066 1067 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1068 z_in = 10.0 1069 z_out = 10.0-culvert_length*culvert_slope/100 1070 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1071 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1072 delta_total_energy = E_in-E_out 1073 1074 Q_expected = 2.961 1075 v_expected = 0.685 1076 d_expected = 1.20 1077 1078 if verbose: 1079 print 50*'=' 1080 print 'width ',culvert_width 1081 print 'depth ',culvert_height 1082 print 'flow_width ',culvert_width 1083 print 'length ' ,culvert_length 1084 print 'driving_energy ',inlet_specific_energy 1085 print 'delta_total_energy ',delta_total_energy 1086 print 'outlet_enquiry_depth ',outlet_depth 1087 print 'sum_loss ',sum_loss 1088 print 'manning ',manning 1089 1090 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 1091 culvert_height, 1092 culvert_width, 1093 culvert_length, 1094 inlet_specific_energy, 1095 delta_total_energy, 1096 outlet_depth, 1097 sum_loss, 1098 manning) 1099 1100 1101 1102 if verbose: 1103 print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy)) 1104 print ('%s,%.3f'%('Delta E = ',delta_total_energy)) 1105 1106 print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST05 Q-v-d',Q,v,d)) 1107 print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',2.961, 0.685, 1.20)) 1108 1109 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1110 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1111 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1112 1113 1114 1115 1116 def test_boyd_5_operator(self): 1117 """test_boyd_non_skew 1118 1119 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1120 calculation code by MJ Boyd 1121 """ 1122 1123 1124 g=9.81 1125 culvert_slope=10 # Downward 1126 1127 inlet_depth=1.50 1128 inlet_velocity= 1.0 1129 outlet_depth=2.5 1130 outlet_velocity=0.5 1131 culvert_length=10.0 1132 culvert_width=3.60 1133 culvert_height=1.20 1134 1135 culvert_type='box' 1136 manning=0.013 1137 sum_loss=1.5 1138 1139 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1140 z_in = 10.0 1141 z_out = 10.0-culvert_length*culvert_slope/100 1142 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1143 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1144 delta_total_energy = E_in-E_out 1145 1146 Q_expected = 2.961 1147 v_expected = 0.685 1148 d_expected = 1.20 1149 1150 1151 1152 elevation_0 = z_in 1153 elevation_1 = z_out 1154 1155 stage_0 = elevation_0 + inlet_depth 1156 stage_1 = elevation_1 + outlet_depth 1157 1158 1159 domain_length = 200.0 1160 domain_width = 200.0 1161 1162 #culvert_length = 20.0 1163 #culvert_width = 3.66 1164 #culvert_height = 3.66 1165 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 1166 culvert_mannings = 0.013 1167 1168 culvert_apron = 0.0 1169 enquiry_gap = 5.0 1170 1171 1172 1173 1174 domain = self._create_domain(d_length=domain_length, 1175 d_width=domain_width, 1176 dx = 5.0, 1177 dy = 5.0, 1178 elevation_0 = elevation_0, 1179 elevation_1 = elevation_1, 1180 stage_0 = stage_0, 1181 stage_1 = stage_1, 1182 xvelocity_0 = inlet_velocity, 1183 xvelocity_1 = outlet_velocity) 1184 1185 1186 #print 'Defining Structures' 1187 1188 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 1189 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 1190 1191 1192 culvert = Boyd_box_operator(domain, 1193 losses=culvert_losses, 1194 width=culvert_width, 1195 end_points=[ep0, ep1], 1196 height=culvert_height, 1197 apron=culvert_apron, 1198 enquiry_gap=enquiry_gap, 1199 use_momentum_jet=False, 1200 use_velocity_head=True, 1201 manning=culvert_mannings, 1202 logging=True, 1203 label='3.6x1.2RCBC', 1204 verbose=False) 1205 1206 #culvert.determine_inflow_outflow() 1207 1208 ( Q, v, d ) = culvert.discharge_routine() 1209 1210 if verbose: 1211 print 'test_boyd_operator_1' 1212 print 'expected ',Q_expected,v_expected, d_expected 1213 print 'calc ',Q,v,d 1214 1215 1216 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1217 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1218 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1219 1220 1221 def test_boyd_6(self): 1222 """test_boyd_6 1223 1224 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1225 calculation code by MJ Boyd 1226 """ 1227 # FIXME(Ole): This test fails (20 Feb 2009) 1228 1229 g=9.81 1230 culvert_slope=10 # Downward 1231 1232 inlet_depth=1.50 1233 inlet_velocity= 4.0 1234 outlet_depth=0.80 1235 outlet_velocity=4.0 1236 culvert_length=10.0 1237 culvert_width=3.60 1238 culvert_height=1.20 1239 1240 culvert_type='box' 1241 manning=0.013 1242 sum_loss=1.5 1243 1244 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1245 z_in = 10.0 1246 z_out = 10.0-culvert_length*culvert_slope/100 1247 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1248 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1249 delta_total_energy = E_in-E_out 1250 1251 Q_expected = 15.537 1252 v_expected = 3.597 1253 d_expected = 1.20 1254 1255 if verbose: 1256 print 50*'=' 1257 print 'width ',culvert_width 1258 print 'depth ',culvert_height 1259 print 'flow_width ',culvert_width 1260 print 'length ' ,culvert_length 1261 print 'driving_energy ',inlet_specific_energy 1262 print 'delta_total_energy ',delta_total_energy 1263 print 'outlet_enquiry_depth ',outlet_depth 1264 print 'sum_loss ',sum_loss 1265 print 'manning ',manning 1266 1267 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 1268 culvert_height, 1269 culvert_width, 1270 culvert_length, 1271 inlet_specific_energy, 1272 delta_total_energy, 1273 outlet_depth, 1274 sum_loss, 1275 manning) 1276 1277 1278 1279 1280 if verbose: 1281 print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy)) 1282 print ('%s,%.3f'%('Delta E = ',delta_total_energy)) 1283 1284 print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d)) 1285 print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',15.537, 3.597, 1.20)) 1286 1287 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1288 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1289 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1290 1291 1292 def test_boyd_6_operator(self): 1293 """test_boyd_non_skew 1294 1295 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1296 calculation code by MJ Boyd 1297 """ 1298 1299 g=9.81 1300 culvert_slope=10 # Downward 1301 1302 inlet_depth=1.50 1303 inlet_velocity= 4.0 1304 outlet_depth=0.80 1305 outlet_velocity=4.0 1306 culvert_length=10.0 1307 culvert_width=3.60 1308 culvert_height=1.20 1309 1310 culvert_type='box' 1311 manning=0.013 1312 sum_loss=1.5 1313 1314 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1315 z_in = 10.0 1316 z_out = 10.0-culvert_length*culvert_slope/100 1317 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1318 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1319 delta_total_energy = E_in-E_out 1320 1321 Q_expected = 15.537 1322 v_expected = 3.597 1323 d_expected = 1.20 1324 1325 1326 1327 elevation_0 = z_in 1328 elevation_1 = z_out 1329 1330 stage_0 = elevation_0 + inlet_depth 1331 stage_1 = elevation_1 + outlet_depth 1332 1333 1334 domain_length = 200.0 1335 domain_width = 200.0 1336 1337 #culvert_length = 20.0 1338 #culvert_width = 3.66 1339 #culvert_height = 3.66 1340 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 1341 culvert_mannings = 0.013 1342 1343 culvert_apron = 0.0 1344 enquiry_gap = 5.0 1345 1346 1347 1348 1349 domain = self._create_domain(d_length=domain_length, 1350 d_width=domain_width, 1351 dx = 5.0, 1352 dy = 5.0, 1353 elevation_0 = elevation_0, 1354 elevation_1 = elevation_1, 1355 stage_0 = stage_0, 1356 stage_1 = stage_1, 1357 xvelocity_0 = inlet_velocity, 1358 xvelocity_1 = outlet_velocity) 1359 1360 1361 #print 'Defining Structures' 1362 1363 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 1364 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 1365 1366 1367 culvert = Boyd_box_operator(domain, 1368 losses=culvert_losses, 1369 width=culvert_width, 1370 end_points=[ep0, ep1], 1371 height=culvert_height, 1372 apron=culvert_apron, 1373 enquiry_gap=enquiry_gap, 1374 use_momentum_jet=False, 1375 use_velocity_head=True, 1376 manning=culvert_mannings, 1377 logging=True, 1378 label='3.6x1.2RCBC', 1379 verbose=False) 1380 1381 #culvert.determine_inflow_outflow() 1382 1383 ( Q, v, d ) = culvert.discharge_routine() 1384 1385 if verbose: 1386 print 'test_boyd_operator_1' 1387 print 'expected ',Q_expected,v_expected, d_expected 1388 print 'calc ',Q,v,d 1389 1390 1391 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1392 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1393 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1394 1395 1396 299 1397 # ========================================================================= 300 1398 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.