Пример #1
0
    D_frame = read_spectral_data_from_csv(filename)
    meas_times = sorted(D_frame.index)

    model = builder.create_pyomo_model(0, 600)

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

    sim = PyomoSimulator(model)
    mod = sim.model.clone()

    # defines the discrete points wanted in the concentration profile
    sim.apply_discretization('dae.collocation',
                             nfe=50,
                             ncp=3,
                             scheme='LAGRANGE-RADAU')

    #: we now need to explicitly tell the initial conditions and parameter values
    param_name = "P"
    param_dict = {}
    param_dict["P", "k0"] = 49.7796
    param_dict["P", "k1"] = 8.93156
    param_dict["P", "k2"] = 1.31765
    param_dict["P", "k3"] = 0.310870
    param_dict["P", "k4"] = 3.87809

    ics_ = dict()
    ics_['Z', 'AH'] = 0.395555
    ics_['Z', 'B'] = 0.0351202
    ics_['Z', 'C'] = 0.0
Пример #2
0
        exprs['C'] = m.P['k2'] * m.Z[t, 'B']
        return exprs

    builder.set_odes_rule(rule_odes)

    # create an instance of a pyomo model template
    # the template includes
    #      - Z variables indexed over time and components names e.g. m.Z[t,'A']
    #      - P parameters indexed over the parameter names e.g. m.P['k']
    pyomo_model = builder.create_pyomo_model(0.0, 10.0)

    # create instance of simulator
    simulator = PyomoSimulator(pyomo_model)
    # defines the discrete points wanted in the concentration profile
    simulator.apply_discretization('dae.collocation',
                                   nfe=30,
                                   ncp=2,
                                   scheme='LAGRANGE-RADAU')

    # simulate
    results_pyomo = simulator.run_sim('ipopt', tee=True)

    # display concentration results
    if with_plots:
        results_pyomo.Z.plot.line(legend=True)
        plt.xlabel("time (s)")
        plt.ylabel("Concentration (mol/L)")
        plt.title("Concentration Profile")

        plt.show()