56 for (
int j = 0; j < 82; j++) {
60 plogf(
" --- Subroutine vcs_RxnStepSizes called - Details:\n");
62 for (
int j = 0; j < 82; j++) {
66 plogf(
" --- Species KMoles Rxn_Adjustment DeltaG"
83 sprintf(ANOTE,
"Normal Calc");
91 sprintf(ANOTE,
"ZeroedPhase: Phase is artificially zeroed");
120 "MultSpec (%s): Species not born due to STOICH/PHASEPOP even though DG = %11.3E",
128 "MultSpec (%s): small species born again DG = %11.3E",
135 sprintf(ANOTE,
"MultSpec (%s): phase come alive DG = %11.3E",
140 size_t numSpPhase = Vphase->
nSpecies();
147 sprintf(ANOTE,
"MultSpec (%s): still dead DG = %11.3E",
166 sprintf(ANOTE,
"Skipped: superconverged DG = %11.3E",
m_deltaGRxn_new[irxn]);
169 plogf(
" %12.4E %12.4E %12.4E | %s\n",
182 sprintf(ANOTE,
"Skipped: IC = %3d and DG >0: %11.3E",
186 plogf(
" %12.4E %12.4E %12.4E | %s\n",
227 sprintf(ANOTE,
"Normal calc: diag adjusted from %g "
228 "to %g due to act coeff", s_old, s);
242 sprintf(ANOTE,
"Delta damped from %g "
243 "to %g due to component %d (%10s) going neg", m_deltaMolNumSpecies[kspec],
249 sprintf(ANOTE,
"Delta damped from %g "
250 "to %g due to component %d (%10s) zero", m_deltaMolNumSpecies[kspec],
253 m_deltaMolNumSpecies[kspec] = 0.0;
261 sprintf(ANOTE,
"Delta damped from %g "
316 if ((k == kspec) && (
m_SSPhase[kspec] != 1)) {
324 sprintf(ANOTE,
"Delta damped from %g to %g due to delete %s",
332 plogf(
" %12.4E %12.4E %12.4E | %s\n",
355 sprintf(ANOTE,
"Delete component SS phase %d named %s - SS phases only",
358 sprintf(ANOTE,
"Delete this SS phase %d - SS components only", iphDel);
362 plogf(
" %12.4E %12.4E %12.4E | %s\n",
365 plogf(
" --- vcs_RxnStepSizes Special section to set up to delete %s",
371 forceComponentCalc = 1;
374 plogf(
" --- Force a component recalculation \n");
382 vcs_print_line(
"-", 82);
392 plogf(
" %12.4E %12.4E %12.4E | %s\n",
402 vcs_print_line(
"-", 82);
441 double* dnPhase_irxn;
445 for (j = 0; j < 77; j++) {
448 plogf(
"\n --- Subroutine rxn_adj_cg() called\n");
449 plogf(
" --- Species Moles Rxn_Adjustment | Comment\n");
460 sprintf(ANOTE,
"Normal Calc");
476 (void) sprintf(ANOTE,
"MultSpec: come alive DG = %11.3E",
m_deltaGRxn_new[irxn]);
483 (void) sprintf(ANOTE,
"MultSpec: still dead DG = %11.3E",
m_deltaGRxn_new[irxn]);
500 sprintf(ANOTE,
"Skipped: converged DG = %11.3E\n",
m_deltaGRxn_new[irxn]);
514 sprintf(ANOTE,
"Skipped: IC = %3d and DG >0: %11.3E\n",
600 plogf(
" --- vcs_st2 Special section to delete ");
602 plogf(
"\n --- Immediate return - Restart iteration\n");
637 for (j = 0; j < 77; j++) {
659 double diag = hessianDiag_Ideal;
661 if (hessianDiag_Ideal <= 0.0) {
662 plogf(
"vcs_Hessian_diag_adj::We shouldn't be here\n");
665 if (hessActCoef >= 0.0) {
667 }
else if (fabs(hessActCoef) < 0.6666 * hessianDiag_Ideal) {
670 diag -= 0.6666 * hessianDiag_Ideal;
685 size_t kspec, k, l, kph;
722 void VCS_SOLVE::vcs_CalcLnActCoeffJac(
const double*
const moleSpeciesVCS)
727 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
782 const size_t irxn,
const double*
const molNum,
783 double*
const ac,
double*
const mu_i)
787 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
788 if (pp_ptr[iphase]) {
792 double deltaG = mu_i[kspec];
795 deltaG += sc_irxn[k] * mu_i[k];
815 double VCS_SOLVE::vcs_line_search(
const size_t irxn,
const double dx_orig,
818 double VCS_SOLVE::vcs_line_search(
const size_t irxn,
const double dx_orig)
823 size_t kspec = m_indexRxnToSpecies[irxn];
824 const int MAXITS = 10;
826 double* sc_irxn = m_stoichCoeffRxnMatrix[irxn];
837 irxn, molNumBase, acBase,
839 double forig = fabs(deltaGOrig) + 1.0E-15;
840 if (deltaGOrig > 0.0) {
844 if (m_debug_print_lvl >= 2) {
847 sprintf(ANOTE,
"Rxn reduced to zero step size in line search: dx>0 dg > 0");
851 }
else if (deltaGOrig < 0.0) {
855 if (m_debug_print_lvl >= 2) {
858 sprintf(ANOTE,
"Rxn reduced to zero step size in line search: dx<0 dg < 0");
862 }
else if (deltaGOrig == 0.0) {
865 if (dx_orig == 0.0) {
869 vcs_dcopy(
VCS_DATA_PTR(m_molNumSpecies_new), molNumBase, m_numSpeciesRdc);
870 molSum = molNumBase[kspec];
871 m_molNumSpecies_new[kspec] = molNumBase[kspec] + dx_orig;
872 for (k = 0; k < m_numComponents; k++) {
873 m_molNumSpecies_new[k] = molNumBase[k] + sc_irxn[k] * dx_orig;
874 molSum += molNumBase[k];
887 if (deltaG1 * deltaGOrig > 0.0) {
895 if (fabs(deltaG1) < 0.8*forig) {
896 if (deltaG1 * deltaGOrig < 0.0) {
897 slope = (deltaG1 - deltaGOrig) / dx_orig;
898 dx = -deltaGOrig / slope;
907 for (its = 0; its < MAXITS; its++) {
913 m_molNumSpecies_new[kspec] = molNumBase[kspec] + dx;
914 for (k = 0; k < m_numComponents; k++) {
915 m_molNumSpecies_new[k] = molNumBase[k] + sc_irxn[k] * dx;
926 if (deltaG * deltaGOrig > 0.0) {
933 if (fabs(deltaG) / forig < (1.0 - 0.1 * dx / dx_orig)) {
934 if (deltaG * deltaGOrig < 0.0) {
935 slope = (deltaG - deltaGOrig) / dx;
936 dx = -deltaGOrig / slope;
946 sprintf(ANOTE,
"Rxn reduced to zero step size from %g to %g (MAXITS)",
953 sprintf(ANOTE,
"Line Search reduced step size from %g to %g",