Changeset 2000

Show
Ignore:
Timestamp:
04/30/08 16:02:48 (2 weeks ago)
Author:
rjrw
Message:

Initial read across of ion sources to isolevel sources.

Runs the smoke test without crashing, now need to correct for the
different basis of StatesElem? compared to xIonDense.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/isodyn/source/atmdat_readin.cpp

    r1815 r2000  
    2121#include "hyperfine.h" 
    2222#include "atmdat.h" 
     23#include "iso.h" 
    2324/* */ 
    2425/* this was needed to get array to crash out of bounds if not set. 
     
    303304        } 
    304305 
     306        struc.StatesElem = (realnum ****)MALLOC(sizeof(realnum ***)*(unsigned)(NISO) ); 
     307        for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     308        { 
     309                struc.StatesElem[ipISO] =  
     310                        (realnum***)MALLOC(sizeof(realnum**)*(unsigned)(LIMELM) ); 
     311                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     312                { 
     313                        struc.StatesElem[ipISO][nelem] =  
     314                                (realnum**)MALLOC(sizeof(realnum*)*(unsigned)iso.numLevels_max[ipISO][nelem]); 
     315                        for( long level=0; level < iso.numLevels_max[ipISO][nelem]; ++level ) 
     316                        { 
     317                                struc.StatesElem[ipISO][nelem][level] =  
     318                                        (realnum*)MALLOC(sizeof(realnum)*(unsigned)(struc.nzlim) ); 
     319                        } 
     320                } 
     321        } 
     322 
    305323        /* some structure variables */ 
    306324        for( i=0; i < struc.nzlim; i++ ) 
  • branches/isodyn/source/dynamics.cpp

    r1775 r2000  
    3636#include "wind.h" 
    3737#include "hmi.h" 
     38#include "iso.h" 
    3839#include "dynamics.h" 
    3940static int ipUpstream=0,iphUpstream=0,ipyUpstream=0; 
     
    5758 * [element][ion] */ 
    5859static double **UpstreamIon; 
     60static double ***UpstreamStatesElem; 
    5961/* total abundance of each element per hydrogen */ 
    6062static double *UpstreamElem; 
     
    135137/* the gas phase abundances from the previous iteration */ 
    136138static realnum **Old_gas_phase; 
     139 
     140/* the iso levels from the previous iteration */ 
     141static realnum ****Old_StatesElem; 
    137142 
    138143/* the number of zones that were saved in the previous iteration */ 
     
    840845 
    841846        /* Properties for cell half as far upstream, used to converge timestep */ 
    842         double hupstream, hnextfrac=-BIGFLOAT, hion, hmol
     847        double hupstream, hnextfrac=-BIGFLOAT, hion, hmol, hiso
    843848 
    844849        /* Properties for cell at present depth, used to converge timestep */ 
    845         double ynextfrac=-BIGFLOAT, yion, ymol
     850        double ynextfrac=-BIGFLOAT, yion, ymol, yiso
    846851 
    847852        long int nelem , ion, mol; 
     
    859864                        { 
    860865                                UpstreamIon[nelem][ion] = 0.; 
     866                        } 
     867                } 
     868                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     869                { 
     870                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     871                        { 
     872                                for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     873                                { 
     874                                        UpstreamStatesElem[ipISO][nelem][level] = 0.; 
     875                                } 
    861876                        } 
    862877                } 
     
    955970                } 
    956971 
     972                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     973                { 
     974                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     975                        { 
     976                                for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     977                                { 
     978                                        UpstreamStatesElem[ipISO][nelem][level] =  
     979                                                Old_StatesElem[ipUpstream][ipISO][nelem][level]/Old_hden[ipUpstream] + 
     980                                                (Old_StatesElem[ipUpstream+1][ipISO][nelem][level]/Old_hden[ipUpstream+1] -  
     981                                                 Old_StatesElem[ipUpstream][ipISO][nelem][level]/Old_hden[ipUpstream])* 
     982                                                frac_next; 
     983                                } 
     984                        } 
     985                } 
     986 
    957987                for(mol=0;mol<N_H_MOLEC;mol++) 
    958988                { 
     
    10051035                                        Old_xIonDense[ipUpstream][nelem][ion]/Old_hden[ipUpstream]; 
    10061036                                UpstreamElem[nelem] += UpstreamIon[nelem][ion]; 
     1037                        } 
     1038                } 
     1039 
     1040                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     1041                { 
     1042                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     1043                        { 
     1044                                for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     1045                                { 
     1046                                        UpstreamStatesElem[ipISO][nelem][level] =  
     1047                                                Old_StatesElem[ipUpstream][ipISO][nelem][level]/Old_hden[ipUpstream]; 
     1048                                } 
    10071049                        } 
    10081050                } 
     
    11341176                } 
    11351177        } 
     1178 
     1179        for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     1180        { 
     1181                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     1182                { 
     1183                        for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     1184                        { 
     1185                                double f1; 
     1186                                if(ipyUpstream != nOld_zone-1 && (Old_depth[ipyUpstream+1] - Old_depth[ipyUpstream]>SMALLFLOAT)) 
     1187                                { 
     1188                                        yiso =  
     1189                                                Old_StatesElem[ipyUpstream][ipISO][nelem][level]/Old_hden[ipyUpstream] + 
     1190                                                (Old_StatesElem[ipyUpstream+1][ipISO][nelem][level]/Old_hden[ipyUpstream+1] -  
     1191                                                 Old_StatesElem[ipyUpstream][ipISO][nelem][level]/Old_hden[ipyUpstream])* 
     1192                                                ynextfrac; 
     1193                                } 
     1194                                else 
     1195                                {                
     1196                                        yiso = Old_StatesElem[ipyUpstream][ipISO][nelem][level]/Old_hden[ipyUpstream]; 
     1197                                } 
     1198                                if(iphUpstream != nOld_zone-1 && (Old_depth[iphUpstream+1] - Old_depth[iphUpstream]>SMALLFLOAT)) 
     1199                                { 
     1200                                        hiso =  
     1201                                                Old_StatesElem[iphUpstream][ipISO][nelem][level]/Old_hden[iphUpstream] + 
     1202                                                (Old_StatesElem[iphUpstream+1][ipISO][nelem][level]/Old_hden[iphUpstream+1] -  
     1203                                                 Old_StatesElem[iphUpstream][ipISO][nelem][level]/Old_hden[iphUpstream])* 
     1204                                                hnextfrac; 
     1205                                } 
     1206                                else 
     1207                                {                
     1208                                        hiso = Old_StatesElem[iphUpstream][ipISO][nelem][level]/Old_hden[iphUpstream]; 
     1209                                } 
     1210 
     1211                                /* the proposed thickness of the next zone, there will be a scale factor, something 
     1212                                 * like 1/500, that will be applied when this is used in nextdr */ 
     1213                                f1 = fabs(yiso - UpstreamStatesElem[ipISO][nelem][level] ); 
     1214                                f1 = SDIV( f1 ); 
     1215                                dynamics.dRad = MIN2(dynamics.dRad,Dyn_dr *  
     1216                          /* don't pay attention to species with abundance relative to H less tghan 1e-6 */ 
     1217                                  MAX2(yiso + UpstreamStatesElem[ipISO][nelem][level],1e-6 ) / f1); 
     1218                                /*MAX2(fabs(yion - UpstreamIon[nelem][ion] ),SMALLFLOAT));*/ 
     1219                                /* printf("%d %d %g\n",nelem,ion,dynamics.dRad); */ 
     1220 
     1221                                /* Must be consistent with convergence_error below */ 
     1222                                /* >>chngf 01 aug 01, remove dense.gas_phase[ipHYDROGEN] from HAtom */ 
     1223                                /* >>chngf 02 aug 01, multiply by cell width */ 
     1224                                /* this error is error due to the advection length not being zero - a finite 
     1225                                 * advection length.  no need to bring convergence error to below 
     1226                                 * discretization error.  when convergece error is lower than a fraction of this 
     1227                                 * errror we reduce the advection length. */ 
     1228                                dynamics.discretization_error += POW2(yiso-2.*hiso+UpstreamStatesElem[ipISO][nelem][level]);  
     1229                                dynamics.error_scale2 += POW2(UpstreamStatesElem[ipISO][nelem][level]); 
     1230                        } 
     1231                } 
     1232        } 
     1233 
    11361234 
    11371235        for(mol=0; mol < N_H_MOLEC; mol++)  
     
    15421640                Oldi_hden, 
    15431641                Oldi_ion, 
     1642                Oldi_iso, 
    15441643                Oldi_mol; 
    15451644 
     
    15931692                                /* >>chng 02 nov 11, add first error scale estimate from Robin */ 
    15941693                                dynamics.error_scale1 += POW2(struc.xIonDense[nelem][ion][i]/struc.hden[i]);                     
     1694                        } 
     1695                } 
     1696                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     1697                { 
     1698                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     1699                        { 
     1700                                for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     1701                                { 
     1702                                        if(ilast != nOld_zone-1 && ((Old_depth[ilast+1] - Old_depth[ilast])> SMALLFLOAT) ) 
     1703                                        { 
     1704                                                Oldi_iso = (Old_StatesElem[ilast][ipISO][nelem][level] + 
     1705                                                  (Old_StatesElem[ilast+1][ipISO][nelem][level]-Old_StatesElem[ilast][ipISO][nelem][level])* 
     1706                                                                                                frac_next); 
     1707                                        } 
     1708                                        else 
     1709                                        { 
     1710                                                Oldi_iso = Old_StatesElem[ilast][ipISO][nelem][level]; 
     1711                                        } 
     1712                                        dynamics.convergence_error += POW2(Oldi_iso/Oldi_hden-struc.StatesElem[ipISO][nelem][level][i]/struc.hden[i]) /* *struc.dr[i] */;   
     1713 
     1714                                        /* >>chng 02 nov 11, add first error scale estimate from Robin */ 
     1715                                        dynamics.error_scale1 += POW2(struc.StatesElem[ipISO][nelem][level][i]/struc.hden[i]);                   
     1716                                } 
    15951717                        } 
    15961718                } 
     
    16981820                        } 
    16991821                } 
     1822                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     1823                { 
     1824                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     1825                        { 
     1826                                for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     1827                                {  
     1828                                        Old_StatesElem[i][ipISO][nelem][level] = struc.StatesElem[ipISO][nelem][level][i]; 
     1829                                } 
     1830                        } 
     1831                }                
    17001832        } 
    17011833        return; 
     
    18611993        Old_xIonDense = (realnum ***)MALLOC(sizeof(realnum **)*(unsigned)(struc.nzlim) ); 
    18621994 
     1995        Old_StatesElem = (realnum ****)MALLOC(sizeof(realnum ***)*(unsigned)(struc.nzlim) ); 
     1996 
    18631997        Old_gas_phase = (realnum **)MALLOC(sizeof(realnum *)*(unsigned)(struc.nzlim) ); 
    18641998 
     
    18732007                        (realnum**)MALLOC(sizeof(realnum*)*(unsigned)(LIMELM+3) ); 
    18742008 
     2009                Old_StatesElem[ns] =  
     2010                        (realnum***)MALLOC(sizeof(realnum**)*(unsigned)(NISO) ); 
     2011 
    18752012                Old_gas_phase[ns] =  
    18762013                        (realnum*)MALLOC(sizeof(realnum)*(unsigned)(LIMELM+3) ); 
     
    18862023                        Old_xIonDense[ns][nelem] =  
    18872024                                (realnum*)MALLOC(sizeof(realnum)*(unsigned)(LIMELM+1) ); 
     2025                } 
     2026                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     2027                { 
     2028                        Old_StatesElem[ns][ipISO] =  
     2029                                (realnum**)MALLOC(sizeof(realnum*)*(unsigned)(LIMELM) ); 
     2030                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     2031                        { 
     2032                                Old_StatesElem[ns][ipISO][nelem] =  
     2033                                        (realnum*)MALLOC(sizeof(realnum)*(unsigned)iso.numLevels_max[ipISO][nelem]); 
     2034                        } 
    18882035                } 
    18892036        } 
     
    19102057                        { 
    19112058                                Old_xIonDense[i][nelem][ion] = 0.; 
     2059                        } 
     2060                } 
     2061                for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     2062                { 
     2063                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     2064                        { 
     2065                                for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     2066                                { 
     2067                                        Old_StatesElem[i][ipISO][nelem][level] = 0.; 
     2068                                } 
    19122069                        } 
    19132070                } 
  • branches/isodyn/source/radius_increment.cpp

    r1960 r2000  
    727727                } 
    728728        } 
     729        for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     730        { 
     731                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     732                { 
     733                        for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     734                        { 
     735                                struc.StatesElem[ipISO][nelem][level][nzone_minus_1] = StatesElem[ipISO][nelem][level].Pop; 
     736                        } 
     737                } 
     738        } 
    729739 
    730740        /* the hydrogen molecules */ 
  • branches/isodyn/source/state.cpp

    r1815 r2000  
    324324                } 
    325325        } 
     326        for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     327        { 
     328                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 
     329                { 
     330                        for( long level=0; level < iso.numLevels_local[ipISO][nelem]; ++level ) 
     331                        { 
     332                                state_do( struc.StatesElem[ipISO][nelem][level] , (size_t)(struc.nzlim)*sizeof(realnum ) ); 
     333                        } 
     334                } 
     335        } 
    326336 
    327337        /* the hydrogen molecules */ 
  • branches/isodyn/source/struc.h

    r1732 r2000  
    6262        realnum ***xIonDense; 
    6363 
     64        /** save iso level array across model */ 
     65        realnum ****StatesElem; 
     66 
    6467        /** the hydrogen molecules */ 
    6568        /**realnum *Molec[N_H_MOLEC];*/