Welcome to the chaste_codegen documentation

chaste_codegen is hosted on GitHub, where you can find the code and installation instructions.

Updating Sympy or other python packages

Sympy or any other python package may need to be updated, especially as python versions evolve. To update the version:

  • change the version listed in setup.py, e.g. for sympy it currently lists ‘sympy>=1.9, <1.11’, which means that the version is at least 1.9 and is less than 1.11.

  • update dev-requirements/dev.txt if you want to also update your development pinned (fixed) versions

  • create a new branch git checkout -b <name_of_new_branch>

  • git add, git commit and git push the changes

  • make a pull request. The tests may throw up some errors that may need fixing. The tests are in the tests folder and the reference data in data/tests. In data/tests/chaste_reference_models you’ll see a few reference files ending in .cpp_python36, This is as due to sympy versions supported python 3.6 leads to an equivalent but subtly different generated model.

  • Mention the changes made in the release notes release.txt

  • To use the changes with chaste, do a new release of chaste_codegen.

Updating the ontology and including it in chaste_codegen

  • update the ontology according to the instructions in https://github.com/ModellingWebLab/ontologies

  • the ontology is included in chaste_codegen via a submodule, update this with git submodule update --remote chaste_codegen/ontologies.

  • Please note this same way can be used to update the cellml in chaste_codegen/data/tests/cellml submodule if required.

  • create a new branch git checkout -b <name_of_new_branch>

  • git add, git commit and git push the changes

  • make a pull run the tests and fix any issues that arise

  • update the release notes release.txt with information about the updated ontology.

  • To use the changes with chaste, do a new release of chaste_codegen.

Doing a new chaste_codegen release

  • Update the release version number in chaste_codegen/version.txt.

  • Update the release notes release.txt with the latest release number.

  • For this version number: minor numbers will be picked up by chaste automatically, for major version numbers, chaste_codegen.txt will need updating in the chaste repository.

  • Follow the following tutorial to publish the package: https://packaging.python.org/en/latest/tutorials/packaging-projects/

  • You will need a login to pypi.org and the account you are using will need access to chaste_codegen.

API documentation

chaste_codegen Package

Main module for cardiac Chaste code generation

Functions

add_conversions(model[, use_modifiers, ...])

load_model_with_conversions(model_file[, ...])

load_template(*name)

Loads a template from the local template directory.

subs_math_func_placeholders(expr)

Substitutes the placeholder math functions in expr for their corresponding Sympy functions :param expr: sympy expression

version([formatted])

Returns the version number, as a 3-part integer (major, minor, revision).

Classes

BackwardEulerModel(model, file_name, **kwargs)

Holds template and information specific for the Backwards Euler model type

BackwardEulerOptModel(model, file_name, **kwargs)

Holds information specific for the Optimised Backward Euler model type.

ChasteModel(model, file_name, **kwargs)

Holds information about a cellml model for which chaste code is to be generated.

ChastePrinter([symbol_function, ...])

Converts Sympy expressions to strings for use in Chaste code generation.

CodegenError

CvodeChasteModel(model, file_name, **kwargs)

Holds template and information specific for the CVODE model type

GeneralisedRushLarsenFirstOrderModel(model, ...)

Holds template and information specific for the GeneralisedRushLarsen model type

GeneralisedRushLarsenFirstOrderModelOpt(...)

Holds template and information specific for the GeneralisedRushLarsenOpt model type

GeneralisedRushLarsenSecondOrderModel(model, ...)

Holds template and information specific for the GeneralisedRushLarsen model type

GeneralisedRushLarsenSecondOrderModelOpt(...)

Holds template and information specific for the GeneralisedRushLarsenOpt model type

LabviewPrinter([symbol_function, ...])

Converts Sympy expressions to strings for use in Chaste code generation.

NormalChasteModel(model, file_name, **kwargs)

Holds template and information specific for the Normal model type

OptChasteModel(model, file_name, **kwargs)

Holds information specific for the Optimised model type.

OptCvodeChasteModel(model, file_name, **kwargs)

Holds information specific for the Cvode Optimised model type.

RealFunction(*args)

RushLarsenC(model, file_name, **kwargs)

Holds template and information specific for the RushLarsen model type

RushLarsenLabview(model, file_name, **kwargs)

Holds template and information specific for the RushLarsen model type

RushLarsenModel(model, file_name, **kwargs)

Holds template and information specific for the RushLarsen model type

RushLarsenOptModel(model, file_name, **kwargs)

Holds template and information specific for the RushLarsen model type

Transpiler([symbol_generator, number_generator])

Handles conversion of MathmL to Sympy exprerssions.

abs_(*args)

acos_(*args)

cos_(*args)

exp_(*args)

sin_(*args)

sqrt_(*args)