Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
17748 | georgesk | 1 | CHEMEQ |
2 | ###### |
||
3 | |||
4 | :author: Georges Khaznadar <georgesk@debian.org> |
||
5 | :copyright: (c)2000-2020 |
||
6 | :licence: GPL V2+ |
||
7 | |||
8 | Purpose |
||
9 | ======= |
||
10 | |||
11 | chemeq is a basic standalone filter written in C language, |
||
12 | flex and bison. It inputs strings like: |
||
13 | |||
14 | `2H2 + O2 ---> 2 H2O` |
||
15 | |||
16 | and can outputs LaTeX code and messages about the equilibrium of a |
||
17 | chemical reaction. |
||
18 | |||
19 | .. code-block:: |
||
20 | |||
21 | example:~/src$ echo "2H2 + O2 ---> 2 H2O" | chemeq -lc |
||
22 | 2\,H_{2}\,+\,O_{2}\,\rightarrow\,2\,H_{2}O |
||
23 | OK |
||
24 | example:~/src$ |
||
25 | |||
26 | |||
27 | which means : 2 molecules of dihydrogen react with one molecule of |
||
28 | dioxygen, yelding two water molecules. |
||
29 | The first line, ``"2\,H_{2}\,+\,O_{2}\,\rightarrow\,2\,H_{2}O"`` is a |
||
30 | translation of the equation in LaTeX language. |
||
31 | |||
32 | The second line `"OK"` means that the equation is well equilibrated. |
||
33 | |||
34 | When the input is not successfully parsed, the filter fails with |
||
35 | the exit code `1`. |
||
36 | |||
37 | .. code-block:: |
||
38 | |||
39 | example:~/src$ echo "2H^2 + O2 ---> 2 H2O" | chemeq -lc |
||
40 | ERROR parse error at 4 |
||
41 | example:~/src$ |
||
42 | |||
43 | |||
44 | NOTE : syntax of ions |
||
45 | --------------------- |
||
46 | |||
47 | allthough in some cases, shorter expressions are sucessfully parsed, |
||
48 | it is safer to consider that an "up arrow" (^) must be put before the |
||
49 | charge symbols of an ion. |
||
50 | |||
51 | Examples : `H3O^+, Fe(CN)6^4-, OH^-` |
||
52 | |||
53 | NOTE : square brackets |
||
54 | ---------------------- |
||
55 | |||
56 | Square brackets are allowed outside of a simple chemical notation, as in |
||
57 | `[Fe(CN)6]4-`, and only there. |
||
58 | |||
59 | NOTE : Chemical equilibrium constants |
||
60 | ------------------------------------- |
||
61 | |||
62 | For chemical equilibriums, the constant for the Gulder-Waage equation or |
||
63 | the potential for the Nernst equation can be written at the end of the |
||
64 | equation, surrounded by parentheses. See some examples in ``src/test.1``, and |
||
65 | get them rendered by LaTeX with the command ``src/chemreport`` |
||
66 | |||
67 | This filter can be embedded in educational test systems, in order to |
||
68 | analyze a student's answer to a problem of physics or chemistry. |
||
69 | |||
70 | Feedback is welcome. |
||
71 | |||
72 | Chemeq options |
||
73 | ============== |
||
74 | |||
75 | You can choose chemeq's output by specifying some options. |
||
76 | Valid options are the following : |
||
77 | |||
78 | .. code-block:: |
||
79 | |||
80 | -h outputs a *H*elp message. |
||
81 | -m outputs a *M*inimal output. It allows chemeq to be idempotent, |
||
82 | i.e. the command 'chemeq | chemeq' is equivalent to 'chemeq'. |
||
83 | -l outputs a *L*aTeX string representing the chemical equation. |
||
84 | -c outputs a message giving informations about the *C*onservation of |
||
85 | elements and charges in the equation. 'OK' means that both elements |
||
86 | and electric charges are balanced. |
||
87 | -w outputs the LaTeX string representing the Gulder-*W*aage equation |
||
88 | related to the input chemical equation, or the Nernst equation, |
||
89 | if the input equation is a redox semi-equation. |
||
90 | -n outputs a *N*ormalized string accounting for the input equation. |
||
91 | Two chemical equations having the same normalized string are chemically |
||
92 | equivalent, even if the molecules are scrambled around and the |
||
93 | coefficient are not equal but proportionnal. |
||
94 | |||
95 | |||
96 | ``chemeq`` defaults to ``chemeq -mlcwn``. |
||
97 | |||
98 | CHEMICAL DATA |
||
99 | ============= |
||
100 | |||
101 | Chemeq comes with a buil-in data set. The molar mass of elements come |
||
102 | from https://webbook.nist.gov/ |
||
103 | |||
104 | INSTALLATION |
||
105 | ============ |
||
106 | |||
107 | To build chemeq, run '``make``' in the main chemeq directory, to install it |
||
108 | with its man page, run '``make install``' in the main directory. |
||
109 | |||
110 | |||
111 | TEST MODE and DEMO |
||
112 | ================== |
||
113 | |||
114 | If you modifiy the source code, it is possible to test its conformance |
||
115 | to previous versions by running '``make test``' in the main directory. |
||
116 | |||
117 | If '``make test``' replies 'OK' for all items, and if you have latex |
||
118 | and xdvi installed, you can run '``make demo``' to see some examples |
||
119 | of typesetting. |