The Mathematica Journal
Departments
Feature Articles
Columns
New Products
New Publications
Classifieds
Calendar
News Bulletins
Mailbox
Letters
Write Us
About the Journal
Staff and Contributors
Submissions
Subscriptions
Advertising
Back Issues
Home
Download this Issue

A Simple Chemical Equilibrium Calculation: Phosphoric Acid

The initial step is to load the BioEqCalc package.

[Graphics:../Images/index_gr_41.gif]

Example 1.

The first step in a chemical equilibrium calculation is to define the chemical reactions comprising the system of reactions. This is done by defining the variable system.

[Graphics:../Images/index_gr_42.gif]

Note that double quotes are used at the beginning and end of these four reactions and that commas serve to separate the reactions from each other. It is essential to allow at least one space between the equal signs and the species as well as between the species themselves. Charges are written as a part of the chemical species and are specified as in the above example (i.e., use -2 and not 2-). In the absence of a charge, the charge is assumed to be zero.

Next, the function makeInput[] is used to extract essential information from the variable system.

[Graphics:../Images/index_gr_43.gif]
[Graphics:../Images/index_gr_44.gif]
[Graphics:../Images/index_gr_45.gif]

Although not shown in this output, the transpose of the stoichiometric number matrix [Graphics:../Images/index_gr_46.gif] and the vectors containing the species and the charges of the species have been automatically generated. These can be displayed.

[Graphics:../Images/index_gr_47.gif]
[Graphics:../Images/index_gr_48.gif]
[Graphics:../Images/index_gr_49.gif]
[Graphics:../Images/index_gr_50.gif]

Note that the ions [Graphics:../Images/index_gr_51.gif]and [Graphics:../Images/index_gr_52.gif] have been automatically added to the list of species. This has been done so that appropriate amounts of these species can be added to the solution later, if necessary, to maintain electrical neutrality. In the above example, [Graphics:../Images/index_gr_53.gif] was present as a reactant. If this was not the case, it would also have been added to the list of species in the system.

The next step is to provide the data needed to define the problem. This is done by giving the following parameters to the function reactions[].

[Graphics:../Images/index_gr_54.gif] [Graphics:../Images/index_gr_55.gif]
[Graphics:../Images/index_gr_56.gif] [Graphics:../Images/index_gr_57.gif]
[Graphics:../Images/index_gr_58.gif] [Graphics:../Images/index_gr_59.gif]
[Graphics:../Images/index_gr_60.gif] [Graphics:../Images/index_gr_61.gif]
[Graphics:../Images/index_gr_62.gif] [Graphics:../Images/index_gr_63.gif]
[Graphics:../Images/index_gr_64.gif] [Graphics:../Images/index_gr_65.gif]
[Graphics:../Images/index_gr_66.gif] [Graphics:../Images/index_gr_67.gif]
[Graphics:../Images/index_gr_68.gif] [Graphics:../Images/index_gr_69.gif]
[Graphics:../Images/index_gr_70.gif] [Graphics:../Images/index_gr_71.gif]
[Graphics:../Images/index_gr_72.gif] [Graphics:../Images/index_gr_73.gif]
[Graphics:../Images/index_gr_74.gif] [Graphics:../Images/index_gr_75.gif]
[Graphics:../Images/index_gr_76.gif] [Graphics:../Images/index_gr_77.gif]
[Graphics:../Images/index_gr_78.gif] [Graphics:../Images/index_gr_79.gif]
[Graphics:../Images/index_gr_80.gif] [Graphics:../Images/index_gr_81.gif]
[Graphics:../Images/index_gr_82.gif] [Graphics:../Images/index_gr_83.gif]

In the following example, constrainedSpecies has no entries and constpXa is also empty. Note that nt, species, and charge are generated by makeInput[]. The parameters reactants, pseudo, and ntprime have been left empty. The output should be used to check the accuracy of the data that has been entered.

[Graphics:../Images/index_gr_84.gif]
[Graphics:../Images/index_gr_85.gif]
[Graphics:../Images/index_gr_86.gif]
[Graphics:../Images/index_gr_87.gif]
[Graphics:../Images/index_gr_89.gif]
[Graphics:../Images/index_gr_90.gif]
[Graphics:../Images/index_gr_91.gif]
[Graphics:../Images/index_gr_92.gif]

The solution of the equilibrium problem is obtained by using ionicEquilib[]. All of the parameters have already been defined with the exception of the following.

[Graphics:../Images/index_gr_93.gif] [Graphics:../Images/index_gr_94.gif]

The vector containing the molalities m of the species and the ionic strength I at equilibrium are calculated.

[Graphics:../Images/index_gr_95.gif]
[Graphics:../Images/index_gr_96.gif]
[Graphics:../Images/index_gr_97.gif]
[Graphics:../Images/index_gr_98.gif]
[Graphics:../Images/index_gr_99.gif]


Converted by Mathematica   

[Article Index] [Prev Page][Next Page]