Changeset 3362


Ignore:
Timestamp:
Jul 18, 2006, 9:39:13 PM (18 years ago)
Author:
jakeman
Message:

New files dam2.py and dry_dam.py further test numerical solution
against analytical solution of
Stoker 57. Limiting is still not working correctly.

Location:
development/pyvolution-1d
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • development/pyvolution-1d/dam.py

    r3335 r3362  
     1
    12import os
    23from math import sqrt, pi
     
    8485
    8586def stage(x):
    86     y = zeros(len(x))
     87    y = zeros(len(x),Float)
    8788    for i in range(len(x)):
    8889        if x[i]<=1000.0:
     
    123124        StageQ = domain.quantities['stage'].vertex_values
    124125        y = analytical_sol(X.flat,domain.time)
    125         #linePlot(plot1,X,StageQ,X,y)
     126        linePlot(plot1,X,StageQ,X,y)
    126127    #raw_input('press_return')
    127128    #pass
  • development/pyvolution-1d/quantity.py

    r3335 r3362  
    513513        """
    514514
     515        Z = self.gradients
     516        #print "gradients 1",Z
     517       
    515518        self.compute_gradients()
     519        #print "gradients 2", Z
    516520
    517521        G = self.gradients
     
    527531            #vertex coordinates
    528532            x0, x1 = V[k,:]
     533
    529534            #Extrapolate
    530535            Qv[k,0] = Qc[k] + G[k]*(x0-x)
    531536            Qv[k,1] = Qc[k] + G[k]*(x1-x)
    532537
    533     def limit(self):
    534         """Limit slopes for each volume to eliminate artificial variance
     538    """    def limit(self):
     539        Limit slopes for each volume to eliminate artificial variance
    535540        introduced by e.g. second order extrapolator
    536541
     
    542547        postcondition:
    543548        vertex values are updated
    544         """
     549       
    545550        print "in Q.limit"
    546551        from Numeric import zeros, Float
     
    591596            for i in range(2):
    592597                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       
    594662
    595663def newLinePlot(title='Simple Plot'):
  • development/pyvolution-1d/shallow_water_1d.py

    r3335 r3362  
    1 """Class Domain -
     1u"""Class Domain -
    221D interval domains for finite-volume computations of
    33the shallow water wave equation.
     
    165165        #self.check_integrity()
    166166
    167         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
     167        #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
    171171
    172172
     
    605605
    606606    #Remove very thin layers of water
    607     #protect_against_infinitesimal_and_negative_heights(domain)
     607    protect_against_infinitesimal_and_negative_heights(domain)
    608608
    609609    #Extrapolate all conserved quantities
     
    634634
    635635    #Take bed elevation into account when water heights are small
    636     #balance_deep_and_shallow(domain)
     636    balance_deep_and_shallow(domain)
    637637
    638638    #Compute edge values by interpolation
     
    662662
    663663            #Control momentum
    664 #            xmomc[k] = ymomc[k] = 0.0
     664            #xmomc[k] = ymomc[k] = 0.0
    665665            xmomc[k] = 0.0
    666666
Note: See TracChangeset for help on using the changeset viewer.