Ejemplo n.º 1
0
Example 2: Simple example showing parameter fitting using spectral data
with a non-reacting solvent present
"""
# Standard library imports
import sys  # Only needed for running the example from the command line

# Kipet library imports
import kipet

if __name__ == "__main__":

    with_plots = True
    if len(sys.argv) == 2 and int(sys.argv[1]):
        with_plots = False

    r1 = kipet.ReactionModel('reaction-1')

    # Add the model parameters
    k1 = r1.parameter('k1', value=2.0, bounds=(0.01, 5.0))
    k2 = r1.parameter('k2', value=0.2, bounds=(0.01, 5.0))

    # Declare the components and give the initial values
    A = r1.component('A', value=1e-3)
    B = r1.component('B', value=0.0)
    C = r1.component('C', value=0.0)
    D = r1.component('D', value=5e-4)

    # Input data
    file_name = 'data/Dij.txt'
    r1.add_data(category='spectral', file=file_name)
# Standard library imports
import sys  # Only needed for running the example from the command line

# Third party imports

# Kipet library imports
import kipet

if __name__ == "__main__":

    with_plots = True
    if len(sys.argv) == 2 and int(sys.argv[1]):
        with_plots = False
    """Simulation Model for generating data"""

    sim_model = kipet.ReactionModel('simulation')

    A = sim_model.component('A', value=0.5)
    B = sim_model.component('B', value=0.0)
    C = sim_model.component('C', value=0.0)
    D = sim_model.component('D', value=0.01)
    E = sim_model.component('E', value=0.0)
    F = sim_model.component('F', value=0.3)
    G = sim_model.component('G', value=0.5)
    H = sim_model.component('H', value=0.0)

    #Following this we add the kinetic parameters
    k1 = sim_model.parameter('k1', value=0.3)
    k2 = sim_model.parameter('k2', value=0.1)
    k3 = sim_model.parameter('k3', value=0.1)
    k4 = sim_model.parameter('k4', value=0.4)
Ejemplo n.º 3
0
"""
# Standard library imports
import sys

# Third party imports

# Kipet library imports
import kipet

if __name__ == "__main__":

    with_plots = True
    if len(sys.argv) == 2 and int(sys.argv[1]):
        with_plots = False

    r1 = kipet.ReactionModel('fed_batch')

    # Set the base time unit (match data)
    r1.unit_base.time = 'min'
    r1.unit_base.volume = 'L'

    # Reaction rate constant (parameter to fit)
    k1 = r1.parameter('k1', value=0.05, units='ft**3/mol/min')

    # Components
    A = r1.component('A', value=2.0, units='mol/L')
    B = r1.component('B', value=0.0, units='mol/L')
    C = r1.component('C', value=0.0, units='mol/L')

    # Reactor volume
    V = r1.volume(value=0.264172, units='gal')
Example 5: Simulation with extra states and dosing

"""
# Standard library imports
import sys  # Only needed for running the example from the command line

# Kipet library imports
import kipet

if __name__ == "__main__":

    with_plots = True
    if len(sys.argv) == 2 and int(sys.argv[1]):
        with_plots = False

    r1 = kipet.ReactionModel('simulation')
    r1.unit_base.time = 'min'

    # Components
    AH = r1.component('AH', value=0.395555)
    B = r1.component('B', value=0.0351202)
    C = r1.component('C', value=0.0)
    BHp = r1.component('BHp', value=0.0)
    Am = r1.component('Am', value=0.0)
    ACm = r1.component('ACm', value=0.0)
    P = r1.component('P', value=0.0)

    # Parameters
    k0 = r1.parameter('k0', value=49.7796)
    k1 = r1.parameter('k1', value=8.93156)
    k2 = r1.parameter('k2', value=1.31765)