Ejemplo n.º 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
Ejemplo n.º 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')

        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')

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

        hru.set_timestep(1.0)
        self._model = hru
Ejemplo n.º 3
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')

        fr.set_timestep(2.0)
        self._model = fr
Ejemplo n.º 4
0
numeric_approximator = ImplicitEulerPython(root_finder=root_finder)

ur = UnsaturatedReservoir(parameters={
    'Smax': 50.0,
    'Ce': 1.0,
    'm': 0.01,
    'beta': 2.0
},
                          states={'S0': 25.0},
                          approximation=numeric_approximator,
                          id='UR')

fr = PowerReservoir(parameters={
    'k': 0.1,
    'alpha': 1.0
},
                    states={'S0': 10.0},
                    approximation=numeric_approximator,
                    id='FR')

model = Unit(layers=[[ur], [fr]], id='M4')

from superflexpy.implementation.models.m4_sf_2011 import model

model.set_input([P, E])
model.set_timestep(1.0)
model.reset_states()

output = model.get_output()

from .my_new_model import model
Ejemplo n.º 5
0
unsaturated_reservoir = UnsaturatedReservoir(parameters={
    'Smax': 200.0,
    'Ce': 1.0,
    'm': 0.01,
    'beta': 0.02
},
                                             states={'S0': 100.0},
                                             approximation=num_app,
                                             id='UR')

splitter = ParameterizedSingleFluxSplitter(parameters={'split-par': 0.3},
                                           id='split')
fast_reservoir = PowerReservoir(parameters={
    'k': 0.1,
    'alpha': 1.0
},
                                states={'S0': 2.0},
                                approximation=num_app,
                                id='FR')

slow_reservoir = PowerReservoir(parameters={
    'k': 0.001,
    'alpha': 1.0
},
                                states={'S0': 100.0},
                                approximation=num_app,
                                id='SR')

junction = Junction(direction=[[0, 0]], id='junction')

m04 = Unit(layers=[[unsaturated_reservoir], [splitter],
Ejemplo n.º 6
0
from superflexpy.implementation.computation.implicit_euler import ImplicitEulerPython
from superflexpy.framework.unit import Unit
from superflexpy.framework.node import Node
from superflexpy.framework.network import Network

# Set the wd to the one of the file, to avoid absolute paths
os.chdir(sys.path[0])

# Initialize solver (default settings)
solver_python = PegasusPython()
approximator = ImplicitEulerPython(root_finder=solver_python)
#%% Run element
# Initialize the reservoir
reservoir = PowerReservoir(
    parameters={'k': 0.01, 'alpha': 2.0},
    states={'S0': 10.0},
    approximation=approximator,
    id='R'
)

reservoir.set_timestep(1.0)

# Create input
precipitation = np.array([6.5, 3.0, 0.0, 0.0, 0.0, 2.0, 4.0, 8.0, 2.0, 0.0,
                          0.0, 2.5, 1.0, 0.0, 4.0, 0.0, 1.0, 0.0, 0.0, 0.0])

# Set input
reservoir.set_input([precipitation])

# Run the element
output = reservoir.get_output()[0]
reservoir_state = reservoir.state_array[:, 0]
Ejemplo n.º 7
0
from superflexpy.implementation.computation.implicit_euler import ImplicitEulerPython
from superflexpy.implementation.computation.pegasus_root_finding import PegasusPython
from superflexpy.implementation.elements.hbv import PowerReservoir
from superflexpy.framework.unit import Unit
import spotpy
import numpy as np

root_finder = PegasusPython()
num_app = ImplicitEulerPython(root_finder=root_finder)

reservoir_1 = PowerReservoir(parameters={
    'k': 0.1,
    'alpha': 2.0
},
                             states={'S0': 10.0},
                             approximation=num_app,
                             id='FR1')
reservoir_2 = PowerReservoir(parameters={
    'k': 0.5,
    'alpha': 1.0
},
                             states={'S0': 10.0},
                             approximation=num_app,
                             id='FR2')

hyd_mod = Unit(layers=[[reservoir_1], [reservoir_2]], id='model')


class spotpy_model(object):
    def __init__(self, model, inputs, dt, observations, parameters,
                 parameter_names, output_index):