Beispiel #1
0
    # This model acts as the main model for all experimental datasets

    # define explicit system of ODEs
    # DEFINE MODEL FOR ALL EXPERIMENTS
    def rule_odes(m, t):
        exprs = dict()
        exprs['A'] = -m.P['k1'] * m.Z[t, 'A']
        exprs['B'] = m.P['k1'] * m.Z[t, 'A'] - m.P['k2'] * m.Z[t, 'B']
        exprs['C'] = m.P['k2'] * m.Z[t, 'B']
        exprs['D'] = -m.P['k3'] * m.Z[t, 'D']
        exprs['E'] = m.P['k3'] * m.Z[t, 'D']
        return exprs

    # As with other multiple experiments KIPET examples, we have different TemplateBuilders for
    # each of the experiments.
    builder1.set_odes_rule(rule_odes)

    # In this example, it is useful to bound the profiles to stop the components with 0 concentration,
    # i.e. D and E, from having very large absorbances.
    builder1.bound_profile(var='S', bounds=(0, 10))

    #=========================================================================
    # EXPERIMENT 2 and 3
    #=========================================================================
    builder2 = TemplateBuilder()
    components2 = {'A': 3e-3, 'B': 0, 'C': 0, 'D': 1e-3, 'E': 0}
    builder2.add_mixture_component(components2)
    builder2.add_parameter('k1', init=1.5, bounds=(0.001, 10))
    #There is also the option of providing initial values: Just add init=... as additional argument as above.
    builder2.add_parameter('k2', init=0.2, bounds=(0.0001, 1))
    builder2.add_parameter('k3', init=0.6, bounds=(0.3, 2))
Beispiel #2
0
                      ((m.Y[t, '5'] + 1)**2 + eta**2)**0.5 +
                      (210.0 - m.Y[t, '5']) /
                      ((210.0 - m.Y[t, '5'])**2 + eta**2)**0.5)
        exprs['V'] = 7.27609e-05 * step
        V = m.X[t, 'V']
        # mass balances
        for c in m.mixture_components:
            exprs[c] = gammas[c][0] * m.Y[t, '0'] + gammas[c][1] * m.Y[
                t, '1'] + gammas[c][2] * m.Y[t, '2'] + gammas[c][3] * m.Y[
                    t, '3'] + gammas[c][4] * m.Y[
                        t, '4'] - exprs['V'] / V * m.Z[t, c]
            if c == 'C':
                exprs[c] += 0.02247311828 / (m.X[t, 'V'] * 210) * step
        return exprs

    builder.set_odes_rule(rule_odes)

    #Add time points where feed as discrete jump should take place:
    feed_times = [101.035, 400., 303.126]
    builder.add_feed_times(feed_times)

    model = builder.create_pyomo_model(0, 600)

    #=========================================================================
    #USER INPUT SECTION - FE Factory
    #=========================================================================

    # call FESimulator
    # FESimulator re-constructs the current TemplateBuilder into fe_factory syntax
    # there is no need to call PyomoSimulator any more as FESimulator is a child class
    sim = FESimulator(model)
    # define explicit system of ODEs
    def rule_odes(m, t):
        exprs = dict()
        exprs['A'] = -m.P['k1'] * m.X[t, 'A']
        exprs['B'] = m.P['k1'] * m.X[t, 'A'] - m.P['k2'] * m.Z[t, 'B']
        exprs['C'] = m.P['k2'] * m.Z[t, 'B']
        return exprs

    def rule_odes2(m, t):
        exprs = dict()
        exprs['A2'] = -m.P['k1'] * m.X[t, 'A2']
        exprs['B'] = m.P['k1'] * m.X[t, 'A2'] - m.P['k2'] * m.Z[t, 'B']
        exprs['C'] = m.P['k2'] * m.Z[t, 'B']
        return exprs

    builder.set_odes_rule(rule_odes)
    builder2.set_odes_rule(rule_odes2)
    start_time1 = 0.0
    start_time2 = 0.0
    end_time1 = 10.0
    end_time2 = 10.0

    modelexp1 = builder.create_pyomo_model(start_time1, end_time1)

    builder22 = TemplateBuilder()
    builder22.add_mixture_component(components)
    builder22.add_parameter('k1', init=1.0, bounds=(0.0, 10))
    # There is also the option of providing initial values: Just add init=... as additional argument as above.
    builder22.add_parameter('k2', init=0.224, bounds=(0.0, 10))
    # add complementary state variable:
    builder22.add_complementary_state_variable(extra_states2)