00001
00002
00003
00004 #include "cddefines.h"
00005 #include "taulines.h"
00006 #include "dense.h"
00007 #include "ionbal.h"
00008 #include "thermal.h"
00009 #include "phycon.h"
00010 #include "hmi.h"
00011 #include "dynamics.h"
00012 #include "conv.h"
00013 #include "trace.h"
00014 #include "coolheavy.h"
00015 #include "timesc.h"
00016 #include "thirdparty.h"
00017 #include "mole.h"
00018 #include "mole_co_priv.h"
00019 #include "mole_co_atom.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 void CO_solve(
00037
00038 bool *lgNegPop,
00039
00040 bool *lgZerPop )
00041 {
00042
00043 int32 merror;
00044 long int i, j, k, n,
00045 nelem , ion , ion2;
00046 double
00047 co_denominator;
00048 realnum cartot_mol, oxytot_mol;
00049 realnum abundan;
00050 struct chem_element_s *element;
00051 double sum;
00052
00053 DEBUG_ENTRY( "CO_solve()" );
00054
00055 CO_step();
00056
00057
00058 for(i=0;i<mole.num_comole_calc;i++)
00059 {
00060 sum = 0.;
00061 for(j=0;j<mole.num_comole_calc;j++)
00062 {
00063 sum = sum+fabs(mole.c[i][j]);
00064 }
00065 if(sum < SMALLFLOAT && fabs(mole.b[i]) < SMALLFLOAT)
00066 {
00067 mole.c[i][i] = 1.;
00068 }
00069 }
00070
00071 cartot_mol = dense.xMolecules[ipCARBON] + findspecies("C")->hevmol + findspecies("C+")->hevmol;
00072 oxytot_mol = dense.xMolecules[ipOXYGEN] + findspecies("O")->hevmol + findspecies("O+")->hevmol;
00073
00074 ASSERT( cartot_mol >= 0. && oxytot_mol >= 0.);
00075
00076 *lgNegPop = false;
00077 *lgZerPop = false;
00078
00079
00080 for(nelem=ipLITHIUM; nelem < LIMELM; ++nelem)
00081 {
00082 for(ion=0; ion < nelem+2; ++ion)
00083 {
00084
00085 mole.sink[nelem][ion] = 0.;
00086 mole.source[nelem][ion] = 0.;
00087
00088 for(ion2=0; ion2< nelem+2; ++ion2)
00089 {
00090 mole.xMoleChTrRate[nelem][ion][ion2] = 0.;
00091 }
00092 }
00093 }
00094
00095
00096
00097
00098
00099
00100 if( iteration > dynamics.n_initial_relax+1 && dynamics.lgAdvection )
00101 {
00102 for(i=0;i<mole.num_comole_calc;i++)
00103 {
00104 if(COmole[i]->n_nuclei > 1) {
00105 mole.c[i][i] -= dynamics.Rate;
00106
00107
00108
00109
00110 mole.b[i] -= (COmole[i]->hevmol*dynamics.Rate-dynamics.CO_molec[i]);
00111 }
00112 }
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 for(i=0;i<mole.num_elements; ++i)
00143 {
00144 element = chem_element[i];
00145 mole.sink[element->ipCl][0] -= (mole.c[element->ipMl][element->ipMl] + mole.c[element->ipMl][element->ipMlP])*dense.lgElmtOn[element->ipCl];
00146 mole.sink[element->ipCl][1] -= (mole.c[element->ipMlP][element->ipMlP] + mole.c[element->ipMlP][element->ipMl] )*dense.lgElmtOn[element->ipCl];
00147 }
00148
00149
00150
00151 for(j=0;j < mole.num_elements; ++j)
00152 {
00153 element = chem_element[j];
00154 for(i=0; i < mole.num_comole_calc; ++i)
00155 {
00156 mole.source[element->ipCl][1] += COmole[i]->hevmol*mole.c[i][element->ipMlP]*dense.lgElmtOn[element->ipCl];
00157 mole.source[element->ipCl][0] += COmole[i]->hevmol*mole.c[i][element->ipMl]*dense.lgElmtOn[element->ipCl];
00158 }
00159 }
00160
00161
00162
00163
00164 for(i=0;i < mole.num_elements; ++i)
00165 {
00166 element = chem_element[i];
00167 mole.source[element->ipCl][1] -= ( mole.c[element->ipMlP][element->ipMlP]*COmole[element->ipMlP]->hevmol +
00168 mole.c[element->ipMl][element->ipMlP]*COmole[element->ipMl]->hevmol)*dense.lgElmtOn[element->ipCl];
00169
00170 mole.source[element->ipCl][0] -= ( mole.c[element->ipMl][element->ipMl]*COmole[element->ipMl]->hevmol +
00171 mole.c[element->ipMlP][element->ipMl]*COmole[element->ipMlP]->hevmol)*dense.lgElmtOn[element->ipCl];
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 mole.source[element->ipCl][1] = mole.source[element->ipCl][1] - mole.b[element->ipMlP];
00185 mole.source[element->ipCl][0] = mole.source[element->ipCl][0] - mole.b[element->ipMl];
00186
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 for(i=2; i < LIMELM; ++i)
00198 {
00199 for(j=0; j < 2; ++j)
00200 {
00201
00202 if(mole.source[i][j] < 0)
00203 {
00204 mole.sink[i][j] -= (mole.source[i][j]/SDIV(dense.xIonDense[i][j]));
00205 mole.source[i][j] = 0;
00206 }
00207 }
00208 }
00209
00210
00211
00212 for(i=0;i < mole.num_elements; ++i)
00213 {
00214 element = chem_element[i];
00215 mole.xMoleChTrRate[element->ipCl][1][0] = (realnum)(mole.c[element->ipMlP][element->ipMl] -
00216 ionbal.RateRecomTot[element->ipCl][0])*dense.lgElmtOn[element->ipCl];
00217
00218 mole.xMoleChTrRate[element->ipCl][0][1] = (realnum)(mole.c[element->ipMl][element->ipMlP] -
00219 ionbal.RateIonizTot[element->ipCl][0])*dense.lgElmtOn[element->ipCl];
00220 }
00221
00222
00223 for(i=2; i < LIMELM; ++i)
00224 {
00225 for(j=0; j < 2; ++j)
00226 {
00227 for(k=0; k< 2; ++k)
00228 {
00229
00230 if(j != k)
00231 {
00232 if( mole.xMoleChTrRate[i][j][k] < 0. )
00233 {
00234 mole.xMoleChTrRate[i][k][j] -= mole.xMoleChTrRate[i][j][k];
00235 mole.xMoleChTrRate[i][j][k] = 0.;
00236 }
00237 }
00238 }
00239 }
00240 }
00241
00242 for(n=0;n<mole.num_elements;n++)
00243 {
00244 tot_ion[n] = dense.gas_phase[chem_element[n]->ipCl];
00245 for( i=2; i < chem_element[n]->ipCl+2; i++ )
00246 {
00247 tot_ion[n] -= dense.xIonDense[chem_element[n]->ipCl][i];
00248 }
00249 }
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 if( iteration > dynamics.n_initial_relax+1 && dynamics.lgAdvection)
00265 fixit();
00266
00267 for(n=0;n<mole.num_elements;n++)
00268 {
00269 mole.b[chem_element[n]->ipMl] = tot_ion[n];
00270 }
00271
00272
00273
00274
00275
00276
00277
00278
00279 for( j=0; j < mole.num_comole_calc; j++ )
00280 {
00281 for(i=0;i<mole.num_elements;i++)
00282 {
00283 element = chem_element[i];
00284 mole.c[j][element->ipMl] = COmole[j]->nElem[element->ipCl];
00285 }
00286 }
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311 if( trace.lgTrace && trace.lgTr_CO_Mole )
00312 {
00313 fprintf( ioQQQ, " COMOLE matrix\n " );
00314
00315 # if 0
00316 for( i=0; i < MIN2(mole.num_comole_calc,8); i++ )
00317 {
00318 fprintf( ioQQQ, "%4.4s", COmole[i]->label );
00319 }
00320 fprintf( ioQQQ, " \n" );
00321
00322 for( j=0; j < mole.num_comole_calc; j++ )
00323 {
00324 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00325 fprintf( ioQQQ, " " );
00326 for( i=0; i < MIN2(mole.num_comole_calc,8); i++ )
00327 {
00328 fprintf( ioQQQ, "%9.1e", mole.c[i][j] );
00329 }
00330 fprintf( ioQQQ, "\n" );
00331 }
00332 # endif
00333
00334 fprintf( ioQQQ, " COMOLE matrix\n " );
00335
00336 for( i=0; i < mole.num_comole_calc; i++ )
00337 {
00338 fprintf( ioQQQ, "%4.4s", COmole[i]->label );
00339 }
00340 fprintf( ioQQQ, " \n" );
00341
00342 for( j=0; j < mole.num_comole_calc; j++ )
00343 {
00344 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00345 fprintf( ioQQQ, " " );
00346 for( i=0; i < mole.num_comole_calc; i++ )
00347 {
00348
00349 fprintf( ioQQQ, ", %.15e", mole.c[i][j] );
00350 }
00351 fprintf( ioQQQ, "\n" );
00352 }
00353
00354 fprintf( ioQQQ, " COMOLE b\n " );
00355 for( j=0; j < mole.num_comole_calc; j++ )
00356 {
00357 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00358 fprintf( ioQQQ, ", %.15e\n",mole.b[j] );
00359 }
00360
00361 #if 0
00362 fprintf( ioQQQ,
00363 " COMOLE H2 den:%10.3e, H2,3+=%10.2e%10.2e Carb sum=%10.3e Oxy sum=%10.3e\n",
00364 hmi.H2_total,
00365 hmi.Hmolec[ipMH2p],
00366 hmi.Hmolec[ipMH3p],
00367 mole.c[mole.num_heavy_molec][findspecies("C")->index],
00368 mole.c[mole.num_heavy_molec][findspecies("O")->index] );
00369
00370 #endif
00371 }
00372
00373
00374 for( j=0; j < mole.num_comole_calc; j++ )
00375 {
00376 if( -mole.c[j][j] > SMALLFLOAT )
00377 {
00378
00379 timesc.AgeCOMoleDest[j] = -1./mole.c[j][j];
00380
00381
00382 }
00383 else
00384 {
00385 timesc.AgeCOMoleDest[j] = 0.;
00386 }
00387 }
00388
00389
00390 for( j=0; j < mole.num_comole_calc; j++ )
00391 {
00392 for( i=0; i < mole.num_comole_calc; i++ )
00393 {
00394 mole.amat[i][j] = mole.c[i][j];
00395 }
00396 }
00397
00398 merror = 0;
00399
00400 getrf_wrapper(mole.num_comole_calc,mole.num_comole_calc,mole.amat[0],mole.num_comole_calc, ipiv,&merror);
00401
00402 if( merror != 0 )
00403 {
00404 fprintf( ioQQQ, " CO_solve getrf_wrapper error\n" );
00405 cdEXIT(EXIT_FAILURE);
00406 }
00407
00408 getrs_wrapper('N',mole.num_comole_calc,1,mole.amat[0],mole.num_comole_calc,ipiv,mole.b,mole.num_comole_calc,&merror);
00409
00410 if( merror != 0 )
00411 {
00412 fprintf( ioQQQ, " CO_solve: dgetrs finds singular or ill-conditioned matrix\n" );
00413 cdEXIT(EXIT_FAILURE);
00414 }
00415
00416
00417 *lgNegPop = false;
00418 *lgZerPop = false;
00419 co_denominator = 0;
00420 # if 0
00421 if(fnzone > 1.02)
00422 {
00423 for( i=0; i < mole.num_comole_calc; i++)
00424 {
00425
00426 for( j=61; j < 62; j++ )
00427 {
00428
00429 printf("ZONE\t%.5e\tSPECIES_1\t%s\tSPECIES_2\t%s\tDEST_RATE\t%.3e\tbvec\t%.3e\n",
00430 fnzone, COmole[i]->label,COmole[j]->label,mole.c[i][j],mole.b[i]);
00431
00432 }
00433 }
00434 }
00435 # endif
00436 for( i=0; i < mole.num_comole_calc; i++ )
00437 {
00438
00439 if( mole.b[i] < 0. )
00440 {
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 if( dense.lgElmtOn[COmole[i]->nelem_hevmol] )
00468 {
00469 co_denominator = dense.gas_phase[COmole[i]->nelem_hevmol];
00470 }
00471 else
00472 {
00473
00474 co_denominator = 1e10;
00475 }
00476
00477
00478
00479 ASSERT( co_denominator > SMALLFLOAT || !dense.lgElmtOn[COmole[i]->nelem_hevmol] );
00480
00481
00482
00483
00484
00485
00486
00487 if( mole.b[i] / SDIV(co_denominator) > -1e-5 )
00488 {
00489
00490
00491
00492 mole.b[i] *= -1.;
00493 }
00494 else
00495 {
00496
00497 *lgNegPop = true;
00498
00499
00500
00501
00502
00503 if( nzone>co.co_nzone )
00504 {
00505 static long int nzFail=-2;
00506 long int nzFail2 = (long)fnzone*100;
00507
00508 if( !conv.lgSearch )
00509 fprintf(ioQQQ," PROBLEM ");
00510 fprintf(ioQQQ,
00511 " CO_solve neg pop for species %li %s, value is %.2e rel value is %.2e zone %.2f Te %.4e Search?%c\n",
00512 i ,
00513 COmole[i]->label ,
00514
00515 mole.b[i],
00516
00517 mole.b[i] / SDIV(co_denominator) ,
00518 fnzone,
00519 phycon.te,TorF( conv.lgSearch ) );
00520
00521
00522 if( nzFail2 !=nzFail )
00523 {
00524 nzFail = nzFail2;
00525 ConvFail( "pops" , "CO");
00526 }
00527 }
00528 mole.b[i] *= -1;
00529
00530
00531
00532
00533
00534 }
00535 }
00536 else if( mole.b[i] == 0. )
00537 {
00538
00539
00540 *lgZerPop = true;
00541
00542
00543 # if 0
00544 if( CODEBUG>1 )
00545 {
00546 fprintf(ioQQQ," PROBLEM ");
00547 fprintf(ioQQQ,
00548 " CO_solve zero pop for species %li %s, value is %.2e zone %li\n",
00549 i , COmole[i]->label , mole.b[i], nzone);
00550 }
00551 # endif
00552 mole.b[i] = SMALLFLOAT;
00553 }
00554 COmole[i]->hevmol = (realnum)mole.b[i];
00555
00556 ASSERT( !isnan( COmole[i]->hevmol ) );
00557 }
00558
00559
00560
00561
00562
00563
00564
00565
00566 if( *lgNegPop && (nzone>co.co_nzone &&!conv.lgSearch) )
00567 {
00568 conv.lgConvPops = false;
00569 fprintf(ioQQQ," CO network negative population occurred, Te=%.4e, calling ConvFail. ",
00570 phycon.te);
00571 fprintf( ioQQQ, " CO/C=%9.1e", findspecies("CO")->hevmol/SDIV(dense.gas_phase[ipCARBON]) );
00572 fprintf( ioQQQ, "\n" );
00573
00574 *lgNegPop = false;
00575 }
00576
00577
00578 if( 0 && *lgNegPop )
00579 {
00580
00581 for(j=0; j<2; ++j )
00582 {
00583 double sumcar = 0.;
00584 double sumoxy = 0.;
00585 double renorm;
00586 for( i=0; i < mole.num_comole_calc; i++ )
00587 {
00588
00589 sumcar += COmole[i]->hevmol*COmole[i]->nElem[ipCARBON];
00590 sumoxy += COmole[i]->hevmol*COmole[i]->nElem[ipOXYGEN];
00591 }
00592 renorm = (tot_ion[0] + tot_ion[1]) / SDIV( sumcar+sumoxy);
00593 if(j)
00594 fprintf(ioQQQ,"\t%f\n", renorm);
00595 else
00596 fprintf(ioQQQ,"renormco\t%.2f\t%f", fnzone, renorm);
00597 for( i=0; i < mole.num_comole_calc; i++ )
00598 {
00599 COmole[i]->hevmol *= (realnum)renorm;
00600
00601 ASSERT( !isnan( COmole[i]->hevmol ) );
00602 }
00603 }
00604 }
00605
00606 if( merror != 0 )
00607 {
00608 fprintf( ioQQQ, " COMOLE matrix inversion error, MERROR=%5ld zone=%5ld\n",
00609 (long)merror, nzone );
00610 ShowMe();
00611 fprintf( ioQQQ, " Product matrix\n " );
00612
00613 for( i=0; i < MIN2(mole.num_comole_calc,8); i++ )
00614 {
00615 fprintf( ioQQQ, "%4.4s", COmole[i]->label );
00616 }
00617 fprintf( ioQQQ, " \n" );
00618
00619 for( j=0; j < mole.num_comole_calc; j++ )
00620 {
00621 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00622 fprintf( ioQQQ, " " );
00623
00624 for( i=0; i < MIN2(mole.num_comole_calc,8); i++ )
00625 {
00626 fprintf( ioQQQ, "%9.1e", mole.amat[i][j]*
00627 COmole[i]->hevmol );
00628 }
00629 fprintf( ioQQQ, "\n" );
00630 }
00631
00632 if( mole.num_comole_calc >= 9 )
00633 {
00634 fprintf( ioQQQ, " COMOLE matrix\n " );
00635 for( i=8; i < mole.num_comole_calc; i++ )
00636 {
00637 fprintf( ioQQQ, "%4.4s", COmole[i]->label );
00638 }
00639 fprintf( ioQQQ, " \n" );
00640
00641 for( j=0; j < mole.num_comole_calc; j++ )
00642 {
00643 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00644 fprintf( ioQQQ, " " );
00645 for( i=8; i < mole.num_comole_calc; i++ )
00646 {
00647 fprintf( ioQQQ, "%9.1e",
00648 mole.amat[i][j]* COmole[i]->hevmol );
00649 }
00650 fprintf( ioQQQ, "\n" );
00651 }
00652 }
00653
00654 fprintf( ioQQQ, " Mole dens:" );
00655 for( j=0; j < mole.num_comole_calc; j++ )
00656 {
00657 fprintf( ioQQQ, " %4.4s:%.2e", COmole[j]->label
00658 , COmole[j]->hevmol );
00659 }
00660 fprintf( ioQQQ, " \n" );
00661
00662 cdEXIT(EXIT_FAILURE);
00663 }
00664
00665 if( trace.lgTrace && trace.lgTr_CO_Mole )
00666 {
00667 fprintf( ioQQQ, " Product matrix\n " );
00668
00669 for( i=0; i < MIN2(mole.num_comole_calc,8); i++ )
00670 {
00671 fprintf( ioQQQ, "%4.4s", COmole[i]->label );
00672 }
00673 fprintf( ioQQQ, " \n" );
00674
00675 for( j=0; j < mole.num_comole_calc; j++ )
00676 {
00677 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00678 fprintf( ioQQQ, " " );
00679 for( i=0; i < MIN2(mole.num_comole_calc,8); i++ )
00680 {
00681 fprintf( ioQQQ, "%9.1e", mole.amat[i][j]*
00682 COmole[i]->hevmol );
00683 }
00684 fprintf( ioQQQ, "\n" );
00685
00686 }
00687
00688 if( mole.num_comole_calc >= 9 )
00689 {
00690 fprintf( ioQQQ, " COMOLE matrix\n " );
00691 for( i=8; i < mole.num_comole_calc; i++ )
00692 {
00693 fprintf( ioQQQ, "%4.4s", COmole[i]->label );
00694 }
00695 fprintf( ioQQQ, " \n" );
00696
00697 for( j=0; j < mole.num_comole_calc; j++ )
00698 {
00699 fprintf( ioQQQ, " %4.4s", COmole[j]->label );
00700 fprintf( ioQQQ, " " );
00701
00702 for( i=8; i < mole.num_comole_calc; i++ )
00703 {
00704 fprintf( ioQQQ, "%9.1e", mole.amat[i][j]* COmole[i]->hevmol );
00705 }
00706 fprintf( ioQQQ, "\n" );
00707 }
00708 }
00709
00710 fprintf( ioQQQ, " Mole dens:" );
00711 for( j=0; j < mole.num_comole_calc; j++ )
00712 {
00713 fprintf( ioQQQ, " %4.4s:%.2e", COmole[j]->label
00714 , COmole[j]->hevmol );
00715 }
00716 fprintf( ioQQQ, " \n" );
00717 }
00718
00719
00720 co.CODissHeat = (realnum)(CO_findrate("PHOTON,CO=>C,O")*1e-12);
00721
00722 thermal.heating[0][9] = co.CODissHeat;
00723
00724
00725 abundan = findspecies("CO")->hevmol;
00726
00727 ASSERT( C12O16Rotate[0].Hi->IonStg < LIMELM+2 );
00728 ASSERT( C12O16Rotate[0].Hi->nelem-1 < LIMELM+2 );
00729 dense.xIonDense[ C12O16Rotate[0].Hi->nelem-1][C12O16Rotate[0].Hi->IonStg-1] = abundan;
00730
00731 CO_PopsEmisCool(&C12O16Rotate, nCORotate,abundan , "12CO",
00732 &CoolHeavy.C12O16Rot,&CoolHeavy.dC12O16Rot );
00733
00734
00735
00736
00737 abundan = findspecies("CO")->hevmol/co.C12_C13_isotope_ratio;
00738
00739 ASSERT( C13O16Rotate[0].Hi->IonStg < LIMELM+2 );
00740 ASSERT( C13O16Rotate[0].Hi->nelem-1 < LIMELM+2 );
00741 dense.xIonDense[ C13O16Rotate[0].Hi->nelem-1][C13O16Rotate[0].Hi->IonStg-1] = abundan;
00742
00743 CO_PopsEmisCool(&C13O16Rotate, nCORotate,abundan ,"13CO",
00744 &CoolHeavy.C13O16Rot,&CoolHeavy.dC13O16Rot );
00745
00746
00747 for( i=0;i<LIMELM; ++i )
00748 {
00749 dense.xMolecules[i] = 0.;
00750 }
00751
00752
00753
00754 for(i=0;i<N_H_MOLEC;i++)
00755 {
00756 dense.xMolecules[ipHYDROGEN] += hmi.Hmolec[i]*hmi.nProton[i];
00757 }
00758 dense.xMolecules[ipHYDROGEN] -= (hmi.Hmolec[ipMH] + hmi.Hmolec[ipMHp]);
00759
00760
00761
00762
00763
00764
00765
00766 dense.H_sum_in_CO = 0;
00767 for(i=0; i<mole.num_comole_calc; ++i)
00768 {
00769 if(COmole[i]->n_nuclei <= 1)
00770 continue;
00771
00772 dense.H_sum_in_CO += COmole[i]->nElem[ipHYDROGEN]*COmole[i]->hevmol;
00773
00774 for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem )
00775 {
00776 if( mole.lgElem_in_chemistry[nelem] )
00777 {
00778 if( COmole[i]->hevmol > BIGFLOAT )
00779 {
00780 fprintf(ioQQQ, "PROBLEM DISASTER mole_co_solve has found "
00781 "a CO-network molecule with an insane abundance.\n");
00782 fprintf(ioQQQ, "Species number %li with abundance %.2e\n",
00783 i , COmole[i]->hevmol);
00784 TotalInsanity();
00785 }
00786 else if( conv.lgSearch &&
00787 COmole[i]->nElem[nelem]*COmole[i]->hevmol > dense.gas_phase[nelem])
00788 {
00789 if( !conv.lgSearch )
00790 fprintf(ioQQQ,
00791 "PROBLEM COmole limit trip call %li Seatch? %c nMole %li "
00792 "n(mole) %.2e n(gas) %.2e)\n",
00793 conv.nTotalIoniz,
00794 TorF(conv.lgSearch),i ,
00795 COmole[i]->nElem[nelem]*COmole[i]->hevmol,
00796 dense.gas_phase[nelem]);
00797 COmole[i]->hevmol = dense.gas_phase[nelem]/COmole[i]->nElem[nelem]/2.f;
00798 }
00799 dense.xMolecules[nelem] +=COmole[i]->nElem[nelem]*COmole[i]->hevmol;
00800 }
00801 }
00802 }
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816 for(i=0;i<mole.num_elements; ++i)
00817 {
00818 element = chem_element[i];
00819
00820 COmole[element->ipMlP]->hevmol = ((dense.xIonDense[element->ipCl][1]+ COmole[element->ipMlP]->hevmol)/2)*dense.lgElmtOn[element->ipCl];
00821
00822 COmole[element->ipMl]->hevmol = ((dense.xIonDense[element->ipCl][0]+ COmole[element->ipMl]->hevmol)/2)*dense.lgElmtOn[element->ipCl];
00823
00824
00825 ASSERT( !isnan( COmole[element->ipMlP]->hevmol ) );
00826 ASSERT( !isnan( COmole[element->ipMl]->hevmol ) );
00827 }
00828
00829
00830 if( dense.lgElmtOn[ipCARBON] &&
00831 fabs(dense.xIonDense[ipCARBON][0]- findspecies("C")->hevmol)/SDIV(dense.gas_phase[ipCARBON]) >0.001 )
00832 {
00833 conv.lgConvIoniz = false;
00834 sprintf( conv.chConvIoniz, "CO C0 con");
00835 conv.BadConvIoniz[0] = dense.xIonDense[ipCARBON][0];
00836 conv.BadConvIoniz[1] = findspecies("C")->hevmol;
00837 }
00838 else if( dense.lgElmtOn[ipCARBON] &&
00839 fabs(dense.xIonDense[ipCARBON][1]- findspecies("C+")->hevmol)/SDIV(dense.gas_phase[ipCARBON]) >0.001 )
00840 {
00841 conv.lgConvIoniz = false;
00842 sprintf( conv.chConvIoniz, "CO C1 con");
00843 conv.BadConvIoniz[0] = dense.xIonDense[ipCARBON][1];
00844 conv.BadConvIoniz[1] = findspecies("C+")->hevmol;
00845 }
00846 else if( dense.lgElmtOn[ipOXYGEN] &&
00847 fabs(dense.xIonDense[ipOXYGEN][0]- findspecies("O")->hevmol)/SDIV(dense.gas_phase[ipOXYGEN]) >0.001 )
00848 {
00849 conv.lgConvIoniz = false;
00850 sprintf( conv.chConvIoniz, "CO O0 con");
00851 conv.BadConvIoniz[0] = dense.xIonDense[ipOXYGEN][0];
00852 conv.BadConvIoniz[1] = findspecies("O")->hevmol;
00853 }
00854 else if( dense.lgElmtOn[ipOXYGEN] &&
00855 fabs(dense.xIonDense[ipOXYGEN][1]- findspecies("O+")->hevmol)/SDIV(dense.gas_phase[ipOXYGEN]) >0.001 )
00856 {
00857 conv.lgConvIoniz = false;
00858 sprintf( conv.chConvIoniz, "CO O1 con");
00859 conv.BadConvIoniz[0] = dense.xIonDense[ipOXYGEN][1];
00860 conv.BadConvIoniz[1] = findspecies("O+")->hevmol;
00861 }
00862
00863
00864 for(i=0;i<mole.num_elements; ++i)
00865 {
00866 element = chem_element[i];
00867 dense.xIonDense[element->ipCl][0] = COmole[element->ipMl]->hevmol*dense.lgElmtOn[element->ipCl];
00868 dense.xIonDense[element->ipCl][1] = COmole[element->ipMlP]->hevmol*dense.lgElmtOn[element->ipCl];
00869 dense.IonLow[element->ipCl] = 0;
00870 dense.IonHigh[element->ipCl] = MAX2( dense.IonHigh[element->ipCl] , 1 );
00871 }
00872
00873
00874 # define EPS_MOLE 0.1
00875 if( dense.lgElmtOn[ipHYDROGEN] &&
00876 dense.xMolecules[ipHYDROGEN] > dense.gas_phase[ipHYDROGEN]*(1.+EPS_MOLE) )
00877 {
00878 conv.lgConvIoniz = false;
00879 sprintf( conv.chConvIoniz, "COcon%2i",ipHYDROGEN );
00880 conv.BadConvIoniz[0] = dense.xMolecules[ipHYDROGEN];
00881 conv.BadConvIoniz[1] = dense.gas_phase[ipHYDROGEN];
00882 }
00883 else if( dense.lgElmtOn[ipCARBON] &&
00884 dense.xMolecules[ipCARBON] > dense.gas_phase[ipCARBON]*(1.+EPS_MOLE) )
00885 {
00886 conv.lgConvIoniz = false;
00887 sprintf( conv.chConvIoniz, "COcon%2i",ipCARBON );
00888 conv.BadConvIoniz[0] = dense.xMolecules[ipCARBON];
00889 conv.BadConvIoniz[1] = dense.gas_phase[ipCARBON];
00890 }
00891 else if( dense.lgElmtOn[ipOXYGEN] &&
00892 dense.xMolecules[ipOXYGEN] > dense.gas_phase[ipOXYGEN]*(1.+EPS_MOLE) )
00893 {
00894 conv.lgConvIoniz = false;
00895 sprintf( conv.chConvIoniz, "COcon%2i",ipOXYGEN );
00896 conv.BadConvIoniz[0] = dense.xMolecules[ipOXYGEN];
00897 conv.BadConvIoniz[1] = dense.gas_phase[ipOXYGEN];
00898 }
00899 else if( dense.lgElmtOn[ipSILICON] &&
00900 dense.xMolecules[ipSILICON] > dense.gas_phase[ipSILICON]*(1.+EPS_MOLE) )
00901 {
00902 conv.lgConvIoniz = false;
00903 sprintf( conv.chConvIoniz, "COcon%2i",ipSILICON );
00904 conv.BadConvIoniz[0] = dense.xMolecules[ipSILICON];
00905 conv.BadConvIoniz[1] = dense.gas_phase[ipSILICON];
00906 }
00907 else if( dense.lgElmtOn[ipSULPHUR] &&
00908 dense.xMolecules[ipSULPHUR] > dense.gas_phase[ipSULPHUR]*(1.+EPS_MOLE) )
00909 {
00910 conv.lgConvIoniz = false;
00911 sprintf( conv.chConvIoniz, "COcon%2i",ipSULPHUR );
00912 conv.BadConvIoniz[0] = dense.xMolecules[ipSULPHUR];
00913 conv.BadConvIoniz[1] = dense.gas_phase[ipSULPHUR];
00914 }
00915 else if( dense.lgElmtOn[ipNITROGEN] &&
00916 dense.xMolecules[ipNITROGEN] > dense.gas_phase[ipNITROGEN]*(1.+EPS_MOLE) )
00917 {
00918 conv.lgConvIoniz = false;
00919 sprintf( conv.chConvIoniz, "COcon%2i",ipNITROGEN );
00920 conv.BadConvIoniz[0] = dense.xMolecules[ipNITROGEN];
00921 conv.BadConvIoniz[1] = dense.gas_phase[ipNITROGEN];
00922 }
00923
00924 else if( dense.lgElmtOn[ipCHLORINE] &&
00925 dense.xMolecules[ipCHLORINE] > dense.gas_phase[ipCHLORINE]*(1.+EPS_MOLE) )
00926 {
00927 conv.lgConvIoniz = false;
00928 sprintf( conv.chConvIoniz, "COcon%2i",ipCHLORINE );
00929 conv.BadConvIoniz[0] = dense.xMolecules[ipCHLORINE];
00930 conv.BadConvIoniz[1] = dense.gas_phase[ipCHLORINE];
00931 }
00932
00933
00934 co.nitro_dissoc_rate = (realnum)(CO_dissoc_rate("N"));
00935 return;
00936
00937
00938
00939 }
00940
00941 # undef EPS_MOLE