Changeset 685 for trunk/source/ion_solver.cpp
- Timestamp:
- 12/05/06 18:14:43 (2 years ago)
- Files:
-
- 1 modified
-
trunk/source/ion_solver.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/ion_solver.cpp
r652 r685 45 45 int lgNegPop; 46 46 static int lgMustMalloc=TRUE; 47 static double *sink, *source ;47 static double *sink, *source , *sourcesave; 48 48 int32 nerror; 49 49 static int32 *ipiv; … … 221 221 BadMalloc(); 222 222 if( (source=(double*)MALLOC( (sizeof(double)*(unsigned)ncell ))) == NULL ) 223 BadMalloc(); 224 if( (sourcesave=(double*)MALLOC( (sizeof(double)*(unsigned)ncell ))) == NULL ) 223 225 BadMalloc(); 224 226 if( (ipiv=(int32*)MALLOC( (sizeof(int32)*(unsigned)ncell ))) == NULL ) … … 514 516 MAT( xmatsave, i, j ) = MAT( xmat, i, j ); 515 517 } 518 sourcesave[i] = source[i]; 516 519 } 517 520 … … 523 526 * will not be removed, a possible source of error, but they must not 524 527 * have been significant, given that the molecular fraction is so small */ 528 if( !lgHomogeneous && ion_range==2 ) 529 { 530 /* solve algebraically */ 531 double a = MAT( xmatsave, 0, 0 ), 532 b = MAT( xmatsave, 1, 0 ) , 533 c = MAT( xmatsave, 0, 1 ) , 534 d = MAT( xmatsave, 1, 1 ); 535 b = SDIV(b); 536 d = SDIV(d); 537 double ratio1 = a/b , ratio2 = c/d , fratio1=fabs(a/b),fratio2=fabs(c/d); 538 if( fabs(ratio1-ratio2)/MAX2(fratio1,fratio2) <DBL_EPSILON*1e4 ) 539 { 540 abund_total = SDIV( dense.gas_phase[nelem] - dense.xMolecules[nelem] ); 541 lgHomogeneous = TRUE; 542 } 543 } 544 # if 0 525 545 if( nelem==ipHYDROGEN && 526 546 fabs(dense.xMolecules[nelem]) / SDIV(dense.gas_phase[ipHYDROGEN]) <DBL_EPSILON*100. ) 527 547 { 548 abund_total = SDIV( dense.gas_phase[nelem] - dense.xMolecules[nelem] ); 528 549 lgHomogeneous = TRUE; 529 550 } 551 # endif 530 552 531 553 /* this is true if no source terms … … 566 588 } 567 589 590 for( i=0; i< ion_range; ++i ) 591 { 592 for( j=0; j< ion_range; ++j ) 593 { 594 MAT( xmatsave, i, j ) = MAT( xmat, i, j ); 595 } 596 sourcesave[i] = source[i]; 597 } 598 568 599 if ( FALSE && nelem == ipHYDROGEN && dynamics.lgAdvection&& iteration>1 ) 569 600 { … … 728 759 enum {DEBUG_LOC=FALSE}; 729 760 /*@+redef@*/ 730 if( DEBUG_LOC && (nzone >380 ) &&nelem == ipHYDROGEN )731 { 732 fprintf(ioQQQ,"debuggg \t%.2f\t%.4e\t%.4e\tIon\t%.3e\tRec\t%.3e\n",761 if( DEBUG_LOC && nelem == ipHYDROGEN ) 762 { 763 fprintf(ioQQQ,"debuggg ion_solver1 \t%.2f\t%.4e\t%.4e\tIon\t%.3e\tRec\t%.3e\n", 733 764 fnzone, 734 765 phycon.te,
