Changeset 4530


Ignore:
Timestamp:
Jun 4, 2007, 2:14:08 PM (18 years ago)
Author:
ole
Message:

Added Rainfall forcing function from Rudy van Drie

File:
1 edited

Legend:

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

    r4454 r4530  
    18141814
    18151815
     1816class Rainfall:
     1817    """Class Rainfall - general 'rain over entire domain' forcing term.
     1818   
     1819    Used for implementing Rainfall over the entire domain.
     1820       
     1821        Current Limited to only One Gauge..
     1822       
     1823        Need to add Spatial Varying Capability
     1824        (This module came from copying and amending the Inflow Code)
     1825   
     1826    Rainfall(rain)
     1827       
     1828    rain [mm/s]:  Total rain rate over the specified domain. 
     1829                  NOTE: Raingauge Data needs to reflect the time step.
     1830                  IE: if Gauge is mm read at a time step, then the input
     1831                  here is as mm/(timeStep) so 10mm in 5minutes becomes
     1832                  10/(5x60) = 0.0333mm/s.
     1833       
     1834       
     1835                  This parameter can be either a constant or a
     1836                  function of time. Positive values indicate inflow,
     1837                  negative values indicate outflow.
     1838                  (and be used for Infiltration - Write Seperate Module)
     1839                  The specified flow will be divided by the area of
     1840                  the inflow region and then applied to update the
     1841                  quantity in question.
     1842   
     1843    Examples
     1844    How to put them in a run File...
     1845       
     1846    #--------------------------------------------------------------------------
     1847    # Setup specialised forcing terms
     1848    #--------------------------------------------------------------------------
     1849    # This is the new element implemented by Ole and Rudy to allow direct
     1850    # input of Inflow in mm/s
     1851
     1852    catchmentrainfall = Rainfall(rain=file_function('Q100_2hr_Rain.tms')) 
     1853                        # Note need path to File in String.
     1854                        # Else assumed in same directory
     1855
     1856    domain.forcing_terms.append(catchmentrainfall)
     1857    """
     1858
     1859    # FIXME (OLE): Add a polygon as an alternative.
     1860    # FIXME (AnyOne) : Add various methods to allow spatial variations
     1861    # FIXME (OLE): Generalise to all quantities
     1862
     1863    def __init__(self,
     1864                 rain=0.0,
     1865                 quantity_name='stage'):
     1866
     1867        self.rain = rain
     1868        self.quantity_name = quantity_name
     1869   
     1870    def __call__(self, domain):
     1871
     1872        # Update rainfall
     1873        if callable(self.rain):
     1874            rain = self.rain(domain.get_time())
     1875        else:
     1876            rain = self.rain
     1877
     1878        # Now rain is a number
     1879        quantity = domain.quantities[self.quantity_name].explicit_update
     1880        quantity[:] += rain/1000  # Converting mm/s to m/s to apply in ANUGA
     1881                # 1mm of rainfall is equivalent to 1 litre /m2
     1882                # Flow is expressed as m3/s converted to a stage height in (m)
     1883               
     1884                # Note 1m3 = 1x10^9mm3 (mls)
     1885                # or is that m3 to Litres ??? Check this how is it applied !!!
     1886
    18161887
    18171888class Inflow:
     
    18461917    # over the specified area
    18471918    Inflow((0.5, 0.5), 0.03, lambda t: min(0.01*t, 0.0142))
     1919
     1920    #--------------------------------------------------------------------------
     1921    # Setup specialised forcing terms
     1922    #--------------------------------------------------------------------------
     1923    # This is the new element implemented by Ole to allow direct input
     1924    # of Inflow in m^3/s
     1925
     1926    hydrograph = Inflow(center=(320, 300), radius=10,
     1927                        flow=file_function('Q/QPMF_Rot_Sub13.tms'))
     1928
     1929    domain.forcing_terms.append(hydrograph)
     1930   
    18481931    """
    18491932
Note: See TracChangeset for help on using the changeset viewer.