Changeset 1600
- Timestamp:
- 12/01/07 17:09:37 (12 months ago)
- Location:
- branches/newmole/source
- Files:
-
- 4 modified
-
conv_base.cpp (modified) (5 diffs)
-
ion_solver.cpp (modified) (3 diffs)
-
mole_co_solve.cpp (modified) (3 diffs)
-
mole_h_step.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/newmole/source/conv_base.cpp
r1599 r1600 378 378 { 379 379 380 fprintf(ioQQQ,"Start of loop %g\n",dense.xIonDense[15][0]);381 380 check_conserve(__FILE__,__LINE__); 382 381 … … 413 412 /*fprintf(ioQQQ,"DEBUG h2\t%.2f\t%.3e\t%.3e", fnzone,hmi.H2_total,findspecies("H2")->hevmol);*/ 414 413 iso_solve( ipH_LIKE ); 415 fprintf(ioQQQ,"After H_LIKE %g\n",dense.xIonDense[15][0]);416 414 417 415 /* now do level populations for H2 */ … … 434 432 /* do all he-like species */ 435 433 iso_solve( ipHE_LIKE ); 436 fprintf(ioQQQ,"After He_like %g\n",dense.xIonDense[15][0]);437 434 438 435 /*>>chng 04 may 09, add option to abort here, inspired by H2 pop failures … … 509 506 IonOxyge(); 510 507 IonNitro(); 511 fprintf(ioQQQ,"Before Si %g\n",dense.xIonDense[15][0]);512 508 IonSilic(); 513 fprintf(ioQQQ,"Before S %g\n",dense.xIonDense[15][0]); 509 #define DEBUGRW 1 510 if (DEBUGRW) fprintf(ioQQQ," DEBUG Before S %g\n",dense.xIonDense[15][0]); 514 511 IonSulph(); 515 fprintf(ioQQQ,"After ion%g\n",dense.xIonDense[15][0]);512 if (DEBUGRW) fprintf(ioQQQ," DEBUG After S %g\n",dense.xIonDense[15][0]); 516 513 IonChlor(); 517 514 check_conserve(__FILE__,__LINE__); … … 519 516 /* do carbon monoxide after oxygen */ 520 517 CO_drive(); 521 fprintf(ioQQQ,"After mole %g\n",dense.xIonDense[15][0]); 518 if (DEBUGRW) fprintf(ioQQQ," DEBUG After mole %g\n",dense.xIonDense[15][0]); 519 #undef DEBUGRW 522 520 523 521 check_conserve(__FILE__,__LINE__); -
branches/newmole/source/ion_solver.cpp
r1586 r1600 64 64 abund_total = SDIV ( dense.gas_phase[nelem] - dense.xMolecules[nelem] ); 65 65 66 /* >>chng 04 nov 22,67 * if gas nearly all atomic/ionic do not let source - sink terms from68 * molecular network force system of balance equations to become69 * inhomogeneous70 * what constitutes a source or sink IS DIFFERENT for hydrogen and the rest71 * the H solution must couple with hmole - and its defn of source and sink. For instance, oxygen charge72 * transfer goes into source and sink terms for hydrogen. So we never hose source and sink for H.73 * for the heavy elements, which couple onto comole, mole.source and sink represent terms that74 * remove atoms and ions from the ionization ladder. their presence makes the system of75 * equations inhomogeneous. we don't want to do this when comole has a trivial effect on76 * the ionization balance since the matrix becomes unstable */77 /* >>chng 04 dec 06, limit from 0.01 to 1e-10 as per NA suggestion */78 #if 079 if( nelem>ipHYDROGEN && dense.xMolecules[nelem]/SDIV(dense.gas_phase[nelem]) < 1e-10 )80 {81 for( ion=dense.IonLow[nelem]; ion<=dense.IonHigh[nelem]; ++ion )82 {83 mole.source[nelem][ion] = 0.;84 mole.sink[nelem][ion] = 0.;85 }86 }87 88 /* protect against case where all gas phase abundances are in molecules, use the89 * atomic and first ion density from the molecule solver90 * >>chng 04 aug 15, NA change from 10 0000 to 10 pre-coef on91 * FLT_EPSILON for stability in PDR92 * the factor 10.*FLT_EPSILON also appears in mole_h_step in total H93 * conservation */94 if( fabs( dense.gas_phase[nelem] - dense.xMolecules[nelem])/SDIV(dense.gas_phase[nelem] ) <95 10.*FLT_EPSILON )96 {97 double renorm;98 /* >>chng 04 jul 31, add logic to conserve nuclei in fully molecular limit;99 * in first calls, when searching for solution, we may be VERY far100 * off, and sum of first ion and atom density may be far larger101 * than difference between total gas and molecular densities,102 * since they reflect the previous evaluation of the solution. Do103 * renorm to cover this case */104 /* first form sum of all atoms and ions */105 realnum sum = 0.;106 for( ion=dense.IonLow[nelem]; ion<=dense.IonHigh[nelem]; ++ion )107 sum += dense.xIonDense[nelem][ion];108 /* now renorm to this sum - this should be unity, and is not if we have109 * now conserved particles, due to molecular fraction changing */110 renorm = dense.gas_phase[nelem] / SDIV(sum + dense.xMolecules[nelem] );111 112 abund_total = renorm * sum;113 }114 115 /* negative residual density */116 if( abund_total < 0. )117 {118 /* >>chng 05 dec 16, do not abort when net atomic/ ionic abundance119 * is negative due to chem net having too much of a species - this120 * happens naturally when ices become well formed, but the code will121 * converge away from it. Rather, we set the ionization122 * convergence flag to "not converge" and soldier on123 * if negative populations do not go away, we will eventually124 * terminate due to convergence failures */125 /* print error if not search */126 if( !conv.lgSearch )127 fprintf(ioQQQ,128 "PROBLEM ion_solver - neg net atomic abundance zero for nelem= %li, rel val= %.2e conv.nTotalIoniz=%li, fixed\n",129 nelem,130 fabs(abund_total) / SDIV(dense.xMolecules[nelem]),131 conv.nTotalIoniz );132 /* fix up is to use half the positive abundance, assuming chem is133 * trying to get too much of this species */134 abund_total = -abund_total/2.;135 136 /* say that ionization is not converged - do not abort - but if137 * cannot converge away from negative solution, this will become a138 * convergence failure abort */139 conv.lgConvIoniz = false;140 strcpy( conv.chConvIoniz, "neg ion" );141 }142 #endif143 144 66 if (dense.gas_phase[nelem] < dense.xMolecules[nelem]) 145 67 { 146 fprintf(stdout,"Bad density %li %g %g\n",nelem,dense.gas_phase[nelem],dense.xMolecules[nelem]); 68 fprintf(stdout," DISASTER ion_solver: Bad density %li %g %g\n",nelem,dense.gas_phase[nelem],dense.xMolecules[nelem]); 69 puts( "[Stop in ion_solver]" ); 70 cdEXIT(EXIT_FAILURE); 147 71 } 148 72 … … 455 379 456 380 /* these are the external source and sink terms */ 457 /* source first */458 381 /* need negative sign to get positive pops */ 459 382 source[i] -= mole.source[nelem][ion]; 460 461 383 totsrc += mole.source[nelem][ion]; 462 /* sink next */463 /*MAT( xmat, i, i ) += mole.sink[nelem][ion];*/464 384 MAT( xmat, i, i ) -= mole.sink[nelem][ion]; 465 385 } … … 478 398 { 479 399 ion = i+ion_low; 480 /*MAT( xmat, i, i ) += dynamics.Rate;*/481 400 MAT( xmat, i, i ) -= dynamics.Rate; 482 /*src[i] += dynamics.Source[nelem][ion];*/483 401 source[i] -= dynamics.Source[nelem][ion]; 484 402 /* fprintf(ioQQQ," %li %li %.3e (%.3e %.3e)\n",i,i,MAT(xmat,i,i), -
branches/newmole/source/mole_co_solve.cpp
r1599 r1600 73 73 mole.source[nelem][ion] = mole.src[element_list[nelem]->ipMl[ion]]; 74 74 mole.sink[nelem][ion] = mole.snk[element_list[nelem]->ipMl[ion]]; 75 // dense.xIonDense[nelem][ion] = (realnum) COmole[element_list[nelem]->ipMl[ion]]->hevmol; 75 if (dense.IonLow[nelem] > ion) 76 dense.IonLow[nelem] = ion; 77 if (dense.IonHigh[nelem] < ion) 78 dense.IonHigh[nelem] = ion; 76 79 } 77 80 else … … 81 84 } 82 85 } 83 if (element_list[nelem]->ipMl[0] != -1)84 {85 dense.IonLow[nelem] = 0;86 dense.IonHigh[nelem] = MAX2( dense.IonHigh[nelem] , 1 );87 }88 86 } 89 87 90 88 /* if populations not conserved then not converged */ 91 # define EPS_MOLE 0.1 92 if( dense.lgElmtOn[ipHYDROGEN] && 93 dense.xMolecules[ipHYDROGEN] > dense.gas_phase[ipHYDROGEN]*(1.+EPS_MOLE) ) 94 { 95 conv.lgConvIoniz = false; 96 sprintf( conv.chConvIoniz, "COcon%2i",ipHYDROGEN ); 97 conv.BadConvIoniz[0] = dense.xMolecules[ipHYDROGEN]; 98 conv.BadConvIoniz[1] = dense.gas_phase[ipHYDROGEN]; 99 } 100 else 101 { 102 for (nelem=0;nelem<LIMELM; ++nelem) 103 { 104 element = element_list[nelem]; 105 if( dense.lgElmtOn[nelem] && 106 dense.xMolecules[nelem] > dense.gas_phase[nelem]*(1.+EPS_MOLE) ) 107 { 108 conv.lgConvIoniz = false; 109 sprintf( conv.chConvIoniz, "COcon%2li",nelem ); 110 conv.BadConvIoniz[0] = dense.xMolecules[nelem]; 111 conv.BadConvIoniz[1] = dense.gas_phase[nelem]; 112 break; 113 } 114 } 115 } 89 # define EPS_MOLE 0.01 90 for (nelem=0;nelem<LIMELM; ++nelem) 91 { 92 element = element_list[nelem]; 93 if( dense.lgElmtOn[nelem] ) 94 ASSERT(dense.xMolecules[nelem] <= dense.gas_phase[nelem]*(1.+EPS_MOLE) ); 95 } 96 # undef EPS_MOLE 116 97 117 98 DEBUG_EXIT( "CO_solve()" ); … … 122 103 } 123 104 124 # undef EPS_MOLE125 105 126 106 // #define SVD -
branches/newmole/source/mole_h_step.cpp
r1590 r1600 613 613 614 614 CO_return_cached_species(); 615 615 616 hmi.H2_total = 0.; 616 617 /* this is where the transition struc expects to find the H2 abundance */
