Example #1
0
def main():
    NAMES = map('_'.join, product(('rev', 'irrev'),('binary', 'unary')))
    PARAMS = ('K_eq', 'k_b')
    SYMBS = get_symbs()
    BODY = {name_param: open(name_param+'.c','rt').read() for \
            name_param in map('_'.join, product(NAMES, PARAMS))}
    render_mako_template_to('analytic_template.c', 'analytic.c', locals())
    render_mako_template_to('_analytic_template.pyx', '_analytic.pyx', locals())
Example #2
0
def main():
    NAMES = map('_'.join, product(('rev', 'irrev'), ('binary', 'unary')))
    PARAMS = ('K_eq', 'k_b')
    SYMBS = get_symbs()
    BODY = {name_param: open(name_param+'.c','rt').read() for \
            name_param in map('_'.join, product(NAMES, PARAMS))}
    render_mako_template_to('analytic_template.c', 'analytic.c', locals())
    render_mako_template_to('_analytic_template.pyx', '_analytic.pyx',
                            locals())
Example #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from common import get_symbs
from derivations import as_align_env, primitive_valid
from sympy import (
    symbols, Eq, Derivative, Integral, log, solve,
    collect, atan, sqrt, S, exp, Piecewise, ccode
)

globals().update(get_symbs()) # see common.py: x, Y, Z, k_f, ...

subs = {}
eqs = []

# rate of x
rate_expr = k_f*Y*(Z-x) - k_b*x
rate_eq = Eq(Derivative(x,t), rate_expr)
eqs.append(rate_eq)

integrand = 1/rate_expr
inte_eq_lhs = Integral(integrand.subs({x: chi}), (chi,0,x))
inte_eq_rhs = Integral(1, (tau,0,t))
inte_eq = Eq(inte_eq_lhs, inte_eq_rhs)
eqs.append(inte_eq)

expl_in_x_eq = inte_eq.doit().simplify()
eqs.append(expl_in_x_eq)

expl_in_t_eq = Eq(x, solve(expl_in_x_eq, x)[0])
eqs.append(expl_in_t_eq)
Example #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from common import get_symbs, symbol_names
from derivations import as_align_env, primitive_valid
from sympy import (symbols, Eq, Derivative, Integral, log, solve, collect,
                   atan, sqrt, S, exp, Piecewise, ccode)

globals().update(get_symbs())  # see common.py: x, Y, Z, k_f, ...

subs = {}
eqs = []

# rate of x
rate_expr = k_f * Y * (Z - x) - k_b * x
rate_eq = Eq(Derivative(x, t), rate_expr)
eqs.append(rate_eq)

integrand = 1 / rate_expr
inte_eq_lhs = Integral(integrand.subs({x: chi}), (chi, 0, x))
inte_eq_rhs = Integral(1, (tau, 0, t))
inte_eq = Eq(inte_eq_lhs, inte_eq_rhs)
eqs.append(inte_eq)

expl_in_x_eq = inte_eq.doit().simplify()
eqs.append(expl_in_x_eq)

expl_in_t_eq = Eq(x, solve(expl_in_x_eq, x)[0])
eqs.append(expl_in_t_eq)

alt_expl_in_t = Z * k_f * Y / (k_f * Y + k_b) * (1 - exp(-t * (k_f * Y + k_b)))