[LON-CAPA-users] Titration problem--extracting limited data from an array

Jim Maxka lon-capa-users@mail.lon-capa.org
Thu, 24 May 2007 09:39:37 -0700

Hi Robley -- Didn't I send the code to you last year that does this?  I 
think the solution is to pick data in the range of volumes that are 
realistic to the titration.
--- Jim

Robley Light wrote:
> I'm hoping someone can suggest a better way to handle this, either by coding
> or by a mathmatical manipulation.
> Is this something that maxima could do?
> I found the code for plotting titration curves at Tom O'Havers' web site:
> monoprotic acid: http://www.wam.umd.edu/~toh/models/TitrationDemo.html
> triprotic acid: http://www.wam.umd.edu/~toh/models/Titration.html
> So this is easy to code for gnuplot.  For example, in the problem
> res/fsu/GeneralChemLib/Lab/Titration/StandardizeBase.problem
> I generate the arrays to be plotted as follows:
> <script type="loncapa/perl">
> $VolA=&random(10,80,10);
> $ConcA=&random(0.01,0.08,0.0001);
> $mmolA=$VolA*$ConcA;
> $mmolB=$mmolA;
> $VolBeq=&random(22.4,27.6,0.1);
> $ConcB=$mmolB/$VolBeq;
> $pKa=-1;
> $pKw=14;
> $Ka=10**-$pKa;
> $Kw=10**-$pKw;
> for ($pH=0; $pH<=12.99; $pH+=0.33){
>     push @pH, $pH;
>   $Hconc = 10**-$pH;
>     push @Hconc, $Hconc;
>   $VolB =
> -$VolA*(($Hconc**3+$Ka*$Hconc**2-($Kw+$Ka*$ConcA)*$Hconc-$Kw*$Ka)/($Hconc**3
> +($Ka+$ConcB)*$Hconc**2+($Ka*$ConcB-$Kw)*$Hconc-$Ka*$Kw));
>     push @VolB, $VolB;
> }</script>
> As O'Haver points out, this is an "inverse" solution, where [H+] is the
> independent variable and the volume of base is the dependent variable, even
> though one is plotting the other way.
> This array gives a set of values in @pH and @VolB that vary in regular
> increments of $pH (of 0.33 units), which is okay for plotting purposes. (I
> could make the increments as small as I like).
> What I would like to do for a different prelab problem is to generate array
> data that is in regular increments of $VolB (say 0.05 mL), or roughly if not
> exactly regular increments,--which is more like data one is likely to
> generate in a lab titration. I want to present these array values in a table
> rather than in a plot.
> Short of solving the equation specifically for [H+] as a function of VolB
> (probably possible in this case, very complicated in the di- and tri-protic
> acid cases), is there a way to extract such data from the arrays generated
> by the above code?  My Perl knowledge is relatively limited.
> Robley
> *************************************************************
> Robley J. Light                  Professor Emeritus of Chemistry and
> Biochemistry
> Department of Chemistry          Phone:   (850) 644-3844
>    and Biochemistry              Email:  rlight@chem.fsu.edu  
> Florida State University         Fax:      (850) 644-8281
> Tallahassee, FL 32306-4390    Home Page:
> http://www.chem.fsu.edu/editors/rlight