Subject: Chemical Kinetics Simulation- FREE
From: [email-masked] ()
Newsgroups: sci.chem,sci.engr.chem

From: [email-masked] ()
Path: wrc.unr.edu!whitbeck
Newsgroups: sci.chem,sci.engr.chem
Subject: Chemical Kinetics Simulation- FREE
Expires: 
References: 
Sender: 
Reply-To: [email-masked] ()
Followup-To: 
Distribution: world
Organization: DRI-WRC Reno
Keywords: 

A while back someone asked in sci.chem about chemical kinetics
simulation software.

At the time I offered a FORTRAN listing of a rather complete
program (easy input, simulation, sensitivity analysis, and least
squares fitting of the model to exptl data). However I got no
takers (the offer still stands!- send mail). Perhaps the problem 
was that of typing in some 3000+ lines of FORTRAN from the listing?

Well I hacked out a simpler program that just does the simulation.
It is written in C for the Sun 3|4 computers (should port to other
platforms- I ported an intermediate version to GEMDOS (1040ST) with
no great difficulty).

The code uses  lsoda as the core integrater = livermore solver
for ordinary differential equations, with automatic method switching 
for stiff and nonstiff problems by  Linda R. Petzold  and  Alan C.
Hindmarsh, computing and mathematics research division, l-316
lawrence livermore national laboratory (lsoda.f is available at
[email-masked], the C port was provided by Hon Wah Tam
Wolfram Research, Inc.  [email-masked]).

INPUT:
	two files
		root.m where root can be your choice of names
		This file contains a reaction mechanism (free
		format) like:

2.0 	a -> b
0.15 	b -> c 
0.80	b + c -> d + d

the first field is a rate constant in 'F' or 'E' format (e.g. 1.00e-09)
then a list of reactants and products separated by '->' (required).
The specie names can be anything, eg CH3O2, NO2, PABA etc. There
are some restrictions on name lengths (10 chars) and some tokens
are 'special'.

		root.p is a file containing the integration
		parameters again in a free format. It looks like:

0.0  6 .1 1.0E-9
a	1.0	1.0e-10		1.0e-6
b	0.0	1.0e-10		1.0e-8

You simply provide (first line) starting time, stopping time,
output interval, and a solution tolerance value (a default value
for solution accuracy- to be explained in the package).
This line is followed by one or more lines to initialize specie
values (a,b,c,d in the example). No entry is required if the
initial value is zero and the default tolerance is acceptable.
Otherwise give the species name, starting value, absolute
tolerance, relative tolerance (explained in the package).

The program REACT sucks in these two files and spits out a file
named root.r (again root is from your input file name; i.e. 
REACT A produces A.r from A.[m,p]). This file contains the answers!
To facilitate printing and plotting the package contains 3 post
processors:

SELECT	reads root.e, a file containing the species to be printed.
	if root.e contains the lines
	a b d
	c b
	then a table is printed with the headings 
	TIME 	a	b	d
	then a table is printed with the headings
	TIME	c	b
 a sample from the above example might be:
3 reacions involving 4 species
a  b  c  d 
       time              a              b              c
     0.0000e+00      1.0000e+00      0.0000e+00      0.0000e+00 
     1.0000e-01      8.1873e-01      1.7987e-01      1.3925e-03 
     2.0000e-01      6.7032e-01      3.2439e-01      5.1475e-03 
     3.0000e-01      5.4881e-01      4.3989e-01      1.0669e-02 
     4.0000e-01      4.4933e-01      5.3151e-01      1.7433e-02 
     ....
     6.0000e+00      6.1442e-06      2.4471e-01      1.7167e-01 

EXTRACT	same as select but no table headings, useful with unix
	tools like dm, awk, etc.
EXTRACTER	dumps all the data (prints to stdout) in ASCII
	starting with time.

A fifth file root.s contains the list of species that goes with
root.r so that root.m does not have to be reprocessed to make these
tables.

==================================================================

I have just finished this code and it may be a little rough around
the edges but I will place it on the net for free distribution and
use subject to the following:

a) there is interest (people want it, justifying the use of the
net)

b) a site can be found that offers either a mailserver or anonymous
FTP for distribution. I dont have anon ftp here (security
conscious!) and the source code is quite large (several hundred K,
3100+ lines of code!).

For those who want & use the code I ask that
1) you keep the original distribution intact and make it freely
available to those who ask for copies
2) if you commercialize it you charge only for the convience of
compiling it for a target machine and any post-processing software
you provide AND that you let me know (the profits are yours- maybe
you could provide a copy of the finished product gratis :-)
3) give credit where credit is due
4) mail diff files to me or a designated 'maintainer' to keep the
program in a defined state
5) change the name of any hacked over copy so as to not cause
confusion

===============================================================
				WHY?
Why not?

Seriously, I am releasing the software so that it can be used in
teaching and research. If you put it to use please let me know.
If there are improvements that you need or make, please let me
know. 

If someone hacks up a realtime or post- X11 graphics support I
would be especially greatfull!

An MSDOS port would be appreciated I'm sure (I may finish the 1040ST
port anyway which would be very similar).

DO YA WANT IT?

NO: do nothing

YES: send mail, if the mail bounces post to sci.engr.chem and I'll
look there (or sci.chem if you dont get sci.engr.chem)
I'll make a 'users' list. If the list is small I'll make
arrangements to get you copies of the code. If it is large I'll try
and find an ftp site to serve as its home. PLEASE MENTION IN YOUR
MAIL (a) do you have a unix box (BSD 4.3) or not, (b) can handle
unix compress, tar, uudecode or not, cat ftp to/from your site to
get the code or not, can act as a 'beta tester' (run some tought
problems thru it) or not. 

PLEASE POST THIS WHERE ANY INTERESTED COLLEAGUES MAY SPOT IT!
___________________________________________________________
|Mike Whitbeck             | [email-masked]      |
|Desert Research Inst.     | [email-masked] |
|POB 60220                 | [email-masked]        |
|RENO, NV 89506            | 702-673-7348                 |
|__________________________|______________________________|

All academics have the potential for being insatiable...
but the chemists are the most expensive and insatiable among the
expensive and insatiable. - J. Martin in "To Rise Above Principle"