gotran.model package

Submodules

gotran.model.cellmodel module

class gotran.model.cellmodel.CellModel(name_, ns=None)[source]

Bases: gotran.model.ode.ODE

Basic class for storing information of a cell model You can either initialize an empty CellModel similar to an ODE. (Maybe if we can create a library of th cellmodels then it the string matched that of the library we return the model in the library, e.g cell = CellModel(“Noble_1962”)) Or you can initialize the cell using an existing ODE If you have an ODE and want to have a cell, then save the ODE to an .ode file and load it using load_cell (in stead of load_ode)

Example

Example

component_names
currents

Return a list of the currents used in the computation of the membrane potential. Note that intermediate currents (not involved in th computation of the membrane potential) are not retured

get_beattime(dt=1.0, extra=60.0)[source]

Return number timepoints for one beat

Parameters:
  • dt (float) – Time increment in the same time unit as the model
  • extra (float) – Add some extra time (in ms) to prolonge the the time. Default 60 ms
get_component(name)[source]

Get the component with the given name

Parameters:name (str) – Name of the component
Returns:par – The component
Return type:gotran.ODECompoenent
get_intermediate(name)[source]

Get the intermediate with the given name

Parameters:name (str) – Name of the intermediate
Returns:par – The parameter
Return type:gotran.Parameter
get_parameter(name)[source]

Get the parameter with the given name

Parameters:name (str) – Name of the parameter
Returns:par – The parameter
Return type:gotran.Parameter
get_state(name)[source]

Get the state with the given name

Parameters:name (str) – Name of the state variable
Returns:par – The state
Return type:gotran.Parameter
get_time_steps(nbeats=1, t1=None, dt=1.0, t0=0.0)[source]

Get list with time steps given the number of beats and time increment

Parameters:
  • nbeats (int) – Nuber of beats (Default:1)
  • dt (float) – Time increament between two time steps in ms. (Default:1.0) Note that you can provide dt as a Parameter with unit different from ms.
  • t1 (float) – End time. If not provided then end time will determined from the number of beats
  • t0 (float) – Start time (Default: 0.0)
intermediate_symbols
intermediate_unit(name, unit_type='si', return_factor=False)[source]

Get unit of intermediate expression Note that we neglect units within a funtion like exponential and logaritm.

Parameters:
  • name (str) – Name of intermediate
  • unit_type (str) – Type of unit, options si, base or original
Returns:

unit – Unit of the expression for the intermediate

Return type:

str

parameter_symbols
parameter_values()[source]
residual_current(t)[source]
set_parameter(name, value)[source]

Set the parameter in the model to a given value

Parameters:
  • name (str) – Name of the parmaeter
  • value (scalar, gotran.ScalarParam) – The new value of the parameter. Note that if the parameter is of type ScalarParam while the provided value is a scalar then the value will be updated while keeping the unit
set_residual_current(t, current)[source]

Set rediual current

Parameters:
  • t (array) – List of times
  • current (array) – List with residual current
simulate(**kwargs)[source]

Simulate the ODE to \(t_{\mathrm{end}}\) with the given number points

Parameters:
  • t_end (scalar) – The end time
  • nbeats (scalar) – Number of beats based on stimulus protocol
  • npts (int) – Number of communication points used in the solver
state_symbols
state_values()[source]
stimulation_parameters
stimulation_protocol
update_parameter(name, value=None, factor=1.0)[source]
gotran.model.cellmodel.gccm()[source]

Return the current CellModel

gotran.model.expressions module

class gotran.model.expressions.Expression(name, expr, dependent=None)[source]

Bases: gotran.model.odeobjects.ODEValueObject

class for all expressions such as intermediates and derivatives

dependent
expr

Return the stored expression

is_state_expression

True of expression is a state expression

replace_expr(*replace_dicts)[source]

Replace registered expression using passed replace_dicts

sym
class gotran.model.expressions.DerivativeExpression(der_expr, dep_var, expr, dependent=None)[source]

Bases: gotran.model.expressions.Intermediate

A class for Intermediate derivative expressions

dep_var
der_expr
class gotran.model.expressions.AlgebraicExpression(state, expr, dependent=None)[source]

Bases: gotran.model.expressions.StateExpression

A class for algebraic expressions which relates a State with an expression which should equal to 0

class gotran.model.expressions.StateExpression(name, state, expr, dependent=None)[source]

Bases: gotran.model.expressions.Expression

An expression which determines a State.

state
class gotran.model.expressions.StateSolution(state, expr, dependent=None)[source]

Bases: gotran.model.expressions.Intermediate

Sub class of Expression for state solution expressions

state
class gotran.model.expressions.RateExpression(to_state, from_state, expr, dependent=None)[source]

Bases: gotran.model.expressions.Intermediate

A sub class of Expression holding single rates

states

Return a tuple of the two states the rate expression describes the rate between

class gotran.model.expressions.Intermediate(name, expr, dependent=None)[source]

Bases: gotran.model.expressions.Expression

A class for all Intermediate classes

class gotran.model.expressions.StateDerivative(state, expr, dependent=None)[source]

Bases: gotran.model.expressions.StateExpression

A class for all state derivatives

sym
class gotran.model.expressions.IndexedExpression(basename, indices, expr, shape=None, array_params=None, add_offset='', dependent=None)[source]

Bases: gotran.model.odeobjects.IndexedObject, gotran.model.expressions.Expression

An expression which represents an expression with a fixed index associated with it

gotran.model.expressions.recreate_expression(expr, *replace_dicts, **kwargs)[source]

Recreate an Expression while applying replace dicts in given order

gotran.model.loadmodel module

gotran.model.loadmodel.load_ode(filename, name=None, **arguments)[source]

Load an ODE from file and return the instance

The method looks for a file with .ode extension.

Parameters:
  • filename (str) – Name of the ode file to load
  • name (str (optional)) – Set the name of ODE (defaults to filename)
  • arguments (dict (optional)) – Optional arguments which can control loading of model
gotran.model.loadmodel.exec_ode(ode_str, name, **arguments)[source]

Execute an ode given by a str

Parameters:
  • ode_str (str) – The ode as a str
  • name (str) – The name of ODE
  • arguments (dict (optional)) – Optional arguments which can control loading of model
gotran.model.loadmodel.load_cell(filename, name=None, **arguments)[source]

Load a Cell from file and return the instance

The method looks for a file with .ode extension.

Parameters:
  • filename (str) – Name of the ode file to load
  • name (str (optional)) – Set the name of ODE (defaults to filename)
  • arguments (dict (optional)) – Optional arguments which can control loading of model

gotran.model.ode module

class gotran.model.ode.ODE(name, ns=None)[source]

Bases: gotran.model.odecomponent.ODEComponent

Root ODEComponent

Parameters:
  • name (str) – The name of the ODE
  • ns (dict (optional)) – A namespace which will be filled with declared ODE symbols
expanded_expression(expr)[source]

Return the expanded expression.

The returned expanded expression consists of the original expression given by it basics objects (States, Parameters and IndexedObjects)

extract_components(name, *components)[source]

Create an ODE from a number of components

Returns an ODE including the components

Parameters:
  • name (str) – The name of the created ODE
  • components (str) – A variable len tuple of str describing the components
finalize()[source]

Finalize the ODE

import_ode(ode, prefix='', components=None, **arguments)[source]

Import a Model into the present Model

Parameters:
  • ode (str, gotran.ODE) – The ode which should be added. If ode is a str an ODE stored in that file will be loaded. If it is an ODE it will be added directly to the present ODE.
  • prefix (str (optional)) – A prefix which all state, parameters and intermediates are prefixed with.
  • components (list, tuple of str (optional)) – A list of components which will either be extracted or excluded from the imported model. If not given the whole ODE will be imported.
  • arguments (dict (optional)) – Optional arguments which can control loading of model
is_dae

Return True if ODE is a DAE

mass_matrix

Return the mass matrix as a sympy.Matrix

ns
present_component

Return the present component

register_ode_object(obj, comp, dependent=None)[source]

Register an ODE object in the root ODEComponent

save(basename=None)[source]

Save ODE to file

Parameters:basename (str (optional)) – The basename of the file which the ode will be saved to, if not given the basename will be the same as the name of the ode.
signature()[source]

Return a signature uniquely defining the ODE

gotran.model.odecomponent module

class gotran.model.odecomponent.ODEComponent(name, parent)[source]

Bases: gotran.model.odeobjects.ODEObject

Base class for all ODE components.

add_algebraic(state, expr, dependent=None)[source]

Add an algebraic expression which relates a State with an expression which should equal to 0

Parameters:
  • state (gotran.State) – The State which the algebraic expression should determine
  • expr (sympy.Basic) – The expression that should equal 0
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_comment(comment, dependent=None)[source]

Add a comment to the ODE component

Parameters:
  • comment (str) – The comment
  • dependent (gotran.ODEObject) – If given the count of this comment will follow as a fractional count based on the count of the dependent object
add_component(name)[source]

Add a sub ODEComponent

add_derivative(der_expr, dep_var, expr, dependent=None)[source]

Add a derivative expression

Parameters:
  • der_expr (gotran.Expression, gotran.State, sympy.AppliedUndef) – The Expression or State which is differentiated
  • dep_var (gotran.State, gotran.Time, gotran.Expression, sympy.AppliedUndef, sympy.Symbol) – The dependent variable
  • expr (sympy.Basic) – The expression which the differetiation should be equal
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_intermediate(name, expr, dependent=None)[source]

Register an intermediate math expression

Parameters:
  • name (str) – The name of the expression
  • expr (sympy.Basic, scalar) – The expression
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_parameter(name, init)[source]

Add a parameter to the component

Parameters:
  • name (str) – The name of the parameter
  • init (scalar, modelparameters.ScalarParam) – The initial value of the parameter
add_parameters(*args, **kwargs)[source]

Add a number of parameters to the current ODEComponent

Parameters:
  • args (list of tuples) – A list of tuples with parameters and init values. Use this to set parameters if you need them ordered.
  • kwargs (dict) – A dict with parameters
add_solve_state(state, expr, dependent=None, **solve_flags)[source]

Add a solve state expression which tries to find a solution to a state by solving an algebraic expression

Parameters:
  • state (gotran.State, AppliedUndef) – The State that is solved
  • expr (sympy.Basic) – The expression that determines the state
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
  • solve_flags (dict) – Flags that are passed directly to sympy.solve
add_state(name, init)[source]

Add a state to the component

Parameters:
  • name (str) – The name of the state variable
  • init (scalar, modelparameters.ScalarParam) – The initial value of the state
add_state_solution(state, expr, dependent=None)[source]

Add a solution expression for a state

Parameters:
  • state (gotran.State, AppliedUndef) – The State that is solved
  • expr (sympy.Basic) – The expression that determines the state
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_states(*args, **kwargs)[source]

Add a number of states to the current ODEComponent

Parameters:
  • args (list of tuples) – A list of tuples with states and init values. Use this to set states if you need them ordered.
  • kwargs (dict) – A dict with states
comments
components

Return a list of all child components in the component

finalize_component()[source]

Called whenever the component should be finalized

full_state_vector

Return a sympy column vector with all full states

full_states

Return a list of all states in the component and its children that are not solved and determined by a state expression

get_object(name, reversed=True, return_component=False)[source]
intermediates

Return a list of all intermediates

is_complete

True if the component and all its children are locally complete

is_finalized
is_locally_complete

True if the number of non-solved states are the same as the number of registered state expressions

num_components

Return the number of all components including it self

num_full_states

Return the number of all full states

num_intermediates

Return the number of all intermediates

num_parameters

Return the number of all parameters

num_rate_expressions

Return the number rate expressions

num_state_expressions

Return the number state expressions

num_states

Return the number of all states

parameters

Return a list of all parameters in the component

parent

Return the the parent if it is still alive. Otherwise it will return None

rate_expressions

Return a list of rate expressions

root

Return the root ODE component (the ode)

state_expressions

Return a list of state expressions

states

Return a list of all states in the component and its children

t

Return the time symbol

time

Return the time

gotran.model.odeobjects module

class gotran.model.odeobjects.ODEObject(name, dependent=None)[source]

Bases: object

Base container class for all ODEObjects

name
rename(name)[source]

Rename the ODEObject

class gotran.model.odeobjects.Comment(comment, dependent=None)[source]

Bases: gotran.model.odeobjects.ODEObject

A Comment. To keep track of user comments in an ODE

class gotran.model.odeobjects.ODEValueObject(name, value, dependent=None)[source]

Bases: gotran.model.odeobjects.ODEObject

A class for all ODE objects which has a value

param
rename(name)[source]

Rename the ODEValueObject

sym
unit
update(value)[source]
value
class gotran.model.odeobjects.Parameter(name, init)[source]

Bases: gotran.model.odeobjects.ODEValueObject

class for a Parameter

init
class gotran.model.odeobjects.State(name, init, time)[source]

Bases: gotran.model.odeobjects.ODEValueObject

class for a State variable

init
is_solved
sym
class gotran.model.odeobjects.Time(name, unit='ms')[source]

Bases: gotran.model.odeobjects.ODEValueObject

Specialization for a Time class

update_unit(unit)[source]

Update unit. For example if time has unit seconds in stead of milliseconds

class gotran.model.odeobjects.Dt(name, unit='ms')[source]

Bases: gotran.model.odeobjects.ODEValueObject

Specialization for a time step class

update_unit(unit)[source]

Update unit. For example if time has unit seconds in stead of milliseconds

class gotran.model.odeobjects.IndexedObject(basename, indices, shape=None, array_params=None, add_offset='', dependent=None)[source]

Bases: gotran.model.odeobjects.ODEObject

An object with a fixed index associated with it

basename
static default_parameters()[source]

Return the default parameters for formating the array

indices
offset_str
shape
sym
gotran.model.odeobjects.cmp_to_key()

Convert a cmp= function into a key= function.

gotran.model.odeobjects.cmp(a, b)[source]

gotran.model.utils module

gotran.model.utils.ode_primitives(expr, time)[source]

Return all ODE primitives

Parameters:
  • expr (sympy.expression) – A sympy expression of ode symbols
  • time (sympy.Symbol) – A Symbol representing time in the ODE
gotran.model.utils.special_expression(name, root)[source]

Check if an expression name corresponds to a special expression

class gotran.model.utils.iter_objects(comp, return_comp=True, only_return_comp=False, reverse=False, *types)[source]

Bases: object

A recursive iterator over all objects of a component including its childrens

Parameters:
  • comp (gotran.ODEComponent) – The root ODEComponent of the iteration
  • reverse (bool) – If True the iteration is done from the last component added
  • types (gotran.ODEObject types (optional)) – Only iterate over particular types
Yields:

ode_object (gotran.ODEObject) – All ODEObjects of a component

next()[source]
gotran.model.utils.ode_objects(comp, *types)[source]

Return a list of ode objects

Parameters:
  • comp (gotran.ODEComponent) – The root ODEComponent of the list
  • types (gotran.ODEObject types (optional)) – Only include objects of type given in types
gotran.model.utils.ode_components(comp, include_self=True)[source]

Return a list of ode components

Parameters:
  • comp (gotran.ODEComponent) – The root ODEComponent of the list
  • return_self (bool (optional)) – The list will include the passed component if True
class gotran.model.utils.ODEObjectList[source]

Bases: list

Specialized container for ODEObjects. It is a list but adds dict access through the name attribute of an ODEObjects

append(object) → None -- append object to end[source]
count(value) → integer -- return number of occurrences of value[source]
extend(iterable) → None -- extend list by appending elements from the iterable[source]
get(name)[source]
index(value[, start[, stop]]) → integer -- return first index of value.[source]

Raises ValueError if the value is not present.

insert(index, item)[source]

L.insert(index, object) – insert object before index

keys()[source]
pop([index]) → item -- remove and return item at index (default last).[source]

Raises IndexError if list is empty or index is out of range.

remove(value) → None -- remove first occurrence of value.[source]

Raises ValueError if the value is not present.

reverse(item)[source]

L.reverse() – reverse IN PLACE

sort(key=None, reverse=False) → None -- stable sort *IN PLACE*[source]
class gotran.model.utils.RateDict(comp)[source]

Bases: collections.OrderedDict

A storage class for Markov model rates

Module contents

class gotran.model.ODEObject(name, dependent=None)[source]

Bases: object

Base container class for all ODEObjects

name
rename(name)[source]

Rename the ODEObject

class gotran.model.Comment(comment, dependent=None)[source]

Bases: gotran.model.odeobjects.ODEObject

A Comment. To keep track of user comments in an ODE

class gotran.model.ODEValueObject(name, value, dependent=None)[source]

Bases: gotran.model.odeobjects.ODEObject

A class for all ODE objects which has a value

param
rename(name)[source]

Rename the ODEValueObject

sym
unit
update(value)[source]
value
class gotran.model.Parameter(name, init)[source]

Bases: gotran.model.odeobjects.ODEValueObject

class for a Parameter

init
class gotran.model.State(name, init, time)[source]

Bases: gotran.model.odeobjects.ODEValueObject

class for a State variable

init
is_solved
sym
class gotran.model.Time(name, unit='ms')[source]

Bases: gotran.model.odeobjects.ODEValueObject

Specialization for a Time class

update_unit(unit)[source]

Update unit. For example if time has unit seconds in stead of milliseconds

class gotran.model.Dt(name, unit='ms')[source]

Bases: gotran.model.odeobjects.ODEValueObject

Specialization for a time step class

update_unit(unit)[source]

Update unit. For example if time has unit seconds in stead of milliseconds

class gotran.model.IndexedObject(basename, indices, shape=None, array_params=None, add_offset='', dependent=None)[source]

Bases: gotran.model.odeobjects.ODEObject

An object with a fixed index associated with it

basename
static default_parameters()[source]

Return the default parameters for formating the array

indices
offset_str
shape
sym
gotran.model.cmp_to_key()

Convert a cmp= function into a key= function.

gotran.model.cmp(a, b)[source]
class gotran.model.ODEComponent(name, parent)[source]

Bases: gotran.model.odeobjects.ODEObject

Base class for all ODE components.

add_algebraic(state, expr, dependent=None)[source]

Add an algebraic expression which relates a State with an expression which should equal to 0

Parameters:
  • state (gotran.State) – The State which the algebraic expression should determine
  • expr (sympy.Basic) – The expression that should equal 0
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_comment(comment, dependent=None)[source]

Add a comment to the ODE component

Parameters:
  • comment (str) – The comment
  • dependent (gotran.ODEObject) – If given the count of this comment will follow as a fractional count based on the count of the dependent object
add_component(name)[source]

Add a sub ODEComponent

add_derivative(der_expr, dep_var, expr, dependent=None)[source]

Add a derivative expression

Parameters:
  • der_expr (gotran.Expression, gotran.State, sympy.AppliedUndef) – The Expression or State which is differentiated
  • dep_var (gotran.State, gotran.Time, gotran.Expression, sympy.AppliedUndef, sympy.Symbol) – The dependent variable
  • expr (sympy.Basic) – The expression which the differetiation should be equal
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_intermediate(name, expr, dependent=None)[source]

Register an intermediate math expression

Parameters:
  • name (str) – The name of the expression
  • expr (sympy.Basic, scalar) – The expression
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_parameter(name, init)[source]

Add a parameter to the component

Parameters:
  • name (str) – The name of the parameter
  • init (scalar, modelparameters.ScalarParam) – The initial value of the parameter
add_parameters(*args, **kwargs)[source]

Add a number of parameters to the current ODEComponent

Parameters:
  • args (list of tuples) – A list of tuples with parameters and init values. Use this to set parameters if you need them ordered.
  • kwargs (dict) – A dict with parameters
add_solve_state(state, expr, dependent=None, **solve_flags)[source]

Add a solve state expression which tries to find a solution to a state by solving an algebraic expression

Parameters:
  • state (gotran.State, AppliedUndef) – The State that is solved
  • expr (sympy.Basic) – The expression that determines the state
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
  • solve_flags (dict) – Flags that are passed directly to sympy.solve
add_state(name, init)[source]

Add a state to the component

Parameters:
  • name (str) – The name of the state variable
  • init (scalar, modelparameters.ScalarParam) – The initial value of the state
add_state_solution(state, expr, dependent=None)[source]

Add a solution expression for a state

Parameters:
  • state (gotran.State, AppliedUndef) – The State that is solved
  • expr (sympy.Basic) – The expression that determines the state
  • dependent (gotran.ODEObject) – If given the count of this expression will follow as a fractional count based on the count of the dependent object
add_states(*args, **kwargs)[source]

Add a number of states to the current ODEComponent

Parameters:
  • args (list of tuples) – A list of tuples with states and init values. Use this to set states if you need them ordered.
  • kwargs (dict) – A dict with states
comments
components

Return a list of all child components in the component

finalize_component()[source]

Called whenever the component should be finalized

full_state_vector

Return a sympy column vector with all full states

full_states

Return a list of all states in the component and its children that are not solved and determined by a state expression

get_object(name, reversed=True, return_component=False)[source]
intermediates

Return a list of all intermediates

is_complete

True if the component and all its children are locally complete

is_finalized
is_locally_complete

True if the number of non-solved states are the same as the number of registered state expressions

num_components

Return the number of all components including it self

num_full_states

Return the number of all full states

num_intermediates

Return the number of all intermediates

num_parameters

Return the number of all parameters

num_rate_expressions

Return the number rate expressions

num_state_expressions

Return the number state expressions

num_states

Return the number of all states

parameters

Return a list of all parameters in the component

parent

Return the the parent if it is still alive. Otherwise it will return None

rate_expressions

Return a list of rate expressions

root

Return the root ODE component (the ode)

state_expressions

Return a list of state expressions

states

Return a list of all states in the component and its children

t

Return the time symbol

time

Return the time

class gotran.model.Expression(name, expr, dependent=None)[source]

Bases: gotran.model.odeobjects.ODEValueObject

class for all expressions such as intermediates and derivatives

dependent
expr

Return the stored expression

is_state_expression

True of expression is a state expression

replace_expr(*replace_dicts)[source]

Replace registered expression using passed replace_dicts

sym
class gotran.model.DerivativeExpression(der_expr, dep_var, expr, dependent=None)[source]

Bases: gotran.model.expressions.Intermediate

A class for Intermediate derivative expressions

dep_var
der_expr
class gotran.model.AlgebraicExpression(state, expr, dependent=None)[source]

Bases: gotran.model.expressions.StateExpression

A class for algebraic expressions which relates a State with an expression which should equal to 0

class gotran.model.StateExpression(name, state, expr, dependent=None)[source]

Bases: gotran.model.expressions.Expression

An expression which determines a State.

state
class gotran.model.StateSolution(state, expr, dependent=None)[source]

Bases: gotran.model.expressions.Intermediate

Sub class of Expression for state solution expressions

state
class gotran.model.RateExpression(to_state, from_state, expr, dependent=None)[source]

Bases: gotran.model.expressions.Intermediate

A sub class of Expression holding single rates

states

Return a tuple of the two states the rate expression describes the rate between

class gotran.model.Intermediate(name, expr, dependent=None)[source]

Bases: gotran.model.expressions.Expression

A class for all Intermediate classes

class gotran.model.StateDerivative(state, expr, dependent=None)[source]

Bases: gotran.model.expressions.StateExpression

A class for all state derivatives

sym
class gotran.model.IndexedExpression(basename, indices, expr, shape=None, array_params=None, add_offset='', dependent=None)[source]

Bases: gotran.model.odeobjects.IndexedObject, gotran.model.expressions.Expression

An expression which represents an expression with a fixed index associated with it

gotran.model.recreate_expression(expr, *replace_dicts, **kwargs)[source]

Recreate an Expression while applying replace dicts in given order

class gotran.model.ODE(name, ns=None)[source]

Bases: gotran.model.odecomponent.ODEComponent

Root ODEComponent

Parameters:
  • name (str) – The name of the ODE
  • ns (dict (optional)) – A namespace which will be filled with declared ODE symbols
expanded_expression(expr)[source]

Return the expanded expression.

The returned expanded expression consists of the original expression given by it basics objects (States, Parameters and IndexedObjects)

extract_components(name, *components)[source]

Create an ODE from a number of components

Returns an ODE including the components

Parameters:
  • name (str) – The name of the created ODE
  • components (str) – A variable len tuple of str describing the components
finalize()[source]

Finalize the ODE

import_ode(ode, prefix='', components=None, **arguments)[source]

Import a Model into the present Model

Parameters:
  • ode (str, gotran.ODE) – The ode which should be added. If ode is a str an ODE stored in that file will be loaded. If it is an ODE it will be added directly to the present ODE.
  • prefix (str (optional)) – A prefix which all state, parameters and intermediates are prefixed with.
  • components (list, tuple of str (optional)) – A list of components which will either be extracted or excluded from the imported model. If not given the whole ODE will be imported.
  • arguments (dict (optional)) – Optional arguments which can control loading of model
is_dae

Return True if ODE is a DAE

mass_matrix

Return the mass matrix as a sympy.Matrix

ns
present_component

Return the present component

register_ode_object(obj, comp, dependent=None)[source]

Register an ODE object in the root ODEComponent

save(basename=None)[source]

Save ODE to file

Parameters:basename (str (optional)) – The basename of the file which the ode will be saved to, if not given the basename will be the same as the name of the ode.
signature()[source]

Return a signature uniquely defining the ODE

class gotran.model.CellModel(name_, ns=None)[source]

Bases: gotran.model.ode.ODE

Basic class for storing information of a cell model You can either initialize an empty CellModel similar to an ODE. (Maybe if we can create a library of th cellmodels then it the string matched that of the library we return the model in the library, e.g cell = CellModel(“Noble_1962”)) Or you can initialize the cell using an existing ODE If you have an ODE and want to have a cell, then save the ODE to an .ode file and load it using load_cell (in stead of load_ode)

Example

Example

component_names
currents

Return a list of the currents used in the computation of the membrane potential. Note that intermediate currents (not involved in th computation of the membrane potential) are not retured

get_beattime(dt=1.0, extra=60.0)[source]

Return number timepoints for one beat

Parameters:
  • dt (float) – Time increment in the same time unit as the model
  • extra (float) – Add some extra time (in ms) to prolonge the the time. Default 60 ms
get_component(name)[source]

Get the component with the given name

Parameters:name (str) – Name of the component
Returns:par – The component
Return type:gotran.ODECompoenent
get_intermediate(name)[source]

Get the intermediate with the given name

Parameters:name (str) – Name of the intermediate
Returns:par – The parameter
Return type:gotran.Parameter
get_parameter(name)[source]

Get the parameter with the given name

Parameters:name (str) – Name of the parameter
Returns:par – The parameter
Return type:gotran.Parameter
get_state(name)[source]

Get the state with the given name

Parameters:name (str) – Name of the state variable
Returns:par – The state
Return type:gotran.Parameter
get_time_steps(nbeats=1, t1=None, dt=1.0, t0=0.0)[source]

Get list with time steps given the number of beats and time increment

Parameters:
  • nbeats (int) – Nuber of beats (Default:1)
  • dt (float) – Time increament between two time steps in ms. (Default:1.0) Note that you can provide dt as a Parameter with unit different from ms.
  • t1 (float) – End time. If not provided then end time will determined from the number of beats
  • t0 (float) – Start time (Default: 0.0)
intermediate_symbols
intermediate_unit(name, unit_type='si', return_factor=False)[source]

Get unit of intermediate expression Note that we neglect units within a funtion like exponential and logaritm.

Parameters:
  • name (str) – Name of intermediate
  • unit_type (str) – Type of unit, options si, base or original
Returns:

unit – Unit of the expression for the intermediate

Return type:

str

parameter_symbols
parameter_values()[source]
residual_current(t)[source]
set_parameter(name, value)[source]

Set the parameter in the model to a given value

Parameters:
  • name (str) – Name of the parmaeter
  • value (scalar, gotran.ScalarParam) – The new value of the parameter. Note that if the parameter is of type ScalarParam while the provided value is a scalar then the value will be updated while keeping the unit
set_residual_current(t, current)[source]

Set rediual current

Parameters:
  • t (array) – List of times
  • current (array) – List with residual current
simulate(**kwargs)[source]

Simulate the ODE to \(t_{\mathrm{end}}\) with the given number points

Parameters:
  • t_end (scalar) – The end time
  • nbeats (scalar) – Number of beats based on stimulus protocol
  • npts (int) – Number of communication points used in the solver
state_symbols
state_values()[source]
stimulation_parameters
stimulation_protocol
update_parameter(name, value=None, factor=1.0)[source]
gotran.model.load_ode(filename, name=None, **arguments)[source]

Load an ODE from file and return the instance

The method looks for a file with .ode extension.

Parameters:
  • filename (str) – Name of the ode file to load
  • name (str (optional)) – Set the name of ODE (defaults to filename)
  • arguments (dict (optional)) – Optional arguments which can control loading of model
gotran.model.exec_ode(ode_str, name, **arguments)[source]

Execute an ode given by a str

Parameters:
  • ode_str (str) – The ode as a str
  • name (str) – The name of ODE
  • arguments (dict (optional)) – Optional arguments which can control loading of model
gotran.model.load_cell(filename, name=None, **arguments)[source]

Load a Cell from file and return the instance

The method looks for a file with .ode extension.

Parameters:
  • filename (str) – Name of the ode file to load
  • name (str (optional)) – Set the name of ODE (defaults to filename)
  • arguments (dict (optional)) – Optional arguments which can control loading of model