Changeset 3362
- Timestamp:
- Jul 18, 2006, 9:39:13 PM (18 years ago)
- Location:
- development/pyvolution-1d
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
development/pyvolution-1d/dam.py
r3335 r3362 1 1 2 import os 2 3 from math import sqrt, pi … … 84 85 85 86 def stage(x): 86 y = zeros(len(x) )87 y = zeros(len(x),Float) 87 88 for i in range(len(x)): 88 89 if x[i]<=1000.0: … … 123 124 StageQ = domain.quantities['stage'].vertex_values 124 125 y = analytical_sol(X.flat,domain.time) 125 #linePlot(plot1,X,StageQ,X,y)126 linePlot(plot1,X,StageQ,X,y) 126 127 #raw_input('press_return') 127 128 #pass -
development/pyvolution-1d/quantity.py
r3335 r3362 513 513 """ 514 514 515 Z = self.gradients 516 #print "gradients 1",Z 517 515 518 self.compute_gradients() 519 #print "gradients 2", Z 516 520 517 521 G = self.gradients … … 527 531 #vertex coordinates 528 532 x0, x1 = V[k,:] 533 529 534 #Extrapolate 530 535 Qv[k,0] = Qc[k] + G[k]*(x0-x) 531 536 Qv[k,1] = Qc[k] + G[k]*(x1-x) 532 537 533 def limit(self):534 """Limit slopes for each volume to eliminate artificial variance538 """ def limit(self): 539 Limit slopes for each volume to eliminate artificial variance 535 540 introduced by e.g. second order extrapolator 536 541 … … 542 547 postcondition: 543 548 vertex values are updated 544 """549 545 550 print "in Q.limit" 546 551 from Numeric import zeros, Float … … 591 596 for i in range(2): 592 597 qv[k,i] = qc[k] + phi*dq[i] 593 598 """ 599 600 def limit(self): 601 """Limit slopes for each volume to eliminate artificial variance 602 introduced by e.g. second order extrapolator 603 604 This is an unsophisticated limiter as it does not take into 605 account dependencies among quantities. 606 607 precondition: 608 vertex values are estimated from gradient 609 postcondition: 610 vertex values are updated 611 """ 612 613 from Numeric import zeros, Float 614 615 N = self.domain.number_of_elements 616 beta = self.beta 617 618 qc = self.centroid_values 619 qv = self.vertex_values 620 621 #Find min and max of this and neighbour's centroid values 622 qmax = self.qmax 623 qmin = self.qmin 624 625 for k in range(N): 626 qmax[k] = qmin[k] = qc[k] 627 for i in range(2): 628 n = self.domain.neighbours[k,i] 629 if n >= 0: 630 qn = qc[n] #Neighbour's centroid value 631 632 qmin[k] = min(qmin[k], qn) 633 qmax[k] = max(qmax[k], qn) 634 635 636 #Diffences between centroids and maxima/minima 637 dqmax = qmax - qc 638 dqmin = qmin - qc 639 640 #Deltas between vertex and centroid values 641 dq = zeros(qv.shape, Float) 642 for i in range(2): 643 dq[:,i] = qv[:,i] - qc 644 645 #Phi limiter 646 for k in range(N): 647 648 #Find the gradient limiter (phi) across vertices 649 phi = 1.0 650 for i in range(2): 651 r = 1.0 652 if (dq[k,i] > 0): r = dqmax[k]/dq[k,i] 653 if (dq[k,i] < 0): r = dqmin[k]/dq[k,i] 654 655 phi = min( min(r*beta, 1), phi ) 656 657 #Then update using phi limiter 658 for i in range(2): 659 qv[k,i] = qc[k] + phi*dq[k,i] 660 661 594 662 595 663 def newLinePlot(title='Simple Plot'): -
development/pyvolution-1d/shallow_water_1d.py
r3335 r3362 1 """Class Domain -1 u"""Class Domain - 2 2 1D interval domains for finite-volume computations of 3 3 the shallow water wave equation. … … 165 165 #self.check_integrity() 166 166 167 msg = 'Parameter beta_h must be in the interval [0, 1)'168 assert 0 <= self.beta_h < 1.0, msg169 msg = 'Parameter beta_w must be in the interval [0, 1)'170 assert 0 <= self.beta_w < 1.0, msg167 #msg = 'Parameter beta_h must be in the interval [0, 1)' 168 #assert 0 <= self.beta_h < 1.0, msg 169 #msg = 'Parameter beta_w must be in the interval [0, 1)' 170 #assert 0 <= self.beta_w < 1.0, msg 171 171 172 172 … … 605 605 606 606 #Remove very thin layers of water 607 #protect_against_infinitesimal_and_negative_heights(domain)607 protect_against_infinitesimal_and_negative_heights(domain) 608 608 609 609 #Extrapolate all conserved quantities … … 634 634 635 635 #Take bed elevation into account when water heights are small 636 #balance_deep_and_shallow(domain)636 balance_deep_and_shallow(domain) 637 637 638 638 #Compute edge values by interpolation … … 662 662 663 663 #Control momentum 664 #xmomc[k] = ymomc[k] = 0.0664 #xmomc[k] = ymomc[k] = 0.0 665 665 xmomc[k] = 0.0 666 666
Note: See TracChangeset
for help on using the changeset viewer.