C++
This module contains all the different writers per reactor for the C++ language.
Batch
- class pykinetic.writers.cplusplus.CplusplusWriter(conc_var='x', mb_var='dxdt', fun_var='model', jac_var='Jac', jac_fun_var='jacobian', header=None, tail=None)[source]
-
- constant(reaction, value_format='{:0.10e}')[source]
Takes in a reaction and returns 2 expressions, the string of the variable and the string with the value of the constant. I.e.
# Reaction(1 => 2)
A = <ElementalStep 1 of Type '=>' with reacts=(1,) products(2,)>
'k01', '1.00000000' = PythonWriter.constant(A)
- Parameters:
reaction (Reaction) -- Any reaction
- Returns:
variable and expresion of the reaction
- Return type:
var,expr
- fill(chemicalsys)[source]
Reads the information of the chemical system and updates the values needed for writing.
- jacobian_element(Jac_ij)[source]
Takes the partial differential of a MB and returns the variable of the jacobian and the string of the expression. I.e.
# Given a Chemical system with only Reaction('A <=> B')
# d[A]dt = -r1 + r2 = -k01[A] + k2[B]
# being A.key = 0 and B.key = 1
C = <JacobianElement(Reaction(1),Compound(A))>
'Jac[0,0]', '-k01' = PythonWriter.jacobian_element(A)
- Parameters:
Jac_ij (JacobianElement) -- Any JacobianElement object
- Returns:
variable and expresion of the reaction
- Return type:
var,expr
- massbalance(MassBalance)[source]
Takes in a mass balance and returns 2 expressions, the string of the variable and the string of the expression. I.e.
# Given a Chemical system with only Reaction('A <=> B')
# d[A]dt = -r1 + r2 = -k01[A] + k2[B]
# being A.key = 0 and B.key = 1
A = <ElementalStep 1 of Type '=>' with reacts=(1,) products(2,)>
'dxdt[0]', '-k01*x[1] +k02[B]' = PythonWriter.massbalance(A)
- Parameters:
reaction (MassBalance) -- Any MassBalance
- Returns:
variable and expresion of the reaction
- Return type:
var,expr
- ratelaw(reaction)[source]
Takes in a reaction and returns 2 expressions, the string of the variable and the string of the ratelaw expression. I.e. # Reaction(1 => 2) A = <ElementalStep 1 of Type '=>' with reacts=(1,) products(2,)> 'r01', 'k01*x[1]' = PythonWriter.ratelaw(A)
- Parameters:
reaction (Reaction) -- Any reaction
- Returns:
variable and expresion of the reaction
- Return type:
var,expr
- ratelaw_partial(reaction, compound)[source]
Takes in a reaction and returns and the string of the partial derivative the ratelaw with respect to the concentration of compound. I.e.
# Reaction(1 => 2), Compound 1
A = <ElementalStep 1 of Type '=>' with reacts=(1,) products(2,)>
# r01,'k01*x[1]'ratelaw(A)
'k01' = PythonWriter.ratelaw_partial(A)