Skip to content

xpp

XPP ode to SBML file converter.

XPP file format is described here http://www.math.pitt.edu/~bard/bardware/tut/newstyle.html

Every ODE file consists of a series of lines that start with a keyword followed by numbers, names, and formulas or declare a named formula such as a differential equation or auxiliary quantity. Only the first letter of the keyword is important; e.g. the parser treats "parameter" and "punxatawney" exactly the same. The parser can understand lines up to 256 characters. You can use line continuation by adding a backslash character. The first line of the file cannot be a number (as this tells XPP that the file is in the old-style) but can be any other charcter or declaration. It is standard form to make the first line a comment which has the name of the file, but this is optional.

! Variables have to be case sensitive !. These issues can easily be fixed based on validator output.

Only supports subset of features. Not supported: - table - sum, - shift - set - boundary - ran - arrays

shift(var,expr) This operator evaluates the expression expr converts it to an integer and then uses this to indirectly address a variable whose address is that of var plus the integer value of the expression. This is a way to imitate arrays in XPP. For example if you defined the sequence of 5 variables, u0,u1,u2,u3,u4 one right after another, then shift(u0,2) would return the value of u2.

sum(ex1,ex2)of(ex3) is a way of summing up things. The expressions ex1>, are evaluated and their integer parts are used as the lower and upper limits of the sum. The index of the sum is i' so that you cannot have double sums since there is only one index. ex3 is the expression to be summed and will generally involve i' For example sum(1,10)of(i') will be evaluated to 55. Another example combines the sum with the shift operator. sum(0,4)of(shift(u0,i')) will sum up u0 and the next four variables that were defined after it.

escape_string

escape_string(info)

Escape string.

parse_keyword

parse_keyword(xpp_id)

Parse the keyword and returns the xpp keyword type.

:param xpp_id: :return:

parts_from_expression

parts_from_expression(expression)

Return the parts of given expression.

The parts can be whitespace or comma separated.

V1=-0.75 R1=0.26 CA1=0.1 H1=0.1 V1=-0.75, R1=0.26, CA1=0.1, H1=0.1

but there can also be commas in function definitions vex=vex(t,freq,vext)

:return: list of cleaned parts

sid_value_from_part

sid_value_from_part(part)

Get sid, value tuple from given part of expression.

:param part: :return:

xpp2sbml

xpp2sbml(
    xpp_file,
    sbml_file,
    force_lower=False,
    validate=True,
    debug=False,
)

Read given xpp_file and converts to SBML file.

:param debug: :param xpp_file: xpp input ode file :param sbml_file: sbml output file :param force_lower: force lower case for all lines :param validate: perform validation on the generated SBML file :return: