BioSANS2020.propagation.deterministic.runge_kutta4

This module is the runge_kutta4 module

This module serves in the integration of ODE trajectory using RK4 and tau-adaptive RK4-algorithm.

The list of functions in this module are

  1. rk4_model

  2. runge_kutta_forth

3. rungek4_int rkck rkqs rungek4a_int

Module Contents

Functions

rk4_model(sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, molar=False)

This function returns the evaluated value of the derivative of

runge_kutta_forth(sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, delt, n_sp, molar=False)

this function prepare some stuffs for the integration

rungek4_int(conc, time, sp_comp, ks_dict, r_dict, p_dict, stch_var, molar=False, delx=1, rfile='')

Peforms the RK4 integration

rkck(hvar, sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, n_sp, molar)

This function is a helper function for tau-adaptive RK4

rkqs(htry, eps, yscal, sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, n_sp, molar)

This function is a helper function for tau-adaptive RK4

rungek4a_int(tvar, sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, yscal=10, molar=False, implicit=False, rfile='')

[summary]

BioSANS2020.propagation.deterministic.runge_kutta4.rk4_model(sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, molar=False)

This function returns the evaluated value of the derivative of each component with respwct to time at a particular instant based on the state of the system at that instant.

Args:
sp_comp (dict): dictionary of appearance or position of species

or component in the reaction tag of BioSANS topology file.

For example;

#REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2

The value of sp_comp is

sp_comp = {‘A’: {0}, ‘B’: {0, 1}, ‘C’: {1}}

A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1

ksn_dict (dict): dictionary of rate constant that appear in each

reactions.

For example;

#REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction

The value of ks_dict is

ks_dict = {

0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction

}

conc (dict): dictionary of initial concentration.

For example;

{‘A’: 100.0, ‘B’: -1.0, ‘C’: 0.0} negative means unknown or for estimation

r_dict (dict): dictionary of reactant stoichiometry. For example

r_dict = {

0: {‘A’: 1}, # first reaction, coefficient of A is 1 1: {‘B’: 1} # second reaction, coefficient of B is 1

}

p_dict (dict): dictionary of product stoichiometry. For example

p_dict = {

0: {‘B’: 1}, # first reaction, coefficient of B is 1 1: {‘C’: 1} # second reaction, coefficient of C is 1

}

stoch_var (numpy.ndarray): stoichiometric matrix. For example

stoch_var = np.array([

[ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C

#1st rxn 2nd rxn

])

tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, …] molar (bool, optional): If True, the units for any amount is in

molar. Propensity will be macroscopic. Defaults to False.

Returns:

np.ndarray: value of dx/dt

BioSANS2020.propagation.deterministic.runge_kutta4.runge_kutta_forth(sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, delt, n_sp, molar=False)

this function prepare some stuffs for the integration

Args:
sp_comp (dict): dictionary of appearance or position of species

or component in the reaction tag of BioSANS topology file.

For example;

#REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2

The value of sp_comp is

sp_comp = {‘A’: {0}, ‘B’: {0, 1}, ‘C’: {1}}

A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1

ks_dict (dict): dictionary of rate constant that appears in each

reactions.

For example;

#REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction

The value of ks_dict is

ks_dict = {

0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction

}

conc ([type]): [description] r_dict (dict): dictionary of reactant stoichiometry. For example

r_dict = {

0: {‘A’: 1}, # first reaction, coefficient of A is 1 1: {‘B’: 1} # second reaction, coefficient of B is 1

}

p_dict (dict): dictionary of product stoichiometry. For example

p_dict = {

0: {‘B’: 1}, # first reaction, coefficient of B is 1 1: {‘C’: 1} # second reaction, coefficient of C is 1

}

v_stoich (numpy.ndarray): stoichiometric matrix. For example

v_stoich = np.array([

[ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C

#1st rxn 2nd rxn

])

tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, …] delt (float): step size n_sp (dict): dictionary of keywords molar (bool, optional): If True, the units for any amount is in

molar. Propensity will be macroscopic. Defaults to False.

Returns:

list: [updated concn, updated time]

BioSANS2020.propagation.deterministic.runge_kutta4.rungek4_int(conc, time, sp_comp, ks_dict, r_dict, p_dict, stch_var, molar=False, delx=1, rfile='')

Peforms the RK4 integration

Args:

conc (dict): dictionary of initial concentration.

For example;

{‘A’: 100.0, ‘B’: -1.0, ‘C’: 0.0} negative means unknown or for estimation

tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, …] sp_comp (dict): dictionary of appearance or position of species

or component in the reaction tag of BioSANS topology file.

For example;

#REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2

The value of sp_comp is

sp_comp = {‘A’: {0}, ‘B’: {0, 1}, ‘C’: {1}}

A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1

ks_dict (dict): dictionary of rate constant that appears in each

reactions.

For example;

#REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction

The value of ks_dict is

ks_dict = {

0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction

}

r_dict (dict): dictionary of reactant stoichiometry. For example

r_dict = {

0: {‘A’: 1}, # first reaction, coefficient of A is 1 1: {‘B’: 1} # second reaction, coefficient of B is 1

}

p_dict (dict): dictionary of product stoichiometry. For example

p_dict = {

0: {‘B’: 1}, # first reaction, coefficient of B is 1 1: {‘C’: 1} # second reaction, coefficient of C is 1

}

stch_var (numpy.ndarray): stoichiometric matrix. For example

v_stoich = np.array([

[ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C

#1st rxn 2nd rxn

])

molar (bool, optional): If True, the units for any amount is in

molar. Propensity will be macroscopic. Defaults to False.

delx (float, optional): stepsize modifier. Defaults to 1. rfile (string, optional): name of topology file where some

parameters or components are negative indicating they have to be estimated. Defaults to None.

Returns:

list: [time stamp, trajectory]

BioSANS2020.propagation.deterministic.runge_kutta4.rkck(hvar, sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, n_sp, molar)

This function is a helper function for tau-adaptive RK4

BioSANS2020.propagation.deterministic.runge_kutta4.rkqs(htry, eps, yscal, sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, tvar, n_sp, molar)

This function is a helper function for tau-adaptive RK4

BioSANS2020.propagation.deterministic.runge_kutta4.rungek4a_int(tvar, sp_comp, ks_dict, conc, r_dict, p_dict, stch_var, yscal=10, molar=False, implicit=False, rfile='')

[summary]

Args:

tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, …] sp_comp (dict): dictionary of appearance or position of species

or component in the reaction tag of BioSANS topology file.

For example;

#REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2

The value of sp_comp is

sp_comp = {‘A’: {0}, ‘B’: {0, 1}, ‘C’: {1}}

A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1

ks_dict (dict): dictionary of rate constant that appears in each

reactions.

For example;

#REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction

The value of ks_dict is

ks_dict = {

0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction

}

conc (dict): dictionary of initial concentration.

For example;

{‘A’: 100.0, ‘B’: -1.0, ‘C’: 0.0} negative means unknown or for estimation

r_dict (dict): dictionary of reactant stoichiometry. For example

r_dict = {

0: {‘A’: 1}, # first reaction, coefficient of A is 1 1: {‘B’: 1} # second reaction, coefficient of B is 1

}

p_dict (dict): dictionary of product stoichiometry. For example

p_dict = {

0: {‘B’: 1}, # first reaction, coefficient of B is 1 1: {‘C’: 1} # second reaction, coefficient of C is 1

}

stch_var (numpy.ndarray): stoichiometric matrix. For example

v_stoich = np.array([

[ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C

#1st rxn 2nd rxn

])

yscal (int, optional): [description]. Defaults to 10. molar (bool, optional): If True, the units for any amount is in

molar. Propensity will be macroscopic. Defaults to False.

implicit (bool, optional): True means report in time intervals

similar to the input time intervals even if actual step is more or less. Defaults to False.

rfile (string, optional): name of topology file where some

parameters or components are negative indicating they have to be estimated. Defaults to None.

Returns:

list: [time stamp, trajectory]