Changeset 4302


Ignore:
Timestamp:
Mar 13, 2007, 10:26:45 AM (17 years ago)
Author:
duncan
Message:

starting to test momentum

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4301 r4302  
    40164016        """
    40174017        self.quantity_name = quantity_name
    4018         quantity_units= {'HA':'METERS',
    4019                               'UA':'METERS/SECOND',
    4020                               'VA':'METERS/SECOND'}
     4018        quantity_units= {'HA':'CENTIMETERS',
     4019                              'UA':'CENTIMETERS/SECOND',
     4020                              'VA':'CENTIMETERS/SECOND'}
    40214021       
    40224022        #self.file_name = file_name
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4296 r4302  
    47394739        return base_name, files
    47404740   
    4741     def write_mux(self,lat_long_points, time_step_count, time_step):
     4741    def write_mux(self,lat_long_points, time_step_count, time_step,
     4742                  depth=None, ha=None, ua=None, va=None
     4743                  ):
    47424744        """
    47434745        This will write 3 non-gridded mux files, for testing.
    4744         The na and va quantities will be the Easting values.
    4745         Depth and ua will be the Northing value.
     4746        If no quantities are passed in,
     4747        na and va quantities will be the Easting values.
     4748        Depth and ua will be the Northing value.
    47464749        """
    47474750        #print "lat_long_points", lat_long_points
     
    47594762            lon = point[1]
    47604763            _ , e, n = redfearn(lat, lon)
    4761             lonlatdeps.append([lon, lat, n])
    4762             quantities_init[0].append(e) # HA
    4763             quantities_init[1].append(n ) # UA
    4764             quantities_init[2].append(e) # VA
     4764            if depth is None:
     4765                this_depth = n
     4766            else:
     4767                this_depth = depth
     4768            if ha is None:
     4769                this_ha = e
     4770            else:
     4771                this_ha = ha
     4772            if ua is None:
     4773                this_ua = n
     4774            else:
     4775                this_ua = ua
     4776            if va is None:
     4777                this_va = e   
     4778            else:
     4779                this_va = va         
     4780            lonlatdeps.append([lon, lat, this_depth])
     4781            quantities_init[0].append(this_ha) # HA
     4782            quantities_init[1].append(this_ua) # UA
     4783            quantities_init[2].append(this_va) # VA
    47654784               
    47664785        file_handle, base_name = tempfile.mkstemp("")
     
    49054924        # the elevation
    49064925        assert allclose(-elevation, y)  #Meters
     4926       
     4927        fid.close()
     4928        self.delete_mux(files)
     4929        os.remove(sww_file)
     4930       
     4931    def test_urs2sww_momentum(self):
     4932        tide = 1
     4933        time_step_count = 3
     4934        time_step = 2
     4935        #lat_long_points =[(-21.5,114.5),(-21.5,115),(-21.,114.5), (-21.,115.)]
     4936        # This is gridded
     4937        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
     4938        depth=20
     4939        ha=2
     4940        ua=5
     4941        va=5
     4942        base_name, files = self.write_mux(lat_long_points,
     4943                                          time_step_count, time_step,
     4944                                          depth=depth,
     4945                                          ha=ha,
     4946                                          ua=ua,
     4947                                          va=va)
     4948        # write_mux(self,lat_long_points, time_step_count, time_step,
     4949        #          depth=None, ha=None, ua=None, va=None
     4950        urs2sww(base_name
     4951                #, origin=(0,0,0)
     4952                , mean_stage=tide
     4953                , remove_nc_files=True
     4954                )
     4955        sww_file = base_name + '.sww'
     4956       
     4957        #Let's interigate the sww file
     4958        # Note, the sww info is not gridded.  It is point data.
     4959        fid = NetCDFFile(sww_file)
     4960
     4961        x = fid.variables['x'][:]
     4962        y = fid.variables['y'][:]
     4963        geo_reference = Geo_reference(NetCDFObject=fid)
     4964       
     4965        #Check first value
     4966        stage = fid.variables['stage'][:]
     4967        xmomentum = fid.variables['xmomentum'][:]
     4968        ymomentum = fid.variables['ymomentum'][:]
     4969        elevation = fid.variables['elevation'][:]
     4970        #assert allclose(stage[0,0], e + tide)  #Meters
     4971
     4972        #Check the momentums - ua
     4973        #momentum = velocity*(stage-elevation)
     4974        #momentum = velocity*(stage+elevation)
     4975        # -(-elevation) since elevation is inverted in mux files
     4976        # = n*(e+tide+n) based on how I'm writing these files
     4977        #answer = n*(e+tide+n)
     4978        actual = xmomentum[0,0]
     4979        #assert allclose(answer, actual)  #Meters
     4980
     4981        # check the stage values, first time step.
     4982        # These arrays are equal since the Easting values were used as
     4983        # the stage
     4984
     4985        #assert allclose(stage[0], x +tide)  #Meters
     4986
     4987        # check the elevation values.
     4988        # -ve since urs measures depth, sww meshers height,
     4989        # these arrays are equal since the northing values were used as
     4990        # the elevation
     4991        #assert allclose(-elevation, y)  #Meters
    49074992       
    49084993        fid.close()
Note: See TracChangeset for help on using the changeset viewer.