Skip to main content

Posts

Week 10

Progress this Week Last week I had almost finished working on RateRules but I was having some trouble with models where the compartment size was being changed through a RateRule. Species in SBML models can be expressed in terms of their concentrations or their amounts. This is an issue that the SBML reference describes in great detail, so I had taken appropriate care to distinguish between the two while developing the simulator, however, there were still a few issues that caused the error I described above. In our weekly meeting, we spent some time discussing this and the mentors suggested that I try an alternative approach, where the AST nodes will be modified before running the simulator. So, wherever a species occurs in an AST in concentration units, it is changed to (species / compartment). This allows the simulator to substitute amount values while evaluating mathematical expressions and makes integration easier and more accurate. While doing this, I found another error, where I h...
Recent posts

Week 9

     Progress this Week The Runge Kutta Fehlberg integrator was completed last week with help from mentors during our weekly meeting. After that, I started working on Rate Rules.  I also modified the data structure I had built earlier and it's a lot more robust now. Earlier, I was using the parsed model directly from the sbml-rs package. That was a problem because the SBML specification allows various ways to set values for quantities like species. For example, it is possible to assign initial amounts/concentrations to species using the initialAmount  or initialConcentration  attributes on <species> tags directly, but it's also possible to assign these values using an initialAssignment . Due to this, while parsing the model, the amount field on a species  struct is an Option<f64>. This creates trouble later while simulating because you have to pattern-match at each step. Hence, this week I created similar structs in the sbml-sim package whi...

Week 8

    Progress this Week This week I worked on the Runge Kutta Fehlberg numerical integration algorithm. While the integrator is set up and running, some of the test cases fail due to issues with error estimation.  For example, in model 3 in the core SBML test suite, the simulator calculates the values as follows: $ cargo run ../testsuites/core-semantic/00003/00003-sbml-l3v2.xml 5 50 1e-4 1e-5 5 seconds with 50 steps. t               S1                      S2 0.000000        0.0150000000000000      0.0000000000000000 0.100000        0.0135747032487483      0.0028505935025034 0.200000        0.0122848378861052      0.0054303242277897 0.300000        0.0111175352508572      0.0077649294982856 0.400000        0.01006114945919...

Week 7

   Progress this Week This week I worked on InitialAssignments, AssignmentRules and LocalParameters. All these features are supported by the simulator and parsers now and I have verified this with tests from the Core Semantic SBML test suites. Some of the tests fail because I didn't account for the fact that amounts and concentrations of species are optional, and can be defined by AssignmentRules instead of being specified while defining the species or through InitialAssignments. I'll work on this in the coming week. Progress so Far As per discussion with my project mentors, we have now diverged from the initially proposed timeline. The first half was completed as proposed and the last two weeks were spent in building support for more SBML features instead of the Runge-Kutta-Fehlberg integrator. Plan for the Coming Week Fix the issues with tests described above Implement the Runge-Kutta-Fehlberg Integrator

Week 6

  Progress this Week This week I fixed errors in my implementation of the Runge-Kutta method for the simulator, added support for FunctionDefinitions and ModifierSpeciesReferences in the SBML parser and lambda functions, piecewise functions, operators, constants and conditions in the MathML parser. Simulator After comparing results from the Rust simulator with the expected results in the SBML test suite, I realized there was an error in the way I had set up differential equations for the integrator. The models I had tested last week specified amounts for species, while differential equations needed concentrations . Last week's test comprised of models that had compartments with size = 1, which is why I didn't realize the error until I checked the results for model 00021.  Now the simulator evaluates the differential equations in terms of concentrations, but reports amounts in the result, just as the expected results in the SBML test suite do. SBML Parser The SBML parser now s...

Week 5

   Progress this Week This week I implemented the Runge-Kutta 4th order method in the simulator. I have also added support for command-line arguments for model filename, duration and step size. The RK4 method is the default for now. Command-line argument support is built using the clap  library. Here's how the simulator can be run:      > cargo run -- -h SBML Simulator in Rust 1.0 Pranav Ballaney <ballaneypranav@gmail.com> A simulator for SBML models. USAGE: sbml-sim [FLAGS] <INPUT> <TIME> <STEPS> FLAGS: -h, --help Prints help information -v Sets the level of verbosity -V, --version Prints version information ARGS: <INPUT> Sets the input file to use <TIME> Simulation duration in seconds <STEPS> Number of steps for numerical integration To check my implementation, I compared the result...

Week 4

  Progress this Week This week I worked implemented the Euler method in the simulator, along with some helper functions in the parsers.  The SBML parser now provides a  . assignments ()  method on an SBML model, which returns initial values of all parameters, species and compartments in a HashMap. This hashmap can then be passed to the MathML parser's  evaluate_node ()  function, in order to evaluate an AST node. The sbml-sim package then simulates the model using the  euler_integrator ()  method. The simulator can be executed as follows:           cargo run <path to model> And produces results like the following:       t S1 S2 S3      0.00 0.0001000 0.0002000 0.0001000      0.10 0.0001050 0.0002025 0.0000975      0.20 0.0001098 0.0002049 0.0000951    ...