Changeset 1196

Show
Ignore:
Timestamp:
06/15/07 19:09:54 (1 year ago)
Author:
rporter
Message:

More iso refactoring. Still no botches. Biggest changes are as follows:

helike_level.cpp and hydrolevelpop.cpp have been deleted and replaced with new iso_level.cpp

In quantumState structure, spin variable s has been replaced by S, often used to denote multiplicity. This way the number will always be an integer, which, of course, is not the case for spin. Many of the files only changed as a reflection of this change. In some places, 2*s+1 were changed to just S.

prt_He_like_DeparCoef and prt_He_like_Pops were merged and renamed to iso_prt_pops, which now takes a third flag that causes departure coefficients to be printed if true. H-like analogs prt_H_like_DeparCoef and prt_H_like_Pops are now only sticking around for ease of comparison with old output. Will go away when new treatment is fully functional. Won't be long now!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/porter/source/assert_results.cpp

    r1185 r1196  
    23802380                                                                                StatesElem[ipHE_LIKE][ipHELIUM][ipHi].n, 
    23812381                                                                                StatesElem[ipHE_LIKE][ipHELIUM][ipHi].l, 
    2382                                                                                 StatesElem[ipHE_LIKE][ipHELIUM][ipHi].s
     2382                                                                                StatesElem[ipHE_LIKE][ipHELIUM][ipHi].S
    23832383                                                                                StatesElem[ipHE_LIKE][ipHELIUM][ipLo].n, 
    23842384                                                                                StatesElem[ipHE_LIKE][ipHELIUM][ipLo].l, 
    2385                                                                                 StatesElem[ipHE_LIKE][ipHELIUM][ipLo].s ); 
     2385                                                                                StatesElem[ipHE_LIKE][ipHELIUM][ipLo].S ); 
    23862386                                                                        break; 
    23872387                                                                } 
  • branches/porter/source/cddefines.h

    r1191 r1196  
    10311031        double ConBoltz; 
    10321032 
    1033         long n, l, s, j; 
     1033        /* S is multiplicity. */ 
     1034        long n, l, S, j; 
    10341035 
    10351036        double lifetime; 
  • branches/porter/source/conv_base.cpp

    r1136 r1196  
    423423                /* do all hydrogenic species, and fully do hydrogen itself, including molecules */ 
    424424                /*fprintf(ioQQQ,"DEBUG h2\t%.2f\t%.3e\t%.3e", fnzone,hmi.H2_total,hmi.Hmolec[ipMH2g]);*/ 
    425                 Hydrogenic(); 
     425                Hydrogenic( ipH_LIKE ); 
    426426                /*fprintf(ioQQQ,"\t%.3e\n", hmi.Hmolec[ipMH2g]);*/ 
    427427 
     
    437437                /* >>chng 02 mar 08 move helike to before helium */ 
    438438                /* do all he-like species */ 
    439                 HeLike(); 
     439                HeLike( ipHE_LIKE ); 
    440440 
    441441                /*>>chng 04 may 09, add option to abort here, inspired by H2 pop failures 
  • branches/porter/source/helike.cpp

    r1192 r1196  
    11/* This file is part of Cloudy and is copyright (C)1978-2007 by Gary J. Ferland 
    22 * For conditions of distribution and use see copyright notice in license.txt */ 
    3 /*prt_He_like_DeparCoef print departure coefficients for helium-like species */ 
    4 /*prt_He_like_Pops print level populations for helium-like species */ 
    5 /*HeCreate create he-like series, called by ContCreatePointers */ 
     3/*He-like main routine to call HeLevel and determine model he-like species atom level balance, 
     4 * called by ionize */ 
    65/*AGN_He1_CS routine to punch table needed for AGN3 - collision strengths of HeI */ 
    7 /*defect - calculate quantum defect. */ 
    8 /*helike_energy - calculates energy of a given level.   */ 
    9  
    106#include "cddefines.h"  
    11  
    12 /* various useful print statements occur throughout this file - search on PRINTIT */ 
    13 /*  
    14    
    15   Energy order within 2 3P 
    16  
    17   The order of the levels within the 2 3P level of atomic helium is opposite 
    18   from the order within astrophysically abundant ions.  The indices below 
    19   consistently point to the correct level, and the energies are correct, 
    20   so the J levels within 2 3P are not in increasing energy order for helium itself.  
    21   This is ok since the atomic data is correct, and the difference in energies is so small. 
    22  
    23 */ 
    24  
    25 /*  
    26 the following block of defines occurs in cddefines.h  
    27 const int ipHe1s1S = 0; 
    28 const int ipHe2s3S = 1; 
    29 const int ipHe2s1S = 2; 
    30 const int ipHe2p3P0 = 3; 
    31 const int ipHe2p3P1 = 4; 
    32 const int ipHe2p3P2 = 5; 
    33 const int ipHe2p1P = 6; 
    34  
    35 level 3 
    36 const int ipHe3s3S = 7; 
    37 const int ipHe3s1S = 8; 
    38 const int ipHe3p3P = 9; 
    39 const int ipHe3d3D = 10; 
    40 const int ipHe3d1D = 11; 
    41 const int ipHe3p1P = 12; 
    42  
    43 level 4 
    44 const int ipHe4s3S = 13; 
    45 const int ipHe4s1S = 14; 
    46 const int ipHe4p3P = 15; 
    47 const int ipHe4d3D = 16; 
    48 const int ipHe4d1D = 17; 
    49 const int ipHe4f3F = 18; 
    50 const int ipHe4f1F = 19; 
    51 const int ipHe4p1P = 20; 
    52 */ 
    53  
    54 /*const int ipRad = 0; 
    55 const int ipCollis = 1; 
    56 const int ipEnergy = 2;*/ 
    57  
    58  
    597#include "dense.h" 
    608#include "elementnames.h" 
     
    6210#include "helike_cs.h" 
    6311#include "helike_recom.h" 
     12#include "hydrogenic.h" 
    6413#include "iso.h" 
    6514#include "phycon.h" 
     
    7120/*lint -e661 creation of  out of bound pointer */ 
    7221 
    73 /*static long ipLev,globalZ;*/ 
    74  
    75 /* Ionization potentials (in eV) for each ion in the iso-seq up to Z=30. These are  
    76  * exactly what you get if you take Verner's numbers in atmdat_ph1(0,1,nelem,0)  
    77  * and multiply by 0.9998787, exactly as is done elsewhere in Cloudy.   */ 
    78 double EionEV[29] =        
    79         {24.59077,75.630824,153.881326,259.368529,392.052444,552.033006,739.210311, 
    80         953.784316,1195.854925,1464.822296,1761.786269,2085.746968,2437.704271, 
    81         2816.658298,3223.608929,3658.556163,4120.500123,4610.440686,5128.377852, 
    82         5674.311623,6248.241996,6851.168852,7481.092433,8140.012497,8827.929042, 
    83         9543.842191,10288.751823,11058.658422,11868.560169}; 
    84  
    8522/*He-like main routine to call HeLevel and determine model he-like species atom level balance, 
    8623 * called by ionize */ 
    87 void HeLike(void
     24void HeLike(long ipISO
    8825{ 
    89         int lowsav , ihisav; 
    90          
    91         long int ipLo, ipHi, nelem, 
    92                 ipISO=ipHE_LIKE; 
     26        long int ipLo, 
     27                ipHi, 
     28                nelem, 
     29                lowsav, 
     30                ihisav; 
    9331        static bool lgFinitePop[LIMELM]; 
    9432        static bool lgMustInit=true; 
     
    13472 
    13573                                /* evaluate collisional rates */ 
    136                                 HeCollid( nelem ); 
     74                                if( ipISO == ipH_LIKE ) 
     75                                        HydroCollid(nelem); 
     76                                else if( ipISO == ipHE_LIKE ) 
     77                                        HeCollid( nelem ); 
     78                                else 
     79                                        TotalInsanity(); 
    13780 
    13881                                /* evaluate photoionization rates */ 
     
    14790 
    14891                                /* solve for the level populations */ 
    149                                 HeLikeLevel( ipISO, nelem ); 
     92                                iso_level( ipISO, nelem ); 
    15093 
    15194                                /* say that we have set the populations */ 
     
    15497                                if( trace.lgTrace ) 
    15598                                { 
    156                                         fprintf( ioQQQ, "       Helium-like Z=%2ld H2OVH1=",nelem); 
     99                                        fprintf( ioQQQ, "       iso=%2ld Z=%2ld H2OVH1=",ipISO,nelem); 
    157100                                        fprintf( ioQQQ,PrintEfmt("%10.3e", iso.pop_ion_ov_neut[ipISO][nelem])); 
    158101                                        fprintf( ioQQQ, " simple="); 
     
    430373} 
    431374 
    432 /*prt_He_like_DeparCoef print departure coefficients for he-like species */ 
    433 void prt_He_like_DeparCoef( long ipISO, long nelem
     375/*prt_iso_Pops print out iso sequence populations or departure coefficients */ 
     376void iso_prt_pops( long ipISO, long nelem, long lgPrtDeparCoef
    434377{ 
    435378        long int in, il, is, i, ipLo, nResolved, ipFirstCollapsed=LONG_MIN; 
    436          
    437         DEBUG_ENTRY( "prt_He_like_DeparCoef()" ); 
    438          
    439         for( is = 0; is<=1; ++is) 
    440         { 
    441                 char chSpin[2][9]={"singlets","triplets"}; 
    442  
    443                 ipFirstCollapsed= iso.numLevels_local[ipISO][nelem]-iso.nCollapsed_local[ipISO][nelem]; 
    444                 nResolved = StatesElem[ipISO][nelem][ipFirstCollapsed-1].n; 
    445                 ASSERT( nResolved == iso.n_HighestResolved_local[ipISO][nelem] ); 
    446                 ASSERT(nResolved > 0 ); 
    447                  
    448                 /* give element number and spin */ 
    449                 fprintf(ioQQQ," He-like %s  %s departure\n", 
    450                         elementnames.chElementSym[nelem], 
    451                         chSpin[is]); 
    452  
    453                 /* header with the l states */ 
    454                 fprintf(ioQQQ," n\\l=>         "); 
    455                 for( i =0; i < nResolved; ++i) 
    456                 { 
    457                         fprintf(ioQQQ,"%2ld       ",i); 
    458                 } 
    459                 fprintf(ioQQQ,"\n"); 
    460          
    461                 /* loop over prin quant numbers, one per line, with l across */ 
    462                 for( in = is+1; in <= nResolved; ++in) 
    463                 { 
    464                         fprintf(ioQQQ," %2ld           ",in); 
    465                         for( il = 0; il < in; ++il) 
    466                         { 
    467                                 if( (in==2) && (il==1) && (is==1) ) 
    468                                 { 
    469                                         fprintf( ioQQQ,PrintEfmt("%9.2e", iso.DepartCoef[ipISO][nelem][ipHe2p3P0])); 
    470                                         fprintf( ioQQQ,PrintEfmt("%9.2e", iso.DepartCoef[ipISO][nelem][ipHe2p3P1])); 
    471                                         fprintf( ioQQQ,PrintEfmt("%9.2e", iso.DepartCoef[ipISO][nelem][ipHe2p3P2])); 
    472                                 } 
    473                                 else 
    474                                 { 
    475                                         ipLo = iso.QuantumNumbers2Index[ipISO][nelem][in][il][is]; 
    476                                         fprintf( ioQQQ,PrintEfmt("%9.2e", iso.DepartCoef[ipISO][nelem][ipLo])); 
    477                                 } 
    478                         } 
    479                         fprintf(ioQQQ,"\n"); 
    480                 } 
    481         }                
    482         /* above loop was over spin, now do collapsed levels, no spin or ang momen */ 
    483         for( il = ipFirstCollapsed; il < iso.numLevels_local[ipISO][nelem]; ++il) 
    484         { 
    485                 in = StatesElem[ipISO][nelem][il].n; 
    486  
    487                 /* prin quan number of collapsed levels */ 
    488                 fprintf(ioQQQ," %2ld           ",in); 
    489                 fprintf( ioQQQ,PrintEfmt("%9.2e", iso.DepartCoef[ipISO][nelem][il])); 
    490                 fprintf(ioQQQ,"\n"); 
    491         }                
    492          
    493         DEBUG_EXIT( "prt_He_like_DeparCoef()" ); 
    494         return; 
    495 
    496  
    497 /*prt_He_like_Pops print out helium-like populations */ 
    498 void prt_He_like_Pops( long ipISO, long nelem ) 
    499 
    500         long int in, il, is, i, ipLo, nResolved, ipFirstCollapsed=LONG_MIN; 
    501  
    502         DEBUG_ENTRY( "prt_He_like_Pops()" ); 
    503  
    504         for( is = 0; is<=1; ++is) 
    505         { 
    506                 char chSpin[2][9]={"singlets","triplets"}; 
     379        char chPrtType[2][12]={"populations","departure"}; 
     380        /* first dimension is multiplicity */ 
     381        char chSpin[3][9]= {"singlets", "doublets", "triplets"}; 
     382 
     383#define ITEM_TO_PRINT(A_)       ( lgPrtDeparCoef ? iso.DepartCoef[ipISO][nelem][A_] : StatesElem[ipISO][nelem][A_].Pop ) 
     384 
     385        DEBUG_ENTRY( "iso_prt_pops()" ); 
     386 
     387        ASSERT( ipISO < NISO ); 
     388 
     389#ifndef NEWHYDRO 
     390        if( ipISO == ipH_LIKE ) 
     391        { 
     392                fprintf(ioQQQ,"\n\n NB H-like %s print-out is broken for old treatment.  I'm terribly sorry, but I had to let it die.\n  It'll be back soon and better than ever.\n\n", 
     393                        chPrtType[ipH_LIKE] ); 
     394                DEBUG_EXIT( "iso_prt_pops()" ); 
     395                return; 
     396        } 
     397#endif 
     398 
     399        for( is = 1; is<=3; ++is) 
     400        { 
     401                if( ipISO == ipH_LIKE && is != 2 ) 
     402                        continue; 
     403                else if( ipISO == ipHE_LIKE && is != 1 && is != 3 ) 
     404                        continue; 
    507405 
    508406                ipFirstCollapsed= iso.numLevels_local[ipISO][nelem]-iso.nCollapsed_local[ipISO][nelem]; 
     
    512410         
    513411                /* give element number and spin */ 
    514                 fprintf(ioQQQ," He-like %s  %s populations\n", 
     412                fprintf(ioQQQ," He-like %s  %s %s\n", 
    515413                        elementnames.chElementSym[nelem], 
    516                         chSpin[is]); 
     414                        chSpin[is-1], 
     415                        chPrtType[lgPrtDeparCoef]); 
    517416 
    518417                /* header with the l states */ 
     
    525424 
    526425                /* loop over prin quant numbers, one per line, with l across */ 
    527                 for( in = is+1; in <= nResolved; ++in) 
    528                 { 
     426                for( in = 1; in <= nResolved; ++in) 
     427                { 
     428                        if( is==3 && in==1 ) 
     429                                continue; 
     430 
    529431                        fprintf(ioQQQ," %2ld           ",in); 
    530432 
    531433                        for( il = 0; il < in; ++il) 
    532434                        { 
    533                                 if( (in==2) && (il==1) && (is==1) ) 
    534                                 { 
    535                                         fprintf( ioQQQ,PrintEfmt("%9.2e", StatesElem[ipISO][nelem][ipHe2p3P0].Pop)); 
    536                                         fprintf( ioQQQ,PrintEfmt("%9.2e", StatesElem[ipISO][nelem][ipHe2p3P1].Pop)); 
    537                                         fprintf( ioQQQ,PrintEfmt("%9.2e", StatesElem[ipISO][nelem][ipHe2p3P2].Pop)); 
     435                                if( ipISO==ipHE_LIKE && (in==2) && (il==1) && (is==3) ) 
     436                                { 
     437                                        fprintf( ioQQQ,PrintEfmt("%9.2e", ITEM_TO_PRINT(ipHe2p3P0) )); 
     438                                        fprintf( ioQQQ,PrintEfmt("%9.2e", ITEM_TO_PRINT(ipHe2p3P1) )); 
     439                                        fprintf( ioQQQ,PrintEfmt("%9.2e", ITEM_TO_PRINT(ipHe2p3P2) )); 
    538440                                } 
    539441                                else 
    540442                                { 
    541443                                        ipLo = iso.QuantumNumbers2Index[ipISO][nelem][in][il][is]; 
    542                                         fprintf( ioQQQ,PrintEfmt("%9.2e", StatesElem[ipISO][nelem][ipLo].Pop)); 
     444                                        fprintf( ioQQQ,PrintEfmt("%9.2e", ITEM_TO_PRINT(ipLo) )); 
    543445                                } 
    544446                        } 
     
    552454                /* prin quan number of collapsed levels */ 
    553455                fprintf(ioQQQ," %2ld           ",in); 
    554                 fprintf( ioQQQ,PrintEfmt("%9.2e", StatesElem[ipISO][nelem][il].Pop)); 
     456                fprintf( ioQQQ,PrintEfmt("%9.2e", ITEM_TO_PRINT(il) )); 
    555457                fprintf(ioQQQ,"\n"); 
    556458        } 
    557459 
    558         DEBUG_EXIT( "prt_He_like_Pops()" ); 
     460        DEBUG_EXIT( "iso_prt_pops()" ); 
    559461        return; 
    560462} 
  • branches/porter/source/helike.h

    r1192 r1196  
    2222#define CASEABMAGIC             (51214) 
    2323 
    24 /** He-like main routine to call HeLikeLevel and determine  
    25  * model he-like species atom level balance     */ 
    26 void HeLike(void); 
     24/**He-like main routine to call iso_level and determine  
     25 * model he-like species atom level balance      
     26\param ipISO 
     27*/ 
     28void HeLike(long ipISO); 
    2729 
    28 /**HeLikeLevel level populations   
     30/**HeCreate create he-like series 
    2931\param ipISO 
    30 \param nelem 
    3132*/ 
    32 void HeLikeLevel( long int ipISO, long int nelem); 
    33  
    34 /** create he-like series */ 
    3533void HeCreate( long ipISO ); 
    3634 
    37 /** read in helium collision data files */ 
     35/**HeCollidSetup read in helium collision data files */ 
    3836void HeCollidSetup( void ); 
    3937 
    40 /** get helike level energy in cm-1  
     38/**helike_energy get helike level energy in cm-1  
    4139\param nelem 
    4240\param ipLev  
     
    4442double helike_energy(long nelem, long ipLev ); 
    4543 
    46 /** get helike quantum defect  
     44/**helike_quantum_defect get quantum defect for helium-like level 
    4745\param nelem 
    4846\param ipLev 
     
    5048double helike_quantum_defect( long int nelem, long int ipLev ); 
    5149 
    52 /** get helike transition probability in s-1  
     50/**helike_transprob get transition probability for helium-like transition [s-1] 
    5351\param nelem 
    5452\param ipHi 
     
    5755float helike_transprob( long nelem, long ipHi, long ipLo ); 
    5856 
    59 /** routine to print departure coefficients for he-like species  
    60 \param nelem 
    61 */ 
    62 void prt_He_like_DeparCoef(long int ipISO, long int nelem ); 
    63  
    64 /** routine to print level pops for he-like species  
    65 \param nelem 
    66 */ 
    67 void prt_He_like_Pops(long int ipISO, long int nelem ); 
    68  
    69 /** routine to punch table needed for AGN3 - collision strengths of HeI  
     57/**AGN_He1_CS routine to punch table needed for AGN3 - collision strengths of HeI  
    7058\param *ioPun 
    7159*/ 
    7260void AGN_He1_CS( FILE *ioPun ); 
    7361 
    74 /** this becomes the most number of levels in any member of the he-like iso sequence */ 
    75 EXTERN long int max_num_levels, max_n; 
     62/** this becomes the largest n ever explicitly considered in the he-like iso sequence  
     63 * resolved or collapsed is irrelevant.  */ 
     64EXTERN long int max_n; 
    7665 
  • branches/porter/source/helike_create.cpp

    r1191 r1196  
    11/* This file is part of Cloudy and is copyright (C)1978-2007 by Gary J. Ferland 
    22 * For conditions of distribution and use see copyright notice in license.txt */ 
    3 #include "cddefines.h"  
     3#include "cddefines.h" 
     4#include "atmdat.h" 
    45#include "physconst.h"  
    56#include "lines_service.h" 
     
    1718#include "helike_einsta.h" 
    1819 
     20/* 
     21  Energy order within 2 3P 
     22 
     23  The order of the levels within the 2 3P level of atomic helium is opposite 
     24  from the order within astrophysically abundant ions.  The indices below 
     25  consistently point to the correct level, and the energies are correct, 
     26  so the J levels within 2 3P are not in increasing energy order for helium itself.  
     27  This is ok since the atomic data is correct, and the difference in energies is so small. 
     28*/ 
     29 
     30/*  
     31the following block of defines occurs in cddefines.h  
     32const int ipHe1s1S = 0; 
     33const int ipHe2s3S = 1; 
     34const int ipHe2s1S = 2; 
     35const int ipHe2p3P0 = 3; 
     36const int ipHe2p3P1 = 4; 
     37const int ipHe2p3P2 = 5; 
     38const int ipHe2p1P = 6; 
     39 
     40level 3 
     41const int ipHe3s3S = 7; 
     42const int ipHe3s1S = 8; 
     43const int ipHe3p3P = 9; 
     44const int ipHe3d3D = 10; 
     45const int ipHe3d1D = 11; 
     46const int ipHe3p1P = 12; 
     47 
     48level 4 
     49const int ipHe4s3S = 13; 
     50const int ipHe4s1S = 14; 
     51const int ipHe4p3P = 15; 
     52const int ipHe4d3D = 16; 
     53const int ipHe4d1D = 17; 
     54const int ipHe4f3F = 18; 
     55const int ipHe4f1F = 19; 
     56const int ipHe4p1P = 20; 
     57*/ 
     58 
    1959/* the designation of the levels, chLevel[n][string] */ 
    2060static char **chLevel; 
    2161 
    22 /* Ionization potentials (in wavenumber) for each ion in the iso-seq up to Z=30.               */ 
    23 /* These are exactly what you get if you take EionRYD below and multiply by RYD_INF.  */ 
     62/* Ionization potentials (in wavenumber) for each ion in the iso-seq up to Z=30. 
     63 * These are exactly what you get if you take EionRYD below and multiply by RYD_INF.  */ 
    2464static double EionWN[LIMELM] =        
    2565        /* the first, or H-like, element is not defined for he-like species */ 
    26         {-DBL_MAX, 
    27         198310.6679     ,610003.839889137,1241136.72201499,2091948.45665631,3162116.52584231, 
    28         4452446.95015668,5962133.81875305,7692790.05069734,9645221.44709864,11814589.7994457, 
    29         14209766.0528639,16822685.5022862,19661412.9625169,22717883.6187518,26000162.0663204, 
    30         29508248.5246975,33234078.1790787,37185715.7345311,41363161.0813172,45766414.4389118, 
    31         50395475.4781030,55258409.0136949,60339085.8550283,65653635.1927626,71202056.8074231, 
    32         76976286.4328920,82984388.3352872,89194104.5722390,95726403.3055320}; 
     66        {-DBL_MAX, 
     67        198310.6679     ,610003.839889137,1241136.72201499,2091948.45665631,3162116.52584231, 
     68        4452446.95015668,5962133.81875305,7692790.05069734,9645221.44709864,11814589.7994457, 
     69        14209766.0528639,16822685.5022862,19661412.9625169,22717883.6187518,26000162.0663204, 
     70        29508248.5246975,33234078.1790787,37185715.7345311,41363161.0813172,45766414.4389118, 
     71        50395475.4781030,55258409.0136949,60339085.8550283,65653635.1927626,71202056.8074231, 
     72        76976286.4328920,82984388.3352872,89194104.5722390,95726403.3055320}; 
    3373         
    34 /* Ionization potentials (in Rydbergs) for each ion in the iso-seq up to Z=30.  */ 
    35 /* These are exactly what you get if you take EionEV below and divide by EVRYD.       */ 
     74/* Ionization potentials (in Rydbergs) for each ion in the iso-seq up to Z=30.   
     75 * These are exactly what you get if you take EionEV below and divide by EVRYD.       */ 
    3676static double EionRYD[LIMELM] =        
    3777        /* the first, or H-like, element is not defined for he-like species */ 
     
    4282        549.850208,598.279945,648.840883,701.459535,756.209388,812.796486,872.323172}; 
    4383 
     84/* Ionization potentials (in eV) for each ion in the iso-seq up to Z=30. These are  
     85 * exactly what you get if you take Verner's numbers in atmdat_ph1(0,1,nelem,0)  
     86 * and multiply by 0.9998787, exactly as is done elsewhere in Cloudy.   */ 
     87double EionEV[LIMELM] =        
     88        /* the first, or H-like, element is not defined for he-like species */ 
     89        {-DBL_MAX, 
     90        24.59077,75.630824,153.881326,259.368529,392.052444,552.033006,739.210311, 
     91        953.784316,1195.854925,1464.822296,1761.786269,2085.746968,2437.704271, 
     92        2816.658298,3223.608929,3658.556163,4120.500123,4610.440686,5128.377852, 
     93        5674.311623,6248.241996,6851.168852,7481.092433,8140.012497,8827.929042, 
     94        9543.842191,10288.751823,11058.658422,11868.560169}; 
    4495 
    4596/* experimental energies, in wavenumbers, for atomic helium */ 
     
    297348        long int n = StatesElem[ipHE_LIKE][nelem][ipLo].n; 
    298349        long int lqn = StatesElem[ipHE_LIKE][nelem][ipLo].l; 
    299         long int s = StatesElem[ipHE_LIKE][nelem][ipLo].s; 
     350        long int S = StatesElem[ipHE_LIKE][nelem][ipLo].S; 
     351        long int s; 
     352 
     353        if( S==1 ) 
     354                s = 0; 
     355        else if( S==3 ) 
     356                s = 1; 
     357        else if( S < 0 ) 
     358        { 
     359                ASSERT( n > iso.n_HighestResolved_max[ipHE_LIKE][nelem] ); 
     360                s = S; 
     361        } 
     362        else 
     363                TotalInsanity(); 
    300364 
    301365        DEBUG_ENTRY( "helike_quantum_defect()" ); 
     
    410474        { 
    411475                Eff_n = N_(ipLev) - helike_quantum_defect( nelem, ipLev ); 
    412                 ASSERT( ( L_(ipLev)==1 && S_(ipLev)==0 ) || ( N_(ipLev) - Eff_n >= 0. ) ); 
     476                /* quantum defect can only be negative for singlet P */ 
     477                ASSERT( ( L_(ipLev)==1 && S_(ipLev)==1 ) || ( N_(ipLev) - Eff_n >= 0. ) ); 
    413478 
    414479                /* energies (in wavenumbers) that correspond to quantum defect */ 
     
    430495        double **SumAPerN, **RobbinsC; 
    431496 
    432         long int i, j, ipLo, ipHi, ipFirstCollapsed, nelem; 
     497        long int i, j, ipLo, ipHi, nelem; 
    433498 
    434499        static int nCalled = 0; 
    435500 
    436         char chSpin[2]={'1','3'}; 
    437501        char chL[6]={'S','P','D','F','G','H'}; 
    438502 
     
    454518        } 
    455519 
    456         /* first find the largest number of levels in any element in the iso sequence */ 
    457         max_num_levels = 0; 
     520        /** find the largest n ever explicitly considered in the he-like iso sequence  
     521        * resolved or collapsed is irrelevant.  */ 
    458522        max_n = 0; 
    459523        for( nelem=ipISO; nelem < LIMELM; nelem++ ) 
     
    462526                if( nelem == ipISO || dense.lgElmtOn[nelem] ) 
    463527                { 
    464                         max_num_levels = MAX2( max_num_levels, iso.numLevels_max[ipISO][nelem] ); 
    465528                        max_n = MAX2( max_n, iso.n_HighestResolved_max[ipISO][nelem] + iso.nCollapsed_max[ipISO][nelem] ); 
    466529                } 
     
    509572                        } 
    510573 
    511                         /* this is the number of resolved levels, so first collapsed level is [ipFirstCollapsed] */ 
    512                         ipFirstCollapsed = iso.numLevels_max[ipISO][nelem]-iso.nCollapsed_max[ipISO][nelem];  
    513                          
    514574                        /* Initialize some ground state stuff, easier here than in loops.       */ 
    515575                        RobbinsC[ipHe1s1S][ipHe1s1S] = 1.; 
    516                         StatesElem[ipISO][nelem][ipHe1s1S].lifetime = 0.; 
    517576                        iso.CascadeProb[ipISO][nelem][ipHe1s1S][ipHe1s1S] = 1.; 
    518577                        if( iso.lgRandErrGen[ipISO] ) 
     
    522581                        } 
    523582 
    524                         StatesElem[ipHE_LIKE][nelem][ipHe1s1S].g = 1.f; 
    525  
    526                         /** \todo 2 remove the next two loops.  */ 
    527                         /* Already done in iso_create, here we just assert sanity.  */ 
    528  
    529                         /************************************************/ 
    530                         /**********  Transition probabilities ***********/ 
    531                         /************************************************/ 
    532                         for( ipHi=ipHe2s3S; ipHi<iso.numLevels_max[ipISO][nelem]; ipHi++ ) 
    533                         { 
    534                                 for( ipLo=ipHe1s1S; ipLo<ipHi; ipLo++ ) 
    535                                 { 
    536                                         double Aul; 
    537                                         /* set the transition probability */ 
    538                                         Aul = helike_transprob(nelem, ipHi, ipLo); 
    539                                         ASSERT(Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul == Aul); 
    540                                         SumAPerN[nelem][N_(ipHi)] += Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul; 
    541                                 } 
    542                         } 
    543  
    544                         /************************************************/ 
    545                         /**********  Lifetimes of levels   **************/ 
    546                         /************************************************/ 
    547                         for( ipHi=ipHe2s3S; ipHi<iso.numLevels_max[ipISO][nelem]; ipHi++ ) 
    548                         { 
    549                                 double dummyLifetime = SMALLFLOAT; 
    550                                  
    551                                 for( ipLo=ipHe1s1S; ipLo<ipHi; ipLo++ ) 
    552                                 {        
    553                                         /* This is not actually the lifetime...must invert when all A's added.  */ 
    554                                         /* No stat. weight is needed because this is the lifetime of an individual level, 
    555                                          * Collapsed or resolved is irrelevant. */ 
    556                                         dummyLifetime += Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul; 
    557                                 } 
    558                                  
    559                                 /* convert sum of As into proper lifetime in seconds */ 
    560                                 dummyLifetime = 1./dummyLifetime; 
    561                                 ASSERT( StatesElem[ipISO][nelem][ipHi].lifetime == dummyLifetime ); 
    562                         } 
    563  
    564                         /************************************************/ 
    565                         /**********  stuff gf, opacity, etc.   **********/ 
    566                         /************************************************/ 
     583                        /***************************************************************************/ 
     584                        /****** Cascade probabilities, Branching ratios, and associated errors *****/ 
     585                        /***************************************************************************/ 
    567586                        for( ipHi=ipHe2s3S; ipHi<iso.numLevels_max[ipISO][nelem]; ipHi++ ) 
    568587                        { 
     
    570589                                RobbinsC[ipHi][ipHi] = 1.; 
    571590                                iso.CascadeProb[ipISO][nelem][ipHi][ipHi] = 1.; 
     591                                iso.BranchRatio[ipISO][nelem][ipHi][ipHe1s1S] = 0.; 
     592 
    572593                                if( iso.lgRandErrGen[ipISO] ) 
    573594                                { 
     
    575596                                        iso.SigmaCascadeProb[ipISO][nelem][ipHi][ipHi] = 0.; 
    576597                                } 
    577                          
     598 
    578599                                for( ipLo=ipHe1s1S; ipLo<ipHi; ipLo++ ) 
    579600                                { 
    580601                                        RobbinsC[ipHi][ipLo] = 0.; 
    581602                                        iso.CascadeProb[ipISO][nelem][ipHi][ipLo] = 0.; 
     603                                        iso.BranchRatio[ipISO][nelem][ipHi][ipLo] =  
     604                                                Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul * 
     605                                                StatesElem[ipISO][nelem][ipHi].lifetime; 
     606                                        /* >>chng 06 mar 08, had been <= 1.0000001, increased to 
     607                                         * when Aul converted to float */ 
     608                                        /* \todo 2 find out what's wrong here. */ 
     609                                        ASSERT( iso.BranchRatio[ipISO][nelem][ipHi][ipLo] <= 1.007 ); 
     610 
     611                                        SumAPerN[nelem][N_(ipHi)] += Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul; 
    582612 
    583613                                        /* there are some negative energy transitions, where the order 
     
    587617                                                Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul <= iso.SmallA ); 
    588618 
    589 #if     0 
    590                                         /* very forbidden transitions may have negative energies */ 
    591                                         if( Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul <= iso.SmallA || 
    592                                                 Transitions[ipISO][nelem][ipHi][ipLo].EnergyWN <= 0.) 
     619                                        if( iso.lgRandErrGen[ipISO] ) 
    593620                                        { 
    594                                                 /* this branch - bogus line */ 
    595                                                 /* transition energy in various units:*/ 
    596  
    597                                                 /* take abs value since some have order switched */ 
    598                                                 /* make following an air wavelength */ 
    599                                                 Transitions[ipISO][nelem][ipHi][ipLo].WLAng = 1e6f; 
    600  
    601                                                 Transitions[ipISO][nelem][ipHi][ipLo].Emis.gf = 1e-20f; 
    602  
    603                                                 /* derive the abs coef, call to function is Emis.gf, wl (A), g_low */ 
    604                                                 Transitions[ipISO][nelem][ipHi][ipLo].Emis.opacity = 0.; 
     621                                                ASSERT( iso.Error[ipISO][nelem][ipHi][ipLo][IPRAD] >= 0. ); 
     622                                                /* Uncertainties in A's are added in quadrature, square root is taken below. */ 
     623                                                iso.SigmaAtot[ipISO][nelem][ipHi] +=  
     624                                                        pow( iso.Error[ipISO][nelem][ipHi][ipLo][IPRAD] *  
     625                                                        (double)Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul, 2. ); 
    605626                                        } 
    606                                         else 
     627                                } 
     628 
     629                                if( iso.lgRandErrGen[ipISO] ) 
     630                                { 
     631                                        /* Uncertainties in A's are added in quadrature above, square root taken here. */ 
     632                                        iso.SigmaAtot[ipISO][nelem][ipHi] = sqrt( iso.SigmaAtot[ipISO][nelem][ipHi] ); 
     633                                } 
     634 
     635                                /* cascade probabilities */ 
     636                                for( ipLo=ipHe1s1S; ipLo<ipHi; ipLo++ ) 
     637                                { 
     638                                        double SigmaA, SigmaCul = 0.; 
     639                                        /*ASSERT( ipLo < ipHi );*/ 
     640                                        for( i=ipLo /* + 1*/; i<ipHi; i++ ) 
    607641                                        { 
    608                                                 /* take abs value since some have order switched */ 
    609                                                 /* make following an air wavelength */ 
    610                                                 Transitions[ipISO][nelem][ipHi][ipLo].WLAng =  
    611                                                         (float)fabs(1.0e8/ 
    612                                                         Transitions[ipISO][nelem][ipHi][ipLo].EnergyWN/ 
    613                                                         RefIndex( Transitions[ipISO][nelem][ipHi][ipLo].EnergyWN )); 
     642                                                RobbinsC[ipHi][ipLo] += iso.BranchRatio[ipISO][nelem][ipHi][i] * RobbinsC[i][ipLo]; 
     643                                                if( iso.lgRandErrGen[ipISO] ) 
     644                                                { 
     645                                                        /* Uncertainties in A's and cascade probabilities */ 
     646                                                        SigmaA = iso.Error[ipISO][nelem][ipHi][i][IPRAD] *  
     647                                                                Transitions[ipHE_LIKE][nelem][ipHi][i].Emis.Aul; 
     648                                                        SigmaCul +=  
     649                                                                pow(SigmaA*RobbinsC[i][ipLo]*StatesElem[ipISO][nelem][ipHi].lifetime, 2.) + 
     650                                                                pow(iso.SigmaAtot[ipISO][nelem][ipHi]*iso.BranchRatio[ipISO][nelem][ipHi][i]*RobbinsC[i][ipLo]*StatesElem[ipISO][nelem][ipHi].lifetime, 2.) + 
     651                                                                pow(iso.SigmaCascadeProb[ipISO][nelem][i][ipLo]*iso.BranchRatio[ipISO][nelem][ipHi][i], 2.); 
     652                                                } 
    614653                                                 
    615                                                 Transitions[ipISO][nelem][ipHi][ipLo].Emis.gf =  
    616                                                         (float)(GetGF(Transitions[ipISO][nelem][ipHi][ipLo].Emis.Aul, 
    617                                                         Transitions[ipISO][nelem][ipHi][ipLo].EnergyWN, 
    618                                                         Transitions[ipISO][nelem][ipHi][ipLo].Hi.g)); 
    619                                                 ASSERT(Transitions[ipISO][nelem][ipHi][ipLo].Emis.gf > 0.); 
    620  
    621                                                 /* derive the abs coef, call to function is Emis.gf, wl (A), g_low */ 
    622                                                 Transitions[ipISO][nelem][ipHi][ipLo].Emis.opacity =  
    623                                                         (float)(abscf(Transitions[ipISO][nelem][ipHi][ipLo].Emis.gf, 
    624                                                         Transitions[ipISO][nelem][ipHi][ipLo].EnergyWN, 
    625                                                         Transitions[ipISO][nelem][ipHi][ipLo].Lo.g)); 
    626                                                 Transitions[ipISO][nelem][ipHi][ipLo].Emis.opacity =  
    627                                                         MAX2(0.f, Transitions[ipISO][nelem][ipHi][ipLo].Emis.opacity ); 
    628654                                        } 
    629 #endif 
     655                                        iso.CascadeProb[ipISO][nelem][ipHi][ipLo] = RobbinsC[ipHi][ipLo]; 
     656                                        if( iso.lgRandErrGen[ipISO] ) 
    630657                                        { 
    631                                                 /* option to print particulars of some line when called 
    632