📄 gep2.c
字号:
for( j=0; j<nsteps; j++ )
for(k=0;k<totmet;k++,i++)
{
wsprintf( (LPSTR) buff,"e(%s,[%s])", (LPSTR) stepname[j], (LPSTR) metname[k]);
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
}
for( j=0; j<totmet; j++ )
for(k=0;k<nsteps;k++,i++)
{
wsprintf( (LPSTR) buff,"C([%s],%s)", (LPSTR) metname[j], (LPSTR) stepname[k]);
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
}
for( j=0; j<nsteps; j++ )
for(k=0;k<nsteps;k++,i++)
{
wsprintf( (LPSTR) buff,"C(J(%s),%s)", (LPSTR) stepname[j], (LPSTR) stepname[k]);
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
}
/* endtime, tolerance, nfunc, njacob, nistep, smstep */
wsprintf( (LPSTR) buff,"time");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = spar[l].title = poolptr;
/* increase i */
i++; l++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"integration steps");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase i */
i++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"function evaluations");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase i */
i++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"jacobian evaluations");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase i */
i++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"last step size");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = poolptr;
/* increase i */
i++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"relative tolerance");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = spar[l].title = poolptr;
/* increase i */
i++; l++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"absolute tolerance");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = spar[l].title = poolptr;
/* increase i */
i++; l++;
/* increase poolptr to point to the first free byte */
poolptr += _fstrlen( buff ) + 1;
wsprintf( (LPSTR) buff,"flux resolution");
/* copy buff to the string pool */
_fstrcpy( (char __far *) poolptr,
(char __far *) buff );
/* store the pointer in outpel[i] */
outpel[i].title = spar[l].title = poolptr;
return 0;
}
/*
make strings for reactions
*/
void step_string( void )
{
int i, j, st, first, tempstoi[MAX_MET];
char auxstr[128];
for( j=0; j<nsteps; j++ )
{
stepstr[j][0] = '\0';
for( i=0; i<totmet; i++ ) tempstoi[i] = 0;
for( i=0; i<MAX_MOL; i++ )
if ((*rstr)[j][i]<0) tempstoi[ -(*rstr)[j][i]-1 ]--;
for( i=0, first=1; i<totmet ; i++ ) /* first the substrates */
{
st = tempstoi[i];
if( st < 0 )
{
if ( st == -1 )
wsprintf( auxstr, "%s%s", first==1 ? (LPSTR) "" : (LPSTR) " + ", &metname[i][0] );
else
wsprintf( auxstr, "%s%i*%s", first==1 ? (LPSTR) "" : (LPSTR) " + ", -st, &metname[i][0] );
_fstrcat( stepstr[j], auxstr );
first = 0;
}
}
if( revers[uc[j]] ) /* the connector */
_fstrcat( stepstr[j], " = " );
else
_fstrcat( stepstr[j], " -> " );
/* setup the stoicheiometries of the products */
for( i=0; i<totmet; i++ ) tempstoi[i] = 0;
for( i=0; i<MAX_MOL; i++ )
if ((*rstr)[j][i]>0) tempstoi[ (*rstr)[j][i]-1 ]++;
for( i=0, first=1; i<totmet; i++ ) /* then the products */
{
st = tempstoi[i];
if( st > 0 )
{
if( st == 1 )
wsprintf( auxstr, "%s%s", first==1 ? (LPSTR) "" : (LPSTR) " + ", &metname[i][0] );
else
wsprintf( auxstr, "%s%i*%s", first==1 ? (LPSTR) "" : (LPSTR) " + ", st, &metname[i][0] );
_fstrcat( stepstr[j], auxstr );
first = 0;
}
}
}
}
/*
set default values when there is no .INI file
*/
void def_def( void )
{
dft_pfo = DFT_PFO;
dft_endtime = DFT_ENDTIME;
dft_hrcz = DFT_HRCZ;
dft_debugval = DFT_DEBUGVAL;
dft_conc = DFT_CONC;
dft_const = DFT_CONST;
dft_timeu = DFT_TIMEU;
dft_concu = DFT_CONCU;
}
/* sets the concentrations and kin. const. to the defaults */
void conc_dft( void )
{
int i, j;
for( i=0; i<totmet; i++ ) xu[i] = dft_conc;
for( i=0; i<nsteps; i++ )
for( j=0; j<(int)ktype[kinetu[0]].nconst; j++ )
*(params[i]+j) = dft_const;
}
void numer_dft( void )
{
options.reltol = DFT_RELTOL;
options.abstol = DFT_ABSTOL;
options.hrcz = dft_hrcz;
options.adams = DFT_ADAMS;
options.bdf = DFT_BDF;
}
/*
set variables to default values
*/
void set_dfts( void )
{
options.endtime = dft_endtime;
options.debug = dft_debugval;
options.dyn = DFT_DYN;
options.ss = DFT_SS;
options.txt = DFT_TXT;
options.dat = DFT_DAT;
options.pfo = dft_pfo;
strcpy( options.timeu, dft_timeu );
strcpy( options.concu, dft_concu );
options.datwidth = DFT_DATWIDTH;
options.datsep = DFT_DATSEP;
options.datmca = DFT_DATMCA;
options.datss = DFT_DATSS;
options.scan = 0;
options.scandens = (unsigned long) 1;
options.quotes = 0;
plot.x = -1;
plot.y[0] = -1;
plot.z = -1;
plot.ny = 1;
plot.type = 0;
plot.file = 0;
plot.lines = 1;
plot.colour = 1;
plot.hidden = 0;
plot.contour = 0;
plot.logx = 0;
plot.logy = 0;
plot.logz = 0;
numer_dft();
}
/*
read default values
*/
void get_dfts( void )
{
def_def();
set_dfts();
}
/*
create a new function tree object
*/
int new_tree( int idx )
{
if( !eqefl )
{
nudf++;
GlobalUnlock( hTree );
hTree = GlobalReAlloc( hTree, (DWORD) nudf * sizeof( struct treet ), GMEM_ZEROINIT | GMEM_MOVEABLE );
if( hTree == NULL )
return IDS_ERR_NOEXEC;
tree = ( struct treet huge * ) GlobalLock( hTree );
}
_fmemcpy( (void __far *) &tree[idx], (void __far *) &tr, sizeof( struct treet ) );
return 0;
}
/*
add a user-defined rate equation to the database
*/
int new_rateq( int idx )
{
GLOBALHANDLE hTemp;
WORD strsize;
int i;
DWORD l;
LPSTR tmpptr;
/* measure the required length for the constant names */
for( i=0, strsize=0; i<tree[idx].nid; i++ )
if( tree[idx].id[i][9] == (char) 0 )
strsize += lstrlen(tree[idx].id[i]) + 1;
sizetr += (DWORD) strsize * sizeof( char );
l = (DWORD) (treeptr - treestr);
/* reallocate the buffer to hold new strings */
GlobalUnlock( hTreeStr );
hTreeStr = GlobalReAlloc( hTreeStr, sizetr, GMEM_ZEROINIT | GMEM_MOVEABLE );
if( hTreeStr == NULL ) return IDS_ERR_NOEXEC;
treestr = GlobalLock( hTreeStr );
treeptr = treestr + l;
tmpptr = treeptr;
/* copy the strings to the buffer */
for( i=0; i<tree[idx].nid; i++ )
if( tree[idx].id[i][9] == (char) 0 )
{
lstrcpy( treeptr, tree[idx].id[i] );
treeptr += lstrlen( tree[idx].id[i] ) + 1;
}
/* unlock the memory handle */
GlobalUnlock( hKtype );
hTemp = GlobalReAlloc( hKtype, (DWORD) (++nrateq) * sizeof( struct kint ), GMEM_ZEROINIT | GMEM_MOVEABLE );
if( hTemp != NULL )
{
hKtype = hTemp;
ktype = ( struct kint huge * ) GlobalLock( hKtype );
ktype[MAX_TYP+idx].nmodf = (unsigned char) tree[idx].nmodf;
ktype[MAX_TYP+idx].nconst =(unsigned char) tree[idx].nconst;
ktype[MAX_TYP+idx].descr = (LPSTR) tree[idx].descr;
ktype[MAX_TYP+idx].constnam = (LPSTR) tmpptr;
return 0;
}
else
{
ktype = ( struct kint huge * ) GlobalLock( hKtype );
return IDS_ERR_NOEXEC;
}
}
/*
free global heap space allocated
*/
void TidyGepasiVar( void )
{
GlobalUnlock( hMetname ); /* unlock all global handles */
GlobalUnlock( hStepname );
GlobalUnlock( hStoiu );
GlobalUnlock( hSto );
GlobalUnlock( hLoop );
GlobalUnlock( hParams );
GlobalUnlock( hKtype );
GlobalUnlock( hRstr );
GlobalUnlock( hOutpEl );
GlobalUnlock( hScanPar );
GlobalUnlock( hStrPool );
GlobalUnlock( hTreeStr );
GlobalUnlock( hTree );
GlobalUnlock( hTmpF );
GlobalFree( hMetname ); /* free all global mem blocks */
GlobalFree( hStepname );
GlobalFree( hStoiu );
GlobalFree( hSto );
GlobalFree( hLoop );
GlobalFree( hParams );
GlobalFree( hKtype );
GlobalFree( hRstr );
GlobalFree( hOutpEl );
GlobalFree( hScanPar );
GlobalFree( hStrPool );
GlobalFree( hTreeStr );
GlobalFree( hTree );
GlobalFree( hTmpF );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -