libpHtools: The pHtools C API
1.0.0
Access pHtools XML databases and compute complex acid/base buffer properties.
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Pages
pHtools.h
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 2011,2013 Daniel P. Dougherty
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 3.0 of the License, or (at your option) any later version.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
*/
20
26
#ifndef _pHtools_h
27
#define _pHtools_h
28
29
#include <math.h>
30
#include <stdlib.h>
31
#include <stdio.h>
32
#include <string.h>
33
34
35
#define MAX_TRACKED_PHDERIVS 20
36
#define MAX_TRACKED_SPECIES 20
37
38
39
/*Bisection*/
40
/*#define CB_ROOT_METHOD 0
41
*/
42
/*Brent -- usually many fewer iterations to converge.*/
43
#define CB_ROOT_METHOD 1
44
45
/*
46
Certainly more than enough space for typical fermentation end-products and up
47
to some modest length peptides or polyomers. Increase this number
48
if your molecules have more dissociable groups in your application.
49
*/
50
#define MAX_BUFFERIONS 20
51
52
/*
53
A solution can have thousands of components but this is the number we are willing
54
to model. Increase if you need to.
55
*/
56
#define MAX_SOLCOMPS 10
57
58
/*
59
A solution can be a mixture of other components. This is the maximum number of
60
nested (contained) solutions.
61
*/
62
#define MAX_BUFFERCONTAINS 10
63
64
#define MAX_BRENT_ITER 100
65
#define MAX_BRENT_EPS 3.0e-8
66
67
#define MAXBUFFSOL 20
68
#define LYTES 321
69
70
/*
71
We define some types to hold the "tableaus" describing the buffers according
72
to the published pHtools framework.
73
*/
74
typedef
struct
{
75
int
npKa;
76
double
pKa[MAX_BUFFERIONS];
77
int
npKb;
78
double
pKb[MAX_BUFFERIONS];
79
double
SaltType;
80
}
BUFFERION
;
81
85
typedef
struct
{
86
int
ncomp;
87
char
*name[MAX_SOLCOMPS];
88
double
value[MAX_SOLCOMPS];
89
}
BUFFERLIST
;
90
91
95
typedef
struct
{
96
int
charge;
/*The charge of the ion that you want to track*/
97
char
externvar[256];
/*The client program's variable name*/
98
double
*externval;
/*The client program's variable value*/
99
double
conc;
/*The molar concentration*/
100
}
SPECIES
;
101
102
106
typedef
struct
{
107
char
name[256];
108
char
nickname[256];
109
char
comment[256];
110
char
createdby[256];
111
char
createdon[256];
112
char
* externvar;
113
char
* externval;
114
double
conc;
115
BUFFERLIST
contains;
116
int
ngroups;
117
BUFFERION
group[MAX_BUFFERIONS];
118
int
nspecies;
119
SPECIES
species
[MAX_TRACKED_SPECIES];
120
}
BUFFERCOMP
;
121
122
123
127
typedef
struct
{
128
int
ncomp;
129
BUFFERCOMP
comp[MAX_SOLCOMPS];
130
char
name[256];
/*This is the unique xpp name identifying this buffer solution.*/
131
char
pHnam[256];
132
double
*pHval;
133
double
initpH;
134
char
dpHdtnam[256];
135
double
*dpHdtval;
136
char
bcapnam[256];
137
double
initBcap;
138
char
istrnam[256];
139
double
initIstr;
140
char
cbnam[256];
141
double
initCb;
142
int
dospecies;
143
int
doionicstr;
144
int
doCb;
145
}
BUFFERSOL
;
146
147
148
void
init_buffer_database
(
void
);
149
void
create_buffersol
(
char
*name);
150
void
deblank
(
char
*s1);
151
int
find_buffersol
(
char
*name);
152
void
show_all_buffersols
(
void
);
153
154
void
setpHtoolsValueSetter
(
int
(*functionPtr)(
char
*name,
double
value));
155
void
setpHtoolsValueGetter
(
int
(*functionPtr)(
char
*name,
double
* value));
156
void
setpHtoolsValueInitializer
(
int
(*functionPtr)(
char
*name,
double
value));
157
void
setpHtoolsLogFile
(FILE *logger);
158
159
void
strupr
(
char
*s);
160
161
int
pHtoolsprintf
(
char
*fmt, ...);
162
void
mix_buffersol
(
char
*name,
char
*ord_pairs);
163
void
add_buffersol
(
char
*name,
char
*ord_pairs);
164
double
initialize_pH
(
char
*name);
165
double
initialize_ionicstr
(
char
*name);
166
double
initialize_Cb
(
char
*name);
167
double
initialize_buffcap
(
char
*name);
168
void
track_buffersol
(
char
*name,
char
*ord_pairs);
169
void
track_species
(
char
*name,
char
* ord_triplets);
170
void
track_ionic_strength
(
char
*name,
char
* istrnam);
171
void
track_Cb
(
char
*name,
char
* cbnam);
172
void
track_buffcap
(
char
*name,
char
* bcapnam);
173
void
track_pH(
char
*name,
char
* pHnam,
char
* dpHdtnam);
174
175
int
findspecies
(
int
charge,
SPECIES
*sp,
int
nsp);
176
BUFFERSOL
*
mksol
(
BUFFERLIST
*sollist);
177
void
dilutesol
(
BUFFERSOL
*SOL,
double
amount);
178
void
mixintosol
(
BUFFERSOL
*SOL1,
BUFFERSOL
*SOL2,
double
weight);
179
void
addsol
(
BUFFERSOL
*SOL1,
BUFFERSOL
*SOL2);
180
int
struct_cmp_by_nickname
(
const
void
*a,
const
void
*b);
181
void
sortandwaterlast
(
BUFFERSOL
*SOL1);
182
void
listcpy
(
BUFFERLIST
*dest,
BUFFERLIST
*src);
183
void
groupcpy
(
BUFFERION
*dest,
BUFFERION
*src);
184
void
speciescpy
(
SPECIES
*dest,
SPECIES
*src);
185
void
compcpy
(
BUFFERCOMP
*dest,
BUFFERCOMP
*src);
186
double
initpHCall
(
BUFFERSOL
*SOL,
double
x1,
double
x2,
double
tol);
187
double
initpHBisection
(
BUFFERSOL
*SOL,
double
x1,
double
x2,
double
xacc);
188
double
initpHBrent
(
BUFFERSOL
*SOL,
double
x1,
double
x2,
double
tol);
189
double
Cb
(
BUFFERSOL
*SOL,
double
pH,
int
doupdate);
190
double
ionicstr
(
BUFFERSOL
*SOL,
double
pH,
int
doupdate);
191
double
buffcapeval
(
BUFFERSOL
*SOL,
double
pH,
int
doupdate);
192
double
dpHdt
(
BUFFERSOL
*SOL,
double
pH,
BUFFERLIST
*derivs);
193
double
dCbdt
(
BUFFERSOL
*SOL,
double
pH,
BUFFERLIST
*derivs);
194
void
showBuffer
(
BUFFERCOMP
*C);
195
void
showSol
(
BUFFERSOL
*C);
196
void
species
(
BUFFERSOL
*SOL,
double
pH,
int
doupdate);
197
double
dCbdH
(
BUFFERSOL
*SOL,
double
pH);
198
BUFFERSOL
*
getBufferSolution
(
int
j);
199
200
201
BUFFERCOMP
* WATER;
202
203
/*
204
Define and statically allocate the needed storage here.
205
*/
206
BUFFERSOL
*buffersol[MAXBUFFSOL];
207
208
#endif
Generated by
1.8.3.1