Changeset 1681 for branches/newmole/source
- Timestamp:
- 12/16/07 06:22:43 (11 months ago)
- Location:
- branches/newmole/source
- Files:
-
- 3 modified
-
dynamics.cpp (modified) (4 diffs)
-
ion_solver.cpp (modified) (2 diffs)
-
mole_newton_step.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/newmole/source/dynamics.cpp
r1653 r1681 774 774 { 775 775 dynamics.Source[nelem][ion] = 0.; 776 dynamics.Source[nelem][dense.IonHigh[nelem]] += 777 UpstreamIon[nelem][ion] * scalingDensity() / timestep; 776 778 } 777 779 } … … 948 950 Old_molecules[ipUpstream][mol]/Old_density[ipUpstream])* 949 951 frac_next; 950 /* Atoms and positive ions are already counted in upstreamElem */952 /* Atoms and positive ions are already counted in UpstreamElem */ 951 953 if(COmole[mol]->n_nuclei != 1 || COmole[mol]->nElec < 0) 952 954 { … … 1506 1508 Oldi_ion = Old_xIonDense[ilast][nelem][ion]; 1507 1509 } 1508 dynamics.convergence_error += POW2( Oldi_ion/Oldi_density-struc.xIonDense[nelem][ion][i]/scalingZoneDensity(i)) /* *struc.dr[i] */;1510 dynamics.convergence_error += POW2((double)Oldi_ion/Oldi_density-struc.xIonDense[nelem][ion][i]/scalingZoneDensity(i)) /* *struc.dr[i] */; 1509 1511 1510 1512 /* >>chng 02 nov 11, add first error scale estimate from Robin */ 1511 dynamics.error_scale1 += POW2(struc.xIonDense[nelem][ion][i]/scalingZoneDensity(i)); 1513 //fprintf(ioQQQ,"%g %g %g\n",dynamics.error_scale1, 1514 // struc.xIonDense[nelem][ion][i],scalingZoneDensity(i)); 1515 dynamics.error_scale1 += POW2((double)struc.xIonDense[nelem][ion][i]/scalingZoneDensity(i)); 1512 1516 } 1513 1517 } … … 1524 1528 Oldi_mol = Old_molecules[ilast][mol]; 1525 1529 } 1526 dynamics.convergence_error += POW2( Oldi_mol/Oldi_density-struc.molecules[mol][i]/scalingZoneDensity(i)) /* *struc.dr[i] */;1530 dynamics.convergence_error += POW2((double)Oldi_mol/Oldi_density-struc.molecules[mol][i]/scalingZoneDensity(i)) /* *struc.dr[i] */; 1527 1531 1528 1532 /* >>chng 02 nov 11, add first error scale estimate from Robin 1529 1533 * used to normalize the above convergence_error */ 1530 dynamics.error_scale1 += POW2( struc.molecules[mol][i]/scalingZoneDensity(i));1534 dynamics.error_scale1 += POW2((double)struc.molecules[mol][i]/scalingZoneDensity(i)); 1531 1535 } 1532 1536 } -
branches/newmole/source/ion_solver.cpp
r1654 r1681 386 386 /* chng 03 jan 13 rjrw, add in dynamics if required here, 387 387 * last test - only do advection if we have not overrun the radius scale */ 388 if( iteration > dynamics.n_initial_relax+1 && dynamics.lgAdvection388 if( dynamics.lgAdvection && iteration > dynamics.n_initial_relax+1 389 389 /*&& radius.depth < dynamics.oldFullDepth*/ ) 390 390 { … … 758 758 759 759 renormnew = 1.; 760 /* >>chng 06 mar 17, comment out test on old full depth - keep old solution if overrun scale */761 if(iteration > dynamics.n_initial_relax+1 && dynamics.lgAdvection /*&& radius.depth < dynamics.oldFullDepth */)762 {763 /* The normalization out of the matrix solution is correct and764 * should be retained if: dynamics is on and the total765 * abundance of HI & H+ isn't being controlled by the766 * molecular network */767 renormnew = 1.;768 }769 else770 760 { 771 761 double dennew = 0., -
branches/newmole/source/mole_newton_step.cpp
r1680 r1681 7 7 /*lint -e725 expect positive indentation */ 8 8 #include "cddefines.h" 9 #include "dense.h" 9 10 #include "dynamics.h" 10 11 #include "mole.h" … … 33 34 34 35 static void updateMolecules(double *b2, double fion[LIMELM][N_MOLE_ION], realnum numelem[]); 35 staticvoid mole_eval_dynamic_balance(long int num_total, double *b, double **c);36 STATIC void mole_eval_dynamic_balance(long int num_total, double *b, double **c); 36 37 STATIC int32 solve_system(double *a, double *b, long int n); 37 38 … … 702 703 return; 703 704 } 704 705 void mole_eval_dynamic_balance(long int num_total, double *b, double **c) 705 STATIC void mole_eval_dynamic_balance(long int num_total, double *b, double **c) 706 706 { 707 long int i; 707 long int i, 708 ion, 709 nelem; 710 double 711 source; 708 712 709 713 DEBUG_ENTRY("mole_eval_dynamic_balance()"); 714 710 715 mole_eval_balance(num_total, b, c); 711 716 … … 714 719 { 715 720 /* Don't use conservation form in matrix solution -- dynamics rate terms make c[][] non-singular */ 721 716 722 for(i=0;i<mole.num_calc;i++) 717 723 { 718 724 if (c) 719 725 c[COmole[i]->index][COmole[i]->index] -= dynamics.Rate; 720 b[COmole[i]->index] -= (COmole[i]->hevmol-dynamics.molecules[i])*dynamics.Rate; 726 727 b[COmole[i]->index] -= COmole[i]->hevmol*dynamics.Rate; 728 729 if (COmole[i]->n_nuclei != 1 || COmole[i]->nElec < 0) 730 { 731 b[COmole[i]->index] += dynamics.molecules[i]*dynamics.Rate; 732 } 733 else if (COmole[i]->nElec == 0) 734 { 735 for ( nelem=ipHYDROGEN; nelem < LIMELM; nelem++) 736 if (COmole[i]->nElem[nelem] == 1) 737 break; 738 source = 0.0; 739 for ( ion=dense.IonLow[nelem]; ion<=dense.IonHigh[nelem]; ++ion ) 740 { 741 source += dynamics.Source[nelem][ion]; 742 if (ion >= N_MOLE_ION || element_list[nelem]->ipMl[ion] == -1) 743 source -= dense.xIonDense[nelem][ion]*dynamics.Rate; 744 } 745 b[COmole[i]->index] += source; 746 } 721 747 } 722 748 }
