Example #1
0
File: run.py Project: lulzzz/kmos
 def __call__(self, pattern=None):
     for i, proc in enumerate(sorted(settings.rate_constants.keys())):
         if pattern is None or fnmatch(proc, pattern):
             rate_expr = settings.rate_constants[proc][0]
             rate_const = evaluate_rate_expression(rate_expr,
                                                   settings.parameters)
             print('# %s: %s = %.2e s^{-1}' % (proc, rate_expr, rate_const))
Example #2
0
File: run.py Project: lulzzz/kmos
 def __call__(self, pattern=None):
     for i, proc in enumerate(sorted(settings.rate_constants.keys())):
         if pattern is None or fnmatch(proc, pattern):
             rate_expr = settings.rate_constants[proc][0]
             rate_const = evaluate_rate_expression(rate_expr,
                                                   settings.parameters)
             print('# %s: %s = %.2e s^{-1}' % (proc, rate_expr, rate_const))
Example #3
0
File: run.py Project: lulzzz/kmos
 def inverse(self):
     res = '# kMC rate constants (%i)\n' % len(settings.rate_constants)
     res += '# ------------------\n'
     for proc in sorted(settings.rate_constants):
         rate_expr = settings.rate_constants[proc][0]
         rate_const = evaluate_rate_expression(rate_expr,
                                               settings.parameters)
         res += '# %s: %.2e s^{-1} = %s\n' % (proc, rate_const, rate_expr)
     res += '# ------------------\n'
     return res
Example #4
0
File: run.py Project: lulzzz/kmos
 def inverse(self):
     res = '# kMC rate constants (%i)\n' % len(settings.rate_constants)
     res += '# ------------------\n'
     for proc in sorted(settings.rate_constants):
         rate_expr = settings.rate_constants[proc][0]
         rate_const = evaluate_rate_expression(rate_expr,
                                               settings.parameters)
         res += '# %s: %.2e s^{-1} = %s\n' % (proc, rate_const, rate_expr)
     res += '# ------------------\n'
     return res
Example #5
0
 def __repr__(self):
     """Compact representation of all current rate_constants."""
     res = '# kMC rate constants (%i)\n' % len(settings.rate_constants)
     res += '# ------------------\n'
     for proc in sorted(settings.rate_constants):
         rate_expr = settings.rate_constants[proc][0]
         rate_const = evaluate_rate_expression(rate_expr,
                                               settings.parameters)
         res += '# %s: %s = %.2e s^{-1}\n' % (proc, rate_expr, rate_const)
     res += '# ------------------\n'
     return res
Example #6
0
 def __repr__(self):
     """Compact representation of all current rate_constants."""
     res = '# kMC rate constants (%i)\n' % len(settings.rate_constants)
     res += '# ------------------\n'
     for proc in sorted(settings.rate_constants):
         rate_expr = settings.rate_constants[proc][0]
         rate_const = evaluate_rate_expression(rate_expr,
                                               settings.parameters)
         res += '# %s: %s = %.2e s^{-1}\n' % (proc, rate_expr, rate_const)
     res += '# ------------------\n'
     return res
Example #7
0
File: run.py Project: lulzzz/kmos
    def set(self, pattern, rate_constant, parameters=None):
        """Set rate constants. Pattern can be a glob pattern,
        and the rate constant will be applied to all processes,
        where the pattern matches. The rate constant can be either
        a number or a rate expression.

        """

        if parameters is None:
            parameters = settings.parameters
        if type(rate_constant) is str:
            rate_constant = evaluate_rate_expression(rate_constant, parameters)
        try:
            rate_constant = float(rate_constant)
        except:
            raise UserWarning("Could not convert rate constant to float")
        for i, proc in enumerate(sorted(settings.rate_constants.keys())):
            if pattern is None or fnmatch(proc, pattern):
                base.set_rate_const(i + 1, rate_constant)
Example #8
0
File: run.py Project: lulzzz/kmos
    def set(self, pattern, rate_constant, parameters=None):
        """Set rate constants. Pattern can be a glob pattern,
        and the rate constant will be applied to all processes,
        where the pattern matches. The rate constant can be either
        a number or a rate expression.

        """

        if parameters is None:
            parameters = settings.parameters
        if type(rate_constant) is str:
            rate_constant = evaluate_rate_expression(rate_constant,
                                                     parameters)
        try:
            rate_constant = float(rate_constant)
        except:
            raise UserWarning("Could not convert rate constant to float")
        for i, proc in enumerate(sorted(settings.rate_constants.keys())):
            if pattern is None or fnmatch(proc, pattern):
                base.set_rate_const(i + 1, rate_constant)
Example #9
0
def set_rate_constants(parameters=None, print_rates=True):
    """Tries to evaluate the supplied expression for a rate constant
    to a simple real number and sets it for the corresponding process.
    For the evaluation it draws on predefined natural constants, user defined
    parameters and mathematical functions.
    """
    if parameters is None:
        parameters = settings.parameters

    if print_rates:
        print('-------------------')
    for proc in sorted(settings.rate_constants):
        rate_expr = settings.rate_constants[proc][0]
        rate_const = evaluate_rate_expression(rate_expr, parameters)

        try:
            base.set_rate_const(eval('proclist.%s' % proc.lower()), rate_const)
            if print_rates:
                n = int(4 * log(rate_const))
                print('%30s: %.3e s^{-1}: %s' % (proc, rate_const, '#' * n))
        except Exception, e:
            raise UserWarning(
                "Could not set %s for process %s!\nException: %s" \
                    % (rate_expr, proc, e))
Example #10
0
def set_rate_constants(parameters=None, print_rates=True):
    """Tries to evaluate the supplied expression for a rate constant
    to a simple real number and sets it for the corresponding process.
    For the evaluation it draws on predefined natural constants, user defined
    parameters and mathematical functions.
    """
    if parameters is None:
        parameters = settings.parameters

    if print_rates:
        print('-------------------')
    for proc in sorted(settings.rate_constants):
        rate_expr = settings.rate_constants[proc][0]
        rate_const = evaluate_rate_expression(rate_expr, parameters)

        try:
            base.set_rate_const(eval('proclist.%s' % proc.lower()), rate_const)
            if print_rates:
                n = int(4 * log(rate_const))
                print('%30s: %.3e s^{-1}: %s' % (proc, rate_const, '#' * n))
        except Exception, e:
            raise UserWarning(
                "Could not set %s for process %s!\nException: %s" \
                    % (rate_expr, proc, e))
scale1.set_xlim(mumin, mumax)
plt.sca(scale1)

labs_seq = []
labs_seq = [1e-18, 1e-14, 1e-10, 1e-6, 1e-2, 1e2, 1e6, 1e10]
labs_seq_strings = []

marks = []
for T in [298.15]:
    #for T in [200]:
    for p in labs_seq:
        labs_seq_strings.append(r'$10^{%d}$' % (np.log10(p)))
        print evaluate_rate_expression('mu_H2Ogas', {
            'T': {
                'value': T
            },
            'p_H2Ogas': {
                'value': p
            }
        })

        value = evaluate_rate_expression('mu_H2Ogas', {
            'T': {
                'value': T
            },
            'p_H2Ogas': {
                'value': p
            }
        })

        marks.append(value)
Example #12
0
File: run.py Project: lulzzz/kmos
 def by_name(self, proc):
     rate_expr = settings.rate_constants[proc][0]
     return evaluate_rate_expression(rate_expr, settings.parameters)
Example #13
0
File: run.py Project: lulzzz/kmos
 def by_name(self, proc):
     rate_expr = settings.rate_constants[proc][0]
     return evaluate_rate_expression(rate_expr, settings.parameters)