Changeset 2000
- Timestamp:
- 04/30/08 16:02:48 (2 weeks ago)
- Files:
-
- branches/isodyn/source/atmdat_readin.cpp (modified) (2 diffs)
- branches/isodyn/source/dynamics.cpp (modified) (15 diffs)
- branches/isodyn/source/radius_increment.cpp (modified) (1 diff)
- branches/isodyn/source/state.cpp (modified) (1 diff)
- branches/isodyn/source/struc.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/isodyn/source/atmdat_readin.cpp
r1815 r2000 21 21 #include "hyperfine.h" 22 22 #include "atmdat.h" 23 #include "iso.h" 23 24 /* */ 24 25 /* this was needed to get array to crash out of bounds if not set. … … 303 304 } 304 305 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 305 323 /* some structure variables */ 306 324 for( i=0; i < struc.nzlim; i++ ) branches/isodyn/source/dynamics.cpp
r1775 r2000 36 36 #include "wind.h" 37 37 #include "hmi.h" 38 #include "iso.h" 38 39 #include "dynamics.h" 39 40 static int ipUpstream=0,iphUpstream=0,ipyUpstream=0; … … 57 58 * [element][ion] */ 58 59 static double **UpstreamIon; 60 static double ***UpstreamStatesElem; 59 61 /* total abundance of each element per hydrogen */ 60 62 static double *UpstreamElem; … … 135 137 /* the gas phase abundances from the previous iteration */ 136 138 static realnum **Old_gas_phase; 139 140 /* the iso levels from the previous iteration */ 141 static realnum ****Old_StatesElem; 137 142 138 143 /* the number of zones that were saved in the previous iteration */ … … 840 845 841 846 /* 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; 843 848 844 849 /* Properties for cell at present depth, used to converge timestep */ 845 double ynextfrac=-BIGFLOAT, yion, ymol ;850 double ynextfrac=-BIGFLOAT, yion, ymol, yiso; 846 851 847 852 long int nelem , ion, mol; … … 859 864 { 860 865 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 } 861 876 } 862 877 } … … 955 970 } 956 971 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 957 987 for(mol=0;mol<N_H_MOLEC;mol++) 958 988 { … … 1005 1035 Old_xIonDense[ipUpstream][nelem][ion]/Old_hden[ipUpstream]; 1006 1036 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 } 1007 1049 } 1008 1050 } … … 1134 1176 } 1135 1177 } 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 1136 1234 1137 1235 for(mol=0; mol < N_H_MOLEC; mol++) … … 1542 1640 Oldi_hden, 1543 1641 Oldi_ion, 1642 Oldi_iso, 1544 1643 Oldi_mol; 1545 1644 … … 1593 1692 /* >>chng 02 nov 11, add first error scale estimate from Robin */ 1594 1693 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 } 1595 1717 } 1596 1718 } … … 1698 1820 } 1699 1821 } 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 } 1700 1832 } 1701 1833 return; … … 1861 1993 Old_xIonDense = (realnum ***)MALLOC(sizeof(realnum **)*(unsigned)(struc.nzlim) ); 1862 1994 1995 Old_StatesElem = (realnum ****)MALLOC(sizeof(realnum ***)*(unsigned)(struc.nzlim) ); 1996 1863 1997 Old_gas_phase = (realnum **)MALLOC(sizeof(realnum *)*(unsigned)(struc.nzlim) ); 1864 1998 … … 1873 2007 (realnum**)MALLOC(sizeof(realnum*)*(unsigned)(LIMELM+3) ); 1874 2008 2009 Old_StatesElem[ns] = 2010 (realnum***)MALLOC(sizeof(realnum**)*(unsigned)(NISO) ); 2011 1875 2012 Old_gas_phase[ns] = 1876 2013 (realnum*)MALLOC(sizeof(realnum)*(unsigned)(LIMELM+3) ); … … 1886 2023 Old_xIonDense[ns][nelem] = 1887 2024 (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 } 1888 2035 } 1889 2036 } … … 1910 2057 { 1911 2058 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 } 1912 2069 } 1913 2070 } branches/isodyn/source/radius_increment.cpp
r1960 r2000 727 727 } 728 728 } 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 } 729 739 730 740 /* the hydrogen molecules */ branches/isodyn/source/state.cpp
r1815 r2000 324 324 } 325 325 } 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 } 326 336 327 337 /* the hydrogen molecules */ branches/isodyn/source/struc.h
r1732 r2000 62 62 realnum ***xIonDense; 63 63 64 /** save iso level array across model */ 65 realnum ****StatesElem; 66 64 67 /** the hydrogen molecules */ 65 68 /**realnum *Molec[N_H_MOLEC];*/
