Ejemplo n.º 1
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.º 2
0
}

PARAMETERS_WEIERBACH_M02 = {
    'm02_FR_k': 0.002139433659078,
    'm02_FR_alpha': 2.16587447669636,
    'm02_UR_Ce': 0.763629137970332,
    'm02_UR_Smax': 115.798257318686,
    'm02_UR_beta': 10.0,
}

root_finder = PegasusPython(iter_max=1000)
num_app = ImplicitEulerPython(root_finder=root_finder)

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

fast_reservoir = PowerReservoir(
    parameters={'k': 0.1, 'alpha': 1.0},
    states={'S0': 2.0},
    approximation=num_app,
    id='FR'
)

m02 = Unit(
    layers=[[unsaturated_reservoir], [fast_reservoir]],
    id='m02'
)
Ejemplo n.º 3
0
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):

        self._model = model
        self._model.set_input(inputs)
        self._model.set_timestep(dt)

        self._parameters = parameters
        self._parameter_names = parameter_names
        self._observarions = observations
        self._output_index = output_index
Ejemplo n.º 4
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
        cat1 = Node(units=[h1, h2], weights=[0.25, 0.75], area=10.0, id='Cat1')
        cat2 = Node(units=[h1, h2], weights=[0.4, 0.6], area=20.0, id='Cat2')
        cat3 = Node(units=[h1, h2], weights=[0.8, 0.2], area=30.0, id='Cat3')

        # Define the network
        net = Network(nodes=[cat1, cat2, cat3],
                      topology={
                          'Cat1': 'Cat3',
                          'Cat2': 'Cat3',
                          'Cat3': None,
                      })
        net.set_timestep(1.0)
        self._cat1 = cat1
        self._cat2 = cat2
        self._cat3 = cat3
        self._model = net
Ejemplo n.º 5
0
    'alpha': 1.0
},
                      states={'S0': 0.0},
                      approximation=approximator,
                      id='slow')

lower_transparent = Transparent(id='lower-transparent')

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

consolidated = Unit(layers=[
    [upper_splitter],
    [snow, upper_transparent],
    [upper_junction],
    [unsaturated],
    [lower_splitter],
    [slow, lag_fun],
    [lower_transparent, fast],
    [lower_junction],
],
                    id='consolidated')

unconsolidated = Unit(layers=[
    [upper_splitter],
    [snow, upper_transparent],
    [upper_junction],
    [unsaturated],
    [lower_splitter],
    [slow, lag_fun],
    [lower_transparent, fast],
    [lower_junction],
Ejemplo n.º 6
0
    'm01_FR_alpha': 4.34329024018006,
    'm01_FR_Ce': 0.77318384036332,
}

root_finder = PegasusPython(iter_max=1000)
num_app = ImplicitEulerPython(root_finder=root_finder)

fast_reservoir = PowerReservoirET(
    parameters={'k': 0.1, 'alpha': 1.0, 'Ce': 1.0, 'm': 0.5},
    states={'S0': 20.0},
    approximation=num_app,
    id='FR'
)

m01 = Unit(
    layers=[[fast_reservoir]],
    id='m01'
)

# if __name__ == '__main__':
#     import pandas as pd
#     data = pd.read_csv('data/Maimai.csv')
#     data.set_index(pd.to_datetime((data.year*10000+data.month*100+data.day).apply(str),format='%Y%m%d'), inplace=True)
#     data.drop(columns=['year', 'month', 'day'], inplace=True)
#     m01.set_parameters(PARAMETERS_MAIMAI)
#     START_SIMULATE = 50
#     START_VISUALIZE = 50 # Relative to START_SIMULATE
#     END_SIMULATE = 830 # Absolute
#     P = data['P(mm/d)'].values[START_SIMULATE:END_SIMULATE]
#     E = data['E(mm/d)'].values[START_SIMULATE:END_SIMULATE]
#     Q_obs = data['Q_obs(mm/d)'].values[START_SIMULATE:END_SIMULATE]
Ejemplo n.º 7
0
                                    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')

transparent = Transparent(id='tr')

junction = Junction(direction=[[0, None],   # First output
                               [1, None],   # Second output
                               [None, 0]],  # Third output
                    id='jun')

flux_aggregator = FluxAggregator(id='fa')

model = Unit(layers=[[interception_filter],
                     [production_store],
                     [splitter],
                     [unit_hydrograph_1, unit_hydrograph_2],
                     [routing_store, transparent],
                     [junction],
                     [flux_aggregator]],
             id='model')
Ejemplo n.º 8
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')

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

transparent_1 = Transparent(id='tr1')

transparent_2 = Transparent(id='tr2')

junction = Junction(
    direction=[[0, 0]],  # First output
    id='jun')

model = Unit(layers=[[upper_zone], [splitter], [channel_routing_1, lower_zone],
                     [channel_routing_2, transparent_1],
                     [channel_routing_3, transparent_2], [junction]],
             id='model')