Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lifeware
biocham
Commits
38ac48f9
Commit
38ac48f9
authored
Jan 16, 2020
by
FAGES Francois
Browse files
correction bug dans list_dimensions sur dimension des nombres
parent
5299bb21
Changes
2
Hide whitespace changes
Inline
Side-by-side
biocham_jupyter/guinbextension/src/config/workflows/commands.py
View file @
38ac48f9
...
...
@@ -30,6 +30,8 @@ commands = [
"check_multistability"
,
"check_oscillations"
,
"cleanup_ctl"
,
"clear_dimension"
,
"clear_dimensions"
,
"clear_initial_state"
,
"clear_model"
,
"clear_variation"
,
...
...
units.pl
View file @
38ac48f9
:-
module
(
units
,
[
list_dimensions
/
0
,
set_dimension
/
3
,
list_dimensions
/
0
clear_dimensions
/
0
,
clear_dimension
/
1
]
).
...
...
@@ -12,28 +14,35 @@
% store declared units
:-
dynamic
(
k_unit
/
3
).
:-
biocham_silent
(
clear_model
).
set_dimension
(
P
,
U
,
V
)
:-
biocham_command
,
doc
(
'Declare dimension time^\\argument{U} and volume^\\argument{V}
for parameter \\argument{P}'
),
type
(
P
,
parameter_name
),
type
(
U
,
number
),
type
(
V
,
number
),
retractall
(
k_unit
(
P
,
_
,
_
)),
assertz
(
k_unit
(
P
,
U
,
V
)).
%! list_dimensions.
%
% biocham command
%
% Infers dimensions (time and volume, without units) of all parameters of the model.
%
% Molecular concentration have dimension volume^-1
% Reaction rates (and influence forces) have dimension time^-1
%
% A dimension is encoded by a couple (time exponent, volume exponent)
% No dimension is encoded by the couple (0, 0)
% Any dimension is encoded by a variable
% Numbers have any dimension
:-
biocham_silent
(
clear_model
).
list_dimensions
:-
biocham_command
,
doc
(
'
Checks the (time) dimensions of all parameters of the current model.
Performs a dimensional analysis of the current model. Infers the time and volume dimensions of all parameters.
The dimension of a molecular concentration is volume^-1.
The dimension of a reaction rate or influence force is time^-1.
The dimensions are considered without units.
\\begin{example}
\\trace{
biocham: MM(v, k) for A => B.
biocham: parameter(k =
1
, v =
1
).
biocham: parameter(k =
2
, v =
3
).
biocham: list_dimensions.
}
\\end{example}
...
...
@@ -54,6 +63,30 @@ list_dimensions :-
print_message
(
error
,
failed_dimension
(
T
,
E
)).
set_dimension
(
P
,
U
,
V
)
:-
biocham_command
,
doc
(
'Declare dimension time^\\argument{U} . volume^\\argument{V}
for parameter \\argument{P}'
),
type
(
P
,
parameter_name
),
type
(
U
,
number
),
type
(
V
,
number
),
retractall
(
k_unit
(
P
,
_
,
_
)),
assertz
(
k_unit
(
P
,
U
,
V
)).
clear_dimensions
:-
biocham_command
,
doc
(
'Clear all declared dimensions'
),
retractall
(
k_unit
(
_
,
_
,
_
)).
clear_dimension
(
P
)
:-
biocham_command
,
doc
(
'Clear declared dimension for parameter \\argument{P}'
),
type
(
P
,
parameter_name
),
retractall
(
k_unit
(
P
,
_
,
_
)).
check_set_dim
([]).
check_set_dim
([((
U
,
V
)
-
P
)
|
L
])
:-
...
...
@@ -110,11 +143,13 @@ find_parameter_dim(-Y, Dim, L) :-
!,
find_parameter_dim
(
Y
,
Dim
,
L
).
%
FIXME? force dimensionless exponentiation
%
forces exponents to be dimensionless
find_parameter_dim
(
X
^
Y
,
(
DimT
,
DimV
),
L
)
:-
!,
find_parameter_dim
(
X
,
(
DT
,
DV
),
L
),
find_parameter_dim
(
Y
,
0
,
L
),
find_parameter_dim
(
Y
,
(
DYT
,
DYV
),
L
),
DYT
#=
0
,
DYV
#=
0
,
(
(
number
(
Y
),
...
...
@@ -131,7 +166,7 @@ find_parameter_dim(X ^ Y, (DimT, DimV), L) :-
DT2
=
DT
,
DV2
=
DV
;
Y
=
1
/
Z
,
Y
=
1
/
Z
,
DT1
=
DT
,
DV1
=
DV
,
DT2
=
DimT
,
...
...
@@ -158,7 +193,7 @@ find_parameter_dim(X ^ Y, (DimT, DimV), L) :-
)
).
%
FIXME? correct? force Dim=0?
%
forces Dim=0 for other functions than addition and multiplication
find_parameter_dim
(
log
(
X
),
(
DimT
,
DimV
),
L
)
:-
!,
nb_setval
(
current_dim_term
,
log
(
X
)),
...
...
@@ -187,11 +222,16 @@ find_parameter_dim(cos(X), (DimT, DimV), L) :-
DimV
#=
0
,
find_parameter_dim
(
X
,
(
DimT
,
DimV
),
L
).
find_parameter_dim
(
N
,
(
DimT
,
DimV
),
_
)
:-
%find_parameter_dim(N, (DimT, DimV), _) :-
% number(N),
% !,
% DimT #= 0,
% DimV #= 0.
%
%FF Numbers may take any dimension
find_parameter_dim
(
N
,
_Dim
,
_
)
:-
number
(
N
),
!,
DimT
#=
0
,
DimV
#=
0
.
!.
find_parameter_dim
(
'Time'
,
(
DimT
,
DimV
),
_
)
:-
!,
...
...
@@ -200,7 +240,7 @@ find_parameter_dim('Time', (DimT, DimV), _) :-
DimV
#=
0
.
find_parameter_dim
(
X
*
Y
,
(
DimT
,
DimV
),
L
)
:-
!,
!,
find_parameter_dim
(
X
,
(
DT1
,
DV1
),
L
),
find_parameter_dim
(
Y
,
(
DT2
,
DV2
),
L
),
nb_setval
(
current_dim_term
,
X
*
Y
),
...
...
@@ -220,13 +260,6 @@ find_parameter_dim(if(then(_C, else(A, B))), Dim, L) :-
find_parameter_dim
(
A
,
Dim
,
L
),
find_parameter_dim
(
B
,
Dim
,
L
).
find_parameter_dim
(
P
,
(
DimT
,
DimV
),
L
)
:-
parameter_value
(
P
,
_
),
!,
member
(((
DT
,
DV
)
-
P
),
L
),
DimT
#=
DT
,
DimV
#=
DV
.
find_parameter_dim
([
M
],
(
DimT
,
DimV
),
_
)
:-
!,
nb_setval
(
current_dim_term
,
[
M
]),
...
...
@@ -240,6 +273,21 @@ find_parameter_dim(M, (DimT, DimV), _) :-
DimT
#=
0
,
DimV
#=
-
1
.
find_parameter_dim
(
P
,
(
DimT
,
DimV
),
L
)
:-
(
(
parameter_value
(
P
,
_
),
%FF should check the expression
member
(((
DT
,
DV
)
-
P
),
L
)
)
->
DimT
#=
DT
,
DimV
#=
DV
;
true
%FF the dimensions for P should be added to L (using a difference list)
).
write_dimensions
([]).
...
...
@@ -257,10 +305,10 @@ write_dimensions([((DT, DV) - P) | L]) :-
prolog
:
message
(
constant_species
)
-->
[
'
some species are constant
in this model'
-
[]].
[
'
There are molecular species without kinetics
in this model'
-
[]].
prolog
:
message
(
no_satisfy
)
-->
[
'Could not satisfy
time units
constraints on parameter dimensions.'
-
[]].
[
'Could not satisfy
all
constraints on parameter dimensions.'
-
[]].
prolog
:
message
(
failed_dimension
(
T
,
E
))
-->
[
'Failed on ~w in ~w~na kinetic expression which should be time^-1'
-
[
T
,
E
]].
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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