Example #1
0
    def _init_model(self, solver):

        if solver == 'numba':
            solver = PegasusNumba()
            num_app = ImplicitEulerNumba(root_finder=solver)
        elif solver == 'python':
            solver = PegasusPython()
            num_app = ImplicitEulerPython(root_finder=solver)

        # Define HRU 1 (40%)
        fr = PowerReservoir(parameters = {'k' : 0.01,
                                         'alpha' : 2.5},
                           states = {'S0' : 0.0},
                           approximation=num_app,
                           id = 'FR')

        h1 = Unit(layers = [[fr]], id = 'H1')

        # Define HRU 2 (60%)
        fr = PowerReservoir(parameters = {'k' : 0.01,
                                         'alpha' : 2.5},
                           states = {'S0' : 0.0},
                           approximation=num_app,
                           id = 'FR')

        sr = PowerReservoir(parameters = {'k' : 1e-4,
                                         'alpha' : 1.0},
                           states = {'S0' : 0.0},
                           approximation=num_app,
                           id = 'SR')

        ur = UnsaturatedReservoir(parameters = {'Smax' : 50.0,
                                                'Ce' : 1.5,
                                                'm' : 0.01,
                                                'beta' : 1.5,
                                                },
                                  states = {'S0' : 0.2*50.0, 'PET' : None},
                           approximation=num_app,
                                  id = 'UR')

        s = Splitter(weight = [[0.3], [0.7]],
                     direction = [[0], [0]],
                     id = 'S')

        j = Junction(direction = [[0, 0]],
                     id = 'J')

        h2 = Unit(layers = [
            [ur],
            [s],
            [fr, sr],
            [j]
        ],
                id = 'H2')

        # Define the catchment
        cat = Node(units = [h1, h2], weights = [0.4, 0.6], area = 1.0, id = 'Cat')

        cat.set_timestep(1.0)
        self._model = cat
Example #2
0
    def _init_model(self, solver):

        if solver == 'numba':
            solver = PegasusNumba()
            num_app = ImplicitEulerNumba(root_finder=solver)
        elif solver == 'python':
            solver = PegasusPython()
            num_app = ImplicitEulerPython(root_finder=solver)

        fr = PowerReservoir(parameters = {'k' : 0.01,
                                         'alpha' : 2.5},
                           states = {'S0' : 0.0},
                           approximation=num_app,
                           id = 'FR')

        sr = PowerReservoir(parameters = {'k' : 1e-4,
                                         'alpha' : 1.0},
                           states = {'S0' : 0.0},
                           approximation=num_app,
                           id = 'SR')

        ur = UnsaturatedReservoir(parameters = {'Smax' : 50.0,
                                                'Ce' : 1.5,
                                                'm' : 0.01,
                                                'beta' : 1.5,
                                                },
                                  states = {'S0' : 0.2*50.0, 'PET' : None},
                           approximation=num_app,
                                  id = 'UR')

        s = Splitter(weight = [[0.3], [0.7]],
                     direction = [[0], [0]],
                     id = 'S')

        j = Junction(direction = [[0, 0]],
                     id = 'J')

        hru = Unit(layers = [
            [ur],
            [s],
            [fr, sr],
            [j]
        ],
                  id = 'H1')

        hru.set_timestep(1.0)
        self._model = hru
Example #3
0
from superflexpy.implementation.elements.structure_elements import Junction, Splitter, Transparent
from superflexpy.framework.unit import Unit

root_finder = PegasusPython()  # Use the default parameters
numerical_approximation = ImplicitEulerPython(root_finder)

upper_zone = UpperZone(parameters={
    'Smax': 50.0,
    'm': 0.01,
    'beta': 2.0
},
                       states={'S0': 10.0},
                       approximation=numerical_approximation,
                       id='uz')

splitter = Splitter(weight=[[0.6], [0.4]], direction=[[0], [0]], id='spl')

channel_routing_1 = LinearReservoir(parameters={'k': 0.1},
                                    states={'S0': 10.0},
                                    approximation=numerical_approximation,
                                    id='cr1')

channel_routing_2 = LinearReservoir(parameters={'k': 0.1},
                                    states={'S0': 10.0},
                                    approximation=numerical_approximation,
                                    id='cr2')

channel_routing_3 = LinearReservoir(parameters={'k': 0.1},
                                    states={'S0': 10.0},
                                    approximation=numerical_approximation,
                                    id='cr3')
Example #4
0
from superflexpy.implementation.root_finders.pegasus import PegasusPython
from superflexpy.implementation.numerical_approximators.implicit_euler import ImplicitEulerPython
from superflexpy.implementation.elements.thur_model_hess import SnowReservoir, UnsaturatedReservoir, PowerReservoir, HalfTriangularLag
from superflexpy.implementation.elements.structure_elements import Transparent, Junction, Splitter
from superflexpy.framework.unit import Unit
from superflexpy.framework.node import Node
from superflexpy.framework.network import Network

solver = PegasusPython()
approximator = ImplicitEulerPython(root_finder=solver)

# Fluxes in the order P, T, PET
upper_splitter = Splitter(
    direction=[
        [0, 1, None],  # P and T go to the snow reservoir
        [2, None, None]  # PET goes to the transparent element
    ],
    weight=[[1.0, 1.0, 0.0], [0.0, 0.0, 1.0]],
    id='upper-splitter')

snow = SnowReservoir(parameters={
    't0': 0.0,
    'k': 0.01,
    'm': 2.0
},
                     states={'S0': 0.0},
                     approximation=approximator,
                     id='snow')

upper_transparent = Transparent(id='upper-transparent')
Example #5
0
x1, x2, x3, x4 = (50.0, 0.1, 20.0, 3.5)

root_finder = PegasusPython()  # Use the default parameters
numerical_approximation = ImplicitEulerPython(root_finder)

interception_filter = InterceptionFilter(id='ir')

production_store = ProductionStore(parameters={'x1': x1, 'alpha': 2.0,
                                               'beta': 5.0, 'ni': 4/9},
                                   states={'S0': 10.0},
                                   approximation=numerical_approximation,
                                   id='ps')

splitter = Splitter(weight=[[0.9], [0.1]],
                    direction=[[0], [0]],
                    id='spl')

unit_hydrograph_1 = UnitHydrograph1(parameters={'lag-time': x4},
                                    states={'lag': None},
                                    id='uh1')

unit_hydrograph_2 = UnitHydrograph2(parameters={'lag-time': 2*x4},
                                    states={'lag': None},
                                    id='uh2')

routing_store = RoutingStore(parameters={'x2': x2, 'x3': x3,
                                         'gamma': 5.0, 'omega': 3.5},
                             states={'S0': 10.0},
                             approximation=numerical_approximation,
                             id='rs')