Changeset 3510 for development/pyvolution-1d/quantity.py
- Timestamp:
- Aug 21, 2006, 10:03:42 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
development/pyvolution-1d/quantity.py
r3425 r3510 51 51 #self.edge_values = zeros((N, 2), Float) 52 52 #edge values are values of the ends of each interval 53 54 #does oe dimension need edge values??? 55 53 56 54 #Intialise centroid values 57 55 self.interpolate() … … 414 412 self.centroid_values += timestep*self.explicit_update 415 413 414 #SECOND ORDER RUNGE_KUTTA 415 #Re-evaluate source term with updated centroid values 416 #and update conserved quantities accordingly 417 """ 418 self.explicit_update = zeros(N, Float) 419 self.domain.compute_forcing_terms() 420 self.centroid_values += 0.5*timestep*(explicit_update 421 """ 422 416 423 ## #Semi implicit updates 417 424 ## denominator = ones(N, Float)-timestep*self.semi_implicit_update … … 679 686 """ 680 687 681 def limit(self):682 """Limit slopes for each volume to eliminate artificial variance688 """def limit(self): 689 Limit slopes for each volume to eliminate artificial variance 683 690 introduced by e.g. second order extrapolator 684 691 … … 690 697 postcondition: 691 698 vertex values are updated 692 """ 693 699 694 700 from Numeric import zeros, Float 695 701 696 702 N = self.domain.number_of_elements 697 #beta = self.beta698 beta = 0.8703 beta = self.beta 704 #beta = 0.8 699 705 700 706 qc = self.centroid_values … … 741 747 qv[k,i] = qc[k] + phi*dq[k,i] 742 748 743 744 749 """ 750 751 752 def limit(self): 753 """Limit slopes for each volume to eliminate artificial variance 754 introduced by e.g. second order extrapolator 755 756 This is an unsophisticated limiter as it does not take into 757 account dependencies among quantities. 758 759 precondition: 760 vertex values are estimated from gradient 761 postcondition: 762 vertex values are updated 763 764 """ 765 import sys 766 from Numeric import zeros, Float 767 from util import minmod, minmod_kurganov, maxmod, vanleer 768 769 N = self.domain.number_of_elements 770 limiter = self.domain.limiter 771 limiter_type = self.domain.limiter_type 772 773 qc = self.centroid_values 774 qv = self.vertex_values 775 776 #Find min and max of this and neighbour's centroid values 777 beta_p = zeros(N,Float) 778 beta_m = zeros(N,Float) 779 beta_x = zeros(N,Float) 780 C = self.domain.centroids 781 X = self.domain.vertices 782 783 for k in range(N): 784 785 n0 = self.domain.neighbours[k,0] 786 n1 = self.domain.neighbours[k,1] 787 if limiter_type == "slope": 788 if ( n0 >= 0) & (n1 >= 0): 789 #SLOPE DERIVATIVE LIMIT 790 beta_p[k] = (qc[k]-qc[k-1])/(C[k]-C[k-1]) 791 beta_m[k] = (qc[k+1]-qc[k])/(C[k+1]-C[k]) 792 beta_x[k] = (qc[k+1]-qc[k-1])/(C[k+1]-C[k-1]) 793 elif limiter_type == "flux": 794 if (n0 >= 0) & (n1 >= 0): 795 # Check denominator not zero 796 if (qc[k+1]-qc[k]) == 0.0: 797 beta_p[k] = float(sys.maxint) 798 beta_m[k] = float(sys.maxint) 799 else: 800 #STEVE LIMIT 801 beta_p[k] = (qc[k]-qc[k-1])/(qc[k+1]-qc[k]) 802 beta_m[k] = (qc[k+2]-qc[k+1])/(qc[k+1]-qc[k]) 803 804 #Deltas between vertex and centroid values 805 dq = zeros(qv.shape, Float) 806 for i in range(2): 807 dq[:,i] =self.domain.vertices[:,i]-self.domain.centroids 808 809 #Phi limiter 810 for k in range(N): 811 if limiter_type == "slope": 812 if limiter == "minmod": 813 phi = minmod(beta_p[k],beta_m[k]) 814 815 elif limiter == "minmod_kurganov": 816 # Also known as monotonized central difference limiter 817 # if theta = 2.0 818 theta = 2.0 819 phi = minmod_kurganov(theta*beta_p[k],theta*beta_m[k],beta_x[k]) 820 elif limiter == "superbee": 821 slope1 = minmod(beta_m[k],2.0*beta_p[k]) 822 slope2 = minmod(2.0*beta_m[k],beta_p[k]) 823 phi = maxmod(slope1,slope2) 824 #phi = max(0.0,min(1.0,2.0*beta_m[k]),min(2.0,beta_m[k]))+max(0.0,min(1.0,2.0*beta_p[k]),min(2.0,beta_p[k]))-1.0 825 826 elif limiter == "vanleer": 827 phi = vanleer(beta_p[k],beta_m[k]) 828 829 830 elif limiter == "muscl": 831 832 #MINMOD 833 #phi = minmod(1.0,beta_m[k]) 834 #SUPERBEE 835 #phi = max(0.0,min(2.0*beta_m[k],1.0),min(beta_m[k],2.0)) 836 #VAN LEER 837 phi = (beta_m[k]+abs(beta_m[k]))/(1.0+abs(beta_m[k])) 838 839 for i in range(2): 840 qv[k,i] = qc[k] + phi*dq[k,i] 841 842 elif limiter_type == "flux": 843 phi = 0.0 844 if limiter == "flux_minmod": 845 #FLUX MINMOD 846 phi = minmod_kurganov(1.0,beta_m[k],beta_p[k]) 847 elif limiter == "flux_superbee": 848 #FLUX SUPERBEE 849 phi = max(0.0,min(1.0,2.0*beta_m[k]),min(2.0,beta_m[k]))+max(0.0,min(1.0,2.0*beta_p[k]),min(2.0,beta_p[k]))-1.0 850 elif limiter == "flux_muscl": 851 #FLUX MUSCL 852 phi = max(0.0,min(2.0,2.0*beta_m[k],2.0*beta_p[k],0.5*(beta_m[k]+beta_p[k]))) 853 elif limiter == "flux_vanleer": 854 #FLUX VAN LEER 855 phi = (beta_m[k]+abs(beta_m[k]))/(1.0+abs(beta_m[k]))+(beta_p[k]+abs(beta_p[k]))/(1.0+abs(beta_p[k]))-1.0 856 857 #Then update using phi limiter 858 n = self.domain.neighbours[k,1] 859 if n>=0: 860 #qv[k,0] = qc[k] - 0.5*phi*(qc[k+1]-qc[k]) 861 #qv[k,1] = qc[k] + 0.5*phi*(qc[k+1]-qc[k]) 862 qv[k,0] = qc[k] + 0.5*phi*(qv[k,0]-qc[k]) 863 qv[k,1] = qc[k] + 0.5*phi*(qv[k,1]-qc[k]) 864 else: 865 qv[k,i] = qc[k] 866 867 745 868 def newLinePlot(title='Simple Plot'): 746 869 import Gnuplot
Note: See TracChangeset
for help on using the changeset viewer.