示例#1
0
        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)

    # defines the discrete points wanted in the concentration profile
    sim.apply_discretization('dae.collocation',
                             nfe=50,
        T2 = 1+(328.0-m.X[t,'T'])/((328.0-m.X[t,'T'])**2+1e-5**2)**0.5
        exprs = dict()
        exprs['A'] = -r
        exprs['B'] = -r
        exprs['C'] = r
        exprs['T'] = T1+T2
        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']
    feed_times=[2.51, 10.0, 15.0]#set with declared feeding points
    builder.add_feed_times(feed_times)#have to add feed times first!

    # Load concentration data
    #################################################################################
    dataDirectory = os.path.abspath(
        os.path.join( os.path.dirname( os.path.abspath( inspect.getfile(
            inspect.currentframe() ) ) ), 'data_sets'))
    filename =  os.path.join(dataDirectory,'Ad5_C_data_input_noise2.csv')
    C_frame = read_concentration_data_from_csv(filename)
    builder.add_concentration_data(C_frame) #has to be added here already to use for initialization as well
    pyomo_model = builder.create_pyomo_model(0.0,20.0)

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