Ignore:
Timestamp:
Oct 26, 2011, 6:32:44 PM (14 years ago)
Author:
steve
Message:

Padarn's code

File:
1 edited

Legend:

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

    r8234 r8240  
    144144
    145145    def update_derived_quantites(self):
     146
    146147        pass
     148
     149
     150
     151    def initialize_plotting(self,
     152                            stage_lim = [-1.0, 40.0],
     153                            height_lim = [-1.0, 10.0],
     154                            velocity_lim = [-5.0, 5.0]):
     155
     156        import pylab
     157        pylab.ion()
     158
     159
     160        x = self.get_vertices().flatten()
     161        z = self.quantities['elevation'].vertex_values.flatten()
     162        w = self.quantities['stage'].vertex_values.flatten()
     163        h = self.quantities['height'].vertex_values.flatten()
     164        v = self.quantities['velocity'].vertex_values.flatten()
     165
     166        print x.shape
     167        print z.shape
     168
     169        self.plot1 = pylab.subplot(311)
     170
     171        self.zplot, = pylab.plot(x, z)
     172        self.wplot, = pylab.plot(x, w)
     173
     174        self.plot1.set_ylim(stage_lim)
     175        pylab.xlabel('Position')
     176        pylab.ylabel('Stage')
     177
     178        self.plot2 = pylab.subplot(312)
     179
     180        self.hplot, = pylab.plot(x, h)
     181
     182        self.plot2.set_ylim(height_lim)
     183        pylab.xlabel('Position')
     184        pylab.ylabel('Height')
     185
     186        self.plot3 = pylab.subplot(313)
     187
     188        self.vplot, = pylab.plot(x, v)
     189
     190        self.plot3.set_ylim(velocity_lim)
     191
     192        pylab.xlabel('Position')
     193        pylab.ylabel('Velocity')
     194
     195
     196    def update_plotting(self):
     197
     198        import pylab
     199
     200        #x = self.get_vertices().flatten()
     201        z = self.quantities['elevation'].vertex_values.flatten()
     202        w = self.quantities['stage'].vertex_values.flatten()
     203        h = self.quantities['height'].vertex_values.flatten()
     204        v = self.quantities['velocity'].vertex_values.flatten()
     205
     206
     207        self.zplot.set_ydata(z)
     208        self.wplot.set_ydata(w)
     209        self.hplot.set_ydata(h)
     210        self.vplot.set_ydata(v)
     211
     212        pylab.draw()
     213
     214
     215    def hold_plotting(self):
     216
     217        self.update_plotting()
     218        import pylab
     219       
     220        pylab.ioff()
     221
     222        pylab.show()
     223
     224
     225
     226    def finalize_plotting(self):
     227
     228        pass
     229
     230
    147231
    148232#=============== End of Channel Domain ===============================
     
    198282    # (i.e. bed and width) have been accurately computed in the previous
    199283    # timestep.
    200     h_C[:] = numpy.where(a_C > 0.0, a_C/(b_C + h0/b_C), 0.0)
    201     u_C[:] = numpy.where(a_C > 0.0, d_C/(a_C + h0/a_C), 0.0)
     284    h_C[:] = numpy.where(a_C > 0.0, a_C/b_C, 0.0)
     285    u_C[:] = numpy.where(a_C > 0.0, d_C/a_C, 0.0)
    202286
    203287    w_C[:] = h_C + z_C
Note: See TracChangeset for help on using the changeset viewer.