rasmusrendal / crnsimul Goto Github PK
View Code? Open in Web Editor NEWAn application for simulating Chemical Reaction Networks
License: GNU General Public License v3.0
An application for simulating Chemical Reaction Networks
License: GNU General Public License v3.0
Let's make the cleanest code yet. It's probably a good "getting started with cmake" issue.
When you sum n floating points numbers, the errors accumulate at a rate of n. There are compensated summation methods that fix such things.
Although the error mostly won't accumulate in the Euler evaluator due to the fact that it mostly converges to a fixed point, it is still deeply wrong to just use +=
in large floating point summations. Kahan summation should probably be used to compensate for any floating point errors.
Reaction constants are required to use, for instance, the square root network. The functionality can be replicated by adding the reaction twice, but that is super ugly.
Implement a realtime plotter
In POSIX, you can start a executable file with #!/usr/bin/bash
to indicate the file is to be executed in bash. Ideally, we should be able to do the same with the chemilang interpreter. But currently, it tries to interpret the shebang, leading to parser errors.
Ideally, we should just add comments that start with #
, but we could also just make a special case to ignore shebangs.
It's frankly just confusing to see the help menu printed, when you've supplied all the right arguments
If we don't have live plotting, we need to have some other way to view what's going on in a non-terminating CRN. Writing to stdout would be a pretty easy way to do that.
Ideally, plots should only happen when using the -g
flag. Otherwise, you could for example print to stdout.
This will allow for running the software headlessly, which will allow me to do some cool things
Current plotting uses iterations as x-values, whereas it should use "time".
Time is equivalent to step*iterations.
If you call the program with -h
, --help
, or just any invalid arguments, it should present the user a help menu, that documents how the utility is used
Doxygen is a super neat framework for doing a lot of documentation. We just need a doxyfile, a bit of gitignore, and some doxygen comments to get started
The random walk example, for instance, goes way too fast for the visualization to be useful. We should probably slow it down by default, and then add a flag for running it in unconstrained mode. This will probably also be nicer on the user's CPU.
I think we are at a place now where we can start implementing the high-level compiler. I also think it would be nice if it wasn't me who had to do that.
I think that for the very first version, we just need to accept the following code snippet, or variations thereof:
module main {
private: [a,b];
output: [c];
concentrations: {
a := 5;
b := 3;
}
reactions: {
a + b -> a + b + c;
c -> 0;
}
}
It should compile to
a := 5;
b := 3;
a + b -> a + b + c;
c -> 0;
The main challenge here is integrating our new code with the CRN parser code without copy-pasting. This will probably require changing the CRN code a lot. (Good thing we have unit tests)
At least you won't have to make up a data structure for module and such (yet)
At the moment, the only way the Markov evaluator will mark itself as "finished" is if there are no more reactions possible in the current state. However, most useful CRNs end up in some sort of equilibrium, which the Markov evaluator will just sit on infinitely.
So we either neet some sort of way to detect that we've reached an equilibrium (might be the halting problem in disguise), or just set a cap on the iterations we're willing to perform.
This is quite difficult. Maybe I should create my own GitHub action, as all the existing ones are bad
For our basic reactions with only two or three species, it's fine that they are all plotted. But if you create big networks, it would be nice if we could say chemilang -p c mul.chem
, and only get one of the values. This could eventually be part of the compilation process, adding this argument to the shebang.
The format could be something akin to -p c,a,i,u
, ie. a commaseperated list of species names
There are deep copies everywhere, mostly based on gut feeling. The unit tests should be expanded, so we can remove where they are not used.
It should be pretty easy to detect when the total change in concentrations is below some very small value (000.1), and terminate the simulation there.
Print the result to a csv file.
This makes it possible to run the out.crn files generated form chemilang directly.
It will crash if there are no initial concentrations in the CRN, and the error message will not be helpful either.
But since reactions of the form 0 -> c
are possible, CRNs with no concentrations at all should be possible to define too.
There should be a unit test that tests the Euler Evaluator, if it works with all the stdlib functions we have in the report thus far.
does not output any text to console when a crn is passed
When the slope of the tangent line is calculated very weird things happen. I have tried calling GetNextNetworkState manually and the slopes on the graph for sure have a bigger slope than 0.00001
We need dat juicy 100% code coverage
Probably gnuplot or something of the sort
The main function itself should have as little code as possible. But currently it's giant. And the structure of it isn't great either. A rule of thumb for nice, readable code is having at most 2 levels of indentation in your function. We're at 6.
As a sidenote, if you're interested in writing better code, the books "Clean Code" is one I can recommend. Alternatively, Humble Bundle currently has "The art of readable code" for โฌ1, together with a bunch of other books.
Ideally, you should be able to supply a "step" value for the euler evaluator, and a threshold for when the simulation stops.
Det er floating point operations. GPU'er kan go fast med floating point operations.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.