Ignore:
Timestamp:
Oct 27, 2011, 8:23:34 PM (14 years ago)
Author:
steve
Message:

Got the ctac figures working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/2010-projects/anuga_1d/channel/var_width_depth.py

    r7884 r8241  
    11import os
    22import random
    3 from math import sqrt, pow, pi 
    4 from channel_domain_Ab import *
    5 from Numeric import allclose, array, zeros, ones, Float, take, sqrt
    6 from config import g, epsilon
     3from math import sqrt, pow, pi
     4from channel_domain import *
     5from numpy import allclose, array, zeros, ones, take, sqrt
     6from anuga_1d.config import g, epsilon
    77
     8
     9random.seed(111)
    810
    911print "Variable Width Only Test"
     
    1113# Define functions for initial quantities
    1214def initial_area(x):
    13     y = zeros(len(x),Float)
     15    y = zeros(len(x),'f')
    1416    for i in range(len(x)):
    1517        y[i]=(10-randomarray[i])
     
    2022def width(x):
    2123
    22     y = zeros(len(x),Float)
     24    y = zeros(len(x),'f')
    2325    for i in range(len(x)):
    2426        y[i]=randomarray[i]
     
    2830def bed(x):
    2931
    30     y = zeros(len(x),Float)
     32    y = zeros(len(x),'f')
    3133    for i in range(len(x)):
    3234        y[i]=randomarray2[i]
     
    3840def stage(x):
    3941
    40     y = zeros(len(x),Float)
     42    y = zeros(len(x),'f')
    4143    for i in range(len(x)):
    4244        if x[i]<200 and x[i]>150:
     
    6466print "Evaluating domain with %d cells" %N
    6567cell_len = L/N # Origin = 0.0
    66 points = zeros(N+1,Float)
     68points = zeros(N+1,'f')
    6769
    6870# Define the centroid points
     
    7476
    7577# Define random array for width
    76 randomarray=zeros(len(points),Float)
     78randomarray=zeros(len(points),'f')
    7779for j in range(N+1):
    7880    randomarray[j]=random.normalvariate(3,1)
    79 randomarray2=zeros(len(points),Float)
     81randomarray2=zeros(len(points),'f')
    8082for j in range(N+1):
    8183    randomarray2[j]=random.normalvariate(3,1)
     
    98100t0 = time.time()
    99101
    100 print domain.quantities['elevation'].vertex_values
     102
     103AreaC = domain.quantities['area'].centroid_values
     104BedC = domain.quantities['elevation'].centroid_values
     105WidthC = domain.quantities['width'].centroid_values
     106#
     107AreaC[:] = (10.0 - BedC)* WidthC
     108
     109
     110#print domain.quantities['elevation'].vertex_values
     111
     112finaltime = 100.0
     113yieldstep = 1.0
     114
     115domain.initialize_plotting(stage_lim = [-1.0, 20.0],
     116                           width_lim = [0.0, 6.0],
     117                           velocity_lim = [-1.0, 1.0])
     118
    101119
    102120for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    103121    domain.write_time()
    104122
    105 print domain.quantities['elevation'].vertex_values
     123    domain.update_plotting()
    106124
    107 N = float(N)
    108 HeightC = domain.quantities['height'].centroid_values
    109 DischargeC = domain.quantities['discharge'].centroid_values
    110 C = domain.centroids
    111 print 'That took %.2f seconds' %(time.time()-t0)
    112 X = domain.vertices
    113 HeightQ = domain.quantities['height'].vertex_values
    114 VelocityQ = domain.quantities['velocity'].vertex_values
    115 x = X.flat
    116 z = domain.quantities['elevation'].vertex_values.flat
    117 b = domain.quantities['width'].vertex_values.flat
    118 stage=HeightQ.flat+z
     125#print domain.quantities['elevation'].vertex_values
    119126
     127domain.hold_plotting()
    120128
    121 
    122 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot
    123 
    124 #hold(False)
    125    
    126 plot1=subplot(211)
    127 
    128 plot(x,stage,x,z,x,b)
    129  
    130 plot1.set_ylim([-5,15])
    131 xlabel('Position')
    132 ylabel('Stage')
    133 legend(('Solution', 'Bed','Width'),
    134             'upper right', shadow=True)
    135 
    136 plot2=subplot(212)
    137 plot(x,VelocityQ.flat)
    138 plot2.set_ylim([-10,10])
    139 xlabel('Position')
    140 ylabel('Velocity')
    141    
    142 show()
    143 
Note: See TracChangeset for help on using the changeset viewer.