void rmlasttag() { deltag(); ewmh_update_net_number_of_desktops(); ewmh_process_net_desktop_names(); ewmh_process_net_desktop_layout(); }
void settags(unsigned int numtags) { if (1 > numtags || scr->nmons > numtags || numtags > MAXTAGS) return; while (scr->ntags < numtags) addtag(); while (scr->ntags > numtags) deltag(); ewmh_update_net_number_of_desktops(); ewmh_process_net_desktop_names(); ewmh_process_net_desktop_layout(); }
/* ------------ estimates equilibrium compositions ------------ */ void inest(void) { double xt1[MAXPHASE], xt2[MAXPHASE], par,xl,ikl,s,s1; int i,j,k,lt,L; ikl = 0.0; lt = 0; /* -- setup data for linear programming routine --- */ /* -- we will use sc[][] temporaly as the linear programing matrix -- */ for ( i = 1; i <= ne; i++) sc[i][m+ne+1] = gai[i]; for ( j = 1; j <= m ; j++) for (i = 1; i <= ne; i++) sc[i][j] = bm[j][i]; /* transpose matrix */ for (j = 1; j <= m; j++) sc[ne+2][j] = ff[j]; /* changed -ff[j] to ff[j] and do minimising */ /* ------ insert linear prog here ---------- */ lin_prog(aw,sc); for (i = 1; i <= m; i++) { ds[i] = 0.0; w[i] = aw[i]; if (aw[i] == 0.0) w[i] = 1e-2; } for (i = 1; i <= m; i++) wt[i] = w[i]; basopt(FALSE); /* ----- calculate total gaseous and liquid moles ---- */ /* ----- chemical potentials of basis ---------------- */ for (i = 1; i <= no_phases; i++) tmole1[i] = tinert[i]; for (i = 1; i <= nc; i++) { if ( si[i] != SINGLE) tmole1[si[i]] += wt[i]; } for (i = 1; i <= nc; i++) { if ( si[i] != SINGLE) fe[i] = ff[i] + log((double)wt[i]/tmole1[si[i]]); /* check if tmole1[] could be zero */ } for (i = nc+1; i <= m; i++) fe[i] = ff[i]; deltag(0,1,n); /* ------ estimate reaction adjustments ---------- */ for (i = 1; i <= no_phases; i++) { delta_mole[i] = 0.0; if ( tmole1[i] != 0.0 ) { xt1[i] = log((double)1e32 * tmole1[i]); xt2[i] = log((double)1e-32 * tmole1[i]); } } /* ++++++ equation 3.4 in Canadian Jour of Chemical Engineer Vol 46 August 1968 +++++ */ for (i = 1; i <= nr; i++) { L = ir[i]; if ( si[L] != SINGLE ) { if ( dg[i] < xt1[si[L]] && dg[i] > xt2[si[L]] ) { ds[L] = tmole1[si[L]] * exp(-dg[i]); for (k = 1; k <= nc; k++) ds[k] += sc[k][i] * ds[L]; delta_mole[si[L]] += d_mole[si[L]][i] * ds[L]; } } } /* ------- keep basis specie positive ------------- */ par = 0.5; for (i = 1; i <= nc; i++) if ( par < (-ds[i]/wt[i]) ) par = -ds[i]/wt[i]; par = 1.0/par; if ( par <= 1.0 && par > 0.0 ) par = 0.8*par; else par = 1.0; /* ------- calculate new mole numbers ------------ */ while(TRUE) { for (i = 1; i <= nc; i++) w[i] = wt[i] + par*ds[i]; for (i = nc+1; i <= m; i++) if (ds[i] != 0.0 ) w[i] = ds[i]*par; for (i = 1; i <= no_phases; i++) tmole[i] = tmole1[i] + delta_mole[i]*par; if( lt > 0 ) return; /* ------- convergence - forcing section ---------- */ dfe(w,0,0); /* for tmole and components + all reactions */ s = 0.0; for (i = 1; i <= mr; i++) s += ds[i]*fe[i]; if ( s < 0.0 && ikl <= 0.0 ) return; else if ( s == 0.0 ) return; if ( ikl <= 0.0 ) { /* -- try half step size --- */ s1 = s; par *= 0.5; ikl = 1.0; } else { /* ---- fit parabola thro half and full steps ----- */ xl = 0.5 * (1.0 - s/(s1-s)); if ( xl >= 0.0 ) { if ( xl <= 1.0 ) par *= 2.0*xl; else /* too big a step, take orginal full step */ par *= 2.0; } else /* poor direction reduce step size */ par *= 0.2; lt = 1; } } }