Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
biocham
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
21
Issues
21
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Lifeware
biocham
Commits
dd130a98
Commit
dd130a98
authored
Oct 16, 2015
by
Thierry Martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plotting
parent
bbeade81
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
3 deletions
+97
-3
gsl.pl
gsl.pl
+30
-0
library/gsl_solver.c
library/gsl_solver.c
+1
-0
numerical_simulation.pl
numerical_simulation.pl
+17
-0
ode.pl
ode.pl
+2
-2
plot.pl
plot.pl
+44
-0
toc.org
toc.org
+2
-0
toplevel.pl
toplevel.pl
+1
-1
No files found.
gsl.pl
View file @
dd130a98
...
...
@@ -41,6 +41,7 @@ write_gsl(Options) :-
write_jacobian
(
Options
),
write_initial_values
(
Options
),
write_initial_parameter_values
(
Options
),
write_print_headers
(
Options
),
write_print
(
Options
).
write_headers
(
Options
)
:-
...
...
@@ -228,6 +229,35 @@ initial_parameter_values(double p[])
'
).
write_print_headers
(
Options
)
:-
(
memberchk
(
headers
:
Headers
,
Options
)
->
write
(
'
void
print_headers(FILE *csv)
{
fprintf(csv, "#Time'
),
\
+
(
member
(
Header
,
Headers
),
\
+
(
format
(
',\\"~a\\"'
,
[
Header
])
)
),
write
(
'\\n"'
),
write
(
');
}
'
)
;
write
(
'
void
print_headers(FILE *csv)
{
}
'
)
).
write_print
(
Options
)
:-
memberchk
(
equations
:
Equations
,
Options
),
length
(
Equations
,
VariableCount
),
...
...
library/gsl_solver.c
View file @
dd130a98
...
...
@@ -22,6 +22,7 @@ main(void)
double
x
[
VARIABLE_COUNT
];
initial_values
(
x
);
initial_parameter_values
(
parameters
);
print_headers
(
csv
);
while
(
t
<
TIME_FINAL
)
{
int
status
=
gsl_odeiv2_evolve_apply
(
e
,
c
,
s
,
&
sys
,
&
t
,
TIME_FINAL
,
&
h
,
x
);
...
...
numerical_simulation.pl
View file @
dd130a98
...
...
@@ -28,10 +28,12 @@ make_ode_system :-
solve
:-
gather_headers
(
Headers
),
gather_equations
(
Equations
),
gather_initial_values
(
InitialValues
),
gather_initial_parameter_values
(
InitialParameterValues
),
Options
=
[
headers
:
Headers
,
equations
:
Equations
,
initial_values
:
InitialValues
,
initial_parameter_values
:
InitialParameterValues
,
...
...
@@ -46,6 +48,20 @@ solve :-
add_trace
(
'numerical_simulation'
,
Table
).
gather_headers
(
Headers
)
:-
peek_count
(
variable_counter
,
VariableCount
),
VariableMax
is
VariableCount
-
1
,
findall
(
Header
,
(
between
(
0
,
VariableMax
,
VariableIndex
),
variable
(
Molecule
,
VariableIndex
),
format
(
atom
(
Header
),
'[~a]'
,
[
Molecule
])
),
Headers
).
gather_equations
(
Equations
)
:-
peek_count
(
variable_counter
,
VariableCount
),
VariableMax
is
VariableCount
-
1
,
...
...
@@ -96,6 +112,7 @@ enumerate_variables :-
\
+
(
ode
(
Molecule
,
_
),
\
+
(
atom
(
Molecule
),
count
(
variable_counter
,
VariableIndex
),
assertz
(
variable
(
Molecule
,
VariableIndex
))
)
...
...
ode.pl
View file @
dd130a98
...
...
@@ -20,8 +20,8 @@ list_ODE :-
compute_ode
:-
retractall
(
ode
(
_
,
_
)),
\
+
(
item
([
model
:
current_model
,
kind
:
r
ule
,
item
:
Item
]),
r
ule
(
Item
,
Kinetics
,
Reactants
,
Products
),
item
([
model
:
current_model
,
kind
:
r
eaction
,
item
:
Item
]),
r
eaction
(
Item
,
Kinetics
,
Reactants
,
Products
),
\
+
(
kinetics
(
Kinetics
,
Reactants
,
KineticsExpression
),
add_molecules
(
Reactants
,
-
KineticsExpression
),
...
...
plot.pl
0 → 100644
View file @
dd130a98
:-
module
(
plot
,
[
plot
/
0
,
export_plot
/
1
]
).
plot
:-
biocham_command
,
doc
(
'plots the current trace.'
),
export_plot
(
plot
),
process_create
(
path
(
gnuplot
),
[
'-persist'
,
'plot.plot'
],
[]).
export_plot
(
FileTemplate
)
:-
biocham_command
,
doc
(
'
saves the numerical trace of the last simulation into two files:
\\argument{FileTemplate}\\texttt{.csv} and \\texttt{.plot}.
'
),
format
(
atom
(
PlotFile
),
'~a.plot'
,
[
FileTemplate
]),
format
(
atom
(
CsvFile
),
'~a.csv'
,
[
FileTemplate
]),
export_trace
(
CsvFile
),
setup_call_cleanup
(
open
(
PlotFile
,
write
,
Stream
),
export_plot_stream
(
Stream
,
CsvFile
),
close
(
Stream
)
).
export_plot_stream
(
Stream
,
CsvFile
)
:-
format
(
Stream
,
'\c
set style data lines
set format y "%g"
set xrange [*:*]
set yrange [*:*]
set ytics nomirror autofreq
set xtics nomirror
set mxtics default
set key outside Left reverse
set datafile separator ","
plot "~a"
'
,
[
CsvFile
]).
toc.org
View file @
dd130a98
...
...
@@ -55,6 +55,8 @@
- numerical_simulation.pl
*** Traces
- traces.pl
*** Plotting the result of simulations
- plot.pl
* Index
+ index
* Bibliography
...
...
toplevel.pl
View file @
dd130a98
...
...
@@ -139,7 +139,7 @@ command(Command) :-
Command
=
(
_
for
_
)
)
->
add_reaction
(
Command
)
command
(
add_reaction
(
Command
)
)
;
throw
(
error
(
unknown_command
(
Functor
/
Arity
)))
).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment