mc.sm 1.94 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
// Mg + 2Cl <--> Mg+2 + 2Cl-
// dxp/gxn 04/10/04

// ctmc model
ctmc

// constants
const int N1; // number of Mg molecules
const int N2; // number of Cl molecules


// Cl and Cl- module
module cl
cl : [0..N2] init N2;
// total number of Cl and Cl- molecules is fixed at N2
// cl is the number of Cl molecules
// therefore N2-cl is the number of Cl- molecules
// reactions with Cl
[e1] cl>0 -> cl : (cl'=cl-1);
[e2] cl>0 -> cl : (cl'=cl-1);
// reactions with CL-
[e3] cl<N2 -> (N2-cl) : (cl'=cl+1);
[e4] cl<N2 -> (N2-cl) : (cl'=cl+1);
endmodule

// Mg, Mg+ and Mg+2 module
module mg
mg : [0..N1] init N1;
mg_p : [0..N1] init 0;
// total number of Mg and Mg+ and Mg+2 molecules is fixed at N1
// mg is the number of Mg molecules
// mg_p is the number of Mg molecules
// therefore N1-(mg+mg+) gives the number of Mg+2 molecules
[e1] mg>0 & mg_p<N1 -> mg : (mg'=mg-1) & (mg_p'=mg_p+1);
[e2] mg_p>0 -> mg_p : (mg_p'=mg_p-1);
[e3] mg_p>0 & mg<N1 -> mg_p : (mg'=mg+1) & (mg_p'=mg_p-1);
[e4] mg_p+mg<N1 -> N1-(mg_p+mg) : (mg_p'=mg_p+1);
endmodule


// base rates
const double e1rate = 10; // Mg + Cl --> Mg+ + Cl-
const double e2rate = 100; // Mg+ + Cl --> Mg+2 + Cl-
const double e3rate = 50; // Mg+ + Cl- --> Mg + Cl
const double e4rate = 5; // Mg+2 + Cl- --> Mg+ + Cl-

// module representing the base rates of reactions
module base_rates
dummy : bool; // dummy variable
[e1] true -> e1rate : true;
[e2] true -> e2rate : true;
[e3] true -> e3rate : true;
[e4] true -> e4rate : true;
endmodule

// reward structur: percentage of Mg molecules
rewards "percentage_mg"
true : 100*mg/N1;
endrewards

// reward structur: percentage of Mg+ molecules
rewards "percentage_mgplus"
true : 100*mg_p/N1;
endrewards

// reward structur: percentage of Mg+2 molecules
rewards "percentage_mgplus2"
true : max(100*(N1-(mg_p+mg))/N1,0);
endrewards