|
1 | 1 | within BioChem;
|
2 | 2 |
|
3 | 3 | package Math
|
4 |
| - extends Icons.Library; |
5 |
| - function log10 = Modelica.Math.log10 annotation( |
6 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10})), |
7 |
| - Diagram(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}))); |
| 4 | + extends BioChem.Icons.Library; |
8 | 5 |
|
9 |
| - function factorial "factorial function, product of all positive integers less than or equal to n" |
10 |
| - input Integer n "input value"; |
11 |
| - output Integer y "output value"; |
12 |
| - protected |
13 |
| - Integer i; |
14 |
| - algorithm |
15 |
| - y := n; |
16 |
| - i := n; |
17 |
| - while i > 1 loop |
18 |
| - i := i - 1; |
19 |
| - y := y * i; |
20 |
| - end while; |
21 |
| - annotation( |
22 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
23 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "n!", fontName = "Arial")})); |
24 |
| - end factorial; |
25 |
| - |
26 |
| - function sec "secant trigonometric function" |
27 |
| - input Modelica.Units.SI.Angle alpha "input angle"; |
28 |
| - output Real y "output value"; |
29 |
| - algorithm |
30 |
| - y := 1 / cos(alpha); |
31 |
| - annotation( |
32 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
33 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "sec( )", fontName = "Arial")})); |
34 |
| - end sec; |
35 |
| - |
36 |
| - function cot "Cotangent trigonometric function" |
37 |
| - input Modelica.Units.SI.Angle alpha "input angle"; |
38 |
| - output Real y "output value"; |
39 |
| - algorithm |
40 |
| - y := 1 / tan(alpha); |
41 |
| - annotation( |
42 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
43 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "cot( )", fontName = "Arial")})); |
44 |
| - end cot; |
45 |
| - |
46 |
| - function csc "cosecant trigonometric function" |
47 |
| - input Modelica.Units.SI.Angle alpha "input angle"; |
48 |
| - output Real y "output value"; |
49 |
| - algorithm |
50 |
| - y := 1 / sin(alpha); |
51 |
| - annotation( |
52 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
53 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "csc( )", fontName = "Arial")})); |
54 |
| - end csc; |
55 |
| - |
56 |
| - function sech "hyperbolic secant trigonometric function" |
57 |
| - input Modelica.Units.SI.Angle alpha "input angle"; |
58 |
| - output Real y "output value"; |
59 |
| - algorithm |
60 |
| - y := 1 / cosh(alpha); |
61 |
| - annotation( |
62 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
63 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "sech( )", fontName = "Arial")})); |
64 |
| - end sech; |
65 |
| - |
66 |
| - function csch "hyperbolic cosecant trigonometric function" |
67 |
| - input Modelica.Units.SI.Angle alpha "input angle"; |
68 |
| - output Real y "output value"; |
69 |
| - algorithm |
70 |
| - y := 1 / sinh(alpha); |
71 |
| - annotation( |
72 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
73 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "csch( )", fontName = "Arial")})); |
74 |
| - end csch; |
75 |
| - |
76 |
| - function coth "hyperbolic cotangent trigonometric function" |
77 |
| - input Modelica.Units.SI.Angle alpha "input angle"; |
78 |
| - output Real y "output value"; |
79 |
| - algorithm |
80 |
| - y := 1 / tanh(alpha); |
81 |
| - annotation( |
82 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
83 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "coth( )", fontName = "Arial")})); |
84 |
| - end coth; |
85 |
| - |
86 |
| - function root |
87 |
| - input Real n "degree"; |
88 |
| - input Real a "value"; |
89 |
| - output Real y "output value"; |
90 |
| - algorithm |
91 |
| - y := a ^ (1 / n); |
92 |
| - annotation( |
93 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
94 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, textString = "root", fontName = "Arial")})); |
95 |
| - end root; |
96 |
| - |
97 |
| - function piecewise "Piecewise function that corresponds to the SBML piecewice definition" |
98 |
| - input Real[:] value "Input values in the form {value1,value2,...,valueN,valueN+1}."; |
99 |
| - input Boolean[:] condition "Input conditions in the form {condition1,condition2,...,conditionN}. Not more than one condition is allowed to be true at any given time."; |
100 |
| - output Real y "Output value selected from the list of inputs."; |
101 |
| - protected |
102 |
| - parameter Integer nin = size(condition, 1); |
103 |
| - algorithm |
104 |
| - y := value[nin + 1]; |
105 |
| - for i in 1:nin loop |
106 |
| - if condition[i] then |
107 |
| - y := value[i]; |
108 |
| - end if; |
109 |
| - end for; |
110 |
| - annotation( |
111 |
| - Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, grid = {10, 10})), |
112 |
| - Icon(coordinateSystem(extent = {{-100.0, -100.0}, {100.0, 100.0}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(origin = {0.0, -0.0}, fillPattern = FillPattern.Solid, extent = {{-100.0, -30.0}, {100.0, 30.0}}, textString = "piecewise()", fontName = "Arial")})); |
113 |
| - end piecewise; |
114 | 6 | annotation(
|
115 |
| - Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, grid = {10, 10})), |
116 |
| - Icon(coordinateSystem(extent = {{-100, 100}, {100, -100}}, preserveAspectRatio = true, grid = {10, 10}), graphics = {Text(origin = {1.40855, -8.72502}, fillPattern = FillPattern.Solid, extent = {{-81.4085, -69.705}, {56.8628, 38.725}}, textString = "f(x)", fontName = "Arial")}), |
117 | 7 | Documentation(info = "<html>
|
118 | 8 | <h1>Math</h1>
|
119 | 9 | A number of mathematical functions are used in pathway models. Some of these can be found in
|
|
0 commit comments